ILIAS  release_4-3 Revision
 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('./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  {
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');
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, $ilAccess;
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  $parent_type = ilObject::_lookupType($parent_ref_id, true);
832 
833  // add new item
834  $subtypes = $objDefinition->getCreatableSubObjects($parent_type, ilObjectDefinition::MODE_REPOSITORY);
835  if($subtypes)
836  {
837  $subobj = array();
838  foreach($subtypes as $type => $sub_item)
839  {
840  if (!in_array($type, array("itgr", "sess")))
841  {
842  // #9950
843  if ($ilAccess->checkAccess("create_".$type, "", $parent_ref_id, $parent_type))
844  {
845  // #10787
846  $title = $this->lng->txt('obj_'.$type);
847  if ($sub_item["plugin"])
848  {
849  include_once("./Services/Component/classes/class.ilPlugin.php");
850  $title = ilPlugin::lookupTxt("rep_robj", $type, "obj_".$type);
851  }
852 
853  $subobj[] = array('value' => $type,
854  'title' => $title,
855  'img' => ilObject::_getIcon('', 'tiny', $type),
856  'alt' => $title);
857  }
858  }
859  }
860 
861  if(sizeof($subobj))
862  {
863  // add new object to parent container instead
864  $this->ctrl->setParameter($this, 'ref_id', $parent_ref_id);
865  // $this->ctrl->setParameter($this, 'crtptrefid', $parent_ref_id);
866  // force after creation callback
867  $this->ctrl->setParameter($this, 'crtcb', $this->ref_id);
868 
869  $this->lng->loadLanguageModule('cntr');
870  $this->tpl->setCreationSelector($this->ctrl->getFormAction($this),
871  $subobj, 'create', $this->lng->txt('add'));
872 
873  $this->ctrl->setParameter($this, 'ref_id', $this->ref_id);
874  // $this->ctrl->setParameter($this, 'crtptrefid', '');
875  $this->ctrl->setParameter($this, 'crtcb', '');
876  }
877  }
878 
879 
880 
881  include_once 'Modules/Session/classes/class.ilEventItems.php';
882  $this->event_items = new ilEventItems($this->object->getId());
883  $items = $this->event_items->getItems();
884 
885  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.sess_materials.html','Modules/Session');
886  #$this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
887 
888  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this,'materials'));
889  $this->tpl->setVariable("COLL_TITLE_IMG",ilUtil::getImagePath('icon_sess.png'));
890  $this->tpl->setVariable("COLL_TITLE_IMG_ALT",$this->lng->txt('events'));
891  $this->tpl->setVariable("TABLE_TITLE",$this->lng->txt('event_assign_materials_table'));
892  $this->tpl->setVariable("TABLE_INFO",$this->lng->txt('event_assign_materials_info'));
893 
894  $materials = array();
895  $nodes = $tree->getSubTree($tree->getNodeData($parent_ref_id));
896  foreach($nodes as $node)
897  {
898  // No side blocks here
899  if ($node['child'] == $parent_ref_id ||
900  $objDefinition->isSideBlock($node['type']) ||
901  in_array($node['type'], array('sess', 'itgr', 'rolf')))
902  {
903  continue;
904  }
905 
906  if($node['type'] == 'rolf')
907  {
908  continue;
909  }
910 
911  $node["sorthash"] = (int)(!in_array($node['ref_id'],$items)).$node["title"];
912  $materials[] = $node;
913  }
914 
915 
916  $materials = ilUtil::sortArray($materials, "sorthash", "ASC");
917 
918  $counter = 1;
919  foreach($materials as $node)
920  {
921  $counter++;
922 
923  $this->tpl->setCurrentBlock("material_row");
924 
925  $this->tpl->setVariable('TYPE_IMG', ilObject::_getIcon('', 'tiny', $node['type']));
926  $this->tpl->setVariable('IMG_ALT',$this->lng->txt('obj_'.$node['type']));
927  $this->tpl->setVariable("ROW_CLASS",ilUtil::switchColor($counter,'tblrow1','tblrow2'));
928  $this->tpl->setVariable("CHECK_COLL",ilUtil::formCheckbox(in_array($node['ref_id'],$items) ? 1 : 0,
929  'items[]',$node['ref_id']));
930  $this->tpl->setVariable("COLL_TITLE",$node['title']);
931 
932  if(strlen($node['description']))
933  {
934  $this->tpl->setVariable("COLL_DESC",$node['description']);
935  }
936  $this->tpl->setVariable("ASSIGNED_IMG_OK",in_array($node['ref_id'],$items) ?
937  ilUtil::getImagePath('icon_ok.png') :
938  ilUtil::getImagePath('icon_not_ok.png'));
939  $this->tpl->setVariable("ASSIGNED_STATUS",$this->lng->txt('event_material_assigned'));
940  $this->tpl->setVariable("COLL_PATH",$this->formatPath($node['ref_id']));
941  $this->tpl->parseCurrentBlock();
942  }
943 
944  $this->tpl->setVariable("SELECT_ROW",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
945  $this->tpl->setVariable("SELECT_ALL",$this->lng->txt('select_all'));
946  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.png'));
947  $this->tpl->setVariable("BTN_SAVE",$this->lng->txt('save'));
948  }
949 
957  public function saveMaterialsObject()
958  {
959  include_once './Modules/Session/classes/class.ilEventItems.php';
960 
961  $this->event_items = new ilEventItems($this->object->getId());
962  $this->event_items->setItems(is_array($_POST['items']) ? $_POST['items'] : array());
963  $this->event_items->update();
964 
965  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
966  $this->materialsObject();
967  }
968 
973  protected function membersObject()
974  {
975  global $tree,$ilUser;
976 
977  $this->checkPermission('write');
978  $this->tabs_gui->setTabActive('event_edit_members');
979 
980  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.sess_members.html', 'Modules/Session');
981 
982  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
983  $toolbar = new ilToolbarGUI();
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  $members_obj = $this->initContainer(true);
990 
991  include_once './Modules/Session/classes/class.ilEventParticipants.php';
992 
993  // Save hide/show table settings
994  $this->setShowHidePrefs();
995 
996  // Admins
997  if(count($admins = $members_obj->getAdmins()))
998  {
999  include_once('./Modules/Session/classes/class.ilSessionParticipantsTableGUI.php');
1000  if($ilUser->getPref('sess_admin_hide'))
1001  {
1003  $this->ctrl->setParameter($this,'admin_hide',0);
1004  $table->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1005  $this->lng->txt('show'),
1006  '',
1007  ilUtil::getImagePath('edit_add.png'));
1008  $this->ctrl->clearParameters($this);
1009  }
1010  else
1011  {
1013  $this->ctrl->setParameter($this,'admin_hide',1);
1014  $table->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1015  $this->lng->txt('hide'),
1016  '',
1017  ilUtil::getImagePath('edit_remove.png'));
1018  $this->ctrl->clearParameters($this);
1019  }
1020 
1021  $table->addCommandButton('updateMembers',$this->lng->txt('save'));
1022  $table->setTitle($this->lng->txt('event_tbl_admins'),'icon_usr.png',$this->lng->txt('event_tbl_admins'));
1023  $table->enableRegistration($this->object->enabledRegistration());
1024  $table->setParticipants($admins);
1025  $table->parse();
1026  $this->tpl->setVariable('ADMINS',$table->getHTML());
1027  }
1028 
1029  // Tutors
1030  if(count($tutors = $members_obj->getTutors()))
1031  {
1032  include_once('./Modules/Session/classes/class.ilSessionParticipantsTableGUI.php');
1033  if($ilUser->getPref('sess_tutor_hide'))
1034  {
1036  $this->ctrl->setParameter($this,'tutor_hide',0);
1037  $table->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1038  $this->lng->txt('show'),
1039  '',
1040  ilUtil::getImagePath('edit_add.png'));
1041  $this->ctrl->clearParameters($this);
1042  }
1043  else
1044  {
1046  $this->ctrl->setParameter($this,'tutor_hide',1);
1047  $table->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1048  $this->lng->txt('hide'),
1049  '',
1050  ilUtil::getImagePath('edit_remove.png'));
1051  $this->ctrl->clearParameters($this);
1052  }
1053  $table->addCommandButton('updateMembers',$this->lng->txt('save'));
1054  $table->setTitle($this->lng->txt('event_tbl_tutors'),'icon_usr.png',$this->lng->txt('event_tbl_admins'));
1055  $table->enableRegistration($this->object->enabledRegistration());
1056  $table->setParticipants($tutors);
1057  $table->parse();
1058  $this->tpl->setVariable('TUTORS',$table->getHTML());
1059  }
1060 
1061  // Members
1062  if(count($members = $members_obj->getMembers()))
1063  {
1064  include_once('./Modules/Session/classes/class.ilSessionParticipantsTableGUI.php');
1065  if($ilUser->getPref('sess_member_hide'))
1066  {
1068  $this->ctrl->setParameter($this,'member_hide',0);
1069  $table->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1070  $this->lng->txt('show'),
1071  '',
1072  ilUtil::getImagePath('edit_add.png'));
1073  $this->ctrl->clearParameters($this);
1074  }
1075  else
1076  {
1078  $this->ctrl->setParameter($this,'member_hide',1);
1079  $table->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1080  $this->lng->txt('hide'),
1081  '',
1082  ilUtil::getImagePath('edit_remove.png'));
1083  $this->ctrl->clearParameters($this);
1084  }
1085  $table->addCommandButton('updateMembers',$this->lng->txt('save'));
1086  $table->setTitle($this->lng->txt('event_tbl_members'),'icon_usr.png',$this->lng->txt('event_tbl_admins'));
1087  $table->enableRegistration($this->object->enabledRegistration());
1088  $table->setParticipants($members);
1089  $table->parse();
1090  $this->tpl->setVariable('MEMBERS',$table->getHTML());
1091  }
1092 
1093 
1094 
1095 
1096 
1097  }
1098 
1105  public function setShowHidePrefs()
1106  {
1107  global $ilUser;
1108 
1109  if(isset($_GET['admin_hide']))
1110  {
1111  $ilUser->writePref('sess_admin_hide',(int) $_GET['admin_hide']);
1112  }
1113  if(isset($_GET['tutor_hide']))
1114  {
1115  $ilUser->writePref('sess_tutor_hide',(int) $_GET['tutor_hide']);
1116  }
1117  if(isset($_GET['member_hide']))
1118  {
1119  $ilUser->writePref('sess_member_hide',(int) $_GET['member_hide']);
1120  }
1121  }
1122 
1130  public function updateMembersObject()
1131  {
1132  global $tree;
1133 
1134  $this->checkPermission('write');
1135 
1136 
1137 
1138  $this->initContainer();
1139 
1140  $_POST['participants'] = is_array($_POST['participants']) ? $_POST['participants'] : array();
1141 
1142  include_once 'Modules/Session/classes/class.ilEventParticipants.php';
1143 
1144  $visible = $_POST['visible_participants'] ? $_POST['visible_participants'] : array();
1145  foreach($visible as $user)
1146  {
1147  $part = new ilEventParticipants($this->object->getId());
1148  $part->setUserId($user);
1149  $part->setMark(ilUtil::stripSlashes($_POST['mark'][$user]));
1150  $part->setComment(ilUtil::stripSlashes($_POST['comment'][$user]));
1151  $part->setParticipated(isset($_POST['participants'][$user]) ? true : false);
1152  $part->setRegistered(ilEventParticipants::_isRegistered($user,$this->object->getId()));
1153  $part->updateUser();
1154  }
1155  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
1156  $this->membersObject();
1157  }
1158 
1165  public function attendanceListObject()
1166  {
1167  global $tpl,$ilTabs;
1168 
1169  $this->checkPermission('write');
1170  $ilTabs->setTabActive('event_edit_members');
1171 
1172  $list = $this->initAttendanceList();
1173  $form = $list->initForm('printAttendanceList');
1174  $tpl->setContent($form->getHTML());
1175  }
1176 
1182  protected function initAttendanceList()
1183  {
1184  $members_obj = $this->initContainer(true);
1185 
1186  include_once 'Services/Membership/classes/class.ilAttendanceList.php';
1187  $list = new ilAttendanceList($this, $members_obj);
1188  $list->setId('sessattlst');
1189 
1190  $event_app = $this->object->getFirstAppointment();
1192  $desc = ilDatePresentation::formatPeriod($event_app->getStart(),$event_app->getEnd());
1194  $desc .= " ".$this->object->getTitle();
1195  $list->setTitle($this->lng->txt('sess_attendance_list'), $desc);
1196 
1197  $list->addPreset('mark', $this->lng->txt('trac_mark'), true);
1198  $list->addPreset('comment', $this->lng->txt('trac_comment'), true);
1199  if($this->object->enabledRegistration())
1200  {
1201  $list->addPreset('registered', $this->lng->txt('event_tbl_registered'), true);
1202  }
1203  $list->addPreset('participated', $this->lng->txt('event_tbl_participated'), true);
1204  $list->addBlank($this->lng->txt('sess_signature'));
1205  return $list;
1206  }
1207 
1213  protected function printAttendanceListObject()
1214  {
1215  global $ilErr,$ilAccess,$tree;
1216 
1217  $this->checkPermission('write');
1218 
1219  $list = $this->initAttendanceList();
1220  $list->initFromForm();
1221  $list->setCallback(array($this, 'getAttendanceListUserData'));
1222 
1223  include_once 'Modules/Session/classes/class.ilEventParticipants.php';
1224  $this->event_part = new ilEventParticipants($this->object->getId());
1225 
1226  echo $list->getFullscreenHTML();
1227  exit();
1228  }
1229 
1235  public function getAttendanceListUserData($a_user_id)
1236  {
1237  $data = $this->event_part->getUser($a_user_id);
1238  $data['registered'] = $data['registered'] ?
1239  $this->lng->txt('yes') :
1240  $this->lng->txt('no');
1241  $data['participated'] = $data['participated'] ?
1242  $this->lng->txt('yes') :
1243  $this->lng->txt('no');
1244  return $data;
1245  }
1246 
1254  public function eventsListObject()
1255  {
1256  global $ilErr,$ilAccess, $ilUser,$tree;
1257 
1258  if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
1259  {
1260  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
1261  }
1262 
1263  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.sess_list.html','Modules/Session');
1264  $this->__showButton($this->ctrl->getLinkTarget($this,'exportCSV'),$this->lng->txt('event_csv_export'));
1265 
1266  include_once 'Modules/Session/classes/class.ilEventParticipants.php';
1267 
1268  $this->tpl->addBlockfile("EVENTS_TABLE","events_table", "tpl.table.html");
1269  $this->tpl->addBlockfile('TBL_CONTENT','tbl_content','tpl.sess_list_row.html','Modules/Session');
1270 
1271  $members_obj = $this->initContainer(true);
1272  $members = $members_obj->getParticipants();
1273  $members = ilUtil::_sortIds($members,'usr_data','lastname','usr_id');
1274 
1275  // Table
1276  $tbl = new ilTableGUI();
1277  $tbl->setTitle($this->lng->txt("event_overview"),
1278  'icon_usr.png',
1279  $this->lng->txt('obj_usr'));
1280  $this->ctrl->setParameter($this,'offset',(int) $_GET['offset']);
1281 
1282  $course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs');
1283  $events = array();
1284  foreach($tree->getSubtree($tree->getNodeData($course_ref_id),false,'sess') as $event_id)
1285  {
1286  $tmp_event = ilObjectFactory::getInstanceByRefId($event_id,false);
1287  if(!is_object($tmp_event) or $tmp_event->getType() != 'sess')
1288  {
1289  continue;
1290  }
1291  $events[] = $tmp_event;
1292  }
1293 
1294  $headerNames = array();
1295  $headerVars = array();
1296  $colWidth = array();
1297 
1298  $headerNames[] = $this->lng->txt('name');
1299  $headerVars[] = "name";
1300  $colWidth[] = '20%';
1301 
1302  for ($i = 1; $i <= count($events); $i++)
1303  {
1304  $headerNames[] = $i;
1305  $headerVars[] = "event_".$i;
1306  $colWidth[] = 80/count($events)."%";
1307  }
1308 
1309  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
1310  $tbl->setHeaderNames($headerNames);
1311  $tbl->setHeaderVars($headerVars, $this->ctrl->getParameterArray($this,'eventsList'));
1312  $tbl->setColumnWidth($colWidth);
1313 
1314  $tbl->setOrderColumn($_GET["sort_by"]);
1315  $tbl->setOrderDirection($_GET["sort_order"]);
1316  $tbl->setOffset($_GET["offset"]);
1317  $tbl->setLimit($ilUser->getPref("hits_per_page"));
1318  $tbl->setMaxCount(count($members));
1319  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1320 
1321  $sliced_users = array_slice($members,$_GET['offset'],$_SESSION['tbl_limit']);
1322  $tbl->disable('sort');
1323  $tbl->render();
1324 
1325  $counter = 0;
1326  foreach($sliced_users as $user_id)
1327  {
1328  foreach($events as $event_obj)
1329  {
1330  $this->tpl->setCurrentBlock("eventcols");
1331 
1332  $event_part = new ilEventParticipants($this->object->getId());
1333 
1334  {
1335  $this->tpl->setVariable("IMAGE_PARTICIPATED", $event_part->hasParticipated($user_id) ?
1336  ilUtil::getImagePath('icon_ok.png') :
1337  ilUtil::getImagePath('icon_not_ok.png'));
1338 
1339  $this->tpl->setVariable("PARTICIPATED", $event_part->hasParticipated($user_id) ?
1340  $this->lng->txt('event_participated') :
1341  $this->lng->txt('event_not_participated'));
1342  }
1343 
1344  $this->tpl->parseCurrentBlock();
1345  }
1346 
1347  $this->tpl->setCurrentBlock("tbl_content");
1348  $name = ilObjUser::_lookupName($user_id);
1349  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor($counter++,'tblrow1','tblrow2'));
1350  $this->tpl->setVariable("LASTNAME",$name['lastname']);
1351  $this->tpl->setVariable("FIRSTNAME",$name['firstname']);
1352  $this->tpl->setVariable("LOGIN",ilObjUser::_lookupLogin($user_id));
1353  $this->tpl->parseCurrentBlock();
1354  }
1355 
1356  $this->tpl->setVariable("HEAD_TXT_LEGEND", $this->lng->txt("legend"));
1357  $this->tpl->setVariable("HEAD_TXT_DIGIT", $this->lng->txt("event_digit"));
1358  $this->tpl->setVariable("HEAD_TXT_EVENT", $this->lng->txt("event"));
1359  $this->tpl->setVariable("HEAD_TXT_LOCATION", $this->lng->txt("event_location"));
1360  $this->tpl->setVariable("HEAD_TXT_DATE_TIME",$this->lng->txt("event_date_time"));
1361  $i = 1;
1362  foreach($events as $event_obj)
1363  {
1364  $this->tpl->setCurrentBlock("legend_loop");
1365  $this->tpl->setVariable("LEGEND_CSS_ROW",ilUtil::switchColor($counter++,'tblrow1','tblrow2'));
1366  $this->tpl->setVariable("LEGEND_DIGIT", $i++);
1367  $this->tpl->setVariable("LEGEND_EVENT_TITLE", $event_obj->getTitle());
1368  $this->tpl->setVariable("LEGEND_EVENT_DESCRIPTION", $event_obj->getDescription());
1369  $this->tpl->setVariable("LEGEND_EVENT_LOCATION", $event_obj->getLocation());
1370  $this->tpl->setVariable("LEGEND_EVENT_APPOINTMENT", $event_obj->getFirstAppointment()->appointmentToString());
1371  $this->tpl->parseCurrentBlock();
1372  }
1373 
1374  }
1375 
1381  protected function initForm($a_mode)
1382  {
1383  global $ilUser;
1384 
1385  if(is_object($this->form))
1386  {
1387  return true;
1388  }
1389 
1390  $this->lng->loadLanguageModule('dateplaner');
1391 
1392  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1393 
1394  include_once('./Services/YUI/classes/class.ilYuiUtil.php');
1396 
1397  $this->form = new ilPropertyFormGUI();
1398  $this->form->setMultipart(true);
1399  $this->form->setTableWidth('600px');
1400  $this->form->setFormAction($this->ctrl->getFormAction($this));
1401  $this->form->setMultipart(true);
1402 
1403  /*
1404  $full = new ilCheckboxInputGUI('','fulltime');
1405  $full->setChecked($this->object->getFirstAppointment()->enabledFulltime() ? true : false);
1406  $full->setOptionTitle($this->lng->txt('event_fulltime_info'));
1407  $full->setAdditionalAttributes('onchange="ilToggleSessionTime(this);"');
1408  #$this->form->addItem($full);
1409  */
1410 
1411  $this->lng->loadLanguageModule('dateplaner');
1412  include_once './Services/Form/classes/class.ilDateDurationInputGUI.php';
1413  #$this->tpl->addJavaScript('./Modules/Session/js/toggle_session_time.js');
1414  $this->tpl->addJavaScript('./Services/Form/js/date_duration.js');
1415  $dur = new ilDateDurationInputGUI($this->lng->txt('cal_fullday'),'event');
1416  $dur->setStartText($this->lng->txt('event_start_date'));
1417  $dur->setEndText($this->lng->txt('event_end_date'));
1418  $dur->enableToggleFullTime(
1419  $this->lng->txt('event_fulltime_info'),
1420  $this->object->getFirstAppointment()->enabledFulltime() ? true : false
1421  );
1422  $dur->setMinuteStepSize(5);
1423  $dur->setShowTime(true);
1424  $dur->setShowDate(true);
1425  $dur->setStart($this->object->getFirstAppointment()->getStart());
1426  $dur->setEnd($this->object->getFirstAppointment()->getEnd());
1427 
1428  $this->form->addItem($dur);
1429 
1430  /*
1431  // start
1432  $start = new ilDateTimeInputGUI($this->lng->txt('event_start_date'),'start');
1433  $start->setMinuteStepSize(5);
1434  $start->setDate($this->object->getFirstAppointment()->getStart());
1435  $start->setShowTime(true);
1436  #$this->form->addItem($start);
1437 
1438  // end
1439  $end = new ilDateTimeInputGUI($this->lng->txt('event_end_date'),'end');
1440  $end->setMinuteStepSize(5);
1441  $end->setDate($this->object->getFirstAppointment()->getEnd());
1442  $end->setShowTime(true);
1443  #$this->form->addItem($end);
1444  */
1445 
1446  // Recurrence
1447  if($a_mode == 'create')
1448  {
1449  if(!is_object($this->rec))
1450  {
1451  include_once('./Modules/Session/classes/class.ilEventRecurrence.php');
1452  $this->rec = new ilEventRecurrence();
1453  }
1454  include_once('./Services/Calendar/classes/Form/class.ilRecurrenceInputGUI.php');
1455  $rec = new ilRecurrenceInputGUI($this->lng->txt('cal_recurrences'),'frequence');
1456  $rec->allowUnlimitedRecurrences(false);
1457  $rec->setRecurrence($this->rec);
1458  $this->form->addItem($rec);
1459  }
1460 
1462  $section->setTitle($this->lng->txt('event_section_information'));
1463  $this->form->addItem($section);
1464 
1465  // title
1466  $title = new ilTextInputGUI($this->lng->txt('event_title'),'title');
1467  $title->setValue($this->object->getTitle());
1468  $title->setSize(50);
1469  $title->setMaxLength(70);
1470  $this->form->addItem($title);
1471 
1472  // desc
1473  $desc = new ilTextAreaInputGUI($this->lng->txt('event_desc'),'desc');
1474  $desc->setValue($this->object->getLongDescription());
1475  $desc->setRows(4);
1476  $desc->setCols(50);
1477  $this->form->addItem($desc);
1478 
1479  // location
1480  $desc = new ilTextAreaInputGUI($this->lng->txt('event_location'),'location');
1481  $desc->setValue($this->object->getLocation());
1482  $desc->setRows(4);
1483  $desc->setCols(50);
1484  $this->form->addItem($desc);
1485 
1486  // workflow
1487  $details = new ilTextAreaInputGUI($this->lng->txt('event_details_workflow'),'details');
1488  $details->setValue($this->object->getDetails());
1489  $details->setCols(50);
1490  $details->setRows(4);
1491  $this->form->addItem($details);
1492 
1493  // section
1495  $section->setTitle($this->lng->txt('event_tutor_data'));
1496  $this->form->addItem($section);
1497 
1498  // name
1499  $tutor_name = new ilTextInputGUI($this->lng->txt('tutor_name'),'tutor_name');
1500  $tutor_name->setValue($this->object->getName());
1501  $tutor_name->setSize(20);
1502  $tutor_name->setMaxLength(70);
1503  $this->form->addItem($tutor_name);
1504 
1505  // email
1506  $tutor_email = new ilTextInputGUI($this->lng->txt('tutor_email'),'tutor_email');
1507  $tutor_email->setValue($this->object->getEmail());
1508  $tutor_email->setSize(20);
1509  $tutor_email->setMaxLength(70);
1510  $this->form->addItem($tutor_email);
1511 
1512  // phone
1513  $tutor_phone = new ilTextInputGUI($this->lng->txt('tutor_phone'),'tutor_phone');
1514  $tutor_phone->setValue($this->object->getPhone());
1515  $tutor_phone->setSize(20);
1516  $tutor_phone->setMaxLength(70);
1517  $this->form->addItem($tutor_phone);
1518 
1520  $section->setTitle($this->lng->txt('crs_further_settings'));
1521  $this->form->addItem($section);
1522 
1523  // registration
1524  $reg = new ilCheckboxInputGUI($this->lng->txt('event_registration'),'registration');
1525  $reg->setChecked($this->object->enabledRegistration() ? true : false);
1526  $reg->setOptionTitle($this->lng->txt('event_registration_info'));
1527  $this->form->addItem($reg);
1528 
1529 
1531  $section->setTitle($this->lng->txt('event_assign_files'));
1532  $this->form->addItem($section);
1533 
1534  $files = new ilFileWizardInputGUI($this->lng->txt('objs_file'),'files');
1535  $files->setFilenames(array(0 => ''));
1536  $this->form->addItem($files);
1537 
1538  switch($a_mode)
1539  {
1540  case 'create':
1541  $this->form->setTitle($this->lng->txt('event_table_create'));
1542  $this->form->setTitleIcon(ilUtil::getImagePath('icon_event.png'));
1543 
1544  $this->form->addCommandButton('save',$this->lng->txt('event_btn_add'));
1545  $this->form->addCommandButton('saveAndAssignMaterials',$this->lng->txt('event_btn_add_edit'));
1546  $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
1547 
1548  return true;
1549 
1550  case 'edit':
1551  $this->form->setTitle($this->lng->txt('event_table_update'));
1552  $this->form->setTitleIcon(ilUtil::getImagePath('icon_event.png'));
1553 
1554  $this->form->addCommandButton('update',$this->lng->txt('save'));
1555  $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
1556 
1557  return true;
1558  }
1559  return true;
1560  }
1561 
1569  protected function load()
1570  {
1571  global $ilUser;
1572 
1573  $this->object->getFirstAppointment()->setStartingTime($this->__toUnix($_POST['event']['start']['date'],$_POST['event']['start']['time']));
1574  $this->object->getFirstAppointment()->setEndingTime($this->__toUnix($_POST['event']['end']['date'],$_POST['event']['end']['time']));
1575  $this->object->getFirstAppointment()->toggleFullTime((bool) $_POST['event']['fulltime']);
1576 
1577  include_once('./Services/Calendar/classes/class.ilDate.php');
1578  if($this->object->getFirstAppointment()->isFullday())
1579  {
1580  $start = new ilDate($_POST['event']['start']['date']['y'].'-'.$_POST['event']['start']['date']['m'].'-'.$_POST['event']['start']['date']['d'],
1581  IL_CAL_DATE);
1582  $this->object->getFirstAppointment()->setStart($start);
1583 
1584  $end = new ilDate($_POST['event']['end']['date']['y'].'-'.$_POST['event']['end']['date']['m'].'-'.$_POST['event']['end']['date']['d'],
1585  IL_CAL_DATE);
1586  $this->object->getFirstAppointment()->setEnd($end);
1587  }
1588  else
1589  {
1590  $start_dt['year'] = (int) $_POST['event']['start']['date']['y'];
1591  $start_dt['mon'] = (int) $_POST['event']['start']['date']['m'];
1592  $start_dt['mday'] = (int) $_POST['event']['start']['date']['d'];
1593  $start_dt['hours'] = (int) $_POST['event']['start']['time']['h'];
1594  $start_dt['minutes'] = (int) $_POST['event']['start']['time']['m'];
1595 
1596  $start = new ilDateTime($start_dt,IL_CAL_FKT_GETDATE,$ilUser->getTimeZone());
1597  $this->object->getFirstAppointment()->setStart($start);
1598 
1599  $end_dt['year'] = (int) $_POST['event']['end']['date']['y'];
1600  $end_dt['mon'] = (int) $_POST['event']['end']['date']['m'];
1601  $end_dt['mday'] = (int) $_POST['event']['end']['date']['d'];
1602  $end_dt['hours'] = (int) $_POST['event']['end']['time']['h'];
1603  $end_dt['minutes'] = (int) $_POST['event']['end']['time']['m'];
1604  $end = new ilDateTime($end_dt,IL_CAL_FKT_GETDATE,$ilUser->getTimeZone());
1605  $this->object->getFirstAppointment()->setEnd($end);
1606  }
1607 
1608  $this->object->setTitle(ilUtil::stripSlashes($_POST['title']));
1609  $this->object->setDescription(ilUtil::stripSlashes($_POST['desc']));
1610  $this->object->setLocation(ilUtil::stripSlashes($_POST['location']));
1611  $this->object->setName(ilUtil::stripSlashes($_POST['tutor_name']));
1612  $this->object->setPhone(ilUtil::stripSlashes($_POST['tutor_phone']));
1613  $this->object->setEmail(ilUtil::stripSlashes($_POST['tutor_email']));
1614  $this->object->setDetails(ilUtil::stripSlashes($_POST['details']));
1615  $this->object->enableRegistration((int) $_POST['registration']);
1616  }
1617 
1624  protected function loadRecurrenceSettings()
1625  {
1626  include_once('./Modules/Session/classes/class.ilSessionRecurrence.php');
1627  $this->rec = new ilSessionRecurrence();
1628 
1629  switch($_POST['frequence'])
1630  {
1631  case IL_CAL_FREQ_DAILY:
1632  $this->rec->setFrequenceType($_POST['frequence']);
1633  $this->rec->setInterval((int) $_POST['count_DAILY']);
1634  break;
1635 
1636  case IL_CAL_FREQ_WEEKLY:
1637  $this->rec->setFrequenceType($_POST['frequence']);
1638  $this->rec->setInterval((int) $_POST['count_WEEKLY']);
1639  if(is_array($_POST['byday_WEEKLY']))
1640  {
1641  $this->rec->setBYDAY(ilUtil::stripSlashes(implode(',',$_POST['byday_WEEKLY'])));
1642  }
1643  break;
1644 
1645  case IL_CAL_FREQ_MONTHLY:
1646  $this->rec->setFrequenceType($_POST['frequence']);
1647  $this->rec->setInterval((int) $_POST['count_MONTHLY']);
1648  switch((int) $_POST['subtype_MONTHLY'])
1649  {
1650  case 0:
1651  // nothing to do;
1652  break;
1653 
1654  case 1:
1655  switch((int) $_POST['monthly_byday_day'])
1656  {
1657  case 8:
1658  // Weekday
1659  $this->rec->setBYSETPOS((int) $_POST['monthly_byday_num']);
1660  $this->rec->setBYDAY('MO,TU,WE,TH,FR');
1661  break;
1662 
1663  case 9:
1664  // Day of month
1665  $this->rec->setBYMONTHDAY((int) $_POST['monthly_byday_num']);
1666  break;
1667 
1668  default:
1669  $this->rec->setBYDAY((int) $_POST['monthly_byday_num'].$_POST['monthly_byday_day']);
1670  break;
1671  }
1672  break;
1673 
1674  case 2:
1675  $this->rec->setBYMONTHDAY((int) $_POST['monthly_bymonthday']);
1676  break;
1677  }
1678  break;
1679 
1680  case IL_CAL_FREQ_YEARLY:
1681  $this->rec->setFrequenceType($_POST['frequence']);
1682  $this->rec->setInterval((int) $_POST['count_YEARLY']);
1683  switch((int) $_POST['subtype_YEARLY'])
1684  {
1685  case 0:
1686  // nothing to do;
1687  break;
1688 
1689  case 1:
1690  $this->rec->setBYMONTH((int) $_POST['yearly_bymonth_byday']);
1691  $this->rec->setBYDAY((int) $_POST['yearly_byday_num'].$_POST['yearly_byday']);
1692  break;
1693 
1694  case 2:
1695  $this->rec->setBYMONTH((int) $_POST['yearly_bymonth_by_monthday']);
1696  $this->rec->setBYMONTHDAY((int) $_POST['yearly_bymonthday']);
1697  break;
1698  }
1699  break;
1700  }
1701 
1702  // UNTIL
1703  switch((int) $_POST['until_type'])
1704  {
1705  case 1:
1706  $this->rec->setFrequenceUntilDate(null);
1707  // nothing to do
1708  break;
1709 
1710  case 2:
1711  $this->rec->setFrequenceUntilDate(null);
1712  $this->rec->setFrequenceUntilCount((int) $_POST['count']);
1713  break;
1714 
1715  case 3:
1716  $end_dt['year'] = (int) $_POST['until_end']['date']['y'];
1717  $end_dt['mon'] = (int) $_POST['until_end']['date']['m'];
1718  $end_dt['mday'] = (int) $_POST['until_end']['date']['d'];
1719 
1720  $this->rec->setFrequenceUntilCount(0);
1721  $this->rec->setFrequenceUntilDate(new ilDate($end_dt,IL_CAL_FKT_GETDATE,$this->timezone));
1722  break;
1723  }
1724  }
1725 
1726 
1734  protected function __toUnix($date,$time)
1735  {
1736  return mktime($time['h'],$time['m'],0,$date['m'],$date['d'],$date['y']);
1737  }
1738 
1745  protected function formatPath($a_ref_id)
1746  {
1747  global $tree;
1748 
1749  $path = $this->lng->txt('path') . ': ';
1750  $first = true;
1751  foreach($tree->getPathFull($a_ref_id,$this->container_ref_id) as $node)
1752  {
1753  if($node['ref_id'] != $a_ref_id)
1754  {
1755  if(!$first)
1756  {
1757  $path .= ' -> ';
1758  }
1759  $first = false;
1760  $path .= $node['title'];
1761  }
1762  }
1763  return $path;
1764  }
1765 
1772  public function addLocatorItems()
1773  {
1774  global $ilLocator;
1775 
1776  if (is_object($this->object))
1777  {
1778  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
1779  }
1780  }
1781 
1788  public function getTabs($tabs_gui)
1789  {
1790  global $ilAccess, $ilTabs, $tree, $ilCtrl, $ilHelp;
1791 
1792  $ilHelp->setScreenIdComponent("sess");
1793 
1794  $parent_id = $tree->getParentId($this->object->getRefId());
1795 
1796  // #11650
1797  $parent_type = ilObject::_lookupType($parent_id, true);
1798 
1799  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $parent_id);
1800  $tabs_gui->setBackTarget($this->lng->txt('back_to_'.$parent_type.'_content'),
1801  $ilCtrl->getLinkTargetByClass("ilrepositorygui", ""));
1802  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
1803 
1804  $tabs_gui->addTarget('info_short',
1805  $this->ctrl->getLinkTarget($this,'infoScreen'));
1806 
1807  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
1808  {
1809  $tabs_gui->addTarget('settings',
1810  $this->ctrl->getLinkTarget($this,'edit'));
1811  $tabs_gui->addTarget('crs_materials',
1812  $this->ctrl->getLinkTarget($this,'materials'));
1813  $tabs_gui->addTarget('event_edit_members',
1814  $this->ctrl->getLinkTarget($this,'members'));
1815  }
1816 
1817  // export
1818  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
1819  {
1820  $ilTabs->addTarget("export",
1821  $this->ctrl->getLinkTargetByClass("ilexportgui", ""), "", "ilexportgui");
1822  }
1823 
1824 
1825  // edit permissions
1826  if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId()))
1827  {
1828  $tabs_gui->addTarget("perm_settings",
1829  $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"), array("perm","info","owner"), 'ilpermissiongui');
1830  }
1831 
1832  }
1833 
1839  public function afterSaveCallback(ilObject $a_obj)
1840  {
1841  // add new object to materials
1842  include_once './Modules/Session/classes/class.ilEventItems.php';
1843  $event_items = new ilEventItems($this->object->getId());
1844  $event_items->addItem($a_obj->getRefId());
1845  $event_items->update();
1846 
1847  /*
1848  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
1849  $this->ctrl->redirect($this, "materials");
1850  */
1851  }
1852 }
1853 ?>