/** * Returns a schedule entry for a course * * @param string $seminar_id the ID of the course * @param string $user_id the ID of the user * @param string $cycle_id optional; if given, specifies the ID of the entry * @return array an array containing the properties of the entry */ static function getSeminarEntry($seminar_id, $user_id, $cycle_id = false) { $ret = array(); $sem = new Seminar($seminar_id); foreach ($sem->getCycles() as $cycle) { if (!$cycle_id || $cycle->getMetaDateID() == $cycle_id) { $entry = array(); $entry['id'] = $seminar_id; $entry['cycle_id'] = $cycle->getMetaDateId(); $entry['start_formatted'] = sprintf("%02d", $cycle->getStartStunde()) . ':' . sprintf("%02d", $cycle->getStartMinute()); $entry['end_formatted'] = sprintf("%02d", $cycle->getEndStunde()) . ':' . sprintf("%02d", $cycle->getEndMinute()); $entry['start'] = (int) $cycle->getStartStunde() * 100 + $cycle->getStartMinute(); $entry['end'] = (int) $cycle->getEndStunde() * 100 + $cycle->getEndMinute(); $entry['day'] = $cycle->getDay(); $entry['content'] = $sem->getNumber() . ' ' . $sem->getName(); $entry['url'] = URLHelper::getLink('dispatch.php/calendar/instschedule/entry/' . $seminar_id . '/' . $cycle->getMetaDateId()); $entry['onClick'] = "function(id) { STUDIP.Instschedule.showSeminarDetails('{$seminar_id}', '" . $cycle->getMetaDateId() . "'); }"; $entry['title'] = ''; $ret[] = $entry; } } return $ret; }
/** * Return an entry for the specified course. * * @param string $seminar_id the ID of the course * @param string $user_id the ID of the user * @param mixed $cycle_id either false or the ID of the cycle * @param mixed $semester filter for this semester * * @return array the course's entry */ static function getSeminarEntry($seminar_id, $user_id, $cycle_id = false, $semester = false) { $ret = array(); $filterStart = 0; $filterEnd = 0; // filter dates (and their rooms) if semester is passed if ($semester) { $filterStart = $semester['vorles_beginn']; $filterEnd = $semester['vorles_ende']; } $sem = new Seminar($seminar_id); foreach ($sem->getCycles() as $cycle) { if (!$cycle_id || $cycle->getMetaDateID() == $cycle_id) { $entry = array(); $entry['id'] = $seminar_id . '-' . $cycle->getMetaDateId(); $entry['cycle_id'] = $cycle->getMetaDateId(); $entry['start_formatted'] = sprintf("%02d", $cycle->getStartStunde()) . ':' . sprintf("%02d", $cycle->getStartMinute()); $entry['end_formatted'] = sprintf("%02d", $cycle->getEndStunde()) . ':' . sprintf("%02d", $cycle->getEndMinute()); $entry['start'] = (int) $cycle->getStartStunde() * 100 + $cycle->getStartMinute(); $entry['end'] = (int) $cycle->getEndStunde() * 100 + $cycle->getEndMinute(); $entry['day'] = $cycle->getDay(); $entry['content'] = $sem->getNumber() . ' ' . $sem->getName(); $entry['title'] = $cycle->getDescription(); // check, if the date is assigned to a room if ($rooms = $cycle->getPredominantRoom($filterStart, $filterEnd)) { $entry['title'] .= implode('', getPlainRooms(array_slice($rooms, 0, 1))) . (sizeof($rooms) > 1 ? ', u.a.' : ''); } else { if ($rooms = $cycle->getFreeTextPredominantRoom($filterStart, $filterEnd)) { unset($rooms['']); if (!empty($rooms)) { $entry['title'] .= '(' . implode('), (', array_slice(array_keys($rooms), 0, 3)) . ')'; } } } // add the lecturer $lecturers = array(); $members = $sem->getMembers('dozent'); foreach ($members as $member) { $lecturers[] = $member['Nachname']; } $entry['content'] .= " (" . implode(', ', array_slice($lecturers, 0, 3)) . (sizeof($members) > 3 ? ' et al.' : '') . ')'; $entry['url'] = URLHelper::getLink('dispatch.php/calendar/schedule/entry/' . $seminar_id . '/' . $cycle->getMetaDateId()); $entry['onClick'] = "function (id) {\n var ids = id.split('-');\n STUDIP.Schedule.showSeminarDetails(ids[0], ids[1]);\n }"; // check the settings for this entry $stmt2 = DBManager::get()->prepare("SELECT sc.*, IF(su.user_id IS NULL, 'virtual', 'sem') as type\n FROM schedule_seminare as sc\n LEFT JOIN seminar_user as su ON (su.user_id = sc.user_id AND su.Seminar_id = sc.seminar_id)\n WHERE sc.seminar_id = ? AND sc.user_id = ? AND sc.metadate_id = ?"); $stmt2->execute(array($sem->getId(), $user_id, $cycle->getMetaDateId())); if ($details = $stmt2->fetch()) { if ($details['type'] == 'virtual') { $entry['color'] = $details['color'] ? $details['color'] : DEFAULT_COLOR_VIRTUAL; $entry['icons'][] = array('image' => 'virtual.png', 'title' => _("Dies ist eine vorgemerkte Veranstaltung")); } else { $entry['color'] = $details['color'] ? $details['color'] : DEFAULT_COLOR_SEM; } $entry['type'] = $details['type']; $entry['visible'] = $details['visible']; } else { $entry['type'] = 'sem'; $entry['color'] = DEFAULT_COLOR_SEM; $entry['visible'] = 1; } // show an unhide icon if entry is invisible if (!$entry['visible']) { $entry['url'] .= '/?show_hidden=1'; $bind_url = URLHelper::getLink('dispatch.php/calendar/schedule/bind/' . $seminar_id . '/' . $cycle->getMetaDateId() . '/?show_hidden=1'); $entry['icons'][] = array('url' => $bind_url, 'image' => Icon::create('visibility-invisible', 'info_alt')->asImagePath(16), 'onClick' => "function(id) { window.location = '" . $bind_url . "'; }", 'title' => _("Diesen Eintrag wieder einblenden")); } else { if ($entry['type'] != 'virtual') { $unbind_url = URLHelper::getLink('dispatch.php/calendar/schedule/unbind/' . $seminar_id . '/' . $cycle->getMetaDateId()); $entry['icons'][] = array('url' => $unbind_url, 'image' => Icon::create('visibility-visible', 'info_alt')->asImagePath(16), 'onClick' => "function(id) { window.location = '" . $unbind_url . "'; }", 'title' => _("Diesen Eintrag ausblenden")); } } $ret[] = $entry; } } return $ret; }