From 923014c635bf9bb786d596fa06c6820cbf8e8b8e Mon Sep 17 00:00:00 2001 From: David Siegfried <ds.siegfried@gmail.com> Date: Wed, 23 Nov 2022 16:25:20 +0100 Subject: [PATCH 01/19] prevent php-warnings, closes #1807 --- app/controllers/admin/datafields.php | 1 - app/controllers/admission/courseset.php | 2 +- app/controllers/course/admission.php | 2 +- app/controllers/course/studygroup.php | 7 ++--- app/controllers/help_content.php | 2 +- app/controllers/institute/basicdata.php | 6 ++-- app/controllers/institute/members.php | 14 ++++++++- app/controllers/resources/admin.php | 4 +-- app/controllers/tour.php | 4 +-- app/views/admin/datafields/new.php | 2 +- app/views/help_content/edit.php | 6 ++-- app/views/institute/basicdata/index.php | 2 +- app/views/institute/members/_table_body.php | 17 +++++----- app/views/institute/members/index.php | 4 +-- app/views/multipersonsearch/js_form.php | 2 +- app/views/tour/admin_details.php | 8 ++--- app/views/tour/import.php | 4 +-- lib/export/export_studipdata_func.inc.php | 2 +- lib/models/CronjobSchedule.class.php | 2 +- lib/models/User.class.php | 35 +++++++++++---------- lib/models/UserDomain.php | 2 +- lib/statusgruppe.inc.php | 6 ++-- public/export.php | 2 +- 23 files changed, 75 insertions(+), 61 deletions(-) diff --git a/app/controllers/admin/datafields.php b/app/controllers/admin/datafields.php index bf390c9fcbc..3485e4b92da 100644 --- a/app/controllers/admin/datafields.php +++ b/app/controllers/admin/datafields.php @@ -140,7 +140,6 @@ class Admin_DatafieldsController extends AuthenticatedController public function new_action($type = null) { $this->datafield = new DataField(); - PageLayout::setTitle(_('Neues Datenfeld anlegen')); if (Request::submitted('anlegen')) { diff --git a/app/controllers/admission/courseset.php b/app/controllers/admission/courseset.php index c75aea95838..b39cdfb7bf8 100644 --- a/app/controllers/admission/courseset.php +++ b/app/controllers/admission/courseset.php @@ -141,6 +141,7 @@ class Admission_CoursesetController extends AuthenticatedController public function configure_action($coursesetId = '') { $this->courseset = null; + $allCourses = []; if ($GLOBALS['perm']->have_perm('root')) { if ($coursesetId) { // Load course set data. @@ -159,7 +160,6 @@ class Admission_CoursesetController extends AuthenticatedController } else { $this->myInstitutes = []; $this->selectedInstitutes = []; - $allCourses = []; $selectedCourses = []; $this->selectedSemester = $_SESSION['_default_sem'] ?: Semester::findCurrent()->semester_id; } diff --git a/app/controllers/course/admission.php b/app/controllers/course/admission.php index a0d38170e41..96a0b61eb5a 100644 --- a/app/controllers/course/admission.php +++ b/app/controllers/course/admission.php @@ -497,7 +497,7 @@ class Course_AdmissionController extends AuthenticatedController $this->instant_course_set_view = true; $response = $this->relay('admission/courseset/configure/' . $cs->getId()); $this->body = $response->body; - if ($response->headers['Location']) { + if (!empty($response->headers['Location'])) { $this->redirect($response->headers['Location']); } } else { diff --git a/app/controllers/course/studygroup.php b/app/controllers/course/studygroup.php index db54b97d84c..17af04306a6 100644 --- a/app/controllers/course/studygroup.php +++ b/app/controllers/course/studygroup.php @@ -891,11 +891,11 @@ class Course_StudygroupController extends AuthenticatedController * @return void */ public function savemodules_action() + { - global $perm; - $perm->check("root"); + $GLOBALS['perm']->check("root"); PageLayout::setHelpKeyword('Admin.Studiengruppen'); - + $errors = []; if (!Request::get('institute')) { $errors[] = _('Bitte wählen Sie eine Einrichtung aus, der die Studiengruppen zugeordnet werden sollen!'); } @@ -927,7 +927,6 @@ class Course_StudygroupController extends AuthenticatedController } $this->redirect('course/studygroup/globalmodules'); } - /** * globally deactivates the studygroups * diff --git a/app/controllers/help_content.php b/app/controllers/help_content.php index 5e8faf98473..4162d85e216 100644 --- a/app/controllers/help_content.php +++ b/app/controllers/help_content.php @@ -125,7 +125,7 @@ class HelpContentController extends AuthenticatedController } $this->parameters = $parameters; $this->help_content_route = Request::get('help_content_route'); - + $this->help_content_id = null; $this->render_template('help_content/edit'); } diff --git a/app/controllers/institute/basicdata.php b/app/controllers/institute/basicdata.php index a265cfef9c1..2f13d9b15ac 100644 --- a/app/controllers/institute/basicdata.php +++ b/app/controllers/institute/basicdata.php @@ -81,7 +81,7 @@ class Institute_BasicdataController extends AuthenticatedController } $lockrule = LockRules::getObjectRule($i_view); - if ($lockrule->description && LockRules::CheckLockRulePermission($i_view, $lockrule['permission'])) { + if ($lockrule && $lockrule->description && LockRules::CheckLockRulePermission($i_view, $lockrule['permission'])) { PageLayout::postInfo(formatLinks($lockrule->description)); } @@ -115,7 +115,7 @@ class Institute_BasicdataController extends AuthenticatedController // Read faculties if neccessary if (count($institute->sub_institutes) === 0) { if ($GLOBALS['perm']->have_perm('root')) { - $this->faculties = Institute::findBySQL('Institut_id = fakultaets_id ORDER BY Name ASC', [$i_view]); + $this->faculties = Institute::findBySQL('Institut_id = fakultaets_id ORDER BY Name ASC'); } else { $temp = User::find($GLOBALS['user']->id) ->institute_memberships->findBy('inst_perms', 'admin') @@ -127,7 +127,7 @@ class Institute_BasicdataController extends AuthenticatedController $this->faculties = $faculties; } } - + $reason_txt = ''; // Indicates whether the current user is allowed to delete the institute $this->may_delete = $i_view !== 'new' && !(count($institute->home_courses) || count($institute->sub_institutes)) diff --git a/app/controllers/institute/members.php b/app/controllers/institute/members.php index 33d8eab38dc..04199b39a57 100644 --- a/app/controllers/institute/members.php +++ b/app/controllers/institute/members.php @@ -177,6 +177,10 @@ class Institute_MembersController extends AuthenticatedController $this->display_tables[] = [ 'members' => $institut_members, 'dview' => $dview, + 'mail_status' => false, + 'mail_gruppe' => false, + 'group' => null, + 'key' => null, 'th_title' => _('keiner Funktion zugeordnet'), ]; } @@ -201,6 +205,8 @@ class Institute_MembersController extends AuthenticatedController 'members' => $institut_members, 'dview' => $dview, 'mail_status' => true, + 'mail_gruppe' => false, + 'group' => null, 'key' => $key, 'th_title' => $permission, ]; @@ -227,6 +233,11 @@ class Institute_MembersController extends AuthenticatedController $this->display_tables[] = [ 'members' => $institut_members, 'dview' => $dview, + 'mail_status' => false, + 'group' => null, + 'mail_gruppe' => false, + 'key' => null, + 'th_title' => null, ]; } @@ -272,10 +283,11 @@ class Institute_MembersController extends AuthenticatedController // output $this->display_tables[] = [ 'members' => $institut_members, + 'mail_status' => false, 'group' => $group, 'th_title' => $title, 'dview' => $dview, - + 'key' => null, // StEP 154: Nachricht an alle Mitglieder der Gruppe 'mail_gruppe' => $GLOBALS['ENABLE_EMAIL_TO_STATUSGROUP'] && $GLOBALS['perm']->have_studip_perm('autor', $this->institute->id), diff --git a/app/controllers/resources/admin.php b/app/controllers/resources/admin.php index 94319113c93..13a0dd4003b 100644 --- a/app/controllers/resources/admin.php +++ b/app/controllers/resources/admin.php @@ -453,7 +453,7 @@ class Resources_AdminController extends AuthenticatedController //At least one property is selected for moving into another //property group. foreach ($this->property_move as $property_id => $group_id) { - $property = $property_object_cache[$property_id]; + $property = $property_object_cache[$property_id] ?? null; if (!$property) { $property = ResourcePropertyDefinition::find($property_id); } @@ -482,7 +482,7 @@ class Resources_AdminController extends AuthenticatedController if ($this->group_position) { foreach ($this->group_position as $group_id => $position) { - $group = $group_object_cache[$group_id]; + $group = $group_object_cache[$group_id] ?? null; if (!$group) { $group = ResourcePropertyGroup::find($group_id); } diff --git a/app/controllers/tour.php b/app/controllers/tour.php index a288ab27ba0..3ff6eaa4220 100644 --- a/app/controllers/tour.php +++ b/app/controllers/tour.php @@ -279,7 +279,7 @@ class TourController extends AuthenticatedController PageLayout::setTitle(_('Hilfe-Tour importieren')); - if ($_FILES['tour_file']['tmp_name']) { + if (!empty($_FILES['tour_file']['tmp_name'])) { $tour_json_data = file_get_contents($_FILES['tour_file']['tmp_name']); $tour_data = @json_decode($tour_json_data, true); if (!$tour_data || !$tour_data['tour']) { @@ -622,7 +622,7 @@ class TourController extends AuthenticatedController } $this->delete_question = ''; - + $this->tour_startpage = ''; // initialize PageLayout::setTitle(_('Verwalten von Touren')); PageLayout::setHelpKeyword('Basis.TourAdmin'); diff --git a/app/views/admin/datafields/new.php b/app/views/admin/datafields/new.php index 25d9a8a0a5d..0c6f696f985 100644 --- a/app/views/admin/datafields/new.php +++ b/app/views/admin/datafields/new.php @@ -126,7 +126,7 @@ use Studip\Button, Studip\LinkButton; <? foreach ($institutes as $institute): ?> <option value="<?= htmlReady($institute['Institut_id']) ?>" class="<?= $institute['is_fak'] ? 'nested-item-header' : 'nested-item' ?>" - <?= $item->institut_id === $institute['Institut_id'] ? 'selected' : ''?>> + <?= isset($item) && $item->institut_id === $institute['Institut_id'] ? 'selected' : ''?>> <?= htmlReady(my_substr($institute['Name'],0,80)) ?> </option> <? endforeach; ?> diff --git a/app/views/help_content/edit.php b/app/views/help_content/edit.php index 2197ff1095f..7b8e3830dcd 100644 --- a/app/views/help_content/edit.php +++ b/app/views/help_content/edit.php @@ -22,7 +22,7 @@ <span class="required"><?= _('Sprache des Textes') ?>:</span> <select name="help_content_language"> <? foreach ($GLOBALS['INSTALLED_LANGUAGES'] as $key => $language) : ?> - <option value="<?= mb_substr($key, 0, 2) ?>"<?= ($help_content->language == mb_substr($key, 0, 2)) ? ' selected' : '' ?>> + <option value="<?= mb_substr($key, 0, 2) ?>"<?= (isset($help_content) && $help_content->language == mb_substr($key, 0, 2)) ? ' selected' : '' ?>> <?= $language['name'] ?> </option> <? endforeach ?> @@ -32,11 +32,11 @@ <label for="help_content_content"> <?= _('Hilfe-Text') ?>: <textarea cols="60" rows="5" name="help_content_content" - placeholder="<?= _('Bitte geben Sie den Text ein') ?>"><?= htmlReady($help_content->content ?: '') ?></textarea> + placeholder="<?= _('Bitte geben Sie den Text ein') ?>"><?= htmlReady($help_content->content ?? '') ?></textarea> </label> <label for="help_content_comment"> <?= _('Bemerkung') ?>: - <textarea name="help_content_comment"><?= htmlReady($help_content->comment ?: '') ?></textarea> + <textarea name="help_content_comment"><?= htmlReady($help_content->comment ?? '') ?></textarea> </label> </fieldset> diff --git a/app/views/institute/basicdata/index.php b/app/views/institute/basicdata/index.php index c794997cb91..8e697c1e011 100644 --- a/app/views/institute/basicdata/index.php +++ b/app/views/institute/basicdata/index.php @@ -1,4 +1,4 @@ -<?= $question ?> +<?= $question ?? '' ?> <form method="post" name="edit" action="<?= $controller->url_for('institute/basicdata/store/' . $i_view) ?>" class="default"> <?= CSRFProtection::tokenTag() ?> diff --git a/app/views/institute/members/_table_body.php b/app/views/institute/members/_table_body.php index 2aa3704259e..5d2a9a32771 100644 --- a/app/views/institute/members/_table_body.php +++ b/app/views/institute/members/_table_body.php @@ -16,7 +16,7 @@ 'inst_id' => Context::getId(), ]), sprintf(_('Nachricht an alle Mitglieder mit dem Status %s verschicken'), $th_title), - Icon::create('mail', 'clickable'), + Icon::create('mail'), ['data-dialog' => ''] ) ->condition($mail_gruppe ?? false) @@ -26,13 +26,14 @@ 'default_subject' => Context::get()->Name, ]), sprintf(_('Nachricht an alle Mitglieder der Gruppe %s verschicken'), $th_title), - Icon::create('mail', 'clickable'), + Icon::create('mail'), ['data-dialog' => ''] ) ?> </th> <? endif; ?> </tr> <? endif; ?> +<? $role_entries = [] ?> <? foreach ($members as $member): $default_entries = DataFieldEntry::getDataFieldEntries([$member->user_id, $institute->id]); @@ -94,7 +95,7 @@ ->addLink( $controller->url_for("messages/write?rec_uname={$member->username}"), _('Nachricht an Benutzer verschicken'), - Icon::create('mail', 'clickable'), + Icon::create('mail'), ['data-dialog' => ''] ) ->conditionAll( @@ -105,16 +106,16 @@ ) ->condition(isset($group)) ->addLink( - $controller->url_for('institute/members/remove_from_group', $group->id, $type, ['username' => $member->username]), + $controller->url_for('institute/members/remove_from_group', (isset($group) ? $group->id : null), $type, ['username' => $member->username]), _('Person aus Gruppe austragen'), - Icon::create('door-leave', 'clickable'), + Icon::create('door-leave'), ['data-confirm' => _('Wollen Sie die Person wirklich aus der Gruppe austragen?')] ) ->condition(!isset($group)) ->addLink( $controller->url_for('institute/members/remove_from_institute', $type, ['username' => $member->username]), _('Person aus Einrichtung austragen'), - Icon::create('door-leave', 'clickable'), + Icon::create('door-leave'), ['data-confirm' => _('Wollen Sie die Person wirklich aus der Einrichtung austragen?')] ) ?> </td> @@ -158,12 +159,12 @@ 'contentbox_open' => $group->id, ]), _('Gruppendaten bearbeiten'), - Icon::create('edit', 'clickable') + Icon::create('edit') ) ->addLink( $controller->url_for('institute/members/remove_from_group', $group->id, $type, ['username' => $member->username]), _('Person aus Gruppe austragen'), - Icon::create('door-leave', 'clickable'), + Icon::create('door-leave'), ['data-confirm' => _('Wollen Sie die Person wirklich aus der Gruppe austragen?')] ) ?> </td> diff --git a/app/views/institute/members/index.php b/app/views/institute/members/index.php index 25cf0aad5c5..4c1678b2eb6 100644 --- a/app/views/institute/members/index.php +++ b/app/views/institute/members/index.php @@ -2,10 +2,10 @@ <table class="default" id="list_institute_members"> <caption><?= _('Mitarbeiterinnen und Mitarbeiter') ?></caption> <colgroup> - <col width="32"> + <col style="width: 32px"> <? foreach ($structure as $key => $field): ?> <? if ($key !== 'statusgruppe'): ?> - <col <? if (!empty($field['width'])): ?> width="<?= htmlReady($field['width']) ?>"<? endif; ?>> + <col <? if (!empty($field['width'])): ?> style="width: <?= htmlReady($field['width']) ?>px"<? endif ?>> <? endif; ?> <? endforeach; ?> </colgroup> diff --git a/app/views/multipersonsearch/js_form.php b/app/views/multipersonsearch/js_form.php index 6c3ddfa68d9..180da233cdd 100644 --- a/app/views/multipersonsearch/js_form.php +++ b/app/views/multipersonsearch/js_form.php @@ -3,7 +3,7 @@ data-secure="li.ms-selected:gt(0)"> <fieldset> <legend> - <?= htmlReady($title) ?: _('Nach Personen suchen') ?> + <?= isset($title) ? htmlReady($title) : _('Nach Personen suchen') ?> </legend> <label class="with-action"> diff --git a/app/views/tour/admin_details.php b/app/views/tour/admin_details.php index 3fbde8b1707..3bbd1fa8560 100644 --- a/app/views/tour/admin_details.php +++ b/app/views/tour/admin_details.php @@ -63,16 +63,16 @@ use Studip\Button, Studip\LinkButton; <label> <?= _('Zugang zur Tour') ?>: <select name="tour_access"> - <option value="link" <? if ($tour->settings->access === 'link') echo 'selected'; ?>> + <option value="link" <? if (isset($tour->settings) && $tour->settings->access === 'link') echo 'selected'; ?>> <?= _('unsichtbar') ?> </option> - <option value="standard" <? if ($tour->settings->access === 'standard') echo 'selected'; ?>> + <option value="standard" <? if (isset($tour->settings) && $tour->settings->access === 'standard') echo 'selected'; ?>> <?= _('Anzeige im Hilfecenter') ?> </option> - <option value="autostart" <? if ($tour->settings->access === 'autostart') echo 'selected'; ?>> + <option value="autostart" <? if (isset($tour->settings) && $tour->settings->access === 'autostart') echo 'selected'; ?>> <?= _('Startet bei jedem Aufruf der Seite, bis die Tour abgeschlossen wurde') ?> </option> - <option value="autostart_once" <? if ($tour->settings->access === 'autostart_once') echo 'selected'; ?>> + <option value="autostart_once" <? if (isset($tour->settings) && $tour->settings->access === 'autostart_once') echo 'selected'; ?>> <?= _('Startet nur beim ersten Aufruf der Seite') ?> </option> </select> diff --git a/app/views/tour/import.php b/app/views/tour/import.php index 1481cbc41e7..d913ca9dd28 100644 --- a/app/views/tour/import.php +++ b/app/views/tour/import.php @@ -11,7 +11,7 @@ <fieldset> <legend><?= _('Importieren') ?></legend> - <? if (!$tourdata) : ?> + <? if (empty($tourdata)) : ?> <label> <span class="required"><?= _('Datei:') ?></span> <input type="file" size="60" name="tour_file" @@ -47,7 +47,7 @@ </fieldset> <footer data-dialog-button> - <? if (!$tourdata) : ?> + <? if (empty($tourdata)) : ?> <?= Studip\Button::create(_('Importieren'), 'import_file', ['data-dialog' => 'size=auto;reload-on-close'])?> <? endif ?> <?= Studip\LinkButton::createCancel(_('Schließen'), $controller->url_for('tour/admin_overview')) ?> diff --git a/lib/export/export_studipdata_func.inc.php b/lib/export/export_studipdata_func.inc.php index bc2b9906e7d..179daf45fd4 100644 --- a/lib/export/export_studipdata_func.inc.php +++ b/lib/export/export_studipdata_func.inc.php @@ -815,7 +815,7 @@ function export_pers($inst_id) if (mb_strtolower($key) == 'email') { $row[$key] = get_visible_email($row['user_id']); } - if ($row[$key] != '') { + if (!empty($row[$key])) { $data_object .= xml_tag($val, $row[$key]); } } diff --git a/lib/models/CronjobSchedule.class.php b/lib/models/CronjobSchedule.class.php index cac458e7cfa..1231f2b12be 100644 --- a/lib/models/CronjobSchedule.class.php +++ b/lib/models/CronjobSchedule.class.php @@ -120,7 +120,7 @@ class CronjobSchedule extends SimpleORMap */ public function getTitle() { - return $this->content['title'] ?: $this->task->name; + return $this->content['title'] ?? ($this->task->name ?? ''); } protected function cbJsonifyParameters($type) diff --git a/lib/models/User.class.php b/lib/models/User.class.php index 06a4eae7d11..82709db4b4e 100644 --- a/lib/models/User.class.php +++ b/lib/models/User.class.php @@ -742,6 +742,9 @@ class User extends AuthUserMd5 implements Range, PrivacyObject if (Config::get()->VOTE_ENABLE) { $activeVotes = Questionnaire::countBySQL("user_id = ? AND visible = '1'", [$this->id]); $stoppedVotes = Questionnaire::countBySQL("user_id = ? AND visible = '0'", [$this->id]); + } else { + $activeVotes = []; + $stoppedVotes = []; } // Evaluations $evalDB = new EvaluationDB(); @@ -764,7 +767,7 @@ class User extends AuthUserMd5 implements Range, PrivacyObject 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), + 'visibility' => $homepage_visibility['motto'] ?? get_default_homepage_visibility($this->id), 'identifier' => 'privatedata' ]; } @@ -772,7 +775,7 @@ class User extends AuthUserMd5 implements Range, PrivacyObject 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), + 'visibility' => $homepage_visibility['skype_name'] ?? get_default_homepage_visibility($this->id), 'identifier' => 'privatedata' ]; } @@ -780,28 +783,28 @@ class User extends AuthUserMd5 implements Range, PrivacyObject 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), + 'visibility' => $homepage_visibility['private_phone'] ?? get_default_homepage_visibility($this->id), 'identifier' => 'privatedata' ]; } 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), + 'visibility' => $homepage_visibility['private_cell'] ?? get_default_homepage_visibility($this->id), 'identifier' => 'privatedata' ]; } 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), + 'visibility' => $homepage_visibility['privadr'] ?? get_default_homepage_visibility($this->id), 'identifier' => 'privatedata' ]; } 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), + 'visibility' => $homepage_visibility['homepage'] ?? get_default_homepage_visibility($this->id), 'extern' => true, 'identifier' => 'privatedata' ]; @@ -809,7 +812,7 @@ class User extends AuthUserMd5 implements Range, PrivacyObject 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), + 'visibility' => $homepage_visibility['news'] ?? get_default_homepage_visibility($this->id), 'extern' => true, 'identifier' => 'commondata' ]; @@ -817,7 +820,7 @@ class User extends AuthUserMd5 implements Range, PrivacyObject 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), + 'visibility' => $homepage_visibility['termine'] ?? get_default_homepage_visibility($this->id), 'extern' => true, 'identifier' => 'commondata' ]; @@ -825,7 +828,7 @@ class User extends AuthUserMd5 implements Range, PrivacyObject 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), + 'visibility' => $homepage_visibility['votes'] ?? get_default_homepage_visibility($this->id), 'identifier' => 'commondata' ]; } @@ -839,14 +842,14 @@ class User extends AuthUserMd5 implements Range, PrivacyObject 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), + 'visibility' => $homepage_visibility['studying'] ?? get_default_homepage_visibility($this->id), 'identifier' => 'studdata' ]; } 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), + 'visibility' => $homepage_visibility['lebenslauf'] ?? get_default_homepage_visibility($this->id), 'extern' => true, 'identifier' => 'privatedata' ]; @@ -854,14 +857,14 @@ class User extends AuthUserMd5 implements Range, PrivacyObject 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), + 'visibility' => $homepage_visibility['hobby'] ?? get_default_homepage_visibility($this->id), 'identifier' => 'privatedata' ]; } 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), + 'visibility' => $homepage_visibility['publi'] ?? get_default_homepage_visibility($this->id), 'extern' => true, 'identifier' => 'privatedata' ]; @@ -869,7 +872,7 @@ class User extends AuthUserMd5 implements Range, PrivacyObject 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), + 'visibility' => $homepage_visibility['schwerp'] ?? get_default_homepage_visibility($this->id), 'extern' => true, 'identifier' => 'privatedata' ]; @@ -880,7 +883,7 @@ class User extends AuthUserMd5 implements Range, PrivacyObject 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), + 'visibility' => $homepage_visibility[$key] ?? get_default_homepage_visibility($this->id), 'extern' => true, 'identifier' => 'additionaldata' ]; @@ -891,7 +894,7 @@ class User extends AuthUserMd5 implements Range, PrivacyObject foreach ($this->profile_categories as $category) { $homepage_elements['kat_' . $category->id] = [ 'name' => $category->name, - 'visibility' => $homepage_visibility['kat_' . $category->id] ?: get_default_homepage_visibility($this->id), + 'visibility' => $homepage_visibility['kat_' . $category->id] ?? get_default_homepage_visibility($this->id), 'extern' => true, 'identifier' => 'owncategory' ]; diff --git a/lib/models/UserDomain.php b/lib/models/UserDomain.php index 8179082a031..381f28c1eed 100644 --- a/lib/models/UserDomain.php +++ b/lib/models/UserDomain.php @@ -32,7 +32,7 @@ class UserDomain extends SimpleORMap $config['registered_callbacks']['before_store'][] = function ($domain) { if (!preg_match('/' . self::REGEXP . '/', $domain->id)) { - throw new Exception(_('Ungültige ID für Nutzerdomäne') . ': ' . $domain->id); + throw new Exception(_('Ungültige ID für Nutzerdomäne') . ': ' . htmlReady($domain->id)); } }; diff --git a/lib/statusgruppe.inc.php b/lib/statusgruppe.inc.php index 719cdce6950..709f0f03b46 100644 --- a/lib/statusgruppe.inc.php +++ b/lib/statusgruppe.inc.php @@ -108,7 +108,7 @@ function GetRoleNames($roles, $level = 0, $pred = '', $all = false) { if (is_array($roles)) foreach ($roles as $role_id => $role) { - if (!$role['name']) $role['name'] = $role['role']->getName(); + if (empty($role['name'])) $role['name'] = $role['role']->getName(); if ($pred != '') { $new_pred = $pred.' > '.$role['name']; @@ -116,11 +116,11 @@ function GetRoleNames($roles, $level = 0, $pred = '', $all = false) { $new_pred = $role['name']; } - if ($role['user_there'] || $all) { + if (!empty($role['user_there']) || $all) { $out[$role_id] = $new_pred; } - if ($role['child']) { + if (!empty($role['child'])) { $out = array_merge((array)$out, (array)GetRoleNames($role['child'], $level+1, $new_pred, $all)); } } diff --git a/public/export.php b/public/export.php index 9430a68bcbc..43a8491aa37 100644 --- a/public/export.php +++ b/public/export.php @@ -70,7 +70,7 @@ if (Config::get()->EXPORT_ENABLE) $xslt_process_done = false; $start_done = false; $xml_output_done = false; - + $xslt_choose_done = false; // Zurueckbutton benutzt? if (Request::submitted('back')) { -- GitLab From e726f119e6d1f04e67aed19d760944c680779ee7 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Thu, 24 Nov 2022 09:22:09 +0000 Subject: [PATCH 02/19] Apply 4 suggestion(s) to 4 file(s) --- app/views/multipersonsearch/js_form.php | 2 +- lib/models/CronjobSchedule.class.php | 2 +- lib/models/UserDomain.php | 2 +- lib/statusgruppe.inc.php | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/views/multipersonsearch/js_form.php b/app/views/multipersonsearch/js_form.php index 180da233cdd..63c2eaabfb4 100644 --- a/app/views/multipersonsearch/js_form.php +++ b/app/views/multipersonsearch/js_form.php @@ -3,7 +3,7 @@ data-secure="li.ms-selected:gt(0)"> <fieldset> <legend> - <?= isset($title) ? htmlReady($title) : _('Nach Personen suchen') ?> + <?= htmlReady($title ?? _('Nach Personen suchen')) ?> </legend> <label class="with-action"> diff --git a/lib/models/CronjobSchedule.class.php b/lib/models/CronjobSchedule.class.php index 1231f2b12be..37001287c69 100644 --- a/lib/models/CronjobSchedule.class.php +++ b/lib/models/CronjobSchedule.class.php @@ -120,7 +120,7 @@ class CronjobSchedule extends SimpleORMap */ public function getTitle() { - return $this->content['title'] ?? ($this->task->name ?? ''); + return $this->content['title'] ?? $this->task->name ?? ''; } protected function cbJsonifyParameters($type) diff --git a/lib/models/UserDomain.php b/lib/models/UserDomain.php index 381f28c1eed..8179082a031 100644 --- a/lib/models/UserDomain.php +++ b/lib/models/UserDomain.php @@ -32,7 +32,7 @@ class UserDomain extends SimpleORMap $config['registered_callbacks']['before_store'][] = function ($domain) { if (!preg_match('/' . self::REGEXP . '/', $domain->id)) { - throw new Exception(_('Ungültige ID für Nutzerdomäne') . ': ' . htmlReady($domain->id)); + throw new Exception(_('Ungültige ID für Nutzerdomäne') . ': ' . $domain->id); } }; diff --git a/lib/statusgruppe.inc.php b/lib/statusgruppe.inc.php index 709f0f03b46..41a60b94540 100644 --- a/lib/statusgruppe.inc.php +++ b/lib/statusgruppe.inc.php @@ -108,7 +108,9 @@ function GetRoleNames($roles, $level = 0, $pred = '', $all = false) { if (is_array($roles)) foreach ($roles as $role_id => $role) { - if (empty($role['name'])) $role['name'] = $role['role']->getName(); + if (empty($role['name'])) { + $role['name'] = $role['role']->getName(); + } if ($pred != '') { $new_pred = $pred.' > '.$role['name']; -- GitLab From 29186e68b59bf14ed58a04fec5b6fea74a02fade Mon Sep 17 00:00:00 2001 From: David Siegfried <ds.siegfried@gmail.com> Date: Wed, 23 Nov 2022 17:06:09 +0100 Subject: [PATCH 03/19] prevent php-warnings, refs #1807 --- .../admission/restricted_courses.php | 17 +++++++++-------- app/controllers/admission/rule.php | 2 -- app/controllers/admission/userlist.php | 6 +++--- app/controllers/calendar/calendar.php | 18 ++++++------------ app/controllers/calendar/contentbox.php | 4 ++-- app/controllers/calendar/group.php | 14 ++++++++++---- app/controllers/calendar/instschedule.php | 10 +++++----- app/controllers/calendar/schedule.php | 7 ++----- app/controllers/consultation/admin.php | 6 ++---- 9 files changed, 39 insertions(+), 45 deletions(-) diff --git a/app/controllers/admission/restricted_courses.php b/app/controllers/admission/restricted_courses.php index e215fd0f886..1b1de62ad14 100644 --- a/app/controllers/admission/restricted_courses.php +++ b/app/controllers/admission/restricted_courses.php @@ -32,7 +32,7 @@ class Admission_RestrictedCoursesController extends AuthenticatedController { $actions = new ActionsWidget(); - $actions->addLink(_("Export"), $this->url_for('admission/restricted_courses', ['csv' => 1]), Icon::create('export', 'clickable')); + $actions->addLink(_("Export"), $this->url_for('admission/restricted_courses', ['csv' => 1]), Icon::create('export')); Sidebar::get()->addWidget($actions); $sem_condition = ""; @@ -113,16 +113,14 @@ class Admission_RestrictedCoursesController extends AuthenticatedController } } if (is_array($this->not_distributed_coursesets)) { - PageLayout::postMessage(MessageBox::info( + PageLayout::postInfo( _("Es existieren Anmeldesets, die zum Zeitpunkt der Platzverteilung nicht gelost wurden. Stellen Sie sicher, dass der Cronjob \"Losverfahren überprüfen\" ausgeführt wird."), - array_unique($this->not_distributed_coursesets))); + array_unique($this->not_distributed_coursesets)); } } function get_courses($seminare_condition) { - global $perm, $user; - $chunks = explode('_', $this->current_institut_id); $institut_id = $chunks[0]; $all = $chunks[1] ?? null; @@ -148,7 +146,7 @@ class Admission_RestrictedCoursesController extends AuthenticatedController INNER JOIN seminare ON seminar_courseset.seminar_id=seminare.seminar_id LEFT JOIN semester_courses ON (seminare.Seminar_id = semester_courses.course_id) "; - if ($institut_id == 'all' && $perm->have_perm('root')) { + if ($institut_id == 'all' && $GLOBALS['perm']->have_perm('root')) { $sql .= "WHERE 1 {$seminare_condition} "; } elseif ($all == 'all') { $sql .= "INNER JOIN Institute USING (Institut_id) @@ -262,14 +260,17 @@ class Admission_RestrictedCoursesController extends AuthenticatedController $statement = DBManager::get()->prepare($query); $statement->execute($parameters); $temp = $statement->fetchAll(PDO::FETCH_ASSOC); - + $_my_inst = []; foreach ($temp as $row) { + if (!isset($_my_inst[$row['Institut_id']])) { + $_my_inst[$row['Institut_id']] = []; + } $_my_inst[$row['Institut_id']] = [ 'name' => $row['Name'], 'is_fak' => $row['is_fak'], 'count' => $row['count'], ]; - if ($row["is_fak"] && (!isset($row['inst_perms']) || $row['inst_perms'] !== 'dozent')) { + if ($row['is_fak'] && (!isset($row['inst_perms']) || $row['inst_perms'] !== 'dozent')) { $institute_statement->execute([$row['Institut_id']]); $alle = $institute_statement->fetchAll(); if (count($alle)) { diff --git a/app/controllers/admission/rule.php b/app/controllers/admission/rule.php index a8fd05edbb0..061cc4ee0f5 100644 --- a/app/controllers/admission/rule.php +++ b/app/controllers/admission/rule.php @@ -92,7 +92,6 @@ class Admission_RuleController extends AuthenticatedController public function save_action($ruleType, $ruleId = '') { CSRFProtection::verifyUnsafeRequest(); - $rules = AdmissionRule::getAvailableAdmissionRules(); $this->rule = new $ruleType($ruleId); $requestData = Request::getInstance(); // Check for start and end date and parse the String values to timestamps. @@ -120,7 +119,6 @@ class Admission_RuleController extends AuthenticatedController */ public function validate_action($ruleType, $ruleId = '') { - $rules = AdmissionRule::getAvailableAdmissionRules(); $rule = new $ruleType($ruleId); $this->errors = $rule->validate(Request::getInstance()); } diff --git a/app/controllers/admission/userlist.php b/app/controllers/admission/userlist.php index f2cda5797c1..4c86185cddf 100644 --- a/app/controllers/admission/userlist.php +++ b/app/controllers/admission/userlist.php @@ -64,13 +64,13 @@ class Admission_UserListController extends AuthenticatedController } $this->users = User::findMany(array_keys($this->userlist->getUsers())); if ($this->flash['name'] || $this->flash['factor'] || $this->flash['users'] || $this->flash['deleted_member']) { - if ($this->flash['name']) { + if (!empty($this->flash['name'])) { $this->userlist->setName($this->flash['name']); } - if ($this->flash['factor']) { + if (!empty($this->flash['factor'])) { $this->userlist->setFactor($this->flash['factor']); } - if ($this->flash['users'] || $this->flash['deleted_member']) { + if (!empty($this->flash['users']) || !empty($this->flash['deleted_member'])) { $this->users = User::findMany($this->flash['cleared_users'] ?: $this->flash['users'] ?: []); } } diff --git a/app/controllers/calendar/calendar.php b/app/controllers/calendar/calendar.php index 5ad138fc79e..1754b00399f 100644 --- a/app/controllers/calendar/calendar.php +++ b/app/controllers/calendar/calendar.php @@ -496,15 +496,12 @@ class Calendar_CalendarController extends AuthenticatedController if (Request::isXhr()) { $event->setTitle(Request::get('summary', '')); - $event->event->description = Request::get('description', ''); - $event->setUserDefinedCategories(Request::get('categories', '')); - $event->event->location = Request::get('location', ''); } else { $event->setTitle(Request::get('summary')); - $event->event->description = Request::get('description', ''); - $event->setUserDefinedCategories(Request::get('categories', '')); - $event->event->location = Request::get('location', ''); } + $event->event->description = Request::get('description', ''); + $event->setUserDefinedCategories(Request::get('categories', '')); + $event->event->location = Request::get('location', ''); $event->event->category_intern = Request::int('category_intern', 1); $event->setAccessibility(Request::option('accessibility', 'PRIVATE')); $event->setPriority(Request::int('priority', 0)); @@ -558,32 +555,29 @@ class Calendar_CalendarController extends AuthenticatedController $rrule['linterval'] = Request::int('linterval_m1', 1); $rrule['day'] = Request::int('day_m', strftime('%e', $event->getStart())); - $rrule['rtype'] = 'MONTHLY'; } else { $rrule['linterval'] = Request::int('linterval_m2', 1); $rrule['sinterval'] = Request::int('sinterval_m', 1); $rrule['wdays'] = Request::int('wday_m', strftime('%u', $event->getStart())); - $rrule['rtype'] = 'MONTHLY'; } + $rrule['rtype'] = 'MONTHLY'; break; case 'yearly': + $rrule['linterval'] = 1; if (Request::option('type_y', 'day') == 'day') { - $rrule['linterval'] = 1; $rrule['day'] = Request::int('day_y', strftime('%e', $event->getStart())); $rrule['month'] = Request::int('month_y1', date('n', $event->getStart())); - $rrule['rtype'] = 'YEARLY'; } else { - $rrule['linterval'] = 1; $rrule['sinterval'] = Request::int('sinterval_y', 1); $rrule['wdays'] = Request::int('wday_y', strftime('%u', $event->getStart())); $rrule['month'] = Request::int('month_y2', date('n', $event->getStart())); - $rrule['rtype'] = 'YEARLY'; } + $rrule['rtype'] = 'YEARLY'; break; } if (sizeof($messages)) { diff --git a/app/controllers/calendar/contentbox.php b/app/controllers/calendar/contentbox.php index f2689bfd106..129fb59c38b 100644 --- a/app/controllers/calendar/contentbox.php +++ b/app/controllers/calendar/contentbox.php @@ -80,7 +80,7 @@ class Calendar_ContentboxController extends StudipController { $course = Course::find($id); $dates = $course->getDatesWithExdates()->findBy('end_time', [$this->start, $this->start + $this->timespan], '><'); - + $this->termine = []; foreach ($dates as $courseDate) { // Build info $info = []; @@ -120,7 +120,7 @@ class Calendar_ContentboxController extends StudipController null, $restrictions ); - + $this->termine = []; // Prepare termine foreach ($events as $termin) { // Exclude events that begin after the given time range diff --git a/app/controllers/calendar/group.php b/app/controllers/calendar/group.php index 342a247a29f..f440a570cfb 100644 --- a/app/controllers/calendar/group.php +++ b/app/controllers/calendar/group.php @@ -18,12 +18,12 @@ class Calendar_GroupController extends Calendar_CalendarController $actions = new ActionsWidget(); $actions->addLink(_('Termin anlegen'), $this->url_for('calendar/group/edit'), - Icon::create('add', 'clickable'), + Icon::create('add'), ['data-dialog' => 'size=auto']); $actions->addLink(_('Kalender freigeben'), $this->url_for('calendar/single/manage_access/' . $GLOBALS['user']->id, ['group_filter' => $this->range_id]), - Icon::create('community', 'clickable'), + Icon::create('community'), ['id' => 'calendar-open-manageaccess', 'data-dialog' => '', 'data-dialogname' => 'manageaccess']); $sidebar->addWidget($actions); @@ -49,6 +49,7 @@ class Calendar_GroupController extends Calendar_CalendarController // the first calendar is the calendar of the actual user $this->calendar = new SingleCalendar($GLOBALS['user']->id); $group = $this->getGroup($this->calendar); + $this->attendee_ids = []; if ($group) { $calendar_owners = CalendarUser::getOwners($GLOBALS['user']->id, Calendar::PERMISSION_WRITABLE)->pluck('owner_id'); @@ -157,11 +158,11 @@ class Calendar_GroupController extends Calendar_CalendarController header('X-Dialog-Close: 1'); exit; } else { - PageLayout::postMessage(MessageBox::success(_('Der Termin wurde nicht geändert.'))); + PageLayout::postSuccess(_('Der Termin wurde nicht geändert.')); $this->relocate('calendar/group/' . $this->last_view, ['atime' => $this->atime]); } } else { - PageLayout::postMessage(MessageBox::success(_('Der Termin wurde gespeichert.'))); + PageLayout::postSuccess(_('Der Termin wurde gespeichert.')); $this->relocate('calendar/group/' . $this->last_view, ['atime' => $this->atime]); } } else { @@ -221,6 +222,7 @@ class Calendar_GroupController extends Calendar_CalendarController public function week_action($range_id = null) { + $this->calendars = []; $this->range_id = $range_id ?: $this->range_id; $timestamp = mktime(12, 0, 0, date('n', $this->atime), date('j', $this->atime), date('Y', $this->atime)); @@ -260,6 +262,7 @@ class Calendar_GroupController extends Calendar_CalendarController public function month_action($range_id = null) { + $this->calendars = []; $this->range_id = $range_id ?: $this->range_id; $month_start = mktime(12, 0, 0, date('n', $this->atime), 1, date('Y', $this->atime)); $month_end = mktime(12, 0, 0, date('n', $this->atime), date('t', $this->atime), date('Y', $this->atime)); @@ -299,6 +302,9 @@ class Calendar_GroupController extends Calendar_CalendarController public function year_action($range_id = null) { + $this->calendars = []; + $this->count_lists = []; + $this->range_id = $range_id ?: $this->range_id; $start = mktime(0, 0, 0, 1, 1, date('Y', $this->atime)); $end = mktime(23, 59, 59, 12, 31, date('Y', $this->atime)); diff --git a/app/controllers/calendar/instschedule.php b/app/controllers/calendar/instschedule.php index dcf6ddf2bf0..452e71db0db 100644 --- a/app/controllers/calendar/instschedule.php +++ b/app/controllers/calendar/instschedule.php @@ -20,7 +20,7 @@ class Calendar_InstscheduleController extends AuthenticatedController * this action is the main action of the schedule-controller, setting the environment for the timetable, * accepting a comma-separated list of days. * - * @param string a list of an arbitrary mix of the numbers 0-6, separated with a comma (e.g. 1,2,3,4,5 (for Monday to Friday, the default)) + * @param string $days a list of an arbitrary mix of the numbers 0-6, separated with a comma (e.g. 1,2,3,4,5 (for Monday to Friday, the default)) */ function index_action($days = false) { @@ -108,14 +108,14 @@ class Calendar_InstscheduleController extends AuthenticatedController $this->url_for('calendar/instschedule/index/'. implode(',', $this->days), ['printview' => 'true', 'semester_id' => $this->current_semester['semester_id']]), - Icon::create('print', 'clickable'), + Icon::create('print'), ['target' => '_blank']); // Only admins should have the ability to change their schedule settings here - they have no other schedule if ($GLOBALS['perm']->have_perm('admin')) { $actions->addLink(_("Darstellung ändern"), $this->url_for('calendar/schedule/settings'), - Icon::create('admin', 'clickable'), + Icon::create('admin'), ['data-dialog' => ''] ); @@ -124,12 +124,12 @@ class Calendar_InstscheduleController extends AuthenticatedController if ($GLOBALS['user']->cfg->MY_INSTITUTES_INCLUDE_CHILDREN) { $actions->addLink(_("Untergeordnete Institute ignorieren"), $this->url_for('calendar/instschedule/include_children/0'), - Icon::create('checkbox-checked', 'clickable') + Icon::create('checkbox-checked') ); } else { $actions->addLink(_("Untergeordnete Institute einbeziehen"), $this->url_for('calendar/instschedule/include_children/1'), - Icon::create('checkbox-unchecked', 'clickable') + Icon::create('checkbox-unchecked') ); } } diff --git a/app/controllers/calendar/schedule.php b/app/controllers/calendar/schedule.php index 67a45773894..5a9f7877412 100644 --- a/app/controllers/calendar/schedule.php +++ b/app/controllers/calendar/schedule.php @@ -114,7 +114,7 @@ class Calendar_ScheduleController extends AuthenticatedController : CalendarScheduleModel::getUserCalendarView($GLOBALS['user']->id, $show_hidden, $this->current_semester, $this->days);; // have we chosen an entry to display? - if ($this->flash['entry']) { + if (!empty($this->flash['entry'])) { if ($inst_mode) { $this->show_entry = $this->flash['entry']; } else if ($this->flash['entry']['id'] == null) { @@ -162,10 +162,7 @@ class Calendar_ScheduleController extends AuthenticatedController $this->inst_mode = $inst_mode; $this->institute_name = $inst['name']; $this->institute_id = $institute_id; - - if (Request::get('show_settings')) { - $this->show_settings = true; - } + $this->show_settings = Request::get('show_settings', false); } public function new_entry_action() diff --git a/app/controllers/consultation/admin.php b/app/controllers/consultation/admin.php index 016167ec6e3..4b8ce7ef048 100644 --- a/app/controllers/consultation/admin.php +++ b/app/controllers/consultation/admin.php @@ -286,7 +286,6 @@ class Consultation_AdminController extends ConsultationController throw new MethodNotAllowedException(); } - $is_expired = false; if (!$slot_id) { $block = $this->loadBlock($block_id); $is_expired = $block->is_expired; @@ -534,7 +533,7 @@ class Consultation_AdminController extends ConsultationController 'CONSULTATION_SEND_MESSAGES', (bool) $state ); - } elseif ($what === 'garbage') { + } elseif ($what === 'garbage' && !empty($this->range_config)) { // TODO: Not available for course $this->range_config->store( 'CONSULTATION_GARBAGE_COLLECT', @@ -657,7 +656,6 @@ class Consultation_AdminController extends ConsultationController ); if (array_sum($deleted) > 0) { - $message = []; if ($deleted['current'] > 0) { PageLayout::postSuccess(sprintf( _('%u aktuelle Termine wurden gelöscht'), @@ -682,7 +680,7 @@ class Consultation_AdminController extends ConsultationController $slots = $this->getSlotsFromBulk(); } else { $block = $this->loadBlock($block_id); - + $slots = []; foreach ($block->slots as $slot) { if ($slot_id && $slot->id != $slot_id) { continue; -- GitLab From d39c53552fa2fe0cc5a99169ffd4fb5ecde30719 Mon Sep 17 00:00:00 2001 From: David Siegfried <ds.siegfried@gmail.com> Date: Wed, 23 Nov 2022 17:16:31 +0100 Subject: [PATCH 04/19] prevent php-warnings, refs #1807 --- app/controllers/course/forum/admin.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/controllers/course/forum/admin.php b/app/controllers/course/forum/admin.php index a7fff7196e3..c4a23bf73ce 100644 --- a/app/controllers/course/forum/admin.php +++ b/app/controllers/course/forum/admin.php @@ -31,9 +31,11 @@ class Course_Forum_AdminController extends ForumController // sort by cat $new_list = []; + $this->categories = []; // iterate over all categories and add the belonging areas to them - foreach ($categories = ForumCat::getListWithAreas($this->getId(), false) as $category) { - if ($category['topic_id']) { + $categories = ForumCat::getListWithAreas($this->getId(), false) ; + foreach ($categories as $category) { + if (!empty($category['topic_id'])) { $new_list[$category['category_id']][$category['topic_id']] = $list['list'][$category['topic_id']]; unset($list['list'][$category['topic_id']]); } else if (ForumPerm::has('add_area', $this->seminar_id)) { @@ -50,10 +52,10 @@ class Course_Forum_AdminController extends ForumController $this->list = $new_list; } - + /** * show child entries for the passed entry - * + * * @param string $parent_id id of entry to get the childs for */ function childs_action($parent_id) @@ -73,7 +75,7 @@ class Course_Forum_AdminController extends ForumController /** * move the submitted topics[] to the passed destination - * + * * @param string $destination id of seminar to move topics to */ function move_action($destination) @@ -82,8 +84,10 @@ class Course_Forum_AdminController extends ForumController if (ForumCat::get($destination)) { $category_id = $destination; $destination = $this->getId(); + } else { + $category_id = null; } - + ForumPerm::check('admin', $this->getId(), $destination); foreach (Request::getArray('topics') as $topic_id) { @@ -113,11 +117,11 @@ class Course_Forum_AdminController extends ForumController ForumEntry::move($entry['topic_id'], $thread['id']); } - + // add entry to passed category when moving to the top if ($category_id) { ForumCat::addArea($category_id, $topic_id); - } + } } } -- GitLab From 8125c4f00dab642db868dd1f488b0455ec5c74e8 Mon Sep 17 00:00:00 2001 From: David Siegfried <ds.siegfried@gmail.com> Date: Thu, 24 Nov 2022 10:11:32 +0100 Subject: [PATCH 05/19] prevent php-warnings, refs #1807 --- app/controllers/course/admission.php | 13 +++++++------ app/controllers/course/basicdata.php | 9 ++++++--- app/controllers/course/block_appointments.php | 4 ++-- app/controllers/course/cancel_dates.php | 1 + app/controllers/course/dates.php | 6 ++++-- app/controllers/course/forum/admin.php | 15 +++++++++------ app/controllers/course/forum/area.php | 3 +-- app/controllers/course/forum/index.php | 13 +++++++------ app/controllers/course/gradebook/lecturers.php | 8 ++------ app/controllers/course/gradebook/students.php | 2 +- app/controllers/resources/admin.php | 2 +- app/controllers/resources/category.php | 2 +- lib/classes/ForumEntry.php | 6 +++--- 13 files changed, 45 insertions(+), 39 deletions(-) diff --git a/app/controllers/course/admission.php b/app/controllers/course/admission.php index 96a0b61eb5a..938b731a130 100644 --- a/app/controllers/course/admission.php +++ b/app/controllers/course/admission.php @@ -40,6 +40,7 @@ class Course_AdmissionController extends AuthenticatedController PageLayout::setTitle($this->course->getFullname()." - " ._("Verwaltung von Zugangsberechtigungen")); $lockrules = words('admission_turnout admission_type admission_endtime admission_binding passwort read_level write_level admission_prelim admission_prelim_txt admission_starttime admission_endtime_sem admission_disable_waitlist user_domain admission_binding admission_studiengang'); + $this->is_locked = []; foreach ($lockrules as $rule) { $this->is_locked[$rule] = LockRules::Check($this->course_id, $rule) ? 'disabled readonly' : ''; } @@ -119,7 +120,7 @@ class Course_AdmissionController extends AuthenticatedController { CSRFProtection::verifyUnsafeRequest(); PageLayout::setTitle(_('Anmeldemodus ändern')); - + $request = null; if (Request::submitted('change_admission_prelim')) { $request = Request::extract('admission_prelim int, admission_binding submitted, admission_prelim_txt'); $request = array_diff_key($request, array_filter($this->is_locked)); @@ -197,7 +198,7 @@ class Course_AdmissionController extends AuthenticatedController unset($question); } } - if (!$question) { + if (!isset($question)) { $this->redirect($this->action_url('index')); } else { $this->button_yes = 'change_admission_prelim_yes'; @@ -246,7 +247,7 @@ class Course_AdmissionController extends AuthenticatedController { CSRFProtection::verifyUnsafeRequest(); PageLayout::setTitle(_('Teilnehmendenanzahl ändern')); - + $request = null; if (Request::submitted('change_admission_turnout')) { $request = Request::extract('admission_turnout int, admission_disable_waitlist submitted, admission_disable_waitlist_move submitted, admission_waitlist_max int'); $request = array_diff_key($request, array_filter($this->is_locked)); @@ -302,7 +303,7 @@ class Course_AdmissionController extends AuthenticatedController unset($question); } } - if (!$question) { + if (!isset($question)) { $this->redirect($this->action_url('index')); } else { $this->request = $request; @@ -359,7 +360,7 @@ class Course_AdmissionController extends AuthenticatedController $question = sprintf(_("In dieser Veranstaltung existiert eine Anmeldeliste (Platzverteilung am %s). Die bestehende Anmeldeliste mit %s Einträgen wird gelöscht. Sind sie sicher?"), strftime('%x %R', $cs->getSeatDistributionTime()), count($priorities)); } } - if (!$question && $cs) { + if (!isset($question) && $cs) { CourseSet::removeCourseFromSet($cs->getId(), $this->course_id); $cs->load(); if (!in_array($this->course_id, $cs->getCourses())) { @@ -390,7 +391,7 @@ class Course_AdmissionController extends AuthenticatedController } } } - if (!$question) { + if (!isset($question)) { $this->redirect($this->action_url('index')); } else { $this->request = ['change_course_set_unassign' => 1]; diff --git a/app/controllers/course/basicdata.php b/app/controllers/course/basicdata.php index a2524b4a375..baa817a0fd5 100644 --- a/app/controllers/course/basicdata.php +++ b/app/controllers/course/basicdata.php @@ -481,7 +481,10 @@ class Course_BasicdataController extends AuthenticatedController } if (sizeof($before) && sizeof($after)) { - foreach($before as $k => $v) $log_message .= "$k: $v => " . $after[$k] . " \n"; + $log_message = ''; + foreach ($before as $k => $v) { + $log_message .= "$k: $v => " . $after[$k] . " \n"; + } StudipLog::log('CHANGE_BASIC_DATA', $sem->getId(), " ", $log_message); NotificationCenter::postNotification('SeminarBasicDataDidUpdate', $sem->id , $GLOBALS['user']->id); } @@ -849,10 +852,10 @@ class Course_BasicdataController extends AuthenticatedController $this->redirect($this->url_for('course/basicdata/view/' . $sem->getId())); } - public function switchdeputy_action($course_id, $newstatus) { + public function switchdeputy_action($course_id, $newstatus) + { CSRFProtection::verifySecurityToken(); - $course = Seminar::getInstance($course_id); switch($newstatus) { case 'dozent': $dozent = new CourseMember(); diff --git a/app/controllers/course/block_appointments.php b/app/controllers/course/block_appointments.php index 67035fa356c..31daa0dae1a 100644 --- a/app/controllers/course/block_appointments.php +++ b/app/controllers/course/block_appointments.php @@ -122,7 +122,8 @@ class Course_BlockAppointmentsController extends AuthenticatedController $start_day = strtotime(Request::get('block_appointments_start_day')); $end_day = strtotime(Request::get('block_appointments_end_day')); - + $start_time = null; + $end_time = null; if (!($start_day && $end_day && $start_day <= $end_day)) { $errors[] = _('Bitte geben Sie korrekte Werte für Start- und Enddatum an!'); } else { @@ -236,7 +237,6 @@ class Course_BlockAppointmentsController extends AuthenticatedController 'block_appointments_days' => $days ]; $dates_created = array_filter(array_map(function ($d) use ($free_room_text) { - $result = false; if (!Request::get('room_id')) { $d->raum = $free_room_text; $result = $d->store(); diff --git a/app/controllers/course/cancel_dates.php b/app/controllers/course/cancel_dates.php index 98fb91b50f8..f3420cb388c 100644 --- a/app/controllers/course/cancel_dates.php +++ b/app/controllers/course/cancel_dates.php @@ -53,6 +53,7 @@ class Course_CancelDatesController extends AuthenticatedController { CSRFProtection::verifyUnsafeRequest(); $sem = Seminar::getInstance($this->course_id); + $msg = ''; foreach ($this->dates as $date) { $sem->cancelSingleDate($date->getTerminId(), $date->getMetadateId()); $date->setComment(Request::get('cancel_dates_comment')); diff --git a/app/controllers/course/dates.php b/app/controllers/course/dates.php index 9c803b7e53e..024e8dbb6b4 100644 --- a/app/controllers/course/dates.php +++ b/app/controllers/course/dates.php @@ -136,7 +136,7 @@ class Course_DatesController extends AuthenticatedController public function details_action($termin_id) { $this->date = new CourseDate($termin_id); - + $this->teachers = []; Navigation::activateItem('/course/schedule/dates'); PageLayout::setTitle( $this->date->getTypeName() . ': ' . @@ -182,7 +182,9 @@ class Course_DatesController extends AuthenticatedController $this->assignLockRulesToTemplate(); Navigation::activateItem('/course/schedule/dates'); - + $start_time = null; + $end_time = null; + $xtitle = ''; if (Request::isPost()) { CSRFProtection::verifyUnsafeRequest(); diff --git a/app/controllers/course/forum/admin.php b/app/controllers/course/forum/admin.php index c4a23bf73ce..e4d21d89dc2 100644 --- a/app/controllers/course/forum/admin.php +++ b/app/controllers/course/forum/admin.php @@ -108,14 +108,17 @@ class Course_Forum_AdminController extends ForumController // second step: move all to deep childs a level up (depth > 3) $data = ForumEntry::getList('depth_to_large', $topic_id); - foreach ($data['list'] as $entry) { - $path = ForumEntry::getPathToPosting($entry['topic_id']); - array_shift($path); // Category - array_shift($path); // Area - $thread = array_shift($path); // Thread + if (!empty($data['list'])) { + foreach ($data['list'] as $entry) { + $path = ForumEntry::getPathToPosting($entry['topic_id']); + array_shift($path); // Category + array_shift($path); // Area - ForumEntry::move($entry['topic_id'], $thread['id']); + $thread = array_shift($path); // Thread + + ForumEntry::move($entry['topic_id'], $thread['id']); + } } // add entry to passed category when moving to the top diff --git a/app/controllers/course/forum/area.php b/app/controllers/course/forum/area.php index a93860aa5c5..821129f6bf6 100644 --- a/app/controllers/course/forum/area.php +++ b/app/controllers/course/forum/area.php @@ -48,11 +48,10 @@ class Course_Forum_AreaController extends ForumController { ForumPerm::check('edit_area', $this->getId(), $area_id); + ForumEntry::update($area_id, Request::get('name'), Request::get('content')); if (Request::isAjax()) { - ForumEntry::update($area_id, Request::get('name'), Request::get('content')); $this->render_json(['content' => ForumEntry::killFormat(ForumEntry::killEdit(Request::get('content')))]); } else { - ForumEntry::update($area_id, Request::get('name'), Request::get('content')); $this->flash['messages'] = ['success' => _('Die Änderungen am Bereich wurden gespeichert.')]; $this->redirect('course/forum/index/index'); } diff --git a/app/controllers/course/forum/index.php b/app/controllers/course/forum/index.php index 97484616de2..d479afd5bd4 100644 --- a/app/controllers/course/forum/index.php +++ b/app/controllers/course/forum/index.php @@ -108,8 +108,9 @@ class Course_Forum_IndexController extends ForumController if ($this->constraint['depth'] == 0) { // BEREICHE $new_list = []; + $this->categories = []; // iterate over all categories and add the belonging areas to them - foreach ($categories = ForumCat::getListWithAreas($this->getId(), false) as $category) { + foreach (ForumCat::getListWithAreas($this->getId(), false) as $category) { if ($category['topic_id']) { $new_list[$category['category_id']][$category['topic_id']] = $list['list'][$category['topic_id']]; unset($list['list'][$category['topic_id']]); @@ -237,7 +238,7 @@ class Course_Forum_IndexController extends ForumController $this->postings = $list['list']; $this->number_of_entries = $list['count']; $this->show_full_path = true; - + $this->no_entries = false; if (empty($this->postings)) { $this->no_entries = true; } @@ -270,7 +271,7 @@ class Course_Forum_IndexController extends ForumController $this->postings = $list['list']; $this->number_of_entries = $list['count']; $this->show_full_path = true; - + $this->no_entries = false; if (empty($this->postings)) { $this->no_entries = true; } @@ -306,8 +307,8 @@ class Course_Forum_IndexController extends ForumController $this->section = 'search'; $this->topic_id = $this->getId(); - $this->show_full_path = true; - + $this->show_full_path = true; + $this->options = []; // parse filter-options foreach (['search_title', 'search_content', 'search_author'] as $option) { $this->options[$option] = Request::option($option); @@ -417,7 +418,7 @@ class Course_Forum_IndexController extends ForumController // get the page of the posting to be able to jump there again $page = ForumEntry::getPostingPage($topic_id); URLHelper::addLinkParam('page', $page); - + $parent = null; if (ForumPerm::hasEditPerms($topic_id) || ForumPerm::check('remove_entry', $this->getId(), $topic_id)) { $path = ForumEntry::getPathToPosting($topic_id); $topic = array_pop($path); diff --git a/app/controllers/course/gradebook/lecturers.php b/app/controllers/course/gradebook/lecturers.php index b934badbd96..2e98856e7fc 100644 --- a/app/controllers/course/gradebook/lecturers.php +++ b/app/controllers/course/gradebook/lecturers.php @@ -147,9 +147,7 @@ class Course_Gradebook_LecturersController extends AuthenticatedController $course = \Context::get(); $gradingDefinitions = Definition::findByCourse($course); $this->groupedDefinitions = $this->getGroupedDefinitions($gradingDefinitions); - $this->customDefinitions = isset($this->groupedDefinitions[Definition::CUSTOM_DEFINITIONS_CATEGORY]) - ? $this->groupedDefinitions[Definition::CUSTOM_DEFINITIONS_CATEGORY] - : []; + $this->customDefinitions = $this->groupedDefinitions[Definition::CUSTOM_DEFINITIONS_CATEGORY] ?? []; $this->students = $course->getMembersWithStatus('autor', true)->orderBy('nachname, vorname'); $this->groupedInstances = $this->groupedInstances($course); @@ -196,9 +194,7 @@ class Course_Gradebook_LecturersController extends AuthenticatedController $course = \Context::get(); $gradingDefinitions = Definition::findByCourse($course); $this->groupedDefinitions = $this->getGroupedDefinitions($gradingDefinitions); - $this->customDefinitions = isset($this->groupedDefinitions[Definition::CUSTOM_DEFINITIONS_CATEGORY]) - ? $this->groupedDefinitions[Definition::CUSTOM_DEFINITIONS_CATEGORY] - : []; + $this->customDefinitions = $this->groupedDefinitions[Definition::CUSTOM_DEFINITIONS_CATEGORY] ?? []; } /** diff --git a/app/controllers/course/gradebook/students.php b/app/controllers/course/gradebook/students.php index 06c983d8bd6..81a1f7fc9e0 100644 --- a/app/controllers/course/gradebook/students.php +++ b/app/controllers/course/gradebook/students.php @@ -69,7 +69,7 @@ class Course_Gradebook_StudentsController extends AuthenticatedController $lines = []; foreach ($this->categories as $category) { foreach ($this->groupedDefinitions[$category] as $definition) { - $instance = isset($this->groupedInstances[$definition->id]) ? $this->groupedInstances[$definition->id] : null; + $instance = $this->groupedInstances[$definition->id] ?? null; $lines[] = [ $category, $definition->name, diff --git a/app/controllers/resources/admin.php b/app/controllers/resources/admin.php index 13a0dd4003b..393cacb3770 100644 --- a/app/controllers/resources/admin.php +++ b/app/controllers/resources/admin.php @@ -119,7 +119,7 @@ class Resources_AdminController extends AuthenticatedController ); $this->sidebar->addWidget($user_search); - + $this->last_activity_date = null; $user_id = Request::get('user_id'); $this->user = User::find($user_id); if ($this->user) { diff --git a/app/controllers/resources/category.php b/app/controllers/resources/category.php index 76f55fdbca9..e5403859a75 100644 --- a/app/controllers/resources/category.php +++ b/app/controllers/resources/category.php @@ -59,7 +59,7 @@ class Resources_CategoryController extends AuthenticatedController 'TRUE ORDER BY name ASC' ); //Load the properties: - if ($this->category->property_links) { + if (!empty($this->category->property_links)) { foreach ($this->category->property_links as $link) { //We want to make sure that only properties that are //defined are displayed. diff --git a/lib/classes/ForumEntry.php b/lib/classes/ForumEntry.php index 776b6b19d23..61cbd75c181 100644 --- a/lib/classes/ForumEntry.php +++ b/lib/classes/ForumEntry.php @@ -597,7 +597,7 @@ class ForumEntry implements PrivacyObject public static function getList($type, $parent_id) { $start = (ForumHelpers::getPage() - 1) * ForumEntry::POSTINGS_PER_PAGE; - + $last_visit_date = ForumVisit::getLastVisit($constraint['seminar_id']); switch ($type) { case 'area': $list = ForumEntry::getEntries($parent_id, ForumEntry::WITHOUT_CHILDS, '', 'DESC', 0, 1000); @@ -650,7 +650,7 @@ class ForumEntry implements PrivacyObject $stmt->bindParam(':seminar_id', $constraint['seminar_id']); $stmt->bindParam(':left', $constraint['lft']); $stmt->bindParam(':right', $constraint['rgt']); - $stmt->bindParam(':mkdate', ForumVisit::getLastVisit($constraint['seminar_id'])); + $stmt->bindParam(':mkdate', $last_visit_date); $stmt->bindParam(':user_id', $GLOBALS['user']->id); $stmt->execute(); @@ -669,7 +669,7 @@ class ForumEntry implements PrivacyObject $stmt_count->bindParam(':seminar_id', $constraint['seminar_id']); $stmt_count->bindParam(':left', $constraint['lft']); $stmt_count->bindParam(':right', $constraint['rgt']); - $stmt_count->bindParam(':mkdate', ForumVisit::getLastVisit($constraint['seminar_id'])); + $stmt_count->bindParam(':mkdate', $last_visit_date); $stmt_count->execute(); -- GitLab From 63b363e56aec8e897661700b89757df44055ed94 Mon Sep 17 00:00:00 2001 From: David Siegfried <ds.siegfried@gmail.com> Date: Thu, 24 Nov 2022 10:22:37 +0100 Subject: [PATCH 06/19] prevent php-warnings, refs #1807 --- app/controllers/course/elearning.php | 24 ++++++++++++++---------- app/controllers/course/enrolment.php | 8 ++++++-- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/app/controllers/course/elearning.php b/app/controllers/course/elearning.php index 2b0061885b4..f568d79f037 100644 --- a/app/controllers/course/elearning.php +++ b/app/controllers/course/elearning.php @@ -102,16 +102,20 @@ class Course_ElearningController extends AuthenticatedController $content_modules_list = []; if ($object_connections->isConnected()) { $caching_active = true; - foreach ($connected_modules as $key => $connection) { - if (ELearningUtils::isCMSActive($connection["cms"])) { + $type_tmp = []; - ELearningUtils::loadClass($connection["cms"]); + if (!empty($connected_modules)) { + foreach ($connected_modules as $key => $connection) { + if (ELearningUtils::isCMSActive($connection["cms"])) { - $connected_cms[$connection["cms"]]->newContentModule($connection["id"], $connection["type"], true); - $connected_modules[$key]['title'] = $connected_cms[$connection["cms"]]->content_module[$connection["id"]]->getTitle(); - $title_tmp[$key] = str_replace(['ä','ö','ü','ß'],['ae','oe','ue','ss'],mb_strtolower($connected_modules[$key]['title'])); - $type_tmp[$key] = array_search($connection['type'], array_keys($GLOBALS['ELEARNING_INTERFACE_MODULES'][$connection["cms"]]['types'])); - $class_tmp[$key] = $GLOBALS['ELEARNING_INTERFACE_MODULES'][$connection["cms"]]["CLASS_PREFIX"]; + ELearningUtils::loadClass($connection["cms"]); + + $connected_cms[$connection["cms"]]->newContentModule($connection["id"], $connection["type"], true); + $connected_modules[$key]['title'] = $connected_cms[$connection["cms"]]->content_module[$connection["id"]]->getTitle(); + $title_tmp[$key] = str_replace(['ä','ö','ü','ß'],['ae','oe','ue','ss'],mb_strtolower($connected_modules[$key]['title'])); + $type_tmp[$key] = array_search($connection['type'], array_keys($GLOBALS['ELEARNING_INTERFACE_MODULES'][$connection["cms"]]['types'])); + $class_tmp[$key] = $GLOBALS['ELEARNING_INTERFACE_MODULES'][$connection["cms"]]["CLASS_PREFIX"]; + } } } array_multisort($class_tmp, SORT_ASC, $type_tmp, SORT_ASC, $title_tmp, SORT_ASC, $connected_modules); @@ -133,7 +137,7 @@ class Course_ElearningController extends AuthenticatedController $content_modules_list[$index]['module'] = $connected_cms[$connection["cms"]]->content_module[$connection["id"]]->view->show(); } } - if (($this->module_count == 0) AND ($this->new_account_cms == "")) { + if (($this->module_count == 0) && ($this->new_account_cms == "")) { if (Context::isInstitute()) { PageLayout::postInfo(_('Momentan sind dieser Einrichtung keine Lernmodule zugeordnet.')); } else { @@ -182,7 +186,7 @@ class Course_ElearningController extends AuthenticatedController // ggf. bestehenden Ilias4-Kurs zuordnen if (Request::submitted('connect_course')) { - if ((ObjectConnections::getConnectionModuleId(Request::option("connect_course_sem_id"), "crs", $this->cms_select)) AND ($GLOBALS['perm']->have_studip_perm("dozent", Request::option("connect_course_sem_id")))) { + if ((ObjectConnections::getConnectionModuleId(Request::option("connect_course_sem_id"), "crs", $this->cms_select)) && ($GLOBALS['perm']->have_studip_perm("dozent", Request::option("connect_course_sem_id")))) { ObjectConnections::setConnection($this->seminar_id, ObjectConnections::getConnectionModuleId(Request::option("connect_course_sem_id"), "crs", $this->cms_select), "crs", $this->cms_select); PageLayout::postInfo(_('Zuordnung wurde gespeichert.')); ELearningUtils::loadClass($this->cms_select); diff --git a/app/controllers/course/enrolment.php b/app/controllers/course/enrolment.php index a1e50237266..a9ca3516bf6 100644 --- a/app/controllers/course/enrolment.php +++ b/app/controllers/course/enrolment.php @@ -83,14 +83,17 @@ class Course_EnrolmentController extends AuthenticatedController } catch (Exception $e) { $this->confirmed = false; } - + $msg_details = []; + $msg = ''; $user_id = $GLOBALS['user']->id; + $enrol_user = false; $courseset = CourseSet::getSetForCourse($this->course_id); if ($courseset) { $errors = $courseset->checkAdmission($user_id, $this->course_id); if (count($errors)) { $this->courseset_message = $courseset->toString(true); $this->admission_error = MessageBox::error(_("Die Anmeldung war nicht erfolgreich."), $errors); + $admission_form = ''; foreach ($courseset->getAdmissionRules() as $rule) { $admission_form .= $rule->getInput(); } @@ -231,7 +234,7 @@ class Course_EnrolmentController extends AuthenticatedController StudipLock::release(); if ($enrol_user && $this->confirmed) { - if ($course->admission_prelim) { + if (!empty($course) && $course->admission_prelim) { $this->relocate(URLHelper::getLink('dispatch.php/course/details', ['sem_id' => $this->course_id])); } else { $this->relocate(URLHelper::getLink('seminar_main.php', ['auswahl' => $this->course_id])); @@ -260,6 +263,7 @@ class Course_EnrolmentController extends AuthenticatedController $user_id = $GLOBALS['user']->id; $courseset = CourseSet::getSetForCourse($this->course_id); $anchor = ''; + $changed = 0; if ($courseset->isSeatDistributionEnabled() && !count($courseset->checkAdmission($user_id, $this->course_id))) { if ($limit = $courseset->getAdmissionRule('LimitedAdmission')) { $admission_user_limit = Request::int('admission_user_limit'); -- GitLab From 7db84d0f172472adea2fd321ef354fbee35ffe5c Mon Sep 17 00:00:00 2001 From: David Siegfried <ds.siegfried@gmail.com> Date: Thu, 24 Nov 2022 10:28:01 +0100 Subject: [PATCH 07/19] prevent php-warnings, refs #1807 --- app/controllers/course/lti.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/course/lti.php b/app/controllers/course/lti.php index 01c57ded24c..2183aae9d1c 100644 --- a/app/controllers/course/lti.php +++ b/app/controllers/course/lti.php @@ -291,7 +291,8 @@ class Course_LtiController extends StudipController $lti_data->description = Studip\Markup::purifyHtml(Studip\Markup::markAsHtml($item['text'])); $lti_data->tool_id = $tool_id; $lti_data->launch_url = (string) $item['url']; - + $custom_parameters = ''; + $options = []; if (is_array($item['custom'])) { foreach ($item['custom'] as $key => $value) { $custom_parameters .= $key . '=' . $value . "\n"; -- GitLab From 3f4a6c42b1b69843e383861e02c6ad7bb9af5983 Mon Sep 17 00:00:00 2001 From: David Siegfried <ds.siegfried@gmail.com> Date: Tue, 21 Feb 2023 13:30:40 +0100 Subject: [PATCH 08/19] revert, refs #1807 --- app/controllers/admin/datafields.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/admin/datafields.php b/app/controllers/admin/datafields.php index 3485e4b92da..bf390c9fcbc 100644 --- a/app/controllers/admin/datafields.php +++ b/app/controllers/admin/datafields.php @@ -140,6 +140,7 @@ class Admin_DatafieldsController extends AuthenticatedController public function new_action($type = null) { $this->datafield = new DataField(); + PageLayout::setTitle(_('Neues Datenfeld anlegen')); if (Request::submitted('anlegen')) { -- GitLab From 4a2ff43bc173b74022fedd5e2bc5bbf11feb40e8 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Thu, 2 Mar 2023 09:12:19 +0000 Subject: [PATCH 09/19] Apply 1 suggestion(s) to 1 file(s) --- app/controllers/admission/restricted_courses.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/admission/restricted_courses.php b/app/controllers/admission/restricted_courses.php index 1b1de62ad14..aafb589e44d 100644 --- a/app/controllers/admission/restricted_courses.php +++ b/app/controllers/admission/restricted_courses.php @@ -146,7 +146,7 @@ class Admission_RestrictedCoursesController extends AuthenticatedController INNER JOIN seminare ON seminar_courseset.seminar_id=seminare.seminar_id LEFT JOIN semester_courses ON (seminare.Seminar_id = semester_courses.course_id) "; - if ($institut_id == 'all' && $GLOBALS['perm']->have_perm('root')) { + if ($institut_id === 'all' && $GLOBALS['perm']->have_perm('root')) { $sql .= "WHERE 1 {$seminare_condition} "; } elseif ($all == 'all') { $sql .= "INNER JOIN Institute USING (Institut_id) -- GitLab From 5f54e5f1dd7c5ac634751ff819840bbe3471abc1 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+github@gmail.com> Date: Thu, 2 Mar 2023 10:22:27 +0100 Subject: [PATCH 10/19] adjustments due to code review, re #1807 --- app/controllers/calendar/calendar.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/app/controllers/calendar/calendar.php b/app/controllers/calendar/calendar.php index 1754b00399f..09eeaab6f77 100644 --- a/app/controllers/calendar/calendar.php +++ b/app/controllers/calendar/calendar.php @@ -494,11 +494,7 @@ class Calendar_CalendarController extends AuthenticatedController $messages[] = _('Die Startzeit muss vor der Endzeit liegen.'); } - if (Request::isXhr()) { - $event->setTitle(Request::get('summary', '')); - } else { - $event->setTitle(Request::get('summary')); - } + $event->setTitle(Request::get('summary', '')); $event->event->description = Request::get('description', ''); $event->setUserDefinedCategories(Request::get('categories', '')); $event->event->location = Request::get('location', ''); @@ -535,7 +531,7 @@ class Calendar_CalendarController extends AuthenticatedController } switch ($rec_type) { case 'daily': - if (Request::option('type_daily', 'day') == 'day') { + if (Request::option('type_daily', 'day') === 'day') { $rrule['linterval'] = Request::int('linterval_d', 1); $rrule['rtype'] = 'DAILY'; } else { @@ -545,13 +541,14 @@ class Calendar_CalendarController extends AuthenticatedController } break; case 'weekly': + $rrule['rtype'] = 'WEEKLY'; $rrule['linterval'] = Request::int('linterval_w', 1); $rrule['wdays'] = implode('', Request::intArray('wdays', [strftime('%u', $event->getStart())])); - $rrule['rtype'] = 'WEEKLY'; break; case 'monthly': - if (Request::option('type_m', 'day') == 'day') { + $rrule['rtype'] = 'MONTHLY'; + if (Request::option('type_m', 'day') === 'day') { $rrule['linterval'] = Request::int('linterval_m1', 1); $rrule['day'] = Request::int('day_m', strftime('%e', $event->getStart())); @@ -561,11 +558,11 @@ class Calendar_CalendarController extends AuthenticatedController $rrule['wdays'] = Request::int('wday_m', strftime('%u', $event->getStart())); } - $rrule['rtype'] = 'MONTHLY'; break; case 'yearly': + $rrule['rtype'] = 'YEARLY'; $rrule['linterval'] = 1; - if (Request::option('type_y', 'day') == 'day') { + if (Request::option('type_y', 'day') === 'day') { $rrule['day'] = Request::int('day_y', strftime('%e', $event->getStart())); $rrule['month'] = Request::int('month_y1', @@ -577,7 +574,6 @@ class Calendar_CalendarController extends AuthenticatedController $rrule['month'] = Request::int('month_y2', date('n', $event->getStart())); } - $rrule['rtype'] = 'YEARLY'; break; } if (sizeof($messages)) { -- GitLab From f70de38b0aff184f3fa09789ece4eb954ff6237a Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Thu, 2 Mar 2023 09:29:55 +0000 Subject: [PATCH 11/19] Apply 1 suggestion(s) to 1 file(s) --- app/controllers/calendar/schedule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/calendar/schedule.php b/app/controllers/calendar/schedule.php index 5a9f7877412..52c6f36c9e8 100644 --- a/app/controllers/calendar/schedule.php +++ b/app/controllers/calendar/schedule.php @@ -162,7 +162,7 @@ class Calendar_ScheduleController extends AuthenticatedController $this->inst_mode = $inst_mode; $this->institute_name = $inst['name']; $this->institute_id = $institute_id; - $this->show_settings = Request::get('show_settings', false); + $this->show_settings = Request::bool('show_settings', false); } public function new_entry_action() -- GitLab From 6ab367ba4f9e2a9b8d1cab9653b46bf27dd01b65 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Thu, 2 Mar 2023 09:30:01 +0000 Subject: [PATCH 12/19] Apply 1 suggestion(s) to 1 file(s) --- app/controllers/consultation/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/consultation/admin.php b/app/controllers/consultation/admin.php index 4b8ce7ef048..47d2ecdda94 100644 --- a/app/controllers/consultation/admin.php +++ b/app/controllers/consultation/admin.php @@ -533,7 +533,7 @@ class Consultation_AdminController extends ConsultationController 'CONSULTATION_SEND_MESSAGES', (bool) $state ); - } elseif ($what === 'garbage' && !empty($this->range_config)) { + } elseif ($what === 'garbage') { // TODO: Not available for course $this->range_config->store( 'CONSULTATION_GARBAGE_COLLECT', -- GitLab From 27bb2496b28ca6ab1a73600ca96fe31e5b4cc654 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Thu, 2 Mar 2023 09:30:09 +0000 Subject: [PATCH 13/19] Apply 1 suggestion(s) to 1 file(s) --- app/controllers/course/forum/index.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/controllers/course/forum/index.php b/app/controllers/course/forum/index.php index d479afd5bd4..c0ab43d8c2a 100644 --- a/app/controllers/course/forum/index.php +++ b/app/controllers/course/forum/index.php @@ -238,10 +238,7 @@ class Course_Forum_IndexController extends ForumController $this->postings = $list['list']; $this->number_of_entries = $list['count']; $this->show_full_path = true; - $this->no_entries = false; - if (empty($this->postings)) { - $this->no_entries = true; - } + $this->no_entries = empty($this->postings); $this->render_action('index'); } -- GitLab From fa880fd63dd440a7d35ea7a86c161020e81dddaf Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Thu, 2 Mar 2023 09:30:16 +0000 Subject: [PATCH 14/19] Apply 1 suggestion(s) to 1 file(s) --- app/controllers/course/forum/index.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/controllers/course/forum/index.php b/app/controllers/course/forum/index.php index c0ab43d8c2a..f2c6de7913d 100644 --- a/app/controllers/course/forum/index.php +++ b/app/controllers/course/forum/index.php @@ -268,10 +268,7 @@ class Course_Forum_IndexController extends ForumController $this->postings = $list['list']; $this->number_of_entries = $list['count']; $this->show_full_path = true; - $this->no_entries = false; - if (empty($this->postings)) { - $this->no_entries = true; - } + $this->no_entries = empty($this->postings); // exploit the visitdate for this view $this->visitdate = ForumVisit::getLastVisit($this->getId()); -- GitLab From d26c01fb48f50e4611d25b59bc2496e7a9e80ece Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Thu, 2 Mar 2023 09:30:20 +0000 Subject: [PATCH 15/19] Apply 1 suggestion(s) to 1 file(s) --- app/controllers/course/admission.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/course/admission.php b/app/controllers/course/admission.php index 938b731a130..eb761442b6e 100644 --- a/app/controllers/course/admission.php +++ b/app/controllers/course/admission.php @@ -198,7 +198,7 @@ class Course_AdmissionController extends AuthenticatedController unset($question); } } - if (!isset($question)) { + if (empty($question)) { $this->redirect($this->action_url('index')); } else { $this->button_yes = 'change_admission_prelim_yes'; -- GitLab From ef9ca8ae1271ff8b7420b7db6621fc240fe317cc Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Thu, 2 Mar 2023 09:30:24 +0000 Subject: [PATCH 16/19] Apply 1 suggestion(s) to 1 file(s) --- app/controllers/course/admission.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/course/admission.php b/app/controllers/course/admission.php index eb761442b6e..5f973226b91 100644 --- a/app/controllers/course/admission.php +++ b/app/controllers/course/admission.php @@ -303,7 +303,7 @@ class Course_AdmissionController extends AuthenticatedController unset($question); } } - if (!isset($question)) { + if (empty($question)) { $this->redirect($this->action_url('index')); } else { $this->request = $request; -- GitLab From c7ad84d99845753c3379e56aa178866464d60c0e Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Thu, 2 Mar 2023 09:30:29 +0000 Subject: [PATCH 17/19] Apply 1 suggestion(s) to 1 file(s) --- app/controllers/course/admission.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/course/admission.php b/app/controllers/course/admission.php index 5f973226b91..b063d024014 100644 --- a/app/controllers/course/admission.php +++ b/app/controllers/course/admission.php @@ -360,7 +360,7 @@ class Course_AdmissionController extends AuthenticatedController $question = sprintf(_("In dieser Veranstaltung existiert eine Anmeldeliste (Platzverteilung am %s). Die bestehende Anmeldeliste mit %s Einträgen wird gelöscht. Sind sie sicher?"), strftime('%x %R', $cs->getSeatDistributionTime()), count($priorities)); } } - if (!isset($question) && $cs) { + if (empty($question) && $cs) { CourseSet::removeCourseFromSet($cs->getId(), $this->course_id); $cs->load(); if (!in_array($this->course_id, $cs->getCourses())) { -- GitLab From 93396290a83884314fc6bcad2a1fbd58cb84c8fc Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Thu, 2 Mar 2023 09:30:34 +0000 Subject: [PATCH 18/19] Apply 1 suggestion(s) to 1 file(s) --- app/controllers/course/admission.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/course/admission.php b/app/controllers/course/admission.php index b063d024014..d451b1c5132 100644 --- a/app/controllers/course/admission.php +++ b/app/controllers/course/admission.php @@ -391,7 +391,7 @@ class Course_AdmissionController extends AuthenticatedController } } } - if (!isset($question)) { + if (empty($question)) { $this->redirect($this->action_url('index')); } else { $this->request = ['change_course_set_unassign' => 1]; -- GitLab From 3943e900153efaba60d759b800bdd37190e723d0 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Thu, 2 Mar 2023 09:31:25 +0000 Subject: [PATCH 19/19] Apply 5 suggestion(s) to 4 file(s) --- app/controllers/course/elearning.php | 7 +++++-- app/controllers/course/studygroup.php | 2 +- app/views/help_content/edit.php | 2 +- lib/models/CronjobSchedule.class.php | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/controllers/course/elearning.php b/app/controllers/course/elearning.php index f568d79f037..a8a7626bed8 100644 --- a/app/controllers/course/elearning.php +++ b/app/controllers/course/elearning.php @@ -137,7 +137,7 @@ class Course_ElearningController extends AuthenticatedController $content_modules_list[$index]['module'] = $connected_cms[$connection["cms"]]->content_module[$connection["id"]]->view->show(); } } - if (($this->module_count == 0) && ($this->new_account_cms == "")) { + if (!$this->module_count && !$this->new_account_cms) { if (Context::isInstitute()) { PageLayout::postInfo(_('Momentan sind dieser Einrichtung keine Lernmodule zugeordnet.')); } else { @@ -186,7 +186,10 @@ class Course_ElearningController extends AuthenticatedController // ggf. bestehenden Ilias4-Kurs zuordnen if (Request::submitted('connect_course')) { - if ((ObjectConnections::getConnectionModuleId(Request::option("connect_course_sem_id"), "crs", $this->cms_select)) && ($GLOBALS['perm']->have_studip_perm("dozent", Request::option("connect_course_sem_id")))) { + if ( + ObjectConnections::getConnectionModuleId(Request::option('connect_course_sem_id'), 'crs', $this->cms_select) + && $GLOBALS['perm']->have_studip_perm('dozent', Request::option('connect_course_sem_id')) + ) { ObjectConnections::setConnection($this->seminar_id, ObjectConnections::getConnectionModuleId(Request::option("connect_course_sem_id"), "crs", $this->cms_select), "crs", $this->cms_select); PageLayout::postInfo(_('Zuordnung wurde gespeichert.')); ELearningUtils::loadClass($this->cms_select); diff --git a/app/controllers/course/studygroup.php b/app/controllers/course/studygroup.php index 17af04306a6..6e7120a73d3 100644 --- a/app/controllers/course/studygroup.php +++ b/app/controllers/course/studygroup.php @@ -893,7 +893,7 @@ class Course_StudygroupController extends AuthenticatedController public function savemodules_action() { - $GLOBALS['perm']->check("root"); + $GLOBALS['perm']->check('root'); PageLayout::setHelpKeyword('Admin.Studiengruppen'); $errors = []; if (!Request::get('institute')) { diff --git a/app/views/help_content/edit.php b/app/views/help_content/edit.php index 7b8e3830dcd..a237988300c 100644 --- a/app/views/help_content/edit.php +++ b/app/views/help_content/edit.php @@ -22,7 +22,7 @@ <span class="required"><?= _('Sprache des Textes') ?>:</span> <select name="help_content_language"> <? foreach ($GLOBALS['INSTALLED_LANGUAGES'] as $key => $language) : ?> - <option value="<?= mb_substr($key, 0, 2) ?>"<?= (isset($help_content) && $help_content->language == mb_substr($key, 0, 2)) ? ' selected' : '' ?>> + <option value="<?= mb_substr($key, 0, 2) ?>"<?= (isset($help_content) && $help_content->language === mb_substr($key, 0, 2)) ? ' selected' : '' ?>> <?= $language['name'] ?> </option> <? endforeach ?> diff --git a/lib/models/CronjobSchedule.class.php b/lib/models/CronjobSchedule.class.php index 37001287c69..028eed7b12e 100644 --- a/lib/models/CronjobSchedule.class.php +++ b/lib/models/CronjobSchedule.class.php @@ -120,7 +120,7 @@ class CronjobSchedule extends SimpleORMap */ public function getTitle() { - return $this->content['title'] ?? $this->task->name ?? ''; + return $this->content['title'] ?: $this->task->name ?? ''; } protected function cbJsonifyParameters($type) -- GitLab