/** * Creates a widget view from a week view. * * @param CalendarWeekView $view The CalendarWeekView object * @return CalendarWidgetView object with the data from the * CalendarWeekView */ public static function createFromWeekView(CalendarWeekView $view) { $new_view = new self($view->getColumns(), $view->getContext()); $new_view->setReadOnly(true); return $new_view; }
/** * Create a CalendarWeekView (a schedule) for the current user and return it. * * @param string $user_id the institute to get the calendar for * @param bool $show_hidden show hidden entries * @param mixed $semester the semester to use * @param mixed $days the days to consider * * @return CalendarWeekView */ static function getUserCalendarView($user_id, $show_hidden = false, $semester = false, $days = false) { $schedule_settings = self::getScheduleSettings($user_id); if (!$semester) { $semester = self::getCurrentSemester(); } if (!$days) { $days = $schedule_settings['glb_days']; foreach ($days as $key => $day_number) { $days[$key] = ($day_number + 6) % 7; } } $entries = CalendarScheduleModel::getEntries($user_id, $semester, $schedule_settings['glb_start_time'], $schedule_settings['glb_end_time'], $days, $show_hidden); $view = new CalendarWeekView($entries, 'schedule'); $view->setHeight(40 + 20 * $schedule_settings['zoom']); $view->setRange($schedule_settings['glb_start_time'], $schedule_settings['glb_end_time']); $view->setInsertFunction("function (entry, column, hour, end_hour) {\n STUDIP.Schedule.newEntry(entry, column, hour, end_hour)\n }"); return $view; }