From 0b867f0e61bfdcacd3339bcfadaf585f7bbba716 Mon Sep 17 00:00:00 2001 From: Moritz Strohm <strohm@data-quest.de> Date: Mon, 4 Jul 2022 10:14:49 +0000 Subject: [PATCH] fix for BIESt #1078 Merge request studip/studip!657 --- app/controllers/contact.php | 2 +- app/controllers/evaluation.php | 2 +- app/controllers/profile.php | 2 ++ app/controllers/profilemodules.php | 8 ++--- app/controllers/settings/details.php | 1 - app/controllers/settings/messaging.php | 11 +++++++ app/views/profile/index.php | 11 ------- app/views/questionnaire/widget.php | 2 +- app/views/settings/details.php | 7 ---- lib/classes/DataFieldEntry.class.php | 1 + lib/classes/Score.class.php | 6 ++-- lib/classes/vCard.php | 2 ++ lib/classes/visibility/UserPrivacy.php | 1 + .../visibility/User_Visibility_Settings.php | 15 +++++---- lib/models/SimpleORMap.class.php | 2 +- lib/models/User.class.php | 32 +++++++++---------- 16 files changed, 52 insertions(+), 53 deletions(-) diff --git a/app/controllers/contact.php b/app/controllers/contact.php index ea46c82bf7a..1453f91d2eb 100644 --- a/app/controllers/contact.php +++ b/app/controllers/contact.php @@ -23,7 +23,7 @@ class ContactController extends AuthenticatedController $this->groups = SimpleCollection::createFromArray(Statusgruppen::findByRange_id(User::findCurrent()->id)); // Load requested group - if ($args[0]) { + if (!empty($args[0])) { $this->group = $this->groups->findOneBy('statusgruppe_id', $args[0]); //Check for cheaters diff --git a/app/controllers/evaluation.php b/app/controllers/evaluation.php index 11a6b3a5472..7ed30df8298 100644 --- a/app/controllers/evaluation.php +++ b/app/controllers/evaluation.php @@ -40,7 +40,7 @@ class EvaluationController extends AuthenticatedController } // Special case: from widget and no data -> no output - if ($this->suppress_empty_output && count($this->evaluations) === 0) { + if (count($this->evaluations) === 0) { $this->render_nothing(); } else { $this->visit(); diff --git a/app/controllers/profile.php b/app/controllers/profile.php index c5a136f78bc..21de27e6121 100644 --- a/app/controllers/profile.php +++ b/app/controllers/profile.php @@ -91,6 +91,7 @@ class ProfileController extends AuthenticatedController $this->homepage = $this->profile->getVisibilityValue('Home', 'homepage'); // skype informations + $this->skype_name = ''; if (Config::get()->ENABLE_SKYPE_INFO && Visibility::verify('skype_name', $this->current_user->user_id)) { $this->skype_name = UserConfig::get($this->current_user->user_id)->SKYPE_NAME; } @@ -121,6 +122,7 @@ class ProfileController extends AuthenticatedController } // calendar + $this->dates = ''; if (Config::get()->CALENDAR_ENABLE) { if (!in_array($this->current_user->perms, ['admin', 'root'])) { if (Visibility::verify('termine', $this->current_user->user_id)) { diff --git a/app/controllers/profilemodules.php b/app/controllers/profilemodules.php index 9e558faca12..3c0a354681c 100644 --- a/app/controllers/profilemodules.php +++ b/app/controllers/profilemodules.php @@ -296,12 +296,12 @@ class ProfileModulesController extends AuthenticatedController 'url' => $plugin->getPluginURL(), 'activated' => $manager->isPluginActivatedForUser($plugin->getPluginId(), $this->user->id), 'icon' => $icon, - 'abstract' => str_replace('\n', ' ', $metadata['descriptionshort'] ?: $metadata['summary']), - 'description' => str_replace('\n', ' ', $metadata['descriptionlong'] ?: $metadata['description']), + 'abstract' => str_replace('\n', ' ', $metadata['descriptionshort'] ?? $metadata['summary']), + 'description' => str_replace('\n', ' ', $metadata['descriptionlong'] ?? $metadata['description']), 'screenshots' => [], 'keywords' => $metadata['keywords'] ? explode(';', $metadata['keywords']) : [], - 'homepage' => $metadata['homepage'], - 'helplink' => $metadata['helplink'], + 'homepage' => $metadata['homepage'] ?? '', + 'helplink' => $metadata['helplink'] ?? '', ]; if (isset($metadata['screenshot'])) { diff --git a/app/controllers/settings/details.php b/app/controllers/settings/details.php index 5f6f738dda5..956f844ad46 100644 --- a/app/controllers/settings/details.php +++ b/app/controllers/settings/details.php @@ -53,7 +53,6 @@ class Settings_DetailsController extends Settings_SettingsController : false; $this->is_dozent = $this->user->perms == 'dozent'; $this->user_entries = $userEntries; - $this->invalid_entries = $invalidEntries; } /** diff --git a/app/controllers/settings/messaging.php b/app/controllers/settings/messaging.php index 4c249af6a5e..23e6d7945e4 100644 --- a/app/controllers/settings/messaging.php +++ b/app/controllers/settings/messaging.php @@ -26,6 +26,17 @@ class Settings_MessagingController extends Settings_SettingsController Navigation::activateItem('/profile/settings/messaging'); $this->settings = $this->config->MESSAGING_SETTINGS; + $all_settings_fields = [ + 'save_snd', + 'request_mail_forward', + 'show_adressees', + 'logout_markreaded' + ]; + foreach ($all_settings_fields as $field) { + if (!array_key_exists($field, $this->settings)) { + $this->settings[$field] = 0; + } + } } public function index_action() diff --git a/app/views/profile/index.php b/app/views/profile/index.php index e14dbecb7a4..1062f74bcf5 100644 --- a/app/views/profile/index.php +++ b/app/views/profile/index.php @@ -110,17 +110,6 @@ <?= $this->render_partial('profile/seminare') ?> <? endif ?> -<? if ($show_lit && $lit_list) : ?> - <article class="studip"> - <header> - <h1><?= _('Literaturlisten') ?></h1> - </header> - <section> - <?= $lit_list ?> - </section> - </article> -<? endif ?> - <? if (!empty($longDatafields)) : ?> <? foreach ($longDatafields as $name => $entry) : ?> <article class="studip"> diff --git a/app/views/questionnaire/widget.php b/app/views/questionnaire/widget.php index 6dada584a39..24aa9e40c65 100644 --- a/app/views/questionnaire/widget.php +++ b/app/views/questionnaire/widget.php @@ -27,7 +27,7 @@ <? foreach ($questionnaire_data as $questionnaire): ?> <?= $this->render_partial("questionnaire/_widget_questionnaire", ['questionnaire' => Questionnaire::buildExisting($questionnaire), 'range_type' => $range_type, 'range_id' => $range_id]) ?> <? endforeach; ?> - <? elseif (!$suppress_empty_output): ?> + <? elseif (empty($suppress_empty_output)): ?> <section class="noquestionnaires"> <?= _('Es sind keine Fragebögen vorhanden.') ?> <? if ($allowed_to_add) : ?> diff --git a/app/views/settings/details.php b/app/views/settings/details.php index 2b5174eea4e..a319af7e082 100644 --- a/app/views/settings/details.php +++ b/app/views/settings/details.php @@ -78,13 +78,6 @@ <fieldset> <legend> <?= _('Zusätzliche Datenfelder') ?></legend> <? foreach ($user_entries as $id => $entry): ?> - - <? if (isset($invalid_entries[$id])): ?> - - <? $entry = $invalid_entries[$id]; // Exchange entry ?> - <? else: ?> - <? endif; ?> - <? if ($entry->isEditable() && !LockRules::check($user->user_id, $entry->getId())): ?> <?= $entry->getHTML('datafields', [ 'tooltip' => $entry->isVisible($user->perms) ? '' : _('Systemfeld (für die Person selbst nicht sichtbar)'), diff --git a/lib/classes/DataFieldEntry.class.php b/lib/classes/DataFieldEntry.class.php index 552cc79bf21..96aa4e0b732 100644 --- a/lib/classes/DataFieldEntry.class.php +++ b/lib/classes/DataFieldEntry.class.php @@ -100,6 +100,7 @@ abstract class DataFieldEntry if (!$range_id) { return []; // we necessarily need a range ID } + $clause1 = ''; $parameters = []; if(is_array($range_id)) { // rangeID may be an array ("classic" rangeID and second rangeID used for user roles) diff --git a/lib/classes/Score.class.php b/lib/classes/Score.class.php index 5fa80d9b1e6..1a1b5d91622 100644 --- a/lib/classes/Score.class.php +++ b/lib/classes/Score.class.php @@ -166,13 +166,13 @@ class Score $statements = []; foreach (self::getActivityTables() as $table) { $statements[] = "SELECT " - . ($table['date_column'] ?: 'mkdate') + . ($table['date_column'] ?? 'mkdate') . " AS mkdate FROM " . $table['table'] . " WHERE " - . ($table['user_id_column'] ?: 'user_id') + . ($table['user_id_column'] ?? 'user_id') . " = :user " - . ($table['where'] ? (' AND ' . $table['where']) : ''); + . (!empty($table['where']) ? (' AND ' . $table['where']) : ''); } return join(' UNION ', $statements); } diff --git a/lib/classes/vCard.php b/lib/classes/vCard.php index ac64265047a..cc2b6181e4e 100644 --- a/lib/classes/vCard.php +++ b/lib/classes/vCard.php @@ -31,6 +31,7 @@ class vCard { return self::exportUser($users); } + $export = ''; foreach ($users as $user) { $export .= self::exportUser($user); } @@ -102,6 +103,7 @@ class vCard { $vCard['END'] = 'VCARD'; // Produce string + $exportString = ''; foreach ($vCard as $index => $value) { $exportString .= $value ? $index . ':' . (is_array($value) ? join(';', $value) : $value) . "\r\n" : ""; } diff --git a/lib/classes/visibility/UserPrivacy.php b/lib/classes/visibility/UserPrivacy.php index 165ac69244a..e521dc3ba66 100644 --- a/lib/classes/visibility/UserPrivacy.php +++ b/lib/classes/visibility/UserPrivacy.php @@ -47,6 +47,7 @@ class UserPrivacy if (User_Visibility_Settings::countBySQL('user_id = ? AND category = 0', [$this->user->id]) == 0) { Visibility::createDefaultCategories($this->user->id); } + $idmap = []; $this->profileSettings = User_Visibility_Settings::findBySQL("user_id = ? AND parent_id = 0 AND identifier <> 'plugins'", [$this->user->id]); foreach ($this->profileSettings as $i => $vis) { $vis->loadChildren(); diff --git a/lib/classes/visibility/User_Visibility_Settings.php b/lib/classes/visibility/User_Visibility_Settings.php index 1b954e1b8a2..bd16910c438 100644 --- a/lib/classes/visibility/User_Visibility_Settings.php +++ b/lib/classes/visibility/User_Visibility_Settings.php @@ -20,25 +20,25 @@ class User_Visibility_Settings extends SimpleORMap // parent of the Visibility public $parent; - + // children of the visibility public $children = []; - + // determines if the option is displayed in settings public $displayed = false; /** * Find a User_Visibility_Setting by an id or an identifier and a user - * + * * @param type $id */ public static function find($id = null, $userid = null) { - + // If we have no id or we have a real int id use standard construction if (!$id || is_int($id)) { parent::find($id); } else { - + // Rewrite user if nessecary $userid = $userid ? : $GLOBALS['user']->id; @@ -72,7 +72,7 @@ class User_Visibility_Settings extends SimpleORMap $pluginManager = PluginManager::getInstance(); $plugin = $pluginManager->getPluginInfoById($this->plugin); $pluginDisplay = ($this->plugin == 0 || ($pluginManager->isPluginActivatedForUser($this->plugin, $this->user_id)) && $plugin['enabled']); - + // now check both if ($catDisplay && $pluginDisplay) { $this->setDisplayed(); @@ -99,12 +99,13 @@ class User_Visibility_Settings extends SimpleORMap public function getHTMLArgs(&$result, $depth = 0) { if ($this->displayed) { + $entry = []; $entry['is_header'] = $this->category == 0 && $this->parent_id == 0; $entry['is_category'] = $this->category == 0; $entry['id'] = $this->visibilityid; $entry['state'] = $this->state; $entry['padding'] = ($depth * 20) . "px"; - $entry['name'] .= $this->name; + $entry['name'] = $this->name ?? ''; $result[] = $entry; // Now add the html args for the children diff --git a/lib/models/SimpleORMap.class.php b/lib/models/SimpleORMap.class.php index 92cdf423af7..8b4649504f6 100644 --- a/lib/models/SimpleORMap.class.php +++ b/lib/models/SimpleORMap.class.php @@ -217,7 +217,7 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate } if (isset($config['additional_fields'])) { foreach ($config['additional_fields'] as $a_field => $a_config) { - if (is_array($a_config) && !(isset($a_config['get']) || isset($a_config['set']))) { + if (!empty($a_config) && is_array($a_config) && !(isset($a_config['get']) || isset($a_config['set']))) { $relation = $a_config[0] ?? ''; $relation_field = $a_config[1] ?? ''; if (!$relation) { diff --git a/lib/models/User.class.php b/lib/models/User.class.php index cdc84e462a2..fd95aa9070b 100644 --- a/lib/models/User.class.php +++ b/lib/models/User.class.php @@ -756,7 +756,7 @@ class User extends AuthUserMd5 implements Range, PrivacyObject // Now join all available elements with visibility settings. $homepage_elements = []; - if (Avatar::getAvatar($this->id)->is_customized() && !$GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['picture']) { + if (Avatar::getAvatar($this->id)->is_customized() && empty($GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['picture'])) { $homepage_elements['picture'] = [ 'name' => _('Eigenes Bild'), 'visibility' => $homepage_visibility['picture'] ?: get_default_homepage_visibility($this->id), @@ -765,7 +765,7 @@ class User extends AuthUserMd5 implements Range, PrivacyObject ]; } - if ($this->info->motto && !$GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['motto']) { + if ($this->info->motto && empty($GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['motto'])) { $homepage_elements['motto'] = [ 'name' => _('Motto'), 'visibility' => $homepage_visibility['motto'] ?: get_default_homepage_visibility($this->id), @@ -773,7 +773,7 @@ class User extends AuthUserMd5 implements Range, PrivacyObject ]; } if (Config::get()->ENABLE_SKYPE_INFO) { - if ($GLOBALS['user']->cfg->getValue('SKYPE_NAME') && !$GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['skype_name']) { + if ($GLOBALS['user']->cfg->getValue('SKYPE_NAME') && empty($GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['skype_name'])) { $homepage_elements['skype_name'] = [ 'name' => _('Skype Name'), 'visibility' => $homepage_visibility['skype_name'] ?: get_default_homepage_visibility($this->id), @@ -781,28 +781,28 @@ class User extends AuthUserMd5 implements Range, PrivacyObject ]; } } - if ($this->info->privatnr && !$GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['Private Daten_phone']) { + if ($this->info->privatnr && empty($GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['Private Daten_phone'])) { $homepage_elements['private_phone'] = [ 'name' => _('Private Telefonnummer'), 'visibility' => $homepage_visibility['private_phone'] ?: get_default_homepage_visibility($this->id), 'identifier' => 'privatedata' ]; } - if ($this->info->privatcell && !$GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['private_cell']) { + if ($this->info->privatcell && empty($GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['private_cell'])) { $homepage_elements['private_cell'] = [ 'name' => _('Private Handynummer'), 'visibility' => $homepage_visibility['private_cell'] ?: get_default_homepage_visibility($this->id), 'identifier' => 'privatedata' ]; } - if ($this->info->privadr && !$GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['privadr']) { + if ($this->info->privadr && empty($GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['privadr'])) { $homepage_elements['privadr'] = [ 'name' => _('Private Adresse'), 'visibility' => $homepage_visibility['privadr'] ?: get_default_homepage_visibility($this->id), 'identifier' => 'privatedata' ]; } - if ($this->info->home && !$GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['homepage']) { + if ($this->info->home && empty($GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['homepage'])) { $homepage_elements['homepage'] = [ 'name' => _('Homepage-Adresse'), 'visibility' => $homepage_visibility['homepage'] ?: get_default_homepage_visibility($this->id), @@ -810,7 +810,7 @@ class User extends AuthUserMd5 implements Range, PrivacyObject 'identifier' => 'privatedata' ]; } - if ($news && !$GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['news']) { + if ($news && empty($GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['news'])) { $homepage_elements['news'] = [ 'name' => _('Ankündigungen'), 'visibility' => $homepage_visibility['news'] ?: get_default_homepage_visibility($this->id), @@ -818,7 +818,7 @@ class User extends AuthUserMd5 implements Range, PrivacyObject 'identifier' => 'commondata' ]; } - if (Config::get()->CALENDAR_ENABLE && $dates && !$GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['dates']) { + if (Config::get()->CALENDAR_ENABLE && $dates && empty($GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['dates'])) { $homepage_elements['termine'] = [ 'name' => _('Termine'), 'visibility' => $homepage_visibility['termine'] ?: get_default_homepage_visibility($this->id), @@ -826,7 +826,7 @@ class User extends AuthUserMd5 implements Range, PrivacyObject 'identifier' => 'commondata' ]; } - if (Config::get()->VOTE_ENABLE && ($activeVotes || $stoppedVotes || $activeEvals) && !$GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['votes']) { + if (Config::get()->VOTE_ENABLE && ($activeVotes || $stoppedVotes || $activeEvals) && empty($GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['votes'])) { $homepage_elements['votes'] = [ 'name' => _('Fragebögen'), 'visibility' => $homepage_visibility['votes'] ?: get_default_homepage_visibility($this->id), @@ -840,14 +840,14 @@ class User extends AuthUserMd5 implements Range, PrivacyObject WHERE user_id = ? AND inst_perms = 'user'"; $statement = DBManager::get()->prepare($query); $statement->execute([$this->id]); - if ($statement->fetchColumn() && !$GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['studying']) { + if ($statement->fetchColumn() && empty($GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['studying'])) { $homepage_elements['studying'] = [ 'name' => _('Wo ich studiere'), 'visibility' => $homepage_visibility['studying'] ?: get_default_homepage_visibility($this->id), 'identifier' => 'studdata' ]; } - if ($this->info->lebenslauf && !$GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['lebenslauf']) { + if ($this->info->lebenslauf && empty($GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['lebenslauf'])) { $homepage_elements['lebenslauf'] = [ 'name' => _('Lebenslauf'), 'visibility' => $homepage_visibility['lebenslauf'] ?: get_default_homepage_visibility($this->id), @@ -855,14 +855,14 @@ class User extends AuthUserMd5 implements Range, PrivacyObject 'identifier' => 'privatedata' ]; } - if ($this->info->hobby && !$GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['hobby']) { + if ($this->info->hobby && empty($GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['hobby'])) { $homepage_elements['hobby'] = [ 'name' => _('Hobbys'), 'visibility' => $homepage_visibility['hobby'] ?: get_default_homepage_visibility($this->id), 'identifier' => 'privatedata' ]; } - if ($this->info->publi && !$GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['publi']) { + if ($this->info->publi && empty($GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['publi'])) { $homepage_elements['publi'] = [ 'name' => _('Publikationen'), 'visibility' => $homepage_visibility['publi'] ?: get_default_homepage_visibility($this->id), @@ -870,7 +870,7 @@ class User extends AuthUserMd5 implements Range, PrivacyObject 'identifier' => 'privatedata' ]; } - if ($this->info->schwerp && !$GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['schwerp']) { + if ($this->info->schwerp && empty($GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['schwerp'])) { $homepage_elements['schwerp'] = [ 'name' => _('Arbeitsschwerpunkte'), 'visibility' => $homepage_visibility['schwerp'] ?: get_default_homepage_visibility($this->id), @@ -881,7 +881,7 @@ class User extends AuthUserMd5 implements Range, PrivacyObject if ($data_fields) { foreach ($data_fields as $key => $field) { - if ($field->getValue() && $field->isEditable($this->perms) && !$GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms][$key]) { + if ($field->getValue() && $field->isEditable($this->perms) && empty($GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms][$key])) { $homepage_elements[$key] = [ 'name' => $field->getName(), 'visibility' => $homepage_visibility[$key] ?: get_default_homepage_visibility($this->id), -- GitLab