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