ILIAS  release_4-4 Revision
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 
4 include_once('./Services/Object/classes/class.ilObjectGUI.php');
5 include_once('./Modules/Session/classes/class.ilObjSession.php');
6 include_once('./Modules/Session/classes/class.ilSessionFile.php');
7 include_once './Services/PersonalDesktop/interfaces/interface.ilDesktopItemHandling.php';
8 
20 {
21 
22 
23  public $lng;
24  public $ctrl;
25  public $tpl;
26 
27  protected $container_ref_id = 0;
28  protected $container_obj_id = 0;
29 
30  protected $files = array();
31 
39  public function __construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output = true)
40  {
41  global $ilCtrl, $lng, $tpl;
42 
43  $this->type = "sess";
44  parent::__construct($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
45 
46  $this->lng = $lng;
47  $this->lng->loadLanguageModule("event");
48  $this->lng->loadLanguageModule('crs');
49  $this->lng->loadLanguageModule('trac');
50 
51  $this->tpl = $tpl;
52  $this->ctrl = $ilCtrl;
53  }
54 
55 
62  public function executeCommand()
63  {
64  global $ilUser,$ilCtrl;
65 
66  $next_class = $this->ctrl->getNextClass($this);
67  $cmd = $this->ctrl->getCmd();
68 
69 
70  $this->prepareOutput();
71  switch($next_class)
72  {
73  case "ilinfoscreengui":
74  $this->checkPermission("visible");
75  $this->infoScreen(); // forwards command
76  break;
77 
78  case 'ilpermissiongui':
79  $this->tabs_gui->setTabActive('perm_settings');
80  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
81  $perm_gui = new ilPermissionGUI($this);
82  $ret = $this->ctrl->forwardCommand($perm_gui);
83  break;
84 
85  case 'ilobjectcopygui':
86  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
87  $cp = new ilObjectCopyGUI($this);
88  $cp->setType('sess');
89  $this->ctrl->forwardCommand($cp);
90  break;
91 
92  case "ilexportgui":
93 // $this->prepareOutput();
94  $this->tabs_gui->setTabActive("export");
95  include_once("./Services/Export/classes/class.ilExportGUI.php");
96  $exp_gui = new ilExportGUI($this);
97  $exp_gui->addFormat("xml");
98  $ret = $this->ctrl->forwardCommand($exp_gui);
99 // $this->tpl->show();
100  break;
101 
102  case "ilcommonactiondispatchergui":
103  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
105  $this->ctrl->forwardCommand($gui);
106  break;
107 
108  default:
109  if(!$cmd)
110  {
111  $cmd = "infoScreen";
112  }
113  $cmd .= "Object";
114  if ($cmd != "infoScreenObject")
115  {
116  $this->checkPermission("read");
117  }
118  else
119  {
120  $this->checkPermission("visible");
121  }
122  $this->$cmd();
123 
124  break;
125  }
126 
127  $this->addHeaderAction();
128 
129  return true;
130  }
131 
135  protected function prepareOutput()
136  {
137  parent::prepareOutput();
138 
139  if(!$this->getCreationMode())
140  {
141  $title = strlen($this->object->getTitle()) ? (': '.$this->object->getTitle()) : '';
142 
143  include_once './Modules/Session/classes/class.ilSessionAppointment.php';
144  $this->tpl->setTitle(
145  $this->object->getFirstAppointment()->appointmentToString().$title);
146  }
147  }
148 
156  public function registerObject()
157  {
158  global $ilUser;
159 
160  include_once 'Modules/Session/classes/class.ilEventParticipants.php';
161  ilEventParticipants::_register($ilUser->getId(),$this->object->getId());
162 
163  ilUtil::sendSuccess($this->lng->txt('event_registered'),true);
164  $this->ctrl->returnToParent($this);
165  }
166 
171  public function joinObject()
172  {
173  global $ilUser;
174 
175  $this->checkPermission('read');
176 
177  if($ilUser->isAnonymous())
178  {
179  $this->ctrl->redirect($this,'infoScreen');
180  }
181 
182  include_once './Modules/Session/classes/class.ilEventParticipants.php';
183 
184  if(ilEventParticipants::_isRegistered($ilUser->getId(),$this->object->getId()))
185  {
186  $_SESSION['sess_hide_info'] = true;
187  ilEventParticipants::_unregister($ilUser->getId(),$this->object->getId());
188  ilUtil::sendSuccess($this->lng->txt('event_unregistered'),true);
189  }
190  else
191  {
192  ilEventParticipants::_register($ilUser->getId(),$this->object->getId());
193  ilUtil::sendSuccess($this->lng->txt('event_registered'),true);
194  }
195 
196  $this->ctrl->redirect($this,'infoScreen');
197  }
198 
205  public function unregisterObject()
206  {
207  global $ilUser;
208 
209  include_once './Modules/Session/classes/class.ilEventParticipants.php';
210  ilEventParticipants::_unregister($ilUser->getId(),$this->object->getId());
211 
212  ilUtil::sendSuccess($this->lng->txt('event_unregistered'),true);
213  $this->ctrl->returnToParent($this);
214  }
215 
224  public static function _goto($a_target)
225  {
226  global $ilAccess,$ilErr,$lng;
227 
228  if($ilAccess->checkAccess('visible', "", $a_target))
229  {
230  ilObjectGUI::_gotoRepositoryNode($a_target, "infoScreen");
231  }
232  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
233  }
234 
238  public function addToDeskObject()
239  {
240  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
242  $this->infoScreenObject();
243  }
244 
248  public function removeFromDeskObject()
249  {
250  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
252  $this->infoScreenObject();
253  }
254 
255 
261  public function infoScreenObject()
262  {
263  $this->ctrl->setCmd("showSummary");
264  $this->ctrl->setCmdClass("ilinfoscreengui");
265  $this->infoScreen();
266  }
267 
271  function modifyItemGUI($a_item_list_gui,$a_item_data, $a_show_path)
272  {
273  global $tree;
274 
275  // if folder is in a course, modify item list gui according to course requirements
276  if ($course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs'))
277  {
278  // #10611
279  include_once "Services/Object/classes/class.ilObjectActivation.php";
280  ilObjectActivation::addListGUIActivationProperty($a_item_list_gui, $a_item_data);
281 
282  include_once("./Modules/Course/classes/class.ilObjCourse.php");
283  include_once("./Modules/Course/classes/class.ilObjCourseGUI.php");
284  $course_obj_id = ilObject::_lookupObjId($course_ref_id);
286  $a_item_list_gui,
287  get_class($this),
288  $a_item_data,
289  $a_show_path,
290  ilObjCourse::_lookupAboStatus($course_obj_id),
291  $course_ref_id,
292  $course_obj_id,
293  $this->object->getRefId());
294  }
295  }
296 
304  public function infoScreen()
305  {
306  global $ilAccess, $ilUser,$ilCtrl,$tree,$ilToolbar;
307 
308  $this->checkPermission('visible');
309  $this->tabs_gui->setTabActive('info_short');
310 
311  $appointment_obj = $this->object->getFirstAppointment();
312 
313  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
314  $info = new ilInfoScreenGUI($this);
315 
316  if($this->object->enabledRegistration() && !$ilUser->isAnonymous())
317  {
318  include_once './Modules/Session/classes/class.ilEventParticipants.php';
319  if(ilEventParticipants::_isRegistered($ilUser->getId(), $this->object->getId()))
320  {
321  $ilToolbar->addFormButton($this->lng->txt('event_unregister'),'join');
322  }
323  else
324  {
325  if(!isset($_SESSION['sess_hide_info']))
326  {
327  ilUtil::sendInfo($this->lng->txt('sess_join_info'));
328  }
329  $ilToolbar->addFormButton($this->lng->txt('join_session'),'join', '', true);
330  }
331  $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
332  }
333 
334  // Session information
335  if(strlen($this->object->getLocation()) or strlen($this->object->getDetails()))
336  {
337  $info->addSection($this->lng->txt('event_section_information'));
338  }
339  if(strlen($location = $this->object->getLocation()))
340  {
341  $info->addProperty($this->lng->txt('event_location'),
342  nl2br($this->object->getLocation()));
343  }
344  if(strlen($this->object->getDetails()))
345  {
346  $info->addProperty($this->lng->txt('event_details_workflow'),
347  nl2br($this->object->getDetails()));
348  }
349 
350  // Tutor information
351  if($this->object->hasTutorSettings())
352  {
353  $info->addSection($this->lng->txt('event_tutor_data'));
354  if(strlen($fullname = $this->object->getName()))
355  {
356  $info->addProperty($this->lng->txt('event_lecturer'),
357  $fullname);
358  }
359  if(strlen($email = $this->object->getEmail()))
360  {
361  $info->addProperty($this->lng->txt('tutor_email'),
362  $email);
363  }
364  if(strlen($phone = $this->object->getPhone()))
365  {
366  $info->addProperty($this->lng->txt('tutor_phone'),
367  $phone);
368  }
369  }
370 
371 
372  $html = '';
373 
374  include_once './Services/Object/classes/class.ilObjectActivation.php';
375  include_once './Services/Container/classes/class.ilContainerSorting.php';
376  include_once './Modules/Session/classes/class.ilSessionObjectListGUIFactory.php';
377 
378  $eventItems = ilObjectActivation::getItemsByEvent($this->object->getId());
379  $parent_id = $tree->getParentId($this->object->getRefId());
380  $parent_id = ilObject::_lookupObjId($parent_id);
381  $eventItems = ilContainerSorting::_getInstance($parent_id)->sortSubItems(
382  'sess',
383  $this->object->getId(),
384  $eventItems
385  );
386 
387  foreach($eventItems as $item)
388  {
389  $list_gui = ilSessionObjectListGUIFactory::factory($item['type']);
390  $list_gui->setContainerObject($this);
391 
392  $this->modifyItemGUI($list_gui, $item, false);
393 
394  $html .= $list_gui->getListItemHTML(
395  $item['ref_id'],
396  $item['obj_id'],
397  $item['title'],
398  $item['description']
399  );
400  }
401 
402  if(strlen($html))
403  {
404  $info->addSection($this->lng->txt('event_materials'));
405  $info->addProperty(
406  '&nbsp;',
407  $html);
408  }
409 
410  // forward the command
411  $this->ctrl->forwardCommand($info);
412 
413  // store read event
414  require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
415  ilChangeEvent::_recordReadEvent($this->object->getType(), $this->object->getRefId(),
416  $this->object->getId(), $ilUser->getId());
417  }
418 
424  public function sendFileObject()
425  {
426  $file = new ilSessionFile((int) $_GET['file_id']);
427 
428  ilUtil::deliverFile($file->getAbsolutePath(),$file->getFileName(),$file->getFileType());
429  return true;
430  }
431 
432  protected function initCreateForm($a_new_type)
433  {
434  if(!is_object($this->object))
435  {
436  $this->object = new ilObjSession();
437  }
438  $this->initForm('create');
439  return $this->form;
440  }
441 
448  {
449  global $ilLog;
450 
451  $this->saveObject(false);
452 
453  /*
454  $this->ctrl->setParameter($this,'ref_id',$this->object->getRefId());
455  $target = $this->ctrl->getLinkTarget($this,'materials');
456  $target = str_replace('new_type=','nt=',$target);
457  */
458  $this->ctrl->setParameter($this,'ref_id',$this->object->getRefId());
459  $this->ctrl->redirect($this,'materials');
460  }
461 
469  public function saveObject($a_redirect_on_success = true)
470  {
471  global $ilErr,$ilUser;
472 
473  $this->object = new ilObjSession();
474 
475  $this->load();
476  $this->loadRecurrenceSettings();
477  $this->initForm('create');
478 
479  $ilErr->setMessage('');
480  if(!$this->form->checkInput()) {
481  $ilErr->setMessage($this->lng->txt('err_check_input'));
482  }
483 
484  $this->object->validate();
485  $this->object->getFirstAppointment()->validate();
486 
487  if(strlen($ilErr->getMessage()))
488  {
489  ilUtil::sendFailure($ilErr->getMessage().$_GET['ref_id']);
490  $this->createObject();
491  return false;
492  }
493  // Create session
494  $this->object->create();
495  $this->object->createReference();
496  $this->object->putInTree($_GET["ref_id"]);
497  $this->object->setPermissions($_GET["ref_id"]);
498 
499  // create appointment
500  $this->object->getFirstAppointment()->setSessionId($this->object->getId());
501  $this->object->getFirstAppointment()->create();
502 
503  $this->handleFileUpload();
504 
505  $this->createRecurringSessions();
506 
507  if($a_redirect_on_success)
508  {
509  ilUtil::sendInfo($this->lng->txt('event_add_new_event'),true);
510  $this->ctrl->returnToParent($this);
511  }
512 
513  return true;
514 
515  }
516 
517  public function handleFileUpload()
518  {
519  global $tree;
520 
521  include_once './Modules/Session/classes/class.ilEventItems.php';
522  $ev = new ilEventItems($this->object->getId());
523  $items = $ev->getItems();
524 
525  $counter = 0;
526  while(true)
527  {
528  if(!isset($_FILES['files']['name'][$counter]))
529  {
530  break;
531  }
532  if(!strlen($_FILES['files']['name'][$counter]))
533  {
534  $counter++;
535  continue;
536  }
537 
538  include_once './Modules/File/classes/class.ilObjFile.php';
539  $file = new ilObjFile();
540  $file->setTitle(ilUtil::stripSlashes($_FILES['files']['name'][$counter]));
541  $file->setDescription('');
542  $file->setFileName(ilUtil::stripSlashes($_FILES['files']['name'][$counter]));
543  $file->setFileType($_FILES['files']['type'][$counter]);
544  $file->setFileSize($_FILES['files']['size'][$counter]);
545  $file->create();
546  $new_ref_id = $file->createReference();
547  $file->putInTree($tree->getParentId($this->object->getRefId()));
548  $file->setPermissions($tree->getParentId($this->object->getRefId()));
549  $file->createDirectory();
550  $file->getUploadFile(
551  $_FILES['files']['tmp_name'][$counter],
552  $_FILES['files']['name'][$counter]
553  );
554 
555  $items[] = $new_ref_id;
556  $counter++;
557 
558  }
559 
560  $ev->setItems($items);
561  $ev->update();
562  }
563 
564 
565 
573  protected function createRecurringSessions()
574  {
575  global $tree;
576 
577  if(!$this->rec->getFrequenceType())
578  {
579  return true;
580  }
581  include_once('./Services/Calendar/classes/class.ilCalendarRecurrenceCalculator.php');
582  $calc = new ilCalendarRecurrenceCalculator($this->object->getFirstAppointment(),$this->rec);
583 
584  $period_start = clone $this->object->getFirstAppointment()->getStart();
585 
586 
587  $period_end = clone $this->object->getFirstAppointment()->getStart();
588  $period_end->increment(IL_CAL_YEAR,5);
589  $date_list = $calc->calculateDateList($period_start,$period_end);
590 
591  $period_diff = $this->object->getFirstAppointment()->getEnd()->get(IL_CAL_UNIX) -
592  $this->object->getFirstAppointment()->getStart()->get(IL_CAL_UNIX);
593  $parent_id = $tree->getParentId($this->object->getRefId());
594 
595  include_once './Modules/Session/classes/class.ilEventItems.php';
596  $evi = new ilEventItems($this->object->getId());
597  $eitems = $evi->getItems();
598 
599  $counter = 0;
600  foreach($date_list->get() as $date)
601  {
602  if(!$counter++)
603  {
604  continue;
605  }
606 
607  $new_obj = $this->object->cloneObject($parent_id);
608  $new_obj->read();
609  $new_obj->getFirstAppointment()->setStartingTime($date->get(IL_CAL_UNIX));
610  $new_obj->getFirstAppointment()->setEndingTime($date->get(IL_CAL_UNIX) + $period_diff);
611  $new_obj->getFirstAppointment()->update();
612  $new_obj->update();
613 
614  $new_evi = new ilEventItems($new_obj->getId());
615  $new_evi->setItems($eitems);
616  $new_evi->update();
617  }
618  }
619 
620 
628  public function editObject()
629  {
630  $this->tabs_gui->setTabActive('settings');
631 
632  $this->initForm('edit');
633  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.sess_edit.html','Modules/Session');
634  $this->tpl->setVariable('EVENT_EDIT_TABLE',$this->form->getHTML());
635 
636  if(!count($this->object->getFiles()))
637  {
638  return true;
639  }
640  $rows = array();
641  foreach($this->object->getFiles() as $file)
642  {
643  $table_data['id'] = $file->getFileId();
644  $table_data['filename'] = $file->getFileName();
645  $table_data['filetype'] = $file->getFileType();
646  $table_data['filesize'] = $file->getFileSize();
647 
648  $rows[] = $table_data;
649  }
650 
651  include_once("./Modules/Session/classes/class.ilSessionFileTableGUI.php");
652  $table_gui = new ilSessionFileTableGUI($this, "edit");
653  $table_gui->setTitle($this->lng->txt("event_files"));
654  $table_gui->setData($rows);
655  $table_gui->addCommandButton("cancel", $this->lng->txt("cancel"));
656  $table_gui->addMultiCommand("confirmDeleteFiles", $this->lng->txt("delete"));
657  $table_gui->setSelectAllCheckbox("file_id");
658  $this->tpl->setVariable('EVENT_FILE_TABLE',$table_gui->getHTML());
659 
660  return true;
661  }
662 
670  public function updateObject()
671  {
672  global $ilErr;
673 
674  $this->load();
675  $this->initForm('edit');
676 
677  $ilErr->setMessage('');
678  if(!$this->form->checkInput())
679  {
680  $ilErr->setMessage($this->lng->txt('err_check_input'));
681  }
682  $this->object->validate();
683  $this->object->getFirstAppointment()->validate();
684 
685  if(strlen($ilErr->getMessage()))
686  {
687  ilUtil::sendFailure($ilErr->getMessage());
688  $this->editObject();
689  return false;
690  }
691  // Update event
692  $this->object->update();
693  $this->object->getFirstAppointment()->update();
694 
695  $this->handleFileUpload();
696 
697  ilUtil::sendSuccess($this->lng->txt('event_updated'),true);
698  $this->ctrl->redirect($this,'edit');
699  #$this->object->initFiles();
700  #$this->editObject();
701  return true;
702  }
703 
711  public function confirmDeleteFilesObject()
712  {
713  $this->tabs_gui->setTabActive('settings');
714 
715  if(!count($_POST['file_id']))
716  {
717  ilUtil::sendFailure($this->lng->txt('select_one'));
718  $this->editObject();
719  return false;
720  }
721 
722  include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
723  $c_gui = new ilConfirmationGUI();
724 
725  // set confirm/cancel commands
726  $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteFiles"));
727  $c_gui->setHeaderText($this->lng->txt("info_delete_sure"));
728  $c_gui->setCancel($this->lng->txt("cancel"), "edit");
729  $c_gui->setConfirm($this->lng->txt("confirm"), "deleteFiles");
730 
731  // add items to delete
732  foreach($_POST["file_id"] as $file_id)
733  {
734  $file = new ilSessionFile($file_id);
735  if($file->getSessionId() != $this->object->getEventId())
736  {
737  ilUtil::sendFailure($this->lng->txt('select_one'));
738  $this->edit();
739  return false;
740  }
741  $c_gui->addItem("file_id[]", $file_id, $file->getFileName());
742  }
743 
744  $this->tpl->setContent($c_gui->getHTML());
745  return true;
746  }
747 
755  public function deleteFilesObject()
756  {
757  if(!count($_POST['file_id']))
758  {
759  ilUtil::sendFailure($this->lng->txt('select_one'));
760  $this->editObject();
761  return false;
762  }
763  foreach($_POST['file_id'] as $id)
764  {
765  $file = new ilSessionFile($id);
766  $file->delete();
767  }
768  $this->object->initFiles();
769  $this->editObject();
770  return true;
771  }
772 
773  protected function initContainer($a_init_participants = false)
774  {
775  global $tree;
776 
777  $is_course = $is_group = false;
778 
779  // #13178
780  $this->container_ref_id = $tree->checkForParentType($this->object->getRefId(),'grp');
781  if($this->container_ref_id)
782  {
783  $is_group = true;
784  }
785  if(!$this->container_ref_id)
786  {
787  $this->container_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs');
788  if($this->container_ref_id)
789  {
790  $is_course = true;
791  }
792  }
793  if(!$this->container_ref_id)
794  {
795  ilUtil::sendFailure('No container object found. Aborting');
796  return true;
797  }
798  $this->container_obj_id = ilObject::_lookupObjId($this->container_ref_id);
799 
800  if($a_init_participants && $this->container_obj_id)
801  {
802  if($is_course)
803  {
804  include_once './Modules/Course/classes/class.ilCourseParticipants.php';
805  return ilCourseParticipants::_getInstanceByObjId($this->container_obj_id);
806  }
807  else if($is_group)
808  {
809  include_once './Modules/Group/classes/class.ilGroupParticipants.php';
810  return ilGroupParticipants::_getInstanceByObjId($this->container_obj_id);
811  }
812  }
813 
814  }
815 
823  public function materialsObject()
824  {
825  global $tree, $objDefinition;
826 
827  $this->tabs_gui->setTabActive('crs_materials');
828 
829  // #11337 - support ANY parent container (crs, grp, fld)
830  $parent_ref_id = $tree->getParentId($this->object->getRefId());
831 
832  include_once "Services/Object/classes/class.ilObjectAddNewItemGUI.php";
833  $gui = new ilObjectAddNewItemGUI($parent_ref_id);
834  $gui->setDisabledObjectTypes(array("itgr", "sess"));
835  $gui->setAfterCreationCallback($this->ref_id);
836  $gui->render();
837 
838  include_once 'Modules/Session/classes/class.ilEventItems.php';
839  $this->event_items = new ilEventItems($this->object->getId());
840  $items = $this->event_items->getItems();
841 
842  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.sess_materials.html','Modules/Session');
843  #$this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
844 
845  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this,'materials'));
846  $this->tpl->setVariable("COLL_TITLE_IMG",ilUtil::getImagePath('icon_sess.png'));
847  $this->tpl->setVariable("COLL_TITLE_IMG_ALT",$this->lng->txt('events'));
848  $this->tpl->setVariable("TABLE_TITLE",$this->lng->txt('event_assign_materials_table'));
849  $this->tpl->setVariable("TABLE_INFO",$this->lng->txt('event_assign_materials_info'));
850 
851  $materials = array();
852  $nodes = $tree->getSubTree($tree->getNodeData($parent_ref_id));
853  foreach($nodes as $node)
854  {
855  // No side blocks here
856  if ($node['child'] == $parent_ref_id ||
857  $objDefinition->isSideBlock($node['type']) ||
858  in_array($node['type'], array('sess', 'itgr', 'rolf')))
859  {
860  continue;
861  }
862 
863  if($node['type'] == 'rolf')
864  {
865  continue;
866  }
867 
868  $node["sorthash"] = (int)(!in_array($node['ref_id'],$items)).$node["title"];
869  $materials[] = $node;
870  }
871 
872 
873  $materials = ilUtil::sortArray($materials, "sorthash", "ASC");
874 
875  $counter = 1;
876  foreach($materials as $node)
877  {
878  $counter++;
879 
880  $this->tpl->setCurrentBlock("material_row");
881 
882  $this->tpl->setVariable('TYPE_IMG', ilObject::_getIcon('', 'tiny', $node['type']));
883  $this->tpl->setVariable('IMG_ALT',$this->lng->txt('obj_'.$node['type']));
884  $this->tpl->setVariable("ROW_CLASS",ilUtil::switchColor($counter,'tblrow1','tblrow2'));
885  $this->tpl->setVariable("CHECK_COLL",ilUtil::formCheckbox(in_array($node['ref_id'],$items) ? 1 : 0,
886  'items[]',$node['ref_id']));
887  $this->tpl->setVariable("COLL_TITLE",$node['title']);
888 
889  if(strlen($node['description']))
890  {
891  $this->tpl->setVariable("COLL_DESC",$node['description']);
892  }
893  $this->tpl->setVariable("ASSIGNED_IMG_OK",in_array($node['ref_id'],$items) ?
894  ilUtil::getImagePath('icon_ok.png') :
895  ilUtil::getImagePath('icon_not_ok.png'));
896  $this->tpl->setVariable("ASSIGNED_STATUS",$this->lng->txt('event_material_assigned'));
897  $this->tpl->setVariable("COLL_PATH",$this->formatPath($node['ref_id']));
898  $this->tpl->parseCurrentBlock();
899  }
900 
901  $this->tpl->setVariable("SELECT_ROW",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
902  $this->tpl->setVariable("SELECT_ALL",$this->lng->txt('select_all'));
903  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.png'));
904  $this->tpl->setVariable("BTN_SAVE",$this->lng->txt('save'));
905  }
906 
914  public function saveMaterialsObject()
915  {
916  include_once './Modules/Session/classes/class.ilEventItems.php';
917 
918  $this->event_items = new ilEventItems($this->object->getId());
919  $this->event_items->setItems(is_array($_POST['items']) ? $_POST['items'] : array());
920  $this->event_items->update();
921 
922  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
923  $this->materialsObject();
924  }
925 
930  protected function membersObject()
931  {
932  global $tree,$ilUser;
933 
934  $this->checkPermission('write');
935  $this->tabs_gui->setTabActive('event_edit_members');
936 
937  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.sess_members.html', 'Modules/Session');
938 
939  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
940  $toolbar = new ilToolbarGUI();
941  $toolbar->addButton($this->lng->txt('sess_gen_attendance_list'),
942  $this->ctrl->getLinkTarget($this,'attendanceList'));
943 
944  $this->tpl->setVariable('ACTION_BUTTONS',$toolbar->getHTML());
945 
946  $members_obj = $this->initContainer(true);
947 
948  include_once './Modules/Session/classes/class.ilEventParticipants.php';
949 
950  // Save hide/show table settings
951  $this->setShowHidePrefs();
952 
953  // Admins
954  if(count($admins = $members_obj->getAdmins()))
955  {
956  include_once('./Modules/Session/classes/class.ilSessionParticipantsTableGUI.php');
957  if($ilUser->getPref('sess_admin_hide'))
958  {
960  $this->ctrl->setParameter($this,'admin_hide',0);
961  $table->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
962  $this->lng->txt('show'),
963  '',
964  ilUtil::getImagePath('edit_add.png'));
965  $this->ctrl->clearParameters($this);
966  }
967  else
968  {
970  $this->ctrl->setParameter($this,'admin_hide',1);
971  $table->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
972  $this->lng->txt('hide'),
973  '',
974  ilUtil::getImagePath('edit_remove.png'));
975  $this->ctrl->clearParameters($this);
976  }
977 
978  $table->addCommandButton('updateMembers',$this->lng->txt('save'));
979  $table->setTitle($this->lng->txt('event_tbl_admins'),'icon_usr.png',$this->lng->txt('event_tbl_admins'));
980  $table->enableRegistration($this->object->enabledRegistration());
981  $table->setParticipants($admins);
982  $table->parse();
983  $this->tpl->setVariable('ADMINS',$table->getHTML());
984  }
985 
986  // Tutors
987  if(count($tutors = $members_obj->getTutors()))
988  {
989  include_once('./Modules/Session/classes/class.ilSessionParticipantsTableGUI.php');
990  if($ilUser->getPref('sess_tutor_hide'))
991  {
993  $this->ctrl->setParameter($this,'tutor_hide',0);
994  $table->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
995  $this->lng->txt('show'),
996  '',
997  ilUtil::getImagePath('edit_add.png'));
998  $this->ctrl->clearParameters($this);
999  }
1000  else
1001  {
1003  $this->ctrl->setParameter($this,'tutor_hide',1);
1004  $table->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1005  $this->lng->txt('hide'),
1006  '',
1007  ilUtil::getImagePath('edit_remove.png'));
1008  $this->ctrl->clearParameters($this);
1009  }
1010  $table->addCommandButton('updateMembers',$this->lng->txt('save'));
1011  $table->setTitle($this->lng->txt('event_tbl_tutors'),'icon_usr.png',$this->lng->txt('event_tbl_admins'));
1012  $table->enableRegistration($this->object->enabledRegistration());
1013  $table->setParticipants($tutors);
1014  $table->parse();
1015  $this->tpl->setVariable('TUTORS',$table->getHTML());
1016  }
1017 
1018  // Members
1019  if(count($members = $members_obj->getMembers()))
1020  {
1021  include_once('./Modules/Session/classes/class.ilSessionParticipantsTableGUI.php');
1022  if($ilUser->getPref('sess_member_hide'))
1023  {
1025  $this->ctrl->setParameter($this,'member_hide',0);
1026  $table->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1027  $this->lng->txt('show'),
1028  '',
1029  ilUtil::getImagePath('edit_add.png'));
1030  $this->ctrl->clearParameters($this);
1031  }
1032  else
1033  {
1035  $this->ctrl->setParameter($this,'member_hide',1);
1036  $table->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1037  $this->lng->txt('hide'),
1038  '',
1039  ilUtil::getImagePath('edit_remove.png'));
1040  $this->ctrl->clearParameters($this);
1041  }
1042  $table->addCommandButton('updateMembers',$this->lng->txt('save'));
1043  $table->setTitle($this->lng->txt('event_tbl_members'),'icon_usr.png',$this->lng->txt('event_tbl_admins'));
1044  $table->enableRegistration($this->object->enabledRegistration());
1045  $table->setParticipants($members);
1046  $table->parse();
1047  $this->tpl->setVariable('MEMBERS',$table->getHTML());
1048  }
1049 
1050 
1051 
1052 
1053 
1054  }
1055 
1062  public function setShowHidePrefs()
1063  {
1064  global $ilUser;
1065 
1066  if(isset($_GET['admin_hide']))
1067  {
1068  $ilUser->writePref('sess_admin_hide',(int) $_GET['admin_hide']);
1069  }
1070  if(isset($_GET['tutor_hide']))
1071  {
1072  $ilUser->writePref('sess_tutor_hide',(int) $_GET['tutor_hide']);
1073  }
1074  if(isset($_GET['member_hide']))
1075  {
1076  $ilUser->writePref('sess_member_hide',(int) $_GET['member_hide']);
1077  }
1078  }
1079 
1087  public function updateMembersObject()
1088  {
1089  global $tree;
1090 
1091  $this->checkPermission('write');
1092 
1093 
1094 
1095  $this->initContainer();
1096 
1097  $_POST['participants'] = is_array($_POST['participants']) ? $_POST['participants'] : array();
1098  $_POST['registered'] = is_array($_POST['registered']) ? $_POST['registered'] : array();
1099 
1100  include_once 'Modules/Session/classes/class.ilEventParticipants.php';
1101 
1102  $visible = $_POST['visible_participants'] ? $_POST['visible_participants'] : array();
1103  foreach($visible as $user)
1104  {
1105  $part = new ilEventParticipants($this->object->getId());
1106  $part->setUserId($user);
1107  $part->setMark(ilUtil::stripSlashes($_POST['mark'][$user]));
1108  $part->setComment(ilUtil::stripSlashes($_POST['comment'][$user]));
1109  $part->setParticipated(isset($_POST['participants'][$user]) ? true : false);
1110  $part->setRegistered(isset($_POST['registered'][$user]) ? true : false);
1111  $part->updateUser();
1112  }
1113  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
1114  $this->membersObject();
1115  }
1116 
1123  public function attendanceListObject()
1124  {
1125  global $tpl,$ilTabs;
1126 
1127  $this->checkPermission('write');
1128  $ilTabs->setTabActive('event_edit_members');
1129 
1130  $list = $this->initAttendanceList();
1131  $form = $list->initForm('printAttendanceList');
1132  $tpl->setContent($form->getHTML());
1133  }
1134 
1140  protected function initAttendanceList()
1141  {
1142  $members_obj = $this->initContainer(true);
1143 
1144  include_once 'Services/Membership/classes/class.ilAttendanceList.php';
1145  $list = new ilAttendanceList($this, $members_obj);
1146  $list->setId('sessattlst');
1147 
1148  $event_app = $this->object->getFirstAppointment();
1150  $desc = ilDatePresentation::formatPeriod($event_app->getStart(),$event_app->getEnd());
1152  $desc .= " ".$this->object->getTitle();
1153  $list->setTitle($this->lng->txt('sess_attendance_list'), $desc);
1154 
1155  $list->addPreset('mark', $this->lng->txt('trac_mark'), true);
1156  $list->addPreset('comment', $this->lng->txt('trac_comment'), true);
1157  if($this->object->enabledRegistration())
1158  {
1159  $list->addPreset('registered', $this->lng->txt('event_tbl_registered'), true);
1160  }
1161  $list->addPreset('participated', $this->lng->txt('event_tbl_participated'), true);
1162  $list->addBlank($this->lng->txt('sess_signature'));
1163 
1164  $list->addUserFilter('registered', $this->lng->txt('event_list_registered_only'));
1165 
1166  return $list;
1167  }
1168 
1174  protected function printAttendanceListObject()
1175  {
1176  $this->checkPermission('write');
1177 
1178  $list = $this->initAttendanceList();
1179  $list->initFromForm();
1180  $list->setCallback(array($this, 'getAttendanceListUserData'));
1181 
1182  include_once 'Modules/Session/classes/class.ilEventParticipants.php';
1183  $this->event_part = new ilEventParticipants($this->object->getId());
1184 
1185  echo $list->getFullscreenHTML();
1186  exit();
1187  }
1188 
1198  public function getAttendanceListUserData($a_user_id, $a_filters)
1199  {
1200  $data = $this->event_part->getUser($a_user_id);
1201 
1202  if($a_filters && $a_filters["registered"] && !$data["registered"])
1203  {
1204  return;
1205  }
1206 
1207  $data['registered'] = $data['registered'] ?
1208  $this->lng->txt('yes') :
1209  $this->lng->txt('no');
1210  $data['participated'] = $data['participated'] ?
1211  $this->lng->txt('yes') :
1212  $this->lng->txt('no');
1213 
1214  return $data;
1215  }
1216 
1224  public function eventsListObject()
1225  {
1226  global $ilErr,$ilAccess, $ilUser,$tree;
1227 
1228  if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
1229  {
1230  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
1231  }
1232 
1233  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.sess_list.html','Modules/Session');
1234  $this->__showButton($this->ctrl->getLinkTarget($this,'exportCSV'),$this->lng->txt('event_csv_export'));
1235 
1236  include_once 'Modules/Session/classes/class.ilEventParticipants.php';
1237 
1238  $this->tpl->addBlockfile("EVENTS_TABLE","events_table", "tpl.table.html");
1239  $this->tpl->addBlockfile('TBL_CONTENT','tbl_content','tpl.sess_list_row.html','Modules/Session');
1240 
1241  $members_obj = $this->initContainer(true);
1242  $members = $members_obj->getParticipants();
1243  $members = ilUtil::_sortIds($members,'usr_data','lastname','usr_id');
1244 
1245  // Table
1246  $tbl = new ilTableGUI();
1247  $tbl->setTitle($this->lng->txt("event_overview"),
1248  'icon_usr.png',
1249  $this->lng->txt('obj_usr'));
1250  $this->ctrl->setParameter($this,'offset',(int) $_GET['offset']);
1251 
1252  $course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs');
1253  $events = array();
1254  foreach($tree->getSubtree($tree->getNodeData($course_ref_id),false,'sess') as $event_id)
1255  {
1256  $tmp_event = ilObjectFactory::getInstanceByRefId($event_id,false);
1257  if(!is_object($tmp_event) or $tmp_event->getType() != 'sess')
1258  {
1259  continue;
1260  }
1261  $events[] = $tmp_event;
1262  }
1263 
1264  $headerNames = array();
1265  $headerVars = array();
1266  $colWidth = array();
1267 
1268  $headerNames[] = $this->lng->txt('name');
1269  $headerVars[] = "name";
1270  $colWidth[] = '20%';
1271 
1272  for ($i = 1; $i <= count($events); $i++)
1273  {
1274  $headerNames[] = $i;
1275  $headerVars[] = "event_".$i;
1276  $colWidth[] = 80/count($events)."%";
1277  }
1278 
1279  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
1280  $tbl->setHeaderNames($headerNames);
1281  $tbl->setHeaderVars($headerVars, $this->ctrl->getParameterArray($this,'eventsList'));
1282  $tbl->setColumnWidth($colWidth);
1283 
1284  $tbl->setOrderColumn($_GET["sort_by"]);
1285  $tbl->setOrderDirection($_GET["sort_order"]);
1286  $tbl->setOffset($_GET["offset"]);
1287  $tbl->setLimit($ilUser->getPref("hits_per_page"));
1288  $tbl->setMaxCount(count($members));
1289  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1290 
1291  $sliced_users = array_slice($members,$_GET['offset'],$_SESSION['tbl_limit']);
1292  $tbl->disable('sort');
1293  $tbl->render();
1294 
1295  $counter = 0;
1296  foreach($sliced_users as $user_id)
1297  {
1298  foreach($events as $event_obj)
1299  {
1300  $this->tpl->setCurrentBlock("eventcols");
1301 
1302  $event_part = new ilEventParticipants($this->object->getId());
1303 
1304  {
1305  $this->tpl->setVariable("IMAGE_PARTICIPATED", $event_part->hasParticipated($user_id) ?
1306  ilUtil::getImagePath('icon_ok.png') :
1307  ilUtil::getImagePath('icon_not_ok.png'));
1308 
1309  $this->tpl->setVariable("PARTICIPATED", $event_part->hasParticipated($user_id) ?
1310  $this->lng->txt('event_participated') :
1311  $this->lng->txt('event_not_participated'));
1312  }
1313 
1314  $this->tpl->parseCurrentBlock();
1315  }
1316 
1317  $this->tpl->setCurrentBlock("tbl_content");
1318  $name = ilObjUser::_lookupName($user_id);
1319  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor($counter++,'tblrow1','tblrow2'));
1320  $this->tpl->setVariable("LASTNAME",$name['lastname']);
1321  $this->tpl->setVariable("FIRSTNAME",$name['firstname']);
1322  $this->tpl->setVariable("LOGIN",ilObjUser::_lookupLogin($user_id));
1323  $this->tpl->parseCurrentBlock();
1324  }
1325 
1326  $this->tpl->setVariable("HEAD_TXT_LEGEND", $this->lng->txt("legend"));
1327  $this->tpl->setVariable("HEAD_TXT_DIGIT", $this->lng->txt("event_digit"));
1328  $this->tpl->setVariable("HEAD_TXT_EVENT", $this->lng->txt("event"));
1329  $this->tpl->setVariable("HEAD_TXT_LOCATION", $this->lng->txt("event_location"));
1330  $this->tpl->setVariable("HEAD_TXT_DATE_TIME",$this->lng->txt("event_date_time"));
1331  $i = 1;
1332  foreach($events as $event_obj)
1333  {
1334  $this->tpl->setCurrentBlock("legend_loop");
1335  $this->tpl->setVariable("LEGEND_CSS_ROW",ilUtil::switchColor($counter++,'tblrow1','tblrow2'));
1336  $this->tpl->setVariable("LEGEND_DIGIT", $i++);
1337  $this->tpl->setVariable("LEGEND_EVENT_TITLE", $event_obj->getTitle());
1338  $this->tpl->setVariable("LEGEND_EVENT_DESCRIPTION", $event_obj->getDescription());
1339  $this->tpl->setVariable("LEGEND_EVENT_LOCATION", $event_obj->getLocation());
1340  $this->tpl->setVariable("LEGEND_EVENT_APPOINTMENT", $event_obj->getFirstAppointment()->appointmentToString());
1341  $this->tpl->parseCurrentBlock();
1342  }
1343 
1344  }
1345 
1351  protected function initForm($a_mode)
1352  {
1353  global $ilUser;
1354 
1355  if(is_object($this->form))
1356  {
1357  return true;
1358  }
1359 
1360  $this->lng->loadLanguageModule('dateplaner');
1361 
1362  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1363 
1364  include_once('./Services/YUI/classes/class.ilYuiUtil.php');
1366 
1367  $this->form = new ilPropertyFormGUI();
1368  $this->form->setMultipart(true);
1369  $this->form->setTableWidth('600px');
1370  $this->form->setFormAction($this->ctrl->getFormAction($this));
1371  $this->form->setMultipart(true);
1372 
1373  /*
1374  $full = new ilCheckboxInputGUI('','fulltime');
1375  $full->setChecked($this->object->getFirstAppointment()->enabledFulltime() ? true : false);
1376  $full->setOptionTitle($this->lng->txt('event_fulltime_info'));
1377  $full->setAdditionalAttributes('onchange="ilToggleSessionTime(this);"');
1378  #$this->form->addItem($full);
1379  */
1380 
1381  $this->lng->loadLanguageModule('dateplaner');
1382  include_once './Services/Form/classes/class.ilDateDurationInputGUI.php';
1383  #$this->tpl->addJavaScript('./Modules/Session/js/toggle_session_time.js');
1384  $this->tpl->addJavaScript('./Services/Form/js/date_duration.js');
1385  $dur = new ilDateDurationInputGUI($this->lng->txt('cal_fullday'),'event');
1386  $dur->setStartText($this->lng->txt('event_start_date'));
1387  $dur->setEndText($this->lng->txt('event_end_date'));
1388  $dur->enableToggleFullTime(
1389  $this->lng->txt('event_fulltime_info'),
1390  $this->object->getFirstAppointment()->enabledFulltime() ? true : false
1391  );
1392  $dur->setMinuteStepSize(5);
1393  $dur->setShowTime(true);
1394  $dur->setShowDate(true);
1395  $dur->setStart($this->object->getFirstAppointment()->getStart());
1396  $dur->setEnd($this->object->getFirstAppointment()->getEnd());
1397 
1398  $this->form->addItem($dur);
1399 
1400  /*
1401  // start
1402  $start = new ilDateTimeInputGUI($this->lng->txt('event_start_date'),'start');
1403  $start->setMinuteStepSize(5);
1404  $start->setDate($this->object->getFirstAppointment()->getStart());
1405  $start->setShowTime(true);
1406  #$this->form->addItem($start);
1407 
1408  // end
1409  $end = new ilDateTimeInputGUI($this->lng->txt('event_end_date'),'end');
1410  $end->setMinuteStepSize(5);
1411  $end->setDate($this->object->getFirstAppointment()->getEnd());
1412  $end->setShowTime(true);
1413  #$this->form->addItem($end);
1414  */
1415 
1416  // Recurrence
1417  if($a_mode == 'create')
1418  {
1419  if(!is_object($this->rec))
1420  {
1421  include_once('./Modules/Session/classes/class.ilEventRecurrence.php');
1422  $this->rec = new ilEventRecurrence();
1423  }
1424  include_once('./Services/Calendar/classes/Form/class.ilRecurrenceInputGUI.php');
1425  $rec = new ilRecurrenceInputGUI($this->lng->txt('cal_recurrences'),'frequence');
1426  $rec->allowUnlimitedRecurrences(false);
1427  $rec->setRecurrence($this->rec);
1428  $this->form->addItem($rec);
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  // section
1465  $section->setTitle($this->lng->txt('event_tutor_data'));
1466  $this->form->addItem($section);
1467 
1468  // name
1469  $tutor_name = new ilTextInputGUI($this->lng->txt('tutor_name'),'tutor_name');
1470  $tutor_name->setValue($this->object->getName());
1471  $tutor_name->setSize(20);
1472  $tutor_name->setMaxLength(70);
1473  $this->form->addItem($tutor_name);
1474 
1475  // email
1476  $tutor_email = new ilTextInputGUI($this->lng->txt('tutor_email'),'tutor_email');
1477  $tutor_email->setValue($this->object->getEmail());
1478  $tutor_email->setSize(20);
1479  $tutor_email->setMaxLength(70);
1480  $this->form->addItem($tutor_email);
1481 
1482  // phone
1483  $tutor_phone = new ilTextInputGUI($this->lng->txt('tutor_phone'),'tutor_phone');
1484  $tutor_phone->setValue($this->object->getPhone());
1485  $tutor_phone->setSize(20);
1486  $tutor_phone->setMaxLength(70);
1487  $this->form->addItem($tutor_phone);
1488 
1490  $section->setTitle($this->lng->txt('crs_further_settings'));
1491  $this->form->addItem($section);
1492 
1493  // registration
1494  $reg = new ilCheckboxInputGUI($this->lng->txt('event_registration'),'registration');
1495  $reg->setChecked($this->object->enabledRegistration() ? true : false);
1496  $reg->setOptionTitle($this->lng->txt('event_registration_info'));
1497  $this->form->addItem($reg);
1498 
1499 
1501  $section->setTitle($this->lng->txt('event_assign_files'));
1502  $this->form->addItem($section);
1503 
1504  $files = new ilFileWizardInputGUI($this->lng->txt('objs_file'),'files');
1505  $files->setFilenames(array(0 => ''));
1506  $this->form->addItem($files);
1507 
1508  switch($a_mode)
1509  {
1510  case 'create':
1511  $this->form->setTitle($this->lng->txt('event_table_create'));
1512  $this->form->setTitleIcon(ilUtil::getImagePath('icon_event.png'));
1513 
1514  $this->form->addCommandButton('save',$this->lng->txt('event_btn_add'));
1515  $this->form->addCommandButton('saveAndAssignMaterials',$this->lng->txt('event_btn_add_edit'));
1516  $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
1517 
1518  return true;
1519 
1520  case 'edit':
1521  $this->form->setTitle($this->lng->txt('event_table_update'));
1522  $this->form->setTitleIcon(ilUtil::getImagePath('icon_event.png'));
1523 
1524  $this->form->addCommandButton('update',$this->lng->txt('save'));
1525  $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
1526 
1527  return true;
1528  }
1529  return true;
1530  }
1531 
1539  protected function load()
1540  {
1541  global $ilUser;
1542 
1543  $this->object->getFirstAppointment()->setStartingTime($this->__toUnix($_POST['event']['start']['date'],$_POST['event']['start']['time']));
1544  $this->object->getFirstAppointment()->setEndingTime($this->__toUnix($_POST['event']['end']['date'],$_POST['event']['end']['time']));
1545  $this->object->getFirstAppointment()->toggleFullTime((bool) $_POST['event']['fulltime']);
1546 
1547  include_once('./Services/Calendar/classes/class.ilDate.php');
1548  if($this->object->getFirstAppointment()->isFullday())
1549  {
1550  $start = new ilDate($_POST['event']['start']['date']['y'].'-'.$_POST['event']['start']['date']['m'].'-'.$_POST['event']['start']['date']['d'],
1551  IL_CAL_DATE);
1552  $this->object->getFirstAppointment()->setStart($start);
1553 
1554  $end = new ilDate($_POST['event']['end']['date']['y'].'-'.$_POST['event']['end']['date']['m'].'-'.$_POST['event']['end']['date']['d'],
1555  IL_CAL_DATE);
1556  $this->object->getFirstAppointment()->setEnd($end);
1557  }
1558  else
1559  {
1560  $start_dt['year'] = (int) $_POST['event']['start']['date']['y'];
1561  $start_dt['mon'] = (int) $_POST['event']['start']['date']['m'];
1562  $start_dt['mday'] = (int) $_POST['event']['start']['date']['d'];
1563  $start_dt['hours'] = (int) $_POST['event']['start']['time']['h'];
1564  $start_dt['minutes'] = (int) $_POST['event']['start']['time']['m'];
1565 
1566  $start = new ilDateTime($start_dt,IL_CAL_FKT_GETDATE,$ilUser->getTimeZone());
1567  $this->object->getFirstAppointment()->setStart($start);
1568 
1569  $end_dt['year'] = (int) $_POST['event']['end']['date']['y'];
1570  $end_dt['mon'] = (int) $_POST['event']['end']['date']['m'];
1571  $end_dt['mday'] = (int) $_POST['event']['end']['date']['d'];
1572  $end_dt['hours'] = (int) $_POST['event']['end']['time']['h'];
1573  $end_dt['minutes'] = (int) $_POST['event']['end']['time']['m'];
1574  $end = new ilDateTime($end_dt,IL_CAL_FKT_GETDATE,$ilUser->getTimeZone());
1575  $this->object->getFirstAppointment()->setEnd($end);
1576  }
1577 
1578  $this->object->setTitle(ilUtil::stripSlashes($_POST['title']));
1579  $this->object->setDescription(ilUtil::stripSlashes($_POST['desc']));
1580  $this->object->setLocation(ilUtil::stripSlashes($_POST['location']));
1581  $this->object->setName(ilUtil::stripSlashes($_POST['tutor_name']));
1582  $this->object->setPhone(ilUtil::stripSlashes($_POST['tutor_phone']));
1583  $this->object->setEmail(ilUtil::stripSlashes($_POST['tutor_email']));
1584  $this->object->setDetails(ilUtil::stripSlashes($_POST['details']));
1585  $this->object->enableRegistration((int) $_POST['registration']);
1586  }
1587 
1594  protected function loadRecurrenceSettings()
1595  {
1596  include_once('./Modules/Session/classes/class.ilSessionRecurrence.php');
1597  $this->rec = new ilSessionRecurrence();
1598 
1599  switch($_POST['frequence'])
1600  {
1601  case IL_CAL_FREQ_DAILY:
1602  $this->rec->setFrequenceType($_POST['frequence']);
1603  $this->rec->setInterval((int) $_POST['count_DAILY']);
1604  break;
1605 
1606  case IL_CAL_FREQ_WEEKLY:
1607  $this->rec->setFrequenceType($_POST['frequence']);
1608  $this->rec->setInterval((int) $_POST['count_WEEKLY']);
1609  if(is_array($_POST['byday_WEEKLY']))
1610  {
1611  $this->rec->setBYDAY(ilUtil::stripSlashes(implode(',',$_POST['byday_WEEKLY'])));
1612  }
1613  break;
1614 
1615  case IL_CAL_FREQ_MONTHLY:
1616  $this->rec->setFrequenceType($_POST['frequence']);
1617  $this->rec->setInterval((int) $_POST['count_MONTHLY']);
1618  switch((int) $_POST['subtype_MONTHLY'])
1619  {
1620  case 0:
1621  // nothing to do;
1622  break;
1623 
1624  case 1:
1625  switch((int) $_POST['monthly_byday_day'])
1626  {
1627  case 8:
1628  // Weekday
1629  $this->rec->setBYSETPOS((int) $_POST['monthly_byday_num']);
1630  $this->rec->setBYDAY('MO,TU,WE,TH,FR');
1631  break;
1632 
1633  case 9:
1634  // Day of month
1635  $this->rec->setBYMONTHDAY((int) $_POST['monthly_byday_num']);
1636  break;
1637 
1638  default:
1639  $this->rec->setBYDAY((int) $_POST['monthly_byday_num'].$_POST['monthly_byday_day']);
1640  break;
1641  }
1642  break;
1643 
1644  case 2:
1645  $this->rec->setBYMONTHDAY((int) $_POST['monthly_bymonthday']);
1646  break;
1647  }
1648  break;
1649 
1650  case IL_CAL_FREQ_YEARLY:
1651  $this->rec->setFrequenceType($_POST['frequence']);
1652  $this->rec->setInterval((int) $_POST['count_YEARLY']);
1653  switch((int) $_POST['subtype_YEARLY'])
1654  {
1655  case 0:
1656  // nothing to do;
1657  break;
1658 
1659  case 1:
1660  $this->rec->setBYMONTH((int) $_POST['yearly_bymonth_byday']);
1661  $this->rec->setBYDAY((int) $_POST['yearly_byday_num'].$_POST['yearly_byday']);
1662  break;
1663 
1664  case 2:
1665  $this->rec->setBYMONTH((int) $_POST['yearly_bymonth_by_monthday']);
1666  $this->rec->setBYMONTHDAY((int) $_POST['yearly_bymonthday']);
1667  break;
1668  }
1669  break;
1670  }
1671 
1672  // UNTIL
1673  switch((int) $_POST['until_type'])
1674  {
1675  case 1:
1676  $this->rec->setFrequenceUntilDate(null);
1677  // nothing to do
1678  break;
1679 
1680  case 2:
1681  $this->rec->setFrequenceUntilDate(null);
1682  $this->rec->setFrequenceUntilCount((int) $_POST['count']);
1683  break;
1684 
1685  case 3:
1686  $end_dt['year'] = (int) $_POST['until_end']['date']['y'];
1687  $end_dt['mon'] = (int) $_POST['until_end']['date']['m'];
1688  $end_dt['mday'] = (int) $_POST['until_end']['date']['d'];
1689 
1690  $this->rec->setFrequenceUntilCount(0);
1691  $this->rec->setFrequenceUntilDate(new ilDate($end_dt,IL_CAL_FKT_GETDATE,$this->timezone));
1692  break;
1693  }
1694  }
1695 
1696 
1704  protected function __toUnix($date,$time)
1705  {
1706  return mktime($time['h'],$time['m'],0,$date['m'],$date['d'],$date['y']);
1707  }
1708 
1715  protected function formatPath($a_ref_id)
1716  {
1717  global $tree;
1718 
1719  $path = $this->lng->txt('path') . ': ';
1720  $first = true;
1721  foreach($tree->getPathFull($a_ref_id,$this->container_ref_id) as $node)
1722  {
1723  if($node['ref_id'] != $a_ref_id)
1724  {
1725  if(!$first)
1726  {
1727  $path .= ' -> ';
1728  }
1729  $first = false;
1730  $path .= $node['title'];
1731  }
1732  }
1733  return $path;
1734  }
1735 
1742  public function addLocatorItems()
1743  {
1744  global $ilLocator;
1745 
1746  if (is_object($this->object))
1747  {
1748  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
1749  }
1750  }
1751 
1758  public function getTabs($tabs_gui)
1759  {
1760  global $ilAccess, $ilTabs, $tree, $ilCtrl, $ilHelp;
1761 
1762  $ilHelp->setScreenIdComponent("sess");
1763 
1764  $parent_id = $tree->getParentId($this->object->getRefId());
1765 
1766  // #11650
1767  $parent_type = ilObject::_lookupType($parent_id, true);
1768 
1769  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $parent_id);
1770  $tabs_gui->setBackTarget($this->lng->txt('back_to_'.$parent_type.'_content'),
1771  $ilCtrl->getLinkTargetByClass("ilrepositorygui", ""));
1772  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
1773 
1774  $tabs_gui->addTarget('info_short',
1775  $this->ctrl->getLinkTarget($this,'infoScreen'));
1776 
1777  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
1778  {
1779  $tabs_gui->addTarget('settings',
1780  $this->ctrl->getLinkTarget($this,'edit'));
1781  $tabs_gui->addTarget('crs_materials',
1782  $this->ctrl->getLinkTarget($this,'materials'));
1783  $tabs_gui->addTarget('event_edit_members',
1784  $this->ctrl->getLinkTarget($this,'members'));
1785  }
1786 
1787  // export
1788  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
1789  {
1790  $ilTabs->addTarget("export",
1791  $this->ctrl->getLinkTargetByClass("ilexportgui", ""), "", "ilexportgui");
1792  }
1793 
1794 
1795  // edit permissions
1796  if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId()))
1797  {
1798  $tabs_gui->addTarget("perm_settings",
1799  $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"), array("perm","info","owner"), 'ilpermissiongui');
1800  }
1801 
1802  }
1803 
1809  public function afterSaveCallback(ilObject $a_obj)
1810  {
1811  // add new object to materials
1812  include_once './Modules/Session/classes/class.ilEventItems.php';
1813  $event_items = new ilEventItems($this->object->getId());
1814  $event_items->addItem($a_obj->getRefId());
1815  $event_items->update();
1816 
1817  /*
1818  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
1819  $this->ctrl->redirect($this, "materials");
1820  */
1821  }
1822 }
1823 ?>
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
getItems()
get assigned items
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 sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _lookupName($a_user_id)
lookup user name
loadRecurrenceSettings()
load recurrence settings
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
print $file
const IL_CAL_FREQ_MONTHLY
createRecurringSessions()
create recurring sessions
exit
Definition: login.php:54
eventsListObject()
list sessions of all user
Class ilInfoScreenGUI.
$_POST['username']
Definition: cron.php:12
static getItemsByEvent($a_event_id)
Get session material / event items.
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
afterSaveCallback(ilObject $a_obj)
Custom callback after object is created (in parent containert.
initForm($a_mode)
Init Form.
registerObject()
register to session
This class represents a property form user interface.
GUI class for the workflow of copying objects.
updateMembersObject()
update participants
membersObject()
Show participants table.
$_GET["client_id"]
$location
Definition: buildRTE.php:44
This class represents a section header in a property form.
saveMaterialsObject()
save material assignment
updateObject()
update object
This class represents an input GUI for recurring events/appointments (course events or calendar appoi...
Class ilObject Basic functions for all objects.
static formatPeriod(ilDateTime $start, ilDateTime $end)
Format a period of two date Shows: 14.
This class represents a file wizard property in a property form.
__showButton($a_cmd, $a_text, $a_target='')
$cmd
Definition: sahs_server.php:35
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
setValue($a_value)
Set Value.
This class represents a checkbox property in a property form.
static setUseRelativeDates($a_status)
set use relative dates
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually...
createObject()
create new object form
Class ilTableGUI.
_unregister($a_usr_id, $a_event_id)
const IL_CAL_UNIX
static addToDesktop()
Add desktop item public.
class ilEvent
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
_register($a_usr_id, $a_event_id)
executeCommand()
execute command
allowUnlimitedRecurrences($a_status)
Allow unlimited recurrences.
static _isRegistered($a_usr_id, $a_event_id)
Base class for attendance lists.
static _goto($a_target)
goto
global $ilCtrl
Definition: ilias.php:18
getAttendanceListUserData($a_user_id, $a_filters)
Get user data for attendance list.
setShowHidePrefs()
set preferences (show/hide tabel content)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$section
Definition: Utf8Test.php:84
calculateDateList(ilDateTime $a_start, ilDateTime $a_end, $a_limit=-1)
calculate date list
addLocatorItems()
Add session locator.
setChecked($a_checked)
Set Checked.
Export User Interface Class.
input GUI for a time span (start and end date)
__toUnix($date, $time)
protected
Class for single dates.
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,7),&#39;usr_data&#39;,&#39;lastname&#39;,&#39;usr_id&#39;) => sorts by lastname.
Calculates an ilDateList for a given calendar entry and recurrence rule.
static _gotoRepositoryNode($a_ref_id, $a_cmd="frameset")
Goto repository root.
__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output=true)
Constructor.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
const IL_CAL_FREQ_DAILY
Model of calendar entry recurrcences.
saveObject()
save object
const IL_CAL_FREQ_YEARLY
Class ilObjectGUI Basic methods of all Output classes.
static _lookupObjId($a_id)
initContainer($a_init_participants=false)
Class ilObjFile.
This class represents a text property in a property form.
static initDomEvent()
Init YUI DomEvent.
Date and time handling
_lookupLogin($a_user_id)
lookup login
saveObject($a_redirect_on_success=true)
save object
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static addListGUIActivationProperty(ilObjectListGUI $a_list_gui, array &$a_item)
Get timing details for list gui.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
setStartText($a_txt)
Set text, which will be shown before the start date.
const IL_CAL_FKT_GETDATE
deleteFilesObject()
delete files
materialsObject()
show material assignment
_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.
static removeFromDesktop()
Remove item from personal desktop public.
const IL_CAL_DATE
joinObject()
Called from info screen.
global $ilUser
Definition: imgupload.php:15
Interface for gui classes (e.g ilLuceneSearchGUI) that offer add/remove to/from desktop.
formatPath($a_ref_id)
format path
Render add new item selector.
$path
Definition: index.php:22
This class represents a text area property in a property form.
static switchColor($a_num, $a_css1, $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows) ...
getTabs($tabs_gui)
Build tabs.
getCreationMode()
get creation mode
getRefId()
get reference id public
modifyItemGUI($a_item_list_gui, $a_item_data, $a_show_path)
Modify Item ListGUI for presentation in container.
confirmDeleteFilesObject()
confirm delete files
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
static _getInstance($a_obj_id)
get instance by obj_id
addItem($a_item_ref_id)
Add one item.
setValue($a_value)
Set Value.
initAttendanceList()
Init attendance list object.
addHeaderAction()
Add header action menu.
static factory($a_type)
Get list gui by type This method caches all the returned list guis.
attendanceListObject()
show attendance list selection
saveAndAssignMaterialsObject()
Save and assign sessoin materials.
unregisterObject()
unregister from session
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
const IL_CAL_FREQ_WEEKLY
static formCheckbox($checked, $varname, $value, $disabled=false)
??? public
printAttendanceListObject()
print attendance list
class ilEvent
const IL_CAL_YEAR
Confirmation screen class.