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> <? }
function resource_message_action($resource_id) { $r_perms = new ResourceObjectPerms($resource_id, $GLOBALS['user']->id); if (!$r_perms->havePerm('admin')) { throw new AccessDeniedException(); } $this->resource = new ResourceObject($resource_id); $title = sprintf(_("Nutzer von %s benachrichtigen"), htmlReady($this->resource->getName())); $form_fields['start_day'] = array('type' => 'text', 'size' => '10', 'required' => true, 'caption' => _("Belegungen berücksichtigen von")); $form_fields['start_day']['attributes'] = array('onMouseOver' => 'jQuery(this).datepicker();this.blur();', 'onChange' => '$(this).closest("form").submit();'); $form_fields['start_day']['default_value'] = strftime('%x'); $form_fields['end_day'] = array('type' => 'text', 'size' => '10', 'required' => true, 'caption' => _("Belegungen berücksichtigen bis")); $form_fields['end_day']['attributes'] = array('onMouseOver' => 'jQuery(this).datepicker();this.blur();', 'onChange' => '$(this).closest("form").submit();'); $form_fields['end_day']['default_value'] = strftime('%x', strtotime('+6 months')); $form_fields['subject'] = array('type' => 'text', 'size' => '200', 'attributes' => array('style' => 'width:100%'), 'required' => true, 'caption' => _("Betreff")); $form_fields['subject']['default_value'] = $this->resource->getName(); $form_fields['message'] = array('caption' => _("Nachricht"), 'type' => 'textarea', 'required' => true, 'attributes' => array('rows' => 4, 'style' => 'width:100%')); $form_buttons['save_close'] = array('caption' => _('OK'), 'info' => _("Benachrichtigung verschicken und Dialog schließen")); $form = new StudipForm($form_fields, $form_buttons, 'resource_message', false); $start_time = strtotime($form->getFormFieldValue('start_day')); $end_time = strtotime($form->getFormFieldValue('end_day')); $assign_events = new AssignEventList($start_time, $end_time, $resource_id, '', '', TRUE, 'all'); $rec = array(); while ($event = $assign_events->nextEvent()) { if ($owner_type = $event->getOwnerType()) { if ($owner_type == 'date') { $seminar = new Seminar(Seminar::GetSemIdByDateId($event->getAssignUserId())); foreach ($seminar->getMembers('dozent') as $dozent) { $rec[$dozent['username']][] = strftime('%x %R', $event->begin) . ' - ' . strftime('%R', $event->end) . ' ' . $seminar->getName(); } } else { $rec[get_username($event->getAssignUserId())][] = strftime('%x %R', $event->begin) . ' - ' . strftime('%R', $event->end); } } } if ($form->isSended() && count($rec) && $form->getFormFieldValue('message')) { $messaging = new Messaging(); $ok = $messaging->insert_message($form->getFormFieldValue('message'), array_keys($rec), $GLOBALS['user']->id, null, null, null, '', $form->getFormFieldValue('subject'), true); PageLayout::postMessage(MessageBox::success(sprintf(_("Die Nachricht wurde an %s Nutzer verschickt"), $ok))); return $this->redirect(URLHelper::getUrl('resources.php?view=resources')); } if (!count($rec)) { PageLayout::postMessage(MessageBox::error(sprintf(_("Im Zeitraum %s - %s wurden keine Belegungen gefunden!"), strftime('%x', $start_time), strftime('%x', $end_time)))); $this->no_receiver = true; } else { $submessage = array(); foreach ($rec as $username => $slots) { $submessage[] = get_fullname_from_uname($username, 'full_rev_username', true) . ' ' . sprintf(_('(%s Belegungen)'), count($slots)); } PageLayout::postMessage(MessageBox::info(sprintf(_("Benachrichtigung an %s Nutzer verschicken"), count($rec)), $submessage, true)); } $this->form = $form; $this->response->add_header('X-Title', $title); }
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; //select view to jump from the schedule if ($view_mode == "oobj") $view = "openobject_assign"; else $view = "edit_object_assign"; $start_time = $this->start_time; $end_time = $this->end_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; } if ($this->resources_groups->getGroupCount($this->group_id)){ $schedule=new SemGroupScheduleDayOfWeek($start_hour, $end_hour,$this->resources_groups->getGroupContent($this->group_id), $start_time, false); $schedule->add_link = "resources.php?cancel_edit_assign=1&quick_view=$view&quick_view_mode=".$view_mode."&add_ts="; $num_rep_events = 0; $num_single_events = 0; $num = 1; foreach ($this->resources_groups->getGroupContent($this->group_id) as $resource_to_show_id => $resource_id){ //fill the schedule $assign_events=new AssignEventList ($start_time, $end_time, $resource_id, '', '', TRUE, $_SESSION['resources_data']["show_repeat_mode"]); while ($event=$assign_events->nextEvent()) { $repeat_mode = $event->getRepeatMode(TRUE); if(in_array($repeat_mode, array('w','d','m','y'))){ $assign = AssignObject::Factory($event->getAssignId()); switch($event->repeat_mode){ case 'd': $add_info = '('.sprintf(_("täglich, %s bis %s"), strftime('%x',$assign->getBegin()), strftime('%x',$assign->getRepeatEnd())).')'; break; case 'w': if($assign->getRepeatInterval() == 1) $add_info = '('._("wöchentlich").')'; else $add_info = '('.$assign->getRepeatInterval().'-'._("wöchentlich").')'; break; case 'm': if($assign->getRepeatInterval() == 1) $add_info = '('._("monatlich").')'; else $add_info = '('.$assign->getRepeatInterval().'-'._("monatlich").')'; break; case 'y': if($assign->getRepeatInterval() == 1) $add_info = '('._("jährlich").')'; else $add_info = '('.$assign->getRepeatInterval().'-'._("jährlich").')'; break; } } else { $add_info = ''; } if (in_array($event->getOwnerType(), array('sem','date'))){ $sem_doz_names = array(); $c = 0; if ($event->getOwnerType() == 'sem'){ $sem_obj = Seminar::GetInstance($event->getAssignUserId()); } else { $sem_obj = Seminar::GetInstance(Seminar::GetSemIdByDateId($event->getAssignUserId())); } foreach($sem_obj->getMembers('dozent') as $dozent){ $sem_doz_names[] = $dozent['Nachname']; if (++$c > 2) break; } $add_info .= '(' . join(', ', $sem_doz_names) . ')'; } $schedule->addEvent($resource_to_show_id, $event->getName(get_config('RESOURCES_SCHEDULE_EXPLAIN_USER_NAME')), $event->getBegin(), $event->getEnd(), URLHelper::getLink('?show_object='.$resource_id.'&cancel_edit_assign=1&quick_view='.$view.'&quick_view_mode='.$view_mode.'&edit_assign_object='.$event->getAssignId()), $add_info, $categories[$repeat_mode]); } } } else { return; } if(!$print_view){ ?> <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() ?>" width="10%" align="left"> <a href="<? echo URLHelper::getLink('?quick_view='.$this->used_view.'&quick_view_mode='.$view_mode.'&previous_day=1')?>"><?= Icon::create('arr_2left', 'clickable', ['title' => _("Vorherigen Tag anzeigen")])->asImg(16, ["alt" => _("Vorherigen Tag anzeigen"), "border" => 0]) ?></a> </td> <td class="<? echo $cssSw->getClass() ?>" width="76%" align="center" style="font-weight:bold"> <? echo htmlReady(strftime('%A, %x (KW %V)', $start_time)); ?> <br> <?php $this->showSemWeekNumber($start_time); ?> </td> <td class="<? echo $cssSw->getClass() ?>" width="10%" align="center"> <a href="<? echo URLHelper::getLink('?quick_view='.$this->used_view.'&quick_view_mode='.$view_mode.'&next_day=1')?>"><?= Icon::create('arr_2right', 'clickable', ['title' => _("Nächsten Tag anzeigen")])->asImg(16, ["alt" => _("Nächsten Tag anzeigen"), "border" => 0]) ?></a> </td> </tr> <tr> <td class="<? $cssSw->switchClass(); echo $cssSw->getClass() ?>" 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() ?>" 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() ?>" width="4%"> </td> <td class="<? echo $cssSw->getClass() ?>" width="96%" colspan="3"> <? $schedule->showSchedule("html"); ?> </td> </tr> <tr> <td class="<? echo $cssSw->getClass() ?>" 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> <? } else { ?> <table border="0" cellpadding="0" cellspacing="0" width="100%" align="center"> <tr> <td align="center"> <div style="font-size:150%;font-weight:bold;"> <?=htmlReady($this->resources_groups->getGroupName($this->group_id))?> <br> <? echo htmlReady(strftime('%A, %x (KW %V)', $start_time));?> <br> <?php $this->showSemWeekNumber($start_time); ?> </div> </td> </tr> <tr> <td> <? $schedule->showSchedule("html", true); ?> </td> </tr> </table> <? } }
function delete() { $db = DBManager::get(); // LOGGING if ($this->assign_user_id) { $type = $this->getOwnerType(); if ($type == 'date') { $semid = Seminar::GetSemIdByDateId($this->assign_user_id); } else { if ($type == 'sem') { $semid = $this->assign_user_id; } else { $semid = null; error_log("unknown type of assign_user_id {$this->assign_user_id}"); } } log_event("RES_ASSIGN_DEL_SEM", $this->resource_id, $semid, $this->getFormattedShortInfo(), "", $GLOBALS['user']->id); } else { log_event("RES_ASSIGN_DEL_SINGLE", $this->resource_id, NULL, $this->getFormattedShortInfo(), NULL, $GLOBALS['user']->id); } // delete entries from resources_temporary_events to keep it consistent $query = sprintf("DELETE FROM resources_temporary_events WHERE assign_id='%s'", $this->id); $db->query($query); // delete entry from resources_assign $query = sprintf("DELETE FROM resources_assign WHERE assign_id='%s'", $this->id); if ($db->exec($query)) { return TRUE; } return FALSE; }