diff options
| author | David Siegfried <david.siegfried@uni-vechta.de> | 2024-11-05 14:48:18 +0000 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2024-11-05 14:48:18 +0000 |
| commit | 5e152fa4fb034e5952dfde30e7f2cd99a6e33b39 (patch) | |
| tree | b086796c5c106d20899f4c3ba508d2fcc2b6bd0f | |
| parent | d5327a04059ae4b88a51f0c089370d597717f4e3 (diff) | |
prevent php-warnings, fixes #4829
Merge request studip/studip!3611
| -rw-r--r-- | app/controllers/avatar.php | 8 | ||||
| -rw-r--r-- | lib/classes/SemBrowse.class.php | 2 | ||||
| -rw-r--r-- | lib/classes/Seminar.class.php | 3 | ||||
| -rw-r--r-- | lib/classes/calendar/CalendarScheduleModel.php | 11 | ||||
| -rw-r--r-- | lib/classes/sidebar/Sidebar.php | 2 | ||||
| -rw-r--r-- | lib/evaluation/classes/EvaluationExportManager.class.php | 11 | ||||
| -rw-r--r-- | lib/evaluation/classes/EvaluationExportManagerCSV.class.php | 15 | ||||
| -rw-r--r-- | lib/evaluation/classes/EvaluationTreeEditView.class.php | 9 | ||||
| -rw-r--r-- | lib/evaluation/classes/EvaluationTreeShowUser.class.php | 2 | ||||
| -rw-r--r-- | lib/meine_seminare_func.inc.php | 2 | ||||
| -rw-r--r-- | public/eval_summary_export.php | 7 | ||||
| -rw-r--r-- | public/show_bereich.php | 2 | ||||
| -rw-r--r-- | public/show_evaluation.php | 2 |
13 files changed, 54 insertions, 22 deletions
diff --git a/app/controllers/avatar.php b/app/controllers/avatar.php index aafbb98..9068a82 100644 --- a/app/controllers/avatar.php +++ b/app/controllers/avatar.php @@ -129,8 +129,12 @@ class AvatarController extends AuthenticatedController $imgdata = Request::get('cropped-image'); // Extract actual image data (prepended by mime type and meta data) - list($type, $imgdata) = explode(';', $imgdata); - list(, $imgdata) = explode(',', $imgdata); + $chunks = explode(';', $imgdata); + $type = $chunks[0]; + $imgdata = $chunks[1] ?? ''; + + $chunks = explode(',', $imgdata); + $imgdata = $chunks[1] ?? ''; $imgdata = base64_decode($imgdata); // Write data to file. $filename = $GLOBALS['TMP_PATH'] . '/avatar-' . $id . '.png'; diff --git a/lib/classes/SemBrowse.class.php b/lib/classes/SemBrowse.class.php index c1cae8d..a3e7c12 100644 --- a/lib/classes/SemBrowse.class.php +++ b/lib/classes/SemBrowse.class.php @@ -816,7 +816,7 @@ class SemBrowse { uksort($group_by_data, function($a,$b) { $the_tree = TreeAbstract::GetInstance('StudipSemTree', false); $the_tree->buildIndex(); - return $the_tree->tree_data[$a]['index'] - $the_tree->tree_data[$b]['index']; + return ($the_tree->tree_data[$a]['index'] ?? 0) - ($the_tree->tree_data[$b]['index'] ?? 0); }); break; case 3: diff --git a/lib/classes/Seminar.class.php b/lib/classes/Seminar.class.php index 054c337..d9455d3 100644 --- a/lib/classes/Seminar.class.php +++ b/lib/classes/Seminar.class.php @@ -1278,7 +1278,8 @@ class Seminar $_SESSION['raumzeitFilter'] = 'all'; $this->applyTimeFilter(0, 0); } else { - $filterSemester = Semester::findByTimestamp($timestamp); + $filterSemester = Semester::findByTimestamp($timestamp) + ?? Semester::findCurrent(); $_SESSION['raumzeitFilter'] = $filterSemester->beginn; $this->applyTimeFilter($filterSemester->beginn, $filterSemester->ende); } diff --git a/lib/classes/calendar/CalendarScheduleModel.php b/lib/classes/calendar/CalendarScheduleModel.php index 0aeadee..fdca8e3 100644 --- a/lib/classes/calendar/CalendarScheduleModel.php +++ b/lib/classes/calendar/CalendarScheduleModel.php @@ -676,6 +676,17 @@ class CalendarScheduleModel $schedule_settings['converted'] = true; } + if (empty($schedule_settings['glb_days'])) { + $schedule_settings['glb_days'] = [1, 2, 3, 4, 5]; + } + + if (empty($settings['glb_start_time'])) { + $schedule_settings['glb_start_time'] = 8; + } + if (empty($settings['glb_end_time'])) { + $schedule_settings['glb_end_time'] = 19; + } + return $schedule_settings; } diff --git a/lib/classes/sidebar/Sidebar.php b/lib/classes/sidebar/Sidebar.php index b9d0338..822fa1b 100644 --- a/lib/classes/sidebar/Sidebar.php +++ b/lib/classes/sidebar/Sidebar.php @@ -145,7 +145,7 @@ class Sidebar extends WidgetContainer $this->setContextAvatar($avatar); } if ($main_navigation === 'profile') { - if ($keys[1] !== "index") { + if (!empty($keys[1]) && $keys[1] !== 'index') { $user = Request::get("username") ? User::findByUsername(Request::get("username")) : User::findCurrent(); diff --git a/lib/evaluation/classes/EvaluationExportManager.class.php b/lib/evaluation/classes/EvaluationExportManager.class.php index 0c88e7f..08fd5e2 100644 --- a/lib/evaluation/classes/EvaluationExportManager.class.php +++ b/lib/evaluation/classes/EvaluationExportManager.class.php @@ -233,10 +233,14 @@ class EvaluationExportManager extends AuthorObject $file = $GLOBALS['TMP_PATH'] . "/" . $file; $part = pathinfo($file); - if (filemtime($file) < (time() - EVALEXPORT_LIFETIME) && - $part["extension"] == $this->extension && - mb_substr($part["basename"], 0, mb_strlen(EVALEXPORT_PREFIX)) == EVALEXPORT_PREFIX) + if ( + filemtime($file) < (time() - EVALEXPORT_LIFETIME) + && isset($part['extension']) + && $part['extension'] === $this->extension + && mb_substr($part['basename'], 0, mb_strlen(EVALEXPORT_PREFIX)) == EVALEXPORT_PREFIX + ) { unlink($file); + } } $dirhandle->close(); } @@ -264,4 +268,3 @@ class EvaluationExportManager extends AuthorObject } } - diff --git a/lib/evaluation/classes/EvaluationExportManagerCSV.class.php b/lib/evaluation/classes/EvaluationExportManagerCSV.class.php index 4baa3f8..f236457 100644 --- a/lib/evaluation/classes/EvaluationExportManagerCSV.class.php +++ b/lib/evaluation/classes/EvaluationExportManagerCSV.class.php @@ -273,10 +273,14 @@ class EvaluationExportManagerCSV extends EvaluationExportManager { /* Questiontype: pol or likert scale --------------------------- */ if ($type == EVALQUESTION_TYPE_LIKERT || $type == EVALQUESTION_TYPE_POL) { - $hasResidual = $this->evalquestions_residual[$evalquestion->getObjectID()]; + $hasResidual = $this->evalquestions_residual[$evalquestion->getObjectID()] ?? ''; $entry = ""; $residual = 0; - if ($answer = $answers[$evalquestion->getObjectID()][$userID]) { + $answer = []; + if ($evalquestion->getObjectID() && !empty($answers[$evalquestion->getObjectID()])) { + $answer = $answers[$evalquestion->getObjectID()][$userID]; + } + if (!empty($answer)) { if ($answer['residual']) { $residual = 1; } else { @@ -295,7 +299,12 @@ class EvaluationExportManagerCSV extends EvaluationExportManager { /* Questiontype: multiple chioice ------------------------------ */ elseif ($type == EVALQUESTION_TYPE_MC) { if ($evalquestion->isMultiplechoice ()) { - $mc_answers = explode(',', $answers[$evalquestion->getObjectID()][$userID]['evalanswer_id']); + if ($evalquestion->getObjectID()) { + $mc_answers = $answers[$evalquestion->getObjectID()][$userID]['evalanswer_id'] ?? []; + } else { + $mc_answers = []; + } + $mc_answers = explode(',', $mc_answers); while ($answer = &$evalquestion->getNextChild ()) { $this->addCol ((int)in_array($answer->getObjectID(), $mc_answers)); } diff --git a/lib/evaluation/classes/EvaluationTreeEditView.class.php b/lib/evaluation/classes/EvaluationTreeEditView.class.php index 3bfe92a..0fbbe08 100644 --- a/lib/evaluation/classes/EvaluationTreeEditView.class.php +++ b/lib/evaluation/classes/EvaluationTreeEditView.class.php @@ -1210,15 +1210,15 @@ class EvaluationTreeEditView $no_answers++; } if ($no_answers == 1) { - if ($this->msg[$this->itemID]) + if (!empty($this->msg[$this->itemID])) $this->msg[$this->itemID] .= "<br>" . _("Einer Frage wurden noch keine Antwortenmöglichkeiten zugewiesen."); else - $this->msg[$this->itemID] .= "info§" . _("Einer Frage wurden noch keine Antwortenmöglichkeiten zugewiesen."); + $this->msg[$this->itemID] = "info§" . _("Einer Frage wurden noch keine Antwortenmöglichkeiten zugewiesen."); } elseif ($no_answers > 1) { - if ($this->msg[$this->itemID]) + if (!empty($this->msg[$this->itemID])) $this->msg[$this->itemID] .= "<br>" . sprintf(_("%s Fragen wurden noch keine Antwortenmöglichkeiten zugewiesen."), $no_answers); else - $this->msg[$this->itemID] .= "info§" . sprintf(_("%s Fragen wurden noch keine Antwortenmöglichkeiten zugewiesen."), $no_answers); + $this->msg[$this->itemID] = "info§" . sprintf(_("%s Fragen wurden noch keine Antwortenmöglichkeiten zugewiesen."), $no_answers); } } @@ -1507,6 +1507,7 @@ class EvaluationTreeEditView $qgroup = &$this->tree->getGroupObject($this->itemID); $questionsDB = $qgroup->getChildren(); $cmd = Request::optionArray('cmd'); + $delete_empty_questions = 0; if (!empty($cmd)) if (key($cmd) == "UpdateItem") $delete_empty_questions = 1; diff --git a/lib/evaluation/classes/EvaluationTreeShowUser.class.php b/lib/evaluation/classes/EvaluationTreeShowUser.class.php index e999cb5..9968ff0 100644 --- a/lib/evaluation/classes/EvaluationTreeShowUser.class.php +++ b/lib/evaluation/classes/EvaluationTreeShowUser.class.php @@ -507,7 +507,7 @@ class EvaluationTreeShowUser ? "checked" : ""; else - $checked = (is_array($answers[$question->getObjectID()]) && + $checked = (!empty($answers[$question->getObjectID()]) && in_array($answer->getObjectID(), $answers[$question->getObjectID()])) ? "checked" : ""; diff --git a/lib/meine_seminare_func.inc.php b/lib/meine_seminare_func.inc.php index 297bf3f..f0b5940 100644 --- a/lib/meine_seminare_func.inc.php +++ b/lib/meine_seminare_func.inc.php @@ -83,7 +83,7 @@ function sort_groups($group_field, &$groups) case 'sem_tree_id': uksort($groups, function ($a, $b) { $the_tree = TreeAbstract::GetInstance('StudipSemTree', ['build_index' => true]); - return $the_tree->tree_data[$a]['index'] - $the_tree->tree_data[$b]['index']; + return ($the_tree->tree_data[$a]['index'] ?? 0) - ($the_tree->tree_data[$b]['index'] ?? 0); }); break; diff --git a/public/eval_summary_export.php b/public/eval_summary_export.php index 77b349a..118cd92 100644 --- a/public/eval_summary_export.php +++ b/public/eval_summary_export.php @@ -138,7 +138,10 @@ function do_graph($data, $evalquestion_id) ); if(!empty($data)) { - $max_x = max(array_map('next',$data)); + array_walk($data, function($d) use (&$_data) { + $_data[] = next($d); + }); + $max_x = max($_data); $graph->SetPlotAreaWorld(NULL, 0); // y-achse bei 0 starten $graph->SetPrecisionY(0); //anzahl kommastellen y-achse $graph->SetYTickIncrement($max_x < 10 ? 1 : round($max_x/10)); @@ -169,7 +172,7 @@ function freetype_answers ($parent_id, $anz_nutzer) { ORDER BY position"; $statement = DBManager::get()->prepare($query); $statement->execute([$parent_id]); - + $counter = 0; while ($answer = $statement->fetchColumn()) { $counter++; fputs($fo_file," <fo:table-row>\n"); diff --git a/public/show_bereich.php b/public/show_bereich.php index 2a5e55d..94bda5e 100644 --- a/public/show_bereich.php +++ b/public/show_bereich.php @@ -47,7 +47,7 @@ if (Request::option('select_sem')) { $_SESSION['_default_sem'] = Request::option('select_sem'); } -$show_semester = Request::option('select_sem', $_SESSION['_default_sem']); +$show_semester = Request::option('select_sem', $_SESSION['_default_sem'] ?? ''); $sem_browse_obj = new SemBrowse(['group_by' => 0]); $sem_browse_obj->sem_browse_data['default_sem'] = "all"; $sem_browse_obj->sem_number = false; diff --git a/public/show_evaluation.php b/public/show_evaluation.php index e81510a..76f6c1f 100644 --- a/public/show_evaluation.php +++ b/public/show_evaluation.php @@ -240,7 +240,7 @@ page_close(); ( is_array($answers) && ! in_array($item->getObjectID(), array_keys($answers)) ) ) && - trim($freetexts[$item->getObjectID()]) == '' + empty($freetexts[$item->getObjectID()]) ) { $mandatories[] = $item->getObjectID(); |
