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