ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
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('./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 $course_ref_id = 0;
28  protected $course_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 'ilcourseitemadministrationgui':
86  include_once 'Modules/Course/classes/class.ilCourseItemAdministrationGUI.php';
87  $this->tabs_gui->clearSubTabs();
88  $this->ctrl->setReturn($this,'info');
89  $item_adm_gui = new ilCourseItemAdministrationGUI($this->object,(int) $_REQUEST['item_id']);
90  $this->ctrl->forwardCommand($item_adm_gui);
91  break;
92 
93  case 'ilobjectcopygui':
94  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
95  $cp = new ilObjectCopyGUI($this);
96  $cp->setType('sess');
97  $this->ctrl->forwardCommand($cp);
98  break;
99 
100  case "ilexportgui":
101 // $this->prepareOutput();
102  $this->tabs_gui->setTabActive("export");
103  include_once("./Services/Export/classes/class.ilExportGUI.php");
104  $exp_gui = new ilExportGUI($this);
105  $exp_gui->addFormat("xml");
106  $ret = $this->ctrl->forwardCommand($exp_gui);
107 // $this->tpl->show();
108  break;
109 
110 
111  default:
112  if(!$cmd)
113  {
114  $cmd = "infoScreen";
115  }
116  $cmd .= "Object";
117  if ($cmd != "infoScreenObject")
118  {
119  $this->checkPermission("read");
120  }
121  else
122  {
123  $this->checkPermission("visible");
124  }
125  $this->$cmd();
126 
127  break;
128  }
129  return true;
130  }
131 
135  protected function prepareOutput()
136  {
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  include_once './Modules/Session/classes/class.ilEventParticipants.php';
178 
179  if(ilEventParticipants::_isRegistered($ilUser->getId(),$this->object->getId()))
180  {
181  $_SESSION['sess_hide_info'] = true;
182  ilEventParticipants::_unregister($ilUser->getId(),$this->object->getId());
183  ilUtil::sendSuccess($this->lng->txt('event_unregistered'),true);
184  }
185  else
186  {
187  ilEventParticipants::_register($ilUser->getId(),$this->object->getId());
188  ilUtil::sendSuccess($this->lng->txt('event_registered'),true);
189  }
190 
191  $this->ctrl->redirect($this,'infoScreen');
192  }
193 
200  public function unregisterObject()
201  {
202  global $ilUser;
203 
204  include_once './Modules/Session/classes/class.ilEventParticipants.php';
205  ilEventParticipants::_unregister($ilUser->getId(),$this->object->getId());
206 
207  ilUtil::sendSuccess($this->lng->txt('event_unregistered'),true);
208  $this->ctrl->returnToParent($this);
209  }
210 
219  public static function _goto($a_target)
220  {
221  global $ilAccess,$ilErr,$lng;
222 
223  if($ilAccess->checkAccess('visible', "", $a_target))
224  {
225  $_GET["cmd"] = "infoScreen";
226  $_GET["ref_id"] = $a_target;
227  include("repository.php");
228  exit;
229  }
230  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
231  }
232 
236  public function addToDeskObject()
237  {
238  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
240  $this->infoScreenObject();
241  }
242 
246  public function removeFromDeskObject()
247  {
248  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
250  $this->infoScreenObject();
251  }
252 
253 
259  public function infoScreenObject()
260  {
261  $this->ctrl->setCmd("showSummary");
262  $this->ctrl->setCmdClass("ilinfoscreengui");
263  $this->infoScreen();
264  }
265 
269  function modifyItemGUI($a_item_list_gui,$a_item_data, $a_show_path)
270  {
271  global $tree;
272 
273  // if folder is in a course, modify item list gui according to course requirements
274  if ($course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs'))
275  {
276  include_once("./Modules/Course/classes/class.ilObjCourse.php");
277  include_once("./Modules/Course/classes/class.ilObjCourseGUI.php");
280  $a_item_list_gui,
281  get_class($this),
282  $a_item_data,
283  $a_show_path,
287  $this->object->getRefId());
288  }
289  }
290 
298  public function infoScreen()
299  {
300  global $ilAccess, $ilUser,$ilCtrl,$tree,$ilToolbar;
301 
302  $this->checkPermission('visible');
303  $this->tabs_gui->setTabActive('info_short');
304 
305  $appointment_obj = $this->object->getFirstAppointment();
306 
307  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
308  $info = new ilInfoScreenGUI($this);
309 
310  if($this->object->enabledRegistration())
311  {
312  include_once './Modules/Session/classes/class.ilEventParticipants.php';
313  if(ilEventParticipants::_isRegistered($ilUser->getId(), $this->object->getId()))
314  {
315  $ilToolbar->addFormButton($this->lng->txt('event_unregister'),'join');
316  }
317  else
318  {
319  if(!isset($_SESSION['sess_hide_info']))
320  {
321  ilUtil::sendInfo($this->lng->txt('sess_join_info'));
322  }
323  $ilToolbar->addFormButton($this->lng->txt('join_session'),'join');
324  }
325  $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
326  }
327 
328  // Session information
329  if(strlen($this->object->getLocation()) or strlen($this->object->getDetails()))
330  {
331  $info->addSection($this->lng->txt('event_section_information'));
332  }
333  if(strlen($location = $this->object->getLocation()))
334  {
335  $info->addProperty($this->lng->txt('event_location'),
336  nl2br($this->object->getLocation()));
337  }
338  if(strlen($this->object->getDetails()))
339  {
340  $info->addProperty($this->lng->txt('event_details_workflow'),
341  nl2br($this->object->getDetails()));
342  }
343 
344  // Tutor information
345  if($this->object->hasTutorSettings())
346  {
347  $info->addSection($this->lng->txt('event_tutor_data'));
348  if(strlen($fullname = $this->object->getName()))
349  {
350  $info->addProperty($this->lng->txt('event_lecturer'),
351  $fullname);
352  }
353  if(strlen($email = $this->object->getEmail()))
354  {
355  $info->addProperty($this->lng->txt('tutor_email'),
356  $email);
357  }
358  if(strlen($phone = $this->object->getPhone()))
359  {
360  $info->addProperty($this->lng->txt('tutor_phone'),
361  $phone);
362  }
363  }
364 
365  include_once './Modules/Session/classes/class.ilSessionObjectListGUIFactory.php';
366  include_once './Modules/Session/classes/class.ilEventItems.php';
367  include_once './Modules/Course/classes/class.ilCourseItems.php';
368 
369  $html = '';
370  $eventItems = new ilEventItems($this->object->getId());
371 
372  $parent_id = $tree->getParentId($this->object->getRefId());
373  $items = new ilCourseItems($parent_id);
374  $eventItems = $items->getItemsByEvent($this->object->getId());
375  include_once './Services/Container/classes/class.ilContainerSorting.php';
376  $eventItems = ilContainerSorting::_getInstance(
377  ilObject::_lookupObjId($parent_id))->sortSubItems(
378  'sess',
379  $this->object->getId(),
380  $eventItems
381  );
382 
383  foreach($eventItems as $item)
384  {
385  $item_id = $item['ref_id'];
386  $obj_id = ilObject::_lookupObjId($item_id);
388 
389 
390  $list_gui = ilSessionObjectListGUIFactory::factory($type);
391  $list_gui->setContainerObject($this);
392  $this->modifyItemGUI($list_gui, ilCourseItems::_getItem($item_id),false);
393 
394  $html .= $list_gui->getListItemHTML(
395  $item_id,
396  $obj_id,
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 
440  public function createObject()
441  {
442  if(!is_object($this->object))
443  {
444  $this->object = new ilObjSession();
445  }
446  $this->ctrl->setParameter($this,'new_type','sess');
447  $this->initForm('create');
448  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.sess_create.html','Modules/Session');
449  $this->tpl->setVariable('EVENT_ADD_TABLE',$this->form->getHTML());
450  $this->fillCloneTemplate('DUPLICATE','sess');
451 
452  $this->initImportForm("sess");
453  $this->tpl->setVariable("IMPORT", $this->form->getHTML());
454 
455  }
456 
462  public function initImportForm($a_new_type = "")
463  {
464  global $lng, $ilCtrl;
465 
466  $lng->loadLanguageModule("sess");
467 
468  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
469  $this->form = new ilPropertyFormGUI();
470  $this->form->setTableWidth('600px');
471  $this->form->setTarget("_top");
472 
473  // Import file
474  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
475  $fi = new ilFileInputGUI($lng->txt("import_file"), "importfile");
476  $fi->setSuffixes(array("zip"));
477  $fi->setRequired(true);
478  $this->form->addItem($fi);
479 
480  $this->form->addCommandButton("importFile", $lng->txt("import"));
481  $this->form->addCommandButton("cancel", $lng->txt("cancel"));
482  $this->form->setTitle($lng->txt($a_new_type."_import"));
483 
484  $this->form->setFormAction($ilCtrl->getFormAction($this));
485  }
486 
492  function importFileObject()
493  {
494  global $rbacsystem, $objDefinition, $tpl, $lng;
495 
496  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
497 
498  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
499  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
500  {
501  $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->MESSAGE);
502  }
503  $this->ctrl->setParameter($this, "new_type", $new_type);
504  $this->initImportForm($new_type);
505  if ($this->form->checkInput())
506  {
507  // todo: make some check on manifest file
508  include_once("./Services/Export/classes/class.ilImport.php");
509  $imp = new ilImport((int) $_GET['ref_id']);
510  $new_id = $imp->importObject($newObj, $_FILES["importfile"]["tmp_name"],
511  $_FILES["importfile"]["name"], $new_type);
512  // put new object id into tree
513  if ($new_id > 0)
514  {
515  $newObj = ilObjectFactory::getInstanceByObjId($new_id);
516  $newObj->createReference();
517  $newObj->putInTree($_GET["ref_id"]);
518  $newObj->setPermissions($_GET["ref_id"]);
519  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
520  //$this->afterSave($newObj);
521  $this->ctrl->returnToParent($this);
522  }
523  return;
524  }
525 
526  $this->form->setValuesByPost();
527  $tpl->setContent($this->form->getHtml());
528  }
529 
536  {
537  global $ilLog;
538 
539  $this->saveObject(false);
540 
541  /*
542  $this->ctrl->setParameter($this,'ref_id',$this->object->getRefId());
543  $target = $this->ctrl->getLinkTarget($this,'materials');
544  $target = str_replace('new_type=','nt=',$target);
545  */
546  $this->ctrl->setParameter($this,'ref_id',$this->object->getRefId());
547  $this->ctrl->redirect($this,'materials');
548  }
549 
550 
558  public function saveObject($a_redirect_on_success = true)
559  {
560  global $ilErr,$ilUser;
561 
562  $this->object = new ilObjSession();
563 
564  $this->load();
565  $this->loadRecurrenceSettings();
566  $this->initForm('create');
567 
568  $ilErr->setMessage('');
569  if(!$this->form->checkInput()) {
570  $ilErr->setMessage($this->lng->txt('err_check_input'));
571  }
572 
573  $this->object->validate();
574  $this->object->getFirstAppointment()->validate();
575 
576  if(strlen($ilErr->getMessage()))
577  {
578  ilUtil::sendFailure($ilErr->getMessage().$_GET['ref_id']);
579  $this->createObject();
580  return false;
581  }
582  // Create session
583  $this->object->create();
584  $this->object->createReference();
585  $this->object->putInTree($_GET["ref_id"]);
586  $this->object->setPermissions($_GET["ref_id"]);
587 
588  // create appointment
589  $this->object->getFirstAppointment()->setSessionId($this->object->getId());
590  $this->object->getFirstAppointment()->create();
591 
592  $this->handleFileUpload();
593 
594  $this->createRecurringSessions();
595 
596  // call crs items for creating a new entry for the new session
597  // Otherwise the sorting of sessions is wrong.
598  // TODO find a better solution
599  include_once './Modules/Course/classes/class.ilCourseItems.php';
600  $tmp_course = ilObjectFactory::getInstanceByRefId((int) $_GET['ref_id'],false);
601  $items = new ilCourseItems($tmp_course->getRefId());
602 
603  if($a_redirect_on_success)
604  {
605  ilUtil::sendInfo($this->lng->txt('event_add_new_event'),true);
606  $this->ctrl->returnToParent($this);
607  }
608 
609  return true;
610 
611  }
612 
613  public function handleFileUpload()
614  {
615  global $tree;
616 
617  include_once './Modules/Session/classes/class.ilEventItems.php';
618  $ev = new ilEventItems($this->object->getId());
619  $items = $ev->getItems();
620 
621  $counter = 0;
622  while(true)
623  {
624  if(!isset($_FILES['files']['name'][$counter]))
625  {
626  break;
627  }
628  if(!strlen($_FILES['files']['name'][$counter]))
629  {
630  $counter++;
631  continue;
632  }
633 
634  include_once './Modules/File/classes/class.ilObjFile.php';
635  $file = new ilObjFile();
636  $file->setTitle(ilUtil::stripSlashes($_FILES['files']['name'][$counter]));
637  $file->setDescription('');
638  $file->setFileName(ilUtil::stripSlashes($_FILES['files']['name'][$counter]));
639  $file->setFileType($_FILES['files']['type'][$counter]);
640  $file->setFileSize($_FILES['files']['size'][$counter]);
641  $file->create();
642  $new_ref_id = $file->createReference();
643  $file->putInTree($tree->getParentId($this->object->getRefId()));
644  $file->setPermissions($tree->getParentId($this->object->getRefId()));
645  $file->createDirectory();
646  $file->getUploadFile(
647  $_FILES['files']['tmp_name'][$counter],
648  $_FILES['files']['name'][$counter]
649  );
650 
651  $items[] = $new_ref_id;
652  $counter++;
653 
654  }
655 
656  $ev->setItems($items);
657  $ev->update();
658  }
659 
660 
661 
669  protected function createRecurringSessions()
670  {
671  global $tree;
672 
673  if(!$this->rec->getFrequenceType())
674  {
675  return true;
676  }
677  include_once('./Services/Calendar/classes/class.ilCalendarRecurrenceCalculator.php');
678  $calc = new ilCalendarRecurrenceCalculator($this->object->getFirstAppointment(),$this->rec);
679 
680  $period_start = clone $this->object->getFirstAppointment()->getStart();
681 
682 
683  $period_end = clone $this->object->getFirstAppointment()->getStart();
684  $period_end->increment(IL_CAL_YEAR,5);
685  $date_list = $calc->calculateDateList($period_start,$period_end);
686 
687  $period_diff = $this->object->getFirstAppointment()->getEnd()->get(IL_CAL_UNIX) -
688  $this->object->getFirstAppointment()->getStart()->get(IL_CAL_UNIX);
689  $parent_id = $tree->getParentId($this->object->getRefId());
690 
691  include_once './Modules/Session/classes/class.ilEventItems.php';
692  $evi = new ilEventItems($this->object->getId());
693  $eitems = $evi->getItems();
694 
695  $counter = 0;
696  foreach($date_list->get() as $date)
697  {
698  if(!$counter++)
699  {
700  continue;
701  }
702 
703  $new_obj = $this->object->cloneObject($parent_id);
704  $new_obj->read();
705  $new_obj->getFirstAppointment()->setStartingTime($date->get(IL_CAL_UNIX));
706  $new_obj->getFirstAppointment()->setEndingTime($date->get(IL_CAL_UNIX) + $period_diff);
707  $new_obj->getFirstAppointment()->update();
708  $new_obj->update();
709 
710  $new_evi = new ilEventItems($new_obj->getId());
711  $new_evi->setItems($eitems);
712  $new_evi->update();
713  }
714  }
715 
716 
724  public function editObject()
725  {
726  $this->tabs_gui->setTabActive('edit_properties');
727 
728  $this->initForm('edit');
729  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.sess_edit.html','Modules/Session');
730  $this->tpl->setVariable('EVENT_EDIT_TABLE',$this->form->getHTML());
731 
732  if(!count($this->object->getFiles()))
733  {
734  return true;
735  }
736  $rows = array();
737  foreach($this->object->getFiles() as $file)
738  {
739  $table_data['id'] = $file->getFileId();
740  $table_data['filename'] = $file->getFileName();
741  $table_data['filetype'] = $file->getFileType();
742  $table_data['filesize'] = $file->getFileSize();
743 
744  $rows[] = $table_data;
745  }
746 
747  include_once("./Modules/Session/classes/class.ilSessionFileTableGUI.php");
748  $table_gui = new ilSessionFileTableGUI($this, "edit");
749  $table_gui->setTitle($this->lng->txt("event_files"));
750  $table_gui->setData($rows);
751  $table_gui->addCommandButton("cancel", $this->lng->txt("cancel"));
752  $table_gui->addMultiCommand("confirmDeleteFiles", $this->lng->txt("delete"));
753  $table_gui->setSelectAllCheckbox("file_id");
754  $this->tpl->setVariable('EVENT_FILE_TABLE',$table_gui->getHTML());
755 
756  return true;
757  }
758 
766  public function updateObject()
767  {
768  global $ilErr;
769 
770  $this->load();
771  $this->initForm('edit');
772 
773  $ilErr->setMessage('');
774  if(!$this->form->checkInput())
775  {
776  $ilErr->setMessage($this->lng->txt('err_check_input'));
777  }
778  $this->object->validate();
779  $this->object->getFirstAppointment()->validate();
780 
781  if(strlen($ilErr->getMessage()))
782  {
783  ilUtil::sendFailure($ilErr->getMessage());
784  $this->editObject();
785  return false;
786  }
787  // Update event
788  $this->object->update();
789  $this->object->getFirstAppointment()->update();
790 
791  $this->handleFileUpload();
792 
793  ilUtil::sendSuccess($this->lng->txt('event_updated'),true);
794  $this->ctrl->redirect($this,'edit');
795  #$this->object->initFiles();
796  #$this->editObject();
797  return true;
798  }
799 
807  public function confirmDeleteFilesObject()
808  {
809  $this->tabs_gui->setTabActive('edit_properties');
810 
811  if(!count($_POST['file_id']))
812  {
813  ilUtil::sendFailure($this->lng->txt('select_one'));
814  $this->editObject();
815  return false;
816  }
817 
818  include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
819  $c_gui = new ilConfirmationGUI();
820 
821  // set confirm/cancel commands
822  $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteFiles"));
823  $c_gui->setHeaderText($this->lng->txt("info_delete_sure"));
824  $c_gui->setCancel($this->lng->txt("cancel"), "edit");
825  $c_gui->setConfirm($this->lng->txt("confirm"), "deleteFiles");
826 
827  // add items to delete
828  foreach($_POST["file_id"] as $file_id)
829  {
830  $file = new ilSessionFile($file_id);
831  if($file->getSessionId() != $this->object->getEventId())
832  {
833  ilUtil::sendFailure($this->lng->txt('select_one'));
834  $this->edit();
835  return false;
836  }
837  $c_gui->addItem("file_id[]", $file_id, $file->getFileName());
838  }
839 
840  $this->tpl->setContent($c_gui->getHTML());
841  return true;
842  }
843 
851  public function deleteFilesObject()
852  {
853  if(!count($_POST['file_id']))
854  {
855  ilUtil::sendFailure($this->lng->txt('select_one'));
856  $this->editObject();
857  return false;
858  }
859  foreach($_POST['file_id'] as $id)
860  {
861  $file = new ilSessionFile($id);
862  $file->delete();
863  }
864  $this->object->initFiles();
865  $this->editObject();
866  return true;
867  }
868 
876  public function materialsObject()
877  {
878  global $tree, $objDefinition;
879 
880  $this->tabs_gui->setTabActive('crs_materials');
881 
882  include_once 'Modules/Session/classes/class.ilEventItems.php';
883  $this->event_items = new ilEventItems($this->object->getId());
884  $items = $this->event_items->getItems();
885 
886  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.sess_materials.html','Modules/Session');
887  #$this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
888 
889  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this,'materials'));
890  $this->tpl->setVariable("COLL_TITLE_IMG",ilUtil::getImagePath('icon_sess.gif'));
891  $this->tpl->setVariable("COLL_TITLE_IMG_ALT",$this->lng->txt('events'));
892  $this->tpl->setVariable("TABLE_TITLE",$this->lng->txt('event_assign_materials_table'));
893  $this->tpl->setVariable("TABLE_INFO",$this->lng->txt('event_assign_materials_info'));
894 
895  $this->course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs');
896  if(!$this->course_ref_id)
897  {
898  ilUtil::sendFailure('No course object found. Aborting');
899  return true;
900  }
901  $nodes = $tree->getSubTree($tree->getNodeData($this->course_ref_id));
902  $counter = 1;
903  foreach($nodes as $node)
904  {
905  // No side blocks here
906  if ($objDefinition->isSideBlock($node['type']) or $node['type'] == 'sess')
907  {
908  continue;
909  }
910 
911  if($node['type'] == 'rolf')
912  {
913  continue;
914  }
915  if($counter++ == 1)
916  {
917  continue;
918  }
919  $this->tpl->setCurrentBlock("material_row");
920 
921  $this->tpl->setVariable('TYPE_IMG',ilUtil::getImagePath('icon_'.$node['type'].'_s.gif'));
922  $this->tpl->setVariable('IMG_ALT',$this->lng->txt('obj_'.$node['type']));
923  $this->tpl->setVariable("ROW_CLASS",ilUtil::switchColor($counter,'tblrow1','tblrow2'));
924  $this->tpl->setVariable("CHECK_COLL",ilUtil::formCheckbox(in_array($node['ref_id'],$items) ? 1 : 0,
925  'items[]',$node['ref_id']));
926  $this->tpl->setVariable("COLL_TITLE",$node['title']);
927 
928  if(strlen($node['description']))
929  {
930  $this->tpl->setVariable("COLL_DESC",$node['description']);
931  }
932  $this->tpl->setVariable("ASSIGNED_IMG_OK",in_array($node['ref_id'],$items) ?
933  ilUtil::getImagePath('icon_ok.gif') :
934  ilUtil::getImagePath('icon_not_ok.gif'));
935  $this->tpl->setVariable("ASSIGNED_STATUS",$this->lng->txt('event_material_assigned'));
936  $this->tpl->setVariable("COLL_PATH",$this->formatPath($node['ref_id']));
937  $this->tpl->parseCurrentBlock();
938  }
939 
940  $this->tpl->setVariable("SELECT_ROW",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
941  $this->tpl->setVariable("SELECT_ALL",$this->lng->txt('select_all'));
942  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
943  $this->tpl->setVariable("BTN_SAVE",$this->lng->txt('save'));
944  }
945 
953  public function saveMaterialsObject()
954  {
955  include_once './Modules/Session/classes/class.ilEventItems.php';
956 
957  $this->event_items = new ilEventItems($this->object->getId());
958  $this->event_items->setItems(is_array($_POST['items']) ? $_POST['items'] : array());
959  $this->event_items->update();
960 
961  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
962  $this->materialsObject();
963  }
964 
969  protected function membersObject()
970  {
971  global $tree,$ilUser;
972 
973  $this->checkPermission('write');
974  $this->tabs_gui->setTabActive('event_edit_members');
975 
976  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.sess_members.html', 'Modules/Session');
977 
978  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
979  $toolbar = new ilToolbarGUI();
980  $toolbar->addButton(
981  $this->lng->txt('print'),
982  $this->ctrl->getLinkTarget($this,'printViewMembers'),
983  '_blank');
984  $toolbar->addButton($this->lng->txt('sess_gen_attendance_list'),
985  $this->ctrl->getLinkTarget($this,'attendanceList'));
986 
987  $this->tpl->setVariable('ACTION_BUTTONS',$toolbar->getHTML());
988 
989  $this->course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs');
990  $this->course_obj_id = ilObject::_lookupObjId($this->course_ref_id);
991  if(!$this->course_ref_id)
992  {
993  ilUtil::sendFailure('No course object found. Aborting');
994  return true;
995  }
996 
997  include_once './Modules/Course/classes/class.ilCourseParticipants.php';
998  include_once './Modules/Session/classes/class.ilEventParticipants.php';
999 
1000  $members_obj = ilCourseParticipants::_getInstanceByObjId($this->course_obj_id);
1001  $event_part = new ilEventParticipants($this->object->getId());
1002 
1003  // Save hide/show table settings
1004  $this->setShowHidePrefs();
1005 
1006  // Admins
1007  if(count($admins = $members_obj->getAdmins()))
1008  {
1009  include_once('./Modules/Session/classes/class.ilSessionParticipantsTableGUI.php');
1010  if($ilUser->getPref('sess_admin_hide'))
1011  {
1013  $this->ctrl->setParameter($this,'admin_hide',0);
1014  $table->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1015  $this->lng->txt('show'),
1016  '',
1017  ilUtil::getImagePath('edit_add.png'));
1018  $this->ctrl->clearParameters($this);
1019  }
1020  else
1021  {
1023  $this->ctrl->setParameter($this,'admin_hide',1);
1024  $table->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1025  $this->lng->txt('hide'),
1026  '',
1027  ilUtil::getImagePath('edit_remove.png'));
1028  $this->ctrl->clearParameters($this);
1029  }
1030 
1031  $table->addCommandButton('updateMembers',$this->lng->txt('save'));
1032  $table->setTitle($this->lng->txt('event_tbl_admins'),'icon_usr.gif',$this->lng->txt('event_tbl_admins'));
1033  $table->enableRegistration($this->object->enabledRegistration());
1034  $table->setParticipants($admins);
1035  $table->parse();
1036  $this->tpl->setVariable('ADMINS',$table->getHTML());
1037  }
1038 
1039  // Tutors
1040  if(count($tutors = $members_obj->getTutors()))
1041  {
1042  include_once('./Modules/Session/classes/class.ilSessionParticipantsTableGUI.php');
1043  if($ilUser->getPref('sess_tutor_hide'))
1044  {
1046  $this->ctrl->setParameter($this,'tutor_hide',0);
1047  $table->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1048  $this->lng->txt('show'),
1049  '',
1050  ilUtil::getImagePath('edit_add.png'));
1051  $this->ctrl->clearParameters($this);
1052  }
1053  else
1054  {
1056  $this->ctrl->setParameter($this,'tutor_hide',1);
1057  $table->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1058  $this->lng->txt('hide'),
1059  '',
1060  ilUtil::getImagePath('edit_remove.png'));
1061  $this->ctrl->clearParameters($this);
1062  }
1063  $table->addCommandButton('updateMembers',$this->lng->txt('save'));
1064  $table->setTitle($this->lng->txt('event_tbl_tutors'),'icon_usr.gif',$this->lng->txt('event_tbl_admins'));
1065  $table->enableRegistration($this->object->enabledRegistration());
1066  $table->setParticipants($tutors);
1067  $table->parse();
1068  $this->tpl->setVariable('TUTORS',$table->getHTML());
1069  }
1070 
1071  // Members
1072  if(count($members = $members_obj->getMembers()))
1073  {
1074  include_once('./Modules/Session/classes/class.ilSessionParticipantsTableGUI.php');
1075  if($ilUser->getPref('sess_member_hide'))
1076  {
1078  $this->ctrl->setParameter($this,'member_hide',0);
1079  $table->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1080  $this->lng->txt('show'),
1081  '',
1082  ilUtil::getImagePath('edit_add.png'));
1083  $this->ctrl->clearParameters($this);
1084  }
1085  else
1086  {
1088  $this->ctrl->setParameter($this,'member_hide',1);
1089  $table->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1090  $this->lng->txt('hide'),
1091  '',
1092  ilUtil::getImagePath('edit_remove.png'));
1093  $this->ctrl->clearParameters($this);
1094  }
1095  $table->addCommandButton('updateMembers',$this->lng->txt('save'));
1096  $table->setTitle($this->lng->txt('event_tbl_members'),'icon_usr.gif',$this->lng->txt('event_tbl_admins'));
1097  $table->enableRegistration($this->object->enabledRegistration());
1098  $table->setParticipants($members);
1099  $table->parse();
1100  $this->tpl->setVariable('MEMBERS',$table->getHTML());
1101  }
1102 
1103 
1104 
1105 
1106 
1107  }
1108 
1115  public function setShowHidePrefs()
1116  {
1117  global $ilUser;
1118 
1119  if(isset($_GET['admin_hide']))
1120  {
1121  $ilUser->writePref('sess_admin_hide',(int) $_GET['admin_hide']);
1122  }
1123  if(isset($_GET['tutor_hide']))
1124  {
1125  $ilUser->writePref('sess_tutor_hide',(int) $_GET['tutor_hide']);
1126  }
1127  if(isset($_GET['member_hide']))
1128  {
1129  $ilUser->writePref('sess_member_hide',(int) $_GET['member_hide']);
1130  }
1131  }
1132 
1140  public function updateMembersObject()
1141  {
1142  global $tree;
1143 
1144  $this->checkPermission('write');
1145 
1146  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
1147  include_once 'Modules/Session/classes/class.ilEventParticipants.php';
1148 
1149  $this->course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs');
1150  $this->course_obj_id = ilObject::_lookupObjId($this->course_ref_id);
1151  if(!$this->course_ref_id)
1152  {
1153  ilUtil::sendFailure('No course object found. Aborting');
1154  return true;
1155  }
1156 
1157  $_POST['participants'] = is_array($_POST['participants']) ? $_POST['participants'] : array();
1158 
1159  $members_obj = ilCourseParticipants::_getInstanceByObjId($this->course_obj_id);
1160  $event_part = new ilEventParticipants($this->object->getId());
1161 
1162  $visible = $_POST['visible_participants'] ? $_POST['visible_participants'] : array();
1163  foreach($visible as $user)
1164  {
1165  $part = new ilEventParticipants($this->object->getId());
1166  $part->setUserId($user);
1167  $part->setMark(ilUtil::stripSlashes($_POST['mark'][$user]));
1168  $part->setComment(ilUtil::stripSlashes($_POST['comment'][$user]));
1169  $part->setParticipated(isset($_POST['participants'][$user]) ? true : false);
1170  $part->setRegistered(ilEventParticipants::_isRegistered($user,$this->object->getId()));
1171  $part->updateUser();
1172  }
1173  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
1174  $this->membersObject();
1175  }
1176 
1183  public function attendanceListObject()
1184  {
1185  global $tpl,$ilTabs;
1186 
1187  $this->checkPermission('write');
1188 
1189  $ilTabs->setTabActive('event_edit_members');
1190 
1191  $this->initAttendanceForm();
1192  $tpl->setContent($this->form->getHTML());
1193 
1194  }
1195 
1202  protected function initAttendanceForm()
1203  {
1204  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
1205 
1206  $this->form = new ilPropertyFormGUI();
1207  $this->form->setFormAction($this->ctrl->getFormAction($this));
1208  $this->form->setTarget('_blank');
1209  $this->form->setTitle($this->lng->txt('sess_gen_attendance_list'));
1210 
1211  $mark = new ilCheckboxInputGUI($this->lng->txt('trac_mark'),'show_mark');
1212  $mark->setOptionTitle($this->lng->txt('sess_gen_mark_title'));
1213  $mark->setValue(1);
1214  $this->form->addItem($mark);
1215 
1216  $comment = new ilCheckboxInputGUI($this->lng->txt('trac_comment'),'show_comment');
1217  $comment->setOptionTitle($this->lng->txt('sess_gen_comment'));
1218  $comment->setValue(1);
1219  $this->form->addItem($comment);
1220 
1221  $signature = new ilCheckboxInputGUI($this->lng->txt('sess_signature'),'show_signature');
1222  $signature->setOptionTitle($this->lng->txt('sess_gen_signature'));
1223  $signature->setValue(1);
1224  $this->form->addItem($signature);
1225 
1226  $part = new ilFormSectionHeaderGUI();
1227  $part->setTitle($this->lng->txt('event_participant_selection'));
1228  $this->form->addItem($part);
1229 
1230  // Admins
1231  $admin = new ilCheckboxInputGUI($this->lng->txt('event_tbl_admins'),'show_admins');
1232  $admin->setOptionTitle($this->lng->txt('event_inc_admins'));
1233  $admin->setValue(1);
1234  $this->form->addItem($admin);
1235 
1236  // Tutors
1237  $tutor = new ilCheckboxInputGUI($this->lng->txt('event_tbl_tutors'),'show_tutors');
1238  $tutor->setOptionTitle($this->lng->txt('event_inc_tutors'));
1239  $tutor->setValue(1);
1240  $this->form->addItem($tutor);
1241 
1242  // Members
1243  $member = new ilCheckboxInputGUI($this->lng->txt('event_tbl_members'),'show_members');
1244  $member->setOptionTitle($this->lng->txt('event_inc_members'));
1245  $member->setValue(1);
1246  $member->setChecked(true);
1247  $this->form->addItem($member);
1248 
1249  $this->form->addCommandButton('printAttendanceList',$this->lng->txt('sess_print_attendance_list'));
1250  #$this->form->addCommandButton('members', $this->lng->txt('cancel'));
1251 
1252  }
1253 
1259  protected function printAttendanceListObject()
1260  {
1261  global $ilErr,$ilAccess,$tree;
1262 
1263  include_once 'Modules/Session/classes/class.ilEventParticipants.php';
1264  include_once('./Modules/Course/classes/class.ilCourseParticipants.php');
1265 
1266  $this->checkPermission('write');
1267 
1268  $this->course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs');
1269  $this->course_obj_id = ilObject::_lookupObjId($this->course_ref_id);
1270  if(!$this->course_ref_id)
1271  {
1272  ilUtil::sendFailure('No course object found. Aborting');
1273  return true;
1274  }
1275 
1276  $members_obj = ilCourseParticipants::_getInstanceByObjId($this->course_obj_id);
1277  $event_app = $this->object->getFirstAppointment();
1278  $event_part = new ilEventParticipants($this->object->getId());
1279 
1280 
1281  $this->tpl = new ilTemplate('tpl.main.html',true,true);
1282  // load style sheet depending on user's settings
1283  $location_stylesheet = ilUtil::getStyleSheetLocation();
1284  $this->tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
1285 
1286  $tpl = new ilTemplate('tpl.sess_attendance_list_print.html',true,true,'Modules/Session');
1287 
1288  $tpl->setVariable("ATTENDANCE_LIST",$this->lng->txt('sess_attendance_list'));
1289  $tpl->setVariable("EVENT_NAME",$this->object->getTitle() ? ': '.$this->object->getTitle() : '');
1291  $tpl->setVariable("DATE",ilDatePresentation::formatPeriod($event_app->getStart(),$event_app->getEnd()));
1293 
1294  $tpl->setVariable("TXT_NAME",$this->lng->txt('name'));
1295  if($_POST['show_mark'])
1296  {
1297  $tpl->setVariable("TXT_MARK",$this->lng->txt('trac_mark'));
1298  }
1299  if($_POST['show_comment'])
1300  {
1301  $tpl->setVariable("TXT_COMMENT",$this->lng->txt('trac_comment'));
1302  }
1303  if($_POST['show_signature'])
1304  {
1305  $tpl->setVariable("TXT_SIGNATURE",$this->lng->txt('sess_signature'));
1306  }
1307 
1308  if($_POST['show_admins'])
1309  {
1310  $members = array_merge((array) $members,$members_obj->getAdmins());
1311  }
1312  if($_POST['show_tutors'])
1313  {
1314  $members = array_merge((array) $members,$members_obj->getTutors());
1315  }
1316  if($_POST['show_members'])
1317  {
1318  $members = array_merge((array) $members,$members_obj->getMembers());
1319  }
1320  $members = ilUtil::_sortIds((array) $members,'usr_data','lastname','usr_id');
1321 
1322  foreach($members as $user_id)
1323  {
1324  $user_data = $event_part->getUser($user_id);
1325 
1326  if($_POST['show_mark'])
1327  {
1328  $tpl->setVariable("MARK",$user_data['mark'] ? $user_data['mark'] : ' ');
1329  }
1330  if($_POST['show_comment'])
1331  {
1332  $tpl->setVariable("COMMENT",$user_data['comment'] ? $user_data['comment'] : ' ');
1333  }
1334  if($_POST['show_signature'])
1335  {
1336  $tpl->touchBlock('row_signature');
1337  }
1338 
1339  $tpl->setCurrentBlock("member_row");
1340  $name = ilObjUser::_lookupName($user_id);
1341  $tpl->setVariable("LASTNAME",$name['lastname']);
1342  $tpl->setVariable("FIRSTNAME",$name['firstname']);
1343  $tpl->setVariable("LOGIN",ilObjUser::_lookupLogin($user_id));
1344  $tpl->parseCurrentBlock();
1345  }
1346 
1347  $this->tpl->setVariable("CONTENT",$tpl->get());
1348  $this->tpl->setVariable("BODY_ATTRIBUTES",'onload="window.print()"');
1349  $this->tpl->show();
1350  exit;
1351  }
1352 
1353 
1361  public function printViewMembersObject()
1362  {
1363  include_once 'Modules/Session/classes/class.ilEventParticipants.php';
1364  include_once('./Modules/Course/classes/class.ilCourseParticipants.php');
1365 
1366  global $ilErr,$ilAccess,$tree,$ilUser;
1367 
1368  $this->course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs');
1369  $this->course_obj_id = ilObject::_lookupObjId($this->course_ref_id);
1370  if(!$this->course_ref_id)
1371  {
1372  ilUtil::sendFailure('No course object found. Aborting');
1373  return true;
1374  }
1375 
1376  $members_obj = ilCourseParticipants::_getInstanceByObjId($this->course_obj_id);
1377  $event_app = $this->object->getFirstAppointment();
1378  $event_part = new ilEventParticipants($this->object->getId());
1379 
1380  $this->tpl = new ilTemplate('tpl.main.html',true,true);
1381  // load style sheet depending on user's settings
1382  $location_stylesheet = ilUtil::getStyleSheetLocation();
1383  $this->tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
1384 
1385  $tpl = new ilTemplate('tpl.sess_members_print.html',true,true,'Modules/Session');
1386 
1387  #$tpl->setVariable("EVENT",$this->lng->txt('event'));
1388  $tpl->setVariable("EVENT_NAME",$this->object->getTitle() ? ': '.$this->object->getTitle() : $this->object->getTitle());
1390  $tpl->setVariable("DATE",ilDatePresentation::formatPeriod($event_app->getStart(),$event_app->getEnd()));
1392 
1393 
1394  if(!$ilUser->getPref('sess_admin_hide') and count($members_obj->getAdmins()))
1395  {
1396  $tmp['txt'] = $this->lng->txt('event_tbl_admins');
1397  $tmp['users'] = $members_obj->getAdmins();
1398 
1399  $participants[] = $tmp;
1400  }
1401  if(!$ilUser->getPref('sess_tutor_hide') and count($members_obj->getTutors()))
1402  {
1403  $tmp['txt'] = $this->lng->txt('event_tbl_tutors');
1404  $tmp['users'] = $members_obj->getTutors();
1405 
1406  $participants[] = $tmp;
1407  }
1408  if(!$ilUser->getPref('sess_member_hide') and count($members_obj->getMembers()))
1409  {
1410  $tmp['txt'] = $this->lng->txt('event_tbl_members');
1411  $tmp['users'] = $members_obj->getMembers();
1412 
1413  $participants[] = $tmp;
1414  }
1415 
1416  foreach((array) $participants as $participants_data)
1417  {
1418  $members = ilUtil::_sortIds($participants_data['users'],'usr_data','lastname','usr_id');
1419  foreach($members as $user_id)
1420  {
1421 
1422  $user_data = $event_part->getUser($user_id);
1423 
1424  if($this->object->enabledRegistration())
1425  {
1426  $tpl->setCurrentBlock("reg_col");
1427  $tpl->setVariable("REGISTERED",$event_part->isRegistered($user_id) ? "X" : "");
1428  $tpl->parseCurrentBlock();
1429  }
1430  $tpl->setVariable("COMMENT",$user_data['comment']);
1431 
1432  $tpl->setCurrentBlock("member_row");
1433  $name = ilObjUser::_lookupName($user_id);
1434  $tpl->setVariable("LASTNAME",$name['lastname']);
1435  $tpl->setVariable("FIRSTNAME",$name['firstname']);
1436  $tpl->setVariable("LOGIN",ilObjUser::_lookupLogin($user_id));
1437  $tpl->setVariable("MARK",$user_data['mark']);
1438  $tpl->setVariable("PARTICIPATED",$event_part->hasParticipated($user_id) ? "X" : "");
1439  $tpl->parseCurrentBlock();
1440  }
1441 
1442  $tpl->setCurrentBlock('part_group');
1443  $tpl->setVariable('GROUP_NAME',$participants_data['txt']);
1444  $tpl->setVariable("TXT_NAME",$this->lng->txt('name'));
1445  $tpl->setVariable("TXT_MARK",$this->lng->txt('trac_mark'));
1446  $tpl->setVariable("TXT_COMMENT",$this->lng->txt('trac_comment'));
1447  $tpl->setVariable("TXT_PARTICIPATED",$this->lng->txt('event_tbl_participated'));
1448  if($this->object->enabledRegistration())
1449  {
1450  $tpl->setVariable("TXT_REGISTERED",$this->lng->txt('event_tbl_registered'));
1451  }
1452  $tpl->parseCurrentBlock();
1453 
1454  }
1455 
1456  $this->tpl->setVariable("CONTENT",$tpl->get());
1457  $this->tpl->setVariable("BODY_ATTRIBUTES",'onload="window.print()"');
1458  $this->tpl->show();
1459  exit;
1460 
1461  }
1462 
1470  public function eventsListObject()
1471  {
1472  global $ilErr,$ilAccess, $ilUser,$tree;
1473 
1474  if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
1475  {
1476  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
1477  }
1478 
1479  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.sess_list.html','Modules/Session');
1480  $this->__showButton($this->ctrl->getLinkTarget($this,'exportCSV'),$this->lng->txt('event_csv_export'));
1481 
1482  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
1483  include_once 'Modules/Session/classes/class.ilEventParticipants.php';
1484 
1485  $this->tpl->addBlockfile("EVENTS_TABLE","events_table", "tpl.table.html");
1486  $this->tpl->addBlockfile('TBL_CONTENT','tbl_content','tpl.sess_list_row.html','Modules/Session');
1487 
1488  $members_obj = ilCourseParticipants::_getInstanceByObjId($this->object->getId());
1489  $members = $members_obj->getParticipants();
1490  $members = ilUtil::_sortIds($members,'usr_data','lastname','usr_id');
1491 
1492  // Table
1493  $tbl = new ilTableGUI();
1494  $tbl->setTitle($this->lng->txt("event_overview"),
1495  'icon_usr.gif',
1496  $this->lng->txt('obj_usr'));
1497  $this->ctrl->setParameter($this,'offset',(int) $_GET['offset']);
1498 
1499  $course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs');
1500  $events = array();
1501  foreach($tree->getSubtree($tree->getNodeData($course_ref_id),false,'sess') as $event_id)
1502  {
1503  $tmp_event = ilObjectFactory::getInstanceByRefId($event_id,false);
1504  if(!is_object($tmp_event) or $tmp_event->getType() != 'sess')
1505  {
1506  continue;
1507  }
1508  $events[] = $tmp_event;
1509  }
1510 
1511  $headerNames = array();
1512  $headerVars = array();
1513  $colWidth = array();
1514 
1515  $headerNames[] = $this->lng->txt('name');
1516  $headerVars[] = "name";
1517  $colWidth[] = '20%';
1518 
1519  for ($i = 1; $i <= count($events); $i++)
1520  {
1521  $headerNames[] = $i;
1522  $headerVars[] = "event_".$i;
1523  $colWidth[] = 80/count($events)."%";
1524  }
1525 
1526  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
1527  $tbl->setHeaderNames($headerNames);
1528  $tbl->setHeaderVars($headerVars, $this->ctrl->getParameterArray($this,'eventsList'));
1529  $tbl->setColumnWidth($colWidth);
1530 
1531  $tbl->setOrderColumn($_GET["sort_by"]);
1532  $tbl->setOrderDirection($_GET["sort_order"]);
1533  $tbl->setOffset($_GET["offset"]);
1534  $tbl->setLimit($ilUser->getPref("hits_per_page"));
1535  $tbl->setMaxCount(count($members));
1536  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1537 
1538  $sliced_users = array_slice($members,$_GET['offset'],$_SESSION['tbl_limit']);
1539  $tbl->disable('sort');
1540  $tbl->render();
1541 
1542  $counter = 0;
1543  foreach($sliced_users as $user_id)
1544  {
1545  foreach($events as $event_obj)
1546  {
1547  $this->tpl->setCurrentBlock("eventcols");
1548 
1549  $event_part = new ilEventParticipants($this->object->getId());
1550 
1551  {
1552  $this->tpl->setVariable("IMAGE_PARTICIPATED", $event_part->hasParticipated($user_id) ?
1553  ilUtil::getImagePath('icon_ok.gif') :
1554  ilUtil::getImagePath('icon_not_ok.gif'));
1555 
1556  $this->tpl->setVariable("PARTICIPATED", $event_part->hasParticipated($user_id) ?
1557  $this->lng->txt('event_participated') :
1558  $this->lng->txt('event_not_participated'));
1559  }
1560 
1561  $this->tpl->parseCurrentBlock();
1562  }
1563 
1564  $this->tpl->setCurrentBlock("tbl_content");
1565  $name = ilObjUser::_lookupName($user_id);
1566  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor($counter++,'tblrow1','tblrow2'));
1567  $this->tpl->setVariable("LASTNAME",$name['lastname']);
1568  $this->tpl->setVariable("FIRSTNAME",$name['firstname']);
1569  $this->tpl->setVariable("LOGIN",ilObjUser::_lookupLogin($user_id));
1570  $this->tpl->parseCurrentBlock();
1571  }
1572 
1573  $this->tpl->setVariable("HEAD_TXT_LEGEND", $this->lng->txt("legend"));
1574  $this->tpl->setVariable("HEAD_TXT_DIGIT", $this->lng->txt("event_digit"));
1575  $this->tpl->setVariable("HEAD_TXT_EVENT", $this->lng->txt("event"));
1576  $this->tpl->setVariable("HEAD_TXT_LOCATION", $this->lng->txt("event_location"));
1577  $this->tpl->setVariable("HEAD_TXT_DATE_TIME",$this->lng->txt("event_date_time"));
1578  $i = 1;
1579  foreach($events as $event_obj)
1580  {
1581  $this->tpl->setCurrentBlock("legend_loop");
1582  $this->tpl->setVariable("LEGEND_CSS_ROW",ilUtil::switchColor($counter++,'tblrow1','tblrow2'));
1583  $this->tpl->setVariable("LEGEND_DIGIT", $i++);
1584  $this->tpl->setVariable("LEGEND_EVENT_TITLE", $event_obj->getTitle());
1585  $this->tpl->setVariable("LEGEND_EVENT_DESCRIPTION", $event_obj->getDescription());
1586  $this->tpl->setVariable("LEGEND_EVENT_LOCATION", $event_obj->getLocation());
1587  $this->tpl->setVariable("LEGEND_EVENT_APPOINTMENT", $event_obj->getFirstAppointment()->appointmentToString());
1588  $this->tpl->parseCurrentBlock();
1589  }
1590 
1591  }
1592 
1598  protected function initForm($a_mode)
1599  {
1600  global $ilUser;
1601 
1602  if(is_object($this->form))
1603  {
1604  return true;
1605  }
1606 
1607  $this->lng->loadLanguageModule('dateplaner');
1608 
1609  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1610 
1611  include_once('./Services/YUI/classes/class.ilYuiUtil.php');
1613 
1614  $this->form = new ilPropertyFormGUI();
1615  $this->form->setMultipart(true);
1616  $this->form->setTableWidth('600px');
1617  $this->form->setFormAction($this->ctrl->getFormAction($this));
1618  $this->form->setMultipart(true);
1619 
1620  /*
1621  $full = new ilCheckboxInputGUI('','fulltime');
1622  $full->setChecked($this->object->getFirstAppointment()->enabledFulltime() ? true : false);
1623  $full->setOptionTitle($this->lng->txt('event_fulltime_info'));
1624  $full->setAdditionalAttributes('onchange="ilToggleSessionTime(this);"');
1625  #$this->form->addItem($full);
1626  */
1627 
1628  $this->lng->loadLanguageModule('dateplaner');
1629  include_once './Services/Form/classes/class.ilDateDurationInputGUI.php';
1630  #$this->tpl->addJavaScript('./Modules/Session/js/toggle_session_time.js');
1631  $this->tpl->addJavaScript('./Services/Form/js/date_duration.js');
1632  $dur = new ilDateDurationInputGUI($this->lng->txt('cal_fullday'),'event');
1633  $dur->setStartText($this->lng->txt('event_start_date'));
1634  $dur->setEndText($this->lng->txt('event_end_date'));
1635  $dur->enableToggleFullTime(
1636  $this->lng->txt('event_fulltime_info'),
1637  $this->object->getFirstAppointment()->enabledFulltime() ? true : false
1638  );
1639  $dur->setMinuteStepSize(5);
1640  $dur->setShowTime(true);
1641  $dur->setShowDate(true);
1642  $dur->setStart($this->object->getFirstAppointment()->getStart());
1643  $dur->setEnd($this->object->getFirstAppointment()->getEnd());
1644 
1645  $this->form->addItem($dur);
1646 
1647  /*
1648  // start
1649  $start = new ilDateTimeInputGUI($this->lng->txt('event_start_date'),'start');
1650  $start->setMinuteStepSize(5);
1651  $start->setDate($this->object->getFirstAppointment()->getStart());
1652  $start->setShowTime(true);
1653  #$this->form->addItem($start);
1654 
1655  // end
1656  $end = new ilDateTimeInputGUI($this->lng->txt('event_end_date'),'end');
1657  $end->setMinuteStepSize(5);
1658  $end->setDate($this->object->getFirstAppointment()->getEnd());
1659  $end->setShowTime(true);
1660  #$this->form->addItem($end);
1661  */
1662 
1663  // Recurrence
1664  if($a_mode == 'create')
1665  {
1666  if(!is_object($this->rec))
1667  {
1668  include_once('./Modules/Session/classes/class.ilEventRecurrence.php');
1669  $this->rec = new ilEventRecurrence();
1670  }
1671  include_once('./Services/Calendar/classes/Form/class.ilRecurrenceInputGUI.php');
1672  $rec = new ilRecurrenceInputGUI($this->lng->txt('cal_recurrences'),'frequence');
1673  $rec->allowUnlimitedRecurrences(false);
1674  $rec->setRecurrence($this->rec);
1675  $this->form->addItem($rec);
1676  }
1677 
1679  $section->setTitle($this->lng->txt('event_section_information'));
1680  $this->form->addItem($section);
1681 
1682  // title
1683  $title = new ilTextInputGUI($this->lng->txt('event_title'),'title');
1684  $title->setValue($this->object->getTitle());
1685  $title->setSize(50);
1686  $title->setMaxLength(70);
1687  $this->form->addItem($title);
1688 
1689  // desc
1690  $desc = new ilTextAreaInputGUI($this->lng->txt('event_desc'),'desc');
1691  $desc->setValue($this->object->getLongDescription());
1692  $desc->setRows(4);
1693  $desc->setCols(50);
1694  $this->form->addItem($desc);
1695 
1696  // location
1697  $desc = new ilTextAreaInputGUI($this->lng->txt('event_location'),'location');
1698  $desc->setValue($this->object->getLocation());
1699  $desc->setRows(4);
1700  $desc->setCols(50);
1701  $this->form->addItem($desc);
1702 
1703  // workflow
1704  $details = new ilTextAreaInputGUI($this->lng->txt('event_details_workflow'),'details');
1705  $details->setValue($this->object->getDetails());
1706  $details->setCols(50);
1707  $details->setRows(4);
1708  $this->form->addItem($details);
1709 
1710  // section
1712  $section->setTitle($this->lng->txt('event_tutor_data'));
1713  $this->form->addItem($section);
1714 
1715  // name
1716  $tutor_name = new ilTextInputGUI($this->lng->txt('tutor_name'),'tutor_name');
1717  $tutor_name->setValue($this->object->getName());
1718  $tutor_name->setSize(20);
1719  $tutor_name->setMaxLength(70);
1720  $this->form->addItem($tutor_name);
1721 
1722  // email
1723  $tutor_email = new ilTextInputGUI($this->lng->txt('tutor_email'),'tutor_email');
1724  $tutor_email->setValue($this->object->getEmail());
1725  $tutor_email->setSize(20);
1726  $tutor_email->setMaxLength(70);
1727  $this->form->addItem($tutor_email);
1728 
1729  // phone
1730  $tutor_phone = new ilTextInputGUI($this->lng->txt('tutor_phone'),'tutor_phone');
1731  $tutor_phone->setValue($this->object->getPhone());
1732  $tutor_phone->setSize(20);
1733  $tutor_phone->setMaxLength(70);
1734  $this->form->addItem($tutor_phone);
1735 
1737  $section->setTitle($this->lng->txt('crs_further_settings'));
1738  $this->form->addItem($section);
1739 
1740  // registration
1741  $reg = new ilCheckboxInputGUI($this->lng->txt('event_registration'),'registration');
1742  $reg->setChecked($this->object->enabledRegistration() ? true : false);
1743  $reg->setOptionTitle($this->lng->txt('event_registration_info'));
1744  $this->form->addItem($reg);
1745 
1746 
1748  $section->setTitle($this->lng->txt('event_assign_files'));
1749  $this->form->addItem($section);
1750 
1751  $files = new ilFileWizardInputGUI($this->lng->txt('objs_file'),'files');
1752  $files->setFilenames(array(0 => ''));
1753  $this->form->addItem($files);
1754 
1755  switch($a_mode)
1756  {
1757  case 'create':
1758  $this->form->setTitle($this->lng->txt('event_table_create'));
1759  $this->form->setTitleIcon(ilUtil::getImagePath('icon_event.gif'));
1760 
1761  $this->form->addCommandButton('save',$this->lng->txt('event_btn_add'));
1762  $this->form->addCommandButton('saveAndAssignMaterials',$this->lng->txt('event_btn_add_edit'));
1763  $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
1764 
1765  return true;
1766 
1767  case 'edit':
1768  $this->form->setTitle($this->lng->txt('event_table_update'));
1769  $this->form->setTitleIcon(ilUtil::getImagePath('icon_event.gif'));
1770 
1771  $this->form->addCommandButton('update',$this->lng->txt('save'));
1772  $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
1773 
1774  return true;
1775  }
1776  return true;
1777  }
1778 
1786  protected function load()
1787  {
1788  global $ilUser;
1789 
1790  $this->object->getFirstAppointment()->setStartingTime($this->__toUnix($_POST['event']['start']['date'],$_POST['event']['start']['time']));
1791  $this->object->getFirstAppointment()->setEndingTime($this->__toUnix($_POST['event']['end']['date'],$_POST['event']['end']['time']));
1792  $this->object->getFirstAppointment()->toggleFullTime((bool) $_POST['event']['fulltime']);
1793 
1794  include_once('./Services/Calendar/classes/class.ilDate.php');
1795  if($this->object->getFirstAppointment()->isFullday())
1796  {
1797  $start = new ilDate($_POST['event']['start']['date']['y'].'-'.$_POST['event']['start']['date']['m'].'-'.$_POST['event']['start']['date']['d'],
1798  IL_CAL_DATE);
1799  $this->object->getFirstAppointment()->setStart($start);
1800 
1801  $end = new ilDate($_POST['event']['end']['date']['y'].'-'.$_POST['event']['end']['date']['m'].'-'.$_POST['event']['end']['date']['d'],
1802  IL_CAL_DATE);
1803  $this->object->getFirstAppointment()->setEnd($end);
1804  }
1805  else
1806  {
1807  $start_dt['year'] = (int) $_POST['event']['start']['date']['y'];
1808  $start_dt['mon'] = (int) $_POST['event']['start']['date']['m'];
1809  $start_dt['mday'] = (int) $_POST['event']['start']['date']['d'];
1810  $start_dt['hours'] = (int) $_POST['event']['start']['time']['h'];
1811  $start_dt['minutes'] = (int) $_POST['event']['start']['time']['m'];
1812 
1813  $start = new ilDateTime($start_dt,IL_CAL_FKT_GETDATE,$ilUser->getTimeZone());
1814  $this->object->getFirstAppointment()->setStart($start);
1815 
1816  $end_dt['year'] = (int) $_POST['event']['end']['date']['y'];
1817  $end_dt['mon'] = (int) $_POST['event']['end']['date']['m'];
1818  $end_dt['mday'] = (int) $_POST['event']['end']['date']['d'];
1819  $end_dt['hours'] = (int) $_POST['event']['end']['time']['h'];
1820  $end_dt['minutes'] = (int) $_POST['event']['end']['time']['m'];
1821  $end = new ilDateTime($end_dt,IL_CAL_FKT_GETDATE,$ilUser->getTimeZone());
1822  $this->object->getFirstAppointment()->setEnd($end);
1823  }
1824 
1825  $this->object->setTitle(ilUtil::stripSlashes($_POST['title']));
1826  $this->object->setDescription(ilUtil::stripSlashes($_POST['desc']));
1827  $this->object->setLocation(ilUtil::stripSlashes($_POST['location']));
1828  $this->object->setName(ilUtil::stripSlashes($_POST['tutor_name']));
1829  $this->object->setPhone(ilUtil::stripSlashes($_POST['tutor_phone']));
1830  $this->object->setEmail(ilUtil::stripSlashes($_POST['tutor_email']));
1831  $this->object->setDetails(ilUtil::stripSlashes($_POST['details']));
1832  $this->object->enableRegistration((int) $_POST['registration']);
1833  }
1834 
1841  protected function loadRecurrenceSettings()
1842  {
1843  include_once('./Modules/Session/classes/class.ilSessionRecurrence.php');
1844  $this->rec = new ilSessionRecurrence();
1845 
1846  switch($_POST['frequence'])
1847  {
1848  case IL_CAL_FREQ_DAILY:
1849  $this->rec->setFrequenceType($_POST['frequence']);
1850  $this->rec->setInterval((int) $_POST['count_DAILY']);
1851  break;
1852 
1853  case IL_CAL_FREQ_WEEKLY:
1854  $this->rec->setFrequenceType($_POST['frequence']);
1855  $this->rec->setInterval((int) $_POST['count_WEEKLY']);
1856  if(is_array($_POST['byday_WEEKLY']))
1857  {
1858  $this->rec->setBYDAY(ilUtil::stripSlashes(implode(',',$_POST['byday_WEEKLY'])));
1859  }
1860  break;
1861 
1862  case IL_CAL_FREQ_MONTHLY:
1863  $this->rec->setFrequenceType($_POST['frequence']);
1864  $this->rec->setInterval((int) $_POST['count_MONTHLY']);
1865  switch((int) $_POST['subtype_MONTHLY'])
1866  {
1867  case 0:
1868  // nothing to do;
1869  break;
1870 
1871  case 1:
1872  switch((int) $_POST['monthly_byday_day'])
1873  {
1874  case 8:
1875  // Weekday
1876  $this->rec->setBYSETPOS((int) $_POST['monthly_byday_num']);
1877  $this->rec->setBYDAY('MO,TU,WE,TH,FR');
1878  break;
1879 
1880  case 9:
1881  // Day of month
1882  $this->rec->setBYMONTHDAY((int) $_POST['monthly_byday_num']);
1883  break;
1884 
1885  default:
1886  $this->rec->setBYDAY((int) $_POST['monthly_byday_num'].$_POST['monthly_byday_day']);
1887  break;
1888  }
1889  break;
1890 
1891  case 2:
1892  $this->rec->setBYMONTHDAY((int) $_POST['monthly_bymonthday']);
1893  break;
1894  }
1895  break;
1896 
1897  case IL_CAL_FREQ_YEARLY:
1898  $this->rec->setFrequenceType($_POST['frequence']);
1899  $this->rec->setInterval((int) $_POST['count_YEARLY']);
1900  switch((int) $_POST['subtype_YEARLY'])
1901  {
1902  case 0:
1903  // nothing to do;
1904  break;
1905 
1906  case 1:
1907  $this->rec->setBYMONTH((int) $_POST['yearly_bymonth_byday']);
1908  $this->rec->setBYDAY((int) $_POST['yearly_byday_num'].$_POST['yearly_byday']);
1909  break;
1910 
1911  case 2:
1912  $this->rec->setBYMONTH((int) $_POST['yearly_bymonth_by_monthday']);
1913  $this->rec->setBYMONTHDAY((int) $_POST['yearly_bymonthday']);
1914  break;
1915  }
1916  break;
1917  }
1918 
1919  // UNTIL
1920  switch((int) $_POST['until_type'])
1921  {
1922  case 1:
1923  $this->rec->setFrequenceUntilDate(null);
1924  // nothing to do
1925  break;
1926 
1927  case 2:
1928  $this->rec->setFrequenceUntilDate(null);
1929  $this->rec->setFrequenceUntilCount((int) $_POST['count']);
1930  break;
1931 
1932  case 3:
1933  $end_dt['year'] = (int) $_POST['until_end']['date']['y'];
1934  $end_dt['mon'] = (int) $_POST['until_end']['date']['m'];
1935  $end_dt['mday'] = (int) $_POST['until_end']['date']['d'];
1936 
1937  $this->rec->setFrequenceUntilCount(0);
1938  $this->rec->setFrequenceUntilDate(new ilDate($end_dt,IL_CAL_FKT_GETDATE,$this->timezone));
1939  break;
1940  }
1941  }
1942 
1943 
1951  protected function __toUnix($date,$time)
1952  {
1953  return mktime($time['h'],$time['m'],0,$date['m'],$date['d'],$date['y']);
1954  }
1955 
1962  protected function formatPath($a_ref_id)
1963  {
1964  global $tree;
1965 
1966  $path = $this->lng->txt('path') . ': ';
1967  $first = true;
1968  foreach($tree->getPathFull($a_ref_id,$this->course_ref_id) as $node)
1969  {
1970  if($node['ref_id'] != $a_ref_id)
1971  {
1972  if(!$first)
1973  {
1974  $path .= ' -> ';
1975  }
1976  $first = false;
1977  $path .= $node['title'];
1978  }
1979  }
1980  return $path;
1981  }
1982 
1989  public function addLocatorItems()
1990  {
1991  global $ilLocator;
1992 
1993  if (is_object($this->object))
1994  {
1995  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
1996  }
1997  }
1998 
2005  public function getTabs($tabs_gui)
2006  {
2007  global $ilAccess,$ilTabs,$tree;
2008 
2009  $parent_id = $tree->getParentId($this->object->getRefId());
2010 
2011  $tabs_gui->setBackTarget($this->lng->txt('back_to_crs_content'),'repository.php?ref_id='.$parent_id);
2012  $tabs_gui->addTarget('info_short',
2013  $this->ctrl->getLinkTarget($this,'infoScreen'));
2014 
2015  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
2016  {
2017  $tabs_gui->addTarget('edit_properties',
2018  $this->ctrl->getLinkTarget($this,'edit'));
2019  $tabs_gui->addTarget('crs_materials',
2020  $this->ctrl->getLinkTarget($this,'materials'));
2021  $tabs_gui->addTarget('event_edit_members',
2022  $this->ctrl->getLinkTarget($this,'members'));
2023  }
2024 
2025  // export
2026  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
2027  {
2028  $ilTabs->addTarget("export",
2029  $this->ctrl->getLinkTargetByClass("ilexportgui", ""), "", "ilexportgui");
2030  }
2031 
2032 
2033  // edit permissions
2034  if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId()))
2035  {
2036  $tabs_gui->addTarget("perm_settings",
2037  $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"), array("perm","info","owner"), 'ilpermissiongui');
2038  }
2039 
2040  }
2041 
2042 }
2043 ?>