ILIAS  Release_4_2_x_branch Revision 61807
 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  case "ilcommonactiondispatchergui":
111  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
113  $this->ctrl->forwardCommand($gui);
114  break;
115 
116  default:
117  if(!$cmd)
118  {
119  $cmd = "infoScreen";
120  }
121  $cmd .= "Object";
122  if ($cmd != "infoScreenObject")
123  {
124  $this->checkPermission("read");
125  }
126  else
127  {
128  $this->checkPermission("visible");
129  }
130  $this->$cmd();
131 
132  break;
133  }
134 
135  $this->addHeaderAction();
136 
137  return true;
138  }
139 
143  protected function prepareOutput()
144  {
146 
147  if(!$this->getCreationMode())
148  {
149  $title = strlen($this->object->getTitle()) ? (': '.$this->object->getTitle()) : '';
150 
151  include_once './Modules/Session/classes/class.ilSessionAppointment.php';
152  $this->tpl->setTitle(
153  $this->object->getFirstAppointment()->appointmentToString().$title);
154  }
155  }
156 
164  public function registerObject()
165  {
166  global $ilUser;
167 
168  include_once 'Modules/Session/classes/class.ilEventParticipants.php';
169  ilEventParticipants::_register($ilUser->getId(),$this->object->getId());
170 
171  ilUtil::sendSuccess($this->lng->txt('event_registered'),true);
172  $this->ctrl->returnToParent($this);
173  }
174 
179  public function joinObject()
180  {
181  global $ilUser;
182 
183  $this->checkPermission('read');
184 
185  include_once './Modules/Session/classes/class.ilEventParticipants.php';
186 
187  if(ilEventParticipants::_isRegistered($ilUser->getId(),$this->object->getId()))
188  {
189  $_SESSION['sess_hide_info'] = true;
190  ilEventParticipants::_unregister($ilUser->getId(),$this->object->getId());
191  ilUtil::sendSuccess($this->lng->txt('event_unregistered'),true);
192  }
193  else
194  {
195  ilEventParticipants::_register($ilUser->getId(),$this->object->getId());
196  ilUtil::sendSuccess($this->lng->txt('event_registered'),true);
197  }
198 
199  $this->ctrl->redirect($this,'infoScreen');
200  }
201 
208  public function unregisterObject()
209  {
210  global $ilUser;
211 
212  include_once './Modules/Session/classes/class.ilEventParticipants.php';
213  ilEventParticipants::_unregister($ilUser->getId(),$this->object->getId());
214 
215  ilUtil::sendSuccess($this->lng->txt('event_unregistered'),true);
216  $this->ctrl->returnToParent($this);
217  }
218 
227  public static function _goto($a_target)
228  {
229  global $ilAccess,$ilErr,$lng;
230 
231  if($ilAccess->checkAccess('visible', "", $a_target))
232  {
233  $_GET["cmd"] = "infoScreen";
234  $_GET["ref_id"] = $a_target;
235  include("repository.php");
236  exit;
237  }
238  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
239  }
240 
244  public function addToDeskObject()
245  {
246  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
248  $this->infoScreenObject();
249  }
250 
254  public function removeFromDeskObject()
255  {
256  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
258  $this->infoScreenObject();
259  }
260 
261 
267  public function infoScreenObject()
268  {
269  $this->ctrl->setCmd("showSummary");
270  $this->ctrl->setCmdClass("ilinfoscreengui");
271  $this->infoScreen();
272  }
273 
277  function modifyItemGUI($a_item_list_gui,$a_item_data, $a_show_path)
278  {
279  global $tree;
280 
281  // if folder is in a course, modify item list gui according to course requirements
282  if ($course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs'))
283  {
284  include_once("./Modules/Course/classes/class.ilObjCourse.php");
285  include_once("./Modules/Course/classes/class.ilObjCourseGUI.php");
288  $a_item_list_gui,
289  get_class($this),
290  $a_item_data,
291  $a_show_path,
295  $this->object->getRefId());
296  }
297  }
298 
306  public function infoScreen()
307  {
308  global $ilAccess, $ilUser,$ilCtrl,$tree,$ilToolbar;
309 
310  $this->checkPermission('visible');
311  $this->tabs_gui->setTabActive('info_short');
312 
313  $appointment_obj = $this->object->getFirstAppointment();
314 
315  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
316  $info = new ilInfoScreenGUI($this);
317 
318  if($this->object->enabledRegistration())
319  {
320  include_once './Modules/Session/classes/class.ilEventParticipants.php';
321  if(ilEventParticipants::_isRegistered($ilUser->getId(), $this->object->getId()))
322  {
323  $ilToolbar->addFormButton($this->lng->txt('event_unregister'),'join');
324  }
325  else
326  {
327  if(!isset($_SESSION['sess_hide_info']))
328  {
329  ilUtil::sendInfo($this->lng->txt('sess_join_info'));
330  }
331  $ilToolbar->addFormButton($this->lng->txt('join_session'),'join');
332  }
333  $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
334  }
335 
336  // Session information
337  if(strlen($this->object->getLocation()) or strlen($this->object->getDetails()))
338  {
339  $info->addSection($this->lng->txt('event_section_information'));
340  }
341  if(strlen($location = $this->object->getLocation()))
342  {
343  $info->addProperty($this->lng->txt('event_location'),
344  nl2br($this->object->getLocation()));
345  }
346  if(strlen($this->object->getDetails()))
347  {
348  $info->addProperty($this->lng->txt('event_details_workflow'),
349  nl2br($this->object->getDetails()));
350  }
351 
352  // Tutor information
353  if($this->object->hasTutorSettings())
354  {
355  $info->addSection($this->lng->txt('event_tutor_data'));
356  if(strlen($fullname = $this->object->getName()))
357  {
358  $info->addProperty($this->lng->txt('event_lecturer'),
359  $fullname);
360  }
361  if(strlen($email = $this->object->getEmail()))
362  {
363  $info->addProperty($this->lng->txt('tutor_email'),
364  $email);
365  }
366  if(strlen($phone = $this->object->getPhone()))
367  {
368  $info->addProperty($this->lng->txt('tutor_phone'),
369  $phone);
370  }
371  }
372 
373  include_once './Modules/Session/classes/class.ilSessionObjectListGUIFactory.php';
374  include_once './Modules/Session/classes/class.ilEventItems.php';
375  include_once './Modules/Course/classes/class.ilCourseItems.php';
376 
377  $html = '';
378  $eventItems = new ilEventItems($this->object->getId());
379 
380  $parent_id = $tree->getParentId($this->object->getRefId());
381  $items = new ilCourseItems($parent_id);
382  $eventItems = $items->getItemsByEvent($this->object->getId());
383  include_once './Services/Container/classes/class.ilContainerSorting.php';
384  $eventItems = ilContainerSorting::_getInstance(
385  ilObject::_lookupObjId($parent_id))->sortSubItems(
386  'sess',
387  $this->object->getId(),
388  $eventItems
389  );
390 
391  foreach($eventItems as $item)
392  {
393  $item_id = $item['ref_id'];
394  $obj_id = ilObject::_lookupObjId($item_id);
396 
397 
398  $list_gui = ilSessionObjectListGUIFactory::factory($type);
399  $list_gui->setContainerObject($this);
400  $this->modifyItemGUI($list_gui, ilCourseItems::_getItem($item_id),false);
401 
402  $html .= $list_gui->getListItemHTML(
403  $item_id,
404  $obj_id,
407  );
408  }
409 
410  if(strlen($html))
411  {
412  $info->addSection($this->lng->txt('event_materials'));
413  $info->addProperty(
414  '&nbsp;',
415  $html);
416  }
417 
418  // forward the command
419  $this->ctrl->forwardCommand($info);
420 
421  // store read event
422  require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
423  ilChangeEvent::_recordReadEvent($this->object->getType(), $this->object->getRefId(),
424  $this->object->getId(), $ilUser->getId());
425  }
426 
432  public function sendFileObject()
433  {
434  $file = new ilSessionFile((int) $_GET['file_id']);
435 
436  ilUtil::deliverFile($file->getAbsolutePath(),$file->getFileName(),$file->getFileType());
437  return true;
438  }
439 
440  protected function initCreateForm($a_new_type)
441  {
442  if(!is_object($this->object))
443  {
444  $this->object = new ilObjSession();
445  }
446  $this->initForm('create');
447  return $this->form;
448  }
449 
456  {
457  global $ilLog;
458 
459  $this->saveObject(false);
460 
461  /*
462  $this->ctrl->setParameter($this,'ref_id',$this->object->getRefId());
463  $target = $this->ctrl->getLinkTarget($this,'materials');
464  $target = str_replace('new_type=','nt=',$target);
465  */
466  $this->ctrl->setParameter($this,'ref_id',$this->object->getRefId());
467  $this->ctrl->redirect($this,'materials');
468  }
469 
477  public function saveObject($a_redirect_on_success = true)
478  {
479  global $ilErr,$ilUser;
480 
481  $this->object = new ilObjSession();
482 
483  $this->load();
484  $this->loadRecurrenceSettings();
485  $this->initForm('create');
486 
487  $ilErr->setMessage('');
488  if(!$this->form->checkInput()) {
489  $ilErr->setMessage($this->lng->txt('err_check_input'));
490  }
491 
492  $this->object->validate();
493  $this->object->getFirstAppointment()->validate();
494 
495  if(strlen($ilErr->getMessage()))
496  {
497  ilUtil::sendFailure($ilErr->getMessage().$_GET['ref_id']);
498  $this->createObject();
499  return false;
500  }
501  // Create session
502  $this->object->create();
503  $this->object->createReference();
504  $this->object->putInTree($_GET["ref_id"]);
505  $this->object->setPermissions($_GET["ref_id"]);
506 
507  // create appointment
508  $this->object->getFirstAppointment()->setSessionId($this->object->getId());
509  $this->object->getFirstAppointment()->create();
510 
511  $this->handleFileUpload();
512 
513  $this->createRecurringSessions();
514 
515  // call crs items for creating a new entry for the new session
516  // Otherwise the sorting of sessions is wrong.
517  // TODO find a better solution
518  include_once './Modules/Course/classes/class.ilCourseItems.php';
519  $tmp_course = ilObjectFactory::getInstanceByRefId((int) $_GET['ref_id'],false);
520  $items = new ilCourseItems($tmp_course->getRefId());
521 
522  if($a_redirect_on_success)
523  {
524  ilUtil::sendInfo($this->lng->txt('event_add_new_event'),true);
525  $this->ctrl->returnToParent($this);
526  }
527 
528  return true;
529 
530  }
531 
532  public function handleFileUpload()
533  {
534  global $tree;
535 
536  include_once './Modules/Session/classes/class.ilEventItems.php';
537  $ev = new ilEventItems($this->object->getId());
538  $items = $ev->getItems();
539 
540  $counter = 0;
541  while(true)
542  {
543  if(!isset($_FILES['files']['name'][$counter]))
544  {
545  break;
546  }
547  if(!strlen($_FILES['files']['name'][$counter]))
548  {
549  $counter++;
550  continue;
551  }
552 
553  include_once './Modules/File/classes/class.ilObjFile.php';
554  $file = new ilObjFile();
555  $file->setTitle(ilUtil::stripSlashes($_FILES['files']['name'][$counter]));
556  $file->setDescription('');
557  $file->setFileName(ilUtil::stripSlashes($_FILES['files']['name'][$counter]));
558  $file->setFileType($_FILES['files']['type'][$counter]);
559  $file->setFileSize($_FILES['files']['size'][$counter]);
560  $file->create();
561  $new_ref_id = $file->createReference();
562  $file->putInTree($tree->getParentId($this->object->getRefId()));
563  $file->setPermissions($tree->getParentId($this->object->getRefId()));
564  $file->createDirectory();
565  $file->getUploadFile(
566  $_FILES['files']['tmp_name'][$counter],
567  $_FILES['files']['name'][$counter]
568  );
569 
570  $items[] = $new_ref_id;
571  $counter++;
572 
573  }
574 
575  $ev->setItems($items);
576  $ev->update();
577  }
578 
579 
580 
588  protected function createRecurringSessions()
589  {
590  global $tree;
591 
592  if(!$this->rec->getFrequenceType())
593  {
594  return true;
595  }
596  include_once('./Services/Calendar/classes/class.ilCalendarRecurrenceCalculator.php');
597  $calc = new ilCalendarRecurrenceCalculator($this->object->getFirstAppointment(),$this->rec);
598 
599  $period_start = clone $this->object->getFirstAppointment()->getStart();
600 
601 
602  $period_end = clone $this->object->getFirstAppointment()->getStart();
603  $period_end->increment(IL_CAL_YEAR,5);
604  $date_list = $calc->calculateDateList($period_start,$period_end);
605 
606  $period_diff = $this->object->getFirstAppointment()->getEnd()->get(IL_CAL_UNIX) -
607  $this->object->getFirstAppointment()->getStart()->get(IL_CAL_UNIX);
608  $parent_id = $tree->getParentId($this->object->getRefId());
609 
610  include_once './Modules/Session/classes/class.ilEventItems.php';
611  $evi = new ilEventItems($this->object->getId());
612  $eitems = $evi->getItems();
613 
614  $counter = 0;
615  foreach($date_list->get() as $date)
616  {
617  if(!$counter++)
618  {
619  continue;
620  }
621 
622  $new_obj = $this->object->cloneObject($parent_id);
623  $new_obj->read();
624  $new_obj->getFirstAppointment()->setStartingTime($date->get(IL_CAL_UNIX));
625  $new_obj->getFirstAppointment()->setEndingTime($date->get(IL_CAL_UNIX) + $period_diff);
626  $new_obj->getFirstAppointment()->update();
627  $new_obj->update();
628 
629  $new_evi = new ilEventItems($new_obj->getId());
630  $new_evi->setItems($eitems);
631  $new_evi->update();
632  }
633  }
634 
635 
643  public function editObject()
644  {
645  $this->tabs_gui->setTabActive('edit_properties');
646 
647  $this->initForm('edit');
648  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.sess_edit.html','Modules/Session');
649  $this->tpl->setVariable('EVENT_EDIT_TABLE',$this->form->getHTML());
650 
651  if(!count($this->object->getFiles()))
652  {
653  return true;
654  }
655  $rows = array();
656  foreach($this->object->getFiles() as $file)
657  {
658  $table_data['id'] = $file->getFileId();
659  $table_data['filename'] = $file->getFileName();
660  $table_data['filetype'] = $file->getFileType();
661  $table_data['filesize'] = $file->getFileSize();
662 
663  $rows[] = $table_data;
664  }
665 
666  include_once("./Modules/Session/classes/class.ilSessionFileTableGUI.php");
667  $table_gui = new ilSessionFileTableGUI($this, "edit");
668  $table_gui->setTitle($this->lng->txt("event_files"));
669  $table_gui->setData($rows);
670  $table_gui->addCommandButton("cancel", $this->lng->txt("cancel"));
671  $table_gui->addMultiCommand("confirmDeleteFiles", $this->lng->txt("delete"));
672  $table_gui->setSelectAllCheckbox("file_id");
673  $this->tpl->setVariable('EVENT_FILE_TABLE',$table_gui->getHTML());
674 
675  return true;
676  }
677 
685  public function updateObject()
686  {
687  global $ilErr;
688 
689  $this->load();
690  $this->initForm('edit');
691 
692  $ilErr->setMessage('');
693  if(!$this->form->checkInput())
694  {
695  $ilErr->setMessage($this->lng->txt('err_check_input'));
696  }
697  $this->object->validate();
698  $this->object->getFirstAppointment()->validate();
699 
700  if(strlen($ilErr->getMessage()))
701  {
702  ilUtil::sendFailure($ilErr->getMessage());
703  $this->editObject();
704  return false;
705  }
706  // Update event
707  $this->object->update();
708  $this->object->getFirstAppointment()->update();
709 
710  $this->handleFileUpload();
711 
712  ilUtil::sendSuccess($this->lng->txt('event_updated'),true);
713  $this->ctrl->redirect($this,'edit');
714  #$this->object->initFiles();
715  #$this->editObject();
716  return true;
717  }
718 
726  public function confirmDeleteFilesObject()
727  {
728  $this->tabs_gui->setTabActive('edit_properties');
729 
730  if(!count($_POST['file_id']))
731  {
732  ilUtil::sendFailure($this->lng->txt('select_one'));
733  $this->editObject();
734  return false;
735  }
736 
737  include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
738  $c_gui = new ilConfirmationGUI();
739 
740  // set confirm/cancel commands
741  $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteFiles"));
742  $c_gui->setHeaderText($this->lng->txt("info_delete_sure"));
743  $c_gui->setCancel($this->lng->txt("cancel"), "edit");
744  $c_gui->setConfirm($this->lng->txt("confirm"), "deleteFiles");
745 
746  // add items to delete
747  foreach($_POST["file_id"] as $file_id)
748  {
749  $file = new ilSessionFile($file_id);
750  if($file->getSessionId() != $this->object->getEventId())
751  {
752  ilUtil::sendFailure($this->lng->txt('select_one'));
753  $this->edit();
754  return false;
755  }
756  $c_gui->addItem("file_id[]", $file_id, $file->getFileName());
757  }
758 
759  $this->tpl->setContent($c_gui->getHTML());
760  return true;
761  }
762 
770  public function deleteFilesObject()
771  {
772  if(!count($_POST['file_id']))
773  {
774  ilUtil::sendFailure($this->lng->txt('select_one'));
775  $this->editObject();
776  return false;
777  }
778  foreach($_POST['file_id'] as $id)
779  {
780  $file = new ilSessionFile($id);
781  $file->delete();
782  }
783  $this->object->initFiles();
784  $this->editObject();
785  return true;
786  }
787 
795  public function materialsObject()
796  {
797  global $tree, $objDefinition;
798 
799  $this->tabs_gui->setTabActive('crs_materials');
800 
801  include_once 'Modules/Session/classes/class.ilEventItems.php';
802  $this->event_items = new ilEventItems($this->object->getId());
803  $items = $this->event_items->getItems();
804 
805  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.sess_materials.html','Modules/Session');
806  #$this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
807 
808  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this,'materials'));
809  $this->tpl->setVariable("COLL_TITLE_IMG",ilUtil::getImagePath('icon_sess.gif'));
810  $this->tpl->setVariable("COLL_TITLE_IMG_ALT",$this->lng->txt('events'));
811  $this->tpl->setVariable("TABLE_TITLE",$this->lng->txt('event_assign_materials_table'));
812  $this->tpl->setVariable("TABLE_INFO",$this->lng->txt('event_assign_materials_info'));
813 
814  $this->course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs');
815  if(!$this->course_ref_id)
816  {
817  ilUtil::sendFailure('No course object found. Aborting');
818  return true;
819  }
820 
821  $materials = array();
822  $nodes = $tree->getSubTree($tree->getNodeData($this->course_ref_id));
823  foreach($nodes as $node)
824  {
825  // No side blocks here
826  if ($objDefinition->isSideBlock($node['type']) or $node['type'] == 'sess')
827  {
828  continue;
829  }
830 
831  if($node['type'] == 'rolf')
832  {
833  continue;
834  }
835 
836  $node["sorthash"] = (int)(!in_array($node['ref_id'],$items)).$node["title"];
837  $materials[] = $node;
838  }
839 
840 
841  $materials = ilUtil::sortArray($materials, "sorthash", "ASC");
842 
843  $counter = 1;
844  foreach($materials as $node)
845  {
846  $counter++;
847 
848  $this->tpl->setCurrentBlock("material_row");
849 
850  $this->tpl->setVariable('TYPE_IMG',ilUtil::getImagePath('icon_'.$node['type'].'_s.gif'));
851  $this->tpl->setVariable('IMG_ALT',$this->lng->txt('obj_'.$node['type']));
852  $this->tpl->setVariable("ROW_CLASS",ilUtil::switchColor($counter,'tblrow1','tblrow2'));
853  $this->tpl->setVariable("CHECK_COLL",ilUtil::formCheckbox(in_array($node['ref_id'],$items) ? 1 : 0,
854  'items[]',$node['ref_id']));
855  $this->tpl->setVariable("COLL_TITLE",$node['title']);
856 
857  if(strlen($node['description']))
858  {
859  $this->tpl->setVariable("COLL_DESC",$node['description']);
860  }
861  $this->tpl->setVariable("ASSIGNED_IMG_OK",in_array($node['ref_id'],$items) ?
862  ilUtil::getImagePath('icon_ok.gif') :
863  ilUtil::getImagePath('icon_not_ok.gif'));
864  $this->tpl->setVariable("ASSIGNED_STATUS",$this->lng->txt('event_material_assigned'));
865  $this->tpl->setVariable("COLL_PATH",$this->formatPath($node['ref_id']));
866  $this->tpl->parseCurrentBlock();
867  }
868 
869  $this->tpl->setVariable("SELECT_ROW",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
870  $this->tpl->setVariable("SELECT_ALL",$this->lng->txt('select_all'));
871  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
872  $this->tpl->setVariable("BTN_SAVE",$this->lng->txt('save'));
873  }
874 
882  public function saveMaterialsObject()
883  {
884  include_once './Modules/Session/classes/class.ilEventItems.php';
885 
886  $this->event_items = new ilEventItems($this->object->getId());
887  $this->event_items->setItems(is_array($_POST['items']) ? $_POST['items'] : array());
888  $this->event_items->update();
889 
890  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
891  $this->materialsObject();
892  }
893 
898  protected function membersObject()
899  {
900  global $tree,$ilUser;
901 
902  $this->checkPermission('write');
903  $this->tabs_gui->setTabActive('event_edit_members');
904 
905  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.sess_members.html', 'Modules/Session');
906 
907  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
908  $toolbar = new ilToolbarGUI();
909  $toolbar->addButton(
910  $this->lng->txt('print'),
911  $this->ctrl->getLinkTarget($this,'printViewMembers'),
912  '_blank');
913  $toolbar->addButton($this->lng->txt('sess_gen_attendance_list'),
914  $this->ctrl->getLinkTarget($this,'attendanceList'));
915 
916  $this->tpl->setVariable('ACTION_BUTTONS',$toolbar->getHTML());
917 
918  $this->course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs');
919  $this->course_obj_id = ilObject::_lookupObjId($this->course_ref_id);
920  if(!$this->course_ref_id)
921  {
922  ilUtil::sendFailure('No course object found. Aborting');
923  return true;
924  }
925 
926  include_once './Modules/Course/classes/class.ilCourseParticipants.php';
927  include_once './Modules/Session/classes/class.ilEventParticipants.php';
928 
929  $members_obj = ilCourseParticipants::_getInstanceByObjId($this->course_obj_id);
930  $event_part = new ilEventParticipants($this->object->getId());
931 
932  // Save hide/show table settings
933  $this->setShowHidePrefs();
934 
935  // Admins
936  if(count($admins = $members_obj->getAdmins()))
937  {
938  include_once('./Modules/Session/classes/class.ilSessionParticipantsTableGUI.php');
939  if($ilUser->getPref('sess_admin_hide'))
940  {
942  $this->ctrl->setParameter($this,'admin_hide',0);
943  $table->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
944  $this->lng->txt('show'),
945  '',
946  ilUtil::getImagePath('edit_add.png'));
947  $this->ctrl->clearParameters($this);
948  }
949  else
950  {
952  $this->ctrl->setParameter($this,'admin_hide',1);
953  $table->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
954  $this->lng->txt('hide'),
955  '',
956  ilUtil::getImagePath('edit_remove.png'));
957  $this->ctrl->clearParameters($this);
958  }
959 
960  $table->addCommandButton('updateMembers',$this->lng->txt('save'));
961  $table->setTitle($this->lng->txt('event_tbl_admins'),'icon_usr.gif',$this->lng->txt('event_tbl_admins'));
962  $table->enableRegistration($this->object->enabledRegistration());
963  $table->setParticipants($admins);
964  $table->parse();
965  $this->tpl->setVariable('ADMINS',$table->getHTML());
966  }
967 
968  // Tutors
969  if(count($tutors = $members_obj->getTutors()))
970  {
971  include_once('./Modules/Session/classes/class.ilSessionParticipantsTableGUI.php');
972  if($ilUser->getPref('sess_tutor_hide'))
973  {
975  $this->ctrl->setParameter($this,'tutor_hide',0);
976  $table->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
977  $this->lng->txt('show'),
978  '',
979  ilUtil::getImagePath('edit_add.png'));
980  $this->ctrl->clearParameters($this);
981  }
982  else
983  {
985  $this->ctrl->setParameter($this,'tutor_hide',1);
986  $table->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
987  $this->lng->txt('hide'),
988  '',
989  ilUtil::getImagePath('edit_remove.png'));
990  $this->ctrl->clearParameters($this);
991  }
992  $table->addCommandButton('updateMembers',$this->lng->txt('save'));
993  $table->setTitle($this->lng->txt('event_tbl_tutors'),'icon_usr.gif',$this->lng->txt('event_tbl_admins'));
994  $table->enableRegistration($this->object->enabledRegistration());
995  $table->setParticipants($tutors);
996  $table->parse();
997  $this->tpl->setVariable('TUTORS',$table->getHTML());
998  }
999 
1000  // Members
1001  if(count($members = $members_obj->getMembers()))
1002  {
1003  include_once('./Modules/Session/classes/class.ilSessionParticipantsTableGUI.php');
1004  if($ilUser->getPref('sess_member_hide'))
1005  {
1007  $this->ctrl->setParameter($this,'member_hide',0);
1008  $table->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1009  $this->lng->txt('show'),
1010  '',
1011  ilUtil::getImagePath('edit_add.png'));
1012  $this->ctrl->clearParameters($this);
1013  }
1014  else
1015  {
1017  $this->ctrl->setParameter($this,'member_hide',1);
1018  $table->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1019  $this->lng->txt('hide'),
1020  '',
1021  ilUtil::getImagePath('edit_remove.png'));
1022  $this->ctrl->clearParameters($this);
1023  }
1024  $table->addCommandButton('updateMembers',$this->lng->txt('save'));
1025  $table->setTitle($this->lng->txt('event_tbl_members'),'icon_usr.gif',$this->lng->txt('event_tbl_admins'));
1026  $table->enableRegistration($this->object->enabledRegistration());
1027  $table->setParticipants($members);
1028  $table->parse();
1029  $this->tpl->setVariable('MEMBERS',$table->getHTML());
1030  }
1031 
1032 
1033 
1034 
1035 
1036  }
1037 
1044  public function setShowHidePrefs()
1045  {
1046  global $ilUser;
1047 
1048  if(isset($_GET['admin_hide']))
1049  {
1050  $ilUser->writePref('sess_admin_hide',(int) $_GET['admin_hide']);
1051  }
1052  if(isset($_GET['tutor_hide']))
1053  {
1054  $ilUser->writePref('sess_tutor_hide',(int) $_GET['tutor_hide']);
1055  }
1056  if(isset($_GET['member_hide']))
1057  {
1058  $ilUser->writePref('sess_member_hide',(int) $_GET['member_hide']);
1059  }
1060  }
1061 
1069  public function updateMembersObject()
1070  {
1071  global $tree;
1072 
1073  $this->checkPermission('write');
1074 
1075  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
1076  include_once 'Modules/Session/classes/class.ilEventParticipants.php';
1077 
1078  $this->course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs');
1079  $this->course_obj_id = ilObject::_lookupObjId($this->course_ref_id);
1080  if(!$this->course_ref_id)
1081  {
1082  ilUtil::sendFailure('No course object found. Aborting');
1083  return true;
1084  }
1085 
1086  $_POST['participants'] = is_array($_POST['participants']) ? $_POST['participants'] : array();
1087 
1088  $members_obj = ilCourseParticipants::_getInstanceByObjId($this->course_obj_id);
1089  $event_part = new ilEventParticipants($this->object->getId());
1090 
1091  $visible = $_POST['visible_participants'] ? $_POST['visible_participants'] : array();
1092  foreach($visible as $user)
1093  {
1094  $part = new ilEventParticipants($this->object->getId());
1095  $part->setUserId($user);
1096  $part->setMark(ilUtil::stripSlashes($_POST['mark'][$user]));
1097  $part->setComment(ilUtil::stripSlashes($_POST['comment'][$user]));
1098  $part->setParticipated(isset($_POST['participants'][$user]) ? true : false);
1099  $part->setRegistered(ilEventParticipants::_isRegistered($user,$this->object->getId()));
1100  $part->updateUser();
1101  }
1102  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
1103  $this->membersObject();
1104  }
1105 
1112  public function attendanceListObject()
1113  {
1114  global $tpl,$ilTabs;
1115 
1116  $this->checkPermission('write');
1117 
1118  $ilTabs->setTabActive('event_edit_members');
1119 
1120  $this->initAttendanceForm();
1121  $tpl->setContent($this->form->getHTML());
1122 
1123  }
1124 
1131  protected function initAttendanceForm()
1132  {
1133  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
1134 
1135  $this->form = new ilPropertyFormGUI();
1136  $this->form->setFormAction($this->ctrl->getFormAction($this));
1137  $this->form->setTarget('_blank');
1138  $this->form->setTitle($this->lng->txt('sess_gen_attendance_list'));
1139 
1140  $mark = new ilCheckboxInputGUI($this->lng->txt('trac_mark'),'show_mark');
1141  $mark->setOptionTitle($this->lng->txt('sess_gen_mark_title'));
1142  $mark->setValue(1);
1143  $this->form->addItem($mark);
1144 
1145  $comment = new ilCheckboxInputGUI($this->lng->txt('trac_comment'),'show_comment');
1146  $comment->setOptionTitle($this->lng->txt('sess_gen_comment'));
1147  $comment->setValue(1);
1148  $this->form->addItem($comment);
1149 
1150  $signature = new ilCheckboxInputGUI($this->lng->txt('sess_signature'),'show_signature');
1151  $signature->setOptionTitle($this->lng->txt('sess_gen_signature'));
1152  $signature->setValue(1);
1153  $this->form->addItem($signature);
1154 
1155  $part = new ilFormSectionHeaderGUI();
1156  $part->setTitle($this->lng->txt('event_participant_selection'));
1157  $this->form->addItem($part);
1158 
1159  // Admins
1160  $admin = new ilCheckboxInputGUI($this->lng->txt('event_tbl_admins'),'show_admins');
1161  $admin->setOptionTitle($this->lng->txt('event_inc_admins'));
1162  $admin->setValue(1);
1163  $this->form->addItem($admin);
1164 
1165  // Tutors
1166  $tutor = new ilCheckboxInputGUI($this->lng->txt('event_tbl_tutors'),'show_tutors');
1167  $tutor->setOptionTitle($this->lng->txt('event_inc_tutors'));
1168  $tutor->setValue(1);
1169  $this->form->addItem($tutor);
1170 
1171  // Members
1172  $member = new ilCheckboxInputGUI($this->lng->txt('event_tbl_members'),'show_members');
1173  $member->setOptionTitle($this->lng->txt('event_inc_members'));
1174  $member->setValue(1);
1175  $member->setChecked(true);
1176  $this->form->addItem($member);
1177 
1178  $this->form->addCommandButton('printAttendanceList',$this->lng->txt('sess_print_attendance_list'));
1179  #$this->form->addCommandButton('members', $this->lng->txt('cancel'));
1180 
1181  }
1182 
1188  protected function printAttendanceListObject()
1189  {
1190  global $ilErr,$ilAccess,$tree;
1191 
1192  include_once 'Modules/Session/classes/class.ilEventParticipants.php';
1193  include_once('./Modules/Course/classes/class.ilCourseParticipants.php');
1194 
1195  $this->checkPermission('write');
1196 
1197  $this->course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs');
1198  $this->course_obj_id = ilObject::_lookupObjId($this->course_ref_id);
1199  if(!$this->course_ref_id)
1200  {
1201  ilUtil::sendFailure('No course object found. Aborting');
1202  return true;
1203  }
1204 
1205  $members_obj = ilCourseParticipants::_getInstanceByObjId($this->course_obj_id);
1206  $event_app = $this->object->getFirstAppointment();
1207  $event_part = new ilEventParticipants($this->object->getId());
1208 
1209 
1210  $this->tpl = new ilTemplate('tpl.main.html',true,true);
1211  // load style sheet depending on user's settings
1212  $location_stylesheet = ilUtil::getStyleSheetLocation();
1213  $this->tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
1214 
1215  $tpl = new ilTemplate('tpl.sess_attendance_list_print.html',true,true,'Modules/Session');
1216 
1217  $tpl->setVariable("ATTENDANCE_LIST",$this->lng->txt('sess_attendance_list'));
1218  $tpl->setVariable("EVENT_NAME",$this->object->getTitle() ? ': '.$this->object->getTitle() : '');
1220  $tpl->setVariable("DATE",ilDatePresentation::formatPeriod($event_app->getStart(),$event_app->getEnd()));
1222 
1223  $tpl->setVariable("TXT_NAME",$this->lng->txt('name'));
1224  if($_POST['show_mark'])
1225  {
1226  $tpl->setVariable("TXT_MARK",$this->lng->txt('trac_mark'));
1227  }
1228  if($_POST['show_comment'])
1229  {
1230  $tpl->setVariable("TXT_COMMENT",$this->lng->txt('trac_comment'));
1231  }
1232  if($_POST['show_signature'])
1233  {
1234  $tpl->setVariable("TXT_SIGNATURE",$this->lng->txt('sess_signature'));
1235  }
1236 
1237  if($_POST['show_admins'])
1238  {
1239  $members = array_merge((array) $members,$members_obj->getAdmins());
1240  }
1241  if($_POST['show_tutors'])
1242  {
1243  $members = array_merge((array) $members,$members_obj->getTutors());
1244  }
1245  if($_POST['show_members'])
1246  {
1247  $members = array_merge((array) $members,$members_obj->getMembers());
1248  }
1249  $members = ilUtil::_sortIds((array) $members,'usr_data','lastname','usr_id');
1250 
1251  foreach($members as $user_id)
1252  {
1253  $user_data = $event_part->getUser($user_id);
1254 
1255  if($_POST['show_mark'])
1256  {
1257  $tpl->setVariable("MARK",$user_data['mark'] ? $user_data['mark'] : ' ');
1258  }
1259  if($_POST['show_comment'])
1260  {
1261  $tpl->setVariable("COMMENT",$user_data['comment'] ? $user_data['comment'] : ' ');
1262  }
1263  if($_POST['show_signature'])
1264  {
1265  $tpl->touchBlock('row_signature');
1266  }
1267 
1268  $tpl->setCurrentBlock("member_row");
1269  $name = ilObjUser::_lookupName($user_id);
1270  $tpl->setVariable("LASTNAME",$name['lastname']);
1271  $tpl->setVariable("FIRSTNAME",$name['firstname']);
1272  $tpl->setVariable("LOGIN",ilObjUser::_lookupLogin($user_id));
1273  $tpl->parseCurrentBlock();
1274  }
1275 
1276  $this->tpl->setVariable("CONTENT",$tpl->get());
1277  $this->tpl->setVariable("BODY_ATTRIBUTES",'onload="window.print()"');
1278  $this->tpl->show();
1279  exit;
1280  }
1281 
1282 
1290  public function printViewMembersObject()
1291  {
1292  include_once 'Modules/Session/classes/class.ilEventParticipants.php';
1293  include_once('./Modules/Course/classes/class.ilCourseParticipants.php');
1294 
1295  global $ilErr,$ilAccess,$tree,$ilUser;
1296 
1297  $this->course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs');
1298  $this->course_obj_id = ilObject::_lookupObjId($this->course_ref_id);
1299  if(!$this->course_ref_id)
1300  {
1301  ilUtil::sendFailure('No course object found. Aborting');
1302  return true;
1303  }
1304 
1305  $members_obj = ilCourseParticipants::_getInstanceByObjId($this->course_obj_id);
1306  $event_app = $this->object->getFirstAppointment();
1307  $event_part = new ilEventParticipants($this->object->getId());
1308 
1309  $this->tpl = new ilTemplate('tpl.main.html',true,true);
1310  // load style sheet depending on user's settings
1311  $location_stylesheet = ilUtil::getStyleSheetLocation();
1312  $this->tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
1313 
1314  $tpl = new ilTemplate('tpl.sess_members_print.html',true,true,'Modules/Session');
1315 
1316  #$tpl->setVariable("EVENT",$this->lng->txt('event'));
1317  $tpl->setVariable("EVENT_NAME",$this->object->getTitle() ? ': '.$this->object->getTitle() : $this->object->getTitle());
1319  $tpl->setVariable("DATE",ilDatePresentation::formatPeriod($event_app->getStart(),$event_app->getEnd()));
1321 
1322 
1323  if(!$ilUser->getPref('sess_admin_hide') and count($members_obj->getAdmins()))
1324  {
1325  $tmp['txt'] = $this->lng->txt('event_tbl_admins');
1326  $tmp['users'] = $members_obj->getAdmins();
1327 
1328  $participants[] = $tmp;
1329  }
1330  if(!$ilUser->getPref('sess_tutor_hide') and count($members_obj->getTutors()))
1331  {
1332  $tmp['txt'] = $this->lng->txt('event_tbl_tutors');
1333  $tmp['users'] = $members_obj->getTutors();
1334 
1335  $participants[] = $tmp;
1336  }
1337  if(!$ilUser->getPref('sess_member_hide') and count($members_obj->getMembers()))
1338  {
1339  $tmp['txt'] = $this->lng->txt('event_tbl_members');
1340  $tmp['users'] = $members_obj->getMembers();
1341 
1342  $participants[] = $tmp;
1343  }
1344 
1345  foreach((array) $participants as $participants_data)
1346  {
1347  $members = ilUtil::_sortIds($participants_data['users'],'usr_data','lastname','usr_id');
1348  foreach($members as $user_id)
1349  {
1350 
1351  $user_data = $event_part->getUser($user_id);
1352 
1353  if($this->object->enabledRegistration())
1354  {
1355  $tpl->setCurrentBlock("reg_col");
1356  $tpl->setVariable("REGISTERED",$event_part->isRegistered($user_id) ? "X" : "");
1357  $tpl->parseCurrentBlock();
1358  }
1359  $tpl->setVariable("COMMENT",$user_data['comment']);
1360 
1361  $tpl->setCurrentBlock("member_row");
1362  $name = ilObjUser::_lookupName($user_id);
1363  $tpl->setVariable("LASTNAME",$name['lastname']);
1364  $tpl->setVariable("FIRSTNAME",$name['firstname']);
1365  $tpl->setVariable("LOGIN",ilObjUser::_lookupLogin($user_id));
1366  $tpl->setVariable("MARK",$user_data['mark']);
1367  $tpl->setVariable("PARTICIPATED",$event_part->hasParticipated($user_id) ? "X" : "");
1368  $tpl->parseCurrentBlock();
1369  }
1370 
1371  $tpl->setCurrentBlock('part_group');
1372  $tpl->setVariable('GROUP_NAME',$participants_data['txt']);
1373  $tpl->setVariable("TXT_NAME",$this->lng->txt('name'));
1374  $tpl->setVariable("TXT_MARK",$this->lng->txt('trac_mark'));
1375  $tpl->setVariable("TXT_COMMENT",$this->lng->txt('trac_comment'));
1376  $tpl->setVariable("TXT_PARTICIPATED",$this->lng->txt('event_tbl_participated'));
1377  if($this->object->enabledRegistration())
1378  {
1379  $tpl->setVariable("TXT_REGISTERED",$this->lng->txt('event_tbl_registered'));
1380  }
1381  $tpl->parseCurrentBlock();
1382 
1383  }
1384 
1385  $this->tpl->setVariable("CONTENT",$tpl->get());
1386  $this->tpl->setVariable("BODY_ATTRIBUTES",'onload="window.print()"');
1387  $this->tpl->show();
1388  exit;
1389 
1390  }
1391 
1399  public function eventsListObject()
1400  {
1401  global $ilErr,$ilAccess, $ilUser,$tree;
1402 
1403  if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
1404  {
1405  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
1406  }
1407 
1408  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.sess_list.html','Modules/Session');
1409  $this->__showButton($this->ctrl->getLinkTarget($this,'exportCSV'),$this->lng->txt('event_csv_export'));
1410 
1411  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
1412  include_once 'Modules/Session/classes/class.ilEventParticipants.php';
1413 
1414  $this->tpl->addBlockfile("EVENTS_TABLE","events_table", "tpl.table.html");
1415  $this->tpl->addBlockfile('TBL_CONTENT','tbl_content','tpl.sess_list_row.html','Modules/Session');
1416 
1417  $members_obj = ilCourseParticipants::_getInstanceByObjId($this->object->getId());
1418  $members = $members_obj->getParticipants();
1419  $members = ilUtil::_sortIds($members,'usr_data','lastname','usr_id');
1420 
1421  // Table
1422  $tbl = new ilTableGUI();
1423  $tbl->setTitle($this->lng->txt("event_overview"),
1424  'icon_usr.gif',
1425  $this->lng->txt('obj_usr'));
1426  $this->ctrl->setParameter($this,'offset',(int) $_GET['offset']);
1427 
1428  $course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs');
1429  $events = array();
1430  foreach($tree->getSubtree($tree->getNodeData($course_ref_id),false,'sess') as $event_id)
1431  {
1432  $tmp_event = ilObjectFactory::getInstanceByRefId($event_id,false);
1433  if(!is_object($tmp_event) or $tmp_event->getType() != 'sess')
1434  {
1435  continue;
1436  }
1437  $events[] = $tmp_event;
1438  }
1439 
1440  $headerNames = array();
1441  $headerVars = array();
1442  $colWidth = array();
1443 
1444  $headerNames[] = $this->lng->txt('name');
1445  $headerVars[] = "name";
1446  $colWidth[] = '20%';
1447 
1448  for ($i = 1; $i <= count($events); $i++)
1449  {
1450  $headerNames[] = $i;
1451  $headerVars[] = "event_".$i;
1452  $colWidth[] = 80/count($events)."%";
1453  }
1454 
1455  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
1456  $tbl->setHeaderNames($headerNames);
1457  $tbl->setHeaderVars($headerVars, $this->ctrl->getParameterArray($this,'eventsList'));
1458  $tbl->setColumnWidth($colWidth);
1459 
1460  $tbl->setOrderColumn($_GET["sort_by"]);
1461  $tbl->setOrderDirection($_GET["sort_order"]);
1462  $tbl->setOffset($_GET["offset"]);
1463  $tbl->setLimit($ilUser->getPref("hits_per_page"));
1464  $tbl->setMaxCount(count($members));
1465  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1466 
1467  $sliced_users = array_slice($members,$_GET['offset'],$_SESSION['tbl_limit']);
1468  $tbl->disable('sort');
1469  $tbl->render();
1470 
1471  $counter = 0;
1472  foreach($sliced_users as $user_id)
1473  {
1474  foreach($events as $event_obj)
1475  {
1476  $this->tpl->setCurrentBlock("eventcols");
1477 
1478  $event_part = new ilEventParticipants($this->object->getId());
1479 
1480  {
1481  $this->tpl->setVariable("IMAGE_PARTICIPATED", $event_part->hasParticipated($user_id) ?
1482  ilUtil::getImagePath('icon_ok.gif') :
1483  ilUtil::getImagePath('icon_not_ok.gif'));
1484 
1485  $this->tpl->setVariable("PARTICIPATED", $event_part->hasParticipated($user_id) ?
1486  $this->lng->txt('event_participated') :
1487  $this->lng->txt('event_not_participated'));
1488  }
1489 
1490  $this->tpl->parseCurrentBlock();
1491  }
1492 
1493  $this->tpl->setCurrentBlock("tbl_content");
1494  $name = ilObjUser::_lookupName($user_id);
1495  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor($counter++,'tblrow1','tblrow2'));
1496  $this->tpl->setVariable("LASTNAME",$name['lastname']);
1497  $this->tpl->setVariable("FIRSTNAME",$name['firstname']);
1498  $this->tpl->setVariable("LOGIN",ilObjUser::_lookupLogin($user_id));
1499  $this->tpl->parseCurrentBlock();
1500  }
1501 
1502  $this->tpl->setVariable("HEAD_TXT_LEGEND", $this->lng->txt("legend"));
1503  $this->tpl->setVariable("HEAD_TXT_DIGIT", $this->lng->txt("event_digit"));
1504  $this->tpl->setVariable("HEAD_TXT_EVENT", $this->lng->txt("event"));
1505  $this->tpl->setVariable("HEAD_TXT_LOCATION", $this->lng->txt("event_location"));
1506  $this->tpl->setVariable("HEAD_TXT_DATE_TIME",$this->lng->txt("event_date_time"));
1507  $i = 1;
1508  foreach($events as $event_obj)
1509  {
1510  $this->tpl->setCurrentBlock("legend_loop");
1511  $this->tpl->setVariable("LEGEND_CSS_ROW",ilUtil::switchColor($counter++,'tblrow1','tblrow2'));
1512  $this->tpl->setVariable("LEGEND_DIGIT", $i++);
1513  $this->tpl->setVariable("LEGEND_EVENT_TITLE", $event_obj->getTitle());
1514  $this->tpl->setVariable("LEGEND_EVENT_DESCRIPTION", $event_obj->getDescription());
1515  $this->tpl->setVariable("LEGEND_EVENT_LOCATION", $event_obj->getLocation());
1516  $this->tpl->setVariable("LEGEND_EVENT_APPOINTMENT", $event_obj->getFirstAppointment()->appointmentToString());
1517  $this->tpl->parseCurrentBlock();
1518  }
1519 
1520  }
1521 
1527  protected function initForm($a_mode)
1528  {
1529  global $ilUser;
1530 
1531  if(is_object($this->form))
1532  {
1533  return true;
1534  }
1535 
1536  $this->lng->loadLanguageModule('dateplaner');
1537 
1538  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1539 
1540  include_once('./Services/YUI/classes/class.ilYuiUtil.php');
1542 
1543  $this->form = new ilPropertyFormGUI();
1544  $this->form->setMultipart(true);
1545  $this->form->setTableWidth('600px');
1546  $this->form->setFormAction($this->ctrl->getFormAction($this));
1547  $this->form->setMultipart(true);
1548 
1549  /*
1550  $full = new ilCheckboxInputGUI('','fulltime');
1551  $full->setChecked($this->object->getFirstAppointment()->enabledFulltime() ? true : false);
1552  $full->setOptionTitle($this->lng->txt('event_fulltime_info'));
1553  $full->setAdditionalAttributes('onchange="ilToggleSessionTime(this);"');
1554  #$this->form->addItem($full);
1555  */
1556 
1557  $this->lng->loadLanguageModule('dateplaner');
1558  include_once './Services/Form/classes/class.ilDateDurationInputGUI.php';
1559  #$this->tpl->addJavaScript('./Modules/Session/js/toggle_session_time.js');
1560  $this->tpl->addJavaScript('./Services/Form/js/date_duration.js');
1561  $dur = new ilDateDurationInputGUI($this->lng->txt('cal_fullday'),'event');
1562  $dur->setStartText($this->lng->txt('event_start_date'));
1563  $dur->setEndText($this->lng->txt('event_end_date'));
1564  $dur->enableToggleFullTime(
1565  $this->lng->txt('event_fulltime_info'),
1566  $this->object->getFirstAppointment()->enabledFulltime() ? true : false
1567  );
1568  $dur->setMinuteStepSize(5);
1569  $dur->setShowTime(true);
1570  $dur->setShowDate(true);
1571  $dur->setStart($this->object->getFirstAppointment()->getStart());
1572  $dur->setEnd($this->object->getFirstAppointment()->getEnd());
1573 
1574  $this->form->addItem($dur);
1575 
1576  /*
1577  // start
1578  $start = new ilDateTimeInputGUI($this->lng->txt('event_start_date'),'start');
1579  $start->setMinuteStepSize(5);
1580  $start->setDate($this->object->getFirstAppointment()->getStart());
1581  $start->setShowTime(true);
1582  #$this->form->addItem($start);
1583 
1584  // end
1585  $end = new ilDateTimeInputGUI($this->lng->txt('event_end_date'),'end');
1586  $end->setMinuteStepSize(5);
1587  $end->setDate($this->object->getFirstAppointment()->getEnd());
1588  $end->setShowTime(true);
1589  #$this->form->addItem($end);
1590  */
1591 
1592  // Recurrence
1593  if($a_mode == 'create')
1594  {
1595  if(!is_object($this->rec))
1596  {
1597  include_once('./Modules/Session/classes/class.ilEventRecurrence.php');
1598  $this->rec = new ilEventRecurrence();
1599  }
1600  include_once('./Services/Calendar/classes/Form/class.ilRecurrenceInputGUI.php');
1601  $rec = new ilRecurrenceInputGUI($this->lng->txt('cal_recurrences'),'frequence');
1602  $rec->allowUnlimitedRecurrences(false);
1603  $rec->setRecurrence($this->rec);
1604  $this->form->addItem($rec);
1605  }
1606 
1608  $section->setTitle($this->lng->txt('event_section_information'));
1609  $this->form->addItem($section);
1610 
1611  // title
1612  $title = new ilTextInputGUI($this->lng->txt('event_title'),'title');
1613  $title->setValue($this->object->getTitle());
1614  $title->setSize(50);
1615  $title->setMaxLength(70);
1616  $this->form->addItem($title);
1617 
1618  // desc
1619  $desc = new ilTextAreaInputGUI($this->lng->txt('event_desc'),'desc');
1620  $desc->setValue($this->object->getLongDescription());
1621  $desc->setRows(4);
1622  $desc->setCols(50);
1623  $this->form->addItem($desc);
1624 
1625  // location
1626  $desc = new ilTextAreaInputGUI($this->lng->txt('event_location'),'location');
1627  $desc->setValue($this->object->getLocation());
1628  $desc->setRows(4);
1629  $desc->setCols(50);
1630  $this->form->addItem($desc);
1631 
1632  // workflow
1633  $details = new ilTextAreaInputGUI($this->lng->txt('event_details_workflow'),'details');
1634  $details->setValue($this->object->getDetails());
1635  $details->setCols(50);
1636  $details->setRows(4);
1637  $this->form->addItem($details);
1638 
1639  // section
1641  $section->setTitle($this->lng->txt('event_tutor_data'));
1642  $this->form->addItem($section);
1643 
1644  // name
1645  $tutor_name = new ilTextInputGUI($this->lng->txt('tutor_name'),'tutor_name');
1646  $tutor_name->setValue($this->object->getName());
1647  $tutor_name->setSize(20);
1648  $tutor_name->setMaxLength(70);
1649  $this->form->addItem($tutor_name);
1650 
1651  // email
1652  $tutor_email = new ilTextInputGUI($this->lng->txt('tutor_email'),'tutor_email');
1653  $tutor_email->setValue($this->object->getEmail());
1654  $tutor_email->setSize(20);
1655  $tutor_email->setMaxLength(70);
1656  $this->form->addItem($tutor_email);
1657 
1658  // phone
1659  $tutor_phone = new ilTextInputGUI($this->lng->txt('tutor_phone'),'tutor_phone');
1660  $tutor_phone->setValue($this->object->getPhone());
1661  $tutor_phone->setSize(20);
1662  $tutor_phone->setMaxLength(70);
1663  $this->form->addItem($tutor_phone);
1664 
1666  $section->setTitle($this->lng->txt('crs_further_settings'));
1667  $this->form->addItem($section);
1668 
1669  // registration
1670  $reg = new ilCheckboxInputGUI($this->lng->txt('event_registration'),'registration');
1671  $reg->setChecked($this->object->enabledRegistration() ? true : false);
1672  $reg->setOptionTitle($this->lng->txt('event_registration_info'));
1673  $this->form->addItem($reg);
1674 
1675 
1677  $section->setTitle($this->lng->txt('event_assign_files'));
1678  $this->form->addItem($section);
1679 
1680  $files = new ilFileWizardInputGUI($this->lng->txt('objs_file'),'files');
1681  $files->setFilenames(array(0 => ''));
1682  $this->form->addItem($files);
1683 
1684  switch($a_mode)
1685  {
1686  case 'create':
1687  $this->form->setTitle($this->lng->txt('event_table_create'));
1688  $this->form->setTitleIcon(ilUtil::getImagePath('icon_event.gif'));
1689 
1690  $this->form->addCommandButton('save',$this->lng->txt('event_btn_add'));
1691  $this->form->addCommandButton('saveAndAssignMaterials',$this->lng->txt('event_btn_add_edit'));
1692  $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
1693 
1694  return true;
1695 
1696  case 'edit':
1697  $this->form->setTitle($this->lng->txt('event_table_update'));
1698  $this->form->setTitleIcon(ilUtil::getImagePath('icon_event.gif'));
1699 
1700  $this->form->addCommandButton('update',$this->lng->txt('save'));
1701  $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
1702 
1703  return true;
1704  }
1705  return true;
1706  }
1707 
1715  protected function load()
1716  {
1717  global $ilUser;
1718 
1719  $this->object->getFirstAppointment()->setStartingTime($this->__toUnix($_POST['event']['start']['date'],$_POST['event']['start']['time']));
1720  $this->object->getFirstAppointment()->setEndingTime($this->__toUnix($_POST['event']['end']['date'],$_POST['event']['end']['time']));
1721  $this->object->getFirstAppointment()->toggleFullTime((bool) $_POST['event']['fulltime']);
1722 
1723  include_once('./Services/Calendar/classes/class.ilDate.php');
1724  if($this->object->getFirstAppointment()->isFullday())
1725  {
1726  $start = new ilDate($_POST['event']['start']['date']['y'].'-'.$_POST['event']['start']['date']['m'].'-'.$_POST['event']['start']['date']['d'],
1727  IL_CAL_DATE);
1728  $this->object->getFirstAppointment()->setStart($start);
1729 
1730  $end = new ilDate($_POST['event']['end']['date']['y'].'-'.$_POST['event']['end']['date']['m'].'-'.$_POST['event']['end']['date']['d'],
1731  IL_CAL_DATE);
1732  $this->object->getFirstAppointment()->setEnd($end);
1733  }
1734  else
1735  {
1736  $start_dt['year'] = (int) $_POST['event']['start']['date']['y'];
1737  $start_dt['mon'] = (int) $_POST['event']['start']['date']['m'];
1738  $start_dt['mday'] = (int) $_POST['event']['start']['date']['d'];
1739  $start_dt['hours'] = (int) $_POST['event']['start']['time']['h'];
1740  $start_dt['minutes'] = (int) $_POST['event']['start']['time']['m'];
1741 
1742  $start = new ilDateTime($start_dt,IL_CAL_FKT_GETDATE,$ilUser->getTimeZone());
1743  $this->object->getFirstAppointment()->setStart($start);
1744 
1745  $end_dt['year'] = (int) $_POST['event']['end']['date']['y'];
1746  $end_dt['mon'] = (int) $_POST['event']['end']['date']['m'];
1747  $end_dt['mday'] = (int) $_POST['event']['end']['date']['d'];
1748  $end_dt['hours'] = (int) $_POST['event']['end']['time']['h'];
1749  $end_dt['minutes'] = (int) $_POST['event']['end']['time']['m'];
1750  $end = new ilDateTime($end_dt,IL_CAL_FKT_GETDATE,$ilUser->getTimeZone());
1751  $this->object->getFirstAppointment()->setEnd($end);
1752  }
1753 
1754  $this->object->setTitle(ilUtil::stripSlashes($_POST['title']));
1755  $this->object->setDescription(ilUtil::stripSlashes($_POST['desc']));
1756  $this->object->setLocation(ilUtil::stripSlashes($_POST['location']));
1757  $this->object->setName(ilUtil::stripSlashes($_POST['tutor_name']));
1758  $this->object->setPhone(ilUtil::stripSlashes($_POST['tutor_phone']));
1759  $this->object->setEmail(ilUtil::stripSlashes($_POST['tutor_email']));
1760  $this->object->setDetails(ilUtil::stripSlashes($_POST['details']));
1761  $this->object->enableRegistration((int) $_POST['registration']);
1762  }
1763 
1770  protected function loadRecurrenceSettings()
1771  {
1772  include_once('./Modules/Session/classes/class.ilSessionRecurrence.php');
1773  $this->rec = new ilSessionRecurrence();
1774 
1775  switch($_POST['frequence'])
1776  {
1777  case IL_CAL_FREQ_DAILY:
1778  $this->rec->setFrequenceType($_POST['frequence']);
1779  $this->rec->setInterval((int) $_POST['count_DAILY']);
1780  break;
1781 
1782  case IL_CAL_FREQ_WEEKLY:
1783  $this->rec->setFrequenceType($_POST['frequence']);
1784  $this->rec->setInterval((int) $_POST['count_WEEKLY']);
1785  if(is_array($_POST['byday_WEEKLY']))
1786  {
1787  $this->rec->setBYDAY(ilUtil::stripSlashes(implode(',',$_POST['byday_WEEKLY'])));
1788  }
1789  break;
1790 
1791  case IL_CAL_FREQ_MONTHLY:
1792  $this->rec->setFrequenceType($_POST['frequence']);
1793  $this->rec->setInterval((int) $_POST['count_MONTHLY']);
1794  switch((int) $_POST['subtype_MONTHLY'])
1795  {
1796  case 0:
1797  // nothing to do;
1798  break;
1799 
1800  case 1:
1801  switch((int) $_POST['monthly_byday_day'])
1802  {
1803  case 8:
1804  // Weekday
1805  $this->rec->setBYSETPOS((int) $_POST['monthly_byday_num']);
1806  $this->rec->setBYDAY('MO,TU,WE,TH,FR');
1807  break;
1808 
1809  case 9:
1810  // Day of month
1811  $this->rec->setBYMONTHDAY((int) $_POST['monthly_byday_num']);
1812  break;
1813 
1814  default:
1815  $this->rec->setBYDAY((int) $_POST['monthly_byday_num'].$_POST['monthly_byday_day']);
1816  break;
1817  }
1818  break;
1819 
1820  case 2:
1821  $this->rec->setBYMONTHDAY((int) $_POST['monthly_bymonthday']);
1822  break;
1823  }
1824  break;
1825 
1826  case IL_CAL_FREQ_YEARLY:
1827  $this->rec->setFrequenceType($_POST['frequence']);
1828  $this->rec->setInterval((int) $_POST['count_YEARLY']);
1829  switch((int) $_POST['subtype_YEARLY'])
1830  {
1831  case 0:
1832  // nothing to do;
1833  break;
1834 
1835  case 1:
1836  $this->rec->setBYMONTH((int) $_POST['yearly_bymonth_byday']);
1837  $this->rec->setBYDAY((int) $_POST['yearly_byday_num'].$_POST['yearly_byday']);
1838  break;
1839 
1840  case 2:
1841  $this->rec->setBYMONTH((int) $_POST['yearly_bymonth_by_monthday']);
1842  $this->rec->setBYMONTHDAY((int) $_POST['yearly_bymonthday']);
1843  break;
1844  }
1845  break;
1846  }
1847 
1848  // UNTIL
1849  switch((int) $_POST['until_type'])
1850  {
1851  case 1:
1852  $this->rec->setFrequenceUntilDate(null);
1853  // nothing to do
1854  break;
1855 
1856  case 2:
1857  $this->rec->setFrequenceUntilDate(null);
1858  $this->rec->setFrequenceUntilCount((int) $_POST['count']);
1859  break;
1860 
1861  case 3:
1862  $end_dt['year'] = (int) $_POST['until_end']['date']['y'];
1863  $end_dt['mon'] = (int) $_POST['until_end']['date']['m'];
1864  $end_dt['mday'] = (int) $_POST['until_end']['date']['d'];
1865 
1866  $this->rec->setFrequenceUntilCount(0);
1867  $this->rec->setFrequenceUntilDate(new ilDate($end_dt,IL_CAL_FKT_GETDATE,$this->timezone));
1868  break;
1869  }
1870  }
1871 
1872 
1880  protected function __toUnix($date,$time)
1881  {
1882  return mktime($time['h'],$time['m'],0,$date['m'],$date['d'],$date['y']);
1883  }
1884 
1891  protected function formatPath($a_ref_id)
1892  {
1893  global $tree;
1894 
1895  $path = $this->lng->txt('path') . ': ';
1896  $first = true;
1897  foreach($tree->getPathFull($a_ref_id,$this->course_ref_id) as $node)
1898  {
1899  if($node['ref_id'] != $a_ref_id)
1900  {
1901  if(!$first)
1902  {
1903  $path .= ' -> ';
1904  }
1905  $first = false;
1906  $path .= $node['title'];
1907  }
1908  }
1909  return $path;
1910  }
1911 
1918  public function addLocatorItems()
1919  {
1920  global $ilLocator;
1921 
1922  if (is_object($this->object))
1923  {
1924  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
1925  }
1926  }
1927 
1934  public function getTabs($tabs_gui)
1935  {
1936  global $ilAccess,$ilTabs,$tree;
1937 
1938  $parent_id = $tree->getParentId($this->object->getRefId());
1939 
1940  $tabs_gui->setBackTarget($this->lng->txt('back_to_crs_content'),'repository.php?ref_id='.$parent_id);
1941  $tabs_gui->addTarget('info_short',
1942  $this->ctrl->getLinkTarget($this,'infoScreen'));
1943 
1944  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
1945  {
1946  $tabs_gui->addTarget('edit_properties',
1947  $this->ctrl->getLinkTarget($this,'edit'));
1948  $tabs_gui->addTarget('crs_materials',
1949  $this->ctrl->getLinkTarget($this,'materials'));
1950  $tabs_gui->addTarget('event_edit_members',
1951  $this->ctrl->getLinkTarget($this,'members'));
1952  }
1953 
1954  // export
1955  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
1956  {
1957  $ilTabs->addTarget("export",
1958  $this->ctrl->getLinkTargetByClass("ilexportgui", ""), "", "ilexportgui");
1959  }
1960 
1961 
1962  // edit permissions
1963  if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId()))
1964  {
1965  $tabs_gui->addTarget("perm_settings",
1966  $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"), array("perm","info","owner"), 'ilpermissiongui');
1967  }
1968 
1969  }
1970 
1971 }
1972 ?>