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