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