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