diff options
| author | Moritz Strohm <strohm@data-quest.de> | 2022-09-28 12:32:56 +0000 |
|---|---|---|
| committer | Moritz Strohm <strohm@data-quest.de> | 2022-09-28 12:32:56 +0000 |
| commit | 9e13d2f5fa4726b54efe8ad046d0b53aadb543bf (patch) | |
| tree | b8fc0583b685de64575feca2cd4efe2663586d74 /lib | |
| parent | 0d56653e17a283d918c6e4cb41468de1990e0331 (diff) | |
fix for BIESt #1104
Merge request studip/studip!674
Diffstat (limited to 'lib')
24 files changed, 156 insertions, 115 deletions
diff --git a/lib/classes/BreadCrumb.class.php b/lib/classes/BreadCrumb.class.php index 386da4f..73a2086 100644 --- a/lib/classes/BreadCrumb.class.php +++ b/lib/classes/BreadCrumb.class.php @@ -37,6 +37,7 @@ class BreadCrumb public function append($object, $action) { $trail = $this->getTrail(); + $id = ''; if (is_object($object)) { $type = get_class($object); $id = $object->id; diff --git a/lib/classes/DbSnapshot.class.php b/lib/classes/DbSnapshot.class.php index 8735fa0..dfb4f89 100644 --- a/lib/classes/DbSnapshot.class.php +++ b/lib/classes/DbSnapshot.class.php @@ -300,6 +300,9 @@ class DbSnapshot for ($i = 0; $i < $this->numRows; ++$i) { for ($j = 0; $j < $num_fields; ++$j) { if ($fieldlist[$j] != $group_by_field) { + if (empty($ret[$this->result[$i][$group_by_field]][$fieldlist[$j]][$this->result[$i][$fieldlist[$j]]])) { + $ret[$this->result[$i][$group_by_field]][$fieldlist[$j]][$this->result[$i][$fieldlist[$j]]] = 0; + } ++$ret[$this->result[$i][$group_by_field]][$fieldlist[$j]][$this->result[$i][$fieldlist[$j]]]; } } diff --git a/lib/classes/QuickSearch.class.php b/lib/classes/QuickSearch.class.php index 6b239de..69a80f7 100644 --- a/lib/classes/QuickSearch.class.php +++ b/lib/classes/QuickSearch.class.php @@ -203,9 +203,9 @@ class QuickSearch if (isset($design['width'])) { $this->box_width = $design['width']; } - $this->box_align = $design['align'] ? $design['align'] : "right"; - $this->search_button_name = $design['search_button_name']; - $this->reset_button_name = $design['reset_button_name']; + $this->box_align = $design['align'] ?? "right"; + $this->search_button_name = $design['search_button_name'] ?? ''; + $this->reset_button_name = $design['reset_button_name'] ?? ''; return $this; } @@ -373,6 +373,7 @@ class QuickSearch $template->set_attribute('withButton', $this->withButton); $template->set_attribute('box_align', $this->box_align); $template->set_attribute('box_width', $this->box_width); + $template->set_attribute('inputStyle', $this->inputStyle ?? ''); $template->set_attribute('beschriftung', $this->beschriftung()); $template->set_attribute('name', $this->name); $template->set_attribute('defaultID', $this->defaultID); diff --git a/lib/classes/SemBrowse.class.php b/lib/classes/SemBrowse.class.php index 29dcd38..12de227 100644 --- a/lib/classes/SemBrowse.class.php +++ b/lib/classes/SemBrowse.class.php @@ -107,10 +107,10 @@ class SemBrowse { $this->sem_number = false; } - $sem_status = (is_array($this->sem_browse_data['sem_status'])) ? $this->sem_browse_data['sem_status'] : false; + $sem_status = (!empty($this->sem_browse_data['sem_status']) && is_array($this->sem_browse_data['sem_status'])) ? $this->sem_browse_data['sem_status'] : false; if ($this->sem_browse_data['level'] == 'vv') { - if (!$this->sem_browse_data['start_item_id']){ + if (empty($this->sem_browse_data['start_item_id'])) { $this->sem_browse_data['start_item_id'] = 'root'; } $this->sem_tree = new StudipSemTreeViewSimple( @@ -282,7 +282,7 @@ class SemBrowse { $db_view = DbView::getView('sem_tree'); $db_view->params[0] = $inst_ids; $db_view->params[1] = (is_object($GLOBALS['perm']) && $GLOBALS['perm']->have_perm(Config::get()->SEM_VISIBILITY_PERM)) ? '' : ' AND c.visible=1'; - $db_view->params[1] .= is_array($this->sem_browse_data['sem_status']) + $db_view->params[1] .= !empty($this->sem_browse_data['sem_status']) && is_array($this->sem_browse_data['sem_status']) ? " AND c.status IN('" . join("','", $this->sem_browse_data['sem_status']) ."')" : ''; $db_view->params[2] = is_array($this->sem_number) @@ -378,13 +378,13 @@ class SemBrowse { if ($this->sem_browse_data['level'] == 'vv') { echo "\n" . '<caption class="legend">'._('Studienbereiche').'<caption>'; echo "\n" . '<tr><td style="text-align: center">'; - $this->sem_tree->show_entries = $this->sem_browse_data['show_entries']; + $this->sem_tree->show_entries = $this->sem_browse_data['show_entries'] ?? false; $this->sem_tree->showSemTree($start_id); } if ($this->sem_browse_data['level'] == 'ev') { echo "\n" . '<caption class="legend">'._('Einrichtungen').'<caption>'; echo "\n" . '<tr><td style="text-align: center">'; - $this->range_tree->show_entries = $this->sem_browse_data['show_entries']; + $this->range_tree->show_entries = $this->sem_browse_data['show_entries'] ?? false; $this->range_tree->showSemRangeTree($start_id); } @@ -407,7 +407,7 @@ class SemBrowse { $this->sem_tree = new StudipSemTreeViewSimple( $this->sem_browse_data['start_item_id'], $this->sem_number, - is_array($this->sem_browse_data['sem_status']) + !empty($this->sem_browse_data['sem_status']) && is_array($this->sem_browse_data['sem_status']) ? $this->sem_browse_data['sem_status'] : false, !(is_object($GLOBALS['perm']) && $GLOBALS['perm']->have_perm(Config::get()->SEM_VISIBILITY_PERM))); } @@ -464,6 +464,7 @@ class SemBrowse { echo '</table>'; } elseif ($this->search_obj->search_button_clicked && !$this->search_obj->new_search_button_clicked) { + $details = []; if ($this->search_obj->found_rows === false) { $details = [_('Der Suchbegriff fehlt oder ist zu kurz')]; } @@ -721,7 +722,7 @@ class SemBrowse { $snap = new DbSnapshot($db); $group_field = $this->group_by_fields[$this->sem_browse_data['group_by']]['group_field']; $data_fields[0] = 'Seminar_id'; - if ($this->group_by_fields[$this->sem_browse_data['group_by']]['unique_field']) { + if (!empty($this->group_by_fields[$this->sem_browse_data['group_by']]['unique_field'])) { $data_fields[1] = $this->group_by_fields[$this->sem_browse_data['group_by']]['unique_field']; } if($user->id == 'nobody' && $snap->numRows == 0){ @@ -768,7 +769,7 @@ class SemBrowse { } } } - if (is_array($tmp_group_by_data)) { + if (!empty($tmp_group_by_data) && is_array($tmp_group_by_data)) { if ($this->sem_number !== false) { unset($group_by_data); } @@ -845,7 +846,7 @@ class SemBrowse { */ if (($GLOBALS['perm']->have_perm(Config::get()->SEM_VISIBILITY_PERM) || key($sem_data[$seminar_id]['visible']) == 1) - && (!$sem_data[key($sem_data[$seminar_id]['parent_course'])] + && (empty($sem_data[key($sem_data[$seminar_id]['parent_course'])]) || $child)) { // create instance of seminar-object $seminar_obj = new Seminar($seminar_id); @@ -934,10 +935,13 @@ class SemBrowse { . htmlReady(mb_substr($seminar_obj->description, 0, 100)) . '</div>'; } else { - $temp_turnus_string = $seminar_obj->getDatesExport([ - 'short' => true, - 'shrink' => true, - ]); + $temp_turnus_string = $seminar_obj->getDatesExport( + [ + 'short' => true, + 'shrink' => true, + 'semester_id' => '' + ] + ); //Shorten, if string too long (add link for details.php) if (mb_strlen($temp_turnus_string) > 70) { $temp_turnus_string = htmlReady(mb_substr($temp_turnus_string, 0, mb_strpos(mb_substr($temp_turnus_string, 70, mb_strlen($temp_turnus_string)), ',') + 71)); @@ -1241,16 +1245,16 @@ class SemBrowse { */ public static function transferSessionData() { - if (Request::option('reset_all')) { - $_SESSION['sem_browse_data'] = null; + if (empty($_SESSION['sem_browse_data']) || Request::option('reset_all')) { + $_SESSION['sem_browse_data'] = []; } $_SESSION['sem_browse_data']['qs_choose'] = Request::get('search_sem_qs_choose', - $_SESSION['sem_browse_data']['qs_choose']); + $_SESSION['sem_browse_data']['qs_choose'] ?? null); // simulate button clicked if semester was changed - if (Request::option('search_sem_sem', $_SESSION['sem_browse_data']['default_sem']) - != $_SESSION['sem_browse_data']['default_sem']) { + $old_default_sem = $_SESSION['sem_browse_data']['default_sem'] ?? null; + if (Request::option('search_sem_sem', $old_default_sem) != $old_default_sem) { $_SESSION['sem_browse_data']['default_sem'] = Request::option('search_sem_sem'); if ($_SESSION['sem_browse_data']['sset']) { Request::set('search_sem_quick_search_parameter', $_SESSION['sem_browse_data']['sset']); @@ -1267,8 +1271,8 @@ class SemBrowse { } // simulate button clicked if class was changed - if (Request::option('show_class', $_SESSION['sem_browse_data']['show_class']) - != $_SESSION['sem_browse_data']['show_class']) { + $old_show_class = $_SESSION['sem_browse_data']['show_class'] ?? null; + if (Request::option('show_class', $old_show_class) != $old_show_class) { $_SESSION['sem_browse_data']['show_class'] = Request::option('show_class'); if ($_SESSION['sem_browse_data']['show_class'] @@ -1300,9 +1304,9 @@ class SemBrowse { ?: 'all'; } $_SESSION['sem_browse_data']['show_class'] = - $_SESSION['sem_browse_data']['show_class'] ?: 'all'; + $_SESSION['sem_browse_data']['show_class'] ?? 'all'; $_SESSION['sem_browse_data']['group_by'] = - $_SESSION['sem_browse_data']['group_by'] ?: '0'; + $_SESSION['sem_browse_data']['group_by'] ?? '0'; } /** @@ -1386,7 +1390,7 @@ class SemBrowse { $stmt->execute([$seminar_id]); $result = $stmt->fetch(); - if ($result['types']) { + if (!empty($result['types'])) { if ($result['type_locked']) { return 2; } diff --git a/lib/classes/StudipForm.class.php b/lib/classes/StudipForm.class.php index fd76fee..88c36fe 100644 --- a/lib/classes/StudipForm.class.php +++ b/lib/classes/StudipForm.class.php @@ -87,7 +87,7 @@ class StudipForm { } if ($this->isSended()){ foreach ($this->form_fields as $name => $foo){ - if (!$foo['disabled']){ + if (empty($foo['disabled'])) { if ( ($field_value = Request::get($this->form_name . "_" . $name)) !== null) { $new_form_values[$name] = trim($field_value); } elseif ( is_array($field_value = Request::getArray($this->form_name . "_" . $name))) { @@ -100,7 +100,7 @@ class StudipForm { } } foreach ($this->form_fields as $name => $value){ - if (!$value['disabled']){ + if (empty($value['disabled'])) { if ($value['type'] == 'combo'){ if ($this->form_values[$name] != $new_form_values[$value['text']]){ //textfeld wurde verändert $new_form_values[$name] = $new_form_values[$value['text']]; @@ -129,7 +129,8 @@ class StudipForm { $new_form_values[$name] = Request::int($this->form_name . "_" . $name, 0); } if ( (isset($this->form_values[$name]) && $this->form_values[$name] != $new_form_values[$name]) - || (!isset($this->form_values[$name]) && $new_form_values[$name] != $this->form_fields[$name]['default_value']) ){ + || (!isset($this->form_values[$name]) && !empty($new_form_values[$name]) && !empty($this->form_fields[$name]['default_value']) + && $new_form_values[$name] != $this->form_fields[$name]['default_value']) ){ $this->value_changed[$name] = true; } } @@ -162,22 +163,22 @@ class StudipForm { if (!$attributes){ $attributes = $this->field_attributes_default; } - if (!$default){ - if (isset($this->form_values[$name])){ + if (empty($default)) { + if (isset($this->form_values[$name])) { $default = $this->form_values[$name]; } else { - $default = $this->form_fields[$name]['default_value']; + $default = $this->form_fields[$name]['default_value'] ?? ''; } } - if (is_array($this->form_fields[$name]['attributes'])){ + if (!empty($this->form_fields[$name]['attributes']) && is_array($this->form_fields[$name]['attributes'])) { $attributes = array_merge((array)$attributes, (array)$this->form_fields[$name]['attributes']); } - if ($this->form_fields[$name]['disabled']){ + if (!empty($this->form_fields[$name]['disabled'])) { $attributes['disabled'] = 'disabled'; } - if ($this->form_fields[$name]['required']){ + if (!empty($this->form_fields[$name]['required'])) { $attributes['required'] = 'required'; } @@ -281,7 +282,7 @@ class StudipForm { function getFormFieldSelect($name, $attributes, $default){ $ret = "\n<select name=\"{$this->form_name}_{$name}"; - if ($this->form_fields[$name]['multiple']){ + if (!empty($this->form_fields[$name]['multiple'])){ $ret .= "[]\" multiple "; } else { $ret .= "\" "; @@ -291,7 +292,7 @@ class StudipForm { if ($default === false){ $default = $this->form_fields[$name]['default_value']; } - if (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']){ $options = call_user_func($this->form_fields[$name]['options_callback'],$this,$name); @@ -299,13 +300,13 @@ class StudipForm { for ($i = 0; $i < count($options); ++$i){ $options_name = (is_array($options[$i])) ? $options[$i]['name'] : $options[$i]; $options_value = (is_array($options[$i])) ? $options[$i]['value'] : $options[$i]; - $options_attributes = (is_array($options[$i])) ? $options[$i]['attributes'] : []; + $options_attributes = $options[$i]['attributes'] ?? []; $selected = false; if ((is_array($default) && in_array("" . $options_value, $default)) || (!is_array($default) && ($default == "" . $options_value))){ $selected = true; } - if ($this->form_fields[$name]['max_length']){ + if (!empty($this->form_fields[$name]['max_length'])) { $options_name = my_substr($options_name,0, $this->form_fields[$name]['max_length']); } $ret .= "\n<option value=\"".htmlReady($options_value)."\" " . (($selected) ? " selected " : ""); @@ -387,15 +388,15 @@ class StudipForm { } function getFormButton($name, $attributes = []){ - if (is_array($this->form_buttons[$name]['attributes'])) { + if (!empty($this->form_buttons[$name]['attributes']) && is_array($this->form_buttons[$name]['attributes'])) { $attributes = array_merge((array)$attributes, (array)$this->form_buttons[$name]['attributes']); } - if (!$this->form_buttons[$name]['is_picture']) { + if (empty($this->form_buttons[$name]['is_picture'])) { if (isset($this->form_buttons[$name]['info']) && !isset($attributes['title'])) { $attributes['title'] = $this->form_buttons[$name]['info']; } $caption = $this->form_buttons[$name]['caption'] ? $this->form_buttons[$name]['caption'] : $this->form_buttons[$name]['type']; - if (in_array($this->form_buttons[$name]['type'], words('cancel accept'))) { + if (!empty($this->form_buttons[$name]['type']) && in_array($this->form_buttons[$name]['type'], ['cancel', 'accept'])) { $create = 'create' . $this->form_buttons[$name]['type']; } else { $create = 'create'; @@ -457,7 +458,7 @@ class StudipForm { if (isset($this->form_values[$name])){ $value = $this->form_values[$name]; } else { - $value = $this->form_fields[$name]['default_value']; + $value = $this->form_fields[$name]['default_value'] ?? ''; } return $value; } @@ -465,7 +466,7 @@ class StudipForm { function getFormFieldsByName($only_editable = false){ $ret = []; foreach ($this->form_fields as $name => $detail){ - if( !($only_editable && ($detail['type'] == 'noform' || $detail['disabled'])) ){ + if( !($only_editable && ($detail['type'] == 'noform' || !empty($detail['disabled']))) ){ $ret[] = $name; } } diff --git a/lib/classes/StudipSemRangeTreeViewSimple.class.php b/lib/classes/StudipSemRangeTreeViewSimple.class.php index 41744bd..eecdd70 100644 --- a/lib/classes/StudipSemRangeTreeViewSimple.class.php +++ b/lib/classes/StudipSemRangeTreeViewSimple.class.php @@ -61,7 +61,7 @@ class StudipSemRangeTreeViewSimple { } $args['visible_only'] = $visible_only; $this->tree = TreeAbstract::GetInstance("StudipRangeTree",$args); - if (!$this->tree->tree_data[$this->start_item_id]){ + if (empty($this->tree->tree_data[$this->start_item_id])) { $this->start_item_id = "root"; } } @@ -156,6 +156,7 @@ class StudipSemRangeTreeViewSimple { if ($item_id == "root"){ $ret = ($this->root_content) ? $this->root_content : _("Keine weitere Info vorhanden"); } else { + $info = ''; $range_object = RangeTreeObject::GetInstance($item_id); if (is_array($range_object->item_data_mapping)){ foreach ($range_object->item_data_mapping as $key => $value){ @@ -165,7 +166,7 @@ class StudipSemRangeTreeViewSimple { } } } - $ret = ($info) ? $info : _("Keine weitere Info vorhanden"); + $ret = $info ?: _("Keine weitere Info vorhanden"); } return $ret; } @@ -211,6 +212,7 @@ class StudipSemRangeTreeViewSimple { public function getSemPath($start_id = null) { $parents = $this->tree->getParents($this->start_item_id); + $ret = ''; if ($parents) { $add_item = false; $start_id = $start_id === null ? 'root' : $start_id; diff --git a/lib/classes/StudipSemSearch.class.php b/lib/classes/StudipSemSearch.class.php index e12c443..8932dd1 100644 --- a/lib/classes/StudipSemSearch.class.php +++ b/lib/classes/StudipSemSearch.class.php @@ -158,7 +158,9 @@ class StudipSemSearch { return $this->form->getFormStart($action, $attributes); } - function getFormEnd(){ + function getFormEnd() + { + $ret = ''; if ($this->search_sem_class != 'all'){ $ret = $this->form->getHiddenField('category',$this->search_sem_class); } diff --git a/lib/classes/StudipSemSearchHelper.class.php b/lib/classes/StudipSemSearchHelper.class.php index 3875bc2..e87da1b 100644 --- a/lib/classes/StudipSemSearchHelper.class.php +++ b/lib/classes/StudipSemSearchHelper.class.php @@ -92,10 +92,11 @@ class StudipSemSearchHelper { } $sem_types = []; - if (isset($this->params['category']) && $this->params['category'] !== 'all'){ - foreach ($GLOBALS['SEM_TYPE'] as $type_key => $type_value){ - if ($type_value['class'] == $this->params['category']) + if (isset($this->params['category']) && $this->params['category'] !== 'all') { + foreach ($GLOBALS['SEM_TYPE'] as $type_key => $type_value) { + if ($type_value['class'] == $this->params['category']) { $sem_types[] = $type_key; + } } } @@ -176,8 +177,10 @@ class StudipSemSearchHelper { $toFilter = explode(" ", $this->params['title']); $search_for = "(Name LIKE '%" . implode("%' AND Name LIKE '%", $toFilter) . "%')"; - $view->params[0] = $this->params['title'] ? $search_for . " " : " "; - + if (!array_key_exists(0, $view->params)) { + $view->params[0] = ''; + } + $view->params[0] .= ($this->params['title']) ? $search_for . " " : " "; $view->params[0] .= ($this->params['title'] && $this->params['sub_title']) ? $combination : " "; $view->params[0] .= ($this->params['sub_title']) ? " Untertitel LIKE '%" . $this->trim($this->params['sub_title']) . "%' " : " "; $view->params[0] .= (($this->params['title'] || $this->params['sub_title']) && $this->params['comment']) ? $combination : " "; diff --git a/lib/classes/StudipSemTree.class.php b/lib/classes/StudipSemTree.class.php index 3337797..82fd37c 100644 --- a/lib/classes/StudipSemTree.class.php +++ b/lib/classes/StudipSemTree.class.php @@ -38,7 +38,7 @@ class StudipSemTree extends TreeAbstract if (isset($args['sem_number']) ){ $this->sem_number = array_map('intval', $args['sem_number']); } - if ($args['sem_status']){ + if (!empty($args['sem_status'])) { $this->sem_status = array_map('intval', $args['sem_status']); } else { foreach ($GLOBALS['SEM_CLASS'] as $key => $value){ @@ -115,8 +115,9 @@ class StudipSemTree extends TreeAbstract public function getSemIds($item_id,$ids_from_kids = false) { - if (!$this->tree_data[$item_id]) + if (empty($this->tree_data[$item_id])) { return false; + } $this->view->params[0] = $this->sem_status; $this->view->params[1] = $this->visible_only ? "visible=1" : "1"; if ($ids_from_kids && $item_id != 'root'){ diff --git a/lib/classes/StudipSemTreeViewSimple.class.php b/lib/classes/StudipSemTreeViewSimple.class.php index a78e217..560f7cc 100644 --- a/lib/classes/StudipSemTreeViewSimple.class.php +++ b/lib/classes/StudipSemTreeViewSimple.class.php @@ -60,7 +60,7 @@ class StudipSemTreeViewSimple $args['visible_only'] = $visible_only; $this->tree = TreeAbstract::GetInstance("StudipSemTree",$args); $this->tree->enable_lonely_sem = false; - if (!$this->tree->tree_data[$this->start_item_id]){ + if (empty($this->tree->tree_data[$this->start_item_id])) { $this->start_item_id = "root"; } } @@ -145,8 +145,9 @@ class StudipSemTreeViewSimple <td class="table_row_even kids-tree-row" align="left" valign="top"> <ul class="semtree">'; for ($i = 0; $i < $num_kids; ++$i){ + $num_entries = 0; if ($this->start_item_id != 'root') { - $num_entries = $this->tree->getNumEntries($kids[$i],true); + $num_entries = $this->tree->getNumEntries($kids[$i],true); $num_all_entries += $num_entries; } $kids_table .= "<li><a " . ($num_entries ? tooltip(sprintf(_("%s Einträge in allen Unterebenen vorhanden"), $num_entries), false) : '') . " href=\"" .URLHelper::getLink($this->getSelf("start_item_id={$kids[$i]}", false)) . "\">"; @@ -212,6 +213,7 @@ class StudipSemTreeViewSimple public function getSemPath($start_id = null) { + $ret = ''; $parents = $this->tree->getParents($this->start_item_id); if ($parents) { $add_item = false; diff --git a/lib/classes/TreeAbstract.class.php b/lib/classes/TreeAbstract.class.php index b06cbcd..dc96820 100644 --- a/lib/classes/TreeAbstract.class.php +++ b/lib/classes/TreeAbstract.class.php @@ -112,7 +112,7 @@ class TreeAbstract { } else { $class_hash = $class_name; } - if (!is_object($tree_instance[$class_hash]) || $invalidate_cache){ + if (empty($tree_instance[$class_hash]) || $invalidate_cache){ $tree_instance[$class_hash] = new $class_name($args); } @@ -162,7 +162,10 @@ class TreeAbstract { $this->tree_data[$item_id]["priority"] = $priority; $this->tree_data[$item_id]["name"] = $name; $this->tree_childs[$parent_id][] = $item_id; - ++$this->tree_num_childs[$parent_id]; + if (empty($this->tree_num_childs[$parent_id])) { + $this->tree_num_childs[$parent_id] = 0; + } + $this->tree_num_childs[$parent_id]++; return; } @@ -213,7 +216,7 @@ class TreeAbstract { public function getNumKids($item_id) { if(!isset($this->tree_num_childs[$item_id])){ - $this->tree_num_childs[$item_id] = (is_array($this->tree_childs[$item_id])) ? count($this->tree_childs[$item_id]) : 0; + $this->tree_num_childs[$item_id] = (!empty($this->tree_childs[$item_id]) && is_array($this->tree_childs[$item_id])) ? count($this->tree_childs[$item_id]) : 0; } return $this->tree_num_childs[$item_id]; } diff --git a/lib/classes/globalsearch/GlobalSearchCourses.php b/lib/classes/globalsearch/GlobalSearchCourses.php index a490b2e..5914cfc 100644 --- a/lib/classes/globalsearch/GlobalSearchCourses.php +++ b/lib/classes/globalsearch/GlobalSearchCourses.php @@ -58,6 +58,13 @@ class GlobalSearchCourses extends GlobalSearchModule implements GlobalSearchFull AND `lang` = " . DBManager::get()->quote($_SESSION['_language']); } + $visibility = ''; + $seminaruser = ''; + $semester_join = ''; + $institute_condition = ''; + $seminar_type_condition = ''; + $semester_condition = ''; + // visibility if (!$GLOBALS['perm']->have_perm('admin')) { $visibility = "courses.`visible` = 1 AND "; @@ -70,7 +77,7 @@ class GlobalSearchCourses extends GlobalSearchModule implements GlobalSearchFull // generate SQL for the given sidebar filter (semester, institute, seminar_type) if ($filter['category'] === self::class || $filter['category'] === 'show_all_categories') { - if ($filter['semester']) { + if (!empty($filter['semester'])) { if ($filter['semester'] === 'future') { $semester = Semester::findCurrent(); $next_semester = Semester::findNext(); @@ -85,11 +92,11 @@ class GlobalSearchCourses extends GlobalSearchModule implements GlobalSearchFull semester_courses.semester_id IS NULL OR semester_courses.semester_id IN (" . join(',', array_map([DBManager::get(), 'quote'], $semester_ids)) . ") ) "; } - if ($filter['institute']) { + if (!empty($filter['institute'])) { $institutes = self::getInstituteIdsForSQL($filter['institute']); $institute_condition = " AND `courses`.`Institut_id` IN (" . DBManager::get()->quote($institutes) . ") "; } - if ($filter['seminar_type']) { + if (!empty($filter['seminar_type'])) { $seminar_types = self::getSeminarTypesForSQL($filter['seminar_type']); $seminar_type_condition = " AND `courses`.`status` IN (" . DBManager::get()->quote($seminar_types) . ") "; } @@ -288,7 +295,7 @@ class GlobalSearchCourses extends GlobalSearchModule implements GlobalSearchFull $stmt->execute([$seminar_id]); $result = $stmt->fetch(); - if ($result['types']) { + if (!empty($result['types'])) { if ($result['type_locked']) { return 2; } diff --git a/lib/classes/globalsearch/GlobalSearchForum.php b/lib/classes/globalsearch/GlobalSearchForum.php index 8c152c8..999757a 100644 --- a/lib/classes/globalsearch/GlobalSearchForum.php +++ b/lib/classes/globalsearch/GlobalSearchForum.php @@ -45,6 +45,7 @@ class GlobalSearchForum extends GlobalSearchModule implements GlobalSearchFullte $query = DBManager::get()->quote("%$search%"); // visibility + $seminaruser = ''; if (!$GLOBALS['perm']->have_perm('admin')) { $seminaruser = " AND EXISTS ( SELECT 1 FROM `seminar_user` @@ -54,8 +55,9 @@ class GlobalSearchForum extends GlobalSearchModule implements GlobalSearchFullte } // generate SQL condition for the semester filter in the sidebar + $semester_condition = ''; if ($filter['category'] == self::class || $filter['category'] == "show_all_categories") { - if ($filter['semester'] != "") { + if (!empty($filter['semester'])) { if ($filter['semester'] === 'future') { $semester = Semester::findCurrent(); $next_semester = Semester::findNext(); diff --git a/lib/classes/globalsearch/GlobalSearchModule.php b/lib/classes/globalsearch/GlobalSearchModule.php index 49d5e74..7e9f251 100644 --- a/lib/classes/globalsearch/GlobalSearchModule.php +++ b/lib/classes/globalsearch/GlobalSearchModule.php @@ -127,7 +127,7 @@ abstract class GlobalSearchModule // Replace camelcase $i = 1; - $replacement = "${$i}"; + $replacement = '$1'; foreach (preg_split('//u', mb_strtoupper($query), -1, PREG_SPLIT_NO_EMPTY) as $letter) { $quoted = preg_quote($letter, '/'); $queryletter[] = "({$quoted})"; diff --git a/lib/classes/globalsearch/GlobalSearchMyCourses.php b/lib/classes/globalsearch/GlobalSearchMyCourses.php index a058b0b..10d7be4 100644 --- a/lib/classes/globalsearch/GlobalSearchMyCourses.php +++ b/lib/classes/globalsearch/GlobalSearchMyCourses.php @@ -46,8 +46,12 @@ class GlobalSearchMyCourses extends GlobalSearchModule } // generate SQL for the given sidebar filter (semester, institute, seminar_type) + $semester_join = ''; + $institute_condition = ''; + $seminar_type_condition = ''; + $semester_condition = ''; if ($filter['category'] === self::class || $filter['category'] == 'show_all_categories') { - if ($filter['semester']) { + if (!empty($filter['semester'])) { if ($filter['semester'] === 'future') { $semester = Semester::findCurrent(); $next_semester = Semester::findNext(); @@ -62,11 +66,11 @@ class GlobalSearchMyCourses extends GlobalSearchModule semester_courses.semester_id IS NULL OR semester_courses.semester_id IN (" . join(',', array_map([DBManager::get(), 'quote'], $semester_ids)) . ") ) "; } - if ($filter['institute']) { + if (!empty($filter['institute'])) { $institutes = self::getInstituteIdsForSQL($filter['institute']); $institute_condition = " AND `courses`.`Institut_id` IN (" .DBManager::get()->quote($institutes). ") "; } - if ($filter['seminar_type']) { + if (!empty($filter['seminar_type'])) { $seminar_types = self::getSeminarTypesForSQL($filter['seminar_type']); $seminar_type_condition = " AND `courses`.`status` IN (" .DBManager::get()->quote($seminar_types). ") "; } diff --git a/lib/classes/globalsearch/GlobalSearchUsers.php b/lib/classes/globalsearch/GlobalSearchUsers.php index b9daa49..548c6ac 100644 --- a/lib/classes/globalsearch/GlobalSearchUsers.php +++ b/lib/classes/globalsearch/GlobalSearchUsers.php @@ -37,6 +37,7 @@ class GlobalSearchUsers extends GlobalSearchModule implements GlobalSearchFullte } // if you're no admin respect visibilty + $visQuery = ''; if (!$GLOBALS['perm']->have_perm('admin')) { $visQuery = get_vis_query('user', 'search') . " AND "; } diff --git a/lib/classes/searchtypes/SearchType.class.php b/lib/classes/searchtypes/SearchType.class.php index e0914dc..d46d57e 100644 --- a/lib/classes/searchtypes/SearchType.class.php +++ b/lib/classes/searchtypes/SearchType.class.php @@ -23,6 +23,8 @@ */ abstract class SearchType { + public $extendedLayout = false; + /** * title of the search like "search for courses" or just "courses" diff --git a/lib/classes/sidebar/ClipboardWidget.class.php b/lib/classes/sidebar/ClipboardWidget.class.php index 90de0c4..abc0d6c 100644 --- a/lib/classes/sidebar/ClipboardWidget.class.php +++ b/lib/classes/sidebar/ClipboardWidget.class.php @@ -69,7 +69,8 @@ class ClipboardWidget extends SidebarWidget $this->clipboard_widget_id = md5(uniqid('clipboard_widget_id')); $this->updateSessionVariables(); - $this->current_clipboard_id = $_SESSION['selected_clipboard_id']; + $this->current_clipboard_id = $_SESSION['selected_clipboard_id'] ?? ''; + $this->setId("ClipboardWidget_{$this->clipboard_widget_id}"); $this->setAdditionalAttribute('data-widget_id', $this->clipboard_widget_id); $this->addLayoutCSSClass('clipboard-widget'); diff --git a/lib/classes/sidebar/ResourceTreeWidget.class.php b/lib/classes/sidebar/ResourceTreeWidget.class.php index 75befd4..34907ce 100644 --- a/lib/classes/sidebar/ResourceTreeWidget.class.php +++ b/lib/classes/sidebar/ResourceTreeWidget.class.php @@ -115,6 +115,7 @@ class ResourceTreeWidget extends SidebarWidget $variables['resource_path'] = $resource_path; $variables['max_open_depth'] = 0; $variables['layout_css_classes'] = $this->layout_css_classes; + $variables['hide'] = false; return parent::render($variables); } diff --git a/lib/classes/sidebar/RoomSearchWidget.class.php b/lib/classes/sidebar/RoomSearchWidget.class.php index da2238e..af7a819 100644 --- a/lib/classes/sidebar/RoomSearchWidget.class.php +++ b/lib/classes/sidebar/RoomSearchWidget.class.php @@ -301,7 +301,7 @@ class RoomSearchWidget extends SidebarWidget protected function restoreSearchFromSession() { - if (is_array($_SESSION['room_search_criteria']['room_search'])) { + if (!empty($_SESSION['room_search_criteria']['room_search']) && is_array($_SESSION['room_search_criteria']['room_search'])) { $this->selected_criteria = $_SESSION['room_search_criteria']['room_search']; } else { diff --git a/lib/models/Modulteil.php b/lib/models/Modulteil.php index deffb5e..14a34ba 100644 --- a/lib/models/Modulteil.php +++ b/lib/models/Modulteil.php @@ -141,9 +141,7 @@ class Modulteil extends ModuleManagementModelTreeItem } else if ($this->nummer) { $name .= $this->nummer . ': '; } - $name .= $GLOBALS['MVV_MODULTEIL']['LERNLEHRFORM']['values'][$this->lernlehrform] - ? $GLOBALS['MVV_MODULTEIL']['LERNLEHRFORM']['values'][$this->lernlehrform]['name'] - : ''; + $name .= $GLOBALS['MVV_MODULTEIL']['LERNLEHRFORM']['values'][$this->lernlehrform]['name'] ?? ''; $deskriptor = $this->getDeskriptor(self::getLanguage()); if (strlen(trim($deskriptor->bezeichnung))) { $name .= $name == '' ? $deskriptor->bezeichnung diff --git a/lib/models/SimpleCollection.class.php b/lib/models/SimpleCollection.class.php index 4d98087..588de1b 100644 --- a/lib/models/SimpleCollection.class.php +++ b/lib/models/SimpleCollection.class.php @@ -684,7 +684,9 @@ class SimpleCollection extends StudipArrayObject $func = function ($d1, $d2) use ($sorter, $sort_func, $sort_locale) { do { - list($field, $dir) = current($sorter); + $field = current($sorter); + $dir = $field[1] ?? ''; + $field = $field[0] ?? ''; if (!$sort_locale) { $value1 = $d1[$field]; $value2 = $d2[$field]; diff --git a/lib/models/resources/Location.class.php b/lib/models/resources/Location.class.php index f380859..c543153 100644 --- a/lib/models/resources/Location.class.php +++ b/lib/models/resources/Location.class.php @@ -23,10 +23,10 @@ class Location extends Resource protected static $required_properties = [ 'geo_coordinates' ]; - + protected static function configure($config = []) { - if (!is_array($config['additional_fields'])) { + if (!isset($config['additional_fields'])) { $config['additional_fields'] = []; } foreach (self::$required_properties as $property) { @@ -35,18 +35,18 @@ class Location extends Resource 'set' => 'setProperty' ]; } - + $config['additional_fields']['buildings']['get'] = 'findBuildings'; - + $config['additional_fields']['director'] = [ 'get' => 'getPropertyRelatedObject', 'set' => 'setPropertyRelatedObject' ]; - + $config['registered_callbacks']['before_store'][] = 'cbValidate'; parent::configure($config); } - + public static function getTranslatedClassName($item_count = 1) { return ngettext( @@ -55,7 +55,7 @@ class Location extends Resource $item_count ); } - + /** * Returns all locations which are stored in the database. * @@ -70,7 +70,7 @@ class Location extends Resource ORDER BY sort_position DESC, name ASC, mkdate ASC" ); } - + /** * Returns the part of the URL for getLink and getURL which will be * placed inside the calls to URLHelper::getLink and URLHelper::getURL @@ -83,7 +83,7 @@ class Location extends Resource _('Zuer Erstellung der URL fehlt eine Standort-ID!') ); } - + switch ($action) { case 'show': return 'dispatch.php/resources/location/index/' . $id; @@ -99,7 +99,7 @@ class Location extends Resource return parent::buildPathForAction($action, $id); } } - + /** * Returns the appropriate link for the location action that shall be * executed on a location. @@ -124,8 +124,8 @@ class Location extends Resource $link_parameters ); } - - + + /** * Returns the appropriate URL for the location action that shall be * executed on a location. @@ -150,12 +150,12 @@ class Location extends Resource $url_parameters ); } - + public function getRequiredPropertyNames() { return self::$required_properties; } - + /** * @see StudipItem::__toString */ @@ -163,7 +163,7 @@ class Location extends Resource { return $this->getFullName(); } - + public function cbValidate() { if ($this->parent_id) { @@ -175,7 +175,7 @@ class Location extends Resource ) ); } - + if (!is_a($this->category->class_name, get_class($this), true)) { //Only resources with the Location category can be handled //with this class! @@ -187,7 +187,7 @@ class Location extends Resource ); } } - + /** * Returns the full (localised) name of the location. * @@ -200,30 +200,30 @@ class Location extends Resource $this->name ); } - + public function getDefaultPictureUrl() { return $this->getIcon()->asImagePath(); } - + public function getIcon($role = Icon::ROLE_INFO) { return Icon::create('place', $role); } - + public function checkHierarchy() { //We must check if this location has locations as children //or rooms, buildings or locations as parents. //In any of those cases the hierarchy is invalid! - + $children = $this->findChildrenByClassName('Location'); if (count($children) > 0) { //At least one child anywhere below this location //resource is a location, too. return false; } - + $parents = ResourceManager::getHierarchy($this); //We do not need to check this element: array_shift($parents); @@ -235,12 +235,12 @@ class Location extends Resource return false; } } - + //If code execution reaches this point then //the hierarchy around this location is valid. return true; } - + /** * Returns the link for an action for this building. * This is the non-static variant of Building::getLinkForAction. @@ -260,7 +260,7 @@ class Location extends Resource $link_parameters ); } - + /** * Returns the URL for an action for this location. * This is the non-static variant of Location::getURLForAction. @@ -279,9 +279,9 @@ class Location extends Resource $url_parameters ); } - + // Relation methods: - + /** * Retrieves the buildings which are associated to this location * by looking up the child resources of this location. @@ -292,14 +292,14 @@ class Location extends Resource public function findBuildings() { $buildings = parent::findChildrenByClassName('Building'); - + $result = []; foreach ($buildings as $building) { $result[] = Building::toObject($building); } return $result; } - + /** * Adds a child resource to this location. The child resource * must not be a resource of the Location class. @@ -320,7 +320,7 @@ class Location extends Resource } return parent::addChild($resource); } - + public function createSimpleBooking( User $user, DateTime $begin, @@ -333,7 +333,7 @@ class Location extends Resource { return null; } - + public function createBookingFromRequest( User $user, ResourceRequest $request, @@ -347,7 +347,7 @@ class Location extends Resource { return null; } - + public function createBooking( User $user, $range_id = null, @@ -364,7 +364,7 @@ class Location extends Resource { return null; } - + public function createSimpleRequest( User $user, DateTime $begin, @@ -375,7 +375,7 @@ class Location extends Resource { return null; } - + public function createRequest( User $user, $date_range_ids = null, @@ -386,7 +386,7 @@ class Location extends Resource { return null; } - + public function createLock( User $user, DateTime $begin, @@ -396,7 +396,7 @@ class Location extends Resource { return null; } - + public function isAssigned( DateTime $begin, DateTime $end, @@ -405,7 +405,7 @@ class Location extends Resource { return false; } - + public function isReserved( DateTime $begin, DateTime $end, @@ -414,7 +414,7 @@ class Location extends Resource { return false; } - + public function isLocked( DateTime $begin, DateTime $end, @@ -423,7 +423,7 @@ class Location extends Resource { return true; } - + public function isAvailable( DateTime $begin, DateTime $end, diff --git a/lib/raumzeit/SingleDate.class.php b/lib/raumzeit/SingleDate.class.php index 3cda04d..d5f1d00 100644 --- a/lib/raumzeit/SingleDate.class.php +++ b/lib/raumzeit/SingleDate.class.php @@ -391,8 +391,8 @@ class SingleDate $this->end_time = $daten['end_time']; $this->mkdate = $daten['mkdate']; $this->chdate = $daten ['chdate']; - $this->ex_termin = $daten['ex_termin'] ?? false; - $this->orig_ex = $daten['ex_termin'] ?? false; + $this->ex_termin = $daten['ex_termin'] ?? null; + $this->orig_ex = $daten['ex_termin'] ?? null; $this->range_id = $daten['range_id']; $this->author_id = $daten['autor_id']; $this->resource_id = $daten['resource_id']; |
