ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjCourseGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 
5 require_once "./Services/Container/classes/class.ilContainerGUI.php";
6 
27 {
32  function ilObjCourseGUI()
33  {
34  global $ilCtrl;
35 
36  // CONTROL OPTIONS
37  $this->ctrl =& $ilCtrl;
38  $this->ctrl->saveParameter($this,array("ref_id","cmdClass"));
39 
40  $this->type = "crs";
41  $this->ilContainerGUI('',(int) $_GET['ref_id'],true,false);
42 
43  $this->lng->loadLanguageModule('crs');
44 
45  $this->SEARCH_USER = 1;
46  $this->SEARCH_GROUP = 2;
47  $this->SEARCH_COURSE = 3;
48  }
49 
50  function gatewayObject()
51  {
52  switch($_POST["action"])
53  {
54 
55  case "deleteSubscribers":
56  $this->deleteSubscribers();
57  break;
58 
59  case "addSubscribers":
60  $this->addSubscribers();
61  break;
62 
63  case "addFromWaitingList":
64  $this->addFromWaitingList();
65  break;
66 
67  case "removeFromWaitingList":
68  $this->removeFromWaitingList();
69  break;
70 
71  default:
72  $this->viewObject();
73  break;
74  }
75  return true;
76  }
77 
84  public function memberGatewayObject()
85  {
86  if(isset($_POST['btn_pressed']['deleteMembers']))
87  {
88  return $this->deleteMembersObject();
89  }
90  elseif($_POST['btn_pressed']['sendMailToSelectedUsers'])
91  {
92  return $this->sendMailToSelectedUsersObject();
93  }
94  else
95  {
96  return $this->updateMembersObject();
97  }
98  }
99 
101  {
102  if(isset($_GET['member_id']))
103  {
104  $_POST['member'] = array($_GET['member_id']);
105  }
106  else
107  {
108  $_POST['member'] = array_unique(array_merge((array) $_POST['members'],
109  (array) $_POST['tutors'],
110  (array) $_POST['admins'],
111  (array) $_POST['waiting'],
112  (array) $_POST['subscribers'],
113  (array) $_POST['roles']
114  ));
115  }
116 
117 
118  if (!count($_POST["member"]))
119  {
120  ilUtil::sendFailure($this->lng->txt("no_checkbox"));
121  $this->membersObject();
122  return false;
123  }
124  foreach($_POST["member"] as $usr_id)
125  {
126  $rcps[] = ilObjUser::_lookupLogin($usr_id);
127  }
128  require_once 'Services/Mail/classes/class.ilMailFormCall.php';
130  array(),
131  array(
132  'type' => 'new',
133  'rcp_to' => implode(',',$rcps),
134  'sig' => $this->createMailSignature()
135  )));
136  }
137 
143  {
144  $this->__unsetSessionVariables();
145 
146  $return_location = "members";
147 
148  #ilUtil::sendSuccess($this->lng->txt("action_aborted"),true);
149  ilUtil::redirect($this->ctrl->getLinkTarget($this,$return_location,"",false,false));
150  }
151 
156  protected function afterImport(ilObject $a_new_object)
157  {
158  global $ilUser;
159 
160  $part = new ilCourseParticipants($a_new_object->getId());
161  $part->add($ilUser->getId(), ilCourseConstants::CRS_ADMIN);
162  $part->updateNotification($ilUser->getId(), 1);
163 
164  parent::afterImport($a_new_object);
165  }
166 
167  function renderObject()
168  {
169  $this->ctrl->setCmd("view");
170  $this->viewObject();
171  }
172 
178  protected function forwardToTimingsView()
179  {
180  if(!$this->ctrl->getCmd() and $this->object->getViewMode() == ilContainer::VIEW_TIMING)
181  {
182  if(!isset($_SESSION['crs_timings'])) {
183  $_SESSION['crs_timings'] = true;
184  }
185 
186  if($_SESSION['crs_timings'] == true) {
187  include_once './Modules/Course/classes/class.ilCourseContentGUI.php';
188  $course_content_obj = new ilCourseContentGUI($this);
189  $this->ctrl->setCmdClass(get_class($course_content_obj));
190  $this->ctrl->setCmd('editUserTimings');
191  $this->ctrl->forwardCommand($course_content_obj);
192  return true;
193  }
194  }
195  $_SESSION['crs_timings'] = false;
196  return false;
197  }
198 
199 
200  function viewObject()
201  {
202  global $rbacsystem, $ilUser, $ilCtrl;
203 
204  // CHECK ACCESS
205  $this->checkPermission('read','view');
206  /*
207  if(!$rbacsystem->checkAccess("read",$this->object->getRefId()))
208  {
209  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
210  }
211  */
212  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
213  {
215  return true;
216  }
217 
218  // Fill meta header tags
219  include_once('Services/MetaData/classes/class.ilMDUtils.php');
220  ilMDUtils::_fillHTMLMetaTags($this->object->getId(),$this->object->getId(),'crs');
221 
222  // Trac access
223  include_once 'Services/Tracking/classes/class.ilLearningProgress.php';
224  ilLearningProgress::_tracProgress($ilUser->getId(),$this->object->getId(),
225  $this->object->getRefId(),'crs');
226 
227  if(!$this->checkAgreement())
228  {
229  include_once('Services/Membership/classes/class.ilMemberAgreementGUI.php');
230  $this->ctrl->setReturn($this,'view_content');
231  $agreement = new ilMemberAgreementGUI($this->object->getRefId());
232  $this->ctrl->setCmdClass(get_class($agreement));
233  $this->ctrl->forwardCommand($agreement);
234  return true;
235  }
236 
237  if(!$this->__checkStartObjects())
238  {
239  $this->showStartObjects();
240  }
241 
242  // views handled by general container logic
243  if ($this->object->getViewMode() == ilContainer::VIEW_SIMPLE ||
244  $this->object->getViewMode() == ilContainer::VIEW_BY_TYPE ||
245  $this->object->getViewMode() == ilContainer::VIEW_SESSIONS ||
246  $this->object->getViewMode() == ilContainer::VIEW_TIMING ||
247  $this->object->getViewMode() == ilContainer::VIEW_OBJECTIVE
248  )
249  {
251  return $ret;
252  }
253  else
254  {
255  include_once './Modules/Course/classes/class.ilCourseContentGUI.php';
256  $course_content_obj = new ilCourseContentGUI($this);
257 
258  $this->ctrl->setCmdClass(get_class($course_content_obj));
259  $this->ctrl->forwardCommand($course_content_obj);
260  }
261 
262  return true;
263  }
264 
265  function renderContainer()
266  {
267  return parent::renderObject();
268  }
269 
275  function infoScreenObject()
276  {
277  $this->ctrl->setCmd("showSummary");
278  $this->ctrl->setCmdClass("ilinfoscreengui");
279  $this->infoScreen();
280  }
281 
285  function infoScreen()
286  {
287  global $ilErr,$ilAccess, $ilUser, $ilSetting;
288 
289  $this->checkPermission('visible');
290 
291  // Fill meta header tags
292  include_once('Services/MetaData/classes/class.ilMDUtils.php');
293  ilMDUtils::_fillHTMLMetaTags($this->object->getId(),$this->object->getId(),'crs');
294 
295  $this->tabs_gui->setTabActive('info_short');
296 
297  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
298  include_once 'Modules/Course/classes/class.ilCourseFile.php';
299 
300  $files =& ilCourseFile::_readFilesByCourse($this->object->getId());
301 
302  $info = new ilInfoScreenGUI($this);
303  $info->enablePrivateNotes();
304  $info->enableFeedback();
305  $info->enableNews();
306  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
307  {
308  $info->enableNewsEditing();
309  }
310 
311  if(strlen($this->object->getImportantInformation()) or
312  strlen($this->object->getSyllabus()) or
313  count($files))
314  {
315  $info->addSection($this->lng->txt('crs_general_informations'));
316  }
317 
318  if(strlen($this->object->getImportantInformation()))
319  {
320  $info->addProperty($this->lng->txt('crs_important_info'),
321  "<strong>".nl2br(
322  ilUtil::makeClickable($this->object->getImportantInformation(), true)."</strong>"));
323  }
324  if(strlen($this->object->getSyllabus()))
325  {
326  $info->addProperty($this->lng->txt('crs_syllabus'), nl2br(
327  ilUtil::makeClickable ($this->object->getSyllabus(), true)));
328  }
329  // files
330  if(count($files))
331  {
332  $tpl = new ilTemplate('tpl.event_info_file.html',true,true,'Modules/Course');
333 
334  foreach($files as $file)
335  {
336  $tpl->setCurrentBlock("files");
337  $this->ctrl->setParameter($this,'file_id',$file->getFileId());
338  $tpl->setVariable("DOWN_LINK",$this->ctrl->getLinkTarget($this,'sendfile'));
339  $tpl->setVariable("DOWN_NAME",$file->getFileName());
340  $tpl->setVariable("DOWN_INFO_TXT",$this->lng->txt('crs_file_size_info'));
341  $tpl->setVariable("DOWN_SIZE",$file->getFileSize());
342  $tpl->setVariable("TXT_BYTES",$this->lng->txt('bytes'));
343  $tpl->parseCurrentBlock();
344  }
345  $info->addProperty($this->lng->txt('crs_file_download'),
346  $tpl->get());
347  }
348 
349  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
350  $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_INFO,'crs',$this->object->getId());
351  $record_gui->setInfoObject($info);
352  $record_gui->parse();
353 
354  // meta data
355  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
356 
357  // contact
358  if($this->object->hasContactData())
359  {
360  $info->addSection($this->lng->txt("crs_contact"));
361  }
362  if(strlen($this->object->getContactName()))
363  {
364  $info->addProperty($this->lng->txt("crs_contact_name"),
365  $this->object->getContactName());
366  }
367  if(strlen($this->object->getContactResponsibility()))
368  {
369  $info->addProperty($this->lng->txt("crs_contact_responsibility"),
370  $this->object->getContactResponsibility());
371  }
372  if(strlen($this->object->getContactPhone()))
373  {
374  $info->addProperty($this->lng->txt("crs_contact_phone"),
375  $this->object->getContactPhone());
376  }
377  if($this->object->getContactEmail())
378  {
379  require_once 'Services/Mail/classes/class.ilMailFormCall.php';
380  $emails = split(",",$this->object->getContactEmail());
381  foreach ($emails as $email) {
382  $email = trim($email);
383  $etpl = new ilTemplate("tpl.crs_contact_email.html", true, true , 'Modules/Course');
384  $etpl->setVariable("EMAIL_LINK", ilMailFormCall::_getLinkTarget($info, 'showSummary', array(),
385  array('type' => 'new', 'rcp_to' => $email,'sig' => $this->createMailSignature())));
386  $etpl->setVariable("CONTACT_EMAIL", $email);
387  $mailString .= $etpl->get()."<br />";
388  }
389  $info->addProperty($this->lng->txt("crs_contact_email"), $mailString);
390  }
391  if(strlen($this->object->getContactConsultation()))
392  {
393  $info->addProperty($this->lng->txt("crs_contact_consultation"),
394  nl2br($this->object->getContactConsultation()));
395  }
396  //
397  // access
398  //
399  $info->addSection($this->lng->txt("access"));
400  $info->showLDAPRoleGroupMappingInfo();
401 
402  // activation
403  if($this->object->getOfflineStatus())
404  {
405  $info->addProperty($this->lng->txt('crs_visibility'),
406  $this->lng->txt('crs_visibility_unvisible'));
407  }
408  elseif($this->object->getActivationUnlimitedStatus())
409  {
410  $info->addProperty($this->lng->txt("crs_visibility"),
411  $this->lng->txt('crs_unlimited'));
412  }
413  else
414  {
415  $info->addProperty($this->lng->txt('crs_visibility'),
417  new ilDateTime($this->object->getActivationStart(),IL_CAL_UNIX),
418  new ilDateTime($this->object->getActivationEnd(),IL_CAL_UNIX)));
419 
420  }
421  switch($this->object->getSubscriptionLimitationType())
422  {
424  $txt = $this->lng->txt("crs_info_reg_deactivated");
425  break;
426 
427  default:
428  switch($this->object->getSubscriptionType())
429  {
431  $txt = $this->lng->txt("crs_info_reg_confirmation");
432  break;
434  $txt = $this->lng->txt("crs_info_reg_direct");
435  break;
437  $txt = $this->lng->txt("crs_info_reg_password");
438  break;
439  }
440  }
441 
442  // subscription
443  $info->addProperty($this->lng->txt("crs_info_reg"),$txt);
444 
445 
446  if($this->object->getSubscriptionLimitationType() != IL_CRS_SUBSCRIPTION_DEACTIVATED)
447  {
448  if($this->object->getSubscriptionUnlimitedStatus())
449  {
450  $info->addProperty($this->lng->txt("crs_reg_until"),
451  $this->lng->txt('crs_unlimited'));
452  }
453  elseif($this->object->getSubscriptionStart() < time())
454  {
455  $info->addProperty($this->lng->txt("crs_reg_until"),
456  $this->lng->txt('crs_to').' '.
457  ilDatePresentation::formatDate(new ilDateTime($this->object->getSubscriptionEnd(),IL_CAL_UNIX)));
458  }
459  elseif($this->object->getSubscriptionStart() > time())
460  {
461  $info->addProperty($this->lng->txt("crs_reg_until"),
462  $this->lng->txt('crs_from').' '.
463  ilDatePresentation::formatDate(new ilDateTime($this->object->getSubscriptionStart(),IL_CAL_UNIX)));
464  }
465  if ($this->object->isSubscriptionMembershipLimited())
466  {
467  include_once './Services/Membership/classes/class.ilParticipants.php';
468  $info->addProperty(
469  $this->lng->txt("mem_free_places"),
470  max(
471  0,
472  $this->object->getSubscriptionMaxMembers() - ilParticipants::lookupNumberOfMembers($this->object->getRefId()))
473  );
474  }
475  }
476 
477  // archive
478  if($this->object->getViewMode() == IL_CRS_VIEW_ARCHIVE)
479  {
480  if($this->object->getArchiveType() != IL_CRS_ARCHIVE_NONE)
481  {
482  $info->addProperty($this->lng->txt("crs_archive"),
484  new ilDateTime($this->object->getArchiveStart(),IL_CAL_UNIX),
485  new ilDateTime($this->object->getArchiveStart(),IL_CAL_UNIX)));
486  }
487  }
488  // Confirmation
489  include_once('Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
490  $privacy = ilPrivacySettings::_getInstance();
491 
492  include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
493  if($privacy->courseConfirmationRequired() or ilCourseDefinedFieldDefinition::_getFields($this->object->getId()) or $privacy->enabledCourseExport())
494  {
495  include_once('Services/PrivacySecurity/classes/class.ilExportFieldsInfo.php');
496 
497  $field_info = ilExportFieldsInfo::_getInstanceByType($this->object->getType());
498 
499  $this->lng->loadLanguageModule('ps');
500  $info->addSection($this->lng->txt('crs_user_agreement_info'));
501  $info->addProperty($this->lng->txt('ps_export_data'),$field_info->exportableFieldsToInfoString());
502 
503  if($fields = ilCourseDefinedFieldDefinition::_fieldsToInfoString($this->object->getId()))
504  {
505  $info->addProperty($this->lng->txt('ps_crs_user_fields'),$fields);
506  }
507  }
508 
509  $info->enableLearningProgress(true);
510 
511  // forward the command
512  $this->ctrl->forwardCommand($info);
513  }
514 
519  {
520  global $ilUser;
521 
522  $ilUser->setPref("grpcrs_ntf_".$this->ref_id, (bool)$_REQUEST["crs_ntf"]);
523  $ilUser->writePrefs();
524 
525  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
526  $this->ctrl->redirect($this, "");
527  }
528 
534  protected function listStructureObject()
535  {
536  global $tpl, $ilToolbar;
537 
538  $this->checkPermission('write');
539 
540  $this->setSubTabs("properties");
541  $this->tabs_gui->setTabActive('settings');
542  $this->tabs_gui->setSubTabActive('crs_start_objects');
543 
544  $ilToolbar->addButton($this->lng->txt('crs_add_starter'),
545  $this->ctrl->getLinkTarget($this, 'selectStarter'));
546 
547  include_once './Modules/Course/classes/class.ilCourseStartObjectsTableGUI.php';
548  $table = new ilCourseStartObjectsTableGUI($this, 'listStructure', $this->object);
549  $tpl->setContent($table->getHTML());
550  }
551 
553  {
554  $this->checkPermission('write');
555 
556  if(!count($_POST['starter']))
557  {
558  ilUtil::sendFailure($this->lng->txt('select_one'));
559  }
560  else
561  {
562  // display confirmation message
563  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
564  $cgui = new ilConfirmationGUI();
565  $cgui->setFormAction($this->ctrl->getFormAction($this));
566  $cgui->setHeaderText($this->lng->txt("crs_starter_delete_sure"));
567  $cgui->setCancel($this->lng->txt("cancel"), "listStructure");
568  $cgui->setConfirm($this->lng->txt("delete"), "deleteStarter");
569 
570  // list objects that should be deleted
571  include_once './Modules/Course/classes/class.ilCourseStart.php';
572  $crs_start =& new ilCourseStart($this->object->getRefId(),$this->object->getId());
573  $crs_start = $crs_start->getStartObjects();
574  foreach($_POST['starter'] as $starter_id)
575  {
576  $ref_id = $crs_start[$starter_id]["item_ref_id"];
579  $cgui->addItem("starter[]", $starter_id, $title);
580  }
581 
582  $this->tpl->setContent($cgui->getHTML());
583  return true;
584  }
585 
586  $this->listStructureObject();
587  return false;
588  }
589 
591  {
592  $this->checkPermission('write');
593 
594  if(!count($_POST['starter']))
595  {
596  ilUtil::sendFailure($this->lng->txt('select_one'));
597  }
598  else
599  {
600  include_once './Modules/Course/classes/class.ilCourseStart.php';
601  $crs_start =& new ilCourseStart($this->object->getRefId(),$this->object->getId());
602  foreach($_POST['starter'] as $starter_id)
603  {
604  $crs_start->delete((int)$starter_id);
605  }
606 
607  ilUtil::sendSuccess($this->lng->txt('crs_starter_deleted'));
608  }
609 
610  $this->listStructureObject();
611  return true;
612  }
613 
614 
616  {
617  global $tpl;
618 
619  $this->checkPermission('write');
620 
621  $this->tabs_gui->clearTargets();
622  $this->tabs_gui->setBackTarget($this->lng->txt('back'),
623  $this->ctrl->getLinkTarget($this, 'listStructure'));
624 
625  include_once './Modules/Course/classes/class.ilCourseStartObjectsTableGUI.php';
626  $table = new ilCourseStartObjectsTableGUI($this, 'selectStarter', $this->object);
627 
628  $tpl->setContent($table->getHTML());
629  }
630 
631  function addStarterObject()
632  {
633  global $rbacsystem;
634 
635  $this->checkPermission('write');
636 
637  if(!count($_POST['starter']))
638  {
639  ilUtil::sendFailure($this->lng->txt('crs_select_one_object'));
640  $this->selectStarterObject();
641 
642  return false;
643  }
644 
645  include_once './Modules/Course/classes/class.ilCourseStart.php';
646  $crs_start =& new ilCourseStart($this->object->getRefId(),$this->object->getId());
647  $added = 0;
648  foreach($_POST['starter'] as $item_ref_id)
649  {
650  if(!$crs_start->exists($item_ref_id))
651  {
652  ++$added;
653  $crs_start->add($item_ref_id);
654  }
655  }
656  if($added)
657  {
658  ilUtil::sendSuccess($this->lng->txt('crs_added_starters'));
659  $this->listStructureObject();
660 
661  return true;
662  }
663  else
664  {
665  ilUtil::sendFailure($this->lng->txt('crs_starters_already_assigned'));
666  $this->selectStarterObject();
667 
668  return false;
669  }
670  }
671 
678  public function editInfoObject()
679  {
680  include_once 'Modules/Course/classes/class.ilCourseFile.php';
681 
682  global $ilErr,$ilAccess;
683 
684  $this->checkPermission('write');
685  /*
686  if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
687  {
688  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
689  }
690  */
691  $this->setSubTabs('properties');
692  $this->tabs_gui->setTabActive('settings');
693  $this->tabs_gui->setSubTabActive('crs_info_settings');
694 
695  $form = $this->initInfoEditor();
696  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.edit_info.html','Modules/Course');
697  $this->tpl->setVariable('INFO_TABLE',$form->getHTML());
698 
699  if(!count($files = ilCourseFile::_readFilesByCourse($this->object->getId())))
700  {
701  return true;
702  }
703  $rows = array();
704  foreach($files as $file)
705  {
706  $table_data['id'] = $file->getFileId();
707  $table_data['filename'] = $file->getFileName();
708  $table_data['filetype'] = $file->getFileType();
709  $table_data['filesize'] = $file->getFileSize();
710 
711  $rows[] = $table_data;
712  }
713 
714  include_once("./Modules/Course/classes/class.ilCourseInfoFileTableGUI.php");
715  $table_gui = new ilCourseInfoFileTableGUI($this, "edit");
716  $table_gui->setTitle($this->lng->txt("crs_info_download"));
717  $table_gui->setData($rows);
718  $table_gui->addCommandButton("cancel", $this->lng->txt("cancel"));
719  $table_gui->addMultiCommand("confirmDeleteInfoFiles", $this->lng->txt("delete"));
720  $table_gui->setSelectAllCheckbox("file_id");
721  $this->tpl->setVariable('INFO_FILE_TABLE',$table_gui->getHTML());
722 
723  return true;
724 
725  }
726 
735  {
736  if(!count($_POST['file_id']))
737  {
738  ilUtil::sendFailure($this->lng->txt('select_one'));
739  $this->editInfoObject();
740  return false;
741  }
742 
743  $this->setSubTabs('properties');
744  $this->tabs_gui->setTabActive('settings');
745  $this->tabs_gui->setSubTabActive('crs_info_settings');
746 
747  include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
748  $c_gui = new ilConfirmationGUI();
749 
750  // set confirm/cancel commands
751  $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteInfoFiles"));
752  $c_gui->setHeaderText($this->lng->txt("info_delete_sure"));
753  $c_gui->setCancel($this->lng->txt("cancel"), "editInfo");
754  $c_gui->setConfirm($this->lng->txt("confirm"), "deleteInfoFiles");
755 
756  // add items to delete
757  include_once('Modules/Course/classes/class.ilCourseFile.php');
758  foreach($_POST["file_id"] as $file_id)
759  {
760  $file = new ilCourseFile($file_id);
761  $c_gui->addItem("file_id[]", $file_id, $file->getFileName());
762  }
763 
764  $this->tpl->setContent($c_gui->getHTML());
765  }
766 
773  public function deleteInfoFilesObject()
774  {
775  if(!count($_POST['file_id']))
776  {
777  ilUtil::sendFailure($this->lng->txt('select_one'));
778  $this->editInfoObject();
779  return false;
780  }
781  include_once('Modules/Course/classes/class.ilCourseFile.php');
782 
783  foreach($_POST['file_id'] as $file_id)
784  {
785  $file = new ilCourseFile($file_id);
786  if($this->object->getId() == $file->getCourseId())
787  {
788  $file->delete();
789  }
790  }
791  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
792  $this->editInfoObject();
793  return true;
794  }
795 
803  public function initInfoEditor()
804  {
805  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
806  $form = new ilPropertyFormGUI();
807  $form->setFormAction($this->ctrl->getFormAction($this,'updateInfo'));
808  $form->setMultipart(true);
809  $form->setTitle($this->lng->txt('crs_general_info'));
810  $form->addCommandButton('updateInfo',$this->lng->txt('save'));
811  $form->addCommandButton('cancel',$this->lng->txt('cancel'));
812 
813  $area = new ilTextAreaInputGUI($this->lng->txt('crs_important_info'),'important');
814  $area->setValue($this->object->getImportantInformation());
815  $area->setRows(6);
816  $area->setCols(80);
817  $form->addItem($area);
818 
819  $area = new ilTextAreaInputGUI($this->lng->txt('crs_syllabus'),'syllabus');
820  $area->setValue($this->object->getSyllabus());
821  $area->setRows(6);
822  $area->setCols(80);
823  $form->addItem($area);
824 
826  $section->setTitle($this->lng->txt('crs_info_download'));
827  $form->addItem($section);
828 
829  $file = new ilFileInputGUI($this->lng->txt('crs_file'),'file');
830  $file->enableFileNameSelection('file_name');
831  $form->addItem($file);
832 
834  $section->setTitle($this->lng->txt('crs_contact'));
835  $form->addItem($section);
836 
837  $text = new ilTextInputGUI($this->lng->txt('crs_contact_name'),'contact_name');
838  $text->setValue($this->object->getContactName());
839  $text->setSize(40);
840  $text->setMaxLength(70);
841  $form->addItem($text);
842 
843  $text = new ilTextInputGUI($this->lng->txt('crs_contact_responsibility'),'contact_responsibility');
844  $text->setValue($this->object->getContactResponsibility());
845  $text->setSize(40);
846  $text->setMaxLength(70);
847  $form->addItem($text);
848 
849  $text = new ilTextInputGUI($this->lng->txt('crs_contact_phone'),'contact_phone');
850  $text->setValue($this->object->getContactPhone());
851  $text->setSize(40);
852  $text->setMaxLength(40);
853  $form->addItem($text);
854 
855  $text = new ilTextInputGUI($this->lng->txt('crs_contact_email'),'contact_email');
856  $text->setValue($this->object->getContactEmail());
857  $text->setInfo($this->lng->txt('crs_contact_email_info'));
858  $text->setSize(40);
859  $text->setMaxLength(255);
860  $form->addItem($text);
861 
862  $area = new ilTextAreaInputGUI($this->lng->txt('crs_contact_consultation'),'contact_consultation');
863  $area->setValue($this->object->getContactConsultation());
864  $area->setRows(6);
865  $area->setCols(80);
866  $form->addItem($area);
867 
868  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
869  $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_EDITOR,'crs',$this->object->getId());
870  $record_gui->setPropertyForm($form);
871  $record_gui->parse();
872 
873  return $form;
874  }
875 
876  function updateInfoObject()
877  {
878  global $ilErr,$ilAccess;
879 
880  $this->checkPermission('write');
881 
882  include_once 'Modules/Course/classes/class.ilCourseFile.php';
883  $file_obj = new ilCourseFile();
884  $file_obj->setCourseId($this->object->getId());
885  $file_obj->setFileName(strlen($_POST['file_name']) ?
886  ilUtil::stripSlashes($_POST['file_name']) :
887  $_FILES['file']['name']);
888  $file_obj->setFileSize($_FILES['file']['size']);
889  $file_obj->setFileType($_FILES['file']['type']);
890  $file_obj->setTemporaryName($_FILES['file']['tmp_name']);
891  $file_obj->setErrorCode($_FILES['file']['error']);
892 
893  $this->object->setImportantInformation(ilUtil::stripSlashes($_POST['important']));
894  $this->object->setSyllabus(ilUtil::stripSlashes($_POST['syllabus']));
895  $this->object->setContactName(ilUtil::stripSlashes($_POST['contact_name']));
896  $this->object->setContactResponsibility(ilUtil::stripSlashes($_POST['contact_responsibility']));
897  $this->object->setContactPhone(ilUtil::stripSlashes($_POST['contact_phone']));
898  $this->object->setContactEmail(ilUtil::stripSlashes($_POST['contact_email']));
899  $this->object->setContactConsultation(ilUtil::stripSlashes($_POST['contact_consultation']));
900 
901  include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
903  'crs',$this->object->getId());
904  $record_gui->loadFromPost();
905 
906  // Validate
907  $ilErr->setMessage('');
908  $file_obj->validate();
909  $this->object->validateInfoSettings();
910 
911  if(strlen($ilErr->getMessage()))
912  {
913  ilUtil::sendFailure($ilErr->getMessage());
914  $this->editInfoObject();
915  return false;
916  }
917  $this->object->update();
918  $file_obj->create();
919  $record_gui->saveValues();
920 
921  $this->object->updateECSContent();
922 
923  ilUtil::sendSuccess($this->lng->txt("crs_settings_saved"));
924  $this->editInfoObject();
925  return true;
926  }
927 
928  function updateObject()
929  {
930  $this->object->setTitle(ilUtil::stripSlashes($_POST['title']));
931  $this->object->setDescription(ilUtil::stripSlashes($_POST['desc']));
932 
933  $activation_start = $this->loadDate('activation_start');
934  $activation_end = $this->loadDate('activation_end');
935  $subscription_start = $this->loadDate('subscription_start');
936  $subscription_end = $this->loadDate('subscription_end');
937  $archive_start = $this->loadDate('archive_start');
938  $archive_end = $this->loadDate('archive_end');
939 
940  $this->object->setActivationType((int) $_POST['activation_type']);
941  $this->object->setActivationStart($activation_start->get(IL_CAL_UNIX));
942  $this->object->setActivationEnd($activation_end->get(IL_CAL_UNIX));
943  $this->object->setSubscriptionLimitationType((int) $_POST['subscription_limitation_type']);
944  $this->object->setSubscriptionType((int) $_POST['subscription_type']);
945  $this->object->setSubscriptionPassword(ilUtil::stripSlashes($_POST['subscription_password']));
946  $this->object->setSubscriptionStart($subscription_start->get(IL_CAL_UNIX));
947  $this->object->setSubscriptionEnd($subscription_end->get(IL_CAL_UNIX));
948  $this->object->enableSubscriptionMembershipLimitation((int) $_POST['subscription_membership_limitation']);
949  $this->object->setSubscriptionMaxMembers((int) $_POST['subscription_max']);
950  $this->object->enableRegistrationAccessCode((int) $_POST['reg_code_enabled']);
951  $this->object->setRegistrationAccessCode(ilUtil::stripSlashes($_POST['reg_code']));
952  $this->object->enableWaitingList((int) $_POST['waiting_list']);
953  #$this->object->setSubscriptionNotify((int) $_POST['subscription_notification']);
954  $this->object->setViewMode((int) $_POST['view_mode']);
955 
956  if($this->object->getViewMode() == IL_CRS_VIEW_TIMING)
957  {
958  $this->object->setOrderType(ilContainer::SORT_ACTIVATION);
959  }
960  else
961  {
962  $this->object->setOrderType((int) $_POST['order_type']);
963  }
964  $this->object->setArchiveStart($archive_start->get(IL_CAL_UNIX));
965  $this->object->setArchiveEnd($archive_end->get(IL_CAL_UNIX));
966  $this->object->setArchiveType($_POST['archive_type']);
967  $this->object->setAboStatus((int) $_POST['abo']);
968  $this->object->setShowMembers((int) $_POST['show_members']);
969 
970  $this->object->enableSessionLimit((int) $_POST['sl']);
971  $this->object->setNumberOfPreviousSessions(is_numeric($_POST['sp']) ? (int) $_POST['sp'] : -1 );
972  $this->object->setNumberOfnextSessions(is_numeric($_POST['sn']) ? (int) $_POST['sn'] : -1 );
973 
974  $this->object->setAutoNotiDisabled($_POST['deact_auto_noti'] == 1 ? true : false);
975 
976  if($this->object->validate())
977  {
978  $this->object->update();
979 
980  // BEGIN ChangeEvent: Record write event
981  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
982  global $ilUser;
983  ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
984  ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
985  // END ChangeEvent: Record write event
986 
987  // Update ecs export settings
988  if(!$this->updateECSExportSettings())
989  {
990  $this->editObject();
991  return false;
992  }
993  return $this->afterUpdate();
994  }
995  else
996  {
997  ilUtil::sendFailure($this->object->getMessage());
998  $this->editObject();
999  return false;
1000  }
1001  }
1002 
1008  protected function updateECSExportSettings()
1009  {
1010  global $rbacadmin;
1011 
1012  // ECS enabled
1013  include_once('./Services/WebServices/ECS/classes/class.ilECSServerSettings.php');
1014  if(!ilECSServerSettings::getInstance()->activeServerExists())
1015  {
1016  return true;
1017  }
1018 
1019  // Parse post data
1020  $mids = array();
1021  foreach((array) $_POST['ecs_sid'] as $sid_mid)
1022  {
1023  $tmp = explode('_',$sid_mid);
1024  $mids[$tmp[0]][] = $tmp[1];
1025  }
1026 
1027  try
1028  {
1029  include_once './Services/WebServices/ECS/classes/class.ilECSCommunitiesCache.php';
1030  include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSettings.php';
1031 
1032  // Update for each server
1033  foreach(ilECSParticipantSettings::getExportServers() as $server_id)
1034  {
1035  // Export
1036  $export = true;
1037  if(!$_POST['ecs_export'])
1038  {
1039  $export = false;
1040  }
1041  if(!count($mids[$server_id]))
1042  {
1043  $export = false;
1044  }
1045  $this->object->handleECSSettings(
1046  $server_id,
1047  $export,
1048  ilECSCommunitiesCache::getInstance()->lookupOwnId($server_id,$mids[$server_id][0]),
1049  $mids[$server_id]
1050  );
1051  // Permission handling
1052  include_once './Services/WebServices/ECS/classes/class.ilECSExport.php';
1053  include_once './Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
1054  foreach(ilECSServerSettings::getInstance()->getServers() as $settings)
1055  {
1056  $export = new ilECSExport($settings->getServerId(), $this->object->getId());
1057  if($export->isExported())
1058  {
1059  $rbacadmin->grantPermission(
1060  $settings->getGlobalRole(),
1061  ilRbacReview::_getOperationIdsByName(array('join','visible')),
1062  $this->object->getRefId()
1063  );
1064  }
1065  else
1066  {
1067  $rbacadmin->revokePermission(
1068  $this->object->getRefId(),
1069  $settings->getGlobalRole()
1070  );
1071  }
1072  }
1073  }
1074  return true;
1075  }
1076  catch(ilECSConnectorException $exc)
1077  {
1078  ilUtil::sendFailure('Error connecting to ECS server: '.$exc->getMessage());
1079  return false;
1080  }
1081  catch(ilECSContentWriterException $exc)
1082  {
1083  ilUtil::sendFailure('Course export failed with message: '.$exc->getMessage());
1084  return false;
1085  }
1086  return true;
1087  }
1088 
1095  public function editObject()
1096  {
1098 
1099  $this->setSubTabs('properties');
1100  $this->tabs_gui->setSubTabActive('crs_settings');
1101  }
1102 
1110  protected function initEditForm()
1111  {
1112  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
1113  include_once('./Services/Calendar/classes/class.ilDateTime.php');
1114 
1115  $form = new ilPropertyFormGUI();
1116  $form->setTitle($this->lng->txt('crs_edit'));
1117  $form->setTitleIcon(ilUtil::getImagePath('icon_crs_s.gif'));
1118 
1119  $form->addCommandButton('update',$this->lng->txt('save'));
1120  $form->addCommandButton('cancel',$this->lng->txt('cancel'));
1121 
1122  $form->setFormAction($this->ctrl->getFormAction($this,'update'));
1123 
1124  // title
1125  $title = new ilTextInputGUI($this->lng->txt('title'),'title');
1126  $title->setSubmitFormOnEnter(true);
1127  $title->setValue($this->object->getTitle());
1128  $title->setSize(40);
1129  $title->setMaxLength(128);
1130  $title->setRequired(true);
1131  $form->addItem($title);
1132 
1133  // desc
1134  $desc = new ilTextAreaInputGUI($this->lng->txt('description'),'desc');
1135  $desc->setValue($this->object->getLongDescription());
1136  $desc->setRows(2);
1137  $desc->setCols(40);
1138  $form->addItem($desc);
1139 
1140  // Show didactic template type
1141  $this->initDidacticTemplate($form);
1142 
1143  // reg type
1144  $act_type = new ilRadioGroupInputGUI($this->lng->txt('crs_visibility'),'activation_type');
1145  $act_type->setValue($this->object->getActivationType());
1146 
1147  $opt = new ilRadioOption($this->lng->txt('crs_visibility_unvisible'),IL_CRS_ACTIVATION_OFFLINE);
1148  $opt->setInfo($this->lng->txt('crs_availability_unvisible_info'));
1149  $act_type->addOption($opt);
1150 
1151  $opt = new ilRadioOption($this->lng->txt('crs_visibility_limitless'),IL_CRS_ACTIVATION_UNLIMITED);
1152  $opt->setInfo($this->lng->txt('crs_availability_limitless_info'));
1153  $act_type->addOption($opt);
1154 
1155  $opt = new ilRadioOption($this->lng->txt('crs_visibility_until'),IL_CRS_ACTIVATION_LIMITED);
1156  $opt->setInfo($this->lng->txt('crs_availability_until_info'));
1157 
1158  $start = new ilDateTimeInputGUI($this->lng->txt('crs_start'),'activation_start');
1159  #$start->setMode(ilDateTimeInputGUI::MODE_INPUT);
1160  $start->setShowTime(true);
1161  $start_date = new ilDateTime($this->object->getActivationStart(),IL_CAL_UNIX);
1162  $start->setDate($start_date);
1163  $opt->addSubItem($start);
1164 
1165  $end = new ilDateTimeInputGUI($this->lng->txt('crs_end'),'activation_end');
1166  #$end->setMode(ilDateTimeInputGUI::MODE_INPUT);
1167  $end->setShowTime(true);
1168  $end_date = new ilDateTime($this->object->getActivationEnd(),IL_CAL_UNIX);
1169  $end->setDate($end_date);
1170  $opt->addSubItem($end);
1171 
1172  $act_type->addOption($opt);
1173 
1174  $form->addItem($act_type);
1175 
1177  $section->setTitle($this->lng->txt('crs_reg'));
1178  $form->addItem($section);
1179 
1180  $reg_type = new ilRadioGroupInputGUI($this->lng->txt('crs_reg_period'),'subscription_limitation_type');
1181  $reg_type->setValue($this->object->getSubscriptionLimitationType());
1182 
1183  $opt = new ilRadioOption($this->lng->txt('crs_reg_deactivated'),IL_CRS_SUBSCRIPTION_DEACTIVATED);
1184  $opt->setInfo($this->lng->txt('crs_registration_deactivated'));
1185  $reg_type->addOption($opt);
1186 
1187  $opt = new ilRadioOption($this->lng->txt('crs_registration_unlimited'),IL_CRS_SUBSCRIPTION_UNLIMITED);
1188  $opt->setInfo($this->lng->txt('crs_reg_unlim_info'));
1189  $reg_type->addOption($opt);
1190 
1191  $opt = new ilRadioOption($this->lng->txt('crs_registration_limited'),IL_CRS_SUBSCRIPTION_LIMITED);
1192  $opt->setInfo($this->lng->txt('crs_reg_lim_info'));
1193 
1194  $start = new ilDateTimeInputGUI($this->lng->txt('crs_start'),'subscription_start');
1195  $start->setShowTime(true);
1196  $start_date = new ilDateTime($this->object->getSubscriptionStart(),IL_CAL_UNIX);
1197  $start->setDate($start_date);
1198  $opt->addSubItem($start);
1199 
1200  $end = new ilDateTimeInputGUI($this->lng->txt('crs_end'),'subscription_end');
1201  $end->setShowTime(true);
1202  $end_date = new ilDateTime($this->object->getSubscriptionEnd(),IL_CAL_UNIX);
1203  $end->setDate($end_date);
1204  $opt->addSubItem($end);
1205 
1206  $reg_type->addOption($opt);
1207 
1208  $form->addItem($reg_type);
1209 
1210 
1211 
1212  $reg_proc = new ilRadioGroupInputGUI($this->lng->txt('crs_registration_type'),'subscription_type');
1213  $reg_proc->setValue($this->object->getSubscriptionType());
1214  $reg_proc->setInfo($this->lng->txt('crs_reg_type_info'));
1215 
1216  $opt = new ilRadioOption($this->lng->txt('crs_subscription_options_confirmation'),IL_CRS_SUBSCRIPTION_CONFIRMATION);
1217  $reg_proc->addOption($opt);
1218 
1219  $opt = new ilRadioOption($this->lng->txt('crs_subscription_options_direct'),IL_CRS_SUBSCRIPTION_DIRECT);
1220  $reg_proc->addOption($opt);
1221 
1222  $opt = new ilRadioOption($this->lng->txt('crs_subscription_options_password'),IL_CRS_SUBSCRIPTION_PASSWORD);
1223 
1224  $pass = new ilTextInputGUI('','subscription_password');
1225  $pass->setSubmitFormOnEnter(true);
1226  $pass->setSize(12);
1227  $pass->setMaxLength(12);
1228  $pass->setValue($this->object->getSubscriptionPassword());
1229 
1230  $opt->addSubItem($pass);
1231  $reg_proc->addOption($opt);
1232 
1233  $form->addItem($reg_proc);
1234 
1235  // Registration codes
1236  $reg_code = new ilCheckboxInputGUI('','reg_code_enabled');
1237  $reg_code->setChecked($this->object->isRegistrationAccessCodeEnabled());
1238  $reg_code->setValue(1);
1239  $reg_code->setInfo($this->lng->txt('crs_reg_code_enabled_info'));
1240  $reg_code->setOptionTitle($this->lng->txt('crs_reg_code'));
1241 
1242  /*
1243  $code = new ilNonEditableValueGUI($this->lng->txt('crs_reg_code_value'));
1244  $code->setValue($this->object->getRegistrationAccessCode());
1245  $reg_code->addSubItem($code);
1246  */
1247 
1248  #$link = new ilNonEditableValueGUI($this->lng->txt('crs_reg_code_link'));
1249  // Create default access code
1250  if(!$this->object->getRegistrationAccessCode())
1251  {
1252  include_once './Services/Membership/classes/class.ilMembershipRegistrationCodeUtils.php';
1253  $this->object->setRegistrationAccessCode(ilMembershipRegistrationCodeUtils::generateCode());
1254  }
1255  $reg_link = new ilHiddenInputGUI('reg_code');
1256  $reg_link->setValue($this->object->getRegistrationAccessCode());
1257  $form->addItem($reg_link);
1258 
1259 
1260  $link = new ilCustomInputGUI($this->lng->txt('crs_reg_code_link'));
1261  include_once './classes/class.ilLink.php';
1262  $val = ilLink::_getLink($this->object->getRefId(),$this->object->getType(),array(),'_rcode'.$this->object->getRegistrationAccessCode());
1263  $link->setHTML('<font class="small">'.$val.'</font>');
1264  $reg_code->addSubItem($link);
1265 
1266  $form->addItem($reg_code);
1267 
1268 
1269  // Max members
1270  $lim = new ilCheckboxInputGUI($this->lng->txt('crs_subscription_max_members_short'),'subscription_membership_limitation');
1271  $lim->setValue(1);
1272  $lim->setOptionTitle($this->lng->txt('crs_subscription_max_members'));
1273  $lim->setChecked($this->object->isSubscriptionMembershipLimited());
1274 
1275  $max = new ilTextInputGUI('','subscription_max');
1276  $max->setSubmitFormOnEnter(true);
1277  $max->setSize(4);
1278  $max->setMaxLength(4);
1279  $max->setValue($this->object->getSubscriptionMaxMembers() ? $this->object->getSubscriptionMaxMembers() : '');
1280  $max->setTitle($this->lng->txt('members').':');
1281  $max->setInfo($this->lng->txt('crs_reg_max_info'));
1282 
1283  $lim->addSubItem($max);
1284 
1285  $wait = new ilCheckboxInputGUI('','waiting_list');
1286  $wait->setOptionTitle($this->lng->txt('crs_waiting_list'));
1287  $wait->setChecked($this->object->enabledWaitingList());
1288  $wait->setInfo($this->lng->txt('crs_wait_info'));
1289  $lim->addSubItem($wait);
1290 
1291  $form->addItem($lim);
1292 
1293  $not = new ilCheckboxInputGUI($this->lng->txt('crs_deact_auto_noti'), 'deact_auto_noti');
1294  $not->setValue(1);
1295  $not->setInfo($this->lng->txt('crs_deact_auto_noti_info'));
1296  $not->setChecked( $this->object->getAutoNotiDisabled() );
1297  $form->addItem($not);
1298 
1299  $pres = new ilFormSectionHeaderGUI();
1300  $pres->setTitle($this->lng->txt('crs_view_mode'));
1301 
1302  $form->addItem($pres);
1303 
1304  // presentation type
1305  $view_type = new ilRadioGroupInputGUI($this->lng->txt('crs_presentation_type'),'view_mode');
1306  $view_type->setValue($this->object->getViewMode());
1307 
1308  $opts = new ilRadioOption($this->lng->txt('cntr_view_sessions'),IL_CRS_VIEW_SESSIONS);
1309  $opts->setInfo($this->lng->txt('cntr_view_info_sessions'));
1310  $view_type->addOption($opts);
1311 
1312  // Limited sessions
1313  $sess = new ilCheckboxInputGUI($this->lng->txt('sess_limit'),'sl');
1314  $sess->setValue(1);
1315  $sess->setChecked($this->object->isSessionLimitEnabled());
1316  $sess->setInfo($this->lng->txt('sess_limit_info'));
1317 
1318  $prev = new ilNumberInputGUI($this->lng->txt('sess_num_prev'),'sp');
1319  #$prev->setSubmitFormOnEnter(true);
1320  $prev->setMinValue(0);
1321  $prev->setValue($this->object->getNumberOfPreviousSessions() == -1 ?
1322  '' :
1323  $this->object->getNumberOfPreviousSessions()
1324  );
1325  $prev->setSize(2);
1326  $prev->setMaxLength(3);
1327  $sess->addSubItem($prev);
1328 
1329  $next = new ilNumberInputGUI($this->lng->txt('sess_num_next'),'sn');
1330  #$next->setSubmitFormOnEnter(true);
1331  $next->setMinValue(0);
1332  $next->setValue($this->object->getNumberOfNextSessions() == -1 ?
1333  '' :
1334  $this->object->getNumberOfnextSessions()
1335  );
1336  $next->setSize(2);
1337  $next->setMaxLength(3);
1338  $sess->addSubItem($next);
1339 
1340  $opts->addSubItem($sess);
1341 
1342 
1343 
1344 
1345  $optsi = new ilRadioOption($this->lng->txt('cntr_view_simple'),IL_CRS_VIEW_SIMPLE);
1346  $optsi->setInfo($this->lng->txt('cntr_view_info_simple'));
1347  $view_type->addOption($optsi);
1348 
1349  $optbt = new ilRadioOption($this->lng->txt('cntr_view_by_type'),IL_CRS_VIEW_BY_TYPE);
1350  $optbt->setInfo($this->lng->txt('cntr_view_info_by_type'));
1351  $view_type->addOption($optbt);
1352 
1353  $opto = new ilRadioOption($this->lng->txt('crs_view_objective'),IL_CRS_VIEW_OBJECTIVE);
1354  $opto->setInfo($this->lng->txt('crs_view_info_objective'));
1355  $view_type->addOption($opto);
1356 
1357  $optt = new ilRadioOption($this->lng->txt('crs_view_timing'),IL_CRS_VIEW_TIMING);
1358  $optt->setInfo($this->lng->txt('crs_view_info_timing'));
1359  $view_type->addOption($optt);
1360 
1361  /*
1362  $opt = new ilRadioOption($this->lng->txt('crs_view_archive'),IL_CRS_VIEW_ARCHIVE);
1363  $opt->setInfo($this->lng->txt('crs_archive_info'));
1364 
1365  $down = new ilCheckboxInputGUI('','archive_type');
1366  $down->setOptionTitle($this->lng->txt('crs_archive_download'));
1367  $down->setChecked($this->object->getArchiveType() == IL_CRS_ARCHIVE_DOWNLOAD);
1368  $opt->addSubItem($down);
1369 
1370  $start = new ilDateTimeInputGUI($this->lng->txt('crs_start'),'archive_start');
1371  $start->setShowTime(true);
1372  $start_date = new ilDateTime($this->object->getArchiveStart(),IL_CAL_UNIX);
1373  $start->setDate($start_date);
1374  $opt->addSubItem($start);
1375 
1376  $end = new ilDateTimeInputGUI($this->lng->txt('crs_end'),'archive_end');
1377  $end->setShowTime(true);
1378  $end_date = new ilDateTime($this->object->getArchiveEnd(),IL_CAL_UNIX);
1379  $end->setDate($end_date);
1380  $opt->addSubItem($end);
1381 
1382  $view_type->addOption($opt);
1383  */
1384  $form->addItem($view_type);
1385 
1386  // sorting type
1387  $sort = new ilRadioGroupInputGUI($this->lng->txt('crs_sortorder_abo'),'order_type');
1388  $sort->setValue($this->object->getOrderType());
1389 
1390  $opt = new ilRadioOption($this->lng->txt('crs_sort_title'),ilContainer::SORT_TITLE);
1391  $opt->setInfo($this->lng->txt('crs_sort_title_info'));
1392  $sort->addOption($opt);
1393 
1394  $opt = new ilRadioOption($this->lng->txt('crs_sort_manual'),ilContainer::SORT_MANUAL);
1395  $opt->setInfo($this->lng->txt('crs_sort_manual_info'));
1396  $sort->addOption($opt);
1397 
1398  $opt = new ilRadioOption($this->lng->txt('crs_sort_activation'),ilContainer::SORT_ACTIVATION);
1399  $opt->setInfo($this->lng->txt('crs_sort_timing_info'));
1400  $sort->addOption($opt);
1401 
1402 
1403  $form->addItem($sort);
1404 
1405  $further = new ilFormSectionHeaderGUI();
1406  $further->setTitle($this->lng->txt('crs_further_settings'));
1407  $form->addItem($further);
1408 
1409  $desk = new ilCheckboxInputGUI($this->lng->txt('crs_add_remove_from_desktop'),'abo');
1410  $desk->setChecked($this->object->getAboStatus());
1411  $desk->setInfo($this->lng->txt('crs_add_remove_from_desktop_info'));
1412  $form->addItem($desk);
1413 
1414  $mem = new ilCheckboxInputGUI($this->lng->txt('crs_show_members'),'show_members');
1415  $mem->setChecked($this->object->getShowMembers());
1416  $mem->setInfo($this->lng->txt('crs_show_members_info'));
1417  $form->addItem($mem);
1418 
1419  $this->fillECSExportSettings($form);
1420 
1421  return $form;
1422  }
1423 
1424  protected function getEditFormValues()
1425  {
1426  // values are done in initEditForm()
1427  }
1428 
1429 
1434  protected function fillECSExportSettings(ilPropertyFormGUI $a_form)
1435  {
1436  global $ilLog;
1437 
1438  include_once('./Services/WebServices/ECS/classes/class.ilECSServerSettings.php');
1439  if(!ilECSServerSettings::getInstance()->activeServerExists())
1440  {
1441  return true;
1442  }
1443 
1444  // Return if no participant is enabled for export and the current object is not released
1445  include_once './Services/WebServices/ECS/classes/class.ilECSExport.php';
1446  include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSettings.php';
1447 
1449  if(!$exportablePart and !ilECSExport::_isExported($this->object->getId()))
1450  {
1451  return true;
1452  }
1453 
1454  $GLOBALS['lng']->loadLanguageModule('ecs');
1455 
1456  // show ecs property form section
1457  $ecs = new ilFormSectionHeaderGUI();
1458  $ecs->setTitle($this->lng->txt('ecs_export'));
1459  $a_form->addItem($ecs);
1460 
1461 
1462  // release or not
1463  $exp = new ilRadioGroupInputGUI($this->lng->txt('ecs_export_obj_settings'),'ecs_export');
1464  $exp->setRequired(true);
1465  $exp->setValue(ilECSExport::_isExported($this->object->getId()) ? 1 : 0);
1466  $off = new ilRadioOption($this->lng->txt('ecs_export_disabled'),0);
1467  $exp->addOption($off);
1468  $on = new ilRadioOption($this->lng->txt('ecs_export_enabled'),1);
1469  $exp->addOption($on);
1470  $a_form->addItem($exp);
1471 
1472  // Show all exportable participants
1473  $publish_for = new ilCheckboxGroupInputGUI($this->lng->txt('ecs_publish_for'),'ecs_sid');
1474 
1475  // @TODO: Active checkboxes for recipients
1476  //$publish_for->setValue((array) $members);
1477 
1478  // Read receivers
1479  $receivers = array();
1480  foreach(ilECSExport::getExportServerIds($this->object->getId()) as $sid)
1481  {
1482  $exp = new ilECSExport($sid, $this->object->getId());
1483  $eid = $exp->getEContentId();
1484  try
1485  {
1486  include_once './Services/WebServices/ECS/classes/class.ilECSEContentReader.php';
1487  $econtent_reader = new ilECSEContentReader($sid,$eid);
1488  $econtent_reader->read(true);
1489  $details = $econtent_reader->getEContentDetails();
1490  if($details instanceof ilECSEContentDetails)
1491  {
1492  foreach($details->getReceivers() as $mid)
1493  {
1494  $receivers[] = $sid.'_'.$mid;
1495  }
1496  #$owner = $details->getFirstSender();
1497  }
1498  }
1499  catch(ilECSConnectorException $exc)
1500  {
1501  $ilLog->write(__METHOD__.': Error connecting to ECS server. '.$exc->getMessage());
1502  }
1503  catch(ilECSReaderException $exc)
1504  {
1505  $ilLog->write(__METHOD__.': Error parsing ECS query: '.$exc->getMessage());
1506  }
1507  }
1508 
1509  $publish_for->setValue($receivers);
1510 
1511  foreach($exportablePart as $pInfo)
1512  {
1513  include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSetting.php';
1514  $partSetting = new ilECSParticipantSetting($pInfo['sid'], $pInfo['mid']);
1515 
1516  $com = new ilCheckboxInputGUI(
1517  $partSetting->getCommunityName().': '.$partSetting->getTitle(),
1518  'sid_mid'
1519  );
1520  $com->setValue($pInfo['sid'].'_'.$pInfo['mid']);
1521  $publish_for->addOption($com);
1522  }
1523  $on->addSubItem($publish_for);
1524  return true;
1525  }
1526 
1527 
1531  function editCourseIconsObject($a_form = null)
1532  {
1533  global $tpl;
1534 
1535  $this->checkPermission('write');
1536 
1537  $this->setSubTabs("properties");
1538  $this->tabs_gui->setTabActive('settings');
1539 
1540  if(!$a_form)
1541  {
1542  $a_form = $this->initCourseIconsForm();
1543  }
1544 
1545  $tpl->setContent($a_form->getHTML());
1546  }
1547 
1549  {
1550  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
1551  $form = new ilPropertyFormGUI();
1552  $form->setFormAction($this->ctrl->getFormAction($this));
1553 
1554  $this->showCustomIconsEditing(1, $form);
1555 
1556  // $form->setTitle($this->lng->txt('edit_grouping'));
1557  $form->addCommandButton('updateCourseIcons', $this->lng->txt('save'));
1558 
1559  return $form;
1560  }
1561 
1562  function sendFileObject()
1563  {
1564  include_once 'Modules/Course/classes/class.ilCourseFile.php';
1565  $file = new ilCourseFile((int) $_GET['file_id']);
1566  ilUtil::deliverFile($file->getAbsolutePath(),$file->getFileName(),$file->getFileType());
1567  return true;
1568  }
1569 
1574  {
1575  $this->checkPermission('write');
1576 
1577  $form = $this->initCourseIconsForm();
1578  if($form->checkInput())
1579  {
1580  //save custom icons
1581  if ($this->ilias->getSetting("custom_icons"))
1582  {
1583  if($_POST["cont_big_icon_delete"])
1584  {
1585  $this->object->removeBigIcon();
1586  }
1587  if($_POST["cont_small_icon_delete"])
1588  {
1589  $this->object->removeSmallIcon();
1590  }
1591  if($_POST["cont_tiny_icon_delete"])
1592  {
1593  $this->object->removeTinyIcon();
1594  }
1595  $this->object->saveIcons($_FILES["cont_big_icon"]['tmp_name'],
1596  $_FILES["cont_small_icon"]['tmp_name'], $_FILES["cont_tiny_icon"]['tmp_name']);
1597  }
1598 
1599  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
1600  $this->ctrl->redirect($this,"editCourseIcons");
1601  }
1602 
1603  $form->setValuesByPost();
1604  $this->editCourseIconsObject($form);
1605  }
1606 
1607 
1611  function setSubTabs($a_tab)
1612  {
1613  global $rbacsystem,$ilUser,$ilAccess;
1614 
1615  switch ($a_tab)
1616  {
1617  case "properties":
1618  $this->tabs_gui->addSubTabTarget("crs_settings",
1619  $this->ctrl->getLinkTarget($this,'edit'),
1620  "edit", get_class($this));
1621 
1622  $this->tabs_gui->addSubTabTarget("crs_info_settings",
1623  $this->ctrl->getLinkTarget($this,'editInfo'),
1624  "editInfo", get_class($this));
1625 
1626  $this->tabs_gui->addSubTabTarget("preconditions",
1627  $this->ctrl->getLinkTargetByClass('ilConditionHandlerInterface','listConditions'),
1628  "", "ilConditionHandlerInterface");
1629  $this->tabs_gui->addSubTabTarget("crs_start_objects",
1630  $this->ctrl->getLinkTarget($this,'listStructure'),
1631  "listStructure", get_class($this));
1632  $this->tabs_gui->addSubTabTarget('groupings',
1633  $this->ctrl->getLinkTargetByClass('ilobjcoursegroupinggui','listGroupings'),
1634  'listGroupings',
1635  get_class($this));
1636 
1637  // custom icon
1638  if ($this->ilias->getSetting("custom_icons"))
1639  {
1640  $this->tabs_gui->addSubTabTarget("icon_settings",
1641  $this->ctrl->getLinkTarget($this,'editCourseIcons'),
1642  "editCourseIcons", get_class($this));
1643  }
1644 
1645  // map settings
1646  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
1648  {
1649  $this->tabs_gui->addSubTabTarget("crs_map_settings",
1650  $this->ctrl->getLinkTarget($this,'editMapSettings'),
1651  "editMapSettings", get_class($this));
1652  }
1653 
1654 
1655  include_once('Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
1656  include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
1657  // only show if export permission is granted
1658  if(ilPrivacySettings::_getInstance()->checkExportAccess($this->object->getRefId()) or ilCourseDefinedFieldDefinition::_hasFields($this->object->getId()))
1659  {
1660  $this->tabs_gui->addSubTabTarget('crs_custom_user_fields',
1661  $this->ctrl->getLinkTargetByClass('ilobjectcustomuserfieldsgui'),
1662  '',
1663  'ilobjectcustomuserfieldsgui');
1664  }
1665  break;
1666 
1667  case "item_activation":
1668  $this->tabs_gui->addSubTabTarget("activation",
1669  $this->ctrl->getLinkTargetByClass('ilCourseItemAdministrationGUI','edit'),
1670  "edit", get_class($this));
1671  $this->ctrl->setParameterByClass('ilconditionhandlerinterface','item_id',(int) $_GET['item_id']);
1672  $this->tabs_gui->addSubTabTarget("preconditions",
1673  $this->ctrl->getLinkTargetByClass('ilConditionHandlerInterface','listConditions'),
1674  "", "ilConditionHandlerInterface");
1675  break;
1676 
1677  case 'members':
1678  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
1679  {
1680  $this->tabs_gui->addSubTabTarget("crs_member_administration",
1681  $this->ctrl->getLinkTarget($this,'members'),
1682  "members", get_class($this));
1683 
1684  $this->tabs_gui->addSubTabTarget("crs_members_groups",
1685  $this->ctrl->getLinkTargetByClass("ilCourseParticipantsGroupsGUI", "show"),
1686  "", "ilCourseParticipantsGroupsGUI");
1687  }
1688  $this->tabs_gui->addSubTabTarget("crs_members_gallery",
1689  $this->ctrl->getLinkTarget($this,'membersGallery'),
1690  "membersGallery", get_class($this));
1691 
1692  // members map
1693  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
1694  if (ilGoogleMapUtil::isActivated() && $this->object->getEnableCourseMap())
1695  {
1696  $this->tabs_gui->addSubTabTarget("crs_members_map",
1697  $this->ctrl->getLinkTarget($this,'membersMap'),
1698  "membersMap", get_class($this));
1699  }
1700 
1701 
1702  include_once 'Services/Mail/classes/class.ilMail.php';
1703  $mail =& new ilMail($ilUser->getId());
1704  if($rbacsystem->checkAccess('mail_visible',$mail->getMailObjectReferenceId()))
1705  {
1706  $this->tabs_gui->addSubTabTarget("mail_members",
1707  $this->ctrl->getLinkTarget($this,'mailMembers'),
1708  "mailMembers", get_class($this));
1709  }
1710 
1711  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
1712  {
1713  $this->tabs_gui->addSubTabTarget("events",
1714  $this->ctrl->getLinkTargetByClass('ilsessionoverviewgui','listSessions'),
1715  "", 'ilsessionoverviewgui');
1716  }
1717 
1718  include_once 'Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
1719  if(ilPrivacySettings::_getInstance()->checkExportAccess($this->object->getRefId()))
1720  {
1721  $this->tabs_gui->addSubTabTarget('export_members',
1722  $this->ctrl->getLinkTargetByClass('ilmemberexportgui','show'),
1723  "", 'ilmemberexportgui');
1724  }
1725 
1726  break;
1727 
1728 
1729  }
1730  }
1731 
1738  {
1739  $this->object->removeSmallIcon();
1740  $this->ctrl->redirect($this,'editCourseIcons');
1741  }
1742 
1749  {
1750  $this->object->removeBigIcon();
1751  $this->ctrl->redirect($this,'editCourseIcons');
1752  }
1753 
1754 
1761  {
1762  $this->object->removeTinyIcon();
1763  $this->ctrl->redirect($this,'editCourseIcons');
1764  }
1765 
1770  protected function afterSave(ilObject $a_new_object)
1771  {
1772  global $rbacadmin, $ilUser;
1773 
1774  $a_new_object->getMemberObject()->add($ilUser->getId(),IL_CRS_ADMIN);
1775  $a_new_object->getMemberObject()->updateNotification($ilUser->getId(),1);
1776  $a_new_object->update();
1777 
1778  // BEGIN ChangeEvent: Record write event.
1779  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
1780  global $ilUser;
1781  ilChangeEvent::_recordWriteEvent($a_new_object->getId(), $ilUser->getId(), 'create');
1782  // END ChangeEvent: Record write event.
1783 
1784  // always send a message
1785  ilUtil::sendSuccess($this->lng->txt("crs_added"),true);
1786 
1787  $this->ctrl->setParameter($this, "ref_id", $a_new_object->getRefId());
1788  ilUtil::redirect($this->getReturnLocation("save",
1789  $this->ctrl->getLinkTarget($this, "edit", "", false, false)));
1790  }
1791 
1793  {
1794  global $rbacsystem;
1795 
1796  $_POST["archives"] = $_POST["archives"] ? $_POST["archives"] : array();
1797 
1798  // MINIMUM ACCESS LEVEL = 'write'
1799  $this->checkPermission('read');
1800  /*
1801  if(!$rbacsystem->checkAccess("read", $this->object->getRefId()))
1802  {
1803  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
1804  }
1805  */
1806  if(!count($_POST['archives']))
1807  {
1808  ilUtil::sendFailure($this->lng->txt('crs_no_archive_selected'));
1809  $this->archiveObject();
1810 
1811  return false;
1812  }
1813  if(count($_POST['archives']) > 1)
1814  {
1815  ilUtil::sendFailure($this->lng->txt('crs_select_one_archive'));
1816  $this->archiveObject();
1817 
1818  return false;
1819  }
1820 
1821  $this->object->initCourseArchiveObject();
1822 
1823  $abs_path = $this->object->archives_obj->getArchiveFile((int) $_POST['archives'][0]);
1824  $basename = basename($abs_path);
1825 
1826  ilUtil::deliverFile($abs_path,$basename);
1827  }
1828 
1835  public function setShowHidePrefs()
1836  {
1837  global $ilUser;
1838 
1839  if(isset($_GET['admin_hide']))
1840  {
1841  $ilUser->writePref('crs_admin_hide',(int) $_GET['admin_hide']);
1842  }
1843  if(isset($_GET['tutor_hide']))
1844  {
1845  $ilUser->writePref('crs_tutor_hide',(int) $_GET['tutor_hide']);
1846  }
1847  if(isset($_GET['member_hide']))
1848  {
1849  $ilUser->writePref('crs_member_hide',(int) $_GET['member_hide']);
1850  }
1851  if(isset($_GET['subscriber_hide']))
1852  {
1853  $ilUser->writePref('crs_subscriber_hide',(int) $_GET['subscriber_hide']);
1854  }
1855  if(isset($_GET['wait_hide']))
1856  {
1857  $ilUser->writePref('crs_wait_hide',(int) $_GET['wait_hide']);
1858  }
1859  include_once './Modules/Course/classes/class.ilCourseParticipants.php';
1860  foreach(ilCourseParticipants::getMemberRoles($this->object->getRefId()) as $role_id)
1861  {
1862  if(isset($_GET['role_hide_'.$role_id]))
1863  {
1864  $ilUser->writePref('crs_role_hide_'.$role_id,(int) $_GET['role_hide_'.$role_id]);
1865  }
1866  }
1867  }
1868 
1869  public function readMemberData($ids,$role = 'admin')
1870  {
1871  if($this->show_tracking)
1872  {
1873  include_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
1874  $completed = ilLPStatusWrapper::_getCompleted($this->object->getId());
1875  $in_progress = ilLPStatusWrapper::_getInProgress($this->object->getId());
1876  $not_attempted = ilLPStatusWrapper::_getNotAttempted($this->object->getId());
1877  $failed = ilLPStatusWrapper::_getFailed($this->object->getId());
1878  }
1879  include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
1880  $privacy = ilPrivacySettings::_getInstance();
1881 
1882  if($privacy->enabledCourseAccessTimes())
1883  {
1884  include_once('./Services/Tracking/classes/class.ilLearningProgress.php');
1885  $progress = ilLearningProgress::_lookupProgressByObjId($this->object->getId());
1886  }
1887 
1888  foreach((array) $ids as $usr_id)
1889  {
1891  $tmp_data['firstname'] = $name['firstname'];
1892  $tmp_data['lastname'] = $name['lastname'];
1893  $tmp_data['login'] = ilObjUser::_lookupLogin($usr_id);
1894  $tmp_data['passed'] = $this->object->getMembersObject()->hasPassed($usr_id) ? 1 : 0;
1895  $tmp_data['notification'] = $this->object->getMembersObject()->isNotificationEnabled($usr_id) ? 1 : 0;
1896  $tmp_data['blocked'] = $this->object->getMembersObject()->isBlocked($usr_id) ? 1 : 0;
1897  $tmp_data['usr_id'] = $usr_id;
1898 
1899  if($this->show_tracking)
1900  {
1901  if(in_array($usr_id,$completed))
1902  {
1903  $tmp_data['progress'] = LP_STATUS_COMPLETED;
1904  }
1905  elseif(in_array($usr_id,$in_progress))
1906  {
1907  $tmp_data['progress'] = LP_STATUS_IN_PROGRESS;
1908  }
1909  elseif(in_array($usr_id,$failed))
1910  {
1911  $tmp_data['progress'] = LP_STATUS_FAILED;
1912  }
1913  else
1914  {
1915  $tmp_data['progress'] = LP_STATUS_NOT_ATTEMPTED;
1916  }
1917  }
1918 
1919  if($privacy->enabledCourseAccessTimes())
1920  {
1921  if(isset($progress[$usr_id]['ts']) and $progress[$usr_id]['ts'])
1922  {
1923  $tmp_data['access_ut'] = $progress[$usr_id]['ts'];
1924  $tmp_data['access_time'] = ilDatePresentation::formatDate(new ilDateTime($progress[$usr_id]['ts'],IL_CAL_UNIX));
1925  }
1926  else
1927  {
1928  $tmp_data['access_ut'] = 0;
1929  $tmp_data['access_time'] = $this->lng->txt('no_date');
1930  }
1931  }
1932  $members[$usr_id] = $tmp_data;
1933  }
1934  return $members ? $members : array();
1935  }
1936 
1937 
1938 
1946  protected function membersObject()
1947  {
1948  global $ilUser, $rbacsystem, $ilToolbar, $lng, $ilCtrl, $tpl, $rbacreview;
1949 
1950  include_once('./Modules/Course/classes/class.ilCourseParticipants.php');
1951  include_once('./Modules/Course/classes/class.ilCourseParticipantsTableGUI.php');
1952  include_once './Services/Tracking/classes/class.ilObjUserTracking.php';
1953  include_once('./Services/Tracking/classes/class.ilLPObjSettings.php');
1954 
1955 
1956  if(isset($_GET['member_table_nav']))
1957  {
1958  list($_SESSION['crs_print_sort'],$_SESSION['crs_print_order'],$tmp) = explode(':',$_GET['member_table_nav']);
1959  }
1960 
1961  $this->checkPermission('write');
1962  $this->show_tracking = (ilObjUserTracking::_enabledLearningProgress() and
1964  ilLPObjSettings::_lookupMode($this->object->getId()) != LP_MODE_DEACTIVATED);
1965 
1966  include_once('./Modules/Course/classes/class.ilCourseItems.php');
1967  $this->timings_enabled = (ilCourseItems::_hasTimings($this->object->getRefId()) and
1968  ($this->object->getViewMode() == IL_CRS_VIEW_TIMING));
1969 
1970  $this->setSubTabs('members');
1971  $this->tabs_gui->setTabActive('members');
1972  $this->tabs_gui->setSubTabActive('crs_member_administration');
1973 
1974  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.crs_edit_members.html','Modules/Course');
1975  $this->tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
1976 
1977  // add members
1978  include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
1980  $this,
1981  $ilToolbar,
1982  array(
1983  'auto_complete_name' => $lng->txt('user'),
1984  'user_type' => array(
1985  ilCourseConstants::CRS_MEMBER => $lng->txt("crs_member"),
1986  ilCourseConstants::CRS_TUTOR => $lng->txt("crs_tutor"),
1987  ilCourseConstants::CRS_ADMIN => $lng->txt("crs_admin")
1988  ),
1989  'submit_name' => $lng->txt('add')
1990  )
1991  );
1992 
1993  // spacer
1994  $ilToolbar->addSeparator();
1995 
1996  // search button
1997  $ilToolbar->addButton($this->lng->txt("crs_search_users"),
1998  $this->ctrl->getLinkTargetByClass('ilRepositorySearchGUI','start'));
1999 
2000  // separator
2001  $ilToolbar->addSeparator();
2002 
2003  // print button
2004  $ilToolbar->addButton($this->lng->txt("crs_print_list"),
2005  $this->ctrl->getLinkTarget($this, 'printMembers'), "_blank");
2006 
2007 
2008  $this->setShowHidePrefs();
2009 
2010  // Waiting list table
2011  include_once('./Modules/Course/classes/class.ilCourseWaitingList.php');
2012  $waiting_list = new ilCourseWaitingList($this->object->getId());
2013  if(count($wait = $waiting_list->getAllUsers()))
2014  {
2015  include_once('./Services/Membership/classes/class.ilWaitingListTableGUI.php');
2016  if($ilUser->getPref('crs_wait_hide'))
2017  {
2018  $table_gui = new ilWaitingListTableGUI($this,$waiting_list,false);
2019  $this->ctrl->setParameter($this,'wait_hide',0);
2020  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
2021  $this->lng->txt('show'),
2022  '',
2023  ilUtil::getImagePath('edit_add.png'));
2024  $this->ctrl->clearParameters($this);
2025  }
2026  else
2027  {
2028  $table_gui = new ilWaitingListTableGUI($this,$waiting_list,true);
2029  $this->ctrl->setParameter($this,'wait_hide',1);
2030  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
2031  $this->lng->txt('hide'),
2032  '',
2033  ilUtil::getImagePath('edit_remove.png'));
2034  $this->ctrl->clearParameters($this);
2035  }
2036  $table_gui->setUsers($wait);
2037  $table_gui->setTitle($this->lng->txt('crs_waiting_list'),'icon_usr.gif',$this->lng->txt('crs_waiting_list'));
2038  $this->tpl->setVariable('TABLE_WAIT',$table_gui->getHTML());
2039  }
2040 
2041  // Subscriber table
2042  if($subscribers = ilCourseParticipants::lookupSubscribers($this->object->getId()))
2043  {
2044  include_once('./Services/Membership/classes/class.ilSubscriberTableGUI.php');
2045  if($ilUser->getPref('crs_subscriber_hide'))
2046  {
2047  $table_gui = new ilSubscriberTableGUI($this,false);
2048  $this->ctrl->setParameter($this,'subscriber_hide',0);
2049  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
2050  $this->lng->txt('show'),
2051  '',
2052  ilUtil::getImagePath('edit_add.png'));
2053  $this->ctrl->clearParameters($this);
2054  }
2055  else
2056  {
2057  $table_gui = new ilSubscriberTableGUI($this,true);
2058  $this->ctrl->setParameter($this,'subscriber_hide',1);
2059  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
2060  $this->lng->txt('hide'),
2061  '',
2062  ilUtil::getImagePath('edit_remove.png'));
2063  $this->ctrl->clearParameters($this);
2064  }
2065  $table_gui->readSubscriberData();
2066  $table_gui->setTitle($this->lng->txt('group_new_registrations'),'icon_usr.gif',$this->lng->txt('group_new_registrations'));
2067  $this->tpl->setVariable('TABLE_SUB',$table_gui->getHTML());
2068  }
2069 
2070 
2071 
2072  if($rbacreview->getNumberOfAssignedUsers(array($this->object->getDefaultAdminRole())))
2073  {
2074  // Security: display the list of course administrators read-only,
2075  // if the user doesn't have the 'edit_permission' permission.
2076  $showEditLink = $rbacsystem->checkAccess("edit_permission", $this->object->getRefId());
2077  if($ilUser->getPref('crs_admin_hide'))
2078  {
2079  $table_gui = new ilCourseParticipantsTableGUI(
2080  $this,
2081  'admin',
2082  false,
2083  false,
2084  $this->timings_enabled,
2085  $showEditLink,
2086  $this->object->getDefaultAdminRole()
2087  );
2088  $this->ctrl->setParameter($this,'admin_hide',0);
2089  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
2090  $this->lng->txt('show'),
2091  '',
2092  ilUtil::getImagePath('edit_add.png'));
2093  $this->ctrl->clearParameters($this);
2094  }
2095  else
2096  {
2097  $table_gui = new ilCourseParticipantsTableGUI(
2098  $this,
2099  'admin',
2100  true,
2101  false,
2102  $this->timings_enabled,
2103  $showEditLink,
2104  $this->object->getDefaultAdminRole()
2105  );
2106  $this->ctrl->setParameter($this,'admin_hide',1);
2107  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
2108  $this->lng->txt('hide'),
2109  '',
2110  ilUtil::getImagePath('edit_remove.png'));
2111  $this->ctrl->clearParameters($this);
2112  }
2113  $table_gui->setTitle($this->lng->txt('crs_administrators'),'icon_usr.gif',$this->lng->txt('crs_administrators'));
2114  $table_gui->parse();
2115  $this->tpl->setVariable('ADMINS',$table_gui->getHTML());
2116  }
2117  if($rbacreview->getNumberOfAssignedUsers(array($this->object->getDefaultTutorRole())))
2118  {
2119  if($ilUser->getPref('crs_tutor_hide'))
2120  {
2121  $table_gui = new ilCourseParticipantsTableGUI(
2122  $this,
2123  'tutor',
2124  false,
2125  false,
2126  $this->timings_enabled,
2127  true,
2128  $this->object->getDefaultTutorRole()
2129  );
2130  $this->ctrl->setParameter($this,'tutor_hide',0);
2131  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
2132  $this->lng->txt('show'),
2133  '',
2134  ilUtil::getImagePath('edit_add.png'));
2135  $this->ctrl->clearParameters($this);
2136  }
2137  else
2138  {
2139  $table_gui = new ilCourseParticipantsTableGUI(
2140  $this,
2141  'tutor',
2142  true,
2143  false,
2144  $this->timings_enabled,
2145  true,
2146  $this->object->getDefaultTutorRole()
2147  );
2148  $this->ctrl->setParameter($this,'tutor_hide',1);
2149  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
2150  $this->lng->txt('hide'),
2151  '',
2152  ilUtil::getImagePath('edit_remove.png'));
2153  $this->ctrl->clearParameters($this);
2154  }
2155  $table_gui->setTitle($this->lng->txt('crs_tutors'),'icon_usr.gif',$this->lng->txt('crs_tutors'));
2156  $table_gui->parse();
2157  $this->tpl->setVariable('TUTORS',$table_gui->getHTML());
2158  }
2159  if($rbacreview->getNumberOfAssignedUsers(array($this->object->getDefaultMemberRole())))
2160  {
2161  if($ilUser->getPref('crs_member_hide'))
2162  {
2163  $table_gui = new ilCourseParticipantsTableGUI(
2164  $this,
2165  'member',
2166  false,
2167  $this->show_tracking,
2168  $this->timings_enabled,
2169  true,
2170  $this->object->getDefaultMemberRole()
2171  );
2172 
2173  $this->ctrl->setParameter($this,'member_hide',0);
2174  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
2175  $this->lng->txt('show'),
2176  '',
2177  ilUtil::getImagePath('edit_add.png'));
2178  $this->ctrl->clearParameters($this);
2179  }
2180  else
2181  {
2182  $table_gui = new ilCourseParticipantsTableGUI(
2183  $this,
2184  'member',
2185  true,
2186  $this->show_tracking,
2187  $this->timings_enabled,
2188  true,
2189  $this->object->getDefaultMemberRole()
2190  );
2191  $this->ctrl->setParameter($this,'member_hide',1);
2192  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
2193  $this->lng->txt('hide'),
2194  '',
2195  ilUtil::getImagePath('edit_remove.png'));
2196  $this->ctrl->clearParameters($this);
2197  }
2198  $table_gui->setTitle($this->lng->txt('crs_members'),'icon_usr.gif',$this->lng->txt('crs_members'));
2199  $table_gui->parse();
2200  $this->tpl->setCurrentBlock('member_block');
2201  $this->tpl->setVariable('MEMBERS',$table_gui->getHTML());
2202  $this->tpl->parseCurrentBlock();
2203 
2204  }
2205  foreach(ilCourseParticipants::getMemberRoles($this->object->getRefId()) as $role_id)
2206  {
2207  // Do not show table if no user is assigned
2208  if(!($GLOBALS['rbacreview']->getNumberOfAssignedUsers(array($role_id))))
2209  {
2210  continue;
2211  }
2212  if($ilUser->getPref('crs_role_hide_'.$role_id))
2213  {
2214  $table_gui = new ilCourseParticipantsTableGUI(
2215  $this,
2216  'role',
2217  false,
2218  $this->show_tracking,
2219  $this->timings_enabled,
2220  true,
2221  $role_id
2222  );
2223  $this->ctrl->setParameter($this,'role_hide_'.$role_id,0);
2224  $table_gui->addHeaderCommand(
2225  $this->ctrl->getLinkTarget($this,'members'),
2226  $this->lng->txt('show'),
2227  '',
2228  ilUtil::getImagePath('edit_add.png')
2229  );
2230  $this->ctrl->clearParameters($this);
2231  }
2232  else
2233  {
2234  $table_gui = new ilCourseParticipantsTableGUI(
2235  $this,
2236  'role',
2237  true,
2238  $this->show_tracking,
2239  $this->timings_enabled,
2240  true,
2241  $role_id
2242  );
2243  $this->ctrl->setParameter($this,'role_hide_'.$role_id,1);
2244  $table_gui->addHeaderCommand(
2245  $this->ctrl->getLinkTarget($this,'members'),
2246  $this->lng->txt('hide'),
2247  '',
2248  ilUtil::getImagePath('edit_remove.png')
2249  );
2250  $this->ctrl->clearParameters($this);
2251  }
2252 
2253  $table_gui->setTitle(ilObject::_lookupTitle($role_id),'icon_usr.gif',$this->lng->txt('crs_members'));
2254  $table_gui->parse();
2255  $this->tpl->setCurrentBlock('member_block');
2256  $this->tpl->setVariable('MEMBERS',$table_gui->getHTML());
2257  $this->tpl->parseCurrentBlock();
2258  }
2259 
2260 
2261  $this->tpl->setVariable('TXT_SELECTED_USER',$this->lng->txt('crs_selected_users'));
2262  $this->tpl->setVariable('BTN_FOOTER_EDIT',$this->lng->txt('edit'));
2263  $this->tpl->setVariable('BTN_FOOTER_VAL',$this->lng->txt('remove'));
2264  $this->tpl->setVariable('BTN_FOOTER_MAIL',$this->lng->txt('crs_mem_send_mail'));
2265  $this->tpl->setVariable('ARROW_DOWN',ilUtil::getImagePath('arrow_downright.gif'));
2266 
2267  }
2268 
2269 
2270 
2278  public function updateAdminStatusObject()
2279  {
2280  $this->checkPermission('write');
2281 
2282  $visible_members = array_intersect(array_unique((array) $_POST['visible_member_ids']),$this->object->getMembersObject()->getAdmins());
2283  $passed = is_array($_POST['passed']) ? $_POST['passed'] : array();
2284  $notification = is_array($_POST['notification']) ? $_POST['notification'] : array();
2285 
2286  $this->updateParticipantsStatus('admins',$visible_members,$passed,$notification,array());
2287  }
2288 
2296  public function updateTutorStatusObject()
2297  {
2298  $this->checkPermission('write');
2299 
2300  $visible_members = array_intersect(array_unique((array) $_POST['visible_member_ids']),$this->object->getMembersObject()->getTutors());
2301  $passed = is_array($_POST['passed']) ? $_POST['passed'] : array();
2302  $notification = is_array($_POST['notification']) ? $_POST['notification'] : array();
2303 
2304  $this->updateParticipantsStatus('admins',$visible_members,$passed,$notification,array());
2305  }
2306 
2314  public function updateMemberStatusObject()
2315  {
2316  $this->checkPermission('write');
2317 
2318  $visible_members = array_intersect(array_unique((array) $_POST['visible_member_ids']),$this->object->getMembersObject()->getMembers());
2319  $passed = is_array($_POST['passed']) ? $_POST['passed'] : array();
2320  $blocked = is_array($_POST['blocked']) ? $_POST['blocked'] : array();
2321 
2322  $this->updateParticipantsStatus('members',$visible_members,$passed,array(),$blocked);
2323 
2324  }
2325 
2329  public function updateRoleStatusObject()
2330  {
2331  global $rbacreview;
2332 
2333  $this->checkPermission('write');
2334 
2335  include_once './Modules/Course/classes/class.ilCourseParticipants.php';
2336 
2337  $users = array();
2338  foreach(ilCourseParticipants::getMemberRoles($this->object->getRefId()) as $role_id)
2339  {
2340  $users = array_merge($users,$rbacreview->assignedUsers($role_id));
2341  }
2342 
2343  $passed = is_array($_POST['passed']) ? $_POST['passed'] : array();
2344  $blocked = is_array($_POST['blocked']) ? $_POST['blocked'] : array();
2345 
2346  $this->updateParticipantsStatus('members',$users,$passed,array(),$blocked);
2347  }
2348 
2349  function updateParticipantsStatus($type,$visible_members,$passed,$notification,$blocked)
2350  {
2351  global $ilAccess,$ilErr,$ilUser,$rbacadmin;
2352 
2353  foreach($visible_members as $member_id)
2354  {
2355  $this->object->getMembersObject()->updatePassed($member_id,in_array($member_id,$passed));
2356  switch($type)
2357  {
2358  case 'admins';
2359  $this->object->getMembersObject()->updateNotification($member_id,in_array($member_id,$notification));
2360  $this->object->getMembersObject()->updateBlocked($member_id,false);
2361  break;
2362 
2363  case 'members':
2364  if($this->object->getMembersObject()->isBlocked($member_id) and !in_array($member_id,$blocked))
2365  {
2366  $this->object->getMembersObject()->sendNotification($this->object->getMembersObject()->NOTIFY_UNBLOCK_MEMBER,$member_id);
2367  }
2368  if(!$this->object->getMembersObject()->isBlocked($member_id) and in_array($member_id,$blocked))
2369  {
2370  $this->object->getMembersObject()->sendNotification($this->object->getMembersObject()->NOTIFY_BLOCK_MEMBER,$member_id);
2371  }
2372  $this->object->getMembersObject()->updateNotification($member_id,false);
2373  $this->object->getMembersObject()->updateBlocked($member_id,in_array($member_id,$blocked));
2374 
2375 
2376  break;
2377  }
2378  }
2379 
2380  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
2381  $this->membersObject();
2382  }
2383 
2384 
2386  {
2387  include_once './Modules/Course/classes/class.ilObjCourseGrouping.php';
2388 
2389  $this->object->initWaitingList();
2390  if($this->object->waiting_list_obj->getCountUsers())
2391  {
2392  $counter = 0;
2393  $f_result = array();
2394  foreach($this->object->waiting_list_obj->getAllUsers() as $waiting_data)
2395  {
2396  // GET USER OBJ
2397  if($tmp_obj = ilObjectFactory::getInstanceByObjId($waiting_data['usr_id'],false))
2398  {
2399  $waiting_list_ids[] = $waiting_data['usr_id'];
2400  $message = '';
2401  // Check if user is member in course grouping
2402  foreach(ilObjCourseGrouping::_getGroupingCourseIds($this->object->getRefId(),
2403  $this->object->getId()) as $course_data)
2404  {
2405  $tmp_members = ilCourseParticipants::_getInstanceByObjId($course_data['id']);
2406  if($course_data['id'] != $this->object->getId() and
2407  $tmp_members->isGroupingMember($tmp_obj->getId(),$course_data['unique']))
2408  {
2409  $message .= ('<br /><font class="alert">'.$this->lng->txt('crs_member_of').' ');
2410  $message .= (ilObject::_lookupTitle($course_data['id'])."</font>");
2411  }
2412  }
2413 
2414  $f_result[$counter][] = ilUtil::formCheckbox(0,"waiting_list[]",$waiting_data['usr_id']);
2415  $f_result[$counter][] = $tmp_obj->getLastname().', '.$tmp_obj->getFirstname().$message;
2416  $f_result[$counter][] = $tmp_obj->getLogin();
2417  $f_result[$counter][] = ilDatePresentation::formatDate(new ilDateTime($waiting_data['time'],IL_CAL_UNIX));
2418  unset($tmp_obj);
2419  ++$counter;
2420  }
2421  }
2422  $this->__showWaitingListTable($f_result,$waiting_list_ids);
2423 
2424  } // END waiting list
2425  }
2426 
2427 
2435  public function editMemberObject()
2436  {
2437  $_POST['members'] = array((int) $_GET['member_id']);
2438  $this->editMembersObject();
2439  return true;
2440  }
2441 
2442 
2449  public function editMembersObject()
2450  {
2451  $this->checkPermission('write');
2452 
2453  $participants = array_unique(array_merge((array) $_POST['admins'],(array) $_POST['tutors'],(array) $_POST['members'], (array) $_POST['roles']));
2454 
2455  if(!count($participants))
2456  {
2457  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
2458  $this->membersObject();
2459  return false;
2460  }
2461 
2462  $this->setSubTabs('members');
2463  $this->tabs_gui->setTabActive('members');
2464  $this->tabs_gui->setSubTabActive('crs_member_administration');
2465 
2466  include_once('./Modules/Course/classes/class.ilCourseEditParticipantsTableGUI.php');
2467  $table_gui = new ilCourseEditParticipantsTableGUI($this);
2468  $table_gui->setTitle($this->lng->txt('crs_header_edit_members'),'icon_usr.gif',$this->lng->txt('crs_header_edit_members'));
2469  $table_gui->setData($this->readMemberData($participants));
2470 
2471  $this->tpl->setContent($table_gui->getHTML());
2472  return true;
2473  }
2474 
2482  public function updateMembersObject()
2483  {
2484  global $rbacsystem, $rbacreview;
2485 
2486  $this->checkPermission('write');
2487 
2488  if(!count($_POST['participants']))
2489  {
2490  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
2491  $this->membersObject();
2492  return false;
2493  }
2494 
2495  $notifications = $_POST['notification'] ? $_POST['notification'] : array();
2496  $passed = $_POST['passed'] ? $_POST['passed'] : array();
2497  $blocked = $_POST['blocked'] ? $_POST['blocked'] : array();
2498 
2499  // Determine whether the user has the 'edit_permission' permission
2500  $hasEditPermissionAccess = $rbacsystem->checkAccess('edit_permission', $this->object->getRefId());
2501 
2502  // Get all assignable local roles of the course object, and
2503  // determine the role id of the course administrator role.
2504  $assignableLocalCourseRoles = array();
2505  $courseAdminRoleId = $this->object->getDefaultAdminRole();
2506  foreach ($this->object->getLocalCourseRoles(false) as $title => $role_id)
2507  {
2508  $assignableLocalCourseRoles[$role_id] = $title;
2509  }
2510 
2511  // Validate the user ids and role ids in the post data
2512  foreach($_POST['participants'] as $usr_id)
2513  {
2514  $memberIsCourseAdmin = $rbacreview->isAssigned($usr_id, $courseAdminRoleId);
2515 
2516  // If the current user doesn't have the 'edit_permission'
2517  // permission, make sure he doesn't remove the course
2518  // administrator role of members who are course administrator.
2519  if (! $hasEditPermissionAccess && $memberIsCourseAdmin &&
2520  ! in_array($courseAdminRoleId, $_POST['roles'][$usr_id])
2521  )
2522  {
2523  $_POST['roles'][$usr_id][] = $courseAdminRoleId;
2524  }
2525 
2526  // Validate the role ids in the post data
2527  foreach ((array) $_POST['roles'][$usr_id] as $role_id)
2528  {
2529  if(!array_key_exists($role_id, $assignableLocalCourseRoles))
2530  {
2531  ilUtil::sendFailure($this->lng->txt('msg_no_perm_perm'));
2532  $this->membersObject();
2533  return false;
2534  }
2535  if(!$hasEditPermissionAccess &&
2536  $role_id == $courseAdminRoleId &&
2537  !$memberIsCourseAdmin)
2538  {
2539  ilUtil::sendFailure($this->lng->txt('msg_no_perm_perm'));
2540  $this->membersObject();
2541  return false;
2542  }
2543  }
2544  }
2545 
2546  $has_admin = false;
2547  foreach(ilCourseParticipants::_getInstanceByObjId($this->object->getId())->getAdmins() as $admin_id)
2548  {
2549  if(!isset($_POST['roles'][$admin_id]))
2550  {
2551  $has_admin = true;
2552  break;
2553  }
2554  if(in_array($courseAdminRoleId,$_POST['roles'][$admin_id]))
2555  {
2556  $has_admin = true;
2557  break;
2558  }
2559  }
2560 
2561  if(!$has_admin)
2562  {
2563  ilUtil::sendFailure($this->lng->txt('crs_min_one_admin'));
2564  $_POST['members'] = $_POST['participants'];
2565  $this->editMembersObject();
2566  return false;
2567  }
2568 
2569  foreach($_POST['participants'] as $usr_id)
2570  {
2571  $this->object->getMembersObject()->updateRoleAssignments($usr_id,(array) $_POST['roles'][$usr_id]);
2572 
2573  // Disable notification for all of them
2574  $this->object->getMembersObject()->updateNotification($usr_id,0);
2575  if(($this->object->getMembersObject()->isTutor($usr_id) or $this->object->getMembersObject()->isAdmin($usr_id)) and in_array($usr_id,$notifications))
2576  {
2577  $this->object->getMembersObject()->updateNotification($usr_id,1);
2578  }
2579 
2580  $this->object->getMembersObject()->updateBlocked($usr_id,0);
2581  if((!$this->object->getMembersObject()->isAdmin($usr_id) and !$this->object->getMembersObject()->isTutor($usr_id)) and in_array($usr_id,$blocked))
2582  {
2583  $this->object->getMembersObject()->updateBlocked($usr_id,1);
2584  }
2585  $this->object->getMembersObject()->updatePassed($usr_id,in_array($usr_id,$passed));
2586  $this->object->getMembersObject()->sendNotification(
2587  $this->object->getMembersObject()->NOTIFY_STATUS_CHANGED,
2588  $usr_id);
2589  }
2590  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"));
2591  $this->membersObject();
2592  return true;
2593 
2594  }
2595 
2596 
2597 
2598 
2600  {
2601  global $rbacsystem;
2602 
2603  $this->checkPermission('write');
2604 
2605  // CHECK MEMBER_ID
2606  if(!isset($_GET["member_id"]) or !$this->object->getMembersObject()->isAssigned((int) $_GET["member_id"]))
2607  {
2608  $this->ilias->raiseError($this->lng->txt("crs_no_valid_member_id_given"),$this->ilias->error_obj->MESSAGE);
2609  }
2610 
2611 
2612  // Remember settings for notification
2613  $passed = $this->object->getMembersObject()->hasPassed((int) $_GET['member_id']);
2614  $notify = $this->object->getMembersObject()->isNotificationEnabled((int) $_GET['member_id']);
2615  $blocked = $this->object->getMembersObject()->isBlocked((int) $_GET['member_id']);
2616 
2617  $this->object->getMembersObject()->updateRoleAssignments((int) $_GET['member_id'],$_POST['roles']);
2618  $this->object->getMembersObject()->updatePassed((int) $_GET['member_id'],(int) $_POST['passed']);
2619  $this->object->getMembersObject()->updateNotification((int) $_GET['member_id'],(int) $_POST['notification']);
2620  $this->object->getMembersObject()->updateBlocked((int) $_GET['member_id'],(int) $_POST['blocked']);
2621 
2622  if($passed != $this->object->getMembersObject()->hasPassed((int) $_GET['member_id']) or
2623  $notify != $this->object->getMembersObject()->isNotificationEnabled((int) $_GET['member_id']) or
2624  $blocked != $this->object->getMembersObject()->isBlocked((int) $_GET['member_id']))
2625  {
2626  $this->object->getMembersObject()->sendNotification($this->object->getMembersObject()->NOTIFY_STATUS_CHANGED,(int) $_GET['member_id']);
2627  }
2628 
2629  ilUtil::sendSuccess($this->lng->txt("crs_member_updated"));
2630  $this->membersObject();
2631  return true;
2632 
2633  }
2634 
2635 
2643  public function assignMembersObject(array $a_usr_ids,$a_type)
2644  {
2645  global $rbacsystem;
2646 
2647  $this->checkPermission('write');
2648  if(!count($a_usr_ids))
2649  {
2650  ilUtil::sendFailure($this->lng->txt("crs_no_users_selected"),true);
2651  return false;
2652  }
2653 
2654  $added_users = 0;
2655  foreach($a_usr_ids as $user_id)
2656  {
2657  if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user_id,false))
2658  {
2659  continue;
2660  }
2661  if($this->object->getMembersObject()->isAssigned($user_id))
2662  {
2663  continue;
2664  }
2665  switch($a_type)
2666  {
2668  $this->object->getMembersObject()->add($user_id,IL_CRS_MEMBER);
2669  break;
2671  $this->object->getMembersObject()->add($user_id,IL_CRS_TUTOR);
2672  break;
2674  $this->object->getMembersObject()->add($user_id,IL_CRS_ADMIN);
2675  break;
2676 
2677  }
2678  $this->object->getMembersObject()->sendNotification($this->object->getMembersObject()->NOTIFY_ACCEPT_USER,$user_id);
2679 
2680  include_once './Modules/Forum/classes/class.ilForumNotification.php';
2681  ilForumNotification::checkForumsExistsInsert($this->object->getRefId(), $user_id);
2682 
2683  ++$added_users;
2684  }
2685  if($added_users)
2686  {
2687  ilUtil::sendSuccess($this->lng->txt("crs_users_added"),true);
2688  unset($_SESSION["crs_search_str"]);
2689  unset($_SESSION["crs_search_for"]);
2690  unset($_SESSION['crs_usr_search_result']);
2691 
2692  $this->checkLicenses(true);
2693  $this->ctrl->redirect($this,'members');
2694  }
2695  ilUtil::sendFailure($this->lng->txt("crs_users_already_assigned"),true);
2696  return false;
2697  }
2698 
2700  {
2701  global $rbacsystem;
2702 
2703  $this->checkPermission('write');
2704 
2705  if(!count($_POST["waiting"]))
2706  {
2707  ilUtil::sendFailure($this->lng->txt("crs_no_users_selected"));
2708  $this->membersObject();
2709 
2710  return false;
2711  }
2712  include_once('./Modules/Course/classes/class.ilCourseWaitingList.php');
2713  $waiting_list = new ilCourseWaitingList($this->object->getId());
2714 
2715  $added_users = 0;
2716  foreach($_POST["waiting"] as $user_id)
2717  {
2718  if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user_id,false))
2719  {
2720  continue;
2721  }
2722  if($this->object->getMembersObject()->isAssigned($user_id))
2723  {
2724  continue;
2725  }
2726  $this->object->getMembersObject()->add($user_id,IL_CRS_MEMBER);
2727  $this->object->getMembersObject()->sendNotification($this->object->getMembersObject()->NOTIFY_ACCEPT_USER,$user_id);
2728  $waiting_list->removeFromList($user_id);
2729 
2730  include_once('./Modules/Forum/classes/class.ilForumNotification.php');
2731  ilForumNotification::checkForumsExistsInsert($this->object->getRefId(), $user_id);
2732  ++$added_users;
2733  }
2734 
2735  if($added_users)
2736  {
2737  ilUtil::sendSuccess($this->lng->txt("crs_users_added"));
2738  $this->membersObject();
2739  return true;
2740  }
2741  else
2742  {
2743  ilUtil::sendFailure($this->lng->txt("crs_users_already_assigned"));
2744  $this->membersObject();
2745  return false;
2746  }
2747  }
2748 
2755  public function refuseFromListObject()
2756  {
2757  global $ilUser;
2758 
2759  $this->checkPermission('write');
2760 
2761  if(!count($_POST['waiting']))
2762  {
2763  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
2764  $this->membersObject();
2765  return false;
2766  }
2767 
2768  include_once('./Modules/Course/classes/class.ilCourseWaitingList.php');
2769  $waiting_list = new ilCourseWaitingList($this->object->getId());
2770 
2771  foreach($_POST["waiting"] as $user_id)
2772  {
2773  $waiting_list->removeFromList($user_id);
2774  $this->object->getMembersObject()->sendNotification($this->object->getMembersObject()->NOTIFY_DISMISS_SUBSCRIBER,$user_id);
2775  }
2776 
2777  ilUtil::sendSuccess($this->lng->txt('crs_users_removed_from_list'));
2778  $this->membersObject();
2779  return true;
2780  }
2781 
2782 
2784  {
2785  global $rbacsystem;
2786 
2787  // MINIMUM ACCESS LEVEL = 'administrate'
2788  $this->checkPermission('write');
2789  /*
2790  if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
2791  {
2792  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
2793  }
2794  */
2795  if(!is_array($_SESSION["crs_delete_waiting_list_ids"]))
2796  {
2797  ilUtil::sendFailure($this->lng->txt("crs_no_users_selected"));
2798  $this->membersObject();
2799 
2800  return false;
2801  }
2802 
2803  $this->object->initWaitingList();
2804  foreach($_SESSION['crs_delete_waiting_list_ids'] as $usr_id)
2805  {
2806  $this->object->waiting_list_obj->removeFromList($usr_id);
2807  }
2808  ilUtil::sendSuccess($this->lng->txt('crs_users_removed_from_list'));
2809  $this->membersObject();
2810 
2811  return true;
2812  }
2813 
2814 
2815  public function assignSubscribersObject()
2816  {
2817  global $rbacsystem,$ilErr;
2818 
2819 
2820  $this->checkPermission('write');
2821 
2822  if(!is_array($_POST["subscribers"]))
2823  {
2824  ilUtil::sendFailure($this->lng->txt("crs_no_subscribers_selected"));
2825  $this->membersObject();
2826 
2827  return false;
2828  }
2829 
2830  if(!$this->object->getMembersObject()->assignSubscribers($_POST["subscribers"]))
2831  {
2832  ilUtil::sendFailure($ilErr->getMessage());
2833  $this->membersObject();
2834  return false;
2835  }
2836  else
2837  {
2838  foreach($_POST["subscribers"] as $usr_id)
2839  {
2840  $this->object->getMembersObject()->sendNotification($this->object->getMembersObject()->NOTIFY_ACCEPT_SUBSCRIBER,$usr_id);
2841 
2842  include_once('./Modules/Forum/classes/class.ilForumNotification.php');
2843  ilForumNotification::checkForumsExistsInsert($this->object->getRefId(), $usr_id);
2844  }
2845  }
2846  ilUtil::sendSuccess($this->lng->txt("crs_subscribers_assigned"));
2847  $this->membersObject();
2848 
2849  return true;
2850  }
2851 
2852  function autoFillObject()
2853  {
2854  global $rbacsystem;
2855 
2856  $this->checkPermission('write');
2857 
2858  if($this->object->isSubscriptionMembershipLimited() and $this->object->getSubscriptionMaxMembers() and
2859  $this->object->getSubscriptionMaxMembers() <= $this->object->getMembersObject()->getCountMembers())
2860  {
2861  ilUtil::sendFailure($this->lng->txt("crs_max_members_reached"));
2862  $this->membersObject();
2863 
2864  return false;
2865  }
2866  if($number = $this->object->getMembersObject()->autoFillSubscribers())
2867  {
2868  ilUtil::sendSuccess($this->lng->txt("crs_number_users_added")." ".$number);
2869  }
2870  else
2871  {
2872  ilUtil::sendFailure($this->lng->txt("crs_no_users_added"));
2873  }
2874  $this->membersObject();
2875 
2876  return true;
2877  }
2878 
2879 
2881  {
2882  global $rbacsystem;
2883 
2884  $this->tabs_gui->setTabActive('members');
2885 
2886  // MINIMUM ACCESS LEVEL = 'administrate'
2887  $this->checkPermission('write');
2888  /*
2889  if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
2890  {
2891  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
2892  }
2893  */
2894  if(!is_array($_POST["subscriber"]) or !count($_POST["subscriber"]))
2895  {
2896  ilUtil::sendFailure($this->lng->txt("crs_no_subscribers_selected"));
2897  $this->membersObject();
2898 
2899  return false;
2900  }
2901  ilUtil::sendQuestion($this->lng->txt("crs_delete_subscribers_sure"));
2902 
2903  // SHOW DELETE SCREEN
2904  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_editMembers.html",'Modules/Course');
2905 
2906  // SAVE IDS IN SESSION
2907  $_SESSION["crs_delete_subscriber_ids"] = $_POST["subscriber"];
2908 
2909  $counter = 0;
2910  $f_result = array();
2911 
2912  foreach($_POST["subscriber"] as $member_id)
2913  {
2914  $member_data = $this->object->getMembersObject()->getSubscriberData($member_id);
2915 
2916  // GET USER OBJ
2917  if($tmp_obj = ilObjectFactory::getInstanceByObjId($member_id,false))
2918  {
2919  $f_result[$counter][] = $tmp_obj->getLogin();
2920  $f_result[$counter][] = $tmp_obj->getFirstname();
2921  $f_result[$counter][] = $tmp_obj->getLastname();
2922  $f_result[$counter][] = ilDatePresentation::formatDate(new ilDateTime($member_data['time']),IL_CAL_UNIX);
2923 
2924  unset($tmp_obj);
2925  ++$counter;
2926  }
2927  }
2928  return $this->__showDeleteSubscriberTable($f_result);
2929  }
2930 
2932  {
2933  global $rbacsystem;
2934 
2935  $this->tabs_gui->setTabActive('members');
2936 
2937  // MINIMUM ACCESS LEVEL = 'administrate'
2938  $this->checkPermission('write');
2939  /*
2940  if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
2941  {
2942  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
2943  }
2944  */
2945  if(!is_array($_POST["waiting_list"]) or !count($_POST["waiting_list"]))
2946  {
2947  ilUtil::sendFailure($this->lng->txt("crs_no_users_selected"));
2948  $this->membersObject();
2949 
2950  return false;
2951  }
2952  ilUtil::sendSuccess($this->lng->txt("crs_delete_from_list_sure"));
2953 
2954  // SHOW DELETE SCREEN
2955  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_editMembers.html",'Modules/Course');
2956  $this->object->initWaitingList();
2957 
2958  // SAVE IDS IN SESSION
2959  $_SESSION["crs_delete_waiting_list_ids"] = $_POST["waiting_list"];
2960 
2961  $counter = 0;
2962  $f_result = array();
2963 
2964  foreach($_POST["waiting_list"] as $wait_id)
2965  {
2966  $user_data =& $this->object->waiting_list_obj->getUser($wait_id);
2967  // GET USER OBJ
2968  if($tmp_obj = ilObjectFactory::getInstanceByObjId($wait_id,false))
2969  {
2970  $f_result[$counter][] = $tmp_obj->getLogin();
2971  $f_result[$counter][] = $tmp_obj->getFirstname();
2972  $f_result[$counter][] = $tmp_obj->getLastname();
2973  #$f_result[$counter][] = strftime("%Y-%m-%d %R",$user_data["time"]);
2974  $f_result[$counter][] = ilDatePresentation::formatDate(new ilDateTime($user_data['time'],IL_CAL_UNIX));
2975 
2976  unset($tmp_obj);
2977  ++$counter;
2978  }
2979  }
2980  return $this->__showRemoveFromWaitingListTable($f_result);
2981  }
2982 
2983  public function leaveObject()
2984  {
2985  global $ilUser;
2986 
2987  $this->checkPermission('leave');
2988 
2989  if($this->object->getMembersObject()->isLastAdmin($ilUser->getId()))
2990  {
2991  ilUtil::sendFailure($this->lng->txt('crs_min_one_admin'));
2992  $this->viewObject();
2993  return false;
2994  }
2995 
2996 
2997  $this->tabs_gui->setTabActive('crs_unsubscribe');
2998 
2999  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_unsubscribe_sure.html",'Modules/Course');
3000  ilUtil::sendQuestion($this->lng->txt('crs_unsubscribe_sure'));
3001 
3002  $this->tpl->setVariable("UNSUB_FORMACTION",$this->ctrl->getFormAction($this));
3003  $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt("cancel"));
3004  $this->tpl->setVariable("CMD_SUBMIT",'performUnsubscribe');
3005  $this->tpl->setVariable("TXT_SUBMIT",$this->lng->txt("crs_unsubscribe"));
3006  return true;
3007 
3008  }
3009 
3010 
3012  {
3013  global $rbacsystem,$ilAccess;
3014 
3015  // CHECK ACCESS
3016  $this->checkPermission('leave');
3017  /*
3018  if(!$ilAccess->checkAccess("leave",'', $this->ref_id))
3019  {
3020  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
3021  }
3022  */
3023 
3024  $this->tabs_gui->setTabActive('crs_unsubscribe');
3025  #$this->setSubTabs('members');
3026 
3027 
3028  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_unsubscribe_sure.html",'Modules/Course');
3029  ilUtil::sendQuestion($this->lng->txt('crs_unsubscribe_sure'));
3030 
3031  $this->tpl->setVariable("UNSUB_FORMACTION",$this->ctrl->getFormAction($this));
3032  $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt("cancel"));
3033  $this->tpl->setVariable("CMD_SUBMIT",'performUnsubscribe');
3034  $this->tpl->setVariable("TXT_SUBMIT",$this->lng->txt("crs_unsubscribe"));
3035 
3036  return true;
3037  }
3038 
3040  {
3041  global $rbacsystem,$ilUser;
3042 
3043  // CHECK ACCESS
3044  $this->checkPermission('leave');
3045  $this->object->getMembersObject()->delete($this->ilias->account->getId());
3046  $this->object->getMembersObject()->sendUnsubscribeNotificationToAdmins($this->ilias->account->getId());
3047  $this->object->getMembersObject()->sendNotification($this->object->getMembersObject()->NOTIFY_UNSUBSCRIBE,$ilUser->getId());
3048 
3049  include_once './Modules/Forum/classes/class.ilForumNotification.php';
3050  ilForumNotification::checkForumsExistsDelete($this->ref_id, $ilUser->getId());
3051 
3052  ilUtil::sendSuccess($this->lng->txt('crs_unsubscribed_from_crs'),true);
3053 
3054  ilUtil::redirect("repository.php?ref_id=".$this->tree->getParentId($this->ref_id));
3055  }
3056 
3063  {
3064  global $ilAccess;
3065 
3066  $this->checkPermission('write');
3067 
3068  $this->setSubTabs('members');
3069  $this->tabs_gui->setTabActive('members');
3070  $this->tabs_gui->setSubTabActive('crs_member_administration');
3071 
3072  $participants = array_merge((array) $_POST['admins'],(array) $_POST['tutors'], (array) $_POST['members'], (array) $_POST['roles']);
3073 
3074  if(!$participants)
3075  {
3076  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
3077  $this->membersObject();
3078  return true;
3079  }
3080 
3081  // Check last admin
3082  if(!$this->object->getMemberObject()->checkLastAdmin($participants))
3083  {
3084  ilUtil::sendFailure($this->lng->txt('crs_at_least_one_admin'));
3085  $this->membersObject();
3086 
3087  return false;
3088  }
3089 
3090  // Access check for admin deletion
3091  if(!$ilAccess->checkAccess('edit_permission', '',$this->object->getRefId()))
3092  {
3093  foreach ($participants as $usr_id)
3094  {
3095  $part = ilCourseParticipant::_getInstanceByObjId($this->object->getId(),$usr_id);
3096  if($part->isAdmin())
3097  {
3098  ilUtil::sendFailure($this->lng->txt("msg_no_perm_perm"));
3099  $this->membersObject();
3100  return false;
3101  }
3102  }
3103  }
3104 
3105 
3106  include_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
3107  $confirm = new ilConfirmationGUI();
3108  $confirm->setFormAction($this->ctrl->getFormAction($this,'deleteMembers'));
3109  $confirm->setHeaderText($this->lng->txt('crs_header_delete_members'));
3110  $confirm->setConfirm($this->lng->txt('confirm'),'removeMembers');
3111  $confirm->setCancel($this->lng->txt('cancel'),'members');
3112 
3113  foreach($participants as $usr_id)
3114  {
3115  $name = ilObjUser::_lookupName($usr_id);
3116 
3117  $confirm->addItem('participants[]',
3118  $name['user_id'],
3119  $name['lastname'].', '.$name['firstname'].' ['.$name['login'].']',
3120  ilUtil::getImagePath('icon_usr.gif'));
3121  }
3122 
3123  $this->tpl->setContent($confirm->getHTML());
3124 
3125  }
3126 
3128  {
3129  global $rbacreview, $rbacsystem;
3130 
3131  $this->checkPermission('write');
3132 
3133  if(!is_array($_POST["participants"]) or !count($_POST["participants"]))
3134  {
3135  ilUtil::sendFailure($this->lng->txt("crs_no_member_selected"));
3136  $this->membersObject();
3137 
3138  return false;
3139  }
3140 
3141  // If the user doesn't have the edit_permission, he may not remove
3142  // members who have the course administrator role
3143  if (! $rbacsystem->checkAccess('edit_permission', $this->object->getRefId()))
3144  {
3145  // Determine the role id of the course administrator role.
3146  $courseAdminRoleId = null;
3147  foreach ($this->object->getLocalCourseRoles(false) as $title => $role_id)
3148  {
3149  if (substr($title, 0, 12) == 'il_crs_admin')
3150  {
3151  $courseAdminRoleId = $role_id;
3152  }
3153  }
3154 
3155  foreach ($_POST['participants'] as $usr_id)
3156  {
3157  if ($rbacreview->isAssigned($usr_id, $courseAdminRoleId))
3158  {
3159  ilUtil::sendFailure($this->lng->txt("msg_no_perm_perm"));
3160  $this->membersObject();
3161  return false;
3162  }
3163  }
3164  }
3165 
3166  if(!$this->object->getMembersObject()->deleteParticipants($_POST["participants"]))
3167  {
3168  ilUtil::sendFailure($this->object->getMessage());
3169  $this->membersObject();
3170 
3171  return false;
3172  }
3173  else
3174  {
3175  include_once './Modules/Forum/classes/class.ilForumNotification.php';
3176 
3177  // SEND NOTIFICATION
3178  foreach($_POST["participants"] as $usr_id)
3179  {
3180  $this->object->getMembersObject()->sendNotification($this->object->getMembersObject()->NOTIFY_DISMISS_MEMBER,$usr_id);
3181  ilForumNotification::checkForumsExistsDelete($this->object->getRefId(), $usr_id);
3182  }
3183  }
3184  ilUtil::sendSuccess($this->lng->txt("crs_members_deleted"));
3185  $this->membersObject();
3186 
3187  return true;
3188  }
3189 
3191  {
3192  global $rbacsystem;
3193 
3194  $this->checkPermission('write');
3195 
3196  if(!$_POST['subscribers'])
3197  {
3198  ilUtil::sendFailure($this->lng->txt("crs_no_subscribers_selected"));
3199  $this->membersObject();
3200  return false;
3201  }
3202 
3203  if(!$this->object->getMembersObject()->deleteSubscribers($_POST["subscribers"]))
3204  {
3205  ilUtil::sendFailure($this->object->getMessage());
3206  $this->membersObject();
3207  return false;
3208  }
3209  else
3210  {
3211  foreach($_POST['subscribers'] as $usr_id)
3212  {
3213  $this->object->getMembersObject()->sendNotification($this->object->getMembersObject()->NOTIFY_DISMISS_SUBSCRIBER,$usr_id);
3214  }
3215  }
3216 
3217  ilUtil::sendSuccess($this->lng->txt("crs_subscribers_deleted"));
3218  $this->membersObject();
3219  return true;
3220  }
3221 
3225  function getTabs(&$tabs_gui)
3226  {
3227  global $rbacsystem,$ilAccess,$ilUser, $lng;
3228 
3229  $this->ctrl->setParameter($this,"ref_id",$this->ref_id);
3230 
3231  if($ilAccess->checkAccess('read','',$this->ref_id))
3232  {
3233  $tabs_gui->addTab('view_content', $lng->txt("content"),
3234  $this->ctrl->getLinkTarget($this,''));
3235  }
3236 
3237  if ($ilAccess->checkAccess('visible','',$this->ref_id))
3238  {
3239  //$next_class = $this->ctrl->getNextClass($this);
3240 
3241  // this is not nice. tabs should be displayed in ilcoursegui
3242  // not via ilrepositorygui, then next_class == ilinfoscreengui
3243  // could be checked
3244  $force_active = (strtolower($_GET["cmdClass"]) == "ilinfoscreengui"
3245  || strtolower($_GET["cmdClass"]) == "ilnotegui")
3246  ? true
3247  : false;
3248  $tabs_gui->addTarget("info_short",
3249  $this->ctrl->getLinkTargetByClass(
3250  array("ilobjcoursegui", "ilinfoscreengui"), "showSummary"),
3251  "infoScreen",
3252  "", "", $force_active);
3253  }
3254  if ($ilAccess->checkAccess('write','',$this->ref_id))
3255  {
3256  $force_active = (strtolower($_GET["cmdClass"]) == "ilconditionhandlerinterface"
3257  && $_GET["item_id"] == "")
3258  ? true
3259  : false;
3260  $tabs_gui->addTarget("settings",
3261  $this->ctrl->getLinkTarget($this, "edit"),
3262  array("edit", "editMapSettings", "editCourseIcons", "listStructure"), "", "", $force_active);
3263  }
3264 
3265 
3266  $is_participant = ilCourseParticipants::_isParticipant($this->ref_id, $ilUser->getId());
3267 
3268  // member list
3269  if($ilAccess->checkAccess('write','',$this->ref_id))
3270  {
3271  $tabs_gui->addTarget("members",
3272  $this->ctrl->getLinkTarget($this, "members"),
3273  "members",
3274  get_class($this));
3275  }
3276  elseif ($this->object->getShowMembers() == $this->object->SHOW_MEMBERS_ENABLED &&
3277  $is_participant)
3278  {
3279  $tabs_gui->addTarget("members",
3280  $this->ctrl->getLinkTarget($this, "membersGallery"),
3281  "members",
3282  get_class($this));
3283  }
3284 
3285  // learning progress
3286  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
3287  if(ilLearningProgressAccess::checkAccess($this->object->getRefId(), $is_participant))
3288  {
3289  $tabs_gui->addTarget('learning_progress',
3290  $this->ctrl->getLinkTargetByClass(array('ilobjcoursegui','illearningprogressgui'),''),
3291  '',
3292  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
3293  }
3294 
3295 
3296  // learning objectives
3297  if($ilAccess->checkAccess('write','',$this->ref_id))
3298  {
3299  include_once('./Modules/Course/classes/class.ilCourseObjective.php');
3300  if($this->object->getViewMode() == IL_CRS_VIEW_OBJECTIVE or ilCourseObjective::_getCountObjectives($this->object->getId()))
3301  {
3302  $force_active = (strtolower($_GET["cmdClass"]) == "ilcourseobjectivesgui")
3303  ? true
3304  : false;
3305  $tabs_gui->addTarget("crs_objectives",
3306  $this->ctrl->getLinkTarget($this,"listObjectives"),
3307  "listObjectives",
3308  get_class($this), "", $force_active);
3309  }
3310  }
3311 
3312  // license overview
3313  include_once("Services/License/classes/class.ilLicenseAccess.php");
3314  if ($ilAccess->checkAccess('edit_permission', '', $this->ref_id)
3316  {
3317  $tabs_gui->addTarget("licenses",
3318  $this->ctrl->getLinkTargetByClass('illicenseoverviewgui', ''),
3319  "", "illicenseoverviewgui");
3320  }
3321 
3322  // lom meta data
3323  if ($ilAccess->checkAccess('write','',$this->ref_id))
3324  {
3325  $tabs_gui->addTarget("meta_data",
3326  $this->ctrl->getLinkTargetByClass(array('ilobjcoursegui','ilmdeditorgui'),'listSection'),
3327  "",
3328  "ilmdeditorgui");
3329  }
3330 
3331  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
3332  {
3333  $tabs_gui->addTarget(
3334  'export',
3335  $this->ctrl->getLinkTargetByClass('ilexportgui',''),
3336  'export',
3337  'ilexportgui'
3338  );
3339  }
3340 
3341  if ($ilAccess->checkAccess('edit_permission','',$this->ref_id))
3342  {
3343  $tabs_gui->addTarget("perm_settings",
3344  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
3345  array("perm","info","owner"), 'ilpermissiongui');
3346  }
3347 
3348  if ($this->ctrl->getTargetScript() == "adm_object.php")
3349  {
3350  $tabs_gui->addTarget("show_owner",
3351  $this->ctrl->getLinkTarget($this, "owner"), "owner", get_class($this));
3352 
3353  if ($this->tree->getSavedNodeData($this->ref_id))
3354  {
3355  $tabs_gui->addTarget("trash",
3356  $this->ctrl->getLinkTarget($this, "trash"), "trash", get_class($this));
3357  }
3358  }
3359  // Join/Leave
3360  if($ilAccess->checkAccess('join','',$this->ref_id)
3361  and !$this->object->getMemberObject()->isAssigned())
3362  {
3363  include_once './Modules/Course/classes/class.ilCourseWaitingList.php';
3364  if(ilCourseWaitingList::_isOnList($ilUser->getId(), $this->object->getId()))
3365  {
3366  $tabs_gui->addTab(
3367  'leave',
3368  $this->lng->txt('membership_leave'),
3369  $this->ctrl->getLinkTargetByClass('ilcourseregistrationgui','show','')
3370  );
3371 
3372  }
3373  else
3374  {
3375 
3376  $tabs_gui->addTarget("join",
3377  $this->ctrl->getLinkTargetByClass('ilcourseregistrationgui', "show"),
3378  'show',
3379  "");
3380  }
3381  }
3382  if($ilAccess->checkAccess('leave','',$this->object->getRefId())
3383  and $this->object->getMemberObject()->isMember())
3384  {
3385  $tabs_gui->addTarget("crs_unsubscribe",
3386  $this->ctrl->getLinkTarget($this, "unsubscribe"),
3387  'leave',
3388  "");
3389 
3390  }
3391  }
3392 
3393  function fetchPrintSubscriberData($a_members)
3394  {
3395  foreach($a_members as $member_id)
3396  {
3397 
3398  $member_data = $this->object->getMembersObject()->getSubscriberData($member_id);
3399 
3400  if($tmp_obj = ilObjectFactory::getInstanceByObjId($member_id,false))
3401  {
3402  $print_member[$member_id]['login'] = $tmp_obj->getLogin();
3403  $print_member[$member_id]['name'] = $tmp_obj->getLastname().', '.$tmp_obj->getFirstname();
3404  $print_member[$member_id]['time'] = ilDatePresentation::formatDate(new ilDateTime($member_data['time'],IL_CAL_UNIX));
3405  }
3406  }
3407  switch($_SESSION['crs_print_sort'])
3408  {
3409  case 'lastname':
3410  return ilUtil::sortArray($print_member,'name',$_SESSION['crs_print_order']);
3411 
3412  case 'login':
3413  return ilUtil::sortArray($print_member,'login',$_SESSION['crs_print_order']);
3414 
3415  case 'sub_time':
3416  return ilUtil::sortArray($print_member,'time',$_SESSION['crs_print_order']);
3417 
3418  default:
3419  return ilUtil::sortArray($print_member,'name',$_SESSION['crs_print_order']);
3420  }
3421  }
3422 
3423  function fetchPrintMemberData($a_members)
3424  {
3425  global $ilAccess,$lng;
3426 
3427  $lng->loadLanguageModule('trac');
3428 
3429  #$is_admin = (bool) $ilAccess->checkAccess("write",'',$this->object->getRefId());
3430  $is_admin = true;
3431 
3432  include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
3433  $privacy = ilPrivacySettings::_getInstance();
3434 
3435  if($privacy->enabledCourseAccessTimes())
3436  {
3437  include_once('./Services/Tracking/classes/class.ilLearningProgress.php');
3438  $progress = ilLearningProgress::_lookupProgressByObjId($this->object->getId());
3439  }
3440 
3441  if($this->show_tracking)
3442  {
3443  include_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
3444  $completed = ilLPStatusWrapper::_getCompleted($this->object->getId());
3445  $in_progress = ilLPStatusWrapper::_getInProgress($this->object->getId());
3446  $not_attempted = ilLPStatusWrapper::_getNotAttempted($this->object->getId());
3447  $failed = ilLPStatusWrapper::_getFailed($this->object->getId());
3448  }
3449 
3450  foreach($a_members as $member_id)
3451  {
3452  // GET USER OBJ
3453  if($tmp_obj = ilObjectFactory::getInstanceByObjId($member_id,false))
3454  {
3455  $print_member[$member_id]['login'] = $tmp_obj->getLogin();
3456  $print_member[$member_id]['name'] = $tmp_obj->getLastname().', '.$tmp_obj->getFirstname();
3457 
3458  if($this->object->getMembersObject()->isAdmin($member_id))
3459  {
3460  $print_member[$member_id]['role'] = $this->lng->txt("il_crs_admin");
3461  }
3462  elseif($this->object->getMembersObject()->isTutor($member_id))
3463  {
3464  $print_member[$member_id]['role'] = $this->lng->txt("il_crs_tutor");
3465  }
3466  elseif($this->object->getMembersObject()->isMember($member_id))
3467  {
3468  $print_member[$member_id]['role'] = $this->lng->txt("il_crs_member");
3469  }
3470  if($this->object->getMembersObject()->isAdmin($member_id) or $this->object->getMembersObject()->isTutor($member_id))
3471  {
3472  if($this->object->getMembersObject()->isNotificationEnabled($member_id))
3473  {
3474  $print_member[$member_id]['status'] = $this->lng->txt("crs_notify");
3475  }
3476  else
3477  {
3478  $print_member[$member_id]['status'] = $this->lng->txt("crs_no_notify");
3479  }
3480  }
3481  else
3482  {
3483  if($this->object->getMembersObject()->isBlocked($member_id))
3484  {
3485  $print_member[$member_id]['status'] = $this->lng->txt("crs_blocked");
3486  }
3487  else
3488  {
3489  $print_member[$member_id]['status'] = $this->lng->txt("crs_unblocked");
3490  }
3491  }
3492 
3493  if($is_admin)
3494  {
3495  $print_member[$member_id]['passed'] = $this->object->getMembersObject()->hasPassed($member_id) ?
3496  $this->lng->txt('crs_member_passed') :
3497  $this->lng->txt('crs_member_not_passed');
3498 
3499  }
3500  if($privacy->enabledCourseAccessTimes())
3501  {
3502  if(isset($progress[$member_id]['ts']) and $progress[$member_id]['ts'])
3503  {
3505  $print_member[$member_id]['access'] = ilDatePresentation::formatDate(new ilDateTime($progress[$member_id]['ts'],IL_CAL_UNIX));
3507  }
3508  else
3509  {
3510  $print_member[$member_id]['access'] = $this->lng->txt('no_date');
3511  }
3512  }
3513  if($this->show_tracking)
3514  {
3515  if(in_array($member_id,$completed))
3516  {
3517  $print_member[$member_id]['progress'] = $this->lng->txt(LP_STATUS_COMPLETED);
3518  }
3519  elseif(in_array($member_id,$in_progress))
3520  {
3521  $print_member[$member_id]['progress'] = $this->lng->txt(LP_STATUS_IN_PROGRESS);
3522  }
3523  elseif(in_array($member_id,$failed))
3524  {
3525  $print_member[$member_id]['progress'] = $this->lng->txt(LP_STATUS_FAILED);
3526  }
3527  else
3528  {
3529  $print_member[$member_id]['progress'] = $this->lng->txt(LP_STATUS_NOT_ATTEMPTED);
3530  }
3531  }
3532 
3533  }
3534  }
3535 
3536  switch($_SESSION['crs_print_sort'])
3537  {
3538  case 'progress':
3539  return ilUtil::sortArray($print_member,'progress',$_SESSION['crs_print_order']);
3540 
3541  case 'access_time':
3542  return ilUtil::sortArray($print_member,'access',$_SESSION['crs_print_order']);
3543 
3544  case 'lastname':
3545  return ilUtil::sortArray($print_member,'name',$_SESSION['crs_print_order']);
3546 
3547  case 'login':
3548  return ilUtil::sortArray($print_member,'login',$_SESSION['crs_print_order']);
3549 
3550  case 'passed':
3551  return ilUtil::sortArray($print_member,'passed',$_SESSION['crs_print_order']);
3552 
3553  case 'blocked':
3554  case 'notification':
3555  return ilUtil::sortArray($print_member,'status',$_SESSION['crs_print_order']);
3556 
3557  default:
3558  return ilUtil::sortArray($print_member,'name',$_SESSION['crs_print_order']);
3559  }
3560  }
3561 
3562 
3564  {
3565  global $rbacsystem;
3566 
3567  $this->checkPermission('write');
3568 
3569  $is_admin = true;
3570  $tpl = new ilTemplate('tpl.crs_members_print.html',true,true,'Modules/Course');
3571 
3572  include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
3573  $privacy = ilPrivacySettings::_getInstance();
3574  if($privacy->enabledCourseAccessTimes())
3575  {
3576  include_once('./Services/Tracking/classes/class.ilLearningProgress.php');
3577  $progress = ilLearningProgress::_lookupProgressByObjId($this->object->getId());
3578  }
3579 
3580  include_once './Services/Tracking/classes/class.ilObjUserTracking.php';
3581  include_once('./Services/Tracking/classes/class.ilLPObjSettings.php');
3582  $this->show_tracking = (ilObjUserTracking::_enabledLearningProgress() and
3584  ilLPObjSettings::_lookupMode($this->object->getId()) != LP_MODE_DEACTIVATED);
3585 
3586 
3587  // MEMBERS
3588  if(count($members = $this->object->getMembersObject()->getParticipants()))
3589  {
3590  $members = $this->fetchPrintMemberData($members);
3591 
3592  foreach($members as $member_data)
3593  {
3594  if($this->show_tracking)
3595  {
3596  $tpl->setCurrentBlock('progress_row');
3597  $tpl->setVariable('VAL_PROGRESS',$member_data['progress']);
3598  $tpl->parseCurrentBlock();
3599  }
3600 
3601  if($privacy->enabledCourseAccessTimes())
3602  {
3603  $tpl->setCurrentBlock('access_row');
3604  $tpl->setVariable('VAL_ACCESS',$member_data['access']);
3605  $tpl->parseCurrentBlock();
3606  }
3607  $tpl->setCurrentBlock("members_row");
3608  $tpl->setVariable("LOGIN",$member_data['login']);
3609  $tpl->setVariable("NAME",$member_data['name']);
3610  $tpl->setVariable("ROLE",$member_data['role']);
3611  $tpl->setVariable("STATUS",$member_data['status']);
3612  $tpl->setVariable("PASSED",$member_data['passed']);
3613 
3614  if($is_admin)
3615  {
3616  $tpl->setVariable("STATUS",$member_data['status']);
3617  $tpl->setVariable("PASSED",$member_data['passed']);
3618  }
3619  $tpl->parseCurrentBlock();
3620  }
3621 
3622  $tpl->setCurrentBlock("members");
3623  $tpl->setVariable("MEMBERS_IMG_SOURCE",ilUtil::getImagePath('icon_usr.gif'));
3624  $tpl->setVariable("MEMBERS_IMG_ALT",$this->lng->txt('crs_header_members'));
3625  $tpl->setVariable("MEMBERS_TABLE_HEADER",$this->lng->txt('crs_members_table'));
3626  $tpl->setVariable("TXT_LOGIN",$this->lng->txt('username'));
3627  $tpl->setVariable("TXT_NAME",$this->lng->txt('name'));
3628  $tpl->setVariable("TXT_ROLE",$this->lng->txt('crs_role'));
3629 
3630  if($this->show_tracking)
3631  {
3632  $tpl->setCurrentBlock('progress');
3633  $tpl->setVariable('TXT_PROGRESS',$this->lng->txt('learning_progress'));
3634  $tpl->parseCurrentBlock();
3635  }
3636 
3637  if($privacy->enabledCourseAccessTimes())
3638  {
3639  $tpl->setCurrentBlock('access');
3640  $tpl->setVariable('TXT_ACCESS',$this->lng->txt('last_access'));
3641  $tpl->parseCurrentBlock();
3642  }
3643 
3644 
3645  if($is_admin)
3646  {
3647  $tpl->setVariable("TXT_STATUS",$this->lng->txt('crs_status'));
3648  $tpl->setVariable("TXT_PASSED",$this->lng->txt('crs_passed'));
3649  }
3650 
3651  $tpl->parseCurrentBlock();
3652 
3653  }
3654  // SUBSCRIBERS
3655  if(count($members = $this->object->getMembersObject()->getSubscribers()))
3656  {
3657  $members = $this->fetchPrintSubscriberData($members);
3658  foreach($members as $member_data)
3659  {
3660  $tpl->setCurrentBlock("subscribers_row");
3661  $tpl->setVariable("SLOGIN",$member_data['login']);
3662  $tpl->setVariable("SNAME",$member_data['name']);
3663  $tpl->setVariable("STIME",$member_data["time"]);
3664  $tpl->parseCurrentBlock();
3665  }
3666 
3667  $tpl->setCurrentBlock("subscribers");
3668  $tpl->setVariable("SUBSCRIBERS_IMG_SOURCE",ilUtil::getImagePath('icon_usr.gif'));
3669  $tpl->setVariable("SUBSCRIBERS_IMG_ALT",$this->lng->txt('crs_subscribers'));
3670  $tpl->setVariable("SUBSCRIBERS_TABLE_HEADER",$this->lng->txt('crs_subscribers'));
3671  $tpl->setVariable("TXT_SLOGIN",$this->lng->txt('username'));
3672  $tpl->setVariable("TXT_SNAME",$this->lng->txt('name'));
3673  $tpl->setVariable("TXT_STIME",$this->lng->txt('crs_time'));
3674  $tpl->parseCurrentBlock();
3675 
3676  }
3677 
3678  $tpl->setVariable("TITLE",$this->lng->txt('crs_members_print_title'));
3679  $tpl->setVariable("CSS_PATH",ilUtil::getStyleSheetLocation());
3680 
3681  $headline = $this->lng->txt('obj_crs').': '.$this->object->getTitle().
3682  ' -> '.$this->lng->txt('crs_header_members').' ('.ilFormat::formatUnixTime(time(),true).')';
3683 
3684  $tpl->setVariable("HEADLINE",$headline);
3685 
3686  $tpl->show();
3687  exit;
3688  }
3689 
3690  /*
3691  * @author Arturo Gonzalez <arturogf@gmail.com>
3692  * @access public
3693  */
3695  {
3696 
3697  global $rbacsystem, $ilErr, $ilAccess, $ilUser;
3698 
3699  $is_admin = (bool) $ilAccess->checkAccess("write", "", $this->object->getRefId());
3700 
3701  if (!$is_admin &&
3702  $this->object->getShowMembers() == $this->object->SHOW_MEMBERS_DISABLED)
3703  {
3704  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"),$ilErr->MESSAGE);
3705  }
3706 
3707 
3708  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.crs_members_gallery.html','Modules/Course');
3709 
3710  $this->setSubTabs('members');
3711  $this->tabs_gui->setTabActive('members');
3712  $this->tabs_gui->setSubTabActive('crs_members_gallery');
3713 
3714  // MEMBERS
3715  if(count($members = $this->object->getMembersObject()->getParticipants()))
3716  {
3717  $ordered_members = array();
3718 
3719  foreach($members as $member_id)
3720  {
3721  if(!($usr_obj = ilObjectFactory::getInstanceByObjId($member_id,false)))
3722  {
3723  continue;
3724  }
3725 
3726  // please do not use strtoupper on first/last name for output
3727  // this messes up with some unicode characters, i guess
3728  // depending on php verion, alex
3729  array_push($ordered_members,array("id" => $member_id,
3730  "login" => $usr_obj->getLogin(),
3731  "lastname" => $usr_obj->getLastName(),
3732  "firstname" => $usr_obj->getFirstName(),
3733  "sortlastname" => strtoupper($usr_obj->getLastName()).strtoupper($usr_obj->getFirstName()),
3734  "usr_obj" => $usr_obj));
3735  }
3736 
3737  $ordered_members=ilUtil::sortArray($ordered_members,"sortlastname","asc");
3738 
3739  foreach($ordered_members as $member)
3740  {
3741  $usr_obj = $member["usr_obj"];
3742 
3743  if(!$usr_obj->getActive())
3744  {
3745  continue;
3746  }
3747 
3748  $public_profile = in_array($usr_obj->getPref("public_profile"), array("y", "g")) ? "y" : "";
3749 
3750  // SET LINK TARGET FOR USER PROFILE
3751  $this->ctrl->setParameterByClass("ilpublicuserprofilegui", "user", $member["id"]);
3752  $profile_target = $this->ctrl->getLinkTargetByClass("ilpublicuserprofilegui","getHTML");
3753 
3754  // GET USER IMAGE
3755  $file = $usr_obj->getPersonalPicturePath("xsmall");
3756 
3757  if($this->object->getMembersObject()->isAdmin($member["id"]) or $this->object->getMembersObject()->isTutor($member["id"]))
3758  {
3759  if ($public_profile == "y")
3760  {
3761  $this->tpl->setCurrentBlock("tutor_linked");
3762  $this->tpl->setVariable("LINK_PROFILE", $profile_target);
3763  $this->tpl->setVariable("SRC_USR_IMAGE", $file);
3764  $this->tpl->parseCurrentBlock();
3765  }
3766  else
3767  {
3768  $this->tpl->setCurrentBlock("tutor_not_linked");
3769  $this->tpl->setVariable("SRC_USR_IMAGE", $file);
3770  $this->tpl->parseCurrentBlock();
3771  }
3772  $this->tpl->setCurrentBlock("tutor");
3773  }
3774  else
3775  {
3776  if ($public_profile == "y")
3777  {
3778  $this->tpl->setCurrentBlock("member_linked");
3779  $this->tpl->setVariable("LINK_PROFILE", $profile_target);
3780  $this->tpl->setVariable("SRC_USR_IMAGE", $file);
3781  $this->tpl->parseCurrentBlock();
3782  }
3783  else
3784  {
3785  $this->tpl->setCurrentBlock("member_not_linked");
3786  $this->tpl->setVariable("SRC_USR_IMAGE", $file);
3787  $this->tpl->parseCurrentBlock();
3788  }
3789  $this->tpl->setCurrentBlock("member");
3790  }
3791 
3792  // do not show name, if public profile is not activated
3793  if ($public_profile == "y")
3794  {
3795  $this->tpl->setVariable("FIRSTNAME", $member["firstname"]);
3796  $this->tpl->setVariable("LASTNAME", $member["lastname"]);
3797  }
3798  $this->tpl->setVariable("LOGIN", $member["login"]);
3799  $this->tpl->parseCurrentBlock();
3800 
3801  }
3802  $this->tpl->setCurrentBlock("members");
3803  $this->tpl->setVariable("MEMBERS_TABLE_HEADER",$this->lng->txt('crs_members_title'));
3804  $this->tpl->parseCurrentBlock();
3805 
3806  }
3807 
3808  $this->tpl->setVariable("TITLE",$this->lng->txt('crs_members_print_title'));
3809  $this->tpl->setVariable("CSS_PATH",ilUtil::getStyleSheetLocation());
3810 
3811  $headline = $this->object->getTitle()."<br/>".$this->object->getDescription();
3812 
3813  $this->tpl->setVariable("HEADLINE",$headline);
3814 
3815  $this->tpl->show();
3816  exit;
3817  }
3818 
3819 
3820  function __initTableGUI()
3821  {
3822  include_once "./Services/Table/classes/class.ilTableGUI.php";
3823 
3824  return new ilTableGUI(0,false);
3825  }
3826 
3827 
3828  function __setTableGUIBasicData(&$tbl,&$result_set,$from = "")
3829  {
3830  switch($from)
3831  {
3832  case "members":
3833  $offset = $_GET["update_members"] ? $_GET["offset"] : 0;
3834  $order = $_GET["update_members"] ? $_GET["sort_by"] : 'login';
3835  $direction = $_GET["update_members"] ? $_GET["sort_order"] : '';
3836  break;
3837 
3838  case "subscribers":
3839  $offset = $_GET["update_subscribers"] ? $_GET["offset"] : 0;
3840  $order = $_GET["update_subscribers"] ? $_GET["sort_by"] : 'sub_time';
3841  $direction = $_GET["update_subscribers"] ? $_GET["sort_order"] : '';
3842  break;
3843 
3844  case "group":
3845  $offset = $_GET["offset"];
3846  $order = $_GET["sort_by"] ? $_GET["sort_by"] : "title";
3847  $direction = $_GET["sort_order"];
3848  break;
3849 
3850  case "role":
3851  $offset = $_GET["offset"];
3852  $order = $_GET["sort_by"] ? $_GET["sort_by"] : "title";
3853  $direction = $_GET["sort_order"];
3854  break;
3855 
3856  default:
3857  $offset = $_GET["offset"];
3858  // init sort_by (unfortunatly sort_by is preset with 'title'
3859  if ($_GET["sort_by"] == "title" or empty($_GET["sort_by"]))
3860  {
3861  $_GET["sort_by"] = "login";
3862  }
3863  $order = $_GET["sort_by"];
3864  $direction = $_GET["sort_order"];
3865  break;
3866  }
3867 
3868  $tbl->setOrderColumn($order);
3869  $tbl->setOrderDirection($direction);
3870  $tbl->setOffset($offset);
3871  $tbl->setLimit($_GET["limit"]);
3872  $tbl->setMaxCount(count($result_set));
3873  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
3874  $tbl->setData($result_set);
3875  }
3876 
3877 
3878  function __showRemoveFromWaitingListTable($a_result_set)
3879  {
3880  $tbl =& $this->__initTableGUI();
3881  $tpl =& $tbl->getTemplateObject();
3882 
3883  $tpl->setCurrentBlock("tbl_form_header");
3884  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
3885  $tpl->parseCurrentBlock();
3886  $tpl->setCurrentBlock("tbl_action_btn");
3887  $tpl->setVariable("BTN_NAME","cancelMember");
3888  $tpl->setVariable("BTN_VALUE",$this->lng->txt("cancel"));
3889  $tpl->parseCurrentBlock();
3890  $tpl->setCurrentBlock("tbl_action_btn");
3891  $tpl->setVariable("BTN_NAME","performRemoveFromWaitingList");
3892  $tpl->setVariable("BTN_VALUE",$this->lng->txt("delete"));
3893  $tpl->parseCurrentBlock();
3894  $tpl->setCurrentBlock("tbl_action_row");
3895  $tpl->setVariable("COLUMN_COUNTS",4);
3896  $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
3897  $tpl->parseCurrentBlock();
3898 
3899  $tbl->setTitle($this->lng->txt("crs_header_remove_from_waiting_list"),"icon_usr_b.gif",
3900  $this->lng->txt("crs_header_remove_from_waiting_list"));
3901  $tbl->setHeaderNames(array($this->lng->txt("username"),
3902  $this->lng->txt("firstname"),
3903  $this->lng->txt("lastname"),
3904  $this->lng->txt("crs_time")));
3905  $tbl->setHeaderVars(array("login",
3906  "firstname",
3907  "lastname",
3908  "sub_time"),
3909  array("ref_id" => $this->object->getRefId(),
3910  "cmd" => "members",
3911  "cmdClass" => "ilobjcoursegui",
3912  "cmdNode" => $_GET["cmdNode"]));
3913 
3914  $tbl->setColumnWidth(array("25%","25%","25%","25%"));
3915 
3916  $this->__setTableGUIBasicData($tbl,$a_result_set);
3917  $tbl->render();
3918 
3919  $this->tpl->setVariable("EDIT_MEMBER_TABLE",$tbl->tpl->get());
3920 
3921  return true;
3922  }
3923 
3924  function __showDeleteSubscriberTable($a_result_set)
3925  {
3926  $tbl =& $this->__initTableGUI();
3927  $tpl =& $tbl->getTemplateObject();
3928 
3929  $tpl->setCurrentBlock("tbl_form_header");
3930  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
3931  $tpl->parseCurrentBlock();
3932  $tpl->setCurrentBlock("tbl_action_btn");
3933  $tpl->setVariable("BTN_NAME","removeSubscribers");
3934  $tpl->setVariable("BTN_VALUE",$this->lng->txt("delete"));
3935  $tpl->parseCurrentBlock();
3936  $tpl->setCurrentBlock("tbl_action_btn");
3937  $tpl->setVariable("BTN_NAME","cancelMember");
3938  $tpl->setVariable("BTN_VALUE",$this->lng->txt("cancel"));
3939  $tpl->parseCurrentBlock();
3940  $tpl->setCurrentBlock("tbl_action_row");
3941  $tpl->setVariable("COLUMN_COUNTS",4);
3942  $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
3943  $tpl->parseCurrentBlock();
3944 
3945  $tbl->setTitle($this->lng->txt("crs_header_delete_subscribers"),"icon_usr_b.gif",$this->lng->txt("crs_header_delete_members"));
3946  $tbl->setHeaderNames(array($this->lng->txt("username"),
3947  $this->lng->txt("firstname"),
3948  $this->lng->txt("lastname"),
3949  $this->lng->txt("crs_time")));
3950  $tbl->setHeaderVars(array("login",
3951  "firstname",
3952  "lastname",
3953  "sub_time"),
3954  array("ref_id" => $this->object->getRefId(),
3955  "cmd" => "members",
3956  "cmdClass" => "ilobjcoursegui",
3957  "cmdNode" => $_GET["cmdNode"]));
3958 
3959  $tbl->setColumnWidth(array("25%","25%","25%","25%"));
3960 
3961  $this->__setTableGUIBasicData($tbl,$a_result_set);
3962  $tbl->render();
3963 
3964  $this->tpl->setVariable("EDIT_MEMBER_TABLE",$tbl->tpl->get());
3965 
3966  return true;
3967  }
3968 
3969 
3970 
3971  function __showWaitingListTable($a_result_set,$a_waiting_list_ids = NULL)
3972  {
3973  $actions = array("addFromWaitingList" => $this->lng->txt("crs_add_subscribers"),
3974  "removeFromWaitingList" => $this->lng->txt("crs_delete_from_waiting_list"));
3975 
3976  $tbl =& $this->__initTableGUI();
3977  $tpl =& $tbl->getTemplateObject();
3978 
3979  $tbl->enable('select_all');
3980  $tbl->setFormName("wait_form");
3981  $tbl->setSelectAllCheckbox("waiting_list");
3982 
3983 
3984  // SET FOOTER BUTTONS
3985  $tpl->setCurrentBlock("tbl_action_row");
3986 
3987  $tpl->setVariable("COLUMN_COUNTS",5);
3988 
3989  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
3990 
3991  $tpl->setCurrentBlock("tbl_action_select");
3992  $tpl->setVariable("SELECT_ACTION",ilUtil::formSelect(1,"action",$actions,false,true));
3993  $tpl->setVariable("BTN_NAME","gateway");
3994  $tpl->setVariable("BTN_VALUE",$this->lng->txt("execute"));
3995  $tpl->parseCurrentBlock();
3996 
3997  $tpl->setCurrentBlock("tbl_action_row");
3998  $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
3999  $tpl->parseCurrentBlock();
4000 
4001 
4002  $tbl->setTitle($this->lng->txt("crs_waiting_list"),"icon_usr.gif",$this->lng->txt("crs_waiting_list"));
4003  $tbl->setHeaderNames(array('',
4004  $this->lng->txt("name"),
4005  $this->lng->txt("login"),
4006  $this->lng->txt("crs_time")));
4007  $tbl->setHeaderVars(array("",
4008  "name",
4009  "login",
4010  "sub_time"),
4011  array("ref_id" => $this->object->getRefId(),
4012  "cmd" => "members",
4013  "update_subscribers" => 1,
4014  "cmdClass" => "ilobjcoursegui",
4015  "cmdNode" => $_GET["cmdNode"]));
4016  $tbl->setColumnWidth(array('1%'));
4017 
4018  $this->__setTableGUIBasicData($tbl,$a_result_set,"subscribers");
4019  $tbl->render();
4020 
4021  $this->tpl->setCurrentBlock('sub_wait_table');
4022  $this->tpl->setVariable('SUB_WAIT_NAME','wait_form');
4023  $this->tpl->setVariable('SUB_WAIT_FORMACTION',$this->ctrl->getFormAction($this));
4024  $this->tpl->setVariable("SUB_WAIT_TABLE_CONTENT",$tbl->tpl->get());
4025  $this->tpl->parseCurrentBlock();
4026 
4027  return true;
4028  }
4029 
4030 
4031 
4032  function __getDateSelect($a_type,$a_varname,$a_selected)
4033  {
4034  switch($a_type)
4035  {
4036  case "minute":
4037  for($i=0;$i<=60;$i++)
4038  {
4039  $days[$i] = $i < 10 ? "0".$i : $i;
4040  }
4041  return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
4042 
4043  case "hour":
4044  for($i=0;$i<24;$i++)
4045  {
4046  $days[$i] = $i < 10 ? "0".$i : $i;
4047  }
4048  return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
4049 
4050  case "day":
4051  for($i=1;$i<32;$i++)
4052  {
4053  $days[$i] = $i < 10 ? "0".$i : $i;
4054  }
4055  return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
4056 
4057  case "month":
4058  for($i=1;$i<13;$i++)
4059  {
4060  $month[$i] = $i < 10 ? "0".$i : $i;
4061  }
4062  return ilUtil::formSelect($a_selected,$a_varname,$month,false,true);
4063 
4064  case "year":
4065  for($i = date("Y",time());$i < date("Y",time()) + 3;++$i)
4066  {
4067  $year[$i] = $i;
4068  }
4069  return ilUtil::formSelect($a_selected,$a_varname,$year,false,true);
4070  }
4071  }
4072 
4073  function __toUnix($a_time_arr)
4074  {
4075  return mktime($a_time_arr["hour"],
4076  $a_time_arr["minute"],
4077  $a_time_arr["second"],
4078  $a_time_arr["month"],
4079  $a_time_arr["day"],
4080  $a_time_arr["year"]);
4081  }
4083  {
4084  unset($_SESSION["crs_delete_member_ids"]);
4085  unset($_SESSION["crs_delete_subscriber_ids"]);
4086  unset($_SESSION["crs_search_str"]);
4087  unset($_SESSION["crs_search_for"]);
4088  unset($_SESSION["crs_group"]);
4089  unset($_SESSION["crs_role"]);
4090  unset($_SESSION["crs_archives"]);
4091  }
4092 
4094  {
4095  global $rbacreview, $ilErr, $ilAccess, $ilObjDataCache, $ilias;
4096  include_once('./Services/AccessControl/classes/class.ilObjRole.php');
4097 
4098  $this->lng->loadLanguageModule('mail');
4099  if(!isset($_GET['returned_from_mail']))
4100  {
4101  ilUtil::sendInfo($this->lng->txt('mail_select_recipients'));
4102  }
4103 
4104  $is_admin = (bool) $ilAccess->checkAccess("write", "", $this->object->getRefId());
4105 
4106  if (!$is_admin &&
4107  $this->object->getShowMembers() == $this->object->SHOW_MEMBERS_DISABLED)
4108  {
4109  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"),$ilErr->MESSAGE);
4110  }
4111 
4112  $this->setSubTabs('members');
4113  $this->tabs_gui->setTabActive('members');
4114  $this->tabs_gui->setSubTabActive('mail_members');
4115 
4116  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.mail_members.html','Services/Contact');
4117 
4118 
4119  require_once 'Services/Mail/classes/class.ilMailFormCall.php';
4120  $this->tpl->setVariable("MAILACTION", ilMailFormCall::_getLinkTarget($this, 'mailMembers', array(), array('type' => 'role', 'sig' => $this->createMailSignature())));
4121  $this->tpl->setVariable("SELECT_ACTION",'ilias.php?baseClass=ilmailgui&view=my_courses&search_crs='.$this->object->getId());
4122  $this->tpl->setVariable("MAIL_SELECTED",$this->lng->txt('send_mail_selected'));
4123  $this->tpl->setVariable("MAIL_MEMBERS",$this->lng->txt('send_mail_members'));
4124  $this->tpl->setVariable("MAIL_TUTOR",$this->lng->txt('send_mail_tutors'));
4125  $this->tpl->setVariable("MAIL_ADMIN",$this->lng->txt('send_mail_admins'));
4126  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
4127  $this->tpl->setVariable("OK",$this->lng->txt('next'));
4128 
4129  // Display roles with user friendly mailbox addresses
4130  $role_folder = $rbacreview->getRoleFolderOfObject($this->object->getRefId());
4131  $role_ids = $rbacreview->getRolesOfRoleFolder($role_folder['ref_id'], false);
4132 
4133  // Sort by relevance
4134  $sorted_role_ids = array();
4135  $counter = 3;
4136  foreach($role_ids as $role_id)
4137  {
4138  switch(substr(ilObject::_lookupTitle($role_id),0,8))
4139  {
4140  case 'il_crs_a':
4141  $sorted_role_ids[2] = $role_id;
4142  break;
4143 
4144  case 'il_crs_t':
4145  $sorted_role_ids[1] = $role_id;
4146  break;
4147 
4148  case 'il_crs_m':
4149  $sorted_role_ids[0] = $role_id;
4150  break;
4151 
4152  default:
4153  $sorted_role_ids[$counter++] = $role_id;
4154  break;
4155  }
4156  }
4157 
4158  ksort($sorted_role_ids,SORT_NUMERIC);
4159  foreach ((array) $sorted_role_ids as $role_id)
4160  {
4161  $this->tpl->setCurrentBlock("mailbox_row");
4162  $role_addr = $rbacreview->getRoleMailboxAddress($role_id);
4163 
4164  // check if role title is unique. if not force use pear mail for roles
4165  $ids_for_role_title = ilObject::_getIdsForTitle(ilObject::_lookupTitle($role_id), 'role');
4166  if(count($ids_for_role_title) >= 2)
4167  {
4168  $ilias->setSetting('pear_mail_enable', 1);
4169  }
4170 
4171  $this->tpl->setVariable("CHECK_MAILBOX",ilUtil::formCheckbox(1,'roles[]',
4172  htmlspecialchars($role_addr)
4173  ));
4174  if (ilMail::_usePearMail())
4175  {
4176  // if pear mail is enabled, mailbox addresses are already localized in the language of the user
4177  $this->tpl->setVariable("MAILBOX",$role_addr);
4178  }
4179  else
4180  {
4181  // if pear mail is not enabled, we need to localize mailbox addresses in the language of the user
4182  $this->tpl->setVariable("MAILBOX",ilObjRole::_getTranslation($ilObjDataCache->lookupTitle($role_id)). " (" . $role_addr . ")");
4183  }
4184 
4185  $this->tpl->parseCurrentBlock();
4186  }
4187  }
4188 
4189  function executeCommand()
4190  {
4191  global $rbacsystem,$ilUser,$ilAccess,$ilErr,$ilTabs,$ilNavigationHistory,$ilCtrl;
4192 
4193  $next_class = $this->ctrl->getNextClass($this);
4194  $cmd = $this->ctrl->getCmd();
4195 
4196  $this->prepareOutput();
4197 
4198  // add entry to navigation history
4199  if(!$this->getCreationMode() &&
4200  $ilAccess->checkAccess('read', '', $_GET['ref_id']))
4201  {
4202  $ilNavigationHistory->addItem($_GET['ref_id'],
4203  'repository.php?cmd=frameset&ref_id='.$_GET['ref_id'], 'crs');
4204  }
4205 
4206  if(!$this->getCreationMode())
4207  {
4208  if(IS_PAYMENT_ENABLED)
4209  {
4210  include_once 'Services/Payment/classes/class.ilPaymentObject.php';
4211  if(ilPaymentObject::_requiresPurchaseToAccess($this->object->getRefId(), $type = (isset($_GET['purchasetype']) ? $_GET['purchasetype'] : NULL) ))
4212  {
4213  $ilTabs->setTabActive('info_short');
4214 
4215  include_once 'Services/Payment/classes/class.ilShopPurchaseGUI.php';
4216  $this->ctrl->setReturn($this, '');
4217  $pp_gui = new ilShopPurchaseGUI($this->object->getRefId());
4218  $this->ctrl->forwardCommand($pp_gui);
4219  return true;
4220  }
4221  }
4222  }
4223 
4224  switch($next_class)
4225  {
4226  case "ilinfoscreengui":
4227  $this->infoScreen(); // forwards command
4228  break;
4229 
4230  case 'ilmdeditorgui':
4231  if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
4232  {
4233  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
4234  }
4235 
4236  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
4237 
4238  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
4239  $md_gui->addObserver($this->object,'MDUpdateListener','General');
4240 
4241  $this->ctrl->forwardCommand($md_gui);
4242  $this->tabs_gui->setTabActive('meta_data');
4243  break;
4244 
4245  case 'ilcourseregistrationgui':
4246  $this->ctrl->setReturn($this,'');
4247  $this->tabs_gui->setTabActive('join');
4248  include_once('./Modules/Course/classes/class.ilCourseRegistrationGUI.php');
4249  $registration = new ilCourseRegistrationGUI($this->object);
4250  $this->ctrl->forwardCommand($registration);
4251  break;
4252 
4253  case 'ilobjectcustomuserfieldsgui':
4254  include_once './Services/Membership/classes/class.ilObjectCustomUserFieldsGUI.php';
4255 
4256  $cdf_gui = new ilObjectCustomUserFieldsGUI($this->object->getId());
4257  $this->setSubTabs('properties');
4258  $this->tabs_gui->setTabActive('settings');
4259  $this->ctrl->forwardCommand($cdf_gui);
4260  break;
4261 
4262  case "ilcourseobjectivesgui":
4263  include_once './Modules/Course/classes/class.ilCourseObjectivesGUI.php';
4264 
4265  $this->ctrl->setReturn($this,"");
4266  $reg_gui =& new ilCourseObjectivesGUI($this->object->getRefId());
4267  $ret =& $this->ctrl->forwardCommand($reg_gui);
4268  break;
4269 
4270  case 'ilobjcoursegroupinggui':
4271  include_once './Modules/Course/classes/class.ilObjCourseGroupingGUI.php';
4272 
4273  $this->ctrl->setReturn($this,'edit');
4274  $this->setSubTabs('properties');
4275  $crs_grp_gui =& new ilObjCourseGroupingGUI($this->object,(int) $_GET['obj_id']);
4276  $this->ctrl->forwardCommand($crs_grp_gui);
4277  $this->tabs_gui->setTabActive('settings');
4278  $this->tabs_gui->setSubTabActive('groupings');
4279  break;
4280 
4281  case "ilcolumngui":
4282  $this->tabs_gui->setTabActive('none');
4283  $this->checkPermission("read");
4284  //$this->prepareOutput();
4285  //include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
4286  //$this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
4287  // ilObjStyleSheet::getContentStylePath(0));
4288  //$this->renderObject();
4289  $this->viewObject();
4290  break;
4291 
4292  case "ilconditionhandlerinterface":
4293  include_once './Services/AccessControl/classes/class.ilConditionHandlerInterface.php';
4294 
4295  // preconditions for single course items
4296  if($_GET['item_id'])
4297  {
4298  $this->ctrl->saveParameter($this,'item_id',$_GET['item_id']);
4299  $this->tabs_gui->setTabActive('content');
4300  $this->setSubTabs("item_activation");
4301 
4302  $new_gui =& new ilConditionHandlerInterface($this,(int) $_GET['item_id']);
4303  $this->ctrl->forwardCommand($new_gui);
4304  }
4305  else // preconditions for whole course
4306  {
4307  $this->setSubTabs("properties");
4308  $this->tabs_gui->setTabActive('settings');
4309  $new_gui =& new ilConditionHandlerInterface($this);
4310 
4311  $this->ctrl->forwardCommand($new_gui);
4312  }
4313  break;
4314 
4315  case "illearningprogressgui":
4316  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
4317 
4318  $new_gui =& new ilLearningProgressGUI(LP_MODE_REPOSITORY,
4319  $this->object->getRefId(),
4320  $_GET['user_id'] ? $_GET['user_id'] : $ilUser->getId());
4321  $this->ctrl->forwardCommand($new_gui);
4322  $this->tabs_gui->setTabActive('learning_progress');
4323  break;
4324 
4325  case 'illicenseoverviewgui':
4326  include_once("./Services/License/classes/class.ilLicenseOverviewGUI.php");
4327  $license_gui =& new ilLicenseOverviewGUI($this, LIC_MODE_REPOSITORY);
4328  $ret =& $this->ctrl->forwardCommand($license_gui);
4329  $this->tabs_gui->setTabActive('licenses');
4330  break;
4331 
4332  case 'ilpermissiongui':
4333  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
4334  $this->tabs_gui->setTabActive('perm_settings');
4335  $perm_gui =& new ilPermissionGUI($this);
4336  $ret =& $this->ctrl->forwardCommand($perm_gui);
4337  break;
4338 
4339  case 'ilrepositorysearchgui':
4340  include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
4341  $rep_search =& new ilRepositorySearchGUI();
4342  $rep_search->setCallback($this,
4343  'assignMembersObject',
4344  array(
4345  ilCourseConstants::CRS_MEMBER => $this->lng->txt('crs_member'),
4346  ilCourseConstants::CRS_TUTOR => $this->lng->txt('crs_tutor'),
4347  ilCourseConstants::CRS_ADMIN => $this->lng->txt('crs_admin')
4348  )
4349  );
4350 
4351  $this->checkLicenses();
4352 
4353  // Set tabs
4354  $this->ctrl->setReturn($this,'members');
4355  $ret =& $this->ctrl->forwardCommand($rep_search);
4356  $this->setSubTabs('members');
4357  $this->tabs_gui->setTabActive('members');
4358  $this->tabs_gui->setSubTabActive('crs_member_administration');
4359  break;
4360 
4361  case 'ilcoursecontentinterface':
4362 
4363  $this->initCourseContentInterface();
4364  $this->cci_obj->cci_setContainer($this);
4365 
4366  $this->ctrl->forwardCommand($this->cci_obj);
4367  $this->setSubTabs('content');
4368  $this->tabs_gui->setTabActive('content');
4369  break;
4370 
4371  case 'ilcoursecontentgui':
4372  $this->ctrl->setReturn($this,'members');
4373  include_once './Modules/Course/classes/class.ilCourseContentGUI.php';
4374  $course_content_obj = new ilCourseContentGUI($this);
4375  $this->ctrl->forwardCommand($course_content_obj);
4376  break;
4377 
4378  case 'ilpublicuserprofilegui':
4379  require_once './Services/User/classes/class.ilPublicUserProfileGUI.php';
4380  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
4381  $this->setSubTabs('members');
4382  $this->tabs_gui->setTabActive('members');
4383  $profile_gui->setBackUrl($ilCtrl->getLinkTarget($this, "membersGallery"));
4384  $this->tabs_gui->setSubTabActive('crs_members_gallery');
4385  $html = $this->ctrl->forwardCommand($profile_gui);
4386  $this->tpl->setVariable("ADM_CONTENT", $html);
4387  break;
4388 
4389  case 'ilmemberexportgui':
4390  include_once('./Services/Membership/classes/Export/class.ilMemberExportGUI.php');
4391 
4392  $this->setSubTabs('members');
4393  $this->tabs_gui->setTabActive('members');
4394  $this->tabs_gui->setSubTabActive('export_members');
4395  $export = new ilMemberExportGUI($this->object->getRefId());
4396  $this->ctrl->forwardCommand($export);
4397  break;
4398 
4399  case 'ilmemberagreementgui':
4400  include_once('Services/Membership/classes/class.ilMemberAgreementGUI.php');
4401  $this->ctrl->setReturn($this,'');
4402  $agreement = new ilMemberAgreementGUI($this->object->getRefId());
4403  $this->ctrl->forwardCommand($agreement);
4404  break;
4405 
4406  case 'ilsessionoverviewgui':
4407  include_once('./Modules/Session/classes/class.ilSessionOverviewGUI.php');
4408 
4409  $this->setSubTabs('members');
4410  $this->tabs_gui->setTabActive('members');
4411  $this->tabs_gui->setSubTabActive('events');
4412  $overview = new ilSessionOverviewGUI($this->object->getRefId());
4413  $this->ctrl->forwardCommand($overview);
4414  break;
4415 
4416  case 'ilcourseitemadministrationgui':
4417  include_once 'Modules/Course/classes/class.ilCourseItemAdministrationGUI.php';
4418  $this->tabs_gui->clearSubTabs();
4419  $this->ctrl->setReturn($this,'view');
4420  $item_adm_gui = new ilCourseItemAdministrationGUI($this->object,(int) $_REQUEST['item_id']);
4421  $this->ctrl->forwardCommand($item_adm_gui);
4422  break;
4423 
4424  // container page editing
4425  case "ilpageobjectgui":
4426  $ret = $this->forwardToPageObject();
4427  if ($ret != "")
4428  {
4429  $this->tpl->setContent($ret);
4430  }
4431  break;
4432 
4433  case 'ilobjectcopygui':
4434  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
4435  $cp = new ilObjectCopyGUI($this);
4436  $cp->setType('crs');
4437  $this->ctrl->forwardCommand($cp);
4438  break;
4439 
4440  case "ilobjstylesheetgui":
4441  $this->forwardToStyleSheet();
4442  break;
4443 
4444  case 'ilcourseparticipantsgroupsgui':
4445  include_once './Modules/Course/classes/class.ilCourseParticipantsGroupsGUI.php';
4446 
4447  $cmg_gui = new ilCourseParticipantsGroupsGUI($this->object->getRefId());
4448  $this->setSubTabs('members');
4449  $this->tabs_gui->setTabActive('members');
4450  $this->ctrl->forwardCommand($cmg_gui);
4451  break;
4452 
4453  case 'ilexportgui':
4454  $this->tabs_gui->setTabActive('export');
4455  include_once './Services/Export/classes/class.ilExportGUI.php';
4456  $exp = new ilExportGUI($this);
4457  $exp->addFormat('xml');
4458  $this->ctrl->forwardCommand($exp);
4459  break;
4460 
4461  case "ilcommonactiondispatchergui":
4462  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
4464  $this->ctrl->forwardCommand($gui);
4465  break;
4466 
4467  case 'ildidactictemplategui':
4468  $this->ctrl->setReturn($this,'edit');
4469  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateGUI.php';
4470  $did = new ilDidacticTemplateGUI($this);
4471  $this->ctrl->forwardCommand($did);
4472  break;
4473 
4474 
4475  default:
4476  if(!$this->creation_mode)
4477  {
4478  $this->checkPermission('visible');
4479  }
4480  /*
4481  if(!$this->creation_mode and !$ilAccess->checkAccess('visible','',$this->object->getRefId(),'crs'))
4482  {
4483  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"),$ilErr->MESSAGE);
4484  }
4485  */
4486  if( !$this->creation_mode
4487  && $cmd != 'infoScreen'
4488  && $cmd != 'sendfile'
4489  && $cmd != 'unsubscribe'
4490  && $cmd != 'performUnsubscribe'
4491  && !$ilAccess->checkAccess("read",'',$this->object->getRefId())
4492  || $cmd == 'join'
4493  || $cmd == 'subscribe')
4494  {
4495  include_once './Modules/Course/classes/class.ilCourseParticipants.php';
4496  if($rbacsystem->checkAccess('join',$this->object->getRefId()) &&
4497  !ilCourseParticipants::_isParticipant($this->object->getRefId(),$ilUser->getId()))
4498  {
4499  include_once('./Modules/Course/classes/class.ilCourseRegistrationGUI.php');
4500  $this->ctrl->redirectByClass("ilCourseRegistrationGUI");
4501  }
4502  else
4503  {
4504  $this->infoScreenObject();
4505  break;
4506  }
4507  }
4508 
4509  if($cmd == 'listObjectives')
4510  {
4511  include_once './Modules/Course/classes/class.ilCourseObjectivesGUI.php';
4512 
4513  $this->ctrl->setReturn($this,"");
4514  $obj_gui =& new ilCourseObjectivesGUI($this->object->getRefId());
4515  $ret =& $this->ctrl->forwardCommand($obj_gui);
4516  break;
4517  }
4518 
4519  if((!$this->creation_mode)&&(!$rbacsystem->checkAccess("write",$this->object->getRefId())))
4520  {
4521  $this->ctrl->setReturn($this,'view');
4522  include_once('Services/Feedback/classes/class.ilFeedbackGUI.php');
4523  $feedbackGUI = new ilFeedbackGUI();
4524  $feedbackGUI->handleRequiredFeedback($this->object->getRefId());
4525  }
4526 
4527  // Dirty hack for course timings view
4528  if($this->forwardToTimingsView())
4529  {
4530  break;
4531  }
4532 
4533  if(!$cmd)
4534  {
4535  $cmd = 'view';
4536  }
4537  $cmd .= 'Object';
4538  $this->$cmd();
4539 
4540  break;
4541  }
4542 
4543  $this->addHeaderAction();
4544 
4545  return true;
4546  }
4547 
4554  private function checkAgreement()
4555  {
4556  global $ilUser,$ilAccess;
4557 
4558  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
4559  {
4560  return true;
4561  }
4562 
4563  // Disable aggrement if is not member of course
4564  if(!$this->object->getMemberObject()->isAssigned())
4565  {
4566  return true;
4567  }
4568 
4569  include_once './Services/Container/classes/class.ilMemberViewSettings.php';
4570  if(ilMemberViewSettings::getInstance()->isActive())
4571  {
4572  return true;
4573  }
4574 
4575  include_once('Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
4576  include_once('Services/Membership/classes/class.ilMemberAgreement.php');
4577  $privacy = ilPrivacySettings::_getInstance();
4578 
4579  // Check agreement
4580  if(($privacy->courseConfirmationRequired() or ilCourseDefinedFieldDefinition::_hasFields($this->object->getId()))
4581  and !ilMemberAgreement::_hasAccepted($ilUser->getId(),$this->object->getId()))
4582  {
4583  return false;
4584  }
4585  // Check required fields
4586  include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');
4587  if(!ilCourseUserData::_checkRequired($ilUser->getId(),$this->object->getId()))
4588  {
4589  return false;
4590  }
4591  return true;
4592  }
4593 
4594 
4601  private function checkLicenses($a_keep = false)
4602  {
4603  global $lng;
4604 
4605 
4606  include_once("Services/License/classes/class.ilLicenseAccess.php");
4608  {
4609  $lic_set = new ilSetting("license");
4610  $buffer = $lic_set->get("license_warning");
4611 
4612  include_once("./Services/License/classes/class.ilLicense.php");
4613  $licensed_items = ilLicense::_getLicensedChildObjects($this->object->getRefId());
4614  foreach ($licensed_items as $item)
4615  {
4616  $license =& new ilLicense($item['obj_id']);
4617  $remaining = $license->getRemainingLicenses();
4618  if ($remaining <= $buffer)
4619  {
4620  $lng->loadlanguageModule("license");
4621  ilUtil::sendInfo(sprintf($this->lng->txt("course_licenses_rare"), $remaining), $a_keep);
4622  break;
4623  }
4624  }
4625  }
4626  }
4627 
4628  // STATIC
4629  function _forwards()
4630  {
4631  return array("ilCourseRegisterGUI",'ilConditionHandlerInterface');
4632  }
4633 
4634 
4636  {
4637  $this->initCourseContentInterface();
4638  $this->cci_obj->cci_setContainer($this);
4639  $this->cci_obj->cci_objectives();
4640 
4641  return true;;
4642  }
4644  {
4645  $this->tabs_gui->setTabActive('edit_content');
4646 
4647  $this->initCourseContentInterface();
4648  $this->cci_obj->cci_setContainer($this);
4649  $this->cci_obj->cci_view();
4650 
4651  return true;
4652  }
4654  {
4655  $this->initCourseContentInterface();
4656  $this->cci_obj->cci_setContainer($this);
4657  $this->cci_obj->cci_objectives_ask_reset();
4658 
4659  return true;;
4660  }
4661  function cciResetObject()
4662  {
4663  global $ilUser;
4664 
4665  include_once './Modules/Course/classes/class.ilCourseObjectiveResult.php';
4666 
4667  $tmp_obj_res =& new ilCourseObjectiveResult($ilUser->getId());
4668  $tmp_obj_res->reset($this->object->getId());
4669 
4670  ilUtil::sendSuccess($this->lng->txt('crs_objectives_reseted'));
4671 
4672  $this->initCourseContentInterface();
4673  $this->cci_obj->cci_setContainer($this);
4674  $this->cci_obj->cci_objectives();
4675  }
4676 
4677 
4678  // Methods for ConditionHandlerInterface
4679  function initConditionHandlerGUI($item_id)
4680  {
4681  include_once './Services/AccessControl/classes/class.ilConditionHandlerInterface.php';
4682 
4683  if(!is_object($this->chi_obj))
4684  {
4685  if($_GET['item_id'])
4686  {
4687  $this->chi_obj =& new ilConditionHandlerInterface($this,$item_id);
4688  $this->ctrl->saveParameter($this,'item_id',$_GET['item_id']);
4689  }
4690  else
4691  {
4692  $this->chi_obj =& new ilConditionHandlerInterface($this);
4693  }
4694  }
4695  return true;
4696  }
4697 
4698 
4699  function addLocatorItems()
4700  {
4701  global $ilLocator;
4702  switch ($this->ctrl->getCmd())
4703  {
4704  default:
4705  #$ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""));
4706  break;
4707  }
4708  }
4709 
4713  function _goto($a_target, $a_add = "")
4714  {
4715  global $ilAccess, $ilErr, $lng,$ilUser;
4716 
4717  include_once './Services/Membership/classes/class.ilMembershipRegistrationCodeUtils.php';
4718  if(substr($a_add,0,5) == 'rcode')
4719  {
4720  if($ilUser->getId() == ANONYMOUS_USER_ID)
4721  {
4722  // Redirect to login for anonymous
4724  "login.php?target=".$_GET["target"]."&cmd=force_login&lang=".
4725  $ilUser->getCurrentLanguage()
4726  );
4727  }
4728 
4729  // Redirects to target location after assigning user to course
4731  $a_target,
4733  substr($a_add,5)
4734  );
4735  }
4736 
4737  if ($a_add == "mem" && $ilAccess->checkAccess("write", "", $a_target))
4738  {
4739 //echo "1";
4740  $_GET["cmd"] = "members";
4741  $_GET["ref_id"] = $a_target;
4742  include("repository.php");
4743  exit;
4744  }
4745 
4746  if ($ilAccess->checkAccess("read", "", $a_target))
4747  {
4748  $_GET["cmd"] = "frameset";
4749  $_GET["ref_id"] = $a_target;
4750  include("repository.php");
4751  exit;
4752  }
4753  else
4754  {
4755  // to do: force flat view
4756  if ($ilAccess->checkAccess("visible", "", $a_target))
4757  {
4758  $_GET["cmd"] = "infoScreen";
4759  $_GET["ref_id"] = $a_target;
4760  include("repository.php");
4761  exit;
4762  }
4763  else
4764  {
4765  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
4766  {
4767  $_GET["cmd"] = "frameset";
4768  $_GET["target"] = "";
4769  $_GET["ref_id"] = ROOT_FOLDER_ID;
4770  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
4771  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
4772  include("repository.php");
4773  exit;
4774  }
4775  }
4776  }
4777  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
4778  }
4779 
4780 
4781  function toUnix($date,$time = array())
4782  {
4783  return mktime($time['h'],$time['m'],0,$date['m'],$date['d'],$date['y']);
4784  }
4785 
4786  function __prepareDateSelect($a_unix_time)
4787  {
4788  return array('y' => date('Y',$a_unix_time),
4789  'm' => date('n',$a_unix_time),
4790  'd' => date('d',$a_unix_time));
4791  }
4792 
4793  function __prepareTimeSelect($a_unix_time)
4794  {
4795  return array('h' => date('G',$a_unix_time),
4796  'm' => date('i',$a_unix_time),
4797  's' => date('s',$a_unix_time));
4798  }
4799 
4800  // Copy wizard
4801 
4806  {
4807  global $ilUser, $ilCtrl, $ilUser, $ilAccess;
4808 
4809  $this->setSubTabs("properties");
4810  $this->tabs_gui->setTabActive('settings');
4811 
4813  !$ilAccess->checkAccess("write", "", $this->object->getRefId()))
4814  {
4815  return;
4816  }
4817 
4818  $latitude = $this->object->getLatitude();
4819  $longitude = $this->object->getLongitude();
4820  $zoom = $this->object->getLocationZoom();
4821 
4822  // Get Default settings, when nothing is set
4823  if ($latitude == 0 && $longitude == 0 && $zoom == 0)
4824  {
4826  $latitude = $def["latitude"];
4827  $longitude = $def["longitude"];
4828  $zoom = $def["zoom"];
4829  }
4830 
4831  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"), $this->lng->txt("personal_desktop"));
4832  //$this->tpl->setVariable("HEADER", $this->lng->txt("personal_desktop"));
4833 
4834  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
4835  $form = new ilPropertyFormGUI();
4836  $form->setFormAction($ilCtrl->getFormAction($this));
4837 
4838  $form->setTitle($this->lng->txt("crs_map_settings"));
4839 
4840  // enable map
4841  $public = new ilCheckboxInputGUI($this->lng->txt("crs_enable_map"),
4842  "enable_map");
4843  $public->setValue("1");
4844  $public->setChecked($this->object->getEnableCourseMap());
4845  $form->addItem($public);
4846 
4847  // map location
4848  $loc_prop = new ilLocationInputGUI($this->lng->txt("crs_map_location"),
4849  "location");
4850  $loc_prop->setLatitude($latitude);
4851  $loc_prop->setLongitude($longitude);
4852  $loc_prop->setZoom($zoom);
4853  $form->addItem($loc_prop);
4854 
4855  $form->addCommandButton("saveMapSettings", $this->lng->txt("save"));
4856 
4857  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
4858  //$this->tpl->show();
4859  }
4860 
4862  {
4863  global $ilCtrl, $ilUser;
4864 
4865  $this->object->setLatitude(ilUtil::stripSlashes($_POST["location"]["latitude"]));
4866  $this->object->setLongitude(ilUtil::stripSlashes($_POST["location"]["longitude"]));
4867  $this->object->setLocationZoom(ilUtil::stripSlashes($_POST["location"]["zoom"]));
4868  $this->object->setEnableCourseMap(ilUtil::stripSlashes($_POST["enable_map"]));
4869  $this->object->update();
4870 
4871  $ilCtrl->redirect($this, "editMapSettings");
4872  }
4873 
4877  function membersMapObject()
4878  {
4879  global $tpl;
4880 
4881  $this->tabs_gui->setTabActive("members");
4882  $this->setSubTabs('members');
4883  $this->tabs_gui->setSubTabActive("crs_members_map");
4884 
4885  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
4886  if (!ilGoogleMapUtil::isActivated() || !$this->object->getEnableCourseMap())
4887  {
4888  return;
4889  }
4890 
4891  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapGUI.php");
4892  $map = new ilGoogleMapGUI();
4893  $map->setMapId("course_map");
4894  $map->setWidth("700px");
4895  $map->setHeight("500px");
4896  $map->setLatitude($this->object->getLatitude());
4897  $map->setLongitude($this->object->getLongitude());
4898  $map->setZoom($this->object->getLocationZoom());
4899  $map->setEnableTypeControl(true);
4900  $map->setEnableNavigationControl(true);
4901  $map->setEnableCentralMarker(true);
4902 
4903  include_once './Modules/Course/classes/class.ilCourseParticipants.php';
4904  $members = ilCourseParticipants::_getInstanceByObjId($this->object->getId())->getParticipants();
4905  if(count($members))
4906  {
4907  foreach($members as $user_id)
4908  {
4909  $map->addUserMarker($user_id);
4910  }
4911  }
4912 
4913  $tpl->setContent($map->getHTML());
4914  $tpl->setLeftContent($map->getUserListHTML());
4915  }
4916 
4920  function modifyItemGUI($a_item_list_gui, $a_item_data, $a_show_path)
4921  {
4922  return ilObjCourseGUI::_modifyItemGUI($a_item_list_gui, 'ilcoursecontentgui', $a_item_data, $a_show_path,
4923  $this->object->getAboStatus(), $this->object->getRefId(), $this->object->getId());
4924  }
4925 
4929  static function _modifyItemGUI($a_item_list_gui, $a_cmd_class, $a_item_data, $a_show_path,
4930  $a_abo_status, $a_course_ref_id, $a_course_obj_id, $a_parent_ref_id = 0)
4931  {
4932  global $lng, $ilCtrl, $ilAccess;
4933 
4934  // this is set for folders within the course
4935  if ($a_parent_ref_id == 0)
4936  {
4937  $a_parent_ref_id = $a_course_ref_id;
4938  }
4939 
4940  // Special handling for tests in courses with learning objectives
4941  if($a_item_data['type'] == 'tst' and
4943  {
4944  $a_item_list_gui->addCommandLinkParameter(array('crs_show_result' => $a_course_ref_id));
4945  }
4946 
4947  // ACTIVATION
4948  $activation = '';
4949  if(isset($a_item_data['timing_type']))
4950  {
4951  switch($a_item_data['timing_type'])
4952  {
4954  $activation = ilDatePresentation::formatPeriod(
4955  new ilDateTime($a_item_data['start'],IL_CAL_UNIX),
4956  new ilDateTime($a_item_data['end'],IL_CAL_UNIX));
4957  break;
4958 
4960  $activation = ilDatePresentation::formatPeriod(
4961  new ilDate($a_item_data['start'],IL_CAL_UNIX),
4962  new ilDate($a_item_data['end'],IL_CAL_UNIX));
4963  break;
4964 
4965  default:
4966  $activation = '';
4967  break;
4968  }
4969  }
4970 
4971  $a_item_list_gui->enableSubscribe($a_abo_status);
4972 
4973  // add activation custom property
4974  if ($activation != "")
4975  {
4976  $lng->loadLanguageModule("crs"); // #12774
4977  $a_item_list_gui->addCustomProperty($lng->txt($a_item_data['activation_info']), $activation,
4978  false, true);
4979  }
4980 
4981  $is_tutor = ($ilAccess->checkAccess('write','',
4982  $a_course_ref_id,'crs', $a_course_obj_id));
4983 
4984  if($a_show_path and $is_tutor)
4985  {
4986  $a_item_list_gui->addCustomProperty($lng->txt('path'),
4987 
4988  ilContainer::_buildPath($a_item_data['ref_id'], $a_course_ref_id),
4989  false,
4990  true);
4991  }
4992 
4993  if($is_tutor)
4994  {
4995  $ilCtrl->setParameterByClass('ilcourseitemadministrationgui',"ref_id",
4996  $a_parent_ref_id);
4997  $ilCtrl->setParameterByClass('ilcourseitemadministrationgui',"item_id",
4998  $a_item_data['child']);
4999  $a_item_list_gui->addCustomCommand($ilCtrl->getLinkTargetByClass(
5000  array(strtolower($a_cmd_class), 'ilCourseItemAdministrationGUI'),
5001  'edit'),
5002  'activation');
5003  }
5004  }
5005 
5010  {
5011  global $ilAccess, $lng, $ilCtrl;
5012 
5013  if ($this->object->getType() != 'crs')
5014  {
5015  return true;
5016  }
5017  if (!$ilAccess->checkAccess('write','',
5018  $this->object->getRefId(),'crs',$this->object->getId()))
5019  {
5020  $is_tutor = false;
5021  // No further tabs if objective view or archives
5022  if($this->object->enabledObjectiveView())
5023  {
5024  return false;
5025  }
5026  }
5027  else
5028  {
5029  $is_tutor = true;
5030  }
5031 
5032  // These subtabs should also work, if the command is called directly in
5033  // ilObjCourseGUI, so please use ...ByClass methods.
5034  // (see ilObjCourseGUI->executeCommand: case "ilcolumngui")
5035 
5036  if(!$_SESSION['crs_timings_panel'][$this->object->getId()] or 1)
5037  {
5038  if (!$this->isActiveAdministrationPanel())
5039  {
5040  $this->tabs_gui->addSubTab("view_content", $lng->txt("view"), $ilCtrl->getLinkTargetByClass("ilobjcoursegui", "view"));
5041  }
5042  else
5043  {
5044  $this->tabs_gui->addSubTab("view_content", $lng->txt("view"), $ilCtrl->getLinkTargetByClass("ilobjcoursegui", "disableAdministrationPanel"));
5045  }
5046  }
5047  include_once 'Modules/Course/classes/class.ilCourseItems.php';
5048  if($this->object->getViewMode() == IL_CRS_VIEW_TIMING)
5049  {
5050  $this->tabs_gui->addSubTabTarget('timings_timings',
5051  $this->ctrl->getLinkTargetByClass('ilcoursecontentgui','editUserTimings'));
5052  }
5053 
5054  $this->addStandardContainerSubTabs(false);
5055 
5056  /*
5057  if($is_tutor)
5058  {
5059  $this->tabs_gui->addSubTabTarget('crs_archives',
5060  $this->ctrl->getLinkTargetByClass(
5061  array('ilcoursecontentgui', 'ilcoursearchivesgui'),'view'));
5062  }
5063  */
5064  return true;
5065  }
5066 
5074  protected function loadDate($a_field)
5075  {
5076  global $ilUser;
5077 
5078  include_once('./Services/Calendar/classes/class.ilDateTime.php');
5079 
5080  $dt['year'] = (int) $_POST[$a_field]['date']['y'];
5081  $dt['mon'] = (int) $_POST[$a_field]['date']['m'];
5082  $dt['mday'] = (int) $_POST[$a_field]['date']['d'];
5083  $dt['hours'] = (int) $_POST[$a_field]['time']['h'];
5084  $dt['minutes'] = (int) $_POST[$a_field]['time']['m'];
5085  $dt['seconds'] = (int) $_POST[$a_field]['time']['s'];
5086 
5087  $date = new ilDateTime($dt,IL_CAL_FKT_GETDATE,$ilUser->getTimeZone());
5088  return $date;
5089  }
5090 
5098  public function askResetObject()
5099  {
5100  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_objectives_ask_reset.html",'Modules/Course');
5101 
5102  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
5103  $this->tpl->setVariable("INFO_STRING",$this->lng->txt('crs_objectives_reset_sure'));
5104  $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
5105  $this->tpl->setVariable("TXT_RESET",$this->lng->txt('reset'));
5106 
5107  return true;
5108  }
5109 
5110  function resetObject()
5111  {
5112  global $ilUser;
5113 
5114  include_once './Modules/Course/classes/class.ilCourseObjectiveResult.php';
5115 
5116  $tmp_obj_res = new ilCourseObjectiveResult($ilUser->getId());
5117  $tmp_obj_res->reset($this->object->getId());
5118 
5119  $ilUser->deletePref('crs_objectives_force_details_'.$this->object->getId());
5120 
5121  ilUtil::sendSuccess($this->lng->txt('crs_objectives_reseted'));
5122  $this->viewObject();
5123  }
5124 
5126  {
5127  include_once './Modules/Course/classes/class.ilCourseStart.php';
5128 
5129  global $ilAccess,$ilUser;
5130 
5131  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
5132  {
5133  return true;
5134  }
5135  $this->start_obj = new ilCourseStart($this->object->getRefId(),$this->object->getId());
5136  if(count($this->start_obj->getStartObjects()) and !$this->start_obj->allFullfilled($ilUser->getId()))
5137  {
5138  return false;
5139  }
5140  return true;
5141  }
5142 
5143  function showStartObjects()
5144  {
5145  include_once './Modules/Course/classes/class.ilCourseLMHistory.php';
5146  include_once './Services/Repository/classes/class.ilRepositoryExplorer.php';
5147  include_once './classes/class.ilLink.php';
5148 
5149  global $rbacsystem,$ilias,$ilUser,$ilAccess,$ilObjDataCache;
5150 
5151  $this->tabs_gui->setSubTabActive('view');
5152 
5153  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_start_view.html",'Modules/Course');
5154  $this->tpl->setVariable("INFO_STRING",$this->lng->txt('crs_info_start'));
5155  $this->tpl->setVariable("TBL_TITLE_START",$this->lng->txt('crs_table_start_objects'));
5156  $this->tpl->setVariable("HEADER_NR",$this->lng->txt('crs_nr'));
5157  $this->tpl->setVariable("HEADER_DESC",$this->lng->txt('description'));
5158  $this->tpl->setVariable("HEADER_EDITED",$this->lng->txt('crs_objective_accomplished'));
5159 
5160 
5161  $lm_continue =& new ilCourseLMHistory($this->object->getRefId(),$ilUser->getId());
5162  $continue_data = $lm_continue->getLMHistory();
5163 
5164  $counter = 0;
5165  foreach($this->start_obj->getStartObjects() as $start)
5166  {
5167  $obj_id = $ilObjDataCache->lookupObjId($start['item_ref_id']);
5168  $ref_id = $start['item_ref_id'];
5169  $type = $ilObjDataCache->lookupType($obj_id);
5170 
5172 
5173  $obj_link = ilLink::_getLink($ref_id,$type);
5175  $obj_frame = $obj_frame ? $obj_frame : '';
5176 
5177  // Tmp fix for tests
5178  $obj_frame = $type == 'tst' ? '' : $obj_frame;
5179 
5180  $contentObj = false;
5181 
5182  if($ilAccess->checkAccess('read','',$ref_id))
5183  {
5184  $this->tpl->setCurrentBlock("start_read");
5185  $this->tpl->setVariable("READ_TITLE_START",$ilObjDataCache->lookupTitle($obj_id));
5186  $this->tpl->setVariable("READ_TARGET_START",$obj_frame);
5187  $this->tpl->setVariable("READ_LINK_START", $obj_link.'&crs_show_result='.$this->object->getRefId());
5188  $this->tpl->parseCurrentBlock();
5189  }
5190  else
5191  {
5192  $this->tpl->setCurrentBlock("start_visible");
5193  $this->tpl->setVariable("VISIBLE_LINK_START",$ilObjDataCache->lookupTitle($obj_id));
5194  $this->tpl->parseCurrentBlock();
5195  }
5196 
5197  // CONTINUE LINK
5198  if(isset($continue_data[$ref_id]))
5199  {
5200  $this->tpl->setCurrentBlock("link");
5201  $this->tpl->setVariable("LINK_HREF",ilLink::_getLink($ref_id,'',array('obj_id',
5202  $continue_data[$ref_id]['lm_page_id'])));
5203  #$this->tpl->setVariable("CONTINUE_LINK_TARGET",$target);
5204  $this->tpl->setVariable("LINK_NAME",$this->lng->txt('continue_work'));
5205  $this->tpl->parseCurrentBlock();
5206  }
5207 
5208  // add to desktop link
5209  if(!$ilUser->isDesktopItem($ref_id,$type) and
5210  $this->object->getAboStatus())
5211  {
5212  if ($ilAccess->checkAccess('read','',$ref_id))
5213  {
5214  $this->tpl->setCurrentBlock("link");
5215  $this->ctrl->setParameterByClass(get_class($this),'item_ref_id',$ref_id);
5216  $this->ctrl->setParameterByClass(get_class($this),'item_id',$ref_id);
5217  $this->ctrl->setParameterByClass(get_class($this),'type',$type);
5218 
5219  $this->tpl->setVariable("LINK_HREF",$this->ctrl->getLinkTarget($this,'addToDesk'));
5220  $this->tpl->setVariable("LINK_NAME", $this->lng->txt("to_desktop"));
5221  $this->tpl->parseCurrentBlock();
5222  }
5223  }
5224  elseif($this->object->getAboStatus())
5225  {
5226  $this->tpl->setCurrentBlock("link");
5227  $this->ctrl->setParameterByClass(get_class($this),'item_ref_id',$ref_id);
5228  $this->ctrl->setParameterByClass(get_class($this),'item_id',$ref_id);
5229  $this->ctrl->setParameterByClass(get_class($this),'type',$type);
5230 
5231  $this->tpl->setVariable("LINK_HREF",$this->ctrl->getLinkTarget($this,'removeFromDesk'));
5232  $this->tpl->setVariable("LINK_NAME", $this->lng->txt("unsubscribe"));
5233  $this->tpl->parseCurrentBlock();
5234  }
5235 
5236 
5237  // Description
5238  if(strlen($ilObjDataCache->lookupDescription($obj_id)))
5239  {
5240  $this->tpl->setCurrentBlock("start_description");
5241  $this->tpl->setVariable("DESCRIPTION_START",$ilObjDataCache->lookupDescription($obj_id));
5242  $this->tpl->parseCurrentBlock();
5243  }
5244 
5245 
5246  if($this->start_obj->isFullfilled($ilUser->getId(),$ref_id))
5247  {
5248  $accomplished = 'accomplished';
5249  }
5250  else
5251  {
5252  $accomplished = 'not_accomplished';
5253  }
5254  $this->tpl->setCurrentBlock("start_row");
5255  $this->tpl->setVariable("EDITED_IMG",ilUtil::getImagePath('crs_'.$accomplished.'.gif'));
5256  $this->tpl->setVariable("EDITED_ALT",$this->lng->txt('crs_objective_'.$accomplished));
5257  $this->tpl->setVariable("ROW_CLASS",'option_value');
5258  $this->tpl->setVariable("ROW_CLASS_CENTER",'option_value_center');
5259  $this->tpl->setVariable("OBJ_NR_START",++$counter.'.');
5260  $this->tpl->parseCurrentBlock();
5261  }
5262  return true;
5263  }
5264 
5269  public function prepareOutput()
5270  {
5271  global $rbacsystem;
5272  if(!$this->getCreationMode())
5273  {
5274  include_once './Services/Container/classes/class.ilMemberViewSettings.php';
5275  $settings = ilMemberViewSettings::getInstance();
5276  if($settings->isActive() and $settings->getContainer() != $this->object->getRefId())
5277  {
5278  $settings->setContainer($this->object->getRefId());
5279  $rbacsystem->initMemberView();
5280  }
5281  }
5283  }
5284 
5289  protected function createMailSignature()
5290  {
5291  $link = chr(13).chr(10).chr(13).chr(10);
5292  $link .= $this->lng->txt('crs_mail_permanent_link');
5293  $link .= chr(13).chr(10).chr(13).chr(10);
5294  include_once './classes/class.ilLink.php';
5295  $link .= ilLink::_getLink($this->object->getRefId());
5296  return rawurlencode(base64_encode($link));
5297  }
5298 
5299  protected function initHeaderAction($a_sub_type = null, $a_sub_id = null)
5300  {
5301  global $ilSetting, $ilUser;
5302 
5303  $lg = parent::initHeaderAction($a_sub_type, $a_sub_id);
5304 
5305  if($lg && $ilSetting->get("crsgrp_ntf") &&
5306  ilCourseParticipants::_isParticipant($this->ref_id, $ilUser->getId()))
5307  {
5308  if(!$ilUser->getPref("grpcrs_ntf_".$this->ref_id))
5309  {
5310  $lg->addHeaderIcon("not_icon",
5311  ilUtil::getImagePath("notification_off.png"),
5312  $this->lng->txt("crs_notification_deactivated"));
5313 
5314  $this->ctrl->setParameter($this, "crs_ntf", 1);
5315  $caption = "crs_activate_notification";
5316  }
5317  else
5318  {
5319  $lg->addHeaderIcon("not_icon",
5320  ilUtil::getImagePath("notification_on.png"),
5321  $this->lng->txt("crs_notification_activated"));
5322 
5323  $this->ctrl->setParameter($this, "crs_ntf", 0);
5324  $caption = "crs_deactivate_notification";
5325  }
5326 
5327  $lg->addCustomCommand($this->ctrl->getLinkTarget($this, "saveNotification"),
5328  $caption);
5329 
5330 
5331  $this->ctrl->setParameter($this, "crs_ntf", "");
5332  }
5333 
5334  return $lg;
5335  }
5336 
5337 } // END class.ilObjCourseGUI
5338 ?>