Skip to content
Snippets Groups Projects
Commit d7722cf0 authored by Moritz Strohm's avatar Moritz Strohm
Browse files

fixed Stud.IP 6.0 and PHP 8 problems, fixes #2

parent 523aaec7
No related branches found
No related tags found
No related merge requests found
Showing
with 254 additions and 223 deletions
...@@ -23,19 +23,19 @@ require_once(__DIR__ . '/classes/TandemMatching.class.php'); ...@@ -23,19 +23,19 @@ require_once(__DIR__ . '/classes/TandemMatching.class.php');
class TandemPlugin extends StudIPPlugin implements SystemPlugin, PortalPlugin class TandemPlugin extends StudIPPlugin implements SystemPlugin, PortalPlugin
{ {
public static function isGenderSearchEnabled() public static function isGenderSearchEnabled() : bool
{ {
return (bool)Config::get()->TANDEMPLUGIN_GENDER_SEARCH_ENABLED; return (bool)Config::get()->TANDEMPLUGIN_GENDER_SEARCH_ENABLED;
} }
public function isOldStudip() public function isOldStudip() : bool
{ {
return version_compare($GLOBALS['SOFTWARE_VERSION'], '5.0', '<'); return version_compare($GLOBALS['SOFTWARE_VERSION'], '5.0', '<');
} }
public function getLevels() public function getLevels() : array
{ {
return [ return [
'A1', 'A1',
...@@ -48,7 +48,7 @@ class TandemPlugin extends StudIPPlugin implements SystemPlugin, PortalPlugin ...@@ -48,7 +48,7 @@ class TandemPlugin extends StudIPPlugin implements SystemPlugin, PortalPlugin
} }
public function userHasAccess($user_id) public function userHasAccess($user_id) : bool
{ {
return !\TandemPlugin\BlocklistEntry::userIsBlocked($user_id); return !\TandemPlugin\BlocklistEntry::userIsBlocked($user_id);
} }
...@@ -180,7 +180,7 @@ class TandemPlugin extends StudIPPlugin implements SystemPlugin, PortalPlugin ...@@ -180,7 +180,7 @@ class TandemPlugin extends StudIPPlugin implements SystemPlugin, PortalPlugin
} }
public function cleanupTandemData($event, User $user) public function cleanupTandemData($event, User $user) : void
{ {
TandemUserMotherLanguage::deleteByUser_id($user->id); TandemUserMotherLanguage::deleteByUser_id($user->id);
...@@ -264,12 +264,14 @@ class TandemPlugin extends StudIPPlugin implements SystemPlugin, PortalPlugin ...@@ -264,12 +264,14 @@ class TandemPlugin extends StudIPPlugin implements SystemPlugin, PortalPlugin
if(count($profiles) == 0) { if(count($profiles) == 0) {
$template->set_attribute('never_used', true); $template->set_attribute('never_used', true);
} else { } else {
$pair_exist = [];
$match_count = []; $match_count = [];
$pair_requests = [];
$pairs = [];
$matches_exist = false; $matches_exist = false;
foreach($profiles as $profile) { foreach($profiles as $profile) {
$pairs[$profile->id] = TandemPair::findByProfileAndStatus($profile, 1)[0]; $pairs[$profile->id] = TandemPair::findByProfileAndStatus($profile)[0];
$pair_requests[$profile->id] = TandemPair::countByProfileAndStatus($profile, 0); $pair_requests[$profile->id] = TandemPair::countByProfileAndStatus($profile, 0);
if(!$pairs[$profile->id]) { if(!$pairs[$profile->id]) {
//We're only looking for matches if no pairs have been found. //We're only looking for matches if no pairs have been found.
......
...@@ -14,9 +14,6 @@ ...@@ -14,9 +14,6 @@
**/ **/
require_once('lib/classes/CronJob.class.php');
class TandemPluginCronjob extends CronJob class TandemPluginCronjob extends CronJob
{ {
public static function getName() public static function getName()
...@@ -33,7 +30,7 @@ class TandemPluginCronjob extends CronJob ...@@ -33,7 +30,7 @@ class TandemPluginCronjob extends CronJob
public function setUp() public function setUp()
{ {
global $STUDIP_BASE_PATH; global $STUDIP_BASE_PATH;
require_once($STUDIP_BASE_PATH . '/lib/classes/Config.class.php'); require_once($STUDIP_BASE_PATH . '/lib/classes/Config.php');
} }
......
...@@ -23,7 +23,7 @@ class TandemManager ...@@ -23,7 +23,7 @@ class TandemManager
/** /**
* Sends a match notification to the user who owns the tandem request. * Sends a match notification to the user who owns the tandem request.
*/ */
public static function sendMatchNotification(TandemProfile $request, TandemProfile $match) public static function sendMatchNotification(TandemProfile $request, TandemProfile $match) : void
{ {
$message_title = ''; $message_title = '';
$message_text = ''; $message_text = '';
...@@ -92,9 +92,10 @@ class TandemManager ...@@ -92,9 +92,10 @@ class TandemManager
* *
* @param TandemProfile $request The profile of the user who is applying for a tandem. * @param TandemProfile $request The profile of the user who is applying for a tandem.
* @param TandemProfile $offer The profile where the user applies for building a tandem. * @param TandemProfile $offer The profile where the user applies for building a tandem.
* @param User $user The user who applies for a tandem. *
* @returns bool True on success, false on failure.
*/ */
public static function applyForPair(TandemProfile $request, TandemProfile $offer) public static function applyForPair(TandemProfile $request, TandemProfile $offer) : bool
{ {
$pair = new TandemPair(); $pair = new TandemPair();
$pair->request_profile_id = $request->id; $pair->request_profile_id = $request->id;
...@@ -448,9 +449,9 @@ class TandemManager ...@@ -448,9 +449,9 @@ class TandemManager
* This method handles termination of a tandem pair. * This method handles termination of a tandem pair.
* *
* @return True on success, false on failure. * @return bool True on success, false on failure.
*/ */
public static function terminatePair(TandemPair $pair, User $user, $delete_users_profile = false) public static function terminatePair(TandemPair $pair, User $user, $delete_users_profile = false) : bool
{ {
$message_text = ''; $message_text = '';
$message_title = ''; $message_title = '';
...@@ -474,11 +475,7 @@ class TandemManager ...@@ -474,11 +475,7 @@ class TandemManager
$message_text = sprintf( $message_text = sprintf(
'%s has terminated the tandem for the language %s!', '%s has terminated the tandem for the language %s!',
( $user->getFullName(),
$user
? $user->getFullName()
: 'unknown'
),
($target_language->name_eng ($target_language->name_eng
? $target_language->name_eng ? $target_language->name_eng
: $target_language->name) : $target_language->name)
...@@ -491,11 +488,7 @@ class TandemManager ...@@ -491,11 +488,7 @@ class TandemManager
$message_text = sprintf( $message_text = sprintf(
'%s hat das Tandem für die Sprache %s aufgelöst!', '%s hat das Tandem für die Sprache %s aufgelöst!',
( $user->getFullName(),
$user
? $user->getFullName()
: 'unbekannt'
),
($target_language->name_ger ($target_language->name_ger
? $target_language->name_ger ? $target_language->name_ger
: $target_language->name) : $target_language->name)
......
...@@ -148,17 +148,26 @@ class AdminController extends PluginController ...@@ -148,17 +148,26 @@ class AdminController extends PluginController
} }
} }
$requester_sex = '?';
if ($pair->request->user->geschlecht == '1') {
$requester_sex = 'm';
} elseif ($pair->request->user->geschlecht == '2') {
$requester_sex = 'w';
}
$offerer_sex = '?';
if ($pair->offer->user->geschlecht == '1') {
$offerer_sex = 'm';
} elseif ($pair->offer->user->geschlecht == '2') {
$offerer_sex = 'w';
}
if (Config::get()->TANDEMPLUGIN_PROOF_FIELDS_ENABLED) { if (Config::get()->TANDEMPLUGIN_PROOF_FIELDS_ENABLED) {
$csv_data[] = [ $csv_data[] = [
$pair->request->user->nachname, $pair->request->user->nachname,
$pair->request->user->vorname, $pair->request->user->vorname,
$pair->request->user->email, $pair->request->user->email,
implode(',', $user1_study_names), implode(',', $user1_study_names),
(($pair->request->user->geschlecht == '1') $requester_sex,
? 'm'
: ($pair->request->user->geschlecht == '2')
? 'w'
: '?'),
$pair->offer->target_language_id, $pair->offer->target_language_id,
$pair->request->target_language_id, $pair->request->target_language_id,
$user1_proofs, $user1_proofs,
...@@ -167,11 +176,7 @@ class AdminController extends PluginController ...@@ -167,11 +176,7 @@ class AdminController extends PluginController
$pair->offer->user->vorname, $pair->offer->user->vorname,
$pair->offer->user->email, $pair->offer->user->email,
implode(',', $user2_study_names), implode(',', $user2_study_names),
(($pair->offer->user->geschlecht == '1') $offerer_sex,
? 'm'
: ($pair->offer->user->geschlecht == '2')
? 'w'
: '?'),
$pair->request->target_language_id, $pair->request->target_language_id,
$pair->offer->target_language_id, $pair->offer->target_language_id,
$user2_proofs, $user2_proofs,
...@@ -184,11 +189,7 @@ class AdminController extends PluginController ...@@ -184,11 +189,7 @@ class AdminController extends PluginController
$pair->request->user->vorname, $pair->request->user->vorname,
$pair->request->user->email, $pair->request->user->email,
implode(',', $user1_study_names), implode(',', $user1_study_names),
(($pair->request->user->geschlecht == '1') $requester_sex,
? 'm'
: ($pair->request->user->geschlecht == '2')
? 'w'
: '?'),
$pair->offer->target_language_id, $pair->offer->target_language_id,
$pair->request->target_language_id, $pair->request->target_language_id,
...@@ -196,11 +197,7 @@ class AdminController extends PluginController ...@@ -196,11 +197,7 @@ class AdminController extends PluginController
$pair->offer->user->vorname, $pair->offer->user->vorname,
$pair->offer->user->email, $pair->offer->user->email,
implode(',', $user2_study_names), implode(',', $user2_study_names),
(($pair->offer->user->geschlecht == '1') $offerer_sex,
? 'm'
: ($pair->offer->user->geschlecht == '2')
? 'w'
: '?'),
$pair->request->target_language_id, $pair->request->target_language_id,
$pair->offer->target_language_id, $pair->offer->target_language_id,
...@@ -250,10 +247,7 @@ class AdminController extends PluginController ...@@ -250,10 +247,7 @@ class AdminController extends PluginController
$this->terminated_pairs = []; $this->terminated_pairs = [];
$this->terminated_pairs = TerminatedTandemPair::findBySql( $this->terminated_pairs = TerminatedTandemPair::findBySql('TRUE ORDER BY `mkdate` DESC');
'TRUE ORDER BY mkdate DESC',
[]
);
if(Request::get('csv_export')) { if(Request::get('csv_export')) {
//A CSV file with all terminated pairs shall be created instead of //A CSV file with all terminated pairs shall be created instead of
...@@ -283,28 +277,32 @@ class AdminController extends PluginController ...@@ -283,28 +277,32 @@ class AdminController extends PluginController
} }
} }
$requester_sex = '?';
if ($pair->requester->geschlecht == '1') {
$requester_sex = 'm';
} elseif ($pair->requester->geschlecht == '2') {
$requester_sex = 'w';
}
$offerer_sex = '?';
if ($pair->offerer->geschlecht == '1') {
$offerer_sex = 'm';
} elseif ($pair->offerer->geschlecht == '2') {
$offerer_sex = 'w';
}
$csv_data[] = [ $csv_data[] = [
$pair->requester->nachname, $pair->requester->nachname,
$pair->requester->vorname, $pair->requester->vorname,
$pair->requester->email, $pair->requester->email,
implode(',', $user1_study_names), implode(',', $user1_study_names),
(($pair->requester->geschlecht == '1') $requester_sex,
? 'm'
: ($pair->requester->geschlecht == '2')
? 'w'
: '?'),
$pair->offerer_language_id, $pair->offerer_language_id,
$pair->requester_language_id, $pair->requester_language_id,
$pair->offerer->nachname, $pair->offerer->nachname,
$pair->offerer->vorname, $pair->offerer->vorname,
$pair->offerer->email, $pair->offerer->email,
implode(',', $user2_study_names), implode(',', $user2_study_names),
(($pair->offerer->geschlecht == '1') $offerer_sex,
? 'm'
: ($pair->offerer->geschlecht == '2')
? 'w'
: '?'),
$pair->requester_language_id, $pair->requester_language_id,
$pair->offerer_language_id, $pair->offerer_language_id,
...@@ -621,7 +619,7 @@ class AdminController extends PluginController ...@@ -621,7 +619,7 @@ class AdminController extends PluginController
} }
protected function validateFormFields() protected function validateFormFields() :bool
{ {
$name = Request::get('name'); $name = Request::get('name');
$name_ger = Request::get('name_ger'); $name_ger = Request::get('name_ger');
...@@ -824,7 +822,7 @@ class AdminController extends PluginController ...@@ -824,7 +822,7 @@ class AdminController extends PluginController
); );
$this->response->add_header('X-Dialog-Close', '1'); $this->response->add_header('X-Dialog-Close', '1');
} else { } else {
PageLayout::postFailure( PageLayout::postError(
sprintf( sprintf(
dgettext('TandemPlugin', 'Beim Hinzufügen von %s zur Blockliste trat ein Fehler auf.'), dgettext('TandemPlugin', 'Beim Hinzufügen von %s zur Blockliste trat ein Fehler auf.'),
$user->getFullName() $user->getFullName()
......
...@@ -22,9 +22,7 @@ require_once(__DIR__ . '/../models/TandemUserMotherLanguage.class.php'); ...@@ -22,9 +22,7 @@ require_once(__DIR__ . '/../models/TandemUserMotherLanguage.class.php');
class MyTandemsController extends PluginController class MyTandemsController extends PluginController
{ {
protected $utf8decode_xhr = true; protected function buildSidebar() : void
private function buildSidebar()
{ {
$sidebar = Sidebar::get(); $sidebar = Sidebar::get();
...@@ -82,6 +80,8 @@ class MyTandemsController extends PluginController ...@@ -82,6 +80,8 @@ class MyTandemsController extends PluginController
Navigation::activateItem('/profile/my_tandems/index'); Navigation::activateItem('/profile/my_tandems/index');
} }
$this->first_run = false;
$this->mother_languages = TandemUserMotherLanguage::findByUser_id( $this->mother_languages = TandemUserMotherLanguage::findByUser_id(
$this->user->id $this->user->id
); );
...@@ -174,12 +174,12 @@ class MyTandemsController extends PluginController ...@@ -174,12 +174,12 @@ class MyTandemsController extends PluginController
if (Request::submitted('manage')) { if (Request::submitted('manage')) {
//check for added, edited and deleted entries: //check for added, edited and deleted entries:
$ids = Request::getArray('ids', []); $ids = Request::getArray('ids');
$language_ids = Request::getArray('language_ids', []); $language_ids = Request::getArray('language_ids');
$countries = Request::getArray('countries', []); $countries = Request::getArray('countries');
$regions = Request::getArray('regions', []); $regions = Request::getArray('regions');
$status = Request::getArray('status', []); $status = Request::getArray('status');
$levels = Request::getArray('level', []); $levels = Request::getArray('level');
$processed_language_ids = []; //array of languages that were processed $processed_language_ids = []; //array of languages that were processed
$duplicate_language = false; $duplicate_language = false;
......
...@@ -276,7 +276,7 @@ class PairController extends PluginController ...@@ -276,7 +276,7 @@ class PairController extends PluginController
return; return;
} }
//Check, if the "offerer" (the opposite person) has made an request //Check, if the "offerer" (the opposite person) has made a request
//for the current user's request. //for the current user's request.
//This would mean the current user can simply accept or reject the offer //This would mean the current user can simply accept or reject the offer
//from the "offerer". //from the "offerer".
...@@ -589,7 +589,7 @@ class PairController extends PluginController ...@@ -589,7 +589,7 @@ class PairController extends PluginController
$result = TandemManager::terminatePair( $result = TandemManager::terminatePair(
$pair, $pair,
$user, $user,
(($pair->request->user_id == $user->id) ? true : false) ($pair->request->user_id === $user->id)
); );
if($result) { if($result) {
......
...@@ -23,9 +23,6 @@ require_once(__DIR__ . '/../classes/TandemManager.class.php'); ...@@ -23,9 +23,6 @@ require_once(__DIR__ . '/../classes/TandemManager.class.php');
class ProfileController extends PluginController class ProfileController extends PluginController
{ {
protected $utf8decode_xhr = true;
public function before_filter(&$action, &$args) public function before_filter(&$action, &$args)
{ {
parent::before_filter($action, $args); parent::before_filter($action, $args);
...@@ -38,8 +35,11 @@ class ProfileController extends PluginController ...@@ -38,8 +35,11 @@ class ProfileController extends PluginController
} }
private function addEditHandler($edit_mode = false) private function addEditHandler($edit_mode = false) : void
{ {
$this->hide_form = false;
$this->pair_exists = false;
//load the list of languages: //load the list of languages:
$this->language_list = TandemLanguage::findBySql('TRUE'); $this->language_list = TandemLanguage::findBySql('TRUE');
...@@ -57,7 +57,7 @@ class ProfileController extends PluginController ...@@ -57,7 +57,7 @@ class ProfileController extends PluginController
if ($edit_mode) { if ($edit_mode) {
//In edit mode we have to check, if the tandem profile referenced by its //In edit mode we have to check, if the tandem profile referenced by its
//ID exists in the database: //ID exists in the database:
if(!$this->tandem_profile) { if ($this->tandem_profile->isNew()) {
PageLayout::postError( PageLayout::postError(
dgettext('TandemPlugin', 'Das ausgewählte Profil wurde nicht in der Datenbank gefunden!') dgettext('TandemPlugin', 'Das ausgewählte Profil wurde nicht in der Datenbank gefunden!')
); );
...@@ -78,15 +78,15 @@ class ProfileController extends PluginController ...@@ -78,15 +78,15 @@ class ProfileController extends PluginController
} }
if($edit_mode) { if($edit_mode) {
$this->pair_exists = (TandemPair::countByProfileAndStatus($this->tandem_profile, 1) > 0); $this->pair_exists = (TandemPair::countByProfileAndStatus($this->tandem_profile) > 0);
} }
if(Request::submitted('save')) { if(Request::submitted('save')) {
//A tandem profile shall be saved. //A tandem profile shall be saved.
//Read all attributes: //Read all attributes:
$this->target_language_id = Request::get('target_language_id', null); $this->target_language_id = Request::get('target_language_id');
$this->level = Request::get('level', null); $this->level = Request::get('level');
$this->requested_level = Config::get()->TANDEMPLUGIN_USE_LEVEL $this->requested_level = Config::get()->TANDEMPLUGIN_USE_LEVEL
? Request::get('requested_level', '') ? Request::get('requested_level', '')
: ''; : '';
...@@ -181,7 +181,7 @@ class ProfileController extends PluginController ...@@ -181,7 +181,7 @@ class ProfileController extends PluginController
$result = $this->tandem_profile->store(); $result = $this->tandem_profile->store();
} }
if($result == true) { if ($result) {
//Saving was successful. We can now look for matches. //Saving was successful. We can now look for matches.
$matches = TandemMatching::findMatches( $matches = TandemMatching::findMatches(
$this->tandem_profile $this->tandem_profile
...@@ -206,7 +206,7 @@ class ProfileController extends PluginController ...@@ -206,7 +206,7 @@ class ProfileController extends PluginController
} }
} }
$pair_exists = (TandemPair::countByProfileAndStatus($this->tandem_profile, 1) > 0); $pair_exists = (TandemPair::countByProfileAndStatus($this->tandem_profile) > 0);
if($pair_exists) { if($pair_exists) {
PageLayout::postSuccess( PageLayout::postSuccess(
...@@ -300,7 +300,7 @@ class ProfileController extends PluginController ...@@ -300,7 +300,7 @@ class ProfileController extends PluginController
PageLayout::setTitle( PageLayout::setTitle(
dgettext('TandemPlugin', 'Profil hinzufügen') dgettext('TandemPlugin', 'Profil hinzufügen')
); );
$this->addEditHandler(false); $this->addEditHandler();
} }
......
...@@ -17,12 +17,13 @@ ...@@ -17,12 +17,13 @@
class Initial extends Migration class Initial extends Migration
{ {
private static $cronjob = array( protected string $cronjob_md5 = '';
private static array $cronjob = [
'filename' => 'public/plugins_packages/data-quest/TandemPlugin/TandemPluginCronjob.class.php', 'filename' => 'public/plugins_packages/data-quest/TandemPlugin/TandemPluginCronjob.class.php',
'class' => 'TandemPluginCronjob', 'class' => 'TandemPluginCronjob',
'priority' => 'normal',
'execution_interval' => ['3', '0'] //at 3:00 every day 'execution_interval' => ['3', '0'] //at 3:00 every day
); ];
public function __construct() public function __construct()
...@@ -30,7 +31,6 @@ class Initial extends Migration ...@@ -30,7 +31,6 @@ class Initial extends Migration
$this->cronjob_md5 = md5( $this->cronjob_md5 = md5(
self::$cronjob['filename'] . self::$cronjob['filename'] .
self::$cronjob['class'] . self::$cronjob['class'] .
self::$cronjob['priority'] .
self::$cronjob['execution_interval'] self::$cronjob['execution_interval']
); );
...@@ -145,12 +145,12 @@ class Initial extends Migration ...@@ -145,12 +145,12 @@ class Initial extends Migration
$db->exec( $db->exec(
"INSERT INTO `cronjobs_schedules` "INSERT INTO `cronjobs_schedules`
(`schedule_id`, `task_id`, `active`, `parameters`, `priority`, (`schedule_id`, `task_id`, `active`, `parameters`,
`type`, `hour`, `minute`, `mkdate`, `chdate`, `last_result`) `hour`, `minute`, `mkdate`, `chdate`, `last_result`)
VALUES VALUES
('".$schedule_id."', '" ('".$schedule_id."', '"
.$this->cronjob_md5."', '1', '[]', '".self::$cronjob['priority'] .$this->cronjob_md5."', '1', '[]', "
."', 'periodic', '".self::$cronjob['execution_interval'][0] ."'".self::$cronjob['execution_interval'][0]
."', '" . self::$cronjob['execution_interval'][1] ."', '" . self::$cronjob['execution_interval'][1]
."', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), NULL)" ."', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), NULL)"
); );
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
class AddData extends Migration class AddData extends Migration
{ {
private $languages = [ private array $languages = [
["ara", "Arabic", "Arabisch"], ["ara", "Arabic", "Arabisch"],
["chi", "Chinese", "Chinesisch"], ["chi", "Chinese", "Chinesisch"],
["dan", "Danish", "Dänisch"], ["dan", "Danish", "Dänisch"],
......
...@@ -53,7 +53,7 @@ class BlocklistEntry extends \SimpleORMap ...@@ -53,7 +53,7 @@ class BlocklistEntry extends \SimpleORMap
} }
public static function userIsBlocked($user_id) public static function userIsBlocked($user_id) : bool
{ {
return self::countByUser_id($user_id) > 0; return self::countByUser_id($user_id) > 0;
} }
......
...@@ -14,9 +14,6 @@ ...@@ -14,9 +14,6 @@
**/ **/
require_once(__DIR__ . '/TandemData.class.php');
/** /**
* A model class to store tandem offers for the TandemPlugin. * A model class to store tandem offers for the TandemPlugin.
* *
...@@ -84,9 +81,10 @@ require_once(__DIR__ . '/TandemData.class.php'); ...@@ -84,9 +81,10 @@ require_once(__DIR__ . '/TandemData.class.php');
if(count($correct_levels)) { if(count($correct_levels)) {
//at least one given level was correct: //at least one given level was correct:
$sql .= "AND tandem_offers.level IN ( '" . implode($correct_levels, "','") . "') $sql .= "AND tandem_offers.level IN ( :correct_levels )'
ORDER BY FIELD(tandem_offers.level, '" ORDER BY FIELD(tandem_offers.level, '"
. implode($correct_levels, "','") . "'), mkdate "; . implode( "','", $correct_levels) . "'), mkdate ";
$sql_params['correct_levels'] = $correct_levels;
} }
} else { } else {
//Only one level in array: //Only one level in array:
...@@ -124,7 +122,7 @@ require_once(__DIR__ . '/TandemData.class.php'); ...@@ -124,7 +122,7 @@ require_once(__DIR__ . '/TandemData.class.php');
static public function countByTandemDataAndLevel(TandemData $tandem_data, Array $levels) static public function countByTandemDataAndLevel(TandemData $tandem_data, Array $levels)
{ {
$query = self::sqlForTandemDataAndLevel($tandem_data, $levels, $limit); $query = self::sqlForTandemDataAndLevel($tandem_data, $levels);
return self::countBySql($query['sql'], $query['params']); return self::countBySql($query['sql'], $query['params']);
} }
} }
...@@ -33,8 +33,8 @@ require_once(__DIR__ . '/TerminatedTandemPair.class.php'); ...@@ -33,8 +33,8 @@ require_once(__DIR__ . '/TerminatedTandemPair.class.php');
* 0: undecided/unanswered, 1: accepted, -1: rejected * 0: undecided/unanswered, 1: accepted, -1: rejected
* @property string mkdate database column * @property string mkdate database column
* @property string chdate database column * @property string chdate database column
* @property TandemRequest request belongs to TandemRequest * @property TandemProfile request belongs to TandemProfile
* @property TandemOffer offer belongs to TandemOffer * @property TandemProfile offer belongs to TandemProfile
*/ */
class TandemPair extends SimpleORMap class TandemPair extends SimpleORMap
{ {
...@@ -63,7 +63,7 @@ require_once(__DIR__ . '/TerminatedTandemPair.class.php'); ...@@ -63,7 +63,7 @@ require_once(__DIR__ . '/TerminatedTandemPair.class.php');
* Finds tandem pairs by looking at the tandem requests and * Finds tandem pairs by looking at the tandem requests and
* tandem offers bound to tandem pairs. * tandem offers bound to tandem pairs.
*/ */
static public function findByUserId($user_id = null, Array $status = []) static public function findByUserId($user_id = null, Array $status = []) : array
{ {
if($user_id == null) { if($user_id == null) {
return []; return [];
...@@ -118,7 +118,7 @@ require_once(__DIR__ . '/TerminatedTandemPair.class.php'); ...@@ -118,7 +118,7 @@ require_once(__DIR__ . '/TerminatedTandemPair.class.php');
/** /**
* Returns the number of pairs for a given status and a given profile. * Returns the number of pairs for a given status and a given profile.
*/ */
static public function countByProfileAndStatus(TandemProfile $profile, $status = 1) static public function countByProfileAndStatus(TandemProfile $profile, $status = 1) : int
{ {
return self::countBySql( return self::countBySql(
'(request_profile_id = :profile_id OR offer_profile_id = :profile_id) '(request_profile_id = :profile_id OR offer_profile_id = :profile_id)
...@@ -131,7 +131,7 @@ require_once(__DIR__ . '/TerminatedTandemPair.class.php'); ...@@ -131,7 +131,7 @@ require_once(__DIR__ . '/TerminatedTandemPair.class.php');
} }
public function getStatusNameForUser(User $user) public function getStatusNameForUser(User $user) : string
{ {
if($this->status == 0) { if($this->status == 0) {
if($this->request->user_id == $user->id) { if($this->request->user_id == $user->id) {
...@@ -159,7 +159,7 @@ require_once(__DIR__ . '/TerminatedTandemPair.class.php'); ...@@ -159,7 +159,7 @@ require_once(__DIR__ . '/TerminatedTandemPair.class.php');
* *
* @returns TerminatedTandemPair|null A TerminatedTandemPair object or null on failure. * @returns TerminatedTandemPair|null A TerminatedTandemPair object or null on failure.
*/ */
public function createTerminatedTandemPair() public function createTerminatedTandemPair() : ?TerminatedTandemPair
{ {
if (!$this->request->user_id || !$this->offer->user_id) { if (!$this->request->user_id || !$this->offer->user_id) {
return null; return null;
......
...@@ -56,7 +56,7 @@ require_once(__DIR__ . '/TandemUserMotherLanguage.class.php'); ...@@ -56,7 +56,7 @@ require_once(__DIR__ . '/TandemUserMotherLanguage.class.php');
parent::configure($config); parent::configure($config);
} }
public function getTargetName() public function getTargetName() : string
{ {
return $this->target_language->getLocalName() return $this->target_language->getLocalName()
. ' (' . ' ('
...@@ -67,7 +67,7 @@ require_once(__DIR__ . '/TandemUserMotherLanguage.class.php'); ...@@ -67,7 +67,7 @@ require_once(__DIR__ . '/TandemUserMotherLanguage.class.php');
} }
public function matchesSpokenLanguages(string $user_id) public function matchesSpokenLanguages(string $user_id) : bool
{ {
return TandemUserMotherLanguage::countBySql( return TandemUserMotherLanguage::countBySql(
'user_id = :user_id 'user_id = :user_id
......
...@@ -52,7 +52,7 @@ require_once(__DIR__ . '/TandemLanguage.class.php'); ...@@ -52,7 +52,7 @@ require_once(__DIR__ . '/TandemLanguage.class.php');
} }
static public function findSortedByName($user_id = null) static public function findSortedByName($user_id = null) : array
{ {
if(!$user_id) { if(!$user_id) {
return []; return [];
...@@ -85,7 +85,7 @@ require_once(__DIR__ . '/TandemLanguage.class.php'); ...@@ -85,7 +85,7 @@ require_once(__DIR__ . '/TandemLanguage.class.php');
} elseif($this->country && $this->region) { } elseif($this->country && $this->region) {
$html .= sprintf('(%1$s, %2$s)', htmlReady($this->country), htmlReady($this->region)); $html .= sprintf('(%1$s, %2$s)', htmlReady($this->country), htmlReady($this->region));
} elseif($this->region) { } elseif($this->region) {
$html .= sprintf('(%s)', htmlReady($uml->region)); $html .= sprintf('(%s)', htmlReady($this->region));
} }
} }
if (Config::get()->TANDEMPLUGIN_USE_LEVEL && $this->level) { if (Config::get()->TANDEMPLUGIN_USE_LEVEL && $this->level) {
......
pluginname=TandemPlugin pluginname=TandemPlugin
pluginclassname=TandemPlugin pluginclassname=TandemPlugin
origin=data-quest origin=data-quest
version=1.5.5-rc1 version=1.6
description=Dieses Plugin ermöglicht es, Sprachtandems innerhalb der Stud.IP Platform zu bilden. description=Dieses Plugin ermöglicht es, Sprachtandems innerhalb der Stud.IP Platform zu bilden.
studipMinVersion=5.0 studipMinVersion=5.5
studipMaxVersion=5.9.99 studipMaxVersion=6.0.99
<?php
/**
* @var bool $never_used
* @var TandemProfile[] $profiles
* @var TandemPair[] $pairs
* @var string $current_user_id
* @var array $pair_requests
* @var array $match_count
*/
?>
<section class="contentbox"> <section class="contentbox">
<section> <section>
<a href="<?= PluginEngine::getLink('tandemplugin/my_tandems/index') ?>"> <a href="<?= PluginEngine::getLink('tandemplugin/my_tandems/index') ?>">
<? if($never_used): ?> <?php if ($never_used) : ?>
<?= dgettext('TandemPlugin', 'Hier klicken, um ein Sprachtandem zu finden!') ?> <?= dgettext('TandemPlugin', 'Hier klicken, um ein Sprachtandem zu finden!') ?>
<? else: ?> <?php else : ?>
<table class="default"> <table class="default">
<? foreach($profiles as $profile): ?> <?php foreach($profiles as $profile) : ?>
<tr> <tr>
<td> <td>
<strong style="display:block;"><?= htmlReady($profile->target_language->getLocalName()) ?></strong>(<?= htmlReady($profile->level) ?>) <strong style="display:block;"><?= htmlReady($profile->target_language->getLocalName()) ?></strong>(<?= htmlReady($profile->level) ?>)
</td> </td>
<td> <td>
<? if($pairs[$profile->id]): ?> <?php if ($pairs[$profile->id]) : ?>
<?= sprintf( <?= sprintf(
dgettext('TandemPlugin', 'Bestehendes Tandem mit %s'), dgettext('TandemPlugin', 'Bestehendes Tandem mit %s'),
($pairs[$profile->id]->request->user_id == $current_user_id) ($pairs[$profile->id]->request->user_id == $current_user_id)
...@@ -22,34 +32,34 @@ ...@@ -22,34 +32,34 @@
: dgettext('TandemPlugin', 'unbekannt') : dgettext('TandemPlugin', 'unbekannt')
) )
) ?> ) ?>
<? elseif($pair_requests[$profile->id] > 0): ?> <?php elseif ($pair_requests[$profile->id] > 0) : ?>
<? if($pair_requests[$profile->id] == 1): ?> <?php if($pair_requests[$profile->id] == 1) : ?>
<?= dgettext('TandemPlugin', 'Es gibt eine Anfrage zur Tandem-Bildung!') ?> <?= dgettext('TandemPlugin', 'Es gibt eine Anfrage zur Tandem-Bildung!') ?>
<? else: ?> <?php else : ?>
<?= sprintf( <?= sprintf(
dgettext('TandemPlugin', 'Es gibt %s Anfragen zur Tandem-Bildung!'), dgettext('TandemPlugin', 'Es gibt %s Anfragen zur Tandem-Bildung!'),
$pair_requests[$profile->id] $pair_requests[$profile->id]
) ?> ) ?>
<? endif ?> <?php endif ?>
<? else: ?> <?php else : ?>
<? if($match_count[$profile->id] > 0): ?> <?php if ($match_count[$profile->id] > 0) : ?>
<?= dgettext('TandemPlugin', 'Es wurden passende Sprachtandem-Angebote gefunden!') ?> <?= dgettext('TandemPlugin', 'Es wurden passende Sprachtandem-Angebote gefunden!') ?>
<? else: ?> <?php else : ?>
<?= dgettext('TandemPlugin', 'Die Tandemsuche läuft. Im Moment liegen keine Angebote vor.') ?> <?= dgettext('TandemPlugin', 'Die Tandemsuche läuft. Im Moment liegen keine Angebote vor.') ?>
<? endif ?> <?php endif ?>
<? endif ?> <?php endif ?>
</td> </td>
</tr> </tr>
<? endforeach ?> <?php endforeach ?>
</table> </table>
<? endif ?> <?php endif ?>
</a> </a>
</section> </section>
<? if(!empty($profiles)): ?> <?php if(!empty($profiles)) : ?>
<section> <section>
<a href="<?= PluginEngine::getLink('tandemplugin/my_tandems/index') ?>"> <a href="<?= PluginEngine::getLink('tandemplugin/my_tandems/index') ?>">
<?= dgettext('TandemPlugin', 'Hier klicken, um weitere Sprachtandems anzulegen!') ?> <?= dgettext('TandemPlugin', 'Hier klicken, um weitere Sprachtandems anzulegen!') ?>
</a> </a>
</section> </section>
<? endif ?> <?php endif ?>
</section> </section>
<?php
/**
* @var TandemProfile $profile
* @var string[] $highlighted_languages
*/
?>
<?= Avatar::getAvatar($profile->user_id)->getImageTag( <?= Avatar::getAvatar($profile->user_id)->getImageTag(
Avatar::MEDIUM, Avatar::MEDIUM,
['style' => 'float:left; margin-right: 0.5em;'] ['style' => 'float:left; margin-right: 0.5em;']
) ?> ) ?>
<div style="float:left;"> <div style="float:left;">
<? if ($profile->user): ?> <?php if ($profile->user) : ?>
<a href="<?= URLHelper::getLink( <a href="<?= URLHelper::getLink(
'dispatch.php/profile', 'dispatch.php/profile',
['username' => $profile->user->username] ['username' => $profile->user->username]
) ?>"> ) ?>">
<strong><?= htmlReady($profile->user->getFullName()) ?></strong> <strong><?= htmlReady($profile->user->getFullName()) ?></strong>
</a> </a>
<? else: ?> <?php else : ?>
<strong><?= dgettext('TandemPlugin', 'unbekannt') ?></strong> <strong><?= dgettext('TandemPlugin', 'unbekannt') ?></strong>
<? endif ?> <?php endif ?>
<? if($established_pair or $admin_view): ?> <?php if (!empty($established_pair) || !empty($admin_view)) : ?>
<? if ($profile->user) : ?> <?php if ($profile->user) : ?>
<a href="<?= URLHelper::getLink( <a href="<?= URLHelper::getLink(
'dispatch.php/messages/write', 'dispatch.php/messages/write',
['rec_uname' => $profile->user->username] ['rec_uname' => $profile->user->username]
) ?>" data-dialog> ) ?>" data-dialog>
<?= Icon::create('mail', 'clickable')->asImg('20px', ['class' => 'text-bottom']) ?> <?= Icon::create('mail', 'clickable')->asImg('20px', ['class' => 'text-bottom']) ?>
</a> </a>
<? endif ?> <?php endif ?>
<? endif ?> <?php endif ?>
<div> <div>
<? if ($profile->user): ?> <?php if ($profile->user) : ?>
<strong><?= dgettext('TandemPlugin', 'Geschlecht') ?>:</strong> <strong><?= dgettext('TandemPlugin', 'Geschlecht') ?>:</strong>
<?= ($profile->user->geschlecht == '1') <?= ($profile->user->geschlecht == '1')
? dgettext('TandemPlugin', 'männlich') ? dgettext('TandemPlugin', 'männlich')
: (($profile->user->geschlecht == '2') : (($profile->user->geschlecht == '2')
? dgettext('TandemPlugin', 'weiblich') ? dgettext('TandemPlugin', 'weiblich')
: dgettext('TandemPlugin', 'Keine Angabe')) ?> : dgettext('TandemPlugin', 'Keine Angabe')) ?>
<? endif ?> <?php endif ?>
</div> </div>
<? $study_names = null; ?> <?php
<? if ($profile->user): ?> $study_names = null;
<? if($profile->user->studycourses): ?> ?>
<? $study_names = []; <?php if ($profile->user) : ?>
<?php if($profile->user->studycourses) : ?>
<?php
$study_names = [];
foreach ($profile->user->studycourses as $studycourse) { foreach ($profile->user->studycourses as $studycourse) {
$study_names[] = $studycourse->studycourse->name; $study_names[] = $studycourse->studycourse->name;
} ?> }
<? endif ?> ?>
<? endif ?> <?php endif ?>
<?php endif ?>
<div> <div>
<strong><?= dgettext('TandemPlugin', 'Studiengänge') ?>:</strong> <strong><?= dgettext('TandemPlugin', 'Studiengänge') ?>:</strong>
<?= ($study_names <?= ($study_names
...@@ -51,52 +61,52 @@ ...@@ -51,52 +61,52 @@
: dgettext('TandemPlugin', 'Keine Angabe')) ?> : dgettext('TandemPlugin', 'Keine Angabe')) ?>
</div> </div>
<? if($established_pair or $admin_view): ?> <?php if (!empty($established_pair) || !empty($admin_view)) : ?>
<? if($highlighted_languages): ?> <?php if (!empty($highlighted_languages)) : ?>
<div> <div>
<strong><?= htmlReady($highlighted_languages[0]) ?></strong> <strong><?= htmlReady($highlighted_languages[0]) ?></strong>
<?= Icon::create('group', 'info')->asImg('16px', ['class' => 'text-bottom']) ?> <?= Icon::create('group', 'info')->asImg('16px', ['class' => 'text-bottom']) ?>
<?= htmlReady($profile->getTargetName()) ?> <?= htmlReady($profile->getTargetName()) ?>
</div> </div>
<? endif ?> <?php endif ?>
<? else: ?> <?php else : ?>
<div> <div>
<strong><?= dgettext('TandemPlugin', 'Sucht') ?>:</strong> <strong><?= dgettext('TandemPlugin', 'Sucht') ?>:</strong>
<?= htmlReady($profile->getTargetName()) ?> <?= htmlReady($profile->getTargetName()) ?>
</div> </div>
<div> <div>
<strong><?= dgettext('TandemPlugin', 'Spricht') ?>:</strong> <strong><?= dgettext('TandemPlugin', 'Spricht') ?>:</strong>
<? $user_mother_languages = TandemUserMotherLanguage::findSortedByName($profile->user_id) ?> <?php $user_mother_languages = TandemUserMotherLanguage::findSortedByName($profile->user_id) ?>
<? foreach($user_mother_languages as $uml): ?> <?php foreach($user_mother_languages as $uml) : ?>
<span style="white-space: nowrap;"> <span style="white-space: nowrap;">
<?= $uml->render( <?= $uml->render(
$highlighted_languages && in_array($uml->language->getLocalName(), $highlighted_languages), $highlighted_languages && in_array($uml->language->getLocalName(), $highlighted_languages),
true true
) ?> ) ?>
</span> </span>
<? endforeach ?> <?php endforeach ?>
</div> </div>
<? endif ?> <?php endif ?>
<? if($profile->comment): ?> <?php if ($profile->comment): ?>
<div> <div>
<strong><?= dgettext('TandemPlugin', 'Bemerkung') ?>:</strong> <strong><?= dgettext('TandemPlugin', 'Bemerkung') ?>:</strong>
<?= htmlReady($profile->comment) ?> <?= htmlReady($profile->comment) ?>
</div> </div>
<? endif ?> <?php endif ?>
<? if($admin_view and Config::get()->TANDEMPLUGIN_PROOF_FIELDS_ENABLED): ?> <?php if (!empty($admin_view) && Config::get()->TANDEMPLUGIN_PROOF_FIELDS_ENABLED) : ?>
<div> <div>
<? if($profile->proof_of_achievement): ?> <?php if($profile->proof_of_achievement) : ?>
<div> <div>
<strong><?= dgettext('TandemPlugin', 'Leistungsbescheinigung') ?>:</strong> <strong><?= dgettext('TandemPlugin', 'Leistungsbescheinigung') ?>:</strong>
<span><?= dgettext('TandemPlugin', 'gewünscht') ?></span> <span><?= dgettext('TandemPlugin', 'gewünscht') ?></span>
</div> </div>
<? endif ?> <?php endif ?>
<? if($profile->proof_of_attendance): ?> <?php if($profile->proof_of_attendance) : ?>
<div> <div>
<strong><?= dgettext('TandemPlugin', 'Teilnahmebestätigung') ?>:</strong> <strong><?= dgettext('TandemPlugin', 'Teilnahmebestätigung') ?>:</strong>
<span><?= dgettext('TandemPlugin', 'gewünscht') ?></span> <span><?= dgettext('TandemPlugin', 'gewünscht') ?></span>
</div> </div>
<? endif ?> <?php endif ?>
<? endif ?> <?php endif ?>
</div> </div>
</div> </div>
<?php
/**
* @var string $name
* @var string $name_ger
* @var string $name_eng
*/
?>
<label> <label>
<?= dgettext('TandemPlugin', 'Name') ?> <?= dgettext('TandemPlugin', 'Name') ?>
<input type="text" name="name" value="<?= htmlReady($name) ?>"> <input type="text" name="name" value="<?= htmlReady($name) ?>">
......
<?php
/**
* @var PluginController $controller
* @var string $lang_id
* @var string $name
* @var string $name_ger
* @var string $name_eng
*/
?>
<form class="default" method="post" data-dialog="reload-on-close" <form class="default" method="post" data-dialog="reload-on-close"
action="<?= $controller->link_for('admin/add_language') ?>"> action="<?= $controller->link_for('admin/add_language') ?>">
<?= CSRFProtection::tokenTag() ?> <?= CSRFProtection::tokenTag() ?>
......
<?php
/**
* @var PluginController $controller
* @var QuickSearch $user_search
* @var string $reason
*/
?>
<form class="default" method="post" action="<?= $controller->link_for('admin/add_to_blocklist') ?>" <form class="default" method="post" action="<?= $controller->link_for('admin/add_to_blocklist') ?>"
data-dialog="reload-on-close"> data-dialog="reload-on-close">
<?= CSRFProtection::tokenTag() ?> <?= CSRFProtection::tokenTag() ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment