/** * common tasks for all actions */ function before_filter(&$action, &$args) { global $perm; parent::before_filter($action, $args); if (Request::get('termin_id')) { $this->dates[0] = new SingleDate(Request::option('termin_id')); $this->course_id = $this->dates[0]->range_id; } if (Request::get('issue_id')) { $this->issue_id = Request::option('issue_id'); $this->dates = array_values(array_map(function ($data) { $d = new SingleDate(); $d->fillValuesFromArray($data); return $d; }, IssueDB::getDatesforIssue(Request::option('issue_id')))); $this->course_id = $this->dates[0]->range_id; } if (!get_object_type($this->course_id, array('sem')) || SeminarCategories::GetBySeminarId($this->course_id)->studygroup_mode || !$perm->have_studip_perm("tutor", $this->course_id)) { throw new Trails_Exception(400); } PageLayout::setHelpKeyword("Basis.VeranstaltungenVerwaltenAendernVonZeitenUndTerminen"); PageLayout::setTitle(Course::findCurrent()->getFullname() . " - " . _("Veranstaltungstermine absagen")); $this->set_content_type('text/html;charset=windows-1252'); if (Request::isXhr()) { $this->set_layout(null); $this->response->add_header('X-Title', PageLayout::getTitle()); $request = Request::getInstance(); foreach ($request as $key => $value) { $request[$key] = studip_utf8decode($value); } } }
private function internalFormatDateWithAllRooms() { $dateWithRooms = ''; if ($this->dates['termin']) { // if we have multiple rooms at the same time we display them all foreach ($this->dates['termin'] as $num => $termin_id) { $date = new SingleDate($termin_id); // if we want an int and format the date ourself if ($this->return_mode == 'int') { return $date->getStartTime(); } $isFirstDate = $num == 0; if ($isFirstDate) { $dateWithRooms = $this->internalFormatDateAndRoom($date); } else { $dateWithRooms .= ', ' . $this->formatRoom($date); } } } return $dateWithRooms; }
/** * Get all activities for this user as an array. */ private function get_dates($user_id, $days, $future) { $items = array(); $start_date = time() - 3600; $end_date = strtotime('+2 years'); // #TODO: use passed variables if (get_config('CALENDAR_ENABLE')) { $list = new DbCalendarEventList(new SingleCalendar($user_id, Calendar::PERMISSION_OWN), $start_date, $end_date, true, Calendar::getBindSeminare($user_id)); if ($list->existEvent()) { while ($date = $list->nextEvent()) { $singledate = SingleDate::getInstance($date->getId()); $items[] = array('id' => $date->getId(), 'start' => $date->getStart(), 'end' => $date->getEnd(), 'title' => $date->getTitle(), 'content' => $date->getDescription(), 'semname' => strtolower(get_class($date)) == 'seminarcalendarevent' ? $termin->getSemName() : false, 'room' => $singledate->getRoom()); } } } else { $stmt = DBManager::get()->prepare($query = "SELECT t.date as start, " . "t.end_time as end, t.termin_id as id, " . "th.title as title, th.description as content, " . "ro.name as room, s.Name as semname FROM termine t " . "LEFT JOIN themen_termine USING (termin_id) " . "LEFT JOIN themen as th USING (issue_id) " . "LEFT JOIN seminare s ON (range_id = s.Seminar_id) " . "LEFT JOIN seminar_user su ON (s.Seminar_id = su.Seminar_id) " . "LEFT JOIN resources_assign ra ON (ra.assign_user_id = t.termin_id) " . "LEFT JOIN resources_objects ro ON (ro.resource_id = ra.resource_id) " . "WHERE (user_id = ?) ORDER BY date DESC"); $stmt->execute(array($user_id)); // echo str_replace('?', "'$user_id'", $query);die; $items = $stmt->fetchAll(PDO::FETCH_ASSOC); } return $items; }
/** * Exports lecture-data. * * This function gets the data of the lectures at an institute and writes it into $data_object. * It calls output_data afterwards. * * @access public * @param string $inst_id Stud.IP-inst_id for export * @param string $ex_sem_id allows to choose if only a specific lecture is to be exported */ function export_sem($inst_id, $ex_sem_id = 'all') { global $range_id, $xml_file, $o_mode, $xml_names_lecture, $xml_groupnames_lecture, $object_counter, $SEM_TYPE, $SEM_CLASS, $filter, $ex_sem, $ex_sem_class, $ex_person_details, $persons; $ex_only_homeinst = Request::int('ex_only_homeinst', 0); // Prepare user count statement $query = "SELECT COUNT(user_id)\n FROM seminar_user\n WHERE seminar_id = ? AND status = 'autor'"; $count_statement = DBManager::get()->prepare($query); // Prepare inner statement $query = "SELECT seminar_user.position,\n auth_user_md5.user_id, auth_user_md5.username, auth_user_md5.Vorname, auth_user_md5.Nachname,\n user_info.title_front, user_info.title_rear\n FROM seminar_user\n LEFT JOIN user_info USING (user_id)\n LEFT JOIN auth_user_md5 USING (user_id)\n WHERE seminar_user.status = 'dozent' AND seminar_user.Seminar_id = ?\n ORDER BY seminar_user.position"; $inner_statement = DBManager::get()->prepare($query); // Prepare (build) and execute outmost query switch ($filter) { case "seminar": $order = " seminare.Name"; break; case "status": $order = "seminare.status, seminare.Name"; $group = "FIRSTGROUP"; $group_tab_zelle = "status"; $do_group = true; break; default: $order = "seminare.status, seminare.Name"; $group = "FIRSTGROUP"; $group_tab_zelle = "status"; $do_group = true; } $parameters = array(); if (isset($ex_sem) && ($semester = Semester::find($ex_sem))) { $addquery = " AND seminare.start_time <= :begin AND (:begin <= (seminare.start_time + seminare.duration_time) OR seminare.duration_time = -1) "; $parameters[':begin'] = $semester->beginn; } if ($ex_sem_id != 'all') { if ($ex_sem_id == 'root') { $addquery .= " AND EXISTS (SELECT * FROM seminar_sem_tree WHERE seminar_sem_tree.seminar_id = seminare.Seminar_id) "; } else { if (!is_array($ex_sem_id)) { $ex_sem_id = array($ex_sem_id); } $ex_sem_id = array_flip($ex_sem_id); } } if (!$GLOBALS['perm']->have_perm('root') && !$GLOBALS['perm']->have_studip_perm('admin', $inst_id)) { $addquery .= " AND visible = 1 "; } if (count($ex_sem_class) > 0) { $allowed_sem_types = array(); foreach (array_keys($ex_sem_class) as $semclassid) { $allowed_sem_types += array_keys(SeminarCategories::get($semclassid)->getTypes()); } $addquery .= " AND seminare.status IN (:status) "; $parameters[':status'] = $allowed_sem_types; } else { $addquery .= " AND seminare.status NOT IN (:status) "; $parameters[':status'] = studygroup_sem_types() ?: ''; } if ($ex_only_homeinst) { $query = "SELECT seminare.*,Seminar_id as seminar_id, Institute.Name AS heimateinrichtung\n FROM seminare\n LEFT JOIN Institute USING (Institut_id)\n WHERE Institut_id = :institute_id {$addquery}\n ORDER BY " . $order; $parameters[':institute_id'] = $inst_id; } else { $query = "SELECT seminare.*,Seminar_id as seminar_id, Institute.Name AS heimateinrichtung\n FROM seminar_inst\n LEFT JOIN seminare USING (Seminar_id)\n LEFT JOIN Institute ON seminare.Institut_id = Institute.Institut_id\n WHERE seminar_inst.Institut_id = :institute_id {$addquery}\n ORDER BY " . $order; $parameters[':institute_id'] = $inst_id; } $statement = DBManager::get()->prepare($query); $statement->execute($parameters); $data = $statement->fetchAll(PDO::FETCH_ASSOC); $data_object .= xml_open_tag($xml_groupnames_lecture['group']); foreach ($data as $row) { if (is_array($ex_sem_id) && !isset($ex_sem_id[$row['seminar_id']])) { continue; } $group_string = ''; if ($do_group && $group != $row[$group_tab_zelle]) { if ($group != 'FIRSTGROUP') { $group_string .= xml_close_tag($xml_groupnames_lecture['subgroup1']); } if ($group_tab_zelle == 'status') { $group_string .= xml_open_tag($xml_groupnames_lecture['subgroup1'], $SEM_TYPE[$row[$group_tab_zelle]]['name']); } else { $group_string .= xml_open_tag($xml_groupnames_lecture['subgroup1'], $row[$group_tab_zelle]); } $group = $row[$group_tab_zelle]; if ($do_subgroup && $subgroup == $row[$subgroup_tab_zelle]) { $subgroup = "NEXTGROUP"; } } if ($do_subgroup && $subgroup != $row[$subgroup_tab_zelle]) { if ($subgroup != 'FIRSTGROUP') { $group_string = xml_close_tag($xml_groupnames_lecture['subgroup2']) . $group_string; } $group_string .= xml_open_tag($xml_groupnames_lecture['subgroup2'], $row[$subgroup_tab_zelle]); $subgroup = $row[$subgroup_tab_zelle]; } $data_object .= $group_string; $object_counter += 1; $data_object .= xml_open_tag($xml_groupnames_lecture['object'], $row['seminar_id']); $sem_obj = new Seminar($row['seminar_id']); while (list($key, $val) = each($xml_names_lecture)) { if ($val == '') { $val = $key; } if ($key == 'status') { $data_object .= xml_tag($val, $SEM_TYPE[$row[$key]]['name']); } elseif ($key == 'ort') { $data_object .= xml_tag($val, $sem_obj->getDatesTemplate('dates/seminar_export_location')); } elseif ($key == 'bereich' && $SEM_CLASS[$SEM_TYPE[$row['status']]['class']]['bereiche']) { $data_object .= xml_open_tag($xml_groupnames_lecture['childgroup3']); $pathes = get_sem_tree_path($row['seminar_id']); if (is_array($pathes)) { foreach ($pathes as $path_name) { $data_object .= xml_tag($val, $path_name); } } else { $data_object .= xml_tag($val, 'n.a.'); } $data_object .= xml_close_tag($xml_groupnames_lecture['childgroup3']); } elseif ($key == 'admission_turnout') { $data_object .= xml_open_tag($val, $row['admission_type'] ? _('max.') : _('erw.')); $data_object .= $row[$key]; $data_object .= xml_close_tag($val); } elseif ($key == 'teilnehmer_anzahl_aktuell') { $count_statement->execute(array($row['seminar_id'])); $count = $count_statement->fetchColumn(); $count_statement->closeCursor(); $data_object .= xml_tag($val, $count); } elseif ($key == 'metadata_dates') { $data_object .= xml_open_tag($xml_groupnames_lecture['childgroup1']); $vorb = vorbesprechung($row['seminar_id'], 'export'); if ($vorb != false) { $data_object .= xml_tag($val[0], $vorb); } if (($first_date = SeminarDB::getFirstDate($row['seminar_id'])) && count($first_date)) { $really_first_date = new SingleDate($first_date[0]); $data_object .= xml_tag($val[1], $really_first_date->getDatesExport()); } $data_object .= xml_tag($val[2], $sem_obj->getDatesExport()); $data_object .= xml_close_tag($xml_groupnames_lecture["childgroup1"]); } elseif ($key == 'Institut_id') { $data_object .= xml_tag($val, $row['heimateinrichtung'], array('key' => $row[$key])); } elseif ($row[$key] != '') { $data_object .= xml_tag($val, $row[$key]); } } $data_object .= "<" . $xml_groupnames_lecture['childgroup2'] . ">\n"; $inner_statement->execute(array($row['seminar_id'])); while ($inner = $inner_statement->fetch(PDO::FETCH_ASSOC)) { if ($ex_person_details) { $persons[$inner['user_id']] = true; } $content_string = $inner['Vorname'] . ' ' . $inner['Nachname']; if ($inner['title_front'] != '') { $content_string = $inner['title_front'] . ' ' . $content_string; } if ($inner['title_rear'] != '') { $content_string .= ', ' . $inner['title_rear']; } $data_object .= xml_tag($xml_groupnames_lecture['childobject2'], $content_string, array('key' => $inner['username'])); } $data_object .= xml_close_tag($xml_groupnames_lecture['childgroup2']); // freie Datenfelder ausgeben $data_object .= export_datafields($row['seminar_id'], $xml_groupnames_lecture['childgroup4'], $xml_groupnames_lecture['childobject4'], 'sem', $row['status']); $data_object .= xml_close_tag($xml_groupnames_lecture['object']); reset($xml_names_lecture); output_data($data_object, $o_mode); $data_object = ''; } if ($do_subgroup && $subgroup != 'FIRSTGROUP') { $data_object .= xml_close_tag($xml_groupnames_lecture['subgroup2']); } if ($do_group && $group != 'FIRSTGROUP') { $data_object .= xml_close_tag($xml_groupnames_lecture['subgroup1']); } $data_object .= xml_close_tag($xml_groupnames_lecture['group']); output_data($data_object, $o_mode); }
public function getTypeExplained() { $ret = ''; if ($this->termin_id) { $ret = _("Einzeltermin der Veranstaltung"); if (get_object_type($this->termin_id, array('date'))) { $termin = new SingleDate($this->termin_id); $ret .= chr(10) . '(' . $termin->toString() . ')'; } } elseif ($this->metadate_id) { $ret = _("alle Termine einer regelmäßigen Zeit"); if ($cycle = SeminarCycleDate::find($this->metadate_id)) { $ret .= chr(10) . ' (' . $cycle->toString('full') . ')'; } } elseif ($this->seminar_id) { $ret = _("alle regelmäßigen und unregelmäßigen Termine der Veranstaltung"); if (get_object_type($this->seminar_id, array('sem'))) { $course = new Seminar($this->seminar_id); $ret .= chr(10) . ' (' . $course->getDatesExport(array('short' => true, 'shrink' => true)) . ')'; } } else { $ret = _("Kein Typ zugewiesen"); } return $ret; }
function showScheduleGraphical($print_view = false) { global $RELATIVE_PATH_RESOURCES, $cssSw, $view_mode, $ActualObjectPerms; $categories["na"] = 4; $categories["sd"] = 4; $categories["y"] = 3; $categories["m"] = 3; $categories["w"] = 0; $categories["d"] = 2; //an assign for a date corresponding to a (seminar-)metadate $categories["meta"] = 1; //match start_time & end_time for a whole week $dow = date ("w", $this->start_time); if (date ("w", $this->start_time) >1) $offset = 1 - date ("w", $this->start_time); if (date ("w", $this->start_time) <1) $offset = -6; //select view to jump from the schedule if ($this->used_view == "openobject_schedule") $view = "openobject_assign"; else $view = "edit_object_assign"; $start_time = mktime (0, 0, 0, date("n",$this->start_time), date("j", $this->start_time)+$offset+($this->week_offset*7), date("Y", $this->start_time)); $end_time = mktime (23, 59, 59, date("n",$start_time), date("j", $start_time)+6, date("Y", $start_time)); if ($_SESSION['resources_data']["schedule_time_range"] == -1) { $start_hour = 0; $end_hour = 12; } elseif ($_SESSION['resources_data']["schedule_time_range"] == 1) { $start_hour = 12; $end_hour = 23; } else { $start_hour = 8; $end_hour = 22; } $schedule = new ScheduleWeek($start_hour, $end_hour, FALSE, $start_time, true); if ($ActualObjectPerms->havePerm("autor")) $schedule->add_link = "resources.php?cancel_edit_assign=1&quick_view=$view&quick_view_mode=".$view_mode."&add_ts="; //fill the schedule $assign_events=new AssignEventList ($start_time, $end_time, $this->resource_id, '', '', TRUE, $_SESSION['resources_data']["show_repeat_mode"]); while ($event=$assign_events->nextEvent()) { $repeat_mode = $event->getRepeatMode(TRUE); $add_info = ''; if ($event->getOwnerType() == 'date') { $sem_obj = Seminar::GetInstance(Seminar::GetSemIdByDateId($event->getAssignUserId())); $date = new SingleDate($event->getAssignUserId()); $dozenten = array_intersect_key($sem_obj->getMembers('dozent'), array_flip($date->getRelatedPersons())); $sem_doz_names = array_map(create_function('$a', 'return $a["Nachname"];'), array_slice($dozenten,0,3, true)); $add_info = '(' . join(', ', $sem_doz_names) . ')'; } $schedule->addEvent($event->getName(get_config('RESOURCES_SCHEDULE_EXPLAIN_USER_NAME')), $event->getBegin(), $event->getEnd(), URLHelper::getLink('?cancel_edit_assign=1&quick_view=' . $view . '&quick_view_mode='.$view_mode.'&edit_assign_object='.$event->getAssignId()), $add_info, $categories[$repeat_mode]); } ?> <table border=0 celpadding=2 cellspacing=0 width="99%" align="center"> <tr> <td class="<? $cssSw->switchClass(); echo $cssSw->getClass() ?>" width="4%"> </td> <td class="<? echo $cssSw->getClass() ?> hidden" width="10%" align="left"> <a href="<? echo URLHelper::getLink('?quick_view='.$this->used_view.'&quick_view_mode='.$view_mode.'&previous_week=TRUE') ?> "><?= Icon::create('arr_2left', 'clickable', ['title' => _("Vorherige Woche anzeigen")])->asImg(16, ["alt" => _("Vorherige Woche anzeigen"), "border" => 0]) ?></a> </td> <td class="<? echo $cssSw->getClass() ?>" width="76%" align="center" style="font-weight:bold"> <? printf(_("Anzeige der Woche vom %s bis %s (KW %s)"), strftime("%x", $start_time), strftime("%x", $end_time),strftime("%V", $start_time));?> <br> <?php $this->showSemWeekNumber($start_time); ?> <br> <?php $room = ResourceObject::Factory($this->resource_id); echo "Raum: ".htmlReady($room->getName()); ?> </td> <td class="<? echo $cssSw->getClass() ?> hidden" width="10%" align="center"> <a href="<? echo URLHelper::getLink('?quick_view='.$this->used_view.'&quick_view_mode='.$view_mode.'&next_week=TRUE')?>"><?= Icon::create('arr_2right', 'clickable', ['title' => _("Nächste Woche anzeigen")])->asImg(16, ["alt" => _("Nächste Woche anzeigen"), "border" => 0]) ?></a> </td> </tr> <tr> <td class="<? $cssSw->switchClass(); echo $cssSw->getClass() ?> hidden" width="4%" align="center" valign="bottom"> <? if ((!$_SESSION['resources_data']["schedule_time_range"]) || ($_SESSION['resources_data']["schedule_time_range"] == 1)): ?> <a href="<?= URLHelper::getLink('', array('quick_view' => $this->used_view, 'quick_view_mode' => $view_mode, 'time_range' => $_SESSION['resources_data']['schedule_time_range'] ? 'FALSE' : -1)) ?>"> <?= Icon::create('arr_2up', 'clickable', ['title' => _('Frühere Belegungen anzeigen')])->asImg(['class' => 'middle']) ?> </a> <? endif; ?> </td> <td class="<? echo $cssSw->getClass() ?>" width="76%" colspan="2"> <? echo " <font size=-1>"._("Anzahl der Belegungen in diesem Zeitraum:")." ", $assign_events->numberOfEvents()."</font><br> "; ?> </td> <td class="<? echo $cssSw->getClass() ?> hidden" width="20%" nowrap> <? print "<select style=\"font-size:10px;\" name=\"show_repeat_mode\">"; printf ("<option style=\"font-size:10px;\" %s value=\"all\">"._("alle Belegungen")."</option>", ($_SESSION['resources_data']["show_repeat_mode"] == "all") ? "selected" : ""); printf ("<option %s style=\"font-size:10px;\" value=\"single\">"._("nur Einzeltermine")."</option>", ($_SESSION['resources_data']["show_repeat_mode"] == "single") ? "selected" : ""); printf ("<option %s style=\"font-size:10px;\" value=\"repeated\">"._("nur Wiederholungstermine")."</option>", ($_SESSION['resources_data']["show_repeat_mode"] == "repeated") ? "selected" : ""); print "</select>"; print " " . Icon::create('accept', 'accept', ['title' => _("Ansicht umschalten")])->asInput(["type" => "image", "class" => "middle", "name" => "send_schedule_repeat_mode"]); ?> </td> </tr> <tr> <td class="<? echo $cssSw->getClass() ?> hidden" width="4%"> </td> <td class="<? echo $cssSw->getClass() ?>" width="96%" colspan="3"> <? $schedule->showSchedule("html", $print_view); ?> </td> </tr> <tr> <td class="<? echo $cssSw->getClass() ?> hidden" width="4%" align="center" valign="bottom"> <? if ((!$_SESSION['resources_data']['schedule_time_range']) || ($_SESSION['resources_data']['schedule_time_range'] == -1)): ?> <a href="<?= URLHelper::getLink('', array('quick_view' => $this->used_view, 'quick_view_mode' => $view_mode, 'time_range' => $_SESSION['resources_data']['schedule_time_range'] ? 'FALSE' : 1)) ?>"> <?= Icon::create('arr_2down', 'clickable', ['title' => _('Spätere Belegungen anzeigen')])->asImg() ?> </a> <? endif; ?> </td> <td class="<? echo $cssSw->getClass() ?>" width="20%" nowrap colspan="3"> </td> </tr> </table> </form> <? }
/** * @deprecated since 3.4 use SeminarCycleDate::removeOutRangedSingleDates($start, $end, $seminar_id) * * removes all singleDates which are NOT between $start and $end */ function removeOutRangedSingleDates($start, $end, $seminar_id) { $query = "SELECT termin_id\n FROM termine\n WHERE range_id = ? AND (`date` NOT BETWEEN ? AND ?)\n AND NOT (metadate_id IS NULL OR metadate_id = '')"; $statement = DBManager::get()->prepare($query); $statement->execute(array($seminar_id, $start, $end)); $ids = $statement->fetchAll(PDO::FETCH_COLUMN); foreach ($ids as $id) { $termin = new SingleDate($id); $termin->delete(); unset($termin); } if (count($ids) > 0) { // remove all assigns for the dates in question $query = "SELECT assign_id FROM resources_assign WHERE assign_user_id IN (?)"; $statement = DBManager::get()->prepare($query); $statement->execute(array($ids)); while ($id = $statement->fetchColumn()) { AssignObject::Factory($assign_id)->delete(); } } // $query = "DELETE FROM termine // WHERE range_id = ? AND (`date` NOT BETWEEN ? AND ?) // AND NOT (metadate_id IS NULL OR metadate_id = '')"; // $statement = DBManager::get()->prepare($query); // $statement->execute(array($seminar_id, $start, $end)); $query = "DELETE FROM ex_termine\n WHERE range_id = ? AND (`date` NOT BETWEEN ? AND ?)\n AND NOT (metadate_id IS NULL OR metadate_id = '')"; $statement = DBManager::get()->prepare($query); $statement->execute(array($seminar_id, $start, $end)); }
/** * create a new room requests */ public function new_action() { $options = array(); $this->url_params = array(); if (Request::get('origin') !== null) { $this->url_params['origin'] = Request::get('origin'); } if (!RoomRequest::existsByCourse($this->course_id)) { $options[] = array('value' => 'course', 'name' => _('alle regelmäßigen und unregelmäßigen Termine der Veranstaltung')); } foreach (SeminarCycleDate::findBySeminar($this->course_id) as $cycle) { if (!RoomRequest::existsByCycle($cycle->getId())) { $name = _("alle Termine einer regelmäßigen Zeit"); $name .= ' (' . $cycle->toString('full') . ')'; $options[] = array('value' => 'cycle_' . $cycle->getId(), 'name' => $name); } } foreach (SeminarDB::getSingleDates($this->course_id) as $date) { if (!RoomRequest::existsByDate($date['termin_id'])) { $name = _("Einzeltermin der Veranstaltung"); $termin = new SingleDate($date['termin_id']); $name .= ' (' . $termin->toString() . ')'; $options[] = array('value' => 'date_' . $date['termin_id'], 'name' => $name); } } $this->options = $options; Helpbar::get()->addPlainText(_('Information'), _('Hier können Sie festlegen, welche Art von Raumanfrage Sie erstellen möchten.')); }
/** * Returns the singledate for the id found in the given field. * * @param string $field The name of the table field. * @return string The singledate. */ protected function formatSingledate($field) { $termin = new SingleDate($this->{$field}); return '<em>' . $termin->toString() . '</em>'; }
public function getGroupedDates($singledate = null, $metadate = null) { $i = 0; $first_event = FALSE; $semesterData = new SemesterData(); $all_semester = $semesterData->getAllSemesterData(); if (Config::get()->RESOURCES_HIDE_PAST_SINGLE_DATES) { // filtering foreach ($all_semester as $semester) { if ($semester['ende'] > time()) { $new_as[] = $semester; } } $all_semester = $new_as; } if (!$singledate) { foreach ($all_semester as $semester) { foreach ($this->metadate->cycles as $metadate_id => $cycle) { if ($metadate && $metadate_id != $metadate) continue; $group = $cycle->getSingleDates(); $metadate_has_termine = 0; $single = true; foreach ($group as $termin) { if (!$termin->isExTermin() && $termin->getStartTime() >= $semester['beginn'] && $termin->getStartTime() <= $semester['ende'] && (!Config::get()->RESOURCES_HIDE_PAST_SINGLE_DATES || $termin->getStartTime() >= time()) && $termin->isPresence()) { if (empty($first_event)) { $first_event = $termin->getStartTime(); } $groups[$i]["termin_ids"][$termin->getSingleDateId()] = TRUE; $metadate_has_termine = 1; if (empty($info[$i]['raum'])) { $info[$i]['raum'] = $termin->resource_id; } else if ($info[$i]['raum'] != $termin->resource_id) { $single = false; } } } if ($metadate_has_termine) { $info[$i]['name'] = $cycle->toString('long').' ('.$semester['name'].')'; $info[$i]['weekend'] = ($cycle->getDay() == 6 || $cycle->getDay() == 0); $this->applyTimeFilter($semester['beginn'], $semester['ende']); $raum = $this->getDatesTemplate('dates/seminar_predominant_html', array('cycle_id' => $metadate_id)); if ($raum) { $info[$i]['name'] .= '<br> '.$raum; $room_stat = $this->getStatOfNotBookedRooms($cycle->getMetadateId()); $info[$i]['name'] .= sprintf(_(" (%s von %s belegt)"), $room_stat['all'] - $room_stat['open'] , $room_stat['all']); $groups[$i]['complete'] = ($room_stat['all'] - $room_stat['open'] >= sizeof($groups[$i]['termin_ids'])) ? true : false; } if (!$single) unset($info[$i]['raum']); $i++; } } } if (!$metadate) { $irreg = $this->getSingleDates(); if (Config::get()->RESOURCES_HIDE_PAST_SINGLE_DATES) { $anzahl = 0; foreach ($irreg as $termin_id => $termin) { if ($termin->getStartTime() > time() - 3600) { $anzahl++; } } } else { $anzahl = sizeof($irreg); } if ($anzahl > Config::get()->RESOURCES_ALLOW_SINGLE_DATE_GROUPING) { $single = true; $first = true; foreach ($irreg as $termin_id => $termin) { if ($termin->isPresence()) { if (!Config::get()->RESOURCES_HIDE_PAST_SINGLE_DATES || $termin->getStartTime() > time() - 3600) { if (empty($first_event)) { $first_event = $termin->getStartTime(); } $groups[$i]["termin_ids"][$termin->getSingleDateId()] = TRUE; if (!$first) $info[$i]['name'] .= '<br> '; $info[$i]['name'] .= $termin->toString(); $resObj = ResourceObject::Factory($termin->resource_id); if ($link = $resObj->getFormattedLink($termin->getStartTime())) { $info[$i]['name'] .= '<br> '.$link; if (empty($info[$i]['raum'])) { $info[$i]['raum'] = $termin->resource_id; } else if ($info[$i]['raum'] != $termin->resource_id) { $single = false; } } if (date('w', $termin->getStartTime()) == 6 || date('w', $termin->getStartTime()) == 0) { $info[$i]['weekend'] = true; } $first = false; } } } if (!$single) unset($info[$i]['raum']); } else { foreach ($irreg as $termin_id => $termin) { if ($termin->isPresence()) { if (!Config::get()->RESOURCES_HIDE_PAST_SINGLE_DATES || $termin->getStartTime() > time() - 3600) { if (empty($first_event)) { $first_event = $termin->getStartTime(); } $groups[$i]["termin_ids"][$termin->getSingleDateId()] = TRUE; $info[$i]['name'] = $termin->toString(); $resObj = ResourceObject::Factory($termin->resource_id); if ($link = $resObj->getFormattedLink($termin->getStartTime())) { $info[$i]['name'] .= '<br> '.$link; $info[$i]['raum'] = $termin->resource_id; } $info[$i]['weekend'] = (date('w', $termin->getStartTime()) == 6 || date('w', $termin->getStartTime()) == 0); $i++; } } } } } } else { // we have a single date $termin = new SingleDate($singledate); $groups[0]['termin_ids'][$termin->getSingleDateID()] = TRUE; $info[0]['name'] = $termin->toString(); $info[0]['raum'] = $termin->resource_id; $info[0]['weekend'] = (date('w', $termin->getStartTime()) == 6 || date('w', $termin->getStartTime()) == 0); $first_event = $termin->getStartTime(); } return array('first_event' => $first_event, 'groups' => $groups, 'info' => $info); }
function getCorrespondingMetadates($termin_id, $begin = '', $end = '', $seminar_id = '') { $termin = new SingleDate($termin_id); if (!$termin->getMetaDateID()) { return false; } if (!$seminar_id) { $seminar_id = $termin->getRangeID(); } $sem = new Seminar($seminar_id); $turnus = $sem->getFormattedTurnusDates(); return $turnus[$termin->getMetaDateID()]; }
/** * generate single date objects for one cycle and one semester, existing dates are merged in * * @param string cycle id * @param int timestamp of semester start * @param int timestamp of semester end * @param int alternative timestamp to start from * @param int correction calculation, if the semester does not start on monday (number of days?) * @return array returns an array of two arrays of SingleDate objects: 'dates' => all new and surviving dates, 'dates_to_delete' => obsolete dates */ function getVirtualSingleDatesForSemester($metadate_id, $sem_begin, $sem_end, $startAfterTimeStamp, $corr) { $dates = array(); $dates_to_delete = array(); // loads the singledates of the by metadate_id denoted regular time-entry into the object $this->readSingleDates($metadate_id); // The currently existing singledates for the by metadate_id denoted regular time-entry $existingSingleDates =& $this->cycles[$metadate_id]->getSingleDates(); $start_woche = $this->cycles[$metadate_id]->week_offset; $end_woche = $this->cycles[$metadate_id]->end_offset; $turnus = $this->cycles[$metadate_id]->cycle; // HolidayData is used to decide wether a date is during a holiday an should be created as an ex_termin. // Additionally, it is used to show which type of holiday we've got. $holiday = new HolidayData(); // This variable is used to check if a given singledate shall be created in a bi-weekly seminar. if ($start_woche == -1) { $start_woche = 0; } $week = 0; // get the first presence date after sem_begin $day_of_week = date('l', strtotime('Sunday + ' . $this->cycles[$metadate_id]->day . ' days')); $stamp = strtotime('this ' . $day_of_week, $sem_begin); if ($end_woche) { $end_woche -= 1; if ($end_woche < 0) { $end_woche = 0; } $sem_end = strtotime(sprintf('+%u weeks %s', $end_woche, strftime('%d.%m.%Y', $stamp))); } $start_time = mktime((int) $this->cycles[$metadate_id]->start_stunde, (int) $this->cycles[$metadate_id]->start_minute, 0, date("n", $stamp), date("j", $stamp), date("Y", $stamp)); // Year $end_time = mktime((int) $this->cycles[$metadate_id]->end_stunde, (int) $this->cycles[$metadate_id]->end_minute, 0, date("n", $stamp), date("j", $stamp), date("Y", $stamp)); // Year // loop through all possible singledates for this regular time-entry do { // if dateExists is true, the singledate will not be created. Default is of course to create the singledate $dateExists = false; // do not create singledates, if they are earlier then the chosen start-week if ($start_woche > $week) { $dateExists = true; } // bi-weekly check if ($turnus > 0 && $week - $start_woche > 0 && ($week - $start_woche) % ($turnus + 1)) { $dateExists = true; } /* * We only create dates, which do not already exist, so we do not overwrite existing dates. * * Additionally, we delete singledates which are not needed any more (bi-weekly, changed start-week, etc.) */ foreach ($existingSingleDates as $key => $val) { // take only the singledate into account, that maps the current timepoint if ($start_time > $startAfterTimeStamp && $val->date == $start_time && $val->end_time == $end_time) { // bi-weekly check if ($turnus > 0 && $week - $start_woche > 0 && ($week - $start_woche) % ($turnus + 1)) { $dates_to_delete[$key] = $val; unset($existingSingleDates[$key]); } // delete singledates if they are earlier than the chosen start-week if ($start_woche > $week) { $dates_to_delete[$key] = $val; unset($existingSingleDates[$key]); } $dateExists = true; if (isset($existingSingleDates[$key])) { $dates[$key] = $val; } } } if ($start_time < $startAfterTimeStamp) { $dateExists = true; } if (!$dateExists) { $termin = new SingleDate(array('seminar_id' => $this->seminar_id)); $all_holiday = $holiday->getAllHolidays(); // fetch all Holidays foreach ($all_holiday as $val2) { if ($val2["beginn"] <= $start_time && $start_time <= $val2["ende"]) { $termin->setExTermin(true); } } //check for calculatable holidays if (!$termin->isExTermin()) { $holy_type = holiday($start_time); if ($holy_type["col"] == 3) { $termin->setExTermin(true); } } // fill the singleDate-Object with data $termin->setMetaDateID($metadate_id); $termin->setTime($start_time, $end_time); $termin->setDateType(1); //best guess $dates[$termin->getTerminID()] = $termin; } //inc the week, create timestamps for the next singledate $start_time = strtotime('+1 week', $start_time); $end_time = strtotime('+1 week', $end_time); $week++; } while ($end_time < $sem_end); foreach ($existingSingleDates as $id => $val) { foreach (array_keys($dates) as $date) { if ($date != $id) { $dates_to_delete[$id] = $val; unset($existingSingleDates[$id]); } } } return array('dates' => $dates, 'dates_to_delete' => $dates_to_delete); }
$permission = 7; if ($open_id == $SessSemName[1]) { $titel=_("Allgemeiner Dateiordner"); $description= sprintf(_("Ablage für allgemeine Ordner und Dokumente der %s"), $SessSemName["art_generic"]); } else if ($open_id == md5('new_top_folder')){ $titel = Request::get('top_folder_name') ? Request::get('top_folder_name') : _("Neuer Ordner"); $open_id = md5($SessSemName[1] . 'top_folder'); } elseif($titel = GetStatusgruppeName($open_id)) { $titel = _("Dateiordner der Gruppe:") . ' ' . $titel; $description = _("Ablage für Ordner und Dokumente dieser Gruppe"); $permission = 15; } else if ($data = SingleDateDB::restoreSingleDate($open_id)) { // If we create a folder which has not yet an issue, we just create one $issue = new Issue(array('seminar_id' => $SessSemName[1])); $issue->setTitle(_("Ohne Titel")); $termin = new SingleDate($open_id); $termin->addIssueID($issue->getIssueID()); $issue->store(); $termin->store(); $open_id = $issue->getIssueID(); $titel = $issue->getTitle(); $description= _("Themenbezogener Dateiordner"); } else { $query = "SELECT title FROM themen WHERE issue_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($open_id)); if ($result = $statement->fetch()) { $titel = $result["title"]; $description= _("Themenbezogener Dateiordner"); }
$users = array_merge($users, array_keys($semObj->getMembers('dozent'))); } // the room-request has been declined if ($_sendMessage['type'] == 'declined') { $decline_message = Request::get('decline_message'); if ($semObj->seminar_number) { $message = sprintf(_("ABGELEHNTE RAUMANFRAGE: Ihre Raumanfrage zur Veranstaltung %s (%s) wurde abgelehnt.") . "\n\n" . _("Nachricht des Raumadministrators:") . "\n" . $decline_message, $semObj->getName(), $semObj->seminar_number); } else { $message = sprintf(_("ABGELEHNTE RAUMANFRAGE: Ihre Raumanfrage zur Veranstaltung %s wurde abgelehnt.") . "\n\n" . _("Nachricht des Raumadministrators:") . "\n" . $decline_message, $semObj->getName()); } if ($reqObj->getTerminId()) { $termin = new SingleDate($reqObj->getTerminId()); $message .= "\n\n". _("Betroffener Termin:") . "\n" . $termin->toString(); } if ($reqObj->getMetadateId()) { $cycle = SeminarCycleDate::find($reqObj->getMetadateId()); $message .= "\n\n". _("Betroffene Zeit:") . "\n" . $cycle->toString('full'); } // fetch the names of the lecutrers to display them in the message foreach($semObj->getMembers('dozent') as $dozenten){ $title[] = $dozenten['Nachname']; } if($semObj->seminar_number) $title[] = $semObj->seminar_number; $title[] = mila($semObj->getName(),30); $reqObj->setReplyComment($decline_message);
function bookable_rooms_action() { if (!getGlobalPerms($GLOBALS['user']->id) == 'admin') { $resList = new ResourcesUserRoomsList($GLOBALS['user']->id, false, false, false); if (!$resList->roomsExist()) { throw new AccessDeniedException(); } } $select_options = Request::optionArray('rooms'); $rooms = array_filter($select_options, function ($v) { return strlen($v) === 32; }); $events = array(); $dates = array(); $timestamps = array(); if (count(Request::getArray('new_date'))) { $new_date = array(); foreach (Request::getArray('new_date') as $one) { if ($one['name'] == 'startDate') { $dmy = explode('.', $one['value']); $new_date['day'] = (int) $dmy[0]; $new_date['month'] = (int) $dmy[1]; $new_date['year'] = (int) $dmy[2]; } $new_date[$one['name']] = (int) $one['value']; } if (check_singledate($new_date['day'], $new_date['month'], $new_date['year'], $new_date['start_stunde'], $new_date['start_minute'], $new_date['end_stunde'], $new_date['end_minute'])) { $start = mktime($new_date['start_stunde'], $new_date['start_minute'], 0, $new_date['month'], $new_date['day'], $new_date['year']); $ende = mktime($new_date['end_stunde'], $new_date['end_minute'], 0, $new_date['month'], $new_date['day'], $new_date['year']); $timestamps[] = $start; $timestamps[] = $ende; $event = new AssignEvent('new_date', $start, $ende, null, null, ''); $events[$event->getId()] = $event; } } foreach (Request::optionArray('selected_dates') as $one) { $date = new SingleDate($one); if ($date->getStartTime()) { $timestamps[] = $date->getStartTime(); $timestamps[] = $date->getEndTime(); $event = new AssignEvent($date->getTerminID(), $date->getStartTime(), $date->getEndTime(), null, null, ''); $events[$event->getId()] = $event; $dates[$date->getTerminID()] = $date; } } if (count($events)) { $result = array(); $checker = new CheckMultipleOverlaps(); $checker->setTimeRange(min($timestamps), max($timestamps)); foreach ($rooms as $room) { $checker->addResource($room); } $checker->checkOverlap($events, $result, "assign_id"); foreach ((array) $result as $room_id => $details) { foreach ($details as $termin_id => $conflicts) { if ($termin_id == 'new_date' && Request::option('singleDateID')) { $assign_id = SingleDateDB::getAssignID(Request::option('singleDateID')); } else { $assign_id = SingleDateDB::getAssignID($termin_id); } $filter = function ($a) use($assign_id) { if ($a['assign_id'] && $a['assign_id'] == $assign_id) { return false; } return true; }; if (!count(array_filter($conflicts, $filter))) { unset($result[$room_id][$termin_id]); } } } $result = array_filter($result); $this->render_json(array_keys($result)); return; } $this->render_nothing(); }
function deleteNewerSingleDates($metadate_id, $timestamp, $keepIssues = false) { $count = 0; $query = "SELECT termin_id FROM termine WHERE metadate_id = ? AND `date` > ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($metadate_id, $timestamp)); while ($termin_id = $statement->fetchColumn()) { $termin = new SingleDate($termin_id); $termin->delete($keepIssues); unset($termin); $count += 1; } $query = "DELETE FROM termine WHERE metadate_id = ? AND `date` > ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($metadate_id, $timestamp)); $query = "DELETE FROM ex_termine WHERE metadate_id = ? AND `date` > ?"; $statement = DBManager::get()->prepare($query); $statement->execute(array($metadate_id, $timestamp)); return $count; }
/** * load corresponding single dates from database * give timestamps as params to filter by time range * * @param int $start * @param int $end * @return boolean */ function readSingleDates($start = 0, $end = 0) { $this->termine = array(); $termin_data = CycleDataDB::getTermine($this->metadate_id, $start, $end); if ($termin_data) { foreach ($termin_data as $val) { unset($termin); $termin = new SingleDate(); $termin->fillValuesFromArray($val); $termin->setExTermin($val['ex_termin']); $this->termine[$val['termin_id']] = $termin; } return TRUE; } return FALSE; }