ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjSessionGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once('./Services/Object/classes/class.ilObjectGUI.php');
5include_once('./Modules/Session/classes/class.ilObjSession.php');
6include_once('./Modules/Session/classes/class.ilSessionFile.php');
7include_once './Services/PersonalDesktop/interfaces/interface.ilDesktopItemHandling.php';
8
21{
25 protected $logger = null;
26
27
28 public $lng;
29 public $ctrl;
30 public $tpl;
31
32 protected $container_ref_id = 0;
33 protected $container_obj_id = 0;
34
35 protected $files = array();
36
44 public function __construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output = true)
45 {
46 global $ilCtrl, $lng, $tpl;
47
48 $this->type = "sess";
49 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
50
51 $this->lng = $lng;
52 $this->lng->loadLanguageModule("event");
53 $this->lng->loadLanguageModule('crs');
54 $this->lng->loadLanguageModule('trac');
55 $this->lng->loadLanguageModule('sess');
56
57
58 $this->tpl = $tpl;
59 $this->ctrl = $ilCtrl;
60
61 $this->logger = $GLOBALS['DIC']->logger()->sess();
62 }
63
64
71 public function executeCommand()
72 {
73 global $ilUser,$ilCtrl;
74
75 $next_class = $this->ctrl->getNextClass($this);
76 $cmd = $this->ctrl->getCmd();
77
78 if (
79 !$this->getCreationMode() &&
80 $GLOBALS['DIC']->access()->checkAccess('read', '', $_GET['ref_id'])
81 ) {
82 $GLOBALS['DIC']['ilNavigationHistory']->addItem(
83 (int) $_GET['ref_id'],
84 ilLink::_getLink((int) $_GET['ref_id'], 'sess'),
85 'sess'
86 );
87 }
88
89 $this->prepareOutput();
90 switch ($next_class) {
91 case 'ilsessionmembershipgui':
92 $this->tabs_gui->activateTab('members');
93 include_once './Modules/Session/classes/class.ilSessionMembershipGUI.php';
94 $mem_gui = new ilSessionMembershipGUI($this, $this->object);
95 $this->ctrl->forwardCommand($mem_gui);
96 break;
97
98 case "ilinfoscreengui":
99 $this->checkPermission("visible");
100 $this->infoScreen(); // forwards command
101 break;
102
103 case 'ilobjectmetadatagui':
104 $this->checkPermission('write');
105 $this->tabs_gui->setTabActive('meta_data');
106 $md_gui = new ilObjectMetaDataGUI($this->object);
107 $this->ctrl->forwardCommand($md_gui);
108 break;
109
110
111 case 'ilpermissiongui':
112 $this->tabs_gui->setTabActive('perm_settings');
113 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
114 $perm_gui = new ilPermissionGUI($this);
115 $ret = $this->ctrl->forwardCommand($perm_gui);
116 break;
117
118 case 'ilobjectcopygui':
119 include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
120 $cp = new ilObjectCopyGUI($this);
121 $cp->setType('sess');
122 $this->ctrl->forwardCommand($cp);
123 break;
124
125 case "ilexportgui":
126// $this->prepareOutput();
127 $this->tabs_gui->setTabActive("export");
128 include_once("./Services/Export/classes/class.ilExportGUI.php");
129 $exp_gui = new ilExportGUI($this);
130 $exp_gui->addFormat("xml");
131 $ret = $this->ctrl->forwardCommand($exp_gui);
132// $this->tpl->show();
133 break;
134
135 case "ilcommonactiondispatchergui":
136 include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
138 $this->ctrl->forwardCommand($gui);
139 break;
140
141 case 'ilmembershipgui':
142 $this->ctrl->setReturn($this, 'members');
143 include_once './Services/Membership/classes/class.ilMembershipMailGUI.php';
144 $mem = new ilMembershipMailGUI($this);
145 $this->ctrl->forwardCommand($mem);
146 break;
147
148 case "illearningprogressgui":
149 include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
150 $new_gui = new ilLearningProgressGUI(
152 $this->object->getRefId(),
153 $_GET['user_id'] ? $_GET['user_id'] : $ilUser->getId()
154 );
155 $this->ctrl->forwardCommand($new_gui);
156 $this->tabs_gui->setTabActive('learning_progress');
157 break;
158
159 default:
160 if (!$cmd) {
161 $cmd = "infoScreen";
162 }
163 $cmd .= "Object";
164 $this->$cmd();
165
166 break;
167 }
168
169 $this->addHeaderAction();
170
171 return true;
172 }
173
174
178 protected function membersObject()
179 {
180 $this->ctrl->redirectByClass('ilSessionMembershipGUI', 'participants');
181 }
182
187 public function getCurrentObject()
188 {
189 return $this->object;
190 }
191
195 public function prepareOutput($a_show_subobjects = true)
196 {
197 parent::prepareOutput($a_show_subobjects);
198
199 if (!$this->getCreationMode()) {
200 $title = strlen($this->object->getTitle()) ? (': ' . $this->object->getTitle()) : '';
201
202 include_once './Modules/Session/classes/class.ilSessionAppointment.php';
203 $this->tpl->setTitle(
204 $this->object->getFirstAppointment()->appointmentToString() . $title
205 );
206 }
207 }
208
216 public function registerObject()
217 {
218 global $ilUser;
219
220 $this->checkPermission('visible');
221
222 include_once './Services/Membership/classes/class.ilParticipants.php';
223 $part = ilParticipants::getInstance($this->getCurrentObject()->getRefId());
224
225 include_once './Modules/Session/classes/class.ilEventParticipants.php';
226 $event_part = new ilEventParticipants($this->getCurrentObject()->getId());
227 if (
228 $this->getCurrentObject()->isRegistrationUserLimitEnabled() and
229 $this->getCurrentObject()->getRegistrationMaxUsers() and
230 (count($event_part->getRegistered()) >= $this->getCurrentObject()->getRegistrationMaxUsers())
231 ) {
232 include_once './Modules/Session/classes/class.ilSessionWaitingList.php';
233 $wait = new ilSessionWaitingList($this->getCurrentObject()->getId());
234 $wait->addToList($ilUser->getId());
235 ilUtil::sendInfo($this->lng->txt('sess_reg_added_to_wl'), true);
236 $this->ctrl->redirect($this, 'infoScreen');
237 return true;
238 }
239
240
241 switch ($this->getCurrentObject()->getRegistrationType()) {
243 $this->ctrl->redirect($this, 'info');
244 break;
245
247 $part->register($ilUser->getId());
248 ilUtil::sendSuccess($this->lng->txt('event_registered'), true);
249 $this->ctrl->redirect($this, 'infoScreen');
250 break;
251
253 ilUtil::sendSuccess($this->lng->txt('sess_registered_confirm'), true);
254 $part->addSubscriber($ilUser->getId());
255 $this->ctrl->redirect($this, 'infoScreen');
256 break;
257 }
258 }
259
264 public function joinObject()
265 {
266 global $ilUser;
267
268 $this->checkPermission('read');
269
270 if ($ilUser->isAnonymous()) {
271 $this->ctrl->redirect($this, 'infoScreen');
272 }
273
274 include_once './Modules/Session/classes/class.ilEventParticipants.php';
275
276 if (ilEventParticipants::_isRegistered($ilUser->getId(), $this->object->getId())) {
277 $_SESSION['sess_hide_info'] = true;
278 ilEventParticipants::_unregister($ilUser->getId(), $this->object->getId());
279 ilUtil::sendSuccess($this->lng->txt('event_unregistered'), true);
280 } else {
281 ilEventParticipants::_register($ilUser->getId(), $this->object->getId());
282 ilUtil::sendSuccess($this->lng->txt('event_registered'), true);
283 }
284
285 $this->ctrl->redirect($this, 'infoScreen');
286 }
287
294 public function unregisterObject()
295 {
296 global $ilUser;
297
298 include_once './Modules/Session/classes/class.ilSessionParticipants.php';
299 $part = ilSessionParticipants::getInstance($this->object->getRefId());
300 if ($part->isSubscriber($ilUser->getId())) {
301 $part->deleteSubscriber($ilUser->getId());
302 }
303
304 $part->unregister($ilUser->getId());
305
306 include_once './Modules/Session/classes/class.ilSessionWaitingList.php';
307 ilSessionWaitingList::deleteUserEntry($ilUser->getId(), $this->getCurrentObject()->getId());
308
309 // check for visible permission of user
311 $GLOBALS['DIC']->access()->clear();
312 $has_access = $GLOBALS['DIC']->access()->checkAccessOfUser(
313 $GLOBALS['DIC']->user()->getId(),
314 'visible',
315 '',
316 $this->object->getRefId()
317 );
318 if (!$has_access) {
319 $parent = $GLOBALS['DIC']->repositoryTree()->getParentId($this->object->getRefId());
320 $this->redirectToRefId($parent);
321 return;
322 }
323
324 ilUtil::sendSuccess($this->lng->txt('event_unregistered'), true);
325 $this->ctrl->returnToParent($this);
326 }
327
336 public static function _goto($a_target)
337 {
338 global $DIC;
339
340 $ilAccess = $DIC->access();
341 $ilErr = $DIC["ilErr"];
342 $lng = $DIC->language();
343
344 if ($ilAccess->checkAccess('visible', "", $a_target)) {
345 ilObjectGUI::_gotoRepositoryNode($a_target, "infoScreen");
346 } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
348 sprintf(
349 $lng->txt("msg_no_perm_read_item"),
351 ),
352 true
353 );
355 }
356 }
357
361 public function addToDeskObject()
362 {
363 include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
365 $this->infoScreenObject();
366 }
367
371 public function removeFromDeskObject()
372 {
373 include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
375 $this->infoScreenObject();
376 }
377
378
384 public function infoScreenObject()
385 {
386 $this->ctrl->setCmd("showSummary");
387 $this->ctrl->setCmdClass("ilinfoscreengui");
388 $this->infoScreen();
389 }
390
398 public function modifyItemGUI($a_item_list_gui, $a_item_data, $a_show_path)
399 {
400 global $tree;
401
402 // if folder is in a course, modify item list gui according to course requirements
403 if ($course_ref_id = $tree->checkForParentType($this->object->getRefId(), 'crs')) {
404 // #10611
405 include_once "Services/Object/classes/class.ilObjectActivation.php";
406 ilObjectActivation::addListGUIActivationProperty($a_item_list_gui, $a_item_data);
407
408 include_once("./Modules/Course/classes/class.ilObjCourse.php");
409 include_once("./Modules/Course/classes/class.ilObjCourseGUI.php");
410 $course_obj_id = ilObject::_lookupObjId($course_ref_id);
412 $a_item_list_gui,
413 get_class($this),
414 $a_item_data,
415 $a_show_path,
416 ilObjCourse::_lookupAboStatus($course_obj_id),
417 $course_ref_id,
418 $course_obj_id,
419 $this->object->getRefId()
420 );
421 }
422 }
423
429 public function showJoinRequestButtonInCalendar(ilToolbarGUI $a_ilToolbar)
430 {
431 $this->showJoinRequestButton($a_ilToolbar);
432 }
433
438 protected function showJoinRequestButton(ilToolbarGUI $ilToolbar = null)
439 {
440 global $ilUser;
441
442 if (!$ilToolbar) {
443 global $ilToolbar;
444 }
445
446 if (!$this->getCurrentObject()->enabledRegistration() || $ilUser->isAnonymous()) {
447 return false;
448 }
449
450 include_once './Modules/Session/classes/class.ilSessionWaitingList.php';
451
452 include_once './Services/Membership/classes/class.ilParticipants.php';
453 $part = ilParticipants::getInstance($this->getCurrentObject()->getRefId());
454
455 include_once './Modules/Session/classes/class.ilEventParticipants.php';
456
457 $btn_attend = ilLinkButton::getInstance();
458 $btn_attend->addCSSClass("btn-primary");
459 $this->ctrl->setParameter($this, "ref_id", $this->getCurrentObject()->getRefId());
460
461 if (ilEventParticipants::_isRegistered($ilUser->getId(), $this->getCurrentObject()->getId())) {
462 $btn_attend->setCaption($this->lng->txt("event_unregister"), false);
463 $btn_attend->setUrl($this->ctrl->getLinkTargetByClass(array("ilRepositoryGUI", "ilObjSessionGUI"), "unregister"));
464 $ilToolbar->addButtonInstance($btn_attend);
465 return true;
466 } elseif ($part->isSubscriber($ilUser->getId())) {
467 $btn_attend->setCaption($this->lng->txt("event_unregister"), false);
468 $btn_attend->setUrl($this->ctrl->getLinkTargetByClass(array("ilRepositoryGUI", "ilObjSessionGUI"), "unregister"));
469 $ilToolbar->addButtonInstance($btn_attend);
470 return true;
471 } elseif (ilSessionWaitingList::_isOnList($ilUser->getId(), $this->getCurrentObject()->getId())) {
472 $btn_attend->setCaption($this->lng->txt("leave_waiting_list"), false);
473 $btn_attend->setUrl($this->ctrl->getLinkTargetByClass(array("ilRepositoryGUI", "ilObjSessionGUI"), "unregister"));
474 $ilToolbar->addButtonInstance($btn_attend);
475 return true;
476 }
477
478 $event_part = new ilEventParticipants($this->getCurrentObject()->getId());
479
480 if (
481 $this->getCurrentObject()->isRegistrationUserLimitEnabled() and
482 $this->getCurrentObject()->getRegistrationMaxUsers() and
483 (count($event_part->getRegistered()) >= $this->getCurrentObject()->getRegistrationMaxUsers())
484 ) {
485 if ($this->getCurrentObject()->isRegistrationWaitingListEnabled()) {
486 ilUtil::sendInfo($this->lng->txt('sess_reg_max_users_exceeded_wl'));
487 $btn_attend->setCaption($this->lng->txt("mem_add_to_wl"), false);
488 $btn_attend->setUrl($this->ctrl->getLinkTargetByClass(array("ilRepositoryGUI", "ilObjSessionGUI"), "register"));
489 $ilToolbar->addButtonInstance($btn_attend);
490 return true;
491 } else {
492 ilUtil::sendInfo($this->lng->txt('sess_reg_max_users_exceeded'));
493 return true;
494 }
495 } else {
496 if (!isset($_SESSION['sess_hide_info'])) {
497 ilUtil::sendInfo($this->lng->txt('sess_join_info'));
498 $btn_attend->setCaption($this->lng->txt("join_session"), false);
499 $btn_attend->setUrl($this->ctrl->getLinkTargetByClass(array("ilRepositoryGUI", "ilObjSessionGUI"), "register"));
500 $ilToolbar->addButtonInstance($btn_attend);
501 return true;
502 }
503 }
504 }
505
506
507
515 public function infoScreen()
516 {
517 global $ilAccess, $ilUser,$ilCtrl,$tree,$ilToolbar,$lng;
518
519 $this->checkPermission('visible');
520 $this->tabs_gui->setTabActive('info_short');
521
522 $this->showJoinRequestButton();
523
524 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
525 $info = new ilInfoScreenGUI($this);
526
527
528 $eventItems = ilObjectActivation::getItemsByEvent($this->object->getId());
529 $parent_id = $tree->getParentId($this->object->getRefId());
530 $parent_id = ilObject::_lookupObjId($parent_id);
531 $eventItems = ilContainerSorting::_getInstance($parent_id)->sortSubItems(
532 'sess',
533 $this->object->getId(),
534 $eventItems
535 );
536
537 $lng->loadLanguageModule("cntr");// #14158
538
539 $html = '';
540 foreach ($eventItems as $item) {
541 $list_gui = ilSessionObjectListGUIFactory::factory($item['type']);
542 $list_gui->setContainerObject($this);
543
544 $this->modifyItemGUI($list_gui, $item, false);
545
546 $html .= $list_gui->getListItemHTML(
547 $item['ref_id'],
548 $item['obj_id'],
549 $item['title'],
550 $item['description']
551 );
552 }
553
554 if (strlen($html)) {
555 $info->addSection($this->lng->txt('event_materials'));
556 $info->addProperty(
557 '&nbsp;',
558 $html
559 );
560 }
561
562
563
564 // Session information
565 if (strlen($this->object->getLocation()) or strlen($this->object->getDetails())) {
566 $info->addSection($this->lng->txt('event_section_information'));
567 }
568 if (strlen($location = $this->object->getLocation())) {
569 $info->addProperty(
570 $this->lng->txt('event_location'),
571 ilUtil::makeClickable(nl2br($this->object->getLocation()), true)
572 );
573 }
574 if (strlen($this->object->getDetails())) {
575 $info->addProperty(
576 $this->lng->txt('event_details_workflow'),
577 ilUtil::makeClickable(nl2br($this->object->getDetails()), true)
578 );
579 }
580
581 $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_INFO, 'sess', $this->object->getId());
582 $record_gui->setInfoObject($info);
583 $record_gui->parse();
584
585 // meta data
586 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
587
588
589 // Tutor information
590 if ($this->object->hasTutorSettings()) {
591 $info->addSection($this->lng->txt('event_tutor_data'));
592 if (strlen($fullname = $this->object->getName())) {
593 $info->addProperty(
594 $this->lng->txt('event_lecturer'),
595 $fullname
596 );
597 }
598 if (strlen($email = $this->object->getEmail())) {
599 $info->addProperty(
600 $this->lng->txt('tutor_email'),
601 $email
602 );
603 }
604 if (strlen($phone = $this->object->getPhone())) {
605 $info->addProperty(
606 $this->lng->txt('tutor_phone'),
607 $phone
608 );
609 }
610 }
611 // forward the command
612 $this->ctrl->forwardCommand($info);
613
614 // store read event
615 require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
617 $this->object->getType(),
618 $this->object->getRefId(),
619 $this->object->getId(),
620 $ilUser->getId()
621 );
622 }
623
629 public function sendFileObject()
630 {
631 $file = new ilSessionFile((int) $_GET['file_id']);
632
633 ilUtil::deliverFile($file->getAbsolutePath(), $file->getFileName(), $file->getFileType());
634 return true;
635 }
636
637 protected function initCreateForm($a_new_type)
638 {
639 if (!is_object($this->object)) {
640 $this->object = new ilObjSession();
641 }
642 $this->initForm('create');
643 return $this->form;
644 }
645
652 {
653 global $ilLog;
654
655 $this->saveObject(false);
656
657 $this->ctrl->setParameter($this, 'ref_id', $this->object->getRefId());
658 $this->ctrl->setParameter($this, 'new_type', '');
659 $this->ctrl->redirect($this, 'materials');
660 }
661
669 public function saveObject($a_redirect_on_success = true)
670 {
671 global $ilErr,$ilUser;
672
673 $this->object = new ilObjSession();
674
675 $this->ctrl->saveParameter($this, "new_type");
676
677 $this->initForm('create');
678 $ilErr->setMessage('');
679 if (!$this->form->checkInput()) {
680 $ilErr->setMessage($this->lng->txt('err_check_input'));
681 }
682
683 if (!$this->record_gui->importEditFormPostValues()) {
684 $ilErr->setMessage($this->lng->txt('err_check_input'));
685 }
686
687 $this->load();
688 $this->loadRecurrenceSettings();
689
690 $this->object->validate();
691 $this->object->getFirstAppointment()->validate();
692
693 if (strlen($ilErr->getMessage())) {
694 ilUtil::sendFailure($ilErr->getMessage());
695 $this->form->setValuesByPost();
696 $this->createObject();
697 return false;
698 }
699 // Create session
700 $this->object->create();
701 $this->object->createReference();
702 $this->object->putInTree($_GET["ref_id"]);
703 $this->object->setPermissions($_GET["ref_id"]);
704
706 $this->object->getId(),
707 $this->form,
708 array(
710 )
711 );
712 $this->record_gui->writeEditForm($this->object->getId());
713
714
715 // apply didactic template?
716 $dtpl = $this->getDidacticTemplateVar("dtpl");
717 if ($dtpl) {
718 $this->object->applyDidacticTemplate($dtpl);
719 }
720
721 // #14547 - active is default
722 if (!$this->form->getInput("lp_preset")) {
723 include_once "Services/Tracking/classes/class.ilLPObjSettings.php";
724 $lp_obj_settings = new ilLPObjSettings($this->object->getId());
725 $lp_obj_settings->setMode(ilLPObjSettings::LP_MODE_DEACTIVATED);
726 $lp_obj_settings->update(false);
727 }
728
729 // create appointment
730 $this->object->getFirstAppointment()->setSessionId($this->object->getId());
731 $this->object->getFirstAppointment()->create();
732
733 $this->handleFileUpload();
734
735 $this->createRecurringSessions($this->form->getInput("lp_preset"));
736
737 if ($a_redirect_on_success) {
738 ilUtil::sendInfo($this->lng->txt('event_add_new_event'), true);
739 $this->ctrl->returnToParent($this);
740 }
741
742 return true;
743 }
744
745 public function handleFileUpload()
746 {
747 global $tree;
748
749 include_once './Modules/Session/classes/class.ilEventItems.php';
750 $ev = new ilEventItems($this->object->getId());
751 $items = $ev->getItems();
752
753 $counter = 0;
754 while (true) {
755 if (!isset($_FILES['files']['name'][$counter])) {
756 break;
757 }
758 if (!strlen($_FILES['files']['name'][$counter])) {
759 $counter++;
760 continue;
761 }
762
763 include_once './Modules/File/classes/class.ilObjFile.php';
764 $file = new ilObjFile();
765 $file->setTitle(ilUtil::stripSlashes($_FILES['files']['name'][$counter]));
766 $file->setDescription('');
767 $file->setFileName(ilUtil::stripSlashes($_FILES['files']['name'][$counter]));
768 $file->setFileType($_FILES['files']['type'][$counter]);
769 $file->setFileSize($_FILES['files']['size'][$counter]);
770 $file->create();
771 $new_ref_id = $file->createReference();
772 $file->putInTree($tree->getParentId($this->object->getRefId()));
773 $file->setPermissions($tree->getParentId($this->object->getRefId()));
774 $file->createDirectory();
775 $file->getUploadFile(
776 $_FILES['files']['tmp_name'][$counter],
777 $_FILES['files']['name'][$counter]
778 );
779
780 $items[] = $new_ref_id;
781 $counter++;
782 }
783
784 $ev->setItems($items);
785 $ev->update();
786 }
787
788
789
797 protected function createRecurringSessions($a_activate_lp = true)
798 {
799 global $tree;
800
801 if (!$this->rec->getFrequenceType()) {
802 return true;
803 }
804 include_once('./Services/Calendar/classes/class.ilCalendarRecurrenceCalculator.php');
805 $calc = new ilCalendarRecurrenceCalculator($this->object->getFirstAppointment(), $this->rec);
806
807 $period_start = clone $this->object->getFirstAppointment()->getStart();
808
809
810 $period_end = clone $this->object->getFirstAppointment()->getStart();
811 $period_end->increment(IL_CAL_YEAR, 5);
812 $date_list = $calc->calculateDateList($period_start, $period_end);
813
814 $period_diff = $this->object->getFirstAppointment()->getEnd()->get(IL_CAL_UNIX) -
815 $this->object->getFirstAppointment()->getStart()->get(IL_CAL_UNIX);
816 $parent_id = $tree->getParentId($this->object->getRefId());
817
818 include_once './Modules/Session/classes/class.ilEventItems.php';
819 $evi = new ilEventItems($this->object->getId());
820 $eitems = $evi->getItems();
821
822 $counter = 0;
823 foreach ($date_list->get() as $date) {
824 if (!$counter++) {
825 continue;
826 }
827
828 $new_obj = $this->object->cloneObject($parent_id);
829
830 // apply didactic template?
831 $dtpl = $this->getDidacticTemplateVar("dtpl");
832 if ($dtpl) {
833 $new_obj->applyDidacticTemplate($dtpl);
834 }
835
836 $new_obj->read();
837 $new_obj->getFirstAppointment()->setStartingTime($date->get(IL_CAL_UNIX));
838 $new_obj->getFirstAppointment()->setEndingTime($date->get(IL_CAL_UNIX) + $period_diff);
839 $new_obj->getFirstAppointment()->update();
840 $new_obj->update(true);
841
842 // #14547 - active is default
843 if (!$a_activate_lp) {
844 include_once "Services/Tracking/classes/class.ilLPObjSettings.php";
845 $lp_obj_settings = new ilLPObjSettings($new_obj->getId());
846 $lp_obj_settings->setMode(ilLPObjSettings::LP_MODE_DEACTIVATED);
847 $lp_obj_settings->update(false);
848 }
849
850 $new_evi = new ilEventItems($new_obj->getId());
851 $new_evi->setItems($eitems);
852 $new_evi->update();
853 }
854 }
855
856
864 public function editObject()
865 {
866 $this->tabs_gui->setTabActive('settings');
867
868 $this->initForm('edit');
869 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.sess_edit.html', 'Modules/Session');
870 $this->tpl->setVariable('EVENT_EDIT_TABLE', $this->form->getHTML());
871
872 if (!count($this->object->getFiles())) {
873 return true;
874 }
875 $rows = array();
876 foreach ($this->object->getFiles() as $file) {
877 $table_data['id'] = $file->getFileId();
878 $table_data['filename'] = $file->getFileName();
879 $table_data['filetype'] = $file->getFileType();
880 $table_data['filesize'] = $file->getFileSize();
881
882 $rows[] = $table_data;
883 }
884
885 include_once("./Modules/Session/classes/class.ilSessionFileTableGUI.php");
886 $table_gui = new ilSessionFileTableGUI($this, "edit");
887 $table_gui->setTitle($this->lng->txt("event_files"));
888 $table_gui->setData($rows);
889 $table_gui->addCommandButton("cancel", $this->lng->txt("cancel"));
890 $table_gui->addMultiCommand("confirmDeleteFiles", $this->lng->txt("delete"));
891 $table_gui->setSelectAllCheckbox("file_id");
892 $this->tpl->setVariable('EVENT_FILE_TABLE', $table_gui->getHTML());
893
894 return true;
895 }
896
904 public function updateObject()
905 {
906 global $ilErr;
907
908 $old_autofill = $this->object->hasWaitingListAutoFill();
909
910 $this->initForm('edit');
911 $ilErr->setMessage('');
912 if (!$this->form->checkInput()) {
913 $ilErr->setMessage($this->lng->txt('err_check_input'));
914 }
915
916 if (!$this->record_gui->importEditFormPostValues()) {
917 $ilErr->setMessage($this->lng->txt('err_check_input'));
918 }
919
920
921 $this->load();
922
923 $this->object->validate();
924 $this->object->getFirstAppointment()->validate();
925
926 if (strlen($ilErr->getMessage())) {
927 ilUtil::sendFailure($ilErr->getMessage());
928 $this->editObject();
929 return false;
930 }
931 // Update event
932 $this->object->update();
933 $this->object->getFirstAppointment()->update();
934
936 $this->object->getId(),
937 $this->form,
938 array(
940 )
941 );
942 $this->record_gui->writeEditForm();
943 $this->handleFileUpload();
944
945 // if autofill has been activated trigger process
946 if (!$old_autofill &&
947 $this->object->hasWaitingListAutoFill()) {
948 $this->object->handleAutoFill();
949 }
950
951 ilUtil::sendSuccess($this->lng->txt('event_updated'), true);
952 $this->ctrl->redirect($this, 'edit');
953 #$this->object->initFiles();
954 #$this->editObject();
955 return true;
956 }
957
965 public function confirmDeleteFilesObject()
966 {
967 $this->tabs_gui->setTabActive('settings');
968
969 if (!count($_POST['file_id'])) {
970 ilUtil::sendFailure($this->lng->txt('select_one'));
971 $this->editObject();
972 return false;
973 }
974
975 include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
976 $c_gui = new ilConfirmationGUI();
977
978 // set confirm/cancel commands
979 $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteFiles"));
980 $c_gui->setHeaderText($this->lng->txt("info_delete_sure"));
981 $c_gui->setCancel($this->lng->txt("cancel"), "edit");
982 $c_gui->setConfirm($this->lng->txt("confirm"), "deleteFiles");
983
984 // add items to delete
985 foreach ($_POST["file_id"] as $file_id) {
986 $file = new ilSessionFile($file_id);
987 if ($file->getSessionId() != $this->object->getEventId()) {
988 ilUtil::sendFailure($this->lng->txt('select_one'));
989 $this->edit();
990 return false;
991 }
992 $c_gui->addItem("file_id[]", $file_id, $file->getFileName());
993 }
994
995 $this->tpl->setContent($c_gui->getHTML());
996 return true;
997 }
998
1006 public function deleteFilesObject()
1007 {
1008 if (!count($_POST['file_id'])) {
1009 ilUtil::sendFailure($this->lng->txt('select_one'));
1010 $this->editObject();
1011 return false;
1012 }
1013 foreach ($_POST['file_id'] as $id) {
1014 $file = new ilSessionFile($id);
1015 $file->delete();
1016 }
1017 $this->object->initFiles();
1018 $this->editObject();
1019 return true;
1020 }
1021
1022 protected function initContainer($a_init_participants = false)
1023 {
1024 global $tree;
1025
1026 $is_course = $is_group = false;
1027
1028 // #13178
1029 $this->container_ref_id = $tree->checkForParentType($this->object->getRefId(), 'grp');
1030 if ($this->container_ref_id) {
1031 $is_group = true;
1032 }
1033 if (!$this->container_ref_id) {
1034 $this->container_ref_id = $tree->checkForParentType($this->object->getRefId(), 'crs');
1035 if ($this->container_ref_id) {
1036 $is_course = true;
1037 }
1038 }
1039 if (!$this->container_ref_id) {
1040 ilUtil::sendFailure('No container object found. Aborting');
1041 return true;
1042 }
1043 $this->container_obj_id = ilObject::_lookupObjId($this->container_ref_id);
1044
1045 if ($a_init_participants && $this->container_obj_id) {
1046 if ($is_course) {
1047 include_once './Modules/Course/classes/class.ilCourseParticipants.php';
1048 return ilCourseParticipants::_getInstanceByObjId($this->container_obj_id);
1049 } elseif ($is_group) {
1050 include_once './Modules/Group/classes/class.ilGroupParticipants.php';
1051 return ilGroupParticipants::_getInstanceByObjId($this->container_obj_id);
1052 }
1053 }
1054 }
1055
1063 public function materialsObject()
1064 {
1065 global $tree, $objDefinition;
1066
1067 $this->tabs_gui->setTabActive('crs_materials');
1068
1069 // #11337 - support ANY parent container (crs, grp, fld)
1070 $parent_ref_id = $tree->getParentId($this->object->getRefId());
1071
1072 include_once "Services/Object/classes/class.ilObjectAddNewItemGUI.php";
1073 $gui = new ilObjectAddNewItemGUI($parent_ref_id);
1074 $gui->setDisabledObjectTypes(array("itgr", "sess"));
1075 $gui->setAfterCreationCallback($this->ref_id);
1076 $gui->render();
1077
1078 include_once 'Modules/Session/classes/class.ilEventItems.php';
1079 $this->event_items = new ilEventItems($this->object->getId());
1080
1081 include_once 'Modules/Session/classes/class.ilSessionMaterialsTableGUI.php';
1082 $tbl = new ilSessionMaterialsTableGUI($this, "materials");
1083 $tbl->setTitle($this->lng->txt("event_assign_materials_table"));
1084 $tbl->setDescription($this->lng->txt('event_assign_materials_info'));
1085
1086 $tbl->setMaterialItems($this->event_items->getItems());
1087 $tbl->setContainerRefId($this->getContainerRefId());
1088 $tbl->getDataFromDb();
1089
1090 $this->tpl->setContent($tbl->getHTML());
1091 }
1092
1100 public function saveMaterialsObject()
1101 {
1102 include_once './Modules/Session/classes/class.ilEventItems.php';
1103
1104 $this->event_items = new ilEventItems($this->object->getId());
1105
1106 $list_items = is_array($_POST['all_items']) ? $_POST['all_items'] : array();
1107 $list_items_checked = is_array($_POST['items']) ? $_POST['items'] : array();
1108
1109 $checked = $this->event_items->getItems();
1110 $checked = array_diff($checked, $list_items);//remove all visible items in list
1111 $checked = array_merge($checked, $list_items_checked);//add checked items in list
1112
1113 $this->event_items->setItems($checked);
1114 $this->event_items->update();
1115
1116 include_once 'Modules/Session/classes/class.ilSessionMaterialsTableGUI.php';
1117 $tbl = new ilSessionMaterialsTableGUI($this, "materials");
1118 $tbl->setOffset(0);
1119 $tbl->storeNavParameter();//remove offset and go to page 1
1120
1121 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
1122 $this->ctrl->redirect($this, 'materials');
1123 }
1124
1125
1126
1133 public function attendanceListObject()
1134 {
1135 global $tpl,$ilTabs;
1136
1137 $this->checkPermission('write');
1138 $ilTabs->setTabActive('event_edit_members');
1139
1140 $list = $this->initAttendanceList();
1141 $form = $list->initForm('printAttendanceList');
1142 $tpl->setContent($form->getHTML());
1143 }
1144
1150 protected function initAttendanceList()
1151 {
1152 $members_obj = $this->initContainer(true);
1153
1154 include_once 'Services/Membership/classes/class.ilAttendanceList.php';
1155 $list = new ilAttendanceList(
1156 $this,
1157 $this->object,
1158 $members_obj
1159 );
1160 $list->setId('sessattlst');
1161
1162 $event_app = $this->object->getFirstAppointment();
1164 $desc = ilDatePresentation::formatPeriod($event_app->getStart(), $event_app->getEnd());
1166 $desc .= " " . $this->object->getTitle();
1167 $list->setTitle($this->lng->txt('sess_attendance_list'), $desc);
1168
1169 $list->addPreset('mark', $this->lng->txt('trac_mark'), true);
1170 $list->addPreset('comment', $this->lng->txt('trac_comment'), true);
1171 if ($this->object->enabledRegistration()) {
1172 $list->addPreset('registered', $this->lng->txt('event_tbl_registered'), true);
1173 }
1174 $list->addPreset('participated', $this->lng->txt('event_tbl_participated'), true);
1175 $list->addBlank($this->lng->txt('sess_signature'));
1176
1177 $list->addUserFilter('registered', $this->lng->txt('event_list_registered_only'));
1178
1179 return $list;
1180 }
1181
1187 protected function printAttendanceListObject()
1188 {
1189 $this->checkPermission('write');
1190
1191 $list = $this->initAttendanceList();
1192 $list->initFromForm();
1193 $list->setCallback(array($this, 'getAttendanceListUserData'));
1194
1195 include_once 'Modules/Session/classes/class.ilEventParticipants.php';
1196 $this->event_part = new ilEventParticipants($this->object->getId());
1197
1198 echo $list->getFullscreenHTML();
1199 exit();
1200 }
1201
1211 public function getAttendanceListUserData($a_user_id, $a_filters)
1212 {
1213 $data = $this->event_part->getUser($a_user_id);
1214
1215 if ($a_filters && $a_filters["registered"] && !$data["registered"]) {
1216 return;
1217 }
1218
1219 $data['registered'] = $data['registered'] ?
1220 $this->lng->txt('yes') :
1221 $this->lng->txt('no');
1222 $data['participated'] = $data['participated'] ?
1223 $this->lng->txt('yes') :
1224 $this->lng->txt('no');
1225
1226 return $data;
1227 }
1228
1236 public function eventsListObject()
1237 {
1238 global $ilErr,$ilAccess, $ilUser,$tree;
1239
1240 if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
1241 $ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $ilErr->MESSAGE);
1242 }
1243
1244 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.sess_list.html', 'Modules/Session');
1245 $this->__showButton($this->ctrl->getLinkTarget($this, 'exportCSV'), $this->lng->txt('event_csv_export'));
1246
1247 include_once 'Modules/Session/classes/class.ilEventParticipants.php';
1248
1249 $this->tpl->addBlockfile("EVENTS_TABLE", "events_table", "tpl.table.html");
1250 $this->tpl->addBlockfile('TBL_CONTENT', 'tbl_content', 'tpl.sess_list_row.html', 'Modules/Session');
1251
1252 $members_obj = $this->initContainer(true);
1253 $members = $members_obj->getParticipants();
1254 $members = ilUtil::_sortIds($members, 'usr_data', 'lastname', 'usr_id');
1255
1256 // Table
1257 $tbl = new ilTableGUI();
1258 $tbl->setTitle(
1259 $this->lng->txt("event_overview"),
1260 'icon_usr.svg',
1261 $this->lng->txt('obj_usr')
1262 );
1263 $this->ctrl->setParameter($this, 'offset', (int) $_GET['offset']);
1264
1265 $course_ref_id = $tree->checkForParentType($this->object->getRefId(), 'crs');
1266 $events = array();
1267 foreach ($tree->getSubtree($tree->getNodeData($course_ref_id), false, 'sess') as $event_id) {
1268 $tmp_event = ilObjectFactory::getInstanceByRefId($event_id, false);
1269 if (!is_object($tmp_event) or $tmp_event->getType() != 'sess') {
1270 continue;
1271 }
1272 $events[] = $tmp_event;
1273 }
1274
1275 $headerNames = array();
1276 $headerVars = array();
1277 $colWidth = array();
1278
1279 $headerNames[] = $this->lng->txt('name');
1280 $headerVars[] = "name";
1281 $colWidth[] = '20%';
1282
1283 for ($i = 1; $i <= count($events); $i++) {
1284 $headerNames[] = $i;
1285 $headerVars[] = "event_" . $i;
1286 $colWidth[] = 80/count($events) . "%";
1287 }
1288
1289 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1290 $tbl->setHeaderNames($headerNames);
1291 $tbl->setHeaderVars($headerVars, $this->ctrl->getParameterArray($this, 'eventsList'));
1292 $tbl->setColumnWidth($colWidth);
1293
1294 $tbl->setOrderColumn($_GET["sort_by"]);
1295 $tbl->setOrderDirection($_GET["sort_order"]);
1296 $tbl->setOffset($_GET["offset"]);
1297 $tbl->setLimit($ilUser->getPref("hits_per_page"));
1298 $tbl->setMaxCount(count($members));
1299 $tbl->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
1300
1301 $sliced_users = array_slice($members, $_GET['offset'], $_SESSION['tbl_limit']);
1302 $tbl->disable('sort');
1303 $tbl->render();
1304
1305 $counter = 0;
1306 foreach ($sliced_users as $user_id) {
1307 foreach ($events as $event_obj) {
1308 $this->tpl->setCurrentBlock("eventcols");
1309
1310 $event_part = new ilEventParticipants($this->object->getId());
1311
1312 {
1313 $this->tpl->setVariable("IMAGE_PARTICIPATED", $event_part->hasParticipated($user_id) ?
1314 ilUtil::getImagePath('icon_ok.svg') :
1315 ilUtil::getImagePath('icon_not_ok.svg'));
1316
1317 $this->tpl->setVariable("PARTICIPATED", $event_part->hasParticipated($user_id) ?
1318 $this->lng->txt('event_participated') :
1319 $this->lng->txt('event_not_participated'));
1320 }
1321
1322 $this->tpl->parseCurrentBlock();
1323 }
1324
1325 $this->tpl->setCurrentBlock("tbl_content");
1326 $name = ilObjUser::_lookupName($user_id);
1327 $this->tpl->setVariable("CSS_ROW", ilUtil::switchColor($counter++, 'tblrow1', 'tblrow2'));
1328 $this->tpl->setVariable("LASTNAME", $name['lastname']);
1329 $this->tpl->setVariable("FIRSTNAME", $name['firstname']);
1330 $this->tpl->setVariable("LOGIN", ilObjUser::_lookupLogin($user_id));
1331 $this->tpl->parseCurrentBlock();
1332 }
1333
1334 $this->tpl->setVariable("HEAD_TXT_LEGEND", $this->lng->txt("legend"));
1335 $this->tpl->setVariable("HEAD_TXT_DIGIT", $this->lng->txt("event_digit"));
1336 $this->tpl->setVariable("HEAD_TXT_EVENT", $this->lng->txt("event"));
1337 $this->tpl->setVariable("HEAD_TXT_LOCATION", $this->lng->txt("event_location"));
1338 $this->tpl->setVariable("HEAD_TXT_DATE_TIME", $this->lng->txt("event_date_time"));
1339 $i = 1;
1340 foreach ($events as $event_obj) {
1341 $this->tpl->setCurrentBlock("legend_loop");
1342 $this->tpl->setVariable("LEGEND_CSS_ROW", ilUtil::switchColor($counter++, 'tblrow1', 'tblrow2'));
1343 $this->tpl->setVariable("LEGEND_DIGIT", $i++);
1344 $this->tpl->setVariable("LEGEND_EVENT_TITLE", $event_obj->getTitle());
1345 $this->tpl->setVariable("LEGEND_EVENT_DESCRIPTION", $event_obj->getDescription());
1346 $this->tpl->setVariable("LEGEND_EVENT_LOCATION", $event_obj->getLocation());
1347 $this->tpl->setVariable("LEGEND_EVENT_APPOINTMENT", $event_obj->getFirstAppointment()->appointmentToString());
1348 $this->tpl->parseCurrentBlock();
1349 }
1350 }
1351
1357 protected function initForm($a_mode)
1358 {
1359 global $ilUser;
1360
1361 if (is_object($this->form)) {
1362 return true;
1363 }
1364
1365 $this->lng->loadLanguageModule('dateplaner');
1366
1367 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1368
1369 include_once('./Services/YUI/classes/class.ilYuiUtil.php');
1371
1372 $this->form = new ilPropertyFormGUI();
1373 $this->form->setMultipart(true);
1374 $this->form->setTableWidth('600px');
1375 $this->form->setFormAction($this->ctrl->getFormAction($this));
1376 $this->form->setMultipart(true);
1377
1378 if ($a_mode == 'create') {
1379 $this->form = $this->initDidacticTemplate($this->form);
1380 }
1381
1382 $this->lng->loadLanguageModule('dateplaner');
1383 include_once './Services/Form/classes/class.ilDateDurationInputGUI.php';
1384 $dur = new ilDateDurationInputGUI($this->lng->txt('cal_fullday'), 'event');
1385 $dur->setRequired(true);
1386 $dur->enableToggleFullTime(
1387 $this->lng->txt('event_fulltime_info'),
1388 $this->object->getFirstAppointment()->enabledFulltime() ? true : false
1389 );
1390 $dur->setShowTime(true);
1391 $dur->setStart($this->object->getFirstAppointment()->getStart());
1392 $dur->setEnd($this->object->getFirstAppointment()->getEnd());
1393
1394 $this->form->addItem($dur);
1395
1396 /*
1397 // start
1398 $start = new ilDateTimeInputGUI($this->lng->txt('event_start_date'),'start');
1399 $start->setMinuteStepSize(5);
1400 $start->setDate($this->object->getFirstAppointment()->getStart());
1401 $start->setShowTime(true);
1402 #$this->form->addItem($start);
1403
1404 // end
1405 $end = new ilDateTimeInputGUI($this->lng->txt('event_end_date'),'end');
1406 $end->setMinuteStepSize(5);
1407 $end->setDate($this->object->getFirstAppointment()->getEnd());
1408 $end->setShowTime(true);
1409 #$this->form->addItem($end);
1410 */
1411
1412 // Recurrence
1413 if ($a_mode == 'create') {
1414 if (!is_object($this->rec)) {
1415 include_once('./Modules/Session/classes/class.ilEventRecurrence.php');
1416 $this->rec = new ilEventRecurrence();
1417 }
1418 include_once('./Services/Calendar/classes/Form/class.ilRecurrenceInputGUI.php');
1419 $rec = new ilRecurrenceInputGUI($this->lng->txt('cal_recurrences'), 'frequence');
1420 $rec->allowUnlimitedRecurrences(false);
1421 $rec->setRecurrence($this->rec);
1422 $this->form->addItem($rec);
1423
1424 // #14547
1425 $lp = new ilCheckboxInputGUI($this->lng->txt("sess_lp_preset"), "lp_preset");
1426 $lp->setInfo($this->lng->txt("sess_lp_preset_info"));
1427 $lp->setChecked(true);
1428 $this->form->addItem($lp);
1429 }
1430
1432 $section->setTitle($this->lng->txt('event_section_information'));
1433 $this->form->addItem($section);
1434
1435 // title
1436 $title = new ilTextInputGUI($this->lng->txt('event_title'), 'title');
1437 $title->setValue($this->object->getTitle());
1438 $title->setSize(50);
1439 $title->setMaxLength(70);
1440 $this->form->addItem($title);
1441
1442 // desc
1443 $desc = new ilTextAreaInputGUI($this->lng->txt('event_desc'), 'desc');
1444 $desc->setValue($this->object->getLongDescription());
1445 $desc->setRows(4);
1446 $desc->setCols(50);
1447 $this->form->addItem($desc);
1448
1449 // location
1450 $desc = new ilTextAreaInputGUI($this->lng->txt('event_location'), 'location');
1451 $desc->setValue($this->object->getLocation());
1452 $desc->setRows(4);
1453 $desc->setCols(50);
1454 $this->form->addItem($desc);
1455
1456 // workflow
1457 $details = new ilTextAreaInputGUI($this->lng->txt('event_details_workflow'), 'details');
1458 $details->setValue($this->object->getDetails());
1459 $details->setCols(50);
1460 $details->setRows(4);
1461 $this->form->addItem($details);
1462
1463 if ($a_mode == 'create') {
1464 $this->record_gui = new ilAdvancedMDRecordGUI(
1466 'sess'
1467 );
1468 $this->record_gui->setRefId((int) $_GET['ref_id']);
1469 } else {
1470 $this->record_gui = new ilAdvancedMDRecordGUI(
1472 'sess',
1473 $this->object->getId()
1474 );
1475 }
1476 $this->record_gui->setPropertyForm($this->form);
1477 $this->record_gui->parse();
1478
1479
1480 // section
1482 $section->setTitle($this->lng->txt('event_tutor_data'));
1483 $this->form->addItem($section);
1484
1485 // name
1486 $tutor_name = new ilTextInputGUI($this->lng->txt('tutor_name'), 'tutor_name');
1487 $tutor_name->setValue($this->object->getName());
1488 $tutor_name->setSize(20);
1489 $tutor_name->setMaxLength(70);
1490 $this->form->addItem($tutor_name);
1491
1492 // email
1493 $tutor_email = new ilTextInputGUI($this->lng->txt('tutor_email'), 'tutor_email');
1494 $tutor_email->setValue($this->object->getEmail());
1495 $tutor_email->setSize(20);
1496 $tutor_email->setMaxLength(70);
1497 $this->form->addItem($tutor_email);
1498
1499 // phone
1500 $tutor_phone = new ilTextInputGUI($this->lng->txt('tutor_phone'), 'tutor_phone');
1501 $tutor_phone->setValue($this->object->getPhone());
1502 $tutor_phone->setSize(20);
1503 $tutor_phone->setMaxLength(70);
1504 $this->form->addItem($tutor_phone);
1505
1507 $section->setTitle($this->lng->txt('sess_section_reg'));
1508 $this->form->addItem($section);
1509
1510 include_once './Modules/Session/classes/class.ilSessionMembershipRegistrationSettingsGUI.php';
1511 include_once './Services/Membership/classes/class.ilMembershipRegistrationSettings.php';
1513 $this,
1514 $this->object,
1515 array(
1520 )
1521 );
1522 $reg_settings->addMembershipFormElements($this->form, '');
1523
1524
1526 $section->setTitle($this->lng->txt('event_assign_files'));
1527 $this->form->addItem($section);
1528
1529 $files = new ilFileWizardInputGUI($this->lng->txt('objs_file'), 'files');
1530 $files->setFilenames(array(0 => ''));
1531 $this->form->addItem($files);
1532
1533 $features = new ilFormSectionHeaderGUI();
1534 $features->setTitle($this->lng->txt('obj_features'));
1535 $this->form->addItem($features);
1537 $this->object->getId(),
1538 $this->form,
1539 array(
1541 )
1542 );
1543
1544
1545 switch ($a_mode) {
1546 case 'create':
1547 $this->form->setTitle($this->lng->txt('event_table_create'));
1548
1549 $this->form->addCommandButton('save', $this->lng->txt('event_btn_add'));
1550 $this->form->addCommandButton('saveAndAssignMaterials', $this->lng->txt('event_btn_add_edit'));
1551 $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
1552
1553 return true;
1554
1555 case 'edit':
1556 $this->form->setTitle($this->lng->txt('event_table_update'));
1557
1558 $this->form->addCommandButton('update', $this->lng->txt('save'));
1559 $this->form->addCommandButton('cancelEdit', $this->lng->txt('cancel'));
1560
1561 return true;
1562 }
1563 return true;
1564 }
1565
1573 protected function load()
1574 {
1575 $event = $this->form->getItemByPostVar('event');
1576 if ($event->getStart() && $event->getEnd()) {
1577 $this->object->getFirstAppointment()->setStartingTime($event->getStart()->get(IL_CAL_UNIX));
1578 $this->object->getFirstAppointment()->setEndingTime($event->getStart()->get(IL_CAL_UNIX));
1579 $this->object->getFirstAppointment()->setStart($event->getStart());
1580 $this->object->getFirstAppointment()->setEnd($event->getEnd());
1581 $this->object->getFirstAppointment()->toggleFulltime($event->getStart() instanceof ilDate);
1582 }
1583
1584 $this->object->setTitle(ilUtil::stripSlashes($_POST['title']));
1585 $this->object->setDescription(ilUtil::stripSlashes($_POST['desc']));
1586 $this->object->setLocation(ilUtil::stripSlashes($_POST['location']));
1587 $this->object->setName(ilUtil::stripSlashes($_POST['tutor_name']));
1588 $this->object->setPhone(ilUtil::stripSlashes($_POST['tutor_phone']));
1589 $this->object->setEmail(ilUtil::stripSlashes($_POST['tutor_email']));
1590 $this->object->setDetails(ilUtil::stripSlashes($_POST['details']));
1591
1592 $this->object->setRegistrationType((int) $_POST['registration_type']);
1593 // $this->object->setRegistrationMinUsers((int) $_POST['registration_min_members']);
1594 $this->object->setRegistrationMaxUsers((int) $_POST['registration_max_members']);
1595 $this->object->enableRegistrationUserLimit((int) $_POST['registration_membership_limited']);
1596
1597 switch ((int) $_POST['waiting_list']) {
1598 case 2:
1599 $this->object->enableRegistrationWaitingList(true);
1600 $this->object->setWaitingListAutoFill(true);
1601 break;
1602
1603 case 1:
1604 $this->object->enableRegistrationWaitingList(true);
1605 $this->object->setWaitingListAutoFill(false);
1606 break;
1607
1608 default:
1609 $this->object->enableRegistrationWaitingList(false);
1610 $this->object->setWaitingListAutoFill(false);
1611 break;
1612 }
1613 }
1614
1621 protected function loadRecurrenceSettings()
1622 {
1623 include_once('./Modules/Session/classes/class.ilSessionRecurrence.php');
1624 $this->rec = new ilSessionRecurrence();
1625
1626 switch ($_POST['frequence']) {
1627 case IL_CAL_FREQ_DAILY:
1628 $this->rec->setFrequenceType($_POST['frequence']);
1629 $this->rec->setInterval((int) $_POST['count_DAILY']);
1630 break;
1631
1632 case IL_CAL_FREQ_WEEKLY:
1633 $this->rec->setFrequenceType($_POST['frequence']);
1634 $this->rec->setInterval((int) $_POST['count_WEEKLY']);
1635 if (is_array($_POST['byday_WEEKLY'])) {
1636 $this->rec->setBYDAY(ilUtil::stripSlashes(implode(',', $_POST['byday_WEEKLY'])));
1637 }
1638 break;
1639
1641 $this->rec->setFrequenceType($_POST['frequence']);
1642 $this->rec->setInterval((int) $_POST['count_MONTHLY']);
1643 switch ((int) $_POST['subtype_MONTHLY']) {
1644 case 0:
1645 // nothing to do;
1646 break;
1647
1648 case 1:
1649 switch ((int) $_POST['monthly_byday_day']) {
1650 case 8:
1651 // Weekday
1652 $this->rec->setBYSETPOS((int) $_POST['monthly_byday_num']);
1653 $this->rec->setBYDAY('MO,TU,WE,TH,FR');
1654 break;
1655
1656 case 9:
1657 // Day of month
1658 $this->rec->setBYMONTHDAY((int) $_POST['monthly_byday_num']);
1659 break;
1660
1661 default:
1662 $this->rec->setBYDAY((int) $_POST['monthly_byday_num'] . $_POST['monthly_byday_day']);
1663 break;
1664 }
1665 break;
1666
1667 case 2:
1668 $this->rec->setBYMONTHDAY((int) $_POST['monthly_bymonthday']);
1669 break;
1670 }
1671 break;
1672
1673 case IL_CAL_FREQ_YEARLY:
1674 $this->rec->setFrequenceType($_POST['frequence']);
1675 $this->rec->setInterval((int) $_POST['count_YEARLY']);
1676 switch ((int) $_POST['subtype_YEARLY']) {
1677 case 0:
1678 // nothing to do;
1679 break;
1680
1681 case 1:
1682 $this->rec->setBYMONTH((int) $_POST['yearly_bymonth_byday']);
1683 $this->rec->setBYDAY((int) $_POST['yearly_byday_num'] . $_POST['yearly_byday']);
1684 break;
1685
1686 case 2:
1687 $this->rec->setBYMONTH((int) $_POST['yearly_bymonth_by_monthday']);
1688 $this->rec->setBYMONTHDAY((int) $_POST['yearly_bymonthday']);
1689 break;
1690 }
1691 break;
1692 }
1693
1694 // UNTIL
1695 switch ((int) $_POST['until_type']) {
1696 case 1:
1697 $this->rec->setFrequenceUntilDate(null);
1698 // nothing to do
1699 break;
1700
1701 case 2:
1702 $this->rec->setFrequenceUntilDate(null);
1703 $this->rec->setFrequenceUntilCount((int) $_POST['count']);
1704 break;
1705
1706 case 3:
1707 $frequence = $this->form->getItemByPostVar('frequence');
1708 $end = $frequence->getRecurrence()->getFrequenceUntilDate();
1709 $this->rec->setFrequenceUntilCount(0);
1710 $this->rec->setFrequenceUntilDate($end);
1711 break;
1712 }
1713 }
1714
1715
1723 protected function __toUnix($date, $time)
1724 {
1725 return mktime($time['h'], $time['m'], 0, $date['m'], $date['d'], $date['y']);
1726 }
1727
1734 public function addLocatorItems()
1735 {
1736 global $ilLocator;
1737
1738 if (!$this->getCreationMode()) {
1739 // see prepareOutput()
1740 include_once './Modules/Session/classes/class.ilSessionAppointment.php';
1741 $title = strlen($this->object->getTitle()) ? (': ' . $this->object->getTitle()) : '';
1742 $title = $this->object->getFirstAppointment()->appointmentToString() . $title;
1743
1744 $ilLocator->addItem($title, $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
1745 }
1746 }
1747
1748
1753 {
1754 global $DIC;
1755
1756 $objDefinition = $DIC['objDefinition'];
1757
1758 $tree = $DIC->repositoryTree();
1759 $ctrl = $DIC->ctrl();
1760
1761 $parent_id = $tree->getParentId($this->object->getRefId());
1762
1763 // #11650
1764 $parent_type = ilObject::_lookupType($parent_id, true);
1765
1766 $parent_class = $objDefinition->getClassName($parent_type);
1767 $parent_class = 'ilObj' . $parent_class . 'GUI';
1768
1769 $ctrl->setParameterByClass($parent_class, "ref_id", $parent_id);
1770 $ctrl->redirectByClass($parent_class, "view");
1771 }
1772
1773
1780 public function getTabs()
1781 {
1782 global $ilAccess, $ilTabs, $tree, $ilCtrl, $ilHelp;
1783
1784 $ilHelp->setScreenIdComponent("sess");
1785
1786 $parent_id = $tree->getParentId($this->object->getRefId());
1787
1788 // #11650
1789 $parent_type = ilObject::_lookupType($parent_id, true);
1790
1791 $this->tabs_gui->setBackTarget(
1792 $this->lng->txt('back_to_' . $parent_type . '_content'),
1793 $ilCtrl->getLinkTarget($this, "redirectToParentContentPage")
1794 );
1795
1796 $this->tabs_gui->addTarget(
1797 'info_short',
1798 $this->ctrl->getLinkTarget($this, 'infoScreen')
1799 );
1800
1801 if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) {
1802 $this->tabs_gui->addTarget(
1803 'settings',
1804 $this->ctrl->getLinkTarget($this, 'edit')
1805 );
1806 $this->tabs_gui->addTarget(
1807 'crs_materials',
1808 $this->ctrl->getLinkTarget($this, 'materials')
1809 );
1810
1811 $this->tabs_gui->addTab(
1812 'members',
1813 $this->lng->txt('event_edit_members'),
1814 $this->ctrl->getLinkTargetByClass('ilsessionmembershipgui', '')
1815 );
1816 }
1817
1818 // learning progress
1819 include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
1820 if (ilLearningProgressAccess::checkAccess($this->object->getRefId())) {
1821 $this->tabs_gui->addTarget(
1822 'learning_progress',
1823 $this->ctrl->getLinkTargetByClass(array('ilobjsessiongui','illearningprogressgui'), ''),
1824 '',
1825 array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui')
1826 );
1827 }
1828
1829 // meta data
1830 if ($ilAccess->checkAccess('write', '', $this->ref_id)) {
1831 include_once "Services/Object/classes/class.ilObjectMetaDataGUI.php";
1832 $mdgui = new ilObjectMetaDataGUI($this->object);
1833 $mdtab = $mdgui->getTab();
1834 if ($mdtab) {
1835 $this->tabs_gui->addTarget(
1836 "meta_data",
1837 $mdtab,
1838 "",
1839 "ilobjectmetadatagui"
1840 );
1841 }
1842 }
1843
1844
1845 // export
1846 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1847 $this->tabs_gui->addTarget(
1848 "export",
1849 $this->ctrl->getLinkTargetByClass("ilexportgui", ""),
1850 "",
1851 "ilexportgui"
1852 );
1853 }
1854
1855
1856 // edit permissions
1857 if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId())) {
1858 $this->tabs_gui->addTarget(
1859 "perm_settings",
1860 $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"),
1861 array("perm","info","owner"),
1862 'ilpermissiongui'
1863 );
1864 }
1865 }
1866
1872 public function afterSaveCallback(ilObject $a_obj)
1873 {
1874 // add new object to materials
1875 include_once './Modules/Session/classes/class.ilEventItems.php';
1876 $event_items = new ilEventItems($this->object->getId());
1877 $event_items->addItem($a_obj->getRefId());
1878 $event_items->update();
1879
1880 /*
1881 ilUtil::sendSuccess($this->lng->txt("object_added"), true);
1882 $this->ctrl->redirect($this, "materials");
1883 */
1884 }
1885
1886
1890 public function readMemberData($a_usr_ids)
1891 {
1892 $tmp_data = array();
1893 foreach ($a_usr_ids as $usr_id) {
1894 $tmp_data[$usr_id] = array();
1895 }
1896 return $tmp_data;
1897 }
1898
1899
1900
1905 public function getContainerRefId()
1906 {
1907 if (!$this->container_ref_id) {
1908 $this->initContainer();
1909 }
1911 }
1912
1913
1919 protected function cancelEditObject()
1920 {
1921 global $ilCtrl, $tree;
1922
1923 $parent_id = $tree->getParentId((int) $_REQUEST['ref_id']);
1924
1925 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $parent_id);
1926
1927 $ilCtrl->redirectByClass("ilrepositorygui", "");
1928 }
1929
1930
1935 public function getDefaultMemberRole()
1936 {
1937 $local_roles = $GLOBALS['DIC']->rbac()->review()->getRolesOfRoleFolder($this->object->getRefId(), false);
1938
1939 foreach ($local_roles as $role_id) {
1940 $title = ilObject::_lookupTitle($role_id);
1941 if (substr($title, 0, 19) == 'il_sess_participant') {
1942 return $role_id;
1943 }
1944 }
1945 return 0;
1946 }
1947
1948
1953 public function getLocalRoles()
1954 {
1955 return $GLOBALS['DIC']->rbac()->review()->getRolesOfRoleFolder($this->object->getRefId(), false);
1956 }
1957
1958
1963 public function createMailSignature()
1964 {
1965 $link = chr(13) . chr(10) . chr(13) . chr(10);
1966 $link .= $this->lng->txt('sess_mail_permanent_link');
1967 $link .= chr(13) . chr(10) . chr(13) . chr(10);
1968 include_once './Services/Link/classes/class.ilLink.php';
1969 $link .= ilLink::_getLink($this->object->getRefId());
1970 return rawurlencode(base64_encode($link));
1971 }
1972}
sprintf('%.4f', $callTime)
user()
Definition: user.php:4
$section
Definition: Utf8Test.php:83
$location
Definition: buildRTE.php:44
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_FREQ_YEARLY
const IL_CAL_FREQ_MONTHLY
const IL_CAL_FREQ_WEEKLY
const IL_CAL_UNIX
const IL_CAL_YEAR
Base class for attendance lists.
Calculates an ilDateList for a given calendar entry and recurrence rule.
static _recordReadEvent( $a_type, $a_ref_id, $obj_id, $usr_id, $isCatchupWriteEvents=true, $a_ext_rc=false, $a_ext_time=false)
Records a read event and catches up with write events.
This class represents a checkbox property in a property form.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
Confirmation screen class.
static _getInstance($a_obj_id)
get instance by obj_id
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
input GUI for a time span (start and end date)
static setUseRelativeDates($a_status)
set use relative dates
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
Class for single dates.
static addToDesktop()
Add desktop item @access public.
static removeFromDesktop()
Remove item from personal desktop @access public.
class ilEvent
static _isRegistered($a_usr_id, $a_event_id)
static _register($a_usr_id, $a_event_id)
static _unregister($a_usr_id, $a_event_id)
Export User Interface Class.
This class represents a file wizard property in a property form.
This class represents a section header in a property form.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
Class ilInfoScreenGUI.
static checkAccess($a_ref_id, $a_allow_only_read=true)
check access to learning progress
Class ilObjUserTrackingGUI.
static getInstance()
Factory.
static _modifyItemGUI( $a_item_list_gui, $a_cmd_class, $a_item_data, $a_show_path, $a_abo_status, $a_course_ref_id, $a_course_obj_id, $a_parent_ref_id=0)
We need a static version of this, e.g.
static _lookupAboStatus($a_id)
Class ilObjFile.
unregisterObject()
unregister from session
materialsObject()
show material assignment
addLocatorItems()
Add session locator.
cancelEditObject()
Cancel editigin @global type $ilCtrl @global type $tree.
executeCommand()
execute command
prepareOutput($a_show_subobjects=true)
initContainer($a_init_participants=false)
showJoinRequestButtonInCalendar(ilToolbarGUI $a_ilToolbar)
saveMaterialsObject()
save material assignment
readMemberData($a_usr_ids)
Used for waiting list.
loadRecurrenceSettings()
load recurrence settings
redirectToParentContentPageObject()
Redirect to parent content page.
getAttendanceListUserData($a_user_id, $a_filters)
Get user data for attendance list.
confirmDeleteFilesObject()
confirm delete files
attendanceListObject()
show attendance list selection
updateObject()
update object
static _goto($a_target)
goto
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually,...
modifyItemGUI($a_item_list_gui, $a_item_data, $a_show_path)
Modify Item ListGUI for presentation in container @global type $tree.
saveAndAssignMaterialsObject()
Save and assign sessoin materials.
saveObject($a_redirect_on_success=true)
save object
membersObject()
Redirect to member adminsitration.
getCurrentObject()
Get session object.
printAttendanceListObject()
print attendance list
__toUnix($date, $time)
@access protected
getLocalRoles()
get all local roles
afterSaveCallback(ilObject $a_obj)
Custom callback after object is created (in parent containert.
getDefaultMemberRole()
Get default member role.
initCreateForm($a_new_type)
Init object creation form.
joinObject()
Called from info screen.
createRecurringSessions($a_activate_lp=true)
create recurring sessions
deleteFilesObject()
delete files
initAttendanceList()
Init attendance list object.
showJoinRequestButton(ilToolbarGUI $ilToolbar=null)
createMailSignature()
Create a course mail signature.
initForm($a_mode)
Init Form.
registerObject()
register to session
eventsListObject()
list sessions of all user
__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output=true)
Constructor.
getContainerRefId()
container ref id
static _lookupLogin($a_user_id)
lookup login
static _lookupName($a_user_id)
lookup user name
static addListGUIActivationProperty(ilObjectListGUI $a_list_gui, array &$a_item)
Get timing details for list gui.
static getItemsByEvent($a_event_id)
Get session material / event items.
Render add new item selector.
GUI class for the workflow of copying objects.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilObjectGUI Basic methods of all Output classes.
__showButton($a_cmd, $a_text, $a_target='')
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
getDidacticTemplateVar($a_type)
Get didactic template setting from creation screen.
static _gotoRepositoryNode($a_ref_id, $a_cmd="frameset")
Goto repository root.
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
getCreationMode()
get creation mode
saveObject()
save object
initDidacticTemplate(ilPropertyFormGUI $form)
Show didactic template types.
addHeaderAction()
Add header action menu.
createObject()
create new object form
redirectToRefId($a_ref_id, $a_cmd="")
redirects to (repository) view per ref id usually to a container and usually used at the end of a sav...
Class ilObjectMetaDataGUI.
static initServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
Init service settings form.
static updateServiceSettingsForm($a_obj_id, ilPropertyFormGUI $form, $services)
Update service settings.
Class ilObject Basic functions for all objects.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
getRefId()
get reference id @access public
static _lookupType($a_id, $a_reference=false)
lookup object type
static getInstance($a_ref_id)
Get instance by ref_id.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
static resetCaches()
Reset internal caches.
This class represents an input GUI for recurring events/appointments (course events or calendar appoi...
GUI class for membership features.
static factory($a_type)
Get list gui by type This method caches all the returned list guis.
static getInstance($a_ref_id)
Get instance.
Class ilTableGUI.
This class represents a text area property in a property form.
This class represents a text property in a property form.
static _sortIds($a_ids, $a_table, $a_field, $a_id_name)
Function that sorts ids by a given table field using WHERE IN E.g: __sort(array(6,...
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static makeClickable($a_text, $detectGotoLinks=false)
makeClickable In Texten enthaltene URLs und Mail-Adressen klickbar machen
static switchColor($a_num, $a_css1, $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows)
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static deleteUserEntry($a_usr_id, $a_obj_id)
Delete one user entry.
static _isOnList($a_usr_id, $a_obj_id)
Check if a user on the waiting list.
static initDomEvent()
Init YUI DomEvent.
$counter
$i
Definition: disco.tpl.php:19
$html
Definition: example_001.php:87
$tbl
Definition: example_048.php:81
if(!array_key_exists('StateId', $_REQUEST)) $id
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
const IL_CAL_FREQ_DAILY
Model of calendar entry recurrcences.
global $ilCtrl
Definition: ilias.php:18
Interface for gui classes (e.g ilLuceneSearchGUI) that offer add/remove to/from desktop.
$time
Definition: cron.php:21
if($format !==null) $name
Definition: metadata.php:146
if( $orgName !==null) if($spconfig->hasValue('contacts')) $email
Definition: metadata.php:193
$end
Definition: saml1-acs.php:18
$info
Definition: index.php:5
$ret
Definition: parser.php:6
if(isset($_POST['submit'])) $form
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18
$rows
Definition: xhr_table.php:10