Skip to content
Snippets Groups Projects
Commit a6341700 authored by David Siegfried's avatar David Siegfried
Browse files

prevent php-warnings, fixes #4063

Closes #4063

Merge request studip/studip!2909
parent 73482db3
No related branches found
No related tags found
No related merge requests found
...@@ -43,14 +43,6 @@ class InstituteCalendarHelper ...@@ -43,14 +43,6 @@ class InstituteCalendarHelper
*/ */
public static function getResourceColumns($institut_id, $only_visible = false) public static function getResourceColumns($institut_id, $only_visible = false)
{ {
/*
returns the columns in following format:
$columns = [
['id' => '0', 'title' => 'Sammelspalte'],
['id' => '1', 'title' => 'Spalte 1']
];
*/
$columns = []; $columns = [];
$inst_columns = [ $inst_columns = [
0 => ['Sammelspalte', 1] 0 => ['Sammelspalte', 1]
...@@ -206,13 +198,13 @@ class InstituteCalendarHelper ...@@ -206,13 +198,13 @@ class InstituteCalendarHelper
/** /**
* Looks up default color value for institute course events * Looks up default color value for institute course events
* *
* @param Course $course * @param SimpleORMap $context
* *
* @return array course events with color value * @return array course events with color value
*/ */
public static function getInstituteDefaultEventcolors($institut) public static function getInstituteDefaultEventcolors($context)
{ {
$df = DatafieldEntryModel::findByModel($institut, self::INST_DEFAULT_COLOR_DATAFIELD_ID); $df = DatafieldEntryModel::findByModel($context, self::INST_DEFAULT_COLOR_DATAFIELD_ID);
if ($df && $df[0]->content) { if ($df && $df[0]->content) {
$event_colors = unserialize($df[0]->content); $event_colors = unserialize($df[0]->content);
} else { } else {
...@@ -224,17 +216,17 @@ class InstituteCalendarHelper ...@@ -224,17 +216,17 @@ class InstituteCalendarHelper
/** /**
* Sets default institute course events color value for semtypes * Sets default institute course events color value for semtypes
* *
* @param Institut $institut * @param SimpleORMap $context
* @param string $semtype * @param string $semtype
* @param string $color colorcode * @param string $color colorcode
* *
* @return bool stored * @return bool stored
*/ */
public static function setInstituteDefaultEventcolor($institut, $semtype, $color) public static function setInstituteDefaultEventcolor($context, $semtype, $color)
{ {
$df = DatafieldEntryModel::findByModel($institut, self::INST_DEFAULT_COLOR_DATAFIELD_ID); $df = DatafieldEntryModel::findByModel($context, self::INST_DEFAULT_COLOR_DATAFIELD_ID);
if ($df[0]) { if ($df[0]) {
$event_colors = self::getInstituteDefaultEventcolors($institut); $event_colors = self::getInstituteDefaultEventcolors($context);
$event_colors[$semtype['name']] = $color; $event_colors[$semtype['name']] = $color;
$df[0]->content = serialize($event_colors); $df[0]->content = serialize($event_colors);
return $df[0]->store(); return $df[0]->store();
...@@ -317,7 +309,6 @@ class InstituteCalendarHelper ...@@ -317,7 +309,6 @@ class InstituteCalendarHelper
*/ */
public static function getEvents($courses, $institut_id, $semester = null, $specific_weekday = null) public static function getEvents($courses, $institut_id, $semester = null, $specific_weekday = null)
{ {
$events = [];
$today = date('w'); $today = date('w');
$user_insts = array_map(function ($arr) { $user_insts = array_map(function ($arr) {
...@@ -330,9 +321,15 @@ class InstituteCalendarHelper ...@@ -330,9 +321,15 @@ class InstituteCalendarHelper
$maxbigtime = (int) $max_time[0]; $maxbigtime = (int) $max_time[0];
$institut = Institute::find($institut_id); $institut = Institute::find($institut_id);
if (!$institut) {
return [];
}
$inst_default_colors = self::getInstituteDefaultEventcolors($institut); $inst_default_colors = self::getInstituteDefaultEventcolors($institut);
Course::findAndMapMany(function ($course) use ( $events = [];
Course::findEachMany(function ($course) use (
$courses, $courses,
&$events, &$events,
$today, $today,
...@@ -418,8 +415,8 @@ class InstituteCalendarHelper ...@@ -418,8 +415,8 @@ class InstituteCalendarHelper
} }
if (!$backgroundcolor) { if (!$backgroundcolor) {
$backgroundcolor = array_key_exists($semtype['name'], $inst_default_colors) $backgroundcolor = array_key_exists($semtype['name'], $inst_default_colors)
? $inst_default_colors[$semtype['name']] ? $inst_default_colors[$semtype['name']]
: self::DEFAULT_EVENT_COLOR; : self::DEFAULT_EVENT_COLOR;
} }
$textcolor = '#ffffff'; $textcolor = '#ffffff';
...@@ -472,7 +469,7 @@ class InstituteCalendarHelper ...@@ -472,7 +469,7 @@ class InstituteCalendarHelper
* @param SeminarCycleDate $cycle_date * @param SeminarCycleDate $cycle_date
* @param string $institut_id * @param string $institut_id
* *
* @return string enriched course info string for tooltip * @return array enriched course info string for tooltip
*/ */
public static function getCycleEvent($cycle_date, $institut_id) public static function getCycleEvent($cycle_date, $institut_id)
{ {
...@@ -594,9 +591,8 @@ class InstituteCalendarHelper ...@@ -594,9 +591,8 @@ class InstituteCalendarHelper
*/ */
private static function getCycleInfos($course, $cycle_date) private static function getCycleInfos($course, $cycle_date)
{ {
$info_string = '';
$info_string .= $course->getFullName('number-name') . "\n"; $info_string = $course->getFullName('number-name') . "\n";
$dozenten = []; $dozenten = [];
foreach (CourseMember::findByCourseAndStatus($course->id, 'dozent') as $cmember) { foreach (CourseMember::findByCourseAndStatus($course->id, 'dozent') as $cmember) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment