ILIAS  eassessment Revision 61809
 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 
968  $section = new ilFormSectionHeaderGUI();
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 
976  $section = new ilFormSectionHeaderGUI();
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 
1305  $section = new ilFormSectionHeaderGUI();
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  ++$added_users;
2732  }
2733  if($added_users)
2734  {
2735  ilUtil::sendSuccess($this->lng->txt("crs_users_added"),true);
2736  unset($_SESSION["crs_search_str"]);
2737  unset($_SESSION["crs_search_for"]);
2738  unset($_SESSION['crs_usr_search_result']);
2739 
2740  $this->checkLicenses(true);
2741  $this->ctrl->redirect($this,'members');
2742  }
2743  ilUtil::sendFailure($this->lng->txt("crs_users_already_assigned"));
2744  return false;
2745  }
2746 
2748  {
2749  global $rbacsystem;
2750 
2751  $this->checkPermission('write');
2752 
2753  if(!count($_POST["waiting"]))
2754  {
2755  ilUtil::sendFailure($this->lng->txt("crs_no_users_selected"));
2756  $this->membersObject();
2757 
2758  return false;
2759  }
2760  $this->object->initCourseMemberObject();
2761 
2762  include_once('./Modules/Course/classes/class.ilCourseWaitingList.php');
2763  $waiting_list = new ilCourseWaitingList($this->object->getId());
2764 
2765  $added_users = 0;
2766  foreach($_POST["waiting"] as $user_id)
2767  {
2768  if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user_id,false))
2769  {
2770  continue;
2771  }
2772  if($this->object->members_obj->isAssigned($user_id))
2773  {
2774  continue;
2775  }
2776  $this->object->members_obj->add($user_id,IL_CRS_MEMBER);
2777  $this->object->members_obj->sendNotification($this->object->members_obj->NOTIFY_ACCEPT_USER,$user_id);
2778  $waiting_list->removeFromList($user_id);
2779 
2780  ++$added_users;
2781  }
2782 
2783  if($added_users)
2784  {
2785  ilUtil::sendSuccess($this->lng->txt("crs_users_added"));
2786  $this->membersObject();
2787  return true;
2788  }
2789  else
2790  {
2791  ilUtil::sendFailure($this->lng->txt("crs_users_already_assigned"));
2792  $this->membersObject();
2793  return false;
2794  }
2795  }
2796 
2803  public function refuseFromListObject()
2804  {
2805  global $ilUser;
2806 
2807  $this->checkPermission('write');
2808 
2809  if(!count($_POST['waiting']))
2810  {
2811  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
2812  $this->membersObject();
2813  return false;
2814  }
2815 
2816  include_once('./Modules/Course/classes/class.ilCourseWaitingList.php');
2817  $waiting_list = new ilCourseWaitingList($this->object->getId());
2818 
2819  foreach($_POST["waiting"] as $user_id)
2820  {
2821  $waiting_list->removeFromList($user_id);
2822  $this->object->members_obj->sendNotification($this->object->members_obj->NOTIFY_DISMISS_SUBSCRIBER,$user_id);
2823  }
2824 
2825  ilUtil::sendSuccess($this->lng->txt('crs_users_removed_from_list'));
2826  $this->membersObject();
2827  return true;
2828  }
2829 
2830 
2832  {
2833  global $rbacsystem;
2834 
2835  // MINIMUM ACCESS LEVEL = 'administrate'
2836  $this->checkPermission('write');
2837  /*
2838  if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
2839  {
2840  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
2841  }
2842  */
2843  if(!is_array($_SESSION["crs_delete_waiting_list_ids"]))
2844  {
2845  ilUtil::sendFailure($this->lng->txt("crs_no_users_selected"));
2846  $this->membersObject();
2847 
2848  return false;
2849  }
2850 
2851  $this->object->initWaitingList();
2852  foreach($_SESSION['crs_delete_waiting_list_ids'] as $usr_id)
2853  {
2854  $this->object->waiting_list_obj->removeFromList($usr_id);
2855  }
2856  ilUtil::sendSuccess($this->lng->txt('crs_users_removed_from_list'));
2857  $this->membersObject();
2858 
2859  return true;
2860  }
2861 
2862 
2863  public function assignSubscribersObject()
2864  {
2865  global $rbacsystem,$ilErr;
2866 
2867 
2868  $this->checkPermission('write');
2869 
2870  if(!is_array($_POST["subscribers"]))
2871  {
2872  ilUtil::sendFailure($this->lng->txt("crs_no_subscribers_selected"));
2873  $this->membersObject();
2874 
2875  return false;
2876  }
2877  $this->object->initCourseMemberObject();
2878 
2879  if(!$this->object->members_obj->assignSubscribers($_POST["subscribers"]))
2880  {
2881  ilUtil::sendFailure($ilErr->getMessage());
2882  $this->membersObject();
2883  return false;
2884  }
2885  else
2886  {
2887  foreach($_POST["subscribers"] as $usr_id)
2888  {
2889  $this->object->members_obj->sendNotification($this->object->members_obj->NOTIFY_ACCEPT_SUBSCRIBER,$usr_id);
2890  }
2891  }
2892  ilUtil::sendSuccess($this->lng->txt("crs_subscribers_assigned"));
2893  $this->membersObject();
2894 
2895  return true;
2896  }
2897 
2898  function autoFillObject()
2899  {
2900  global $rbacsystem;
2901 
2902  $this->checkPermission('write');
2903  $this->object->initCourseMemberObject();
2904 
2905  if($this->object->isSubscriptionMembershipLimited() and $this->object->getSubscriptionMaxMembers() and
2906  $this->object->getSubscriptionMaxMembers() <= $this->object->members_obj->getCountMembers())
2907  {
2908  ilUtil::sendFailure($this->lng->txt("crs_max_members_reached"));
2909  $this->membersObject();
2910 
2911  return false;
2912  }
2913  if($number = $this->object->members_obj->autoFillSubscribers())
2914  {
2915  ilUtil::sendSuccess($this->lng->txt("crs_number_users_added")." ".$number);
2916  }
2917  else
2918  {
2919  ilUtil::sendFailure($this->lng->txt("crs_no_users_added"));
2920  }
2921  $this->membersObject();
2922 
2923  return true;
2924  }
2925 
2926 
2928  {
2929  global $rbacsystem;
2930 
2931  $this->tabs_gui->setTabActive('members');
2932 
2933  // MINIMUM ACCESS LEVEL = 'administrate'
2934  $this->checkPermission('write');
2935  /*
2936  if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
2937  {
2938  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
2939  }
2940  */
2941  if(!is_array($_POST["subscriber"]) or !count($_POST["subscriber"]))
2942  {
2943  ilUtil::sendFailure($this->lng->txt("crs_no_subscribers_selected"));
2944  $this->membersObject();
2945 
2946  return false;
2947  }
2948  ilUtil::sendQuestion($this->lng->txt("crs_delete_subscribers_sure"));
2949 
2950  // SHOW DELETE SCREEN
2951  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_editMembers.html",'Modules/Course');
2952  $this->object->initCourseMemberObject();
2953 
2954  // SAVE IDS IN SESSION
2955  $_SESSION["crs_delete_subscriber_ids"] = $_POST["subscriber"];
2956 
2957  $counter = 0;
2958  $f_result = array();
2959 
2960  foreach($_POST["subscriber"] as $member_id)
2961  {
2962  $member_data = $this->object->members_obj->getSubscriberData($member_id);
2963 
2964  // GET USER OBJ
2965  if($tmp_obj = ilObjectFactory::getInstanceByObjId($member_id,false))
2966  {
2967  $f_result[$counter][] = $tmp_obj->getLogin();
2968  $f_result[$counter][] = $tmp_obj->getFirstname();
2969  $f_result[$counter][] = $tmp_obj->getLastname();
2970  $f_result[$counter][] = ilDatePresentation::formatDate(new ilDateTime($member_data['time']),IL_CAL_UNIX);
2971 
2972  unset($tmp_obj);
2973  ++$counter;
2974  }
2975  }
2976  return $this->__showDeleteSubscriberTable($f_result);
2977  }
2978 
2980  {
2981  global $rbacsystem;
2982 
2983  $this->tabs_gui->setTabActive('members');
2984 
2985  // MINIMUM ACCESS LEVEL = 'administrate'
2986  $this->checkPermission('write');
2987  /*
2988  if(!$rbacsystem->checkAccess("write", $this->object->getRefId()))
2989  {
2990  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
2991  }
2992  */
2993  if(!is_array($_POST["waiting_list"]) or !count($_POST["waiting_list"]))
2994  {
2995  ilUtil::sendFailure($this->lng->txt("crs_no_users_selected"));
2996  $this->membersObject();
2997 
2998  return false;
2999  }
3000  ilUtil::sendSuccess($this->lng->txt("crs_delete_from_list_sure"));
3001 
3002  // SHOW DELETE SCREEN
3003  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_editMembers.html",'Modules/Course');
3004  $this->object->initCourseMemberObject();
3005  $this->object->initWaitingList();
3006 
3007  // SAVE IDS IN SESSION
3008  $_SESSION["crs_delete_waiting_list_ids"] = $_POST["waiting_list"];
3009 
3010  $counter = 0;
3011  $f_result = array();
3012 
3013  foreach($_POST["waiting_list"] as $wait_id)
3014  {
3015  $user_data =& $this->object->waiting_list_obj->getUser($wait_id);
3016  // GET USER OBJ
3017  if($tmp_obj = ilObjectFactory::getInstanceByObjId($wait_id,false))
3018  {
3019  $f_result[$counter][] = $tmp_obj->getLogin();
3020  $f_result[$counter][] = $tmp_obj->getFirstname();
3021  $f_result[$counter][] = $tmp_obj->getLastname();
3022  #$f_result[$counter][] = strftime("%Y-%m-%d %R",$user_data["time"]);
3023  $f_result[$counter][] = ilDatePresentation::formatDate(new ilDateTime($user_data['time'],IL_CAL_UNIX));
3024 
3025  unset($tmp_obj);
3026  ++$counter;
3027  }
3028  }
3029  return $this->__showRemoveFromWaitingListTable($f_result);
3030  }
3031 
3032  public function leaveObject()
3033  {
3034  global $ilUser;
3035 
3036  $this->checkPermission('leave');
3037 
3038  if($this->object->members_obj->isLastAdmin($ilUser->getId()))
3039  {
3040  ilUtil::sendFailure($this->lng->txt('crs_min_one_admin'));
3041  $this->viewObject();
3042  return false;
3043  }
3044 
3045 
3046  $this->tabs_gui->setTabActive('crs_unsubscribe');
3047 
3048  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_unsubscribe_sure.html",'Modules/Course');
3049  ilUtil::sendQuestion($this->lng->txt('crs_unsubscribe_sure'));
3050 
3051  $this->tpl->setVariable("UNSUB_FORMACTION",$this->ctrl->getFormAction($this));
3052  $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt("cancel"));
3053  $this->tpl->setVariable("CMD_SUBMIT",'performUnsubscribe');
3054  $this->tpl->setVariable("TXT_SUBMIT",$this->lng->txt("crs_unsubscribe"));
3055  return true;
3056 
3057  }
3058 
3059 
3061  {
3062  global $rbacsystem,$ilAccess;
3063 
3064  // CHECK ACCESS
3065  $this->checkPermission('leave');
3066  /*
3067  if(!$ilAccess->checkAccess("leave",'', $this->ref_id))
3068  {
3069  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
3070  }
3071  */
3072 
3073  $this->tabs_gui->setTabActive('crs_unsubscribe');
3074  #$this->setSubTabs('members');
3075 
3076 
3077  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_unsubscribe_sure.html",'Modules/Course');
3078  ilUtil::sendQuestion($this->lng->txt('crs_unsubscribe_sure'));
3079 
3080  $this->tpl->setVariable("UNSUB_FORMACTION",$this->ctrl->getFormAction($this));
3081  $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt("cancel"));
3082  $this->tpl->setVariable("CMD_SUBMIT",'performUnsubscribe');
3083  $this->tpl->setVariable("TXT_SUBMIT",$this->lng->txt("crs_unsubscribe"));
3084 
3085  return true;
3086  }
3087 
3089  {
3090  global $rbacsystem,$ilUser;
3091 
3092  // CHECK ACCESS
3093  $this->checkPermission('leave');
3094  $this->object->initCourseMemberObject();
3095  $this->object->members_obj->delete($this->ilias->account->getId());
3096  $this->object->members_obj->sendUnsubscribeNotificationToAdmins($this->ilias->account->getId());
3097  $this->object->members_obj->sendNotification($this->object->members_obj->NOTIFY_UNSUBSCRIBE,$ilUser->getId());
3098 
3099  ilUtil::sendSuccess($this->lng->txt('crs_unsubscribed_from_crs'),true);
3100 
3101  ilUtil::redirect("repository.php?ref_id=".$this->tree->getParentId($this->ref_id));
3102  }
3103 
3105  {
3106  global $ilAccess;
3107 
3108  $this->checkPermission('write');
3109 
3110  $this->setSubTabs('members');
3111  $this->tabs_gui->setTabActive('members');
3112  $this->tabs_gui->setSubTabActive('crs_member_administration');
3113 
3114  $participants = array_merge((array) $_POST['admins'],(array) $_POST['tutors'], (array) $_POST['members']);
3115 
3116  if(!$participants)
3117  {
3118  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
3119  $this->membersObject();
3120  return true;
3121  }
3122 
3123  // Check last admin
3124  $this->object->initCourseMemberObject();
3125  if(!$this->object->members_obj->checkLastAdmin($participants))
3126  {
3127  ilUtil::sendFailure($this->lng->txt('crs_at_least_one_admin'));
3128  $this->membersObject();
3129 
3130  return false;
3131  }
3132 
3133  // Access check for admin deletion
3134  if(!$ilAccess->checkAccess('edit_permission', '',$this->object->getRefId()))
3135  {
3136  $part = ilCourseParticipants::_getInstanceByObjId($this->object->getId());
3137 
3138  foreach ($participants as $usr_id)
3139  {
3140  if($part->isAdmin($usr_id))
3141  {
3142  ilUtil::sendFailure($this->lng->txt("msg_no_perm_perm"));
3143  $this->membersObject();
3144  return false;
3145  }
3146  }
3147  }
3148 
3149 
3150  include_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
3151  $confirm = new ilConfirmationGUI();
3152  $confirm->setFormAction($this->ctrl->getFormAction($this,'deleteMembers'));
3153  $confirm->setHeaderText($this->lng->txt('crs_header_delete_members'));
3154  $confirm->setConfirm($this->lng->txt('confirm'),'removeMembers');
3155  $confirm->setCancel($this->lng->txt('cancel'),'members');
3156 
3157  foreach($this->readMemberData($participants) as $participant)
3158  {
3159  $confirm->addItem('participants[]',
3160  $participant['usr_id'],
3161  $participant['lastname'].', '.$participant['firstname'].' ['.$participant['login'].']',
3162  ilUtil::getImagePath('icon_usr.gif'));
3163  }
3164 
3165  $this->tpl->setContent($confirm->getHTML());
3166 
3167  }
3168 
3170  {
3171  global $rbacreview, $rbacsystem;
3172 
3173  $this->checkPermission('write');
3174 
3175  if(!is_array($_POST["participants"]) or !count($_POST["participants"]))
3176  {
3177  ilUtil::sendFailure($this->lng->txt("crs_no_member_selected"));
3178  $this->membersObject();
3179 
3180  return false;
3181  }
3182  $this->object->initCourseMemberObject();
3183 
3184  // If the user doesn't have the edit_permission, he may not remove
3185  // members who have the course administrator role
3186  if (! $rbacsystem->checkAccess('edit_permission', $this->object->getRefId()))
3187  {
3188  // Determine the role id of the course administrator role.
3189  $courseAdminRoleId = null;
3190  foreach ($this->object->getLocalCourseRoles(false) as $title => $role_id)
3191  {
3192  if (substr($title, 0, 12) == 'il_crs_admin')
3193  {
3194  $courseAdminRoleId = $role_id;
3195  }
3196  }
3197 
3198  foreach ($_POST['participants'] as $usr_id)
3199  {
3200  if ($rbacreview->isAssigned($usr_id, $courseAdminRoleId))
3201  {
3202  ilUtil::sendFailure($this->lng->txt("msg_no_perm_perm"));
3203  $this->membersObject();
3204  return false;
3205  }
3206  }
3207  }
3208 
3209  if(!$this->object->members_obj->deleteParticipants($_POST["participants"]))
3210  {
3211  ilUtil::sendFailure($this->object->getMessage());
3212  $this->membersObject();
3213 
3214  return false;
3215  }
3216  else
3217  {
3218  /* do nothing (forum code deleted) */
3219  }
3220  ilUtil::sendSuccess($this->lng->txt("crs_members_deleted"));
3221  $this->membersObject();
3222 
3223  return true;
3224  }
3225 
3227  {
3228  global $rbacsystem;
3229 
3230  $this->checkPermission('write');
3231 
3232  if(!$_POST['subscribers'])
3233  {
3234  ilUtil::sendFailure($this->lng->txt("crs_no_subscribers_selected"));
3235  $this->membersObject();
3236  return false;
3237  }
3238 
3239  $this->object->initCourseMemberObject();
3240 
3241  if(!$this->object->members_obj->deleteSubscribers($_POST["subscribers"]))
3242  {
3243  ilUtil::sendFailure($this->object->getMessage());
3244  $this->membersObject();
3245  return false;
3246  }
3247  else
3248  {
3249  foreach($_POST['subscribers'] as $usr_id)
3250  {
3251  $this->object->members_obj->sendNotification($this->object->members_obj->NOTIFY_DISMISS_SUBSCRIBER,$usr_id);
3252  }
3253  }
3254 
3255  ilUtil::sendSuccess($this->lng->txt("crs_subscribers_deleted"));
3256  $this->membersObject();
3257  return true;
3258  }
3259 
3263  function getTabs(&$tabs_gui)
3264  {
3265  global $rbacsystem,$ilAccess,$ilUser, $lng;
3266 
3267  $this->object->initCourseMemberObject();
3268 
3269  $this->ctrl->setParameter($this,"ref_id",$this->ref_id);
3270 
3271  if($ilAccess->checkAccess('read','',$this->ref_id))
3272  {
3273  $tabs_gui->addTab('view_content', $lng->txt("content"),
3274  $this->ctrl->getLinkTarget($this,''));
3275  }
3276 
3277  if ($ilAccess->checkAccess('visible','',$this->ref_id))
3278  {
3279  //$next_class = $this->ctrl->getNextClass($this);
3280 
3281  // this is not nice. tabs should be displayed in ilcoursegui
3282  // not via ilrepositorygui, then next_class == ilinfoscreengui
3283  // could be checked
3284  $force_active = (strtolower($_GET["cmdClass"]) == "ilinfoscreengui"
3285  || strtolower($_GET["cmdClass"]) == "ilnotegui")
3286  ? true
3287  : false;
3288  $tabs_gui->addTarget("info_short",
3289  $this->ctrl->getLinkTargetByClass(
3290  array("ilobjcoursegui", "ilinfoscreengui"), "showSummary"),
3291  "infoScreen",
3292  "", "", $force_active);
3293  }
3294  if ($ilAccess->checkAccess('write','',$this->ref_id))
3295  {
3296  $force_active = (strtolower($_GET["cmdClass"]) == "ilconditionhandlerinterface"
3297  && $_GET["item_id"] == "")
3298  ? true
3299  : false;
3300  $tabs_gui->addTarget("settings",
3301  $this->ctrl->getLinkTarget($this, "edit"),
3302  array("edit", "editMapSettings", "editCourseIcons", "listStructure"), "", "", $force_active);
3303  }
3304 
3305  // member list
3306  if($ilAccess->checkAccess('write','',$this->ref_id))
3307  {
3308  $tabs_gui->addTarget("members",
3309  $this->ctrl->getLinkTarget($this, "members"),
3310  "members",
3311  get_class($this));
3312  }
3313  elseif ($ilAccess->checkAccess('read','',$this->ref_id) &&
3314  $this->object->getShowMembers() == $this->object->SHOW_MEMBERS_ENABLED &&
3315  $ilUser->getId() != ANONYMOUS_USER_ID)
3316  {
3317  $tabs_gui->addTarget("members",
3318  $this->ctrl->getLinkTarget($this, "membersGallery"),
3319  "members",
3320  get_class($this));
3321  }
3322 
3323  // learning progress
3324  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
3325  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()))
3326  {
3327  $tabs_gui->addTarget('learning_progress',
3328  $this->ctrl->getLinkTargetByClass(array('ilobjcoursegui','illearningprogressgui'),''),
3329  '',
3330  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
3331  }
3332 
3333  // learning objectives
3334  if($ilAccess->checkAccess('write','',$this->ref_id))
3335  {
3336  include_once('./Modules/Course/classes/class.ilCourseObjective.php');
3337  if($this->object->getViewMode() == IL_CRS_VIEW_OBJECTIVE or ilCourseObjective::_getCountObjectives($this->object->getId()))
3338  {
3339  $force_active = (strtolower($_GET["cmdClass"]) == "ilcourseobjectivesgui")
3340  ? true
3341  : false;
3342  $tabs_gui->addTarget("crs_objectives",
3343  $this->ctrl->getLinkTarget($this,"listObjectives"),
3344  "listObjectives",
3345  get_class($this), "", $force_active);
3346  }
3347  }
3348 
3349  // license overview
3350  include_once("Services/License/classes/class.ilLicenseAccess.php");
3351  if ($ilAccess->checkAccess('edit_permission', '', $this->ref_id)
3353  {
3354  $tabs_gui->addTarget("licenses",
3355  $this->ctrl->getLinkTargetByClass('illicenseoverviewgui', ''),
3356  "", "illicenseoverviewgui");
3357  }
3358 
3359  // lom meta data
3360  if ($ilAccess->checkAccess('write','',$this->ref_id))
3361  {
3362  $tabs_gui->addTarget("meta_data",
3363  $this->ctrl->getLinkTargetByClass(array('ilobjcoursegui','ilmdeditorgui'),'listSection'),
3364  "",
3365  "ilmdeditorgui");
3366  }
3367 
3368  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
3369  {
3370  $tabs_gui->addTarget(
3371  'export',
3372  $this->ctrl->getLinkTargetByClass('ilexportgui',''),
3373  'export',
3374  'ilexportgui'
3375  );
3376  }
3377 
3378  if ($ilAccess->checkAccess('edit_permission','',$this->ref_id))
3379  {
3380  $tabs_gui->addTarget("perm_settings",
3381  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
3382  array("perm","info","owner"), 'ilpermissiongui');
3383  }
3384 
3385  if ($this->ctrl->getTargetScript() == "adm_object.php")
3386  {
3387  $tabs_gui->addTarget("show_owner",
3388  $this->ctrl->getLinkTarget($this, "owner"), "owner", get_class($this));
3389 
3390  if ($this->tree->getSavedNodeData($this->ref_id))
3391  {
3392  $tabs_gui->addTarget("trash",
3393  $this->ctrl->getLinkTarget($this, "trash"), "trash", get_class($this));
3394  }
3395  }
3396  // Join/Leave
3397  if($ilAccess->checkAccess('join','',$this->ref_id)
3398  and !$this->object->members_obj->isAssigned($ilUser->getId()))
3399  {
3400  include_once './Modules/Course/classes/class.ilCourseWaitingList.php';
3401  if(ilCourseWaitingList::_isOnList($ilUser->getId(), $this->object->getId()))
3402  {
3403  $tabs_gui->addTab(
3404  'leave',
3405  $this->lng->txt('membership_leave'),
3406  $this->ctrl->getLinkTargetByClass('ilcourseregistrationgui','show','')
3407  );
3408 
3409  }
3410  else
3411  {
3412 
3413  $tabs_gui->addTarget("join",
3414  $this->ctrl->getLinkTargetByClass('ilcourseregistrationgui', "show"),
3415  'show',
3416  "");
3417  }
3418  }
3419  if($ilAccess->checkAccess('leave','',$this->object->getRefId())
3420  and $this->object->members_obj->isMember($ilUser->getId()))
3421  {
3422  $tabs_gui->addTarget("crs_unsubscribe",
3423  $this->ctrl->getLinkTarget($this, "unsubscribe"),
3424  'leave',
3425  "");
3426 
3427  }
3428  }
3429 
3430  function fetchPrintSubscriberData($a_members)
3431  {
3432  foreach($a_members as $member_id)
3433  {
3434 
3435  $member_data = $this->object->members_obj->getSubscriberData($member_id);
3436 
3437  if($tmp_obj = ilObjectFactory::getInstanceByObjId($member_id,false))
3438  {
3439  $print_member[$member_id]['login'] = $tmp_obj->getLogin();
3440  $print_member[$member_id]['name'] = $tmp_obj->getLastname().', '.$tmp_obj->getFirstname();
3441  $print_member[$member_id]['time'] = ilDatePresentation::formatDate(new ilDateTime($member_data['time'],IL_CAL_UNIX));
3442  }
3443  }
3444  switch($_SESSION['crs_print_sort'])
3445  {
3446  case 'lastname':
3447  return ilUtil::sortArray($print_member,'name',$_SESSION['crs_print_order']);
3448 
3449  case 'login':
3450  return ilUtil::sortArray($print_member,'login',$_SESSION['crs_print_order']);
3451 
3452  case 'sub_time':
3453  return ilUtil::sortArray($print_member,'time',$_SESSION['crs_print_order']);
3454 
3455  default:
3456  return ilUtil::sortArray($print_member,'name',$_SESSION['crs_print_order']);
3457  }
3458  }
3459 
3460  function fetchPrintMemberData($a_members)
3461  {
3462  global $ilAccess,$lng;
3463 
3464  $lng->loadLanguageModule('trac');
3465 
3466  #$is_admin = (bool) $ilAccess->checkAccess("write",'',$this->object->getRefId());
3467  $is_admin = true;
3468 
3469  include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
3470  $privacy = ilPrivacySettings::_getInstance();
3471 
3472  if($privacy->enabledCourseAccessTimes())
3473  {
3474  include_once('./Services/Tracking/classes/class.ilLearningProgress.php');
3475  $progress = ilLearningProgress::_lookupProgressByObjId($this->object->getId());
3476  }
3477 
3478  if($this->show_tracking)
3479  {
3480  include_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
3481  $completed = ilLPStatusWrapper::_getCompleted($this->object->getId());
3482  $in_progress = ilLPStatusWrapper::_getInProgress($this->object->getId());
3483  $not_attempted = ilLPStatusWrapper::_getNotAttempted($this->object->getId());
3484  $failed = ilLPStatusWrapper::_getFailed($this->object->getId());
3485  }
3486 
3487  foreach($a_members as $member_id)
3488  {
3489  // GET USER OBJ
3490  if($tmp_obj = ilObjectFactory::getInstanceByObjId($member_id,false))
3491  {
3492  $print_member[$member_id]['login'] = $tmp_obj->getLogin();
3493  $print_member[$member_id]['name'] = $tmp_obj->getLastname().', '.$tmp_obj->getFirstname();
3494 
3495  if($this->object->members_obj->isAdmin($member_id))
3496  {
3497  $print_member[$member_id]['role'] = $this->lng->txt("il_crs_admin");
3498  }
3499  elseif($this->object->members_obj->isTutor($member_id))
3500  {
3501  $print_member[$member_id]['role'] = $this->lng->txt("il_crs_tutor");
3502  }
3503  elseif($this->object->members_obj->isMember($member_id))
3504  {
3505  $print_member[$member_id]['role'] = $this->lng->txt("il_crs_member");
3506  }
3507  if($this->object->members_obj->isAdmin($member_id) or $this->object->members_obj->isTutor($member_id))
3508  {
3509  if($this->object->members_obj->isNotificationEnabled($member_id))
3510  {
3511  $print_member[$member_id]['status'] = $this->lng->txt("crs_notify");
3512  }
3513  else
3514  {
3515  $print_member[$member_id]['status'] = $this->lng->txt("crs_no_notify");
3516  }
3517  }
3518  else
3519  {
3520  if($this->object->members_obj->isBlocked($member_id))
3521  {
3522  $print_member[$member_id]['status'] = $this->lng->txt("crs_blocked");
3523  }
3524  else
3525  {
3526  $print_member[$member_id]['status'] = $this->lng->txt("crs_unblocked");
3527  }
3528  }
3529 
3530  if($is_admin)
3531  {
3532  $print_member[$member_id]['passed'] = $this->object->members_obj->hasPassed($member_id) ?
3533  $this->lng->txt('crs_member_passed') :
3534  $this->lng->txt('crs_member_not_passed');
3535 
3536  }
3537  if($privacy->enabledCourseAccessTimes())
3538  {
3539  if(isset($progress[$member_id]['ts']) and $progress[$member_id]['ts'])
3540  {
3542  $print_member[$member_id]['access'] = ilDatePresentation::formatDate(new ilDateTime($progress[$member_id]['ts'],IL_CAL_UNIX));
3544  }
3545  else
3546  {
3547  $print_member[$member_id]['access'] = $this->lng->txt('no_date');
3548  }
3549  }
3550  if($this->show_tracking)
3551  {
3552  if(in_array($member_id,$completed))
3553  {
3554  $print_member[$member_id]['progress'] = $this->lng->txt(LP_STATUS_COMPLETED);
3555  }
3556  elseif(in_array($member_id,$in_progress))
3557  {
3558  $print_member[$member_id]['progress'] = $this->lng->txt(LP_STATUS_IN_PROGRESS);
3559  }
3560  elseif(in_array($member_id,$failed))
3561  {
3562  $print_member[$member_id]['progress'] = $this->lng->txt(LP_STATUS_FAILED);
3563  }
3564  else
3565  {
3566  $print_member[$member_id]['progress'] = $this->lng->txt(LP_STATUS_NOT_ATTEMPTED);
3567  }
3568  }
3569 
3570  }
3571  }
3572 
3573  switch($_SESSION['crs_print_sort'])
3574  {
3575  case 'progress':
3576  return ilUtil::sortArray($print_member,'progress',$_SESSION['crs_print_order']);
3577 
3578  case 'access_time':
3579  return ilUtil::sortArray($print_member,'access',$_SESSION['crs_print_order']);
3580 
3581  case 'lastname':
3582  return ilUtil::sortArray($print_member,'name',$_SESSION['crs_print_order']);
3583 
3584  case 'login':
3585  return ilUtil::sortArray($print_member,'login',$_SESSION['crs_print_order']);
3586 
3587  case 'passed':
3588  return ilUtil::sortArray($print_member,'passed',$_SESSION['crs_print_order']);
3589 
3590  case 'blocked':
3591  case 'notification':
3592  return ilUtil::sortArray($print_member,'status',$_SESSION['crs_print_order']);
3593 
3594  default:
3595  return ilUtil::sortArray($print_member,'name',$_SESSION['crs_print_order']);
3596  }
3597  }
3598 
3599 
3601  {
3602  global $rbacsystem;
3603 
3604  $this->checkPermission('write');
3605 
3606  $is_admin = true;
3607  $tpl = new ilTemplate('tpl.crs_members_print.html',true,true,'Modules/Course');
3608 
3609  $this->object->initCourseMemberObject();
3610 
3611  include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
3612  $privacy = ilPrivacySettings::_getInstance();
3613  if($privacy->enabledCourseAccessTimes())
3614  {
3615  include_once('./Services/Tracking/classes/class.ilLearningProgress.php');
3616  $progress = ilLearningProgress::_lookupProgressByObjId($this->object->getId());
3617  }
3618 
3619  include_once './Services/Tracking/classes/class.ilObjUserTracking.php';
3620  include_once('./Services/Tracking/classes/class.ilLPObjSettings.php');
3621  $this->show_tracking = (ilObjUserTracking::_enabledLearningProgress() and
3623  ilLPObjSettings::_lookupMode($this->object->getId()) != LP_MODE_DEACTIVATED);
3624 
3625 
3626  // MEMBERS
3627  if(count($members = $this->object->members_obj->getParticipants()))
3628  {
3629  $members = $this->fetchPrintMemberData($members);
3630 
3631  foreach($members as $member_data)
3632  {
3633  if($this->show_tracking)
3634  {
3635  $tpl->setCurrentBlock('progress_row');
3636  $tpl->setVariable('VAL_PROGRESS',$member_data['progress']);
3637  $tpl->parseCurrentBlock();
3638  }
3639 
3640  if($privacy->enabledCourseAccessTimes())
3641  {
3642  $tpl->setCurrentBlock('access_row');
3643  $tpl->setVariable('VAL_ACCESS',$member_data['access']);
3644  $tpl->parseCurrentBlock();
3645  }
3646  $tpl->setCurrentBlock("members_row");
3647  $tpl->setVariable("LOGIN",$member_data['login']);
3648  $tpl->setVariable("NAME",$member_data['name']);
3649  $tpl->setVariable("ROLE",$member_data['role']);
3650  $tpl->setVariable("STATUS",$member_data['status']);
3651  $tpl->setVariable("PASSED",$member_data['passed']);
3652 
3653  if($is_admin)
3654  {
3655  $tpl->setVariable("STATUS",$member_data['status']);
3656  $tpl->setVariable("PASSED",$member_data['passed']);
3657  }
3658  $tpl->parseCurrentBlock();
3659  }
3660 
3661  $tpl->setCurrentBlock("members");
3662  $tpl->setVariable("MEMBERS_IMG_SOURCE",ilUtil::getImagePath('icon_usr.gif'));
3663  $tpl->setVariable("MEMBERS_IMG_ALT",$this->lng->txt('crs_header_members'));
3664  $tpl->setVariable("MEMBERS_TABLE_HEADER",$this->lng->txt('crs_members_table'));
3665  $tpl->setVariable("TXT_LOGIN",$this->lng->txt('username'));
3666  $tpl->setVariable("TXT_NAME",$this->lng->txt('name'));
3667  $tpl->setVariable("TXT_ROLE",$this->lng->txt('crs_role'));
3668 
3669  if($this->show_tracking)
3670  {
3671  $tpl->setCurrentBlock('progress');
3672  $tpl->setVariable('TXT_PROGRESS',$this->lng->txt('learning_progress'));
3673  $tpl->parseCurrentBlock();
3674  }
3675 
3676  if($privacy->enabledCourseAccessTimes())
3677  {
3678  $tpl->setCurrentBlock('access');
3679  $tpl->setVariable('TXT_ACCESS',$this->lng->txt('last_access'));
3680  $tpl->parseCurrentBlock();
3681  }
3682 
3683 
3684  if($is_admin)
3685  {
3686  $tpl->setVariable("TXT_STATUS",$this->lng->txt('crs_status'));
3687  $tpl->setVariable("TXT_PASSED",$this->lng->txt('crs_passed'));
3688  }
3689 
3690  $tpl->parseCurrentBlock();
3691 
3692  }
3693  // SUBSCRIBERS
3694  if(count($members = $this->object->members_obj->getSubscribers()))
3695  {
3696  $members = $this->fetchPrintSubscriberData($members);
3697  foreach($members as $member_data)
3698  {
3699  $tpl->setCurrentBlock("subscribers_row");
3700  $tpl->setVariable("SLOGIN",$member_data['login']);
3701  $tpl->setVariable("SNAME",$member_data['name']);
3702  $tpl->setVariable("STIME",$member_data["time"]);
3703  $tpl->parseCurrentBlock();
3704  }
3705 
3706  $tpl->setCurrentBlock("subscribers");
3707  $tpl->setVariable("SUBSCRIBERS_IMG_SOURCE",ilUtil::getImagePath('icon_usr.gif'));
3708  $tpl->setVariable("SUBSCRIBERS_IMG_ALT",$this->lng->txt('crs_subscribers'));
3709  $tpl->setVariable("SUBSCRIBERS_TABLE_HEADER",$this->lng->txt('crs_subscribers'));
3710  $tpl->setVariable("TXT_SLOGIN",$this->lng->txt('username'));
3711  $tpl->setVariable("TXT_SNAME",$this->lng->txt('name'));
3712  $tpl->setVariable("TXT_STIME",$this->lng->txt('crs_time'));
3713  $tpl->parseCurrentBlock();
3714 
3715  }
3716 
3717  $tpl->setVariable("TITLE",$this->lng->txt('crs_members_print_title'));
3718  $tpl->setVariable("CSS_PATH",ilUtil::getStyleSheetLocation());
3719 
3720  $headline = $this->lng->txt('obj_crs').': '.$this->object->getTitle().
3721  ' -> '.$this->lng->txt('crs_header_members').' ('.ilFormat::formatUnixTime(time(),true).')';
3722 
3723  $tpl->setVariable("HEADLINE",$headline);
3724 
3725  $tpl->show();
3726  exit;
3727  }
3728 
3729  /*
3730  * @author Arturo Gonzalez <arturogf@gmail.com>
3731  * @access public
3732  */
3734  {
3735 
3736  global $rbacsystem, $ilErr, $ilAccess, $ilUser;
3737 
3738  $is_admin = (bool) $ilAccess->checkAccess("write", "", $this->object->getRefId());
3739 
3740  if (!$is_admin &&
3741  $this->object->getShowMembers() == $this->object->SHOW_MEMBERS_DISABLED)
3742  {
3743  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"),$ilErr->MESSAGE);
3744  }
3745 
3746 
3747  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.crs_members_gallery.html','Modules/Course');
3748 
3749  $this->setSubTabs('members');
3750  $this->tabs_gui->setTabActive('members');
3751  $this->tabs_gui->setSubTabActive('crs_members_gallery');
3752 
3753  $this->object->initCourseMemberObject();
3754 
3755  // MEMBERS
3756  if(count($members = $this->object->members_obj->getParticipants()))
3757  {
3758  $ordered_members = array();
3759 
3760  foreach($members as $member_id)
3761  {
3762  if(!($usr_obj = ilObjectFactory::getInstanceByObjId($member_id,false)))
3763  {
3764  continue;
3765  }
3766 
3767  // please do not use strtoupper on first/last name for output
3768  // this messes up with some unicode characters, i guess
3769  // depending on php verion, alex
3770  array_push($ordered_members,array("id" => $member_id,
3771  "login" => $usr_obj->getLogin(),
3772  "lastname" => $usr_obj->getLastName(),
3773  "firstname" => $usr_obj->getFirstName(),
3774  "sortlastname" => strtoupper($usr_obj->getLastName()).strtoupper($usr_obj->getFirstName()),
3775  "usr_obj" => $usr_obj));
3776  }
3777 
3778  $ordered_members=ilUtil::sortArray($ordered_members,"sortlastname","asc");
3779 
3780  foreach($ordered_members as $member)
3781  {
3782  $usr_obj = $member["usr_obj"];
3783 
3784  if(!$usr_obj->getActive())
3785  {
3786  continue;
3787  }
3788 
3789  $public_profile = in_array($usr_obj->getPref("public_profile"), array("y", "g")) ? "y" : "";
3790 
3791  // SET LINK TARGET FOR USER PROFILE
3792  $this->ctrl->setParameterByClass("ilpublicuserprofilegui", "user", $member["id"]);
3793  $profile_target = $this->ctrl->getLinkTargetByClass("ilpublicuserprofilegui","getHTML");
3794 
3795  // GET USER IMAGE
3796  $file = $usr_obj->getPersonalPicturePath("xsmall");
3797 
3798  if($this->object->members_obj->isAdmin($member["id"]) or $this->object->members_obj->isTutor($member["id"]))
3799  {
3800  if ($public_profile == "y")
3801  {
3802  $this->tpl->setCurrentBlock("tutor_linked");
3803  $this->tpl->setVariable("LINK_PROFILE", $profile_target);
3804  $this->tpl->setVariable("SRC_USR_IMAGE", $file);
3805  $this->tpl->parseCurrentBlock();
3806  }
3807  else
3808  {
3809  $this->tpl->setCurrentBlock("tutor_not_linked");
3810  $this->tpl->setVariable("SRC_USR_IMAGE", $file);
3811  $this->tpl->parseCurrentBlock();
3812  }
3813  $this->tpl->setCurrentBlock("tutor");
3814  }
3815  else
3816  {
3817  if ($public_profile == "y")
3818  {
3819  $this->tpl->setCurrentBlock("member_linked");
3820  $this->tpl->setVariable("LINK_PROFILE", $profile_target);
3821  $this->tpl->setVariable("SRC_USR_IMAGE", $file);
3822  $this->tpl->parseCurrentBlock();
3823  }
3824  else
3825  {
3826  $this->tpl->setCurrentBlock("member_not_linked");
3827  $this->tpl->setVariable("SRC_USR_IMAGE", $file);
3828  $this->tpl->parseCurrentBlock();
3829  }
3830  $this->tpl->setCurrentBlock("member");
3831  }
3832 
3833  // do not show name, if public profile is not activated
3834  if ($public_profile == "y")
3835  {
3836  $this->tpl->setVariable("FIRSTNAME", $member["firstname"]);
3837  $this->tpl->setVariable("LASTNAME", $member["lastname"]);
3838  }
3839  $this->tpl->setVariable("LOGIN", $member["login"]);
3840  $this->tpl->parseCurrentBlock();
3841 
3842  }
3843  $this->tpl->setCurrentBlock("members");
3844  $this->tpl->setVariable("MEMBERS_TABLE_HEADER",$this->lng->txt('crs_members_title'));
3845  $this->tpl->parseCurrentBlock();
3846 
3847  }
3848 
3849  $this->tpl->setVariable("TITLE",$this->lng->txt('crs_members_print_title'));
3850  $this->tpl->setVariable("CSS_PATH",ilUtil::getStyleSheetLocation());
3851 
3852  $headline = $this->object->getTitle()."<br/>".$this->object->getDescription();
3853 
3854  $this->tpl->setVariable("HEADLINE",$headline);
3855 
3856  $this->tpl->show();
3857  exit;
3858  }
3859 
3860 
3861  function __initTableGUI()
3862  {
3863  include_once "./Services/Table/classes/class.ilTableGUI.php";
3864 
3865  return new ilTableGUI(0,false);
3866  }
3867 
3868 
3869  function __setTableGUIBasicData(&$tbl,&$result_set,$from = "")
3870  {
3871  switch($from)
3872  {
3873  case "members":
3874  $offset = $_GET["update_members"] ? $_GET["offset"] : 0;
3875  $order = $_GET["update_members"] ? $_GET["sort_by"] : 'login';
3876  $direction = $_GET["update_members"] ? $_GET["sort_order"] : '';
3877  break;
3878 
3879  case "subscribers":
3880  $offset = $_GET["update_subscribers"] ? $_GET["offset"] : 0;
3881  $order = $_GET["update_subscribers"] ? $_GET["sort_by"] : 'sub_time';
3882  $direction = $_GET["update_subscribers"] ? $_GET["sort_order"] : '';
3883  break;
3884 
3885  case "group":
3886  $offset = $_GET["offset"];
3887  $order = $_GET["sort_by"] ? $_GET["sort_by"] : "title";
3888  $direction = $_GET["sort_order"];
3889  break;
3890 
3891  case "role":
3892  $offset = $_GET["offset"];
3893  $order = $_GET["sort_by"] ? $_GET["sort_by"] : "title";
3894  $direction = $_GET["sort_order"];
3895  break;
3896 
3897  default:
3898  $offset = $_GET["offset"];
3899  // init sort_by (unfortunatly sort_by is preset with 'title'
3900  if ($_GET["sort_by"] == "title" or empty($_GET["sort_by"]))
3901  {
3902  $_GET["sort_by"] = "login";
3903  }
3904  $order = $_GET["sort_by"];
3905  $direction = $_GET["sort_order"];
3906  break;
3907  }
3908 
3909  $tbl->setOrderColumn($order);
3910  $tbl->setOrderDirection($direction);
3911  $tbl->setOffset($offset);
3912  $tbl->setLimit($_GET["limit"]);
3913  $tbl->setMaxCount(count($result_set));
3914  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
3915  $tbl->setData($result_set);
3916  }
3917 
3918 
3919  function __showRemoveFromWaitingListTable($a_result_set)
3920  {
3921  $tbl =& $this->__initTableGUI();
3922  $tpl =& $tbl->getTemplateObject();
3923 
3924  $tpl->setCurrentBlock("tbl_form_header");
3925  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
3926  $tpl->parseCurrentBlock();
3927  $tpl->setCurrentBlock("tbl_action_btn");
3928  $tpl->setVariable("BTN_NAME","cancelMember");
3929  $tpl->setVariable("BTN_VALUE",$this->lng->txt("cancel"));
3930  $tpl->parseCurrentBlock();
3931  $tpl->setCurrentBlock("tbl_action_btn");
3932  $tpl->setVariable("BTN_NAME","performRemoveFromWaitingList");
3933  $tpl->setVariable("BTN_VALUE",$this->lng->txt("delete"));
3934  $tpl->parseCurrentBlock();
3935  $tpl->setCurrentBlock("tbl_action_row");
3936  $tpl->setVariable("COLUMN_COUNTS",4);
3937  $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
3938  $tpl->parseCurrentBlock();
3939 
3940  $tbl->setTitle($this->lng->txt("crs_header_remove_from_waiting_list"),"icon_usr_b.gif",
3941  $this->lng->txt("crs_header_remove_from_waiting_list"));
3942  $tbl->setHeaderNames(array($this->lng->txt("username"),
3943  $this->lng->txt("firstname"),
3944  $this->lng->txt("lastname"),
3945  $this->lng->txt("crs_time")));
3946  $tbl->setHeaderVars(array("login",
3947  "firstname",
3948  "lastname",
3949  "sub_time"),
3950  array("ref_id" => $this->object->getRefId(),
3951  "cmd" => "members",
3952  "cmdClass" => "ilobjcoursegui",
3953  "cmdNode" => $_GET["cmdNode"]));
3954 
3955  $tbl->setColumnWidth(array("25%","25%","25%","25%"));
3956 
3957  $this->__setTableGUIBasicData($tbl,$a_result_set);
3958  $tbl->render();
3959 
3960  $this->tpl->setVariable("EDIT_MEMBER_TABLE",$tbl->tpl->get());
3961 
3962  return true;
3963  }
3964 
3965  function __showDeleteSubscriberTable($a_result_set)
3966  {
3967  $tbl =& $this->__initTableGUI();
3968  $tpl =& $tbl->getTemplateObject();
3969 
3970  $tpl->setCurrentBlock("tbl_form_header");
3971  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
3972  $tpl->parseCurrentBlock();
3973  $tpl->setCurrentBlock("tbl_action_btn");
3974  $tpl->setVariable("BTN_NAME","removeSubscribers");
3975  $tpl->setVariable("BTN_VALUE",$this->lng->txt("delete"));
3976  $tpl->parseCurrentBlock();
3977  $tpl->setCurrentBlock("tbl_action_btn");
3978  $tpl->setVariable("BTN_NAME","cancelMember");
3979  $tpl->setVariable("BTN_VALUE",$this->lng->txt("cancel"));
3980  $tpl->parseCurrentBlock();
3981  $tpl->setCurrentBlock("tbl_action_row");
3982  $tpl->setVariable("COLUMN_COUNTS",4);
3983  $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
3984  $tpl->parseCurrentBlock();
3985 
3986  $tbl->setTitle($this->lng->txt("crs_header_delete_subscribers"),"icon_usr_b.gif",$this->lng->txt("crs_header_delete_members"));
3987  $tbl->setHeaderNames(array($this->lng->txt("username"),
3988  $this->lng->txt("firstname"),
3989  $this->lng->txt("lastname"),
3990  $this->lng->txt("crs_time")));
3991  $tbl->setHeaderVars(array("login",
3992  "firstname",
3993  "lastname",
3994  "sub_time"),
3995  array("ref_id" => $this->object->getRefId(),
3996  "cmd" => "members",
3997  "cmdClass" => "ilobjcoursegui",
3998  "cmdNode" => $_GET["cmdNode"]));
3999 
4000  $tbl->setColumnWidth(array("25%","25%","25%","25%"));
4001 
4002  $this->__setTableGUIBasicData($tbl,$a_result_set);
4003  $tbl->render();
4004 
4005  $this->tpl->setVariable("EDIT_MEMBER_TABLE",$tbl->tpl->get());
4006 
4007  return true;
4008  }
4009 
4010 
4011 
4012  function __showSubscribersTable($a_result_set,$a_subscriber_ids = NULL)
4013  {
4014  $actions = array("addSubscribers" => $this->lng->txt("crs_add_subscribers"),
4015  "deleteSubscribers" => $this->lng->txt("crs_delete_subscribers"));
4016 
4017  $tbl =& $this->__initTableGUI();
4018  $tpl =& $tbl->getTemplateObject();
4019 
4020  // SET FOOTER BUTTONS
4021  $tpl->setCurrentBlock("tbl_action_row");
4022 
4023  // BUTTONS FOR ADD USER
4024  $tpl->setCurrentBlock("plain_button");
4025  $tpl->setVariable("PBTN_NAME","autoFill");
4026  $tpl->setVariable("PBTN_VALUE",$this->lng->txt("crs_auto_fill"));
4027  $tpl->parseCurrentBlock();
4028  $tpl->setCurrentBlock("plain_buttons");
4029  $tpl->parseCurrentBlock();
4030 
4031  $tpl->setVariable("COLUMN_COUNTS",4);
4032 
4033  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
4034 
4035  $tpl->setCurrentBlock("tbl_action_select");
4036  $tpl->setVariable("SELECT_ACTION",ilUtil::formSelect(1,"action",$actions,false,true));
4037  $tpl->setVariable("BTN_NAME","gateway");
4038  $tpl->setVariable("BTN_VALUE",$this->lng->txt("execute"));
4039  $tpl->parseCurrentBlock();
4040 
4041  $tbl->enable('select_all');
4042  $tbl->setFormName("subscriber_form");
4043  $tbl->setSelectAllCheckbox("subscriber");
4044 
4045  $tpl->setCurrentBlock("tbl_action_row");
4046  $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
4047  $tpl->parseCurrentBlock();
4048 
4049 
4050  $tbl->setTitle($this->lng->txt("crs_subscribers"),"icon_usr.gif",$this->lng->txt("crs_header_members"));
4051  $tbl->setHeaderNames(array('',
4052  $this->lng->txt("name"),
4053  $this->lng->txt("login"),
4054  $this->lng->txt("crs_time")));
4055  $tbl->setHeaderVars(array("",
4056  "name",
4057  "login",
4058  "sub_time"),
4059  array("ref_id" => $this->object->getRefId(),
4060  "cmd" => "members",
4061  "update_subscribers" => 1,
4062  "cmdClass" => "ilobjcoursegui",
4063  "cmdNode" => $_GET["cmdNode"]));
4064  $tbl->setColumnWidth(array('1%'));
4065 
4066  $this->__setTableGUIBasicData($tbl,$a_result_set,"subscribers");
4067  $tbl->render();
4068 
4069  $this->tpl->setCurrentBlock('sub_wait_table');
4070  $this->tpl->setVariable('SUB_WAIT_NAME','subscriber_form');
4071  $this->tpl->setVariable('SUB_WAIT_FORMACTION',$this->ctrl->getFormAction($this));
4072  $this->tpl->setVariable("SUB_WAIT_TABLE_CONTENT",$tbl->tpl->get());
4073  $this->tpl->parseCurrentBlock();
4074 
4075  return true;
4076  }
4077  function __showWaitingListTable($a_result_set,$a_waiting_list_ids = NULL)
4078  {
4079  $actions = array("addFromWaitingList" => $this->lng->txt("crs_add_subscribers"),
4080  "removeFromWaitingList" => $this->lng->txt("crs_delete_from_waiting_list"));
4081 
4082  $tbl =& $this->__initTableGUI();
4083  $tpl =& $tbl->getTemplateObject();
4084 
4085  $tbl->enable('select_all');
4086  $tbl->setFormName("wait_form");
4087  $tbl->setSelectAllCheckbox("waiting_list");
4088 
4089 
4090  // SET FOOTER BUTTONS
4091  $tpl->setCurrentBlock("tbl_action_row");
4092 
4093  $tpl->setVariable("COLUMN_COUNTS",5);
4094 
4095  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
4096 
4097  $tpl->setCurrentBlock("tbl_action_select");
4098  $tpl->setVariable("SELECT_ACTION",ilUtil::formSelect(1,"action",$actions,false,true));
4099  $tpl->setVariable("BTN_NAME","gateway");
4100  $tpl->setVariable("BTN_VALUE",$this->lng->txt("execute"));
4101  $tpl->parseCurrentBlock();
4102 
4103  $tpl->setCurrentBlock("tbl_action_row");
4104  $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
4105  $tpl->parseCurrentBlock();
4106 
4107 
4108  $tbl->setTitle($this->lng->txt("crs_waiting_list"),"icon_usr.gif",$this->lng->txt("crs_waiting_list"));
4109  $tbl->setHeaderNames(array('',
4110  $this->lng->txt("name"),
4111  $this->lng->txt("login"),
4112  $this->lng->txt("crs_time")));
4113  $tbl->setHeaderVars(array("",
4114  "name",
4115  "login",
4116  "sub_time"),
4117  array("ref_id" => $this->object->getRefId(),
4118  "cmd" => "members",
4119  "update_subscribers" => 1,
4120  "cmdClass" => "ilobjcoursegui",
4121  "cmdNode" => $_GET["cmdNode"]));
4122  $tbl->setColumnWidth(array('1%'));
4123 
4124  $this->__setTableGUIBasicData($tbl,$a_result_set,"subscribers");
4125  $tbl->render();
4126 
4127  $this->tpl->setCurrentBlock('sub_wait_table');
4128  $this->tpl->setVariable('SUB_WAIT_NAME','wait_form');
4129  $this->tpl->setVariable('SUB_WAIT_FORMACTION',$this->ctrl->getFormAction($this));
4130  $this->tpl->setVariable("SUB_WAIT_TABLE_CONTENT",$tbl->tpl->get());
4131  $this->tpl->parseCurrentBlock();
4132 
4133  return true;
4134  }
4135 
4136 
4137 
4138  function __getDateSelect($a_type,$a_varname,$a_selected)
4139  {
4140  switch($a_type)
4141  {
4142  case "minute":
4143  for($i=0;$i<=60;$i++)
4144  {
4145  $days[$i] = $i < 10 ? "0".$i : $i;
4146  }
4147  return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
4148 
4149  case "hour":
4150  for($i=0;$i<24;$i++)
4151  {
4152  $days[$i] = $i < 10 ? "0".$i : $i;
4153  }
4154  return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
4155 
4156  case "day":
4157  for($i=1;$i<32;$i++)
4158  {
4159  $days[$i] = $i < 10 ? "0".$i : $i;
4160  }
4161  return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
4162 
4163  case "month":
4164  for($i=1;$i<13;$i++)
4165  {
4166  $month[$i] = $i < 10 ? "0".$i : $i;
4167  }
4168  return ilUtil::formSelect($a_selected,$a_varname,$month,false,true);
4169 
4170  case "year":
4171  for($i = date("Y",time());$i < date("Y",time()) + 3;++$i)
4172  {
4173  $year[$i] = $i;
4174  }
4175  return ilUtil::formSelect($a_selected,$a_varname,$year,false,true);
4176  }
4177  }
4178 
4179  function __toUnix($a_time_arr)
4180  {
4181  return mktime($a_time_arr["hour"],
4182  $a_time_arr["minute"],
4183  $a_time_arr["second"],
4184  $a_time_arr["month"],
4185  $a_time_arr["day"],
4186  $a_time_arr["year"]);
4187  }
4189  {
4190  unset($_SESSION["crs_delete_member_ids"]);
4191  unset($_SESSION["crs_delete_subscriber_ids"]);
4192  unset($_SESSION["crs_search_str"]);
4193  unset($_SESSION["crs_search_for"]);
4194  unset($_SESSION["crs_group"]);
4195  unset($_SESSION["crs_role"]);
4196  unset($_SESSION["crs_archives"]);
4197  }
4198 
4200  {
4201  global $rbacreview, $ilErr, $ilAccess, $ilObjDataCache, $ilias;
4202  include_once('./Services/AccessControl/classes/class.ilObjRole.php');
4203 
4204  $this->lng->loadLanguageModule('mail');
4205  ilUtil::sendInfo($this->lng->txt('mail_select_recipients'));
4206 
4207  $is_admin = (bool) $ilAccess->checkAccess("write", "", $this->object->getRefId());
4208 
4209  if (!$is_admin &&
4210  $this->object->getShowMembers() == $this->object->SHOW_MEMBERS_DISABLED)
4211  {
4212  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"),$ilErr->MESSAGE);
4213  }
4214 
4215  $this->setSubTabs('members');
4216  $this->tabs_gui->setTabActive('members');
4217  $this->tabs_gui->setSubTabActive('mail_members');
4218 
4219  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.mail_members.html','Services/Contact');
4220 
4221 
4222  require_once 'Services/Mail/classes/class.ilMailFormCall.php';
4223  $this->tpl->setVariable("MAILACTION", ilMailFormCall::_getLinkTarget($this, 'members', array(), array('type' => 'role', 'sig' => $this->createMailSignature())));
4224  $this->tpl->setVariable("SELECT_ACTION",'ilias.php?baseClass=ilmailgui&view=my_courses&search_crs='.$this->object->getId());
4225  $this->tpl->setVariable("MAIL_SELECTED",$this->lng->txt('send_mail_selected'));
4226  $this->tpl->setVariable("MAIL_MEMBERS",$this->lng->txt('send_mail_members'));
4227  $this->tpl->setVariable("MAIL_TUTOR",$this->lng->txt('send_mail_tutors'));
4228  $this->tpl->setVariable("MAIL_ADMIN",$this->lng->txt('send_mail_admins'));
4229  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
4230  $this->tpl->setVariable("OK",$this->lng->txt('next'));
4231 
4232  // Display roles with user friendly mailbox addresses
4233  $role_folder = $rbacreview->getRoleFolderOfObject($this->object->getRefId());
4234  $role_ids = $rbacreview->getRolesOfRoleFolder($role_folder['ref_id'], false);
4235 
4236  // Sort by relevance
4237  $sorted_role_ids = array();
4238  $counter = 3;
4239  foreach($role_ids as $role_id)
4240  {
4241  switch(substr(ilObject::_lookupTitle($role_id),0,8))
4242  {
4243  case 'il_crs_a':
4244  $sorted_role_ids[2] = $role_id;
4245  break;
4246 
4247  case 'il_crs_t':
4248  $sorted_role_ids[1] = $role_id;
4249  break;
4250 
4251  case 'il_crs_m':
4252  $sorted_role_ids[0] = $role_id;
4253  break;
4254 
4255  default:
4256  $sorted_role_ids[$counter++] = $role_id;
4257  break;
4258  }
4259  }
4260 
4261  ksort($sorted_role_ids,SORT_NUMERIC);
4262  foreach ((array) $sorted_role_ids as $role_id)
4263  {
4264  $this->tpl->setCurrentBlock("mailbox_row");
4265  $role_addr = $rbacreview->getRoleMailboxAddress($role_id);
4266 
4267  // check if role title is unique. if not force use pear mail for roles
4268  $ids_for_role_title = ilObject::_getIdsForTitle(ilObject::_lookupTitle($role_id), 'role');
4269  if(count($ids_for_role_title) >= 2)
4270  {
4271  $ilias->setSetting('pear_mail_enable',true);
4272  }
4273 
4274  $this->tpl->setVariable("CHECK_MAILBOX",ilUtil::formCheckbox(1,'roles[]',
4275  htmlspecialchars($role_addr)
4276  ));
4277  if (ilMail::_usePearMail())
4278  {
4279  // if pear mail is enabled, mailbox addresses are already localized in the language of the user
4280  $this->tpl->setVariable("MAILBOX",$role_addr);
4281  }
4282  else
4283  {
4284  // if pear mail is not enabled, we need to localize mailbox addresses in the language of the user
4285  $this->tpl->setVariable("MAILBOX",ilObjRole::_getTranslation($ilObjDataCache->lookupTitle($role_id)). " (" . $role_addr . ")");
4286  }
4287 
4288  $this->tpl->parseCurrentBlock();
4289  }
4290  }
4291 
4292  function executeCommand()
4293  {
4294  global $rbacsystem,$ilUser,$ilAccess,$ilErr,$ilTabs,$ilNavigationHistory,$ilCtrl;
4295 
4296  $next_class = $this->ctrl->getNextClass($this);
4297  $cmd = $this->ctrl->getCmd();
4298 
4299  $this->prepareOutput();
4300 
4301  // add entry to navigation history
4302  if(!$this->getCreationMode() &&
4303  $ilAccess->checkAccess('read', '', $_GET['ref_id']))
4304  {
4305  $ilNavigationHistory->addItem($_GET['ref_id'],
4306  'repository.php?cmd=frameset&ref_id='.$_GET['ref_id'], 'crs');
4307  }
4308 
4309  if(!$this->getCreationMode())
4310  {
4311  if(IS_PAYMENT_ENABLED)
4312  {
4313  include_once 'Services/Payment/classes/class.ilPaymentObject.php';
4314  if(ilPaymentObject::_isBuyable($this->object->getRefId()) &&
4315  !ilPaymentObject::_hasAccess($this->object->getRefId()))
4316  {
4317  $ilTabs->setTabActive('info_short');
4318 
4319  include_once 'Services/Payment/classes/class.ilShopPurchaseGUI.php';
4320  $this->ctrl->setReturn($this, '');
4321  $pp_gui = new ilShopPurchaseGUI($this->object->getRefId());
4322  $this->ctrl->forwardCommand($pp_gui);
4323  return true;
4324  }
4325  }
4326  }
4327 
4328  switch($next_class)
4329  {
4330  case "ilinfoscreengui":
4331  $this->infoScreen(); // forwards command
4332  break;
4333 
4334  case 'ilmdeditorgui':
4335  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
4336 
4337  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
4338  $md_gui->addObserver($this->object,'MDUpdateListener','General');
4339 
4340  $this->ctrl->forwardCommand($md_gui);
4341  $this->tabs_gui->setTabActive('meta_data');
4342  break;
4343 
4344  case 'ilcourseregistrationgui':
4345  $this->ctrl->setReturn($this,'');
4346  $this->tabs_gui->setTabActive('join');
4347  include_once('./Modules/Course/classes/class.ilCourseRegistrationGUI.php');
4348  $registration = new ilCourseRegistrationGUI($this->object);
4349  $this->ctrl->forwardCommand($registration);
4350  break;
4351 
4352  case 'ilobjectcustomuserfieldsgui':
4353  include_once './Services/Membership/classes/class.ilObjectCustomUserFieldsGUI.php';
4354 
4355  $cdf_gui = new ilObjectCustomUserFieldsGUI($this->object->getId());
4356  $this->setSubTabs('properties');
4357  $this->tabs_gui->setTabActive('settings');
4358  $this->ctrl->forwardCommand($cdf_gui);
4359  break;
4360 
4361  case "ilcourseobjectivesgui":
4362  include_once './Modules/Course/classes/class.ilCourseObjectivesGUI.php';
4363 
4364  $this->ctrl->setReturn($this,"");
4365  $reg_gui =& new ilCourseObjectivesGUI($this->object->getRefId());
4366  $ret =& $this->ctrl->forwardCommand($reg_gui);
4367  break;
4368 
4369  case 'ilobjcoursegroupinggui':
4370  include_once './Modules/Course/classes/class.ilObjCourseGroupingGUI.php';
4371 
4372  $this->ctrl->setReturn($this,'edit');
4373  $this->setSubTabs('properties');
4374  $crs_grp_gui =& new ilObjCourseGroupingGUI($this->object,(int) $_GET['obj_id']);
4375  $this->ctrl->forwardCommand($crs_grp_gui);
4376  $this->tabs_gui->setTabActive('settings');
4377  $this->tabs_gui->setSubTabActive('groupings');
4378  break;
4379 
4380  case "ilcolumngui":
4381  $this->tabs_gui->setTabActive('none');
4382  $this->checkPermission("read");
4383  //$this->prepareOutput();
4384  //include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
4385  //$this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
4386  // ilObjStyleSheet::getContentStylePath(0));
4387  //$this->renderObject();
4388  $this->viewObject();
4389  break;
4390 
4391  case "ilconditionhandlerinterface":
4392  include_once './classes/class.ilConditionHandlerInterface.php';
4393 
4394  // preconditions for single course items
4395  if($_GET['item_id'])
4396  {
4397  $this->ctrl->saveParameter($this,'item_id',$_GET['item_id']);
4398  $this->tabs_gui->setTabActive('content');
4399  $this->setSubTabs("item_activation");
4400 
4401  $new_gui =& new ilConditionHandlerInterface($this,(int) $_GET['item_id']);
4402  $this->ctrl->forwardCommand($new_gui);
4403  }
4404  else // preconditions for whole course
4405  {
4406  $this->setSubTabs("properties");
4407  $this->tabs_gui->setTabActive('settings');
4408  $new_gui =& new ilConditionHandlerInterface($this);
4409 
4410  $this->ctrl->forwardCommand($new_gui);
4411  }
4412  break;
4413 
4414  case "illearningprogressgui":
4415  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
4416 
4417  $new_gui =& new ilLearningProgressGUI(LP_MODE_REPOSITORY,
4418  $this->object->getRefId(),
4419  $_GET['user_id'] ? $_GET['user_id'] : $ilUser->getId());
4420  $this->ctrl->forwardCommand($new_gui);
4421  $this->tabs_gui->setTabActive('learning_progress');
4422  break;
4423 
4424  case 'illicenseoverviewgui':
4425  include_once("./Services/License/classes/class.ilLicenseOverviewGUI.php");
4426  $license_gui =& new ilLicenseOverviewGUI($this, LIC_MODE_REPOSITORY);
4427  $ret =& $this->ctrl->forwardCommand($license_gui);
4428  $this->tabs_gui->setTabActive('licenses');
4429  break;
4430 
4431  case 'ilpermissiongui':
4432  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
4433  $this->tabs_gui->setTabActive('perm_settings');
4434  $perm_gui =& new ilPermissionGUI($this);
4435  $ret =& $this->ctrl->forwardCommand($perm_gui);
4436  break;
4437 
4438  case 'ilrepositorysearchgui':
4439  include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
4440  $rep_search =& new ilRepositorySearchGUI();
4441  $rep_search->setCallback($this,
4442  'assignMembersObject',
4443  array(
4444  ilCourseConstants::CRS_MEMBER => $this->lng->txt('crs_member'),
4445  ilCourseConstants::CRS_TUTOR => $this->lng->txt('crs_tutor'),
4446  ilCourseConstants::CRS_ADMIN => $this->lng->txt('crs_admin')
4447  )
4448  );
4449 
4450  $this->checkLicenses();
4451 
4452  // Set tabs
4453  $this->ctrl->setReturn($this,'members');
4454  $ret =& $this->ctrl->forwardCommand($rep_search);
4455  $this->setSubTabs('members');
4456  $this->tabs_gui->setTabActive('members');
4457  $this->tabs_gui->setSubTabActive('crs_member_administration');
4458  break;
4459 
4460  case 'ilcoursecontentinterface':
4461 
4462  $this->initCourseContentInterface();
4463  $this->cci_obj->cci_setContainer($this);
4464 
4465  $this->ctrl->forwardCommand($this->cci_obj);
4466  $this->setSubTabs('content');
4467  $this->tabs_gui->setTabActive('content');
4468  break;
4469 
4470  case 'ilcoursecontentgui':
4471  $this->ctrl->setReturn($this,'members');
4472  include_once './Modules/Course/classes/class.ilCourseContentGUI.php';
4473  $course_content_obj = new ilCourseContentGUI($this);
4474  $this->ctrl->forwardCommand($course_content_obj);
4475  break;
4476 
4477  case 'ilpublicuserprofilegui':
4478  require_once './Services/User/classes/class.ilPublicUserProfileGUI.php';
4479  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
4480  $this->setSubTabs('members');
4481  $this->tabs_gui->setTabActive('members');
4482  $profile_gui->setBackUrl($ilCtrl->getLinkTarget($this, "membersGallery"));
4483  $this->tabs_gui->setSubTabActive('crs_members_gallery');
4484  $html = $this->ctrl->forwardCommand($profile_gui);
4485  $this->tpl->setVariable("ADM_CONTENT", $html);
4486  break;
4487 
4488  case 'ilmemberexportgui':
4489  include_once('./Services/Membership/classes/Export/class.ilMemberExportGUI.php');
4490 
4491  $this->setSubTabs('members');
4492  $this->tabs_gui->setTabActive('members');
4493  $this->tabs_gui->setSubTabActive('export_members');
4494  $export = new ilMemberExportGUI($this->object->getRefId());
4495  $this->ctrl->forwardCommand($export);
4496  break;
4497 
4498  case 'ilmemberagreementgui':
4499  include_once('Services/Membership/classes/class.ilMemberAgreementGUI.php');
4500  $this->ctrl->setReturn($this,'');
4501  $agreement = new ilMemberAgreementGUI($this->object->getRefId());
4502  $this->ctrl->forwardCommand($agreement);
4503  break;
4504 
4505  case 'ilsessionoverviewgui':
4506  include_once('./Modules/Session/classes/class.ilSessionOverviewGUI.php');
4507 
4508  $this->setSubTabs('members');
4509  $this->tabs_gui->setTabActive('members');
4510  $this->tabs_gui->setSubTabActive('events');
4511  $overview = new ilSessionOverviewGUI($this->object->getRefId());
4512  $this->ctrl->forwardCommand($overview);
4513  break;
4514 
4515  case 'ilcourseitemadministrationgui':
4516  include_once 'Modules/Course/classes/class.ilCourseItemAdministrationGUI.php';
4517  $this->tabs_gui->clearSubTabs();
4518  $this->ctrl->setReturn($this,'view');
4519  $item_adm_gui = new ilCourseItemAdministrationGUI($this->object,(int) $_REQUEST['item_id']);
4520  $this->ctrl->forwardCommand($item_adm_gui);
4521  break;
4522 
4523  // container page editing
4524  case "ilpageobjectgui":
4525  $ret = $this->forwardToPageObject();
4526  if ($ret != "")
4527  {
4528  $this->tpl->setContent($ret);
4529  }
4530  break;
4531 
4532  case 'ilobjectcopygui':
4533  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
4534  $cp = new ilObjectCopyGUI($this);
4535  $cp->setType('crs');
4536  $this->ctrl->forwardCommand($cp);
4537  break;
4538 
4539  case "ilobjstylesheetgui":
4540  $this->forwardToStyleSheet();
4541  break;
4542 
4543  case 'ilcourseparticipantsgroupsgui':
4544  include_once './Modules/Course/classes/class.ilCourseParticipantsGroupsGUI.php';
4545 
4546  $cmg_gui = new ilCourseParticipantsGroupsGUI($this->object->getRefId());
4547  $this->setSubTabs('members');
4548  $this->tabs_gui->setTabActive('members');
4549  $this->ctrl->forwardCommand($cmg_gui);
4550  break;
4551 
4552  case 'ilexportgui':
4553  $this->tabs_gui->setTabActive('export');
4554  include_once './Services/Export/classes/class.ilExportGUI.php';
4555  $exp = new ilExportGUI($this);
4556  $exp->addFormat('xml');
4557  $this->ctrl->forwardCommand($exp);
4558  break;
4559 
4560  default:
4561  if(!$this->creation_mode)
4562  {
4563  $this->checkPermission('visible');
4564  }
4565  /*
4566  if(!$this->creation_mode and !$ilAccess->checkAccess('visible','',$this->object->getRefId(),'crs'))
4567  {
4568  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"),$ilErr->MESSAGE);
4569  }
4570  */
4571  if( !$this->creation_mode
4572  && $cmd != 'infoScreen'
4573  && $cmd != 'sendfile'
4574  && $cmd != 'unsubscribe'
4575  && $cmd != 'performUnsubscribe'
4576  && !$ilAccess->checkAccess("read",'',$this->object->getRefId())
4577  || $cmd == 'join'
4578  || $cmd == 'subscribe')
4579  {
4580  include_once './Modules/Course/classes/class.ilCourseParticipants.php';
4581  if($rbacsystem->checkAccess('join',$this->object->getRefId()) &&
4582  !ilCourseParticipants::_isParticipant($this->object->getRefId(),$ilUser->getId()))
4583  {
4584  include_once('./Modules/Course/classes/class.ilCourseRegistrationGUI.php');
4585  $this->ctrl->redirectByClass("ilCourseRegistrationGUI");
4586  }
4587  else
4588  {
4589  $this->infoScreenObject();
4590  break;
4591  }
4592  }
4593 
4594  if($cmd == 'listObjectives')
4595  {
4596  include_once './Modules/Course/classes/class.ilCourseObjectivesGUI.php';
4597 
4598  $this->ctrl->setReturn($this,"");
4599  $obj_gui =& new ilCourseObjectivesGUI($this->object->getRefId());
4600  $ret =& $this->ctrl->forwardCommand($obj_gui);
4601  break;
4602  }
4603 
4604  if((!$this->creation_mode)&&(!$rbacsystem->checkAccess("write",$this->object->getRefId())))
4605  {
4606  $this->ctrl->setReturn($this,'view');
4607  include_once('Services/Feedback/classes/class.ilFeedbackGUI.php');
4608  $feedbackGUI = new ilFeedbackGUI();
4609  $feedbackGUI->handleRequiredFeedback($this->object->getRefId());
4610  }
4611 
4612  // Dirty hack for course timings view
4613  if($this->forwardToTimingsView())
4614  {
4615  break;
4616  }
4617 
4618  if(!$cmd)
4619  {
4620  $cmd = 'view';
4621  }
4622  $cmd .= 'Object';
4623  $this->$cmd();
4624 
4625  break;
4626  }
4627 
4628  return true;
4629  }
4630 
4637  private function checkAgreement()
4638  {
4639  global $ilUser,$ilAccess;
4640 
4641  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
4642  {
4643  return true;
4644  }
4645 
4646  // Disable aggrement if is not member of course
4647  if(!$this->object->members_obj->isAssigned($ilUser->getId()))
4648  {
4649  return true;
4650  }
4651 
4652  include_once './Services/Container/classes/class.ilMemberViewSettings.php';
4653  if(ilMemberViewSettings::getInstance()->isActive())
4654  {
4655  return true;
4656  }
4657 
4658  include_once('Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
4659  include_once('Services/Membership/classes/class.ilMemberAgreement.php');
4660  $privacy = ilPrivacySettings::_getInstance();
4661 
4662  // Check agreement
4663  if(($privacy->courseConfirmationRequired() or ilCourseDefinedFieldDefinition::_hasFields($this->object->getId()))
4664  and !ilMemberAgreement::_hasAccepted($ilUser->getId(),$this->object->getId()))
4665  {
4666  return false;
4667  }
4668  // Check required fields
4669  include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');
4670  if(!ilCourseUserData::_checkRequired($ilUser->getId(),$this->object->getId()))
4671  {
4672  return false;
4673  }
4674  return true;
4675  }
4676 
4677 
4684  private function checkLicenses($a_keep = false)
4685  {
4686  global $lng;
4687 
4688 
4689  include_once("Services/License/classes/class.ilLicenseAccess.php");
4691  {
4692  $lic_set = new ilSetting("license");
4693  $buffer = $lic_set->get("license_warning");
4694 
4695  include_once("./Services/License/classes/class.ilLicense.php");
4696  $licensed_items = ilLicense::_getLicensedChildObjects($this->object->getRefId());
4697  foreach ($licensed_items as $item)
4698  {
4699  $license =& new ilLicense($item['obj_id']);
4700  $remaining = $license->getRemainingLicenses();
4701  if ($remaining <= $buffer)
4702  {
4703  $lng->loadlanguageModule("license");
4704  ilUtil::sendInfo(sprintf($this->lng->txt("course_licenses_rare"), $remaining), $a_keep);
4705  break;
4706  }
4707  }
4708  }
4709  }
4710 
4711  // STATIC
4712  function _forwards()
4713  {
4714  return array("ilCourseRegisterGUI",'ilConditionHandlerInterface');
4715  }
4716 
4717 
4719  {
4720  $this->initCourseContentInterface();
4721  $this->cci_obj->cci_setContainer($this);
4722  $this->cci_obj->cci_objectives();
4723 
4724  return true;;
4725  }
4727  {
4728  $this->tabs_gui->setTabActive('edit_content');
4729 
4730  $this->initCourseContentInterface();
4731  $this->cci_obj->cci_setContainer($this);
4732  $this->cci_obj->cci_view();
4733 
4734  return true;
4735  }
4737  {
4738  $this->initCourseContentInterface();
4739  $this->cci_obj->cci_setContainer($this);
4740  $this->cci_obj->cci_objectives_ask_reset();
4741 
4742  return true;;
4743  }
4744  function cciResetObject()
4745  {
4746  global $ilUser;
4747 
4748  include_once './Modules/Course/classes/class.ilCourseObjectiveResult.php';
4749 
4750  $tmp_obj_res =& new ilCourseObjectiveResult($ilUser->getId());
4751  $tmp_obj_res->reset($this->object->getId());
4752 
4753  ilUtil::sendSuccess($this->lng->txt('crs_objectives_reseted'));
4754 
4755  $this->initCourseContentInterface();
4756  $this->cci_obj->cci_setContainer($this);
4757  $this->cci_obj->cci_objectives();
4758  }
4759 
4760 
4761  // Methods for ConditionHandlerInterface
4762  function initConditionHandlerGUI($item_id)
4763  {
4764  include_once './classes/class.ilConditionHandlerInterface.php';
4765 
4766  if(!is_object($this->chi_obj))
4767  {
4768  if($_GET['item_id'])
4769  {
4770  $this->chi_obj =& new ilConditionHandlerInterface($this,$item_id);
4771  $this->ctrl->saveParameter($this,'item_id',$_GET['item_id']);
4772  }
4773  else
4774  {
4775  $this->chi_obj =& new ilConditionHandlerInterface($this);
4776  }
4777  }
4778  return true;
4779  }
4780 
4781 
4782  function addLocatorItems()
4783  {
4784  global $ilLocator;
4785  switch ($this->ctrl->getCmd())
4786  {
4787  default:
4788  #$ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""));
4789  break;
4790  }
4791  }
4792 
4796  function _goto($a_target, $a_add = "")
4797  {
4798  global $ilAccess, $ilErr, $lng,$ilUser;
4799 
4800  include_once './Services/Membership/classes/class.ilMembershipRegistrationCodeUtils.php';
4801  if(substr($a_add,0,5) == 'rcode')
4802  {
4803  if($ilUser->getId() == ANONYMOUS_USER_ID)
4804  {
4805  // Redirect to login for anonymous
4807  "login.php?target=".$_GET["target"]."&cmd=force_login&lang=".
4808  $ilUser->getCurrentLanguage()
4809  );
4810  }
4811 
4812  // Redirects to target location after assigning user to course
4814  $a_target,
4816  substr($a_add,5)
4817  );
4818  }
4819 
4820  if ($a_add == "mem" && $ilAccess->checkAccess("write", "", $a_target))
4821  {
4822 //echo "1";
4823  $_GET["cmd"] = "members";
4824  $_GET["ref_id"] = $a_target;
4825  include("repository.php");
4826  exit;
4827  }
4828 
4829  if ($ilAccess->checkAccess("read", "", $a_target))
4830  {
4831  $_GET["cmd"] = "frameset";
4832  $_GET["ref_id"] = $a_target;
4833  include("repository.php");
4834  exit;
4835  }
4836  else
4837  {
4838  // to do: force flat view
4839  if ($ilAccess->checkAccess("visible", "", $a_target))
4840  {
4841  $_GET["cmd"] = "infoScreen";
4842  $_GET["ref_id"] = $a_target;
4843  include("repository.php");
4844  exit;
4845  }
4846  else
4847  {
4848  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
4849  {
4850  $_GET["cmd"] = "frameset";
4851  $_GET["target"] = "";
4852  $_GET["ref_id"] = ROOT_FOLDER_ID;
4853  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
4854  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
4855  include("repository.php");
4856  exit;
4857  }
4858  }
4859  }
4860  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
4861  }
4862 
4863 
4864  function toUnix($date,$time = array())
4865  {
4866  return mktime($time['h'],$time['m'],0,$date['m'],$date['d'],$date['y']);
4867  }
4868 
4869  function __prepareDateSelect($a_unix_time)
4870  {
4871  return array('y' => date('Y',$a_unix_time),
4872  'm' => date('n',$a_unix_time),
4873  'd' => date('d',$a_unix_time));
4874  }
4875 
4876  function __prepareTimeSelect($a_unix_time)
4877  {
4878  return array('h' => date('G',$a_unix_time),
4879  'm' => date('i',$a_unix_time),
4880  's' => date('s',$a_unix_time));
4881  }
4882 
4883  // Copy wizard
4884 
4889  {
4890  global $ilUser, $ilCtrl, $ilUser, $ilAccess;
4891 
4892  $this->setSubTabs("properties");
4893  $this->tabs_gui->setTabActive('settings');
4894 
4896  !$ilAccess->checkAccess("write", "", $this->object->getRefId()))
4897  {
4898  return;
4899  }
4900 
4901  $latitude = $this->object->getLatitude();
4902  $longitude = $this->object->getLongitude();
4903  $zoom = $this->object->getLocationZoom();
4904 
4905  // Get Default settings, when nothing is set
4906  if ($latitude == 0 && $longitude == 0 && $zoom == 0)
4907  {
4909  $latitude = $def["latitude"];
4910  $longitude = $def["longitude"];
4911  $zoom = $def["zoom"];
4912  }
4913 
4914  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"), $this->lng->txt("personal_desktop"));
4915  //$this->tpl->setVariable("HEADER", $this->lng->txt("personal_desktop"));
4916 
4917  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
4918  $form = new ilPropertyFormGUI();
4919  $form->setFormAction($ilCtrl->getFormAction($this));
4920 
4921  $form->setTitle($this->lng->txt("crs_map_settings"));
4922 
4923  // enable map
4924  $public = new ilCheckboxInputGUI($this->lng->txt("crs_enable_map"),
4925  "enable_map");
4926  $public->setValue("1");
4927  $public->setChecked($this->object->getEnableCourseMap());
4928  $form->addItem($public);
4929 
4930  // map location
4931  $loc_prop = new ilLocationInputGUI($this->lng->txt("crs_map_location"),
4932  "location");
4933  $loc_prop->setLatitude($latitude);
4934  $loc_prop->setLongitude($longitude);
4935  $loc_prop->setZoom($zoom);
4936  $form->addItem($loc_prop);
4937 
4938  $form->addCommandButton("saveMapSettings", $this->lng->txt("save"));
4939 
4940  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
4941  //$this->tpl->show();
4942  }
4943 
4945  {
4946  global $ilCtrl, $ilUser;
4947 
4948  $this->object->setLatitude(ilUtil::stripSlashes($_POST["location"]["latitude"]));
4949  $this->object->setLongitude(ilUtil::stripSlashes($_POST["location"]["longitude"]));
4950  $this->object->setLocationZoom(ilUtil::stripSlashes($_POST["location"]["zoom"]));
4951  $this->object->setEnableCourseMap(ilUtil::stripSlashes($_POST["enable_map"]));
4952  $this->object->update();
4953 
4954  $ilCtrl->redirect($this, "editMapSettings");
4955  }
4956 
4960  function membersMapObject()
4961  {
4962  global $tpl;
4963 
4964  $this->tabs_gui->setTabActive("members");
4965  $this->setSubTabs('members');
4966  $this->tabs_gui->setSubTabActive("crs_members_map");
4967 
4968  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
4969  if (!ilGoogleMapUtil::isActivated() || !$this->object->getEnableCourseMap())
4970  {
4971  return;
4972  }
4973 
4974  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapGUI.php");
4975  $map = new ilGoogleMapGUI();
4976  $map->setMapId("course_map");
4977  $map->setWidth("700px");
4978  $map->setHeight("500px");
4979  $map->setLatitude($this->object->getLatitude());
4980  $map->setLongitude($this->object->getLongitude());
4981  $map->setZoom($this->object->getLocationZoom());
4982  $map->setEnableTypeControl(true);
4983  $map->setEnableNavigationControl(true);
4984  $map->setEnableCentralMarker(true);
4985 
4986 
4987  $this->object->initCourseMemberObject();
4988  if(count($members = $this->object->members_obj->getParticipants()))
4989  {
4990  foreach($members as $user_id)
4991  {
4992  $map->addUserMarker($user_id);
4993  }
4994  }
4995 
4996  $tpl->setContent($map->getHTML());
4997  $tpl->setLeftContent($map->getUserListHTML());
4998  }
4999 
5003  function modifyItemGUI($a_item_list_gui, $a_item_data, $a_show_path)
5004  {
5005  return ilObjCourseGUI::_modifyItemGUI($a_item_list_gui, 'ilcoursecontentgui', $a_item_data, $a_show_path,
5006  $this->object->getAboStatus(), $this->object->getRefId(), $this->object->getId());
5007  }
5008 
5012  static function _modifyItemGUI($a_item_list_gui, $a_cmd_class, $a_item_data, $a_show_path,
5013  $a_abo_status, $a_course_ref_id, $a_course_obj_id, $a_parent_ref_id = 0)
5014  {
5015  global $lng, $ilCtrl, $ilAccess;
5016 
5017  // this is set for folders within the course
5018  if ($a_parent_ref_id == 0)
5019  {
5020  $a_parent_ref_id = $a_course_ref_id;
5021  }
5022 
5023  // Special handling for tests in courses with learning objectives
5024  if($a_item_data['type'] == 'tst' and
5026  {
5027  $a_item_list_gui->addCommandLinkParameter(array('crs_show_result' => $a_course_ref_id));
5028  }
5029 
5030  // ACTIVATION
5031  $activation = '';
5032  if(isset($a_item_data['timing_type']))
5033  {
5034  switch($a_item_data['timing_type'])
5035  {
5037  $activation = ilDatePresentation::formatPeriod(
5038  new ilDateTime($a_item_data['start'],IL_CAL_UNIX),
5039  new ilDateTime($a_item_data['end'],IL_CAL_UNIX));
5040  break;
5041 
5043  $activation = ilDatePresentation::formatPeriod(
5044  new ilDate($a_item_data['start'],IL_CAL_UNIX),
5045  new ilDate($a_item_data['end'],IL_CAL_UNIX));
5046  break;
5047 
5048  default:
5049  $activation = '';
5050  break;
5051  }
5052  }
5053 
5054  $a_item_list_gui->enableSubscribe($a_abo_status);
5055 
5056  // add activation custom property
5057  if ($activation != "")
5058  {
5059  $a_item_list_gui->addCustomProperty($lng->txt($a_item_data['activation_info']), $activation,
5060  false, true);
5061  }
5062 
5063  $is_tutor = ($ilAccess->checkAccess('write','',
5064  $a_course_ref_id,'crs', $a_course_obj_id));
5065 
5066  if($a_show_path and $is_tutor)
5067  {
5068  $a_item_list_gui->addCustomProperty($lng->txt('path'),
5069 
5070  ilContainer::_buildPath($a_item_data['ref_id'], $a_course_ref_id),
5071  false,
5072  true);
5073  }
5074 
5075  if($is_tutor)
5076  {
5077  $ilCtrl->setParameterByClass('ilcourseitemadministrationgui',"ref_id",
5078  $a_parent_ref_id);
5079  $ilCtrl->setParameterByClass('ilcourseitemadministrationgui',"item_id",
5080  $a_item_data['child']);
5081  $a_item_list_gui->addCustomCommand($ilCtrl->getLinkTargetByClass(
5082  array(strtolower($a_cmd_class), 'ilCourseItemAdministrationGUI'),
5083  'edit'),
5084  'activation');
5085  }
5086  }
5087 
5092  {
5093  global $ilAccess, $lng, $ilCtrl;
5094 
5095  if ($this->object->getType() != 'crs')
5096  {
5097  return true;
5098  }
5099  if (!$ilAccess->checkAccess('write','',
5100  $this->object->getRefId(),'crs',$this->object->getId()))
5101  {
5102  $is_tutor = false;
5103  // No further tabs if objective view or archives
5104  if($this->object->enabledObjectiveView())
5105  {
5106  return false;
5107  }
5108  }
5109  else
5110  {
5111  $is_tutor = true;
5112  }
5113 
5114  // These subtabs should also work, if the command is called directly in
5115  // ilObjCourseGUI, so please use ...ByClass methods.
5116  // (see ilObjCourseGUI->executeCommand: case "ilcolumngui")
5117 
5118  if(!$_SESSION['crs_timings_panel'][$this->object->getId()] or 1)
5119  {
5120  if (!$this->isActiveAdministrationPanel())
5121  {
5122  $this->tabs_gui->addSubTab("view_content", $lng->txt("view"), $ilCtrl->getLinkTargetByClass("ilobjcoursegui", "view"));
5123  }
5124  else
5125  {
5126  $this->tabs_gui->addSubTab("view_content", $lng->txt("view"), $ilCtrl->getLinkTargetByClass("ilobjcoursegui", "disableAdministrationPanel"));
5127  }
5128  }
5129  include_once 'Modules/Course/classes/class.ilCourseItems.php';
5130  if($this->object->getViewMode() == IL_CRS_VIEW_TIMING)
5131  {
5132  $this->tabs_gui->addSubTabTarget('timings_timings',
5133  $this->ctrl->getLinkTargetByClass('ilcoursecontentgui','editUserTimings'));
5134  }
5135 
5136  $this->addStandardContainerSubTabs(false);
5137 
5138  /*
5139  if($is_tutor)
5140  {
5141  $this->tabs_gui->addSubTabTarget('crs_archives',
5142  $this->ctrl->getLinkTargetByClass(
5143  array('ilcoursecontentgui', 'ilcoursearchivesgui'),'view'));
5144  }
5145  */
5146  return true;
5147  }
5148 
5156  protected function loadDate($a_field)
5157  {
5158  global $ilUser;
5159 
5160  include_once('./Services/Calendar/classes/class.ilDateTime.php');
5161 
5162  $dt['year'] = (int) $_POST[$a_field]['date']['y'];
5163  $dt['mon'] = (int) $_POST[$a_field]['date']['m'];
5164  $dt['mday'] = (int) $_POST[$a_field]['date']['d'];
5165  $dt['hours'] = (int) $_POST[$a_field]['time']['h'];
5166  $dt['minutes'] = (int) $_POST[$a_field]['time']['m'];
5167  $dt['seconds'] = (int) $_POST[$a_field]['time']['s'];
5168 
5169  $date = new ilDateTime($dt,IL_CAL_FKT_GETDATE,$ilUser->getTimeZone());
5170  return $date;
5171  }
5172 
5180  public function askResetObject()
5181  {
5182  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_objectives_ask_reset.html",'Modules/Course');
5183 
5184  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
5185  $this->tpl->setVariable("INFO_STRING",$this->lng->txt('crs_objectives_reset_sure'));
5186  $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
5187  $this->tpl->setVariable("TXT_RESET",$this->lng->txt('reset'));
5188 
5189  return true;
5190  }
5191 
5192  function resetObject()
5193  {
5194  global $ilUser;
5195 
5196  include_once './Modules/Course/classes/class.ilCourseObjectiveResult.php';
5197 
5198  $tmp_obj_res = new ilCourseObjectiveResult($ilUser->getId());
5199  $tmp_obj_res->reset($this->object->getId());
5200 
5201  $ilUser->deletePref('crs_objectives_force_details_'.$this->object->getId());
5202 
5203  ilUtil::sendSuccess($this->lng->txt('crs_objectives_reseted'));
5204  $this->viewObject();
5205  }
5206 
5208  {
5209  include_once './Modules/Course/classes/class.ilCourseStart.php';
5210 
5211  global $ilAccess,$ilUser;
5212 
5213  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
5214  {
5215  return true;
5216  }
5217  $this->start_obj = new ilCourseStart($this->object->getRefId(),$this->object->getId());
5218  if(count($this->start_obj->getStartObjects()) and !$this->start_obj->allFullfilled($ilUser->getId()))
5219  {
5220  return false;
5221  }
5222  return true;
5223  }
5224 
5225  function showStartObjects()
5226  {
5227  include_once './Modules/Course/classes/class.ilCourseLMHistory.php';
5228  include_once './Services/Repository/classes/class.ilRepositoryExplorer.php';
5229  include_once './classes/class.ilLink.php';
5230 
5231  global $rbacsystem,$ilias,$ilUser,$ilAccess,$ilObjDataCache;
5232 
5233  $this->tabs_gui->setSubTabActive('view');
5234 
5235  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_start_view.html",'Modules/Course');
5236  $this->tpl->setVariable("INFO_STRING",$this->lng->txt('crs_info_start'));
5237  $this->tpl->setVariable("TBL_TITLE_START",$this->lng->txt('crs_table_start_objects'));
5238  $this->tpl->setVariable("HEADER_NR",$this->lng->txt('crs_nr'));
5239  $this->tpl->setVariable("HEADER_DESC",$this->lng->txt('description'));
5240  $this->tpl->setVariable("HEADER_EDITED",$this->lng->txt('crs_objective_accomplished'));
5241 
5242 
5243  $lm_continue =& new ilCourseLMHistory($this->object->getRefId(),$ilUser->getId());
5244  $continue_data = $lm_continue->getLMHistory();
5245 
5246  $counter = 0;
5247  foreach($this->start_obj->getStartObjects() as $start)
5248  {
5249  $obj_id = $ilObjDataCache->lookupObjId($start['item_ref_id']);
5250  $ref_id = $start['item_ref_id'];
5251  $type = $ilObjDataCache->lookupType($obj_id);
5252 
5254 
5255  $obj_link = ilLink::_getLink($ref_id,$type);
5257  $obj_frame = $obj_frame ? $obj_frame : '';
5258 
5259  // Tmp fix for tests
5260  $obj_frame = $type == 'tst' ? '' : $obj_frame;
5261 
5262  $contentObj = false;
5263 
5264  if($ilAccess->checkAccess('read','',$ref_id))
5265  {
5266  $this->tpl->setCurrentBlock("start_read");
5267  $this->tpl->setVariable("READ_TITLE_START",$ilObjDataCache->lookupTitle($obj_id));
5268  $this->tpl->setVariable("READ_TARGET_START",$obj_frame);
5269  $this->tpl->setVariable("READ_LINK_START", $obj_link.'&crs_show_result='.$this->object->getRefId());
5270  $this->tpl->parseCurrentBlock();
5271  }
5272  else
5273  {
5274  $this->tpl->setCurrentBlock("start_visible");
5275  $this->tpl->setVariable("VISIBLE_LINK_START",$ilObjDataCache->lookupTitle($obj_id));
5276  $this->tpl->parseCurrentBlock();
5277  }
5278 
5279  // CONTINUE LINK
5280  if(isset($continue_data[$ref_id]))
5281  {
5282  $this->tpl->setCurrentBlock("link");
5283  $this->tpl->setVariable("LINK_HREF",ilLink::_getLink($ref_id,'',array('obj_id',
5284  $continue_data[$ref_id]['lm_page_id'])));
5285  #$this->tpl->setVariable("CONTINUE_LINK_TARGET",$target);
5286  $this->tpl->setVariable("LINK_NAME",$this->lng->txt('continue_work'));
5287  $this->tpl->parseCurrentBlock();
5288  }
5289 
5290  // add to desktop link
5291  if(!$ilUser->isDesktopItem($ref_id,$type) and
5292  $this->object->getAboStatus())
5293  {
5294  if ($ilAccess->checkAccess('read','',$ref_id))
5295  {
5296  $this->tpl->setCurrentBlock("link");
5297  $this->ctrl->setParameterByClass(get_class($this),'item_ref_id',$ref_id);
5298  $this->ctrl->setParameterByClass(get_class($this),'item_id',$ref_id);
5299  $this->ctrl->setParameterByClass(get_class($this),'type',$type);
5300 
5301  $this->tpl->setVariable("LINK_HREF",$this->ctrl->getLinkTarget($this,'addToDesk'));
5302  $this->tpl->setVariable("LINK_NAME", $this->lng->txt("to_desktop"));
5303  $this->tpl->parseCurrentBlock();
5304  }
5305  }
5306  elseif($this->object->getAboStatus())
5307  {
5308  $this->tpl->setCurrentBlock("link");
5309  $this->ctrl->setParameterByClass(get_class($this),'item_ref_id',$ref_id);
5310  $this->ctrl->setParameterByClass(get_class($this),'item_id',$ref_id);
5311  $this->ctrl->setParameterByClass(get_class($this),'type',$type);
5312 
5313  $this->tpl->setVariable("LINK_HREF",$this->ctrl->getLinkTarget($this,'removeFromDesk'));
5314  $this->tpl->setVariable("LINK_NAME", $this->lng->txt("unsubscribe"));
5315  $this->tpl->parseCurrentBlock();
5316  }
5317 
5318 
5319  // Description
5320  if(strlen($ilObjDataCache->lookupDescription($obj_id)))
5321  {
5322  $this->tpl->setCurrentBlock("start_description");
5323  $this->tpl->setVariable("DESCRIPTION_START",$ilObjDataCache->lookupDescription($obj_id));
5324  $this->tpl->parseCurrentBlock();
5325  }
5326 
5327 
5328  if($this->start_obj->isFullfilled($ilUser->getId(),$ref_id))
5329  {
5330  $accomplished = 'accomplished';
5331  }
5332  else
5333  {
5334  $accomplished = 'not_accomplished';
5335  }
5336  $this->tpl->setCurrentBlock("start_row");
5337  $this->tpl->setVariable("EDITED_IMG",ilUtil::getImagePath('crs_'.$accomplished.'.gif'));
5338  $this->tpl->setVariable("EDITED_ALT",$this->lng->txt('crs_objective_'.$accomplished));
5339  $this->tpl->setVariable("ROW_CLASS",'option_value');
5340  $this->tpl->setVariable("ROW_CLASS_CENTER",'option_value_center');
5341  $this->tpl->setVariable("OBJ_NR_START",++$counter.'.');
5342  $this->tpl->parseCurrentBlock();
5343  }
5344  return true;
5345  }
5346 
5351  public function prepareOutput()
5352  {
5353  global $rbacsystem;
5354  if(!$this->getCreationMode())
5355  {
5356  include_once './Services/Container/classes/class.ilMemberViewSettings.php';
5357  $settings = ilMemberViewSettings::getInstance();
5358  if($settings->isActive() and $settings->getContainer() != $this->object->getRefId())
5359  {
5360  $settings->setContainer($this->object->getRefId());
5361  $rbacsystem->initMemberView();
5362  }
5363  }
5365  }
5366 
5371  protected function createMailSignature()
5372  {
5373  $link = chr(13).chr(10).chr(13).chr(10);
5374  $link .= $this->lng->txt('crs_mail_permanent_link');
5375  $link .= chr(13).chr(10).chr(13).chr(10);
5376  include_once './classes/class.ilLink.php';
5377  $link .= ilLink::_getLink($this->object->getRefId());
5378  return rawurlencode(base64_encode($link));
5379  }
5380 
5381 
5382 } // END class.ilObjCourseGUI
5383 ?>