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