From e75c08bedd60a6674d22ce3e2ec57b5a5f1d85eb Mon Sep 17 00:00:00 2001 From: Moritz Strohm <strohm@data-quest.de> Date: Wed, 28 Sep 2022 14:24:20 +0000 Subject: [PATCH] fix for BIESt #1118 Merge request studip/studip!676 --- app/controllers/admin/autoinsert.php | 6 ++ app/controllers/admin/coursewizardsteps.php | 2 +- app/controllers/admin/plugin.php | 1 + app/controllers/admin/role.php | 12 ++- app/controllers/admin/user.php | 17 ++-- app/controllers/course/studygroup.php | 2 +- app/controllers/event_log.php | 2 +- app/controllers/help_content.php | 1 + app/controllers/institute/members.php | 2 +- app/controllers/tour.php | 10 +++ app/views/admin/autoinsert/index.php | 2 +- app/views/admin/autoinsert/manual.php | 2 +- .../cronjobs/schedules/periodic-schedule.php | 4 +- app/views/admin/plugin/index.php | 7 +- app/views/admin/specification/_field.php | 4 +- app/views/admin/specification/edit.php | 4 +- app/views/admin/user/_results.php | 4 +- app/views/admin/user/index.php | 22 +++--- .../ruleadministration/compatibility.php | 4 +- app/views/global_search/settings.php | 2 +- app/views/institute/members/_table_body.php | 24 +++--- app/views/institute/members/index.php | 6 +- lib/classes/ActionMenu.php | 6 +- lib/classes/EventLog.php | 3 +- lib/classes/PluginAdministration.php | 4 + lib/classes/RangeTreeObject.class.php | 78 +++++++++---------- lib/classes/SemClass.class.php | 4 +- lib/classes/StudipForm.class.php | 8 +- lib/classes/StudipRangeTree.class.php | 2 +- .../StudipRangeTreeViewAdmin.class.php | 8 +- lib/classes/StudipSemSearchHelper.class.php | 2 +- lib/classes/StudipSemTree.class.php | 6 +- lib/classes/StudipSemTreeViewAdmin.class.php | 21 ++--- lib/classes/TreeView.class.php | 28 ++++--- lib/classes/URLHelper.php | 2 +- lib/classes/restapi/Router.php | 4 +- lib/classes/searchtypes/RangeSearch.class.php | 1 + lib/extern/admin_extern.inc.php | 2 +- lib/extern/lib/ExternConfig.class.php | 2 +- lib/extern/lib/ExternConfigDb.class.php | 2 +- lib/extern/views/extern_edit_module.inc.php | 2 +- lib/functions.php | 2 +- lib/models/LogEvent.php | 2 +- lib/models/OERHost.php | 4 +- lib/models/SimpleCollection.class.php | 6 +- lib/models/SimpleORMap.class.php | 4 +- lib/models/User.class.php | 2 +- lib/plugins/engine/PluginManager.class.php | 6 +- lib/plugins/engine/PluginRepository.class.php | 4 +- lib/visual.inc.php | 2 +- templates/shared/semester-selector.php | 1 + 51 files changed, 201 insertions(+), 157 deletions(-) diff --git a/app/controllers/admin/autoinsert.php b/app/controllers/admin/autoinsert.php index 6edf3c68af2..fd3b7e0ff56 100644 --- a/app/controllers/admin/autoinsert.php +++ b/app/controllers/admin/autoinsert.php @@ -36,6 +36,10 @@ class Admin_AutoinsertController extends AuthenticatedController */ public function index_action() { + $this->sem_search = ''; + $this->sem_select = ''; + $this->seminar_search = []; + // search seminars if (Request::submitted('suchen')) { if (Request::get('sem_search')) { @@ -142,6 +146,8 @@ class Admin_AutoinsertController extends AuthenticatedController */ public function manual_action() { + $this->seminar_search = []; + PageLayout::setTitle(_('Manuelles Eintragen von Nutzergruppen in Veranstaltungen')); if (Request::submitted('submit')) { $filters = array_filter(Request::getArray('filter')); diff --git a/app/controllers/admin/coursewizardsteps.php b/app/controllers/admin/coursewizardsteps.php index 75870065d16..4e70fa0414e 100644 --- a/app/controllers/admin/coursewizardsteps.php +++ b/app/controllers/admin/coursewizardsteps.php @@ -52,6 +52,7 @@ class Admin_CourseWizardStepsController extends AuthenticatedController */ public function edit_action($id='') { + $this->availableClasses = []; if ($id) { $title = _('Schritt bearbeiten'); $this->step = CourseWizardStepRegistry::find($id); @@ -63,7 +64,6 @@ class Admin_CourseWizardStepsController extends AuthenticatedController $this->step->number = 0; $this->step->enabled = false; - $this->availableClasses = []; foreach (get_declared_classes() as $className) { if (is_a($className, "CourseWizardStep", true) && $className !== "CourseWizardStep") { diff --git a/app/controllers/admin/plugin.php b/app/controllers/admin/plugin.php index 044fc50ca70..7a87d8fe275 100644 --- a/app/controllers/admin/plugin.php +++ b/app/controllers/admin/plugin.php @@ -142,6 +142,7 @@ class Admin_PluginController extends AuthenticatedController $this->plugin_types = $this->plugin_admin->getPluginTypes(); $this->update_info = $this->get_update_info($this->plugins); $this->migrations = $this->plugin_admin->getMigrationInfo(); + $this->num_updates = 0; foreach ($this->update_info as $id => $info) { if (isset($info['update']) && !$this->plugins[$id]['depends']) { diff --git a/app/controllers/admin/role.php b/app/controllers/admin/role.php index 1e99a27051d..f932b0db3cd 100644 --- a/app/controllers/admin/role.php +++ b/app/controllers/admin/role.php @@ -152,18 +152,21 @@ class Admin_RoleController extends AuthenticatedController return; } + $this->username = Request::get('username'); + $this->currentuser = null; + $this->assignedroles = []; + $this->all_userroles = []; + // user search was started if (Request::submitted('search')) { - $username = Request::get('username'); - if ($username == '') { + if ($this->username == '') { $this->error = _('Es wurde kein Suchwort eingegeben.'); } else { - $this->users = $this->search_user($username); + $this->users = $this->search_user($this->username); if (count($this->users) === 0) { $this->error = _('Es wurde keine Person gefunden.'); - $this->username = $username; } } } @@ -282,6 +285,7 @@ class Admin_RoleController extends AuthenticatedController $roleid = Request::int('role', $roleid); $this->roles = RolePersistence::getAllRoles(); + $this->roleid = ''; if ($roleid) { $sql = "SELECT DISTINCT Vorname,Nachname,user_id,username,perms diff --git a/app/controllers/admin/user.php b/app/controllers/admin/user.php index aaa59a0a237..cf1c80665d7 100644 --- a/app/controllers/admin/user.php +++ b/app/controllers/admin/user.php @@ -69,7 +69,7 @@ class Admin_UserController extends AuthenticatedController } //Suchparameter und Ergebnisse vorhanden - if (isset($_SESSION['admin']['user']) && $_SESSION['admin']['user']['results']) { + if (!empty($_SESSION['admin']['user']['results'])) { $request = $_SESSION['admin']['user']; } @@ -81,6 +81,9 @@ class Admin_UserController extends AuthenticatedController } } + $this->request = []; + $this->users = []; + //Datafields $this->datafields = []; $datafields = DataField::getDataFields("user"); @@ -96,6 +99,7 @@ class Admin_UserController extends AuthenticatedController }); //wenn suche durchgeführt + $search_datafields = []; if (!empty($request)) { //suche mit datafields foreach ($this->datafields as $datafield) { @@ -113,8 +117,8 @@ class Admin_UserController extends AuthenticatedController $this->order = $this->order == 'desc' ? 'asc' : 'desc'; } - $request['vorname'] = $request['vorname'] ?: null; - $request['nachname'] = $request['nachname'] ?: null; + $request['vorname'] = $request['vorname'] ?? null; + $request['nachname'] = $request['nachname'] ?? null; $request['inaktiv'] = $inaktiv; $request['datafields'] = $search_datafields; $request['sort'] = $this->sortby; @@ -207,7 +211,8 @@ class Admin_UserController extends AuthenticatedController if ($advanced || !empty($search_datafields) || (!empty($request) - && ($request['auth_plugins'] || $request['userdomains'] || $request['degree'] || $request['institute'] || $request['studycourse'] || $request['show_only_not_lectures'] || !empty($request['roles'])) + && (!empty($request['auth_plugins']) || !empty($request['userdomains']) || !empty($request['degree']) || + !empty($request['institute']) || !empty($request['studycourse']) || !empty($request['show_only_not_lectures']) || !empty($request['roles'])) ) ) { $this->advanced = true; @@ -1621,7 +1626,7 @@ class Admin_UserController extends AuthenticatedController )->asDialog(); $actions->addLink( _('Konten zusammenführen'), - $this->url_for('admin/user/migrate/' . (($this->user && is_array($this->user)) ? $this->user['user_id'] : '')), + $this->url_for('admin/user/migrate/' . ((!empty($this->user) && is_array($this->user)) ? $this->user['user_id'] : '')), Icon::create('community') ); @@ -1641,7 +1646,7 @@ class Admin_UserController extends AuthenticatedController ); } - if (!is_object($this->user)) { + if (empty($this->user) || !is_object($this->user)) { return; } diff --git a/app/controllers/course/studygroup.php b/app/controllers/course/studygroup.php index 58032b86c32..b327a1afcb3 100644 --- a/app/controllers/course/studygroup.php +++ b/app/controllers/course/studygroup.php @@ -21,7 +21,7 @@ class Course_StudygroupController extends AuthenticatedController ) { // args at position zero is always the studygroup-id - if ($args[0] && $action == 'details') { + if (!empty($args[0]) && $action == 'details') { if (SeminarCategories::GetBySeminarId($args[0])->studygroup_mode == false) { throw new Exception(_('Dieses Seminar ist keine Studiengruppe!')); } diff --git a/app/controllers/event_log.php b/app/controllers/event_log.php index 9638b095de4..f1d19c60da3 100644 --- a/app/controllers/event_log.php +++ b/app/controllers/event_log.php @@ -42,10 +42,10 @@ class EventLogController extends AuthenticatedController $this->search = trim(Request::get('search')); $this->log_actions = LogAction::getUsed(true); $this->types = $this->event_log->get_object_types(); + $this->type = Request::option('type'); // restrict log events to object scope if ($this->search) { - $this->type = Request::option('type'); $objects = $this->event_log->find_objects( $this->type, $this->search, diff --git a/app/controllers/help_content.php b/app/controllers/help_content.php index a04c1684f27..5e8faf98473 100644 --- a/app/controllers/help_content.php +++ b/app/controllers/help_content.php @@ -43,6 +43,7 @@ class HelpContentController extends AuthenticatedController */ public function admin_overview_action() { + $this->help_content_searchterm = ''; // initialize PageLayout::setTitle(_('Verwalten von Hilfe-Texten')); PageLayout::setHelpKeyword('Basis.HelpContentAdmin'); diff --git a/app/controllers/institute/members.php b/app/controllers/institute/members.php index 29c325a0ef4..33d8eab38dc 100644 --- a/app/controllers/institute/members.php +++ b/app/controllers/institute/members.php @@ -107,7 +107,7 @@ class Institute_MembersController extends AuthenticatedController // Show lock rule information $lockrule = LockRules::getObjectRule($this->institute->id); - if ($this->admin_view && $lockrule->description + if ($this->admin_view && !empty($lockrule->description) && LockRules::Check($this->institute->id, 'participants')) { PageLayout::postInfo(formatLinks($lockrule->description)); } diff --git a/app/controllers/tour.php b/app/controllers/tour.php index cda3ea41cee..54dfeff770c 100644 --- a/app/controllers/tour.php +++ b/app/controllers/tour.php @@ -180,6 +180,10 @@ class TourController extends AuthenticatedController throw new AccessDeniedException(); } + $this->tour_searchterm = ''; + $this->delete_question = ''; + $this->filter_text = ''; + // initialize PageLayout::setTitle(_('Verwalten von Touren')); PageLayout::setHelpKeyword('Basis.TourAdmin'); @@ -443,6 +447,9 @@ class TourController extends AuthenticatedController $this->render_nothing(); return; } + + $this->force_route = ''; + // Output as dialog (Ajax-Request) or as Stud.IP page? PageLayout::setTitle(_('Schritt bearbeiten')); // save step position @@ -613,6 +620,9 @@ class TourController extends AuthenticatedController if (!$this->help_admin) { throw new AccessDeniedException(); } + + $this->delete_question = ''; + // initialize PageLayout::setTitle(_('Verwalten von Touren')); PageLayout::setHelpKeyword('Basis.TourAdmin'); diff --git a/app/views/admin/autoinsert/index.php b/app/views/admin/autoinsert/index.php index 774932971a3..6f863c551f0 100644 --- a/app/views/admin/autoinsert/index.php +++ b/app/views/admin/autoinsert/index.php @@ -12,7 +12,7 @@ use Studip\Button, Studip\LinkButton; <? endif; ?> <form class="default" action="<?= $controller->index() ?>" method="post"> <?= CSRFProtection::tokenTag() ?> - <?= $this->render_partial("admin/autoinsert/_search.php", ['semester_data' => $semester_data]) ?> + <?= $this->render_partial('admin/autoinsert/_search.php') ?> </form> <? if (is_array($seminar_search) && count($seminar_search) > 0): ?> diff --git a/app/views/admin/autoinsert/manual.php b/app/views/admin/autoinsert/manual.php index 612f5615582..e081a10c7c5 100644 --- a/app/views/admin/autoinsert/manual.php +++ b/app/views/admin/autoinsert/manual.php @@ -10,7 +10,7 @@ <form class="default" action="<?= $controller->manual() ?>" method="post"> <?= CSRFProtection::tokenTag() ?> - <?= $this->render_partial("admin/autoinsert/_search.php", compact('semester_data', 'sem_search', 'sem_select')) ?> + <?= $this->render_partial('admin/autoinsert/_search.php', compact('sem_search', 'sem_select')) ?> </form> diff --git a/app/views/admin/cronjobs/schedules/periodic-schedule.php b/app/views/admin/cronjobs/schedules/periodic-schedule.php index b482efd3173..021002adf55 100644 --- a/app/views/admin/cronjobs/schedules/periodic-schedule.php +++ b/app/views/admin/cronjobs/schedules/periodic-schedule.php @@ -9,7 +9,7 @@ $cronify = function ($n) { return $n; } ?> -<? if ($display === 'table-cells'): ?> +<? if (isset($display) && $display === 'table-cells'): ?> <td><?= $cronify($minute) ?></td> <td><?= $cronify($hour) ?></td> <td><?= $cronify($day) ?></td> @@ -38,4 +38,4 @@ $cronify = function ($n) { <?= $cronify($day_of_week) ?> </li> </ul> -<? endif ?> \ No newline at end of file +<? endif ?> diff --git a/app/views/admin/plugin/index.php b/app/views/admin/plugin/index.php index 859083babbb..26da74fe21f 100644 --- a/app/views/admin/plugin/index.php +++ b/app/views/admin/plugin/index.php @@ -65,7 +65,7 @@ use Studip\Button, Studip\LinkButton; <?= join(', ', $plugin['type']) ?> </td> <td <? if (!$plugin['enabled']) echo 'class="quiet"'; ?>> - <?= htmlReady($update_info[$pluginid]['version']) ?> + <?= htmlReady($update_info[$pluginid]['version'] ?? '') ?> <? if ($plugin['automatic_update_url']): ?> <?= Icon::create('install', Icon::ROLE_STATUS_RED)->asImg([ 'title' => _('Automatische Updates sind eingerichtet'), @@ -75,8 +75,9 @@ use Studip\Button, Studip\LinkButton; </td> <td <? if (!$plugin['enabled']) echo 'class="quiet"'; ?>> <? if (!$plugin['depends']) : ?> - <?= htmlReady($migrations[$pluginid]['schema_version']) ?> - <? if ($migrations[$pluginid]['schema_version'] < $migrations[$pluginid]['migration_top_version']): ?> + <?= htmlReady($migrations[$pluginid]['schema_version'] ?? '') ?> + <? if (!empty($migrations[$pluginid]['schema_version']) && !empty($migrations[$pluginid]['migration_top_version']) + && ($migrations[$pluginid]['schema_version'] < $migrations[$pluginid]['migration_top_version'])): ?> <a href="<?= $controller->url_for('admin/plugin/migrate/' . $pluginid) ?>" title="<?= sprintf(_('Update auf Version %d verfügbar'), $migrations[$pluginid]['migration_top_version']) ?>"> <?= Icon::create('plugin', Icon::ROLE_STATUS_RED) ?> diff --git a/app/views/admin/specification/_field.php b/app/views/admin/specification/_field.php index 30a01ffe202..6f089ea0867 100644 --- a/app/views/admin/specification/_field.php +++ b/app/views/admin/specification/_field.php @@ -4,7 +4,7 @@ $order = Request::getArray('order'); ?> <section> - <? if ($required) : ?> + <? if (!empty($required)) : ?> <span class="required"> <?= htmlReady($name) ?> </span> @@ -28,7 +28,7 @@ $order = Request::getArray('order'); <?= _('Aktivieren') ?> </label> <label class="col-1"> - <? if ($institution) : ?> + <? if (!empty($institution)) : ?> <?= htmlReady($institution->name)?> <? endif; ?> </label> diff --git a/app/views/admin/specification/edit.php b/app/views/admin/specification/edit.php index de868a45da2..e8031714060 100644 --- a/app/views/admin/specification/edit.php +++ b/app/views/admin/specification/edit.php @@ -24,13 +24,13 @@ use Studip\Button, Studip\LinkButton; <span class="required"> <?= _('Name der Regel:') ?> </span> - <input type="text" name="rulename" value="<?= htmlReady(Request::get('rulename', $rule['name'])) ?>" + <input type="text" name="rulename" value="<?= htmlReady(Request::get('rulename', $rule ? $rule['name'] : '')) ?>" required="required"> </label> <label> <?= _('Beschreibung') ?> <textarea cols="60" rows="5" - name="description"><?= htmlReady(Request::get('description', $rule['description'])) ?></textarea> + name="description"><?= htmlReady(Request::get('description', $rule ? $rule['description'] : '')) ?></textarea> </label> </fieldset> <? if (count($entries_semdata) > 0) : ?> diff --git a/app/views/admin/user/_results.php b/app/views/admin/user/_results.php index 1406c2ad811..695e30e200e 100644 --- a/app/views/admin/user/_results.php +++ b/app/views/admin/user/_results.php @@ -96,7 +96,7 @@ <td><?= htmlReady($user->nachname) ?></td> <td><?= htmlReady($user->email) ?></td> <td> - <? if ($user->online->last_lifesign) : + <? if (!empty($user->online->last_lifesign)) : $inactive = time() - $user->online->last_lifesign; if ($inactive < 3600 * 24) { $inactive = gmdate('H:i:s', $inactive); @@ -188,7 +188,7 @@ } - if (Privacy::isVisible($user_id)) { + if (Privacy::isVisible($user->id)) { $actionMenu->addLink( $controller->url_for("privacy/landing/{$user->id}"), _('Anzeige Personendaten'), diff --git a/app/views/admin/user/index.php b/app/views/admin/user/index.php index 50a69c4d9e0..0eb45407981 100644 --- a/app/views/admin/user/index.php +++ b/app/views/admin/user/index.php @@ -13,22 +13,22 @@ use Studip\Button, Studip\LinkButton; <label class="col-3"> <?= _('Benutzername') ?> - <input name="username" type="text" value="<?= htmlReady($request['username']) ?>"> + <input name="username" type="text" value="<?= htmlReady($request['username'] ?? '') ?>"> </label> <label class="col-3"> <?= _('E-Mail') ?> - <input name="email" type="text" value="<?= htmlReady($request['email']) ?>"> + <input name="email" type="text" value="<?= htmlReady($request['email'] ?? '') ?>"> </label> <label class="col-3"> <?= _('Vorname') ?> - <input name="vorname" type="text" value="<?= htmlReady($request['vorname']) ?>"> + <input name="vorname" type="text" value="<?= htmlReady($request['vorname'] ?? '') ?>"> </label> <label class="col-3"> <?= _('Nachname') ?> - <input name="nachname" type="text" value="<?= htmlReady($request['nachname']) ?>"> + <input name="nachname" type="text" value="<?= htmlReady($request['nachname'] ?? '') ?>"> </label> <label class="col-2"> @@ -36,7 +36,7 @@ use Studip\Button, Studip\LinkButton; <select name="perm"> <? foreach(words('alle user autor tutor dozent admin root') as $one): ?> - <option value="<?= $one ?>" <?= ($request['perm'] === $one) ? 'selected' : '' ?>> + <option value="<?= $one ?>" <?= (!empty($request['perm']) && $request['perm'] === $one) ? 'selected' : '' ?>> <?= ($one === 'alle') ? _('alle') : $one ?> </option> <? endforeach; ?> @@ -49,20 +49,20 @@ use Studip\Button, Studip\LinkButton; <div class="hgroup"> <select name="inaktiv" class="size-s"> <? foreach(['<=' => '>=', '=' => '=', '>' => '<', 'nie' =>_('nie')] as $i => $one): ?> - <option value="<?= htmlready($i) ?>" <?= ($request['inaktiv'][0] === $i) ? 'selected' : '' ?>> + <option value="<?= htmlready($i) ?>" <?= (!empty($request['inaktiv'][0]) && $request['inaktiv'][0] === $i) ? 'selected' : '' ?>> <?= htmlReady($one) ?> </option> <? endforeach; ?> </select> <input name="inaktiv_tage" type="number" id="inactive" - value="<?= htmlReady($request['inaktiv'][1]) ?>"> + value="<?= htmlReady($request['inaktiv'][1] ?? '') ?>"> <?= _('Tage') ?> </div> </label> <label class="col-2" style="padding-top: 1.8em;"> - <input type="checkbox" name="locked" value="1" <?= ($request['locked']) ? 'checked' : '' ?>> + <input type="checkbox" name="locked" value="1" <?= !empty($request['locked']) ? 'checked' : '' ?>> <?= _('nur gesperrt') ?> </label> </fieldset> @@ -123,7 +123,7 @@ use Studip\Button, Studip\LinkButton; <? endforeach ?> </select> </label> - + <label class="col-3"> <?= _('Fachsemester') ?> <select name="fachsem"> @@ -180,7 +180,7 @@ use Studip\Button, Studip\LinkButton; <? endforeach ?> </select> <? else : ?> - <input type="text" name="<?= $datafield->id ?>" value="<?= htmlReady($request[$datafield->id]) ?>"> + <input type="text" name="<?= htmlReady($datafield->id) ?>" value="<?= htmlReady($request[$datafield->id] ?? '') ?>"> <? endif ?> </label> <? endforeach; ?> @@ -199,7 +199,7 @@ use Studip\Button, Studip\LinkButton; <? endif?> <label> <input type="checkbox" name="show_only_not_lectures" value="1" - <? if ($request['show_only_not_lectures']) echo 'checked'; ?>> + <?= (!empty($request['show_only_not_lectures'])) ? 'checked' : '' ?>> <?= _('Nur Personen anzeigen, die in keiner Veranstaltung Lehrende sind')?> </label> </fieldset> diff --git a/app/views/admission/ruleadministration/compatibility.php b/app/views/admission/ruleadministration/compatibility.php index 2dc8aa4df6f..d272bd083c8 100644 --- a/app/views/admission/ruleadministration/compatibility.php +++ b/app/views/admission/ruleadministration/compatibility.php @@ -36,7 +36,7 @@ <td> <input type="checkbox" name="compat[<?= $class ?>][]" value="<?= $compat_class ?>"<?= - in_array($compat_class, $matrix[$class] ?: []) ? ' checked' : ''?>> + in_array($compat_class, $matrix[$class] ?? []) ? ' checked' : ''?>> </td> <?php endforeach ?> </tr> @@ -51,5 +51,5 @@ </tr> </tfoot> </table> - + </form> diff --git a/app/views/global_search/settings.php b/app/views/global_search/settings.php index e4e1e0eb3a8..bf1764dfb6a 100644 --- a/app/views/global_search/settings.php +++ b/app/views/global_search/settings.php @@ -65,7 +65,7 @@ <td> <input type="checkbox" id="active[<?= htmlReady(get_class($module)) ?>]" name="modules[<?= htmlReady(get_class($module)) ?>][active]" value="1" - <?= $config[get_class($module)]['active'] && !$resourcesInactive ? ' checked' : '' ?> + <?= !empty($config[get_class($module)]['active']) && !$resourcesInactive ? ' checked' : '' ?> <?= $resourcesInactive ? ' disabled' : '' ?>> </td> <td> diff --git a/app/views/institute/members/_table_body.php b/app/views/institute/members/_table_body.php index 432125d4a95..8bce6d2e80b 100644 --- a/app/views/institute/members/_table_body.php +++ b/app/views/institute/members/_table_body.php @@ -4,7 +4,7 @@ <th colspan="<?= 1 + count($structure) - ($structure['actions'] ? 1 : 0) ?>"> <?= htmlReady($th_title) ?> </th> - <? if ($structure['actions']): ?> + <? if (!empty($structure['actions'])): ?> <th class="actions"> <?= ActionMenu::get() ->setContext($th_title) @@ -36,7 +36,7 @@ <? foreach ($members as $member): $default_entries = DataFieldEntry::getDataFieldEntries([$member->user_id, $institute->id]); - if ($group) { + if (!empty($group)) { $role_entries = DataFieldEntry::getDataFieldEntries([$member->user_id, $group->id]); } ?> @@ -57,25 +57,25 @@ </a> <? endif; ?> </td> - <? if ($structure['status']): ?> + <? if (!empty($structure['status'])): ?> <td><?= htmlReady($member->inst_perms) ?></td> <? endif; ?> - <? if ($structure['statusgruppe']): ?> + <? if (!empty($structure['statusgruppe'])): ?> <td></td> <? endif; ?> - <? if ($structure['raum']): ?> + <? if (!empty($structure['raum'])): ?> <td><?= htmlReady($member->raum) ?></td> <? endif; ?> - <? if ($structure['sprechzeiten']): ?> + <? if (!empty($structure['sprechzeiten'])): ?> <td><?= htmlReady($member->sprechzeiten) ?></td> <? endif; ?> - <? if ($structure['telefon']): ?> + <? if (!empty($structure['telefon'])): ?> <td><?= htmlReady($member->Telefon) ?></td> <? endif; ?> - <? if ($structure['email']): ?> + <? if (!empty($structure['email'])): ?> <td><?= htmlReady(get_visible_email($member->user_id)) ?></td> <? endif; ?> - <? if ($structure['homepage']): ?> + <? if (!empty($structure['homepage'])): ?> <td><?= htmlReady($member->user_info->Home) ?></td> <? endif; ?> <? foreach (array_filter($datafields_list, function ($e) use ($structure) { return isset($structure[$e->getId()]); }) as $entry): ?> @@ -87,7 +87,7 @@ <? endif; ?> </td> <? endforeach; ?> - <? if ($structure['actions']): ?> + <? if (!empty($structure['actions'])): ?> <td class="actions"> <?= ActionMenu::get() ->setContext($member->user) @@ -120,7 +120,7 @@ </td> <? endif; ?> </tr> -<? if ($structure['statusgruppe']): ?> +<? if (!empty($structure['statusgruppe'])): ?> <? $my_groups = $groups->filter(function ($group) use ($member) { return $group->isMember($member->user_id); @@ -148,7 +148,7 @@ <? endif; ?> </td> <? endforeach; ?> - <? if ($structure['actions']): ?> + <? if (!empty($structure['actions'])): ?> <td class="actions"> <?= ActionMenu::get() ->conditionAll($admin_view && !LockRules::Check($institute->id, 'participants')) diff --git a/app/views/institute/members/index.php b/app/views/institute/members/index.php index 17dc60236d5..25cf0aad5c5 100644 --- a/app/views/institute/members/index.php +++ b/app/views/institute/members/index.php @@ -5,15 +5,15 @@ <col width="32"> <? foreach ($structure as $key => $field): ?> <? if ($key !== 'statusgruppe'): ?> - <col <? if ($field['width']): ?> width="<?= $field['width'] ?>"<? endif; ?>> + <col <? if (!empty($field['width'])): ?> width="<?= htmlReady($field['width']) ?>"<? endif; ?>> <? endif; ?> <? endforeach; ?> </colgroup> <thead> <tr> <? foreach ($structure as $key => $field): ?> - <th <? if ($key === 'actions') echo 'class="actions"'; ?> <? if ($field['colspan']): ?>colspan="<?= $field['colspan'] ?>"<? endif; ?>> - <? if ($field['link']): ?> + <th <? if ($key === 'actions') echo 'class="actions"'; ?> <? if (!empty($field['colspan'])): ?>colspan="<?= $field['colspan'] ?>"<? endif; ?>> + <? if (!empty($field['link'])): ?> <a href="<?= URLHelper::getLink($field['link']) ?>"> <?= htmlReady($field['name']) ?> </a> diff --git a/lib/classes/ActionMenu.php b/lib/classes/ActionMenu.php index 92eac8dbcf8..511c995416e 100644 --- a/lib/classes/ActionMenu.php +++ b/lib/classes/ActionMenu.php @@ -111,7 +111,8 @@ class ActionMenu 'link' => $url->link, 'icon' => $url->icon, 'label' => $url->label, - 'attributes' => $url->attributes + 'attributes' => $url->attributes, + 'index' => $index ]; } else { $action = [ @@ -120,6 +121,7 @@ class ActionMenu 'icon' => $icon, 'label' => $label, 'attributes' => $attributes, + 'index' => $index ]; } $index = $index ?: md5($action['link'].json_encode($action['attributes'])); @@ -180,6 +182,7 @@ class ActionMenu 'icon' => $icon, 'label' => $label, 'attributes' => $attributes, + 'index' => '' ]; } @@ -198,6 +201,7 @@ class ActionMenu $this->actions[] = [ 'type' => 'multi-person-search', 'object' => $mp, + 'index' => '' ]; } diff --git a/lib/classes/EventLog.php b/lib/classes/EventLog.php index b6481d2f527..7336415bd4c 100644 --- a/lib/classes/EventLog.php +++ b/lib/classes/EventLog.php @@ -89,6 +89,7 @@ class EventLog $filter = $this->sql_event_filter($action_id, $object_id, $parameters) ?: '1'; $filter .= " ORDER BY mkdate DESC, event_id DESC LIMIT {$offset}, 50"; $log_events = LogEvent::findBySQL($filter, $parameters); + $events = []; foreach ($log_events as $log_event) { $events[] = [ @@ -113,7 +114,7 @@ class EventLog foreach ($actions as $action) { $log_actions[$action->getId()] = $action->toArray(); $log_actions[$action->getId()]['log_count'] - = (int) $log_count[$action->getId()]; + = (int) ($log_count[$action->getId()] ?? 0); } return $log_actions; diff --git a/lib/classes/PluginAdministration.php b/lib/classes/PluginAdministration.php index dc3f3bcc51d..dc8418e2c07 100644 --- a/lib/classes/PluginAdministration.php +++ b/lib/classes/PluginAdministration.php @@ -327,6 +327,10 @@ class PluginAdministration $plugindir = Config::get()->PLUGINS_PATH . '/' . $plugin['path']; $manifest = $plugin_manager->getPluginManifest($plugindir); + if (!$manifest) { + continue; + } + if (isset($manifest['updateURL'])) { $repository = new PluginRepository($manifest['updateURL']); } diff --git a/lib/classes/RangeTreeObject.class.php b/lib/classes/RangeTreeObject.class.php index 95f98b8c240..c4c5320d3fb 100644 --- a/lib/classes/RangeTreeObject.class.php +++ b/lib/classes/RangeTreeObject.class.php @@ -7,8 +7,8 @@ // This file is part of Stud.IP // RangeTreeObject.class.php // Class to handle items in the "range tree" -// -// Copyright (c) 2002 André Noack <noack@data-quest.de> +// +// Copyright (c) 2002 André Noack <noack@data-quest.de> // Suchi & Berg GmbH <info@data-quest.de> // +---------------------------------------------------------------------------+ // This program is free software; you can redistribute it and/or @@ -28,18 +28,18 @@ /** * base class for items in the "range tree" * -* This class is used for items +* This class is used for items * * @access public * @author André Noack <noack@data-quest.de> -* @package +* @package */ class RangeTreeObject { - + /** * item_id in range_tree * - * + * * @access public * @var string $tree_item_id */ @@ -47,7 +47,7 @@ class RangeTreeObject { /** * References the tree object * - * + * * @access private * @var object StudipRangeTree $tree */ @@ -55,25 +55,25 @@ class RangeTreeObject { /** * associative array with data from database fields * - * + * * @access public * @var array $item_data */ var $item_data = null; - + /** * associative array with mapping for database fields * - * + * * @access public * @var array $item_data_mapping */ var $item_data_mapping = null; - + /** * Factory method * - * + * * @access public * @static * @param string $item_id @@ -84,7 +84,7 @@ class RangeTreeObject { $class_name = "RangeTreeObject" . ucfirst($tree->tree_data[$item_id]['studip_object']); return new $class_name($item_id); } - + /** * Constructor * @@ -97,11 +97,11 @@ class RangeTreeObject { $this->tree_item_id = $item_id; $this->item_data = $this->tree->tree_data[$item_id]; } - + /** * Returns all tree items which are kids of this object * - * + * * @access public * @param boolean $as_value_list * @return mixed returns numeric array if param is false, else comma separated string @@ -109,11 +109,11 @@ class RangeTreeObject { function getAllItemKids($as_value_list = false){ return ($as_value_list) ? $this->getValueList($this->tree->getKidsKids($this->tree_item_id)) : $this->tree->getKidsKids($this->tree_item_id); } - + /** * Returns all tree items which are kids of this object and are "real" Stud.IP objects * - * + * * @access public * @param boolean $as_value_list * @return mixed returns numeric array if param is false, else comma separated string @@ -122,11 +122,11 @@ class RangeTreeObject { $all_object_kids = array_merge((array)$this->getInstKids(), (array)$this->getFakKids()); return ($as_value_list) ? $this->getValueList($all_object_kids) : $all_object_kids; } - + /** * Returns all tree items which are kids of this object and are Stud.IP "Einrichtungen" * - * + * * @access public * @param boolean $as_value_list * @return mixed returns numeric array if param is false, else comma separated string @@ -141,11 +141,11 @@ class RangeTreeObject { } return ($as_value_list) ? $this->getValueList($inst_kids) : $inst_kids; } - + /** * Returns all tree items which are kids of this object and are Stud.IP "Fakultaeten" * - * + * * @access public * @param boolean $as_value_list * @return mixed returns numeric array if param is false, else comma separated string @@ -160,19 +160,19 @@ class RangeTreeObject { } return ($as_value_list) ? $this->getValueList($fak_kids) : $fak_kids; } - + /** * Returns array of Stud.IP range_ids of "real" objects * * This function is a wrapper for the according function in StudipRangeTree * @see StudipRangeTree::getAdminRange() * @access public - * @return array of primary keys from table "institute" + * @return array of primary keys from table "institute" */ function getAdminRange(){ return $this->tree->getAdminRange($this->tree_item_id); } - + /** * Only useful in RangeTreeObjectInst ,all other items are always in the correct branch * @@ -182,24 +182,24 @@ class RangeTreeObject { function isInCorrectBranch(){ return true; } - + /** * Returns tree path of the current object * * This function is a wrapper for the according function in StudipRangeTree * @see StudipRangeTree::getItemPath() * @access public - * @return string + * @return string */ function getItemPath(){ return $this->tree->getItemPath($this->tree_item_id); } - + /** * extends the $item_data array * * This function fills the $item_data array with fields from the according database table (is of no use in the base class) - * @abstract + * @abstract * @access private */ function initItemDetail(){ @@ -220,7 +220,7 @@ class RangeTreeObject { } return false; } - + /** * fetch categories of this object from database * @@ -238,21 +238,21 @@ class RangeTreeObject { } return false; } - + /** * getter method for categories of this object * - * + * * @access public * @return object DbSnapshot */ function &getCategories(){ - if (!is_object($this->item_data['categories'])){ + if (empty($this->item_data['categories']) || !is_object($this->item_data['categories'])){ $this->fetchCategories(); } return $this->item_data['categories']; } - + function fetchNumStaff(){ $view = DbView::getView('range_tree'); if (!($view->params[0] = $this->item_data['studip_object_id'])) @@ -264,15 +264,15 @@ class RangeTreeObject { } return false; } - + function getNumStaff(){ if(!isset($this->item_data['num_staff'])){ $this->fetchNumStaff(); } return $this->item_data['num_staff']; } - - + + /** * transform numerical array into a comma separated string * @@ -281,12 +281,12 @@ class RangeTreeObject { * @param array $list * @return string */ - + function getValueList($list){ $value_list = false; - if (count($list) == 1) + if (count($list) == 1) $value_list = "'$list[0]'"; - else + else $value_list = "'".join("','",$list)."'"; return $value_list; } diff --git a/lib/classes/SemClass.class.php b/lib/classes/SemClass.class.php index 5ab5a2d5421..dbbbcd7fa35 100644 --- a/lib/classes/SemClass.class.php +++ b/lib/classes/SemClass.class.php @@ -305,7 +305,7 @@ class SemClass implements ArrayAccess */ public function isModuleActivated($modulename) { - return !$this->data['modules'][$modulename] + return empty($this->data['modules'][$modulename]) || $this->data['modules'][$modulename]['activated']; } @@ -316,7 +316,7 @@ class SemClass implements ArrayAccess */ public function isModuleAllowed($modulename) { - return !$this->data['modules'][$modulename] + return empty($this->data['modules'][$modulename]) || !$this->data['modules'][$modulename]['sticky'] || $this->data['modules'][$modulename]['activated']; } diff --git a/lib/classes/StudipForm.class.php b/lib/classes/StudipForm.class.php index 88c36fe9b6b..024e2e3e578 100644 --- a/lib/classes/StudipForm.class.php +++ b/lib/classes/StudipForm.class.php @@ -182,7 +182,7 @@ class StudipForm { $attributes['required'] = 'required'; } - if (!isset($attributes['id'])) { + if (empty($attributes['id'])) { $attributes['id'] = $this->form_name . '_' . $name; } @@ -282,7 +282,7 @@ class StudipForm { function getFormFieldSelect($name, $attributes, $default){ $ret = "\n<select name=\"{$this->form_name}_{$name}"; - if (!empty($this->form_fields[$name]['multiple'])){ + if (!empty($this->form_fields[$name]['multiple'])) { $ret .= "[]\" multiple "; } else { $ret .= "\" "; @@ -292,9 +292,9 @@ class StudipForm { if ($default === false){ $default = $this->form_fields[$name]['default_value']; } - if (!empty($this->form_fields[$name]['options']) && is_array($this->form_fields[$name]['options'])){ + if (!empty($this->form_fields[$name]['options']) && is_array($this->form_fields[$name]['options'])) { $options = $this->form_fields[$name]['options']; - } else if ($this->form_fields[$name]['options_callback']){ + } else if (!empty($this->form_fields[$name]['options_callback'])) { $options = call_user_func($this->form_fields[$name]['options_callback'],$this,$name); } for ($i = 0; $i < count($options); ++$i){ diff --git a/lib/classes/StudipRangeTree.class.php b/lib/classes/StudipRangeTree.class.php index 291d4430661..36f7314782e 100644 --- a/lib/classes/StudipRangeTree.class.php +++ b/lib/classes/StudipRangeTree.class.php @@ -61,7 +61,7 @@ class StudipRangeTree extends TreeAbstract if (isset($args['sem_status']) ){ $this->sem_status = array_map('intval', $args['sem_status']); } - $this->visible_only = (int)$args['visible_only']; + $this->visible_only = (int)($args['visible_only'] ?? 0); parent::__construct(); //calling the baseclass constructor $this->sem_dates = Semester::findAllVisible(); } diff --git a/lib/classes/StudipRangeTreeViewAdmin.class.php b/lib/classes/StudipRangeTreeViewAdmin.class.php index 1bde3715be9..6c5f3499752 100644 --- a/lib/classes/StudipRangeTreeViewAdmin.class.php +++ b/lib/classes/StudipRangeTreeViewAdmin.class.php @@ -576,7 +576,7 @@ class StudipRangeTreeViewAdmin extends TreeView{ return $content; } $range_object = RangeTreeObject::GetInstance($item_id); - $name = ($range_object->item_data['type']) ? $range_object->item_data['type'] . ": " : ""; + $name = !empty($range_object->item_data['type']) ? $range_object->item_data['type'] . ": " : ""; $name .= $range_object->item_data['name']; $content .= "\n<tr><td class=\"table_header_bold\" align=\"left\" style=\"font-size:10pt\">" . htmlReady($name) ." </td></tr>"; if (is_array($range_object->item_data_mapping)){ @@ -728,7 +728,7 @@ class StudipRangeTreeViewAdmin extends TreeView{ </div> <? - $content .= ob_get_clean(); + $content = ob_get_clean(); return $content; } @@ -787,7 +787,7 @@ class StudipRangeTreeViewAdmin extends TreeView{ </footer> </form> - <? $content .= ob_get_clean() . '</td></tr>'; + <? $content = ob_get_clean() . '</td></tr>'; return $content; } @@ -795,7 +795,7 @@ class StudipRangeTreeViewAdmin extends TreeView{ function getItemMessage($item_id, $colspan = 1) { $content = ""; - if ($this->msg[$item_id]){ + if (!empty($this->msg[$item_id])) { $msg = explode("§", $this->msg[$item_id]); $pics = [ 'error' => Icon::create('decline', 'attention'), diff --git a/lib/classes/StudipSemSearchHelper.class.php b/lib/classes/StudipSemSearchHelper.class.php index e87da1bb95b..ea7aa9c52e7 100644 --- a/lib/classes/StudipSemSearchHelper.class.php +++ b/lib/classes/StudipSemSearchHelper.class.php @@ -103,7 +103,7 @@ class StudipSemSearchHelper { if (isset($this->params['type']) && $this->params['type'] != 'all'){ $sem_types = [$this->params['type']]; } - if ($sem_types) { + if (!empty($sem_types) && is_array($sem_types)) { $clause = " AND c.status IN('" . join("','",$sem_types) . "') " . $clause; } diff --git a/lib/classes/StudipSemTree.class.php b/lib/classes/StudipSemTree.class.php index 82fd37ca588..203bec15e38 100644 --- a/lib/classes/StudipSemTree.class.php +++ b/lib/classes/StudipSemTree.class.php @@ -110,7 +110,7 @@ class StudipSemTree extends TreeAbstract public function isHiddenItem($item_id) { - return (bool) $GLOBALS['SEM_TREE_TYPES'][$this->getValue($item_id, 'type')]['hidden']; + return !empty($GLOBALS['SEM_TREE_TYPES'][$this->getValue($item_id, 'type')]['hidden']); } public function getSemIds($item_id,$ids_from_kids = false) @@ -173,11 +173,11 @@ class StudipSemTree extends TreeAbstract public function getNumEntries($item_id, $num_entries_from_kids = false) { - if (!$this->tree_data[$item_id]) { + if (empty($this->tree_data[$item_id])) { return false; } - if (!$this->entries_init_done) { + if (empty($this->entries_init_done)) { $this->initEntries(); } diff --git a/lib/classes/StudipSemTreeViewAdmin.class.php b/lib/classes/StudipSemTreeViewAdmin.class.php index 8644fef216c..c615f9859e1 100644 --- a/lib/classes/StudipSemTreeViewAdmin.class.php +++ b/lib/classes/StudipSemTreeViewAdmin.class.php @@ -105,6 +105,7 @@ class StudipSemTreeViewAdmin extends TreeView } function parseCommand(){ + $this->mode = ''; if (Request::quoted('mode')) $this->mode = Request::quoted('mode'); if (Request::option('cmd')){ @@ -483,7 +484,7 @@ class StudipSemTreeViewAdmin extends TreeView $head = $this->getItemHeadFrontPic($item_id); $head .= "\n<td class=\"printhead\" nowrap align=\"left\" valign=\"bottom\">"; if ($this->tree->hasKids($item_id)){ - $head .= Icon::create('folder-full', 'clickable', ['title' => $this->open_ranges[$item_id]?_('Alle Unterelemente schliessen'):_('Alle Unterelemente öffnen')])->asImg(16, ['class' => 'text-top']); + $head .= Icon::create('folder-full', Icon::ROLE_CLICKABLE, ['title' => !empty($this->open_ranges[$item_id]) ? _('Alle Unterelemente schliessen') : _('Alle Unterelemente öffnen')])->asImg(['class' => 'text-top']); } else { $head .= Icon::create('folder-empty', 'clickable', ['title' => _('Dieses Element hat keine Unterelemente')])->asImg(); } @@ -491,18 +492,18 @@ class StudipSemTreeViewAdmin extends TreeView } function getItemContent($item_id){ - if ($item_id == $this->edit_item_id ) return $this->getEditItemContent(); - if(!$GLOBALS['SEM_TREE_TYPES'][$this->tree->getValue($item_id, 'type')]['editable']){ + if (!empty($this->edit_item_id) && ($item_id == $this->edit_item_id)) return $this->getEditItemContent(); + if(empty($GLOBALS['SEM_TREE_TYPES'][$this->tree->getValue($item_id, 'type')]['editable'])){ $is_not_editable = true; $this->msg[$item_id] = "info§" . sprintf(_("Der Typ dieses Elementes verbietet eine Bearbeitung.")); } - if ($item_id == $this->move_item_id){ + if (!empty($this->move_item_id) && ($item_id == $this->move_item_id)) { $this->msg[$item_id] = "info§" . sprintf(_("Dieses Element wurde zum Verschieben / Kopieren markiert. Bitte wählen Sie ein Einfügesymbol %s aus, um das Element zu verschieben / kopieren."), Icon::create('arr_2right', 'sort', ['title' => "Einfügesymbol"])->asImg(16, ["alt" => "Einfügesymbol"])); } $content = "\n<table width=\"90%\" cellpadding=\"2\" cellspacing=\"2\" align=\"center\" style=\"font-size:10pt;\">"; $content .= $this->getItemMessage($item_id); $content .= "\n<tr><td style=\"font-size:10pt;\">"; - if(!$is_not_editable){ + if (empty($is_not_editable)) { if ($this->isItemAdmin($item_id) ){ $content .= LinkButton::create(_('Neues Objekt'), URLHelper::getURL($this->getSelf('cmd=NewItem&item_id='.$item_id)), @@ -520,7 +521,7 @@ class StudipSemTreeViewAdmin extends TreeView URLHelper::getURL($this->getSelf('cmd=AssertDeleteItem&item_id=' . $item_id)), ['title' => _('Dieses Element löschen')]) . ' '; - if ($this->move_item_id == $item_id && ($this->mode == "MoveItem" || $this->mode == "CopyItem")){ + if (!empty($this->move_item_id) && ($this->move_item_id == $item_id) && ($this->mode == "MoveItem" || $this->mode == "CopyItem")){ $content .= LinkButton::create(_('Abbrechen'), URLHelper::getURL($this->getSelf('cmd=Cancel&item_id=' . $item_id)), ['title' => _('Verschieben / Kopieren abbrechen')]) . ' '; @@ -561,7 +562,7 @@ class StudipSemTreeViewAdmin extends TreeView $content .= formatReady($this->tree->tree_data[$item_id]['info']) . "</td></tr>"; } $content .= "<tr><td style=\"font-size:10pt;\"colspan=\"3\"> </td></tr>"; - if ($this->tree->getNumEntries($item_id) - $this->tree->tree_data[$item_id]['lonely_sem']){ + if (!empty($this->tree->tree_data[$item_id]['lonely_sem']) && ($this->tree->getNumEntries($item_id) - $this->tree->tree_data[$item_id]['lonely_sem'])) { $content .= "<tr><td class=\"table_row_even\" style=\"font-size:10pt;\" align=\"left\" colspan=\"3\"><b>" . _("Einträge auf dieser Ebene:"); $content .= "</b>\n</td></tr>"; $entries = $this->tree->getSemData($item_id); @@ -569,7 +570,7 @@ class StudipSemTreeViewAdmin extends TreeView } else { $content .= "\n<tr><td class=\"table_row_even\" style=\"font-size:10pt;\" colspan=\"3\">" . _("Keine Einträge auf dieser Ebene vorhanden!") . "</td></tr>"; } - if ($this->tree->tree_data[$item_id]['lonely_sem']){ + if (!empty($this->tree->tree_data[$item_id]['lonely_sem'])) { $content .= "<tr><td class=\"table_row_even\" align=\"left\" style=\"font-size:10pt;\" colspan=\"3\"><b>" . _("Nicht zugeordnete Veranstaltungen auf dieser Ebene:"); $content .= "</b>\n</td></tr>"; $entries = $this->tree->getLonelySemData($item_id); @@ -775,7 +776,7 @@ class StudipSemTreeViewAdmin extends TreeView if ($item_id != "root"){ $head .= " (" . $this->tree->getNumEntries($item_id,true) . ") " ; } - if ($item_id != $this->start_item_id && $this->isParentAdmin($item_id) && $item_id != $this->edit_item_id){ + if ($item_id != $this->start_item_id && $this->isParentAdmin($item_id) && !empty($this->edit_item_id) && ($item_id != $this->edit_item_id)){ $head .= "</td><td nowrap align=\"right\" valign=\"bottom\" class=\"printhead\">"; if (!$this->tree->isFirstKid($item_id)){ $head .= "<a href=\"". URLHelper::getLink($this->getSelf("cmd=OrderItem&direction=up&item_id=$item_id")) . @@ -794,7 +795,7 @@ class StudipSemTreeViewAdmin extends TreeView function getItemMessage($item_id,$colspan = 1){ $content = ""; - if ($this->msg[$item_id]){ + if (!empty($this->msg[$item_id])) { $msg = explode("§",$this->msg[$item_id]); $pics = [ 'error' => Icon::create('decline', 'attention'), diff --git a/lib/classes/TreeView.class.php b/lib/classes/TreeView.class.php index b2d8f5b851e..243a9b9e631 100644 --- a/lib/classes/TreeView.class.php +++ b/lib/classes/TreeView.class.php @@ -168,7 +168,7 @@ class TreeView { $toggle_item = Request::option('close_item') ?: Request::option('open_item'); if ($toggle_item){ - if ($this->open_items[$toggle_item]) { + if (!empty($this->open_items[$toggle_item])) { unset($this->open_items[$toggle_item]); } else { $this->openItem($toggle_item); @@ -216,7 +216,7 @@ class TreeView { for ($j = 0; $j < $num_items; ++$j){ $this->printLevelOutput($items[$j]); $this->printItemOutput($items[$j]); - if ($this->tree->hasKids($items[$j]) && $this->open_ranges[$items[$j]]) { + if ($this->tree->hasKids($items[$j]) && !empty($this->open_ranges[$items[$j]])) { $this->showTree($this->tree->tree_childs[$items[$j]]); } } @@ -276,7 +276,7 @@ class TreeView { echo "\n</td><td class=\"printhead\" align=\"left\" width=\"99%\" nowrap valign=\"bottom\">"; echo $this->getItemHead($item_id); echo "</td></tr></table>"; - if ($this->open_items[$item_id]) { + if (!empty($this->open_items[$item_id])) { $this->printItemDetails($item_id); } return; @@ -318,7 +318,7 @@ class TreeView { else $level_output = "<td class=\"blank\" background=\"" . Assets::image_path('forumstrich.gif') . "\">" . Assets::img('forumleer.gif', ['size' => '10@20']) - . "</td>" . $level_output; //vertical line + . "</td>" . ($level_output ?? ''); //vertical line } } //$level_output = "<td class=\"blank\" background=\"".$GLOBALS['ASSETS_URL']."images/forumleer.gif\" ><img src=\"".$GLOBALS['ASSETS_URL']."images/forumleer.gif\" width=\"20\" height=\"20\" border=\"0\" ></td>" . $level_output; @@ -342,9 +342,11 @@ class TreeView { $head .= "\n<td class=\"printhead\" nowrap align=\"left\" valign=\"bottom\">"; if ($this->tree->hasKids($item_id)){ $head .= "<a href=\""; - $head .= ($this->open_ranges[$item_id]) ? URLHelper::getLink($this->getSelf("close_range={$item_id}")) : URLHelper::getLink($this->getSelf("open_range={$item_id}")); + $head .= !empty($this->open_ranges[$item_id]) + ? URLHelper::getLink($this->getSelf("close_range={$item_id}")) + : URLHelper::getLink($this->getSelf("open_range={$item_id}")); $head .= "\">"; - $head .= Icon::create('folder-full', 'clickable', ['title' => $this->open_ranges[$item_id]?_('Alle Unterelemente schließen'):_('Alle Unterelemente öffnen')])->asImg(16, ['class' => 'text-top']); + $head .= Icon::create('folder-full', 'clickable', ['title' => !empty($this->open_ranges[$item_id]) ? _('Alle Unterelemente schließen') : _('Alle Unterelemente öffnen')])->asImg(16, ['class' => 'text-top']); $head .= "</a>"; } else { $head .= Icon::create('folder-empty', 'clickable', ['title' => _('Dieses Element hat keine Unterelemente')])->asImg(); @@ -362,9 +364,10 @@ class TreeView { $head = "<td class=\"printhead\" nowrap align=\"left\" valign=\"bottom\">"; } $head .= "<a href=\""; - $head .= ($this->open_items[$item_id])? URLHelper::getLink($this->getSelf("close_item={$item_id}")) . "\"" . tooltip(_("Dieses Element schließen"),true) . ">" - : URLHelper::getLink($this->getSelf("open_item={$item_id}")) . "\"" . tooltip(_("Dieses Element öffnen"),true) . ">"; - $head .= Assets::img($this->open_items[$item_id] ? $this->pic_open : $this->pic_close); + $head .= !empty($this->open_items[$item_id]) + ? URLHelper::getLink($this->getSelf("close_item={$item_id}")) . "\"" . tooltip(_("Dieses Element schließen"),true) . ">" + : URLHelper::getLink($this->getSelf("open_item={$item_id}")) . "\"" . tooltip(_("Dieses Element öffnen"),true) . ">"; + $head .= Assets::img(!empty($this->open_items[$item_id]) ? $this->pic_open : $this->pic_close); #$head .= (!$this->open_items[$item_id]) ? "<img src=\"".$GLOBALS['ASSETS_URL']."images/forumleer.gif\" width=\"5\" border=\"0\">" : ""; $head .= "</a>"; $head .= '</td>'; @@ -381,10 +384,11 @@ class TreeView { function getItemHead($item_id){ $head = ""; $head .= " <a class=\"tree\" href=\""; - $head .= ($this->open_items[$item_id])? URLHelper::getLink($this->getSelf("close_item={$item_id}")) . "\"" . tooltip(_("Dieses Element schließen"),true) . "><b>" - : URLHelper::getLink($this->getSelf("open_item={$item_id}")) . "\"" . tooltip(_("Dieses Element öffnen"),true) . ">"; + $head .= !empty($this->open_items[$item_id]) + ? URLHelper::getLink($this->getSelf("close_item={$item_id}")) . "\"" . tooltip(_("Dieses Element schließen"),true) . "><b>" + : URLHelper::getLink($this->getSelf("open_item={$item_id}")) . "\"" . tooltip(_("Dieses Element öffnen"),true) . ">"; $head .= htmlReady(my_substr($this->tree->tree_data[$item_id]['name'],0,$this->max_cols)); - $head .= ($this->open_items[$item_id]) ? "</b></a>" : "</a>"; + $head .= (!empty($this->open_items[$item_id])) ? "</b></a>" : "</a>"; return $head; } diff --git a/lib/classes/URLHelper.php b/lib/classes/URLHelper.php index ae83022dd9b..732ce995dac 100644 --- a/lib/classes/URLHelper.php +++ b/lib/classes/URLHelper.php @@ -69,7 +69,7 @@ class URLHelper if ($url[0] === '/') { preg_match('%^[a-z]+://[\w:.-]+%', $base_url, $host); - $base_url = isset($host) ? $host[0] : ''; + $base_url = $host[0] ?? ''; } return $base_url.$url; diff --git a/lib/classes/restapi/Router.php b/lib/classes/restapi/Router.php index a66463ec91d..d6a331c98a6 100644 --- a/lib/classes/restapi/Router.php +++ b/lib/classes/restapi/Router.php @@ -322,8 +322,8 @@ class Router } if ($describe) { $result[$uri][$method] = [ - 'description' => $this->descriptions[$uri][$method] ?: null, - 'source' => $route['source'] ?: 'unknown', + 'description' => $this->descriptions[$uri][$method] ?? null, + 'source' => $route['source'] ?? 'unknown', ]; } else { $result[$uri][] = $method; diff --git a/lib/classes/searchtypes/RangeSearch.class.php b/lib/classes/searchtypes/RangeSearch.class.php index ee7f969815e..b9c83ae07f0 100644 --- a/lib/classes/searchtypes/RangeSearch.class.php +++ b/lib/classes/searchtypes/RangeSearch.class.php @@ -10,6 +10,7 @@ class RangeSearch extends SQLSearch public function __construct() { + $this->avatarLike = $this->search = ''; $this->sql = $this->getSQL(); } diff --git a/lib/extern/admin_extern.inc.php b/lib/extern/admin_extern.inc.php index 0b6affea54f..fd436c440d4 100644 --- a/lib/extern/admin_extern.inc.php +++ b/lib/extern/admin_extern.inc.php @@ -315,7 +315,7 @@ else { } -if (!$have_config) { +if (empty($have_config)) { echo "<blockquote>\n"; echo _("Es wurden noch keine Konfigurationen angelegt."); echo "</blockquote>"; diff --git a/lib/extern/lib/ExternConfig.class.php b/lib/extern/lib/ExternConfig.class.php index 226dbe7db7b..4c34625d380 100644 --- a/lib/extern/lib/ExternConfig.class.php +++ b/lib/extern/lib/ExternConfig.class.php @@ -121,7 +121,7 @@ class ExternConfig { foreach ($config as $element_name => $element) { if (is_array($element)) foreach ($element as $attribute => $value) { - if ((string)$value[0] == '|') { + if (!empty($value[0]) && (string)$value[0] == '|') { $new_config[$element_name][$attribute] = explode('|', mb_substr($value, 1)); } else { $new_config[$element_name][$attribute] = $value; diff --git a/lib/extern/lib/ExternConfigDb.class.php b/lib/extern/lib/ExternConfigDb.class.php index 1f23a861385..c1ab29b4ad3 100644 --- a/lib/extern/lib/ExternConfigDb.class.php +++ b/lib/extern/lib/ExternConfigDb.class.php @@ -77,7 +77,7 @@ class ExternConfigDb extends ExternConfig if (!parent::insertConfiguration()) { return false; } - $serialized_config = json_encode($this->config); + $serialized_config = json_encode($this->config ?? null); $time = time(); $query = "INSERT INTO extern_config VALUES (?, ?, ?, ?, 0, ?, ?, ?)"; $statement = DBManager::get()->prepare($query); diff --git a/lib/extern/views/extern_edit_module.inc.php b/lib/extern/views/extern_edit_module.inc.php index 8c4bac412fa..21c5c884622 100644 --- a/lib/extern/views/extern_edit_module.inc.php +++ b/lib/extern/views/extern_edit_module.inc.php @@ -145,7 +145,7 @@ if (Request::option('com') == 'store') { } -if (!$edit_open[$edit]) { +if (empty($edit_open[$edit])) { echo LinkButton::create("<< " . _("Zurück"), URLHelper::getURL('?list=TRUE'));; } diff --git a/lib/functions.php b/lib/functions.php index 9986104b50e..a86a9c4b9d5 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -1420,7 +1420,7 @@ function get_route($route = '') if (mb_strpos($route, 'plugins.php/') !== false) { $trails = explode('plugins.php/', $route); $pieces = explode('/', $trails[1]); - $route = 'plugins.php/' . $pieces[0] . ($pieces[1] ? '/' . $pieces[1] : '') . ($pieces[2] ? '/' . $pieces[2] : ''); + $route = 'plugins.php/' . $pieces[0] . (!empty($pieces[1]) ? '/' . $pieces[1] : '') . (!empty($pieces[2]) ? '/' . $pieces[2] : ''); } elseif (mb_strpos($route, 'dispatch.php/') !== false) { $trails = explode('dispatch.php/', $route); $dispatcher = new StudipDispatcher(); diff --git a/lib/models/LogEvent.php b/lib/models/LogEvent.php index 38fdd72dfb1..2e83590da9f 100644 --- a/lib/models/LogEvent.php +++ b/lib/models/LogEvent.php @@ -279,7 +279,7 @@ class LogEvent extends SimpleORMap implements PrivacyObject protected function formatSemester($field) { $all_semester = Semester::findAllVisible(false); foreach ($all_semester as $val) { - if ($val['beginn'] == $this->$field) { + if (!empty($val['beginn']) && ($val['beginn'] == $this->$field)) { return '<em>' . $val['name'] . '</em>'; } } diff --git a/lib/models/OERHost.php b/lib/models/OERHost.php index 7cb2ba5c9d4..1c7c01e9acf 100644 --- a/lib/models/OERHost.php +++ b/lib/models/OERHost.php @@ -15,7 +15,7 @@ class OERHost extends OERIdentity { $host = self::findOneBySQL("`private_key` IS NOT NULL AND `sorm_class` = 'OERHost' LIMIT 1"); if ($host) { - $host['url'] = $GLOBALS['oer_PREFERRED_URI'] ?: $GLOBALS['ABSOLUTE_URI_STUDIP']."dispatch.php/oer/endpoints/"; + $host['url'] = $GLOBALS['oer_PREFERRED_URI'] ?? $GLOBALS['ABSOLUTE_URI_STUDIP']."dispatch.php/oer/endpoints/"; if ($host->isFieldDirty("url")) { $host->store(); } @@ -23,7 +23,7 @@ class OERHost extends OERIdentity } else { $host = new self(); $host['name'] = Config::get()->UNI_NAME_CLEAN; - $host['url'] = $GLOBALS['oer_PREFERRED_URI'] ?: $GLOBALS['ABSOLUTE_URI_STUDIP']."dispatch.php/oer/endpoints/"; + $host['url'] = $GLOBALS['oer_PREFERRED_URI'] ?? $GLOBALS['ABSOLUTE_URI_STUDIP']."dispatch.php/oer/endpoints/"; $host['last_updated'] = time(); $host->store(); return $host; diff --git a/lib/models/SimpleCollection.class.php b/lib/models/SimpleCollection.class.php index 588de1b871d..26439b233f0 100644 --- a/lib/models/SimpleCollection.class.php +++ b/lib/models/SimpleCollection.class.php @@ -684,9 +684,9 @@ class SimpleCollection extends StudipArrayObject $func = function ($d1, $d2) use ($sorter, $sort_func, $sort_locale) { do { - $field = current($sorter); - $dir = $field[1] ?? ''; - $field = $field[0] ?? ''; + $current_sorter = current($sorter); + $field = $current_sorter[0]; + $dir = $current_sorter[1] ?? ''; if (!$sort_locale) { $value1 = $d1[$field]; $value2 = $d2[$field]; diff --git a/lib/models/SimpleORMap.class.php b/lib/models/SimpleORMap.class.php index 5fed34a9a5b..bc670d8ed68 100644 --- a/lib/models/SimpleORMap.class.php +++ b/lib/models/SimpleORMap.class.php @@ -1094,14 +1094,14 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate } if ($type === 'has_and_belongs_to_many') { $thru_table = $options['thru_table']; - if (!$options['thru_key']) { + if (empty($options['thru_key'])) { $options['thru_key'] = $this->pk()[0]; } if (empty($options['thru_assoc_key']) || empty($options['assoc_foreign_key'])) { $class = $options['class_name']; $record = new $class(); $meta = $record->getTableMetadata(); - if (!$options['thru_assoc_key'] ) { + if (empty($options['thru_assoc_key'])) { $options['thru_assoc_key'] = $meta['pk'][0]; } if (empty($options['assoc_foreign_key'])) { diff --git a/lib/models/User.class.php b/lib/models/User.class.php index 7ce868bf222..7eb13218177 100644 --- a/lib/models/User.class.php +++ b/lib/models/User.class.php @@ -365,7 +365,7 @@ class User extends AuthUserMd5 implements Range, PrivacyObject } //locked user - if ((int)$attributes['locked'] == 1) { + if (!empty($attributes['locked'])) { $where[] = "au.`locked` = 1"; } diff --git a/lib/plugins/engine/PluginManager.class.php b/lib/plugins/engine/PluginManager.class.php index 7193f317f6b..7ced174ed38 100644 --- a/lib/plugins/engine/PluginManager.class.php +++ b/lib/plugins/engine/PluginManager.class.php @@ -657,9 +657,9 @@ class PluginManager } foreach ($manifest as $line) { - list($key, $value) = explode('=', $line); - $key = trim($key); - $value = trim($value); + $key_and_value = explode('=', $line); + $key = trim($key_and_value[0]); + $value = trim($key_and_value[1] ?? ''); // skip empty lines and comments if ($key === '' || $key[0] === '#') { diff --git a/lib/plugins/engine/PluginRepository.class.php b/lib/plugins/engine/PluginRepository.class.php index ef09a6c30d4..14415f42bd0 100644 --- a/lib/plugins/engine/PluginRepository.class.php +++ b/lib/plugins/engine/PluginRepository.class.php @@ -116,7 +116,7 @@ class PluginRepository */ protected function registerPlugin($name, $meta_data) { - $old_data = $this->plugins[$name]; + $old_data = $this->plugins[$name] ?? null; if (!isset($old_data) || version_compare($meta_data['version'], $old_data['version']) > 0) { @@ -132,7 +132,7 @@ class PluginRepository */ public function getPlugin($name) { - return $this->plugins[$name]; + return $this->plugins[$name] ?? null; } /** diff --git a/lib/visual.inc.php b/lib/visual.inc.php index 303987d76fd..9cf78c3f42b 100644 --- a/lib/visual.inc.php +++ b/lib/visual.inc.php @@ -679,7 +679,7 @@ function TransformInternalLinks($str){ } $str = $GLOBALS['ABSOLUTE_URI_STUDIP'] . $str; } - if (is_array($GLOBALS['STUDIP_DOMAINS']) && count($GLOBALS['STUDIP_DOMAINS']) > 1) { + if (!empty($GLOBALS['STUDIP_DOMAINS']) && count($GLOBALS['STUDIP_DOMAINS']) > 1) { if (!isset($GLOBALS['TransformInternalLinks_domainData'])){ $domain_data['domains'] = ''; foreach ($GLOBALS['STUDIP_DOMAINS'] as $studip_domain) $domain_data['domains'] .= '|' . preg_quote($studip_domain); diff --git a/templates/shared/semester-selector.php b/templates/shared/semester-selector.php index 74761bf8027..1e559f5f039 100644 --- a/templates/shared/semester-selector.php +++ b/templates/shared/semester-selector.php @@ -1,3 +1,4 @@ +<? $attributes = ''; ?> <? foreach ($select_attributes as $key => $value) : ?> <? $attributes .= sprintf('%s = "%s"', $key, $value) ?> <? endforeach ?> -- GitLab