ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjGroupGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once "./Services/Container/classes/class.ilContainerGUI.php";
6 include_once('./Modules/Group/classes/class.ilObjGroup.php');
7 
25 {
30  public function __construct($a_data,$a_id,$a_call_by_reference,$a_prepare_output = false)
31  {
32  $this->type = "grp";
33  $this->ilContainerGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
34 
35  $this->lng->loadLanguageModule('grp');
36  }
37 
38  function &executeCommand()
39  {
40  global $ilUser,$rbacsystem,$ilAccess, $ilNavigationHistory,$ilErr, $ilCtrl;
41 
42  $next_class = $this->ctrl->getNextClass($this);
43  $cmd = $this->ctrl->getCmd();
44  $this->prepareOutput();
45 
46  // add entry to navigation history
47  if (!$this->getCreationMode() &&
48  $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
49  {
50  $ilNavigationHistory->addItem($_GET["ref_id"],
51  "repository.php?cmd=frameset&ref_id=".$_GET["ref_id"], "grp");
52  }
53 
54  switch($next_class)
55  {
56  case "ilconditionhandlerinterface":
57  include_once './classes/class.ilConditionHandlerInterface.php';
58 
59  if($_GET['item_id'])
60  {
61  $this->ctrl->saveParameter($this,'item_id',$_GET['item_id']);
62  $this->setSubTabs('activation');
63  $this->tabs_gui->setTabActive('view_content');
64 
65  $new_gui =& new ilConditionHandlerInterface($this,(int) $_GET['item_id']);
66  $this->ctrl->forwardCommand($new_gui);
67  }
68  else
69  {
70  $new_gui =& new ilConditionHandlerInterface($this);
71  $this->ctrl->forwardCommand($new_gui);
72  }
73  break;
74 
75  case 'ilgroupregistrationgui':
76  $this->ctrl->setReturn($this,'');
77  $this->tabs_gui->setTabActive('join');
78  include_once('./Modules/Group/classes/class.ilGroupRegistrationGUI.php');
79  $registration = new ilGroupRegistrationGUI($this->object);
80  $this->ctrl->forwardCommand($registration);
81  break;
82 
83  case 'ilpermissiongui':
84  $this->tabs_gui->setTabActive('perm_settings');
85  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
86  $perm_gui =& new ilPermissionGUI($this);
87  $ret =& $this->ctrl->forwardCommand($perm_gui);
88  break;
89 
90  case 'ilrepositorysearchgui':
91  include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
92  $rep_search =& new ilRepositorySearchGUI();
93  $rep_search->setCallback($this,
94  'addUserObject',
95  array(
96  ilObjGroup::GRP_MEMBER => $this->lng->txt('il_grp_member'),
97  ilObjGroup::GRP_ADMIN => $this->lng->txt('il_grp_admin')
98  ));
99 
100  // Set tabs
101  $this->tabs_gui->setTabActive('members');
102  $this->ctrl->setReturn($this,'members');
103  $ret =& $this->ctrl->forwardCommand($rep_search);
104  $this->setSubTabs('members');
105  $this->tabs_gui->setSubTabActive('members');
106  break;
107 
108  case 'ilcourseitemadministrationgui':
109  include_once 'Modules/Course/classes/class.ilCourseItemAdministrationGUI.php';
110  $this->tabs_gui->clearSubTabs();
111  $this->ctrl->setReturn($this,'view');
112  $item_adm_gui = new ilCourseItemAdministrationGUI($this->object,(int) $_REQUEST['item_id']);
113  $this->ctrl->forwardCommand($item_adm_gui);
114  break;
115 
116  case "ilinfoscreengui":
117  $ret =& $this->infoScreen();
118  break;
119 
120  case "illearningprogressgui":
121  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
122 
124  $this->object->getRefId(),
125  $_GET['user_id'] ? $_GET['user_id'] : $ilUser->getId());
126  $this->ctrl->forwardCommand($new_gui);
127  $this->tabs_gui->setTabActive('learning_progress');
128  break;
129 
130  case 'ilobjcoursegroupinggui':
131  include_once './Modules/Course/classes/class.ilObjCourseGroupingGUI.php';
132 
133  $this->ctrl->setReturn($this,'edit');
134  $crs_grp_gui =& new ilObjCourseGroupingGUI($this->object,(int) $_GET['obj_id']);
135  $this->ctrl->forwardCommand($crs_grp_gui);
136  $this->setSubTabs('settings');
137  $this->tabs_gui->setTabActive('settings');
138  $this->tabs_gui->setSubTabActive('groupings');
139  break;
140 
141  case 'ilcoursecontentgui':
142 
143  include_once './Modules/Course/classes/class.ilCourseContentGUI.php';
144  $course_content_obj = new ilCourseContentGUI($this);
145  $this->ctrl->forwardCommand($course_content_obj);
146  break;
147 
148  case 'ilcourseitemadministrationgui':
149 
150  include_once 'Modules/Course/classes/class.ilCourseItemAdministrationGUI.php';
151 
152  $this->ctrl->setReturn($this,'');
153  $item_adm_gui = new ilCourseItemAdministrationGUI($this->object,(int) $_GET['item_id']);
154  $this->ctrl->forwardCommand($item_adm_gui);
155 
156  // (Sub)tabs
157  $this->setSubTabs('activation');
158  $this->tabs_gui->setTabActive('view_content');
159  $this->tabs_gui->setSubTabActive('activation');
160  break;
161 
162  case 'ilpublicuserprofilegui':
163  require_once './Services/User/classes/class.ilPublicUserProfileGUI.php';
164  $this->setSubTabs('members');
165  $this->tabs_gui->setTabActive('group_members');
166  $this->tabs_gui->setSubTabActive('grp_members_gallery');
167  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
168  $profile_gui->setBackUrl($ilCtrl->getLinkTarget($this, "membersGallery"));
169  $html = $this->ctrl->forwardCommand($profile_gui);
170  $this->tpl->setVariable("ADM_CONTENT", $html);
171  break;
172 
173  case "ilcolumngui":
174  $this->tabs_gui->setTabActive('none');
175  $this->checkPermission("read");
176  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
177  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
178  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId()));
179  $this->renderObject();
180  break;
181 
182  // container page editing
183  case "ilpageobjectgui":
184  $ret = $this->forwardToPageObject();
185  if ($ret != "")
186  {
187  $this->tpl->setContent($ret);
188  }
189  break;
190 
191  case 'ilobjectcopygui':
192  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
193  $cp = new ilObjectCopyGUI($this);
194  $cp->setType('grp');
195  $this->ctrl->forwardCommand($cp);
196  break;
197 
198  case "ilobjstylesheetgui":
199  $this->forwardToStyleSheet();
200  break;
201 
202  case 'ilobjectcustomuserfieldsgui':
203  include_once './Services/Membership/classes/class.ilObjectCustomUserFieldsGUI.php';
204  $cdf_gui = new ilObjectCustomUserFieldsGUI($this->object->getId());
205  $this->setSubTabs('settings');
206  $this->tabs_gui->setTabActive('settings');
207  $this->ctrl->forwardCommand($cdf_gui);
208  break;
209 
210  case 'ilmemberagreementgui':
211  include_once('Services/Membership/classes/class.ilMemberAgreementGUI.php');
212  $this->ctrl->setReturn($this,'');
213  $this->tabs_gui->setTabActive('view_content');
214  $agreement = new ilMemberAgreementGUI($this->object->getRefId());
215  $this->ctrl->forwardCommand($agreement);
216  break;
217 
218  case 'ilexportgui':
219  $this->tabs_gui->setTabActive('export');
220  include_once './Services/Export/classes/class.ilExportGUI.php';
221  $exp = new ilExportGUI($this);
222  $exp->addFormat('xml');
223  $this->ctrl->forwardCommand($exp);
224  break;
225 
226  case 'ilmemberexportgui':
227  include_once('./Services/Membership/classes/Export/class.ilMemberExportGUI.php');
228 
229  $this->setSubTabs('members');
230  $this->tabs_gui->setTabActive('members');
231  $this->tabs_gui->setSubTabActive('export_members');
232  $export = new ilMemberExportGUI($this->object->getRefId());
233  $this->ctrl->forwardCommand($export);
234  break;
235 
236 
237 
238  default:
239 
240  // check visible permission
241  if (!$this->getCreationMode() and !$ilAccess->checkAccess('visible','',$this->object->getRefId(),'grp'))
242  {
243  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"),$ilErr->MESSAGE);
244  }
245 
246  // check read permission
247  if ((!$this->getCreationMode()
248  && !$rbacsystem->checkAccess('read',$this->object->getRefId()) && $cmd != 'infoScreen')
249  || $cmd == 'join')
250  {
251  // no join permission -> redirect to info screen
252  if (!$rbacsystem->checkAccess('join',$this->object->getRefId()))
253  {
254  $this->ctrl->redirect($this, "infoScreen");
255  }
256  else // no read -> show registration
257  {
258  include_once('./Modules/Group/classes/class.ilGroupRegistrationGUI.php');
259  $this->ctrl->redirectByClass("ilGroupRegistrationGUI", "show");
260  }
261  }
262  if(!$cmd)
263  {
264  $cmd = 'view';
265  }
266  $cmd .= 'Object';
267  $this->$cmd();
268  break;
269  }
270  }
271 
272  function viewObject()
273  {
274  global $tree,$rbacsystem,$ilUser;
275 
276  include_once 'Services/Tracking/classes/class.ilLearningProgress.php';
277  ilLearningProgress::_tracProgress($ilUser->getId(),$this->object->getId(),
278  $this->object->getRefId(),'grp');
279 
280  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
281  {
283  return true;
284  }
285 
286  if(!$this->checkAgreement())
287  {
288  include_once('Services/Membership/classes/class.ilMemberAgreementGUI.php');
289  $this->tabs_gui->setTabActive('view_content');
290  $this->ctrl->setReturn($this,'view');
291  $agreement = new ilMemberAgreementGUI($this->object->getRefId());
292  $this->ctrl->setCmdClass(get_class($agreement));
293  $this->ctrl->forwardCommand($agreement);
294  return true;
295  }
296 
297  $this->tabs_gui->setTabActive('view_content');
298  $this->renderObject();
299  }
300 
304  function renderObject()
305  {
306  global $ilTabs;
307 
308  $ilTabs->activateTab("view_content");
310  return $ret;
311 
312  }
313 
314 
318  function modifyItemGUI($a_item_list_gui, $a_item_data, $a_show_path)
319  {
320  global $tree;
321 
322  // if folder is in a course, modify item list gui according to course requirements
323  if ($course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs'))
324  {
325  include_once("./Modules/Course/classes/class.ilObjCourse.php");
326  include_once("./Modules/Course/classes/class.ilObjCourseGUI.php");
327  $course_obj_id = ilObject::_lookupObjId($course_ref_id);
328  ilObjCourseGUI::_modifyItemGUI($a_item_list_gui,'ilcoursecontentgui',$a_item_data, $a_show_path,
329  ilObjCourse::_lookupAboStatus($course_obj_id), $course_ref_id, $course_obj_id,
330  $this->object->getRefId());
331  }
332  }
333 
334 
344  public function createObject()
345  {
346  if(!is_object($this->object))
347  {
348  $this->object = new ilObjGroup();
349  }
350 
351  $this->ctrl->setParameter($this,'new_type','grp');
352  $this->initForm('create');
353  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.grp_create.html','Modules/Group');
354  $this->tpl->setVariable('CREATE_FORM',$this->form->getHTML());
355 
356  $this->initImportForm("grp");
357  $this->tpl->setVariable("IMPORT_FORM", $this->form->getHTML());
358 
359  $this->fillCloneTemplate('DUPLICATE','grp');
360  }
361 
367  public function initImportForm($a_new_type = "")
368  {
369  global $lng, $ilCtrl;
370 
371  $lng->loadLanguageModule("crs");
372 
373  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
374  $this->form = new ilPropertyFormGUI();
375  $this->form->setTableWidth('600px');
376  $this->form->setTarget("_top");
377 
378  // Import file
379  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
380  $fi = new ilFileInputGUI($lng->txt("import_file"), "importfile");
381  $fi->setSuffixes(array("zip"));
382  $fi->setRequired(true);
383  $this->form->addItem($fi);
384 
385  $this->form->addCommandButton("importFile", $lng->txt("import"));
386  $this->form->addCommandButton("cancel", $lng->txt("cancel"));
387  $this->form->setTitle($lng->txt($a_new_type."_import"));
388 
389  $this->form->setFormAction($ilCtrl->getFormAction($this));
390  }
391 
392 
400  public function saveObject()
401  {
402  global $ilErr,$ilUser,$tree;
403 
404  $this->object = new ilObjGroup();
405 
406  $this->load();
407  $ilErr->setMessage('');
408 
409  if(!$this->object->validate())
410  {
411  $err = $this->lng->txt('err_check_input');
412  ilUtil::sendFailure($err);
413  $err = $ilErr->getMessage();
414  ilUtil::sendInfo($err);
415  $this->createObject();
416  return true;
417  }
418 
419  $this->object->create();
420  $this->object->createReference();
421  $this->object->putInTree($_GET["ref_id"]);
422  $this->object->setPermissions($_GET["ref_id"]);
423  $this->object->initGroupStatus($this->object->getGroupType());
424 
425  // Save sorting
426  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
427  $sort = new ilContainerSortingSettings($this->object->getId());
428  $sort->setSortMode((int) $_POST['sor']);
429  $sort->update();
430 
431  // Add user as admin and enable notification
432  include_once('./Modules/Group/classes/class.ilGroupParticipants.php');
433  $members_obj = ilGroupParticipants::_getInstanceByObjId($this->object->getId());
434  $members_obj->add($ilUser->getId(),IL_GRP_ADMIN);
435  $members_obj->updateNotification($ilUser->getId(),1);
436 
437 
438  // BEGIN ChangeEvent: Record save object.
439  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
441  {
442  ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'create');
443  }
444  // END ChangeEvent: Record save object.
445 
446  if($crs_refid = $tree->checkForParentType($this->object->getRefId(),'crs'))
447  {
448  include_once './Modules/Course/classes/class.ilCourseItems.php';
449  $tmp = new ilCourseItems($crs_refid,$this->object->getRefId());
450  }
451  ilUtil::sendSuccess($this->lng->txt("grp_added"),true);
452 
453  $this->ctrl->setParameter($this,'ref_id',$this->object->getRefId());
454  $this->ctrl->redirect($this);
455  }
456 
464  public function editObject()
465  {
466  $this->checkPermission("write");
467 
468  $this->setSubTabs('settings');
469  $this->tabs_gui->setTabActive('settings');
470  $this->tabs_gui->setSubTabActive('grp_settings');
471 
472  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.grp_edit.html','Modules/Group');
473  if($_GET['group_type_changed'])
474  {
475  $this->ctrl->clearParameters($this);
476  $this->tpl->setVariable('GRP_FORMACTION',$this->ctrl->getFormAction($this));
477  $this->tpl->setVariable('TXT_SW_GRP_TYPE_S',$this->lng->txt('grp_change_type'));
478  $this->tpl->setVariable('TXT_SW_GRP_TYPE_C',$this->lng->txt('cancel'));
479  $this->initForm('update_group_type');
480  }
481  else
482  {
483  $this->initForm('edit');
484  }
485  $this->tpl->setVariable('EDIT_FORM',$this->form->getHTML());
486  }
487 
495  public function updateGroupTypeObject()
496  {
497  $type = $this->object->getGroupType() ?
498  $this->object->getGroupType() :
499  $this->object->readGroupStatus();
500 
501  if($type == GRP_TYPE_PUBLIC)
502  {
503  $this->object->setGroupType(GRP_TYPE_CLOSED);
504  }
505  else
506  {
507  $this->object->setGroupType(GRP_TYPE_PUBLIC);
508  }
509  $this->object->updateGroupType();
510  $this->object->update();
511  ilUtil::sendSuccess($this->lng->txt('grp_type_changed_info'),true);
512  $this->ctrl->redirect($this,'edit');
513  }
514 
515 
521  public function updateObject()
522  {
523  global $ilErr;
524 
525  $this->checkPermission('write');
526 
527  $old_type = $this->object->getGroupType();
528 
529  $this->load();
530  $ilErr->setMessage('');
531 
532  if(!$this->object->validate())
533  {
534  $err = $this->lng->txt('err_check_input');
535  ilUtil::sendFailure($err);
536  $err = $ilErr->getMessage();
537  ilUtil::sendInfo($err);
538  $this->editObject();
539  return true;
540  }
541 
542  $modified = false;
543  if($this->object->isGroupTypeModified($old_type) and !$update_group_type)
544  {
545  $modified = true;
546  $this->object->setGroupType($old_type);
547  }
548 
549  $this->object->update();
550 
551  // Save sorting
552  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
553  $sort = new ilContainerSortingSettings($this->object->getId());
554  $sort->setSortMode((int) $_POST['sor']);
555  $sort->update();
556 
557  // BEGIN ChangeEvents: Record update Object.
558  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
560  {
561  global $ilUser;
562  ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
563  ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
564  }
565  // END PATCH ChangeEvents: Record update Object.
566 
567  if($modified)
568  {
569  include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
570  ilUtil::sendQuestion($this->lng->txt('grp_warn_grp_type_changed'));
571  $confirm = new ilConfirmationGUI();
572  $confirm->setFormAction($this->ctrl->getFormAction($this));
573  $confirm->addItem(
574  'grp_type',
575  $this->object->getGroupType(),
576  $this->lng->txt('grp_info_new_grp_type').': '.($this->object->getGroupType() == GRP_TYPE_CLOSED ? $this->lng->txt('il_grp_status_open') : $this->lng->txt('il_grp_status_closed'))
577  );
578  $confirm->addButton($this->lng->txt('grp_change_type'), 'updateGroupType');
579  $confirm->setCancel($this->lng->txt('cancel'), 'edit');
580 
581  $this->tpl->setContent($confirm->getHTML());
582  return true;
583  }
584  else
585  {
586  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
587  $this->ctrl->redirect($this,'edit');
588  return true;
589  }
590  }
591 
595  public function editGroupIconsObject()
596  {
597  global $rbacsystem;
598 
599  $this->checkPermission('write');
600 
601  $this->setSubTabs("settings");
602  $this->tabs_gui->setTabActive('settings');
603  $this->tabs_gui->setSubTabActive('grp_icon_settings');
604 
605  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.grp_edit_icons.html",'Modules/Group');
606  $this->showCustomIconsEditing();
607  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this,'updateGroupIcons'));
608  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
609  $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
610  $this->tpl->setVariable("CMD_CANCEL", "cancel");
611  $this->tpl->setVariable("CMD_SUBMIT", "updateGroupIcons");
612  $this->tpl->parseCurrentBlock();
613  }
614 
621  public function updateGroupIconsObject()
622  {
623  $this->checkPermission('write');
624 
625  //save custom icons
626  if ($this->ilias->getSetting("custom_icons"))
627  {
628  $this->object->saveIcons($_FILES["cont_big_icon"]['tmp_name'],
629  $_FILES["cont_small_icon"]['tmp_name'], $_FILES["cont_tiny_icon"]['tmp_name']);
630  }
631 
632  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
633  $this->ctrl->redirect($this,"editGroupIcons");
634  }
635 
641  public function removeSmallIconObject()
642  {
643  $this->object->removeSmallIcon();
644  $this->ctrl->redirect($this, "editGroupIcons");
645  }
646 
652  public function removeBigIconObject()
653  {
654  $this->object->removeBigIcon();
655  $this->ctrl->redirect($this, "editGroupIcons");
656  }
657 
663  public function removeTinyIconObject()
664  {
665  $this->object->removeTinyIcon();
666  $this->ctrl->redirect($this, "editGroupIcons");
667  }
668 
672  public function editMapSettingsObject()
673  {
674  global $ilUser, $ilCtrl, $ilUser, $ilAccess;
675 
676  $this->setSubTabs("settings");
677  $this->tabs_gui->setTabActive('settings');
678  $this->tabs_gui->setSubTabActive('grp_map_settings');
679 
680  include_once('./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php');
682  !$ilAccess->checkAccess("write", "", $this->object->getRefId()))
683  {
684  return;
685  }
686 
687  $latitude = $this->object->getLatitude();
688  $longitude = $this->object->getLongitude();
689  $zoom = $this->object->getLocationZoom();
690 
691  // Get Default settings, when nothing is set
692  if ($latitude == 0 && $longitude == 0 && $zoom == 0)
693  {
695  $latitude = $def["latitude"];
696  $longitude = $def["longitude"];
697  $zoom = $def["zoom"];
698  }
699 
700 
701  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"), $this->lng->txt("personal_desktop"));
702  //$this->tpl->setVariable("HEADER", $this->lng->txt("personal_desktop"));
703 
704  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
705  $form = new ilPropertyFormGUI();
706  $form->setFormAction($ilCtrl->getFormAction($this));
707 
708  $form->setTitle($this->lng->txt("grp_map_settings"));
709 
710  // enable map
711  $public = new ilCheckboxInputGUI($this->lng->txt("grp_enable_map"),
712  "enable_map");
713  $public->setValue("1");
714  $public->setChecked($this->object->getEnableGroupMap());
715  $form->addItem($public);
716 
717  // map location
718  $loc_prop = new ilLocationInputGUI($this->lng->txt("grp_map_location"),
719  "location");
720  $loc_prop->setLatitude($latitude);
721  $loc_prop->setLongitude($longitude);
722  $loc_prop->setZoom($zoom);
723  $form->addItem($loc_prop);
724 
725  $form->addCommandButton("saveMapSettings", $this->lng->txt("save"));
726 
727  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
728  }
729 
730  public function saveMapSettingsObject()
731  {
732  global $ilCtrl, $ilUser;
733 
734  $this->object->setLatitude(ilUtil::stripSlashes($_POST["location"]["latitude"]));
735  $this->object->setLongitude(ilUtil::stripSlashes($_POST["location"]["longitude"]));
736  $this->object->setLocationZoom(ilUtil::stripSlashes($_POST["location"]["zoom"]));
737  $this->object->setEnableGroupMap(ilUtil::stripSlashes($_POST["enable_map"]));
738  $this->object->update();
739 
740  $ilCtrl->redirect($this, "editMapSettings");
741  }
742 
746  public function membersMapObject()
747  {
748  global $tpl;
749 
750  $this->setSubTabs('members');
751  $this->tabs_gui->setTabActive('members');
752 
753  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
754  if (!ilGoogleMapUtil::isActivated() || !$this->object->getEnableGroupMap())
755  {
756  return;
757  }
758 
759  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapGUI.php");
760  $map = new ilGoogleMapGUI();
761  $map->setMapId("group_map");
762  $map->setWidth("700px");
763  $map->setHeight("500px");
764  $map->setLatitude($this->object->getLatitude());
765  $map->setLongitude($this->object->getLongitude());
766  $map->setZoom($this->object->getLocationZoom());
767  $map->setEnableTypeControl(true);
768  $map->setEnableNavigationControl(true);
769  $map->setEnableCentralMarker(true);
770 
771 
772  $member_ids = $this->object->getGroupMemberIds();
773  $admin_ids = $this->object->getGroupAdminIds();
774 
775  // fetch all users data in one shot to improve performance
776  $members = $this->object->getGroupMemberData($member_ids);
777  foreach($member_ids as $user_id)
778  {
779  $map->addUserMarker($user_id);
780  }
781  $tpl->setContent($map->getHTML());
782  $tpl->setLeftContent($map->getUserListHTML());
783  }
784 
785 
792  public function editInfoObject()
793  {
794  global $ilErr,$ilAccess;
795 
796  $this->checkPermission('write');
797 
798  $this->setSubTabs('settings');
799  $this->tabs_gui->setTabActive('settings');
800  $this->tabs_gui->setSubTabActive('grp_info_settings');
801 
802  $this->initInfoEditor();
803  $this->tpl->setContent($this->form->getHTML());
804  }
805 
812  protected function initInfoEditor()
813  {
814  if(is_object($this->form))
815  {
816  return true;
817  }
818 
819  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
820  $this->form = new ilPropertyFormGUI();
821  $this->form->setFormAction($this->ctrl->getFormAction($this,'updateInfo'));
822  $this->form->setTitle($this->lng->txt('grp_general_informations'));
823  $this->form->addCommandButton('updateInfo',$this->lng->txt('save'));
824  $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
825 
826  $area = new ilTextAreaInputGUI($this->lng->txt('grp_information'),'important');
827  $area->setInfo($this->lng->txt('grp_information_info'));
828  $area->setValue($this->object->getInformation());
829  $area->setRows(8);
830  $area->setCols(80);
831  $this->form->addItem($area);
832  }
833 
840  public function updateInfoObject()
841  {
842  $this->checkPermission('write');
843 
844  $this->object->setInformation(ilUtil::stripSlashes($_POST['important']));
845  $this->object->update();
846 
847  ilUtil::sendSuccess($this->lng->txt("settings_saved"));
848  $this->editInfoObject();
849  return true;
850  }
851 
853 
858  public function membersGalleryObject()
859  {
860  global $rbacsystem, $ilAccess, $ilUser;
861 
862  $is_admin = (bool) $rbacsystem->checkAccess("write", $this->object->getRefId());
863 
864  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.crs_members_gallery.html','Modules/Course');
865 
866  $this->setSubTabs('members');
867  $this->tabs_gui->setTabActive('members');
868 
869  $member_ids = $this->object->getGroupMemberIds();
870  $admin_ids = $this->object->getGroupAdminIds();
871 
872  // fetch all users data in one shot to improve performance
873  $members = $this->object->getGroupMemberData($member_ids);
874 
875  // MEMBERS
876  if(count($members))
877  {
878  $ordered_members = array();
879 
880  foreach($members as $member)
881  {
882  // get user object
883  if(!($usr_obj = ilObjectFactory::getInstanceByObjId($member["id"],false)))
884  {
885  continue;
886  }
887 
888  if(!$usr_obj->getActive())
889  {
890  continue;
891  }
892 
893  // please do not use strtoupper on first/last name for output
894  // this messes up with some unicode characters, i guess
895  // depending on php verion, alex
896  array_push($ordered_members,array("id" => $member["id"],
897  "login" => $usr_obj->getLogin(),
898  "lastname" => $usr_obj->getLastName(),
899  "firstname" => $usr_obj->getFirstName(),
900  "sortlastname" => strtoupper($usr_obj->getLastName()).strtoupper($usr_obj->getFirstName()),
901  "usr_obj" => $usr_obj));
902  }
903 
904  $ordered_members=ilUtil::sortArray($ordered_members,"sortlastname","asc");
905 
906  foreach($ordered_members as $member) {
907 
908  $usr_obj = $member["usr_obj"];
909 
910  $public_profile = $usr_obj->getPref("public_profile");
911  if ($public_profile == "g")
912  {
913  $public_profile = "y";
914  }
915 
916  // SET LINK TARGET FOR USER PROFILE
917  $this->ctrl->setParameterByClass("ilpublicuserprofilegui", "user", $member["id"]);
918  $profile_target = $this->ctrl->getLinkTargetByClass("ilpublicuserprofilegui","getHTML");
919 
920  // GET USER IMAGE
921  $file = $usr_obj->getPersonalPicturePath("xsmall");
922 
923  switch(in_array($member["id"],$admin_ids))
924  {
925  //admins
926  case 1:
927  if ($public_profile == "y")
928  {
929  $this->tpl->setCurrentBlock("tutor_linked");
930  $this->tpl->setVariable("LINK_PROFILE", $profile_target);
931  $this->tpl->setVariable("SRC_USR_IMAGE", $file);
932  $this->tpl->parseCurrentBlock();
933  }
934  else
935  {
936  $this->tpl->setCurrentBlock("tutor_not_linked");
937  $this->tpl->setVariable("SRC_USR_IMAGE", $file);
938  $this->tpl->parseCurrentBlock();
939  }
940  $this->tpl->setCurrentBlock("tutor");
941  break;
942 
943  case 0:
944  if ($public_profile == "y")
945  {
946  $this->tpl->setCurrentBlock("member_linked");
947  $this->tpl->setVariable("LINK_PROFILE", $profile_target);
948  $this->tpl->setVariable("SRC_USR_IMAGE", $file);
949  $this->tpl->parseCurrentBlock();
950  }
951  else
952  {
953  $this->tpl->setCurrentBlock("member_not_linked");
954  $this->tpl->setVariable("SRC_USR_IMAGE", $file);
955  $this->tpl->parseCurrentBlock();
956  }
957  $this->tpl->setCurrentBlock("member");
958  break;
959  }
960 
961  // do not show name, if public profile is not activated
962  if ($public_profile == "y")
963  {
964  $this->tpl->setVariable("FIRSTNAME", $member["firstname"]);
965  $this->tpl->setVariable("LASTNAME", $member["lastname"]);
966  }
967  $this->tpl->setVariable("LOGIN", $usr_obj->getLogin());
968  $this->tpl->parseCurrentBlock();
969  }
970  $this->tpl->setCurrentBlock("members");
971  //$this->tpl->setVariable("MEMBERS_TABLE_HEADER",$this->lng->txt('crs_members_title'));
972  $this->tpl->parseCurrentBlock();
973  }
974 
975  $this->tpl->setVariable("TITLE",$this->lng->txt('crs_members_print_title'));
976  $this->tpl->setVariable("CSS_PATH",ilUtil::getStyleSheetLocation());
977  }
978 
979 
980  protected function readMemberData($ids,$role = 'admin')
981  {
982  include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
983  $privacy = ilPrivacySettings::_getInstance();
984 
985  if($this->show_tracking)
986  {
987  include_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
988  $completed = ilLPStatusWrapper::_getCompleted($this->object->getId());
989  $in_progress = ilLPStatusWrapper::_getInProgress($this->object->getId());
990  $not_attempted = ilLPStatusWrapper::_getNotAttempted($this->object->getId());
991  $failed = ilLPStatusWrapper::_getFailed($this->object->getId());
992  }
993 
994  if($privacy->enabledGroupAccessTimes())
995  {
996  include_once('./Services/Tracking/classes/class.ilLearningProgress.php');
997  $progress = ilLearningProgress::_lookupProgressByObjId($this->object->getId());
998  }
999 
1000  foreach($ids as $usr_id)
1001  {
1002  $name = ilObjUser::_lookupName($usr_id);
1003  $tmp_data['firstname'] = $name['firstname'];
1004  $tmp_data['lastname'] = $name['lastname'];
1005  $tmp_data['login'] = ilObjUser::_lookupLogin($usr_id);
1006  $tmp_data['notification'] = $this->object->members_obj->isNotificationEnabled($usr_id) ? 1 : 0;
1007  $tmp_data['usr_id'] = $usr_id;
1008  $tmp_data['login'] = ilObjUser::_lookupLogin($usr_id);
1009 
1010  if($this->show_tracking)
1011  {
1012  if(in_array($usr_id,$completed))
1013  {
1014  $tmp_data['progress'] = LP_STATUS_COMPLETED;
1015  }
1016  elseif(in_array($usr_id,$in_progress))
1017  {
1018  $tmp_data['progress'] = LP_STATUS_IN_PROGRESS;
1019  }
1020  elseif(in_array($usr_id,$failed))
1021  {
1022  $tmp_data['progress'] = LP_STATUS_FAILED;
1023  }
1024  else
1025  {
1026  $tmp_data['progress'] = LP_STATUS_NOT_ATTEMPTED;
1027  }
1028  }
1029 
1030  if($privacy->enabledGroupAccessTimes())
1031  {
1032  if(isset($progress[$usr_id]['ts']) and $progress[$usr_id]['ts'])
1033  {
1034  $tmp_data['access_time'] = ilDatePresentation::formatDate(
1035  $tmp_date = new ilDateTime($progress[$usr_id]['ts'],IL_CAL_UNIX));
1036  $tmp_data['access_time_unix'] = $tmp_date->get(IL_CAL_UNIX);
1037  }
1038  else
1039  {
1040  $tmp_data['access_time'] = $this->lng->txt('no_date');
1041  $tmp_data['access_time_unix'] = 0;
1042  }
1043  }
1044 
1045  $members[$usr_id] = $tmp_data;
1046  }
1047  return $members ? $members : array();
1048  }
1049 
1056  public function membersObject()
1057  {
1058  global $ilUser, $ilToolbar, $lng, $ilCtrl;
1059 
1060  include_once('./Modules/Group/classes/class.ilGroupParticipants.php');
1061  include_once('./Modules/Group/classes/class.ilGroupParticipantsTableGUI.php');
1062 
1063  $this->checkPermission('write');
1064 
1065  include_once './Services/Tracking/classes/class.ilObjUserTracking.php';
1066  include_once('./Services/Tracking/classes/class.ilLPObjSettings.php');
1067  $this->show_tracking = (ilObjUserTracking::_enabledLearningProgress() and
1069  ilLPObjSettings::_lookupMode($this->object->getId()) != LP_MODE_DEACTIVATED);
1070 
1071 
1072  $part = ilGroupParticipants::_getInstanceByObjId($this->object->getId());
1073 
1074  $this->setSubTabs('members');
1075  $this->tabs_gui->setTabActive('members');
1076  $this->tabs_gui->setSubTabActive('grp_edit_members');
1077 
1078  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.grp_edit_members.html','Modules/Group');
1079  $this->tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
1080 
1081  // add members
1082 
1083  // user input
1084  include_once("./Services/Form/classes/class.ilUserLoginAutoCompleteInputGUI.php");
1085  $ul = new ilUserLoginAutoCompleteInputGUI($lng->txt("user"), "user_login", $this, "addMemberAutoComplete");
1086  $ul->setSize(15);
1087  $ilToolbar->addInputItem($ul, true);
1088 
1089  // member type
1090  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
1091  $options = array(
1092  ilObjGroup::GRP_MEMBER => $lng->txt("member"),
1093  ilObjGroup::GRP_ADMIN => $lng->txt("administrator")
1094  );
1095  $si = new ilSelectInputGUI("", "member_type");
1096  $si->setOptions($options);
1097  $ilToolbar->addInputItem($si);
1098 
1099  // add button
1100  $ilToolbar->addFormButton($lng->txt("add"), "addAsMember");
1101  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1102 
1103  // spacer
1104  $ilToolbar->addSeparator();
1105 
1106  // search button
1107  $ilToolbar->addButton($this->lng->txt("grp_search_users"),
1108  $this->ctrl->getLinkTargetByClass('ilRepositorySearchGUI','start'));
1109 
1110  $this->setShowHidePrefs();
1111 
1112 
1113  // Waiting list table
1114  include_once('./Modules/Group/classes/class.ilGroupWaitingList.php');
1115  $waiting_list = new ilGroupWaitingList($this->object->getId());
1116  if(count($wait = $waiting_list->getAllUsers()))
1117  {
1118  include_once('./Services/Membership/classes/class.ilWaitingListTableGUI.php');
1119  if($ilUser->getPref('grp_wait_hide'))
1120  {
1121  $table_gui = new ilWaitingListTableGUI($this,$waiting_list,false);
1122  $this->ctrl->setParameter($this,'wait_hide',0);
1123  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1124  $this->lng->txt('show'),
1125  '',
1126  ilUtil::getImagePath('edit_add.png'));
1127  $this->ctrl->clearParameters($this);
1128  }
1129  else
1130  {
1131  $table_gui = new ilWaitingListTableGUI($this,$waiting_list,true);
1132  $this->ctrl->setParameter($this,'wait_hide',1);
1133  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1134  $this->lng->txt('hide'),
1135  '',
1136  ilUtil::getImagePath('edit_remove.png'));
1137  $this->ctrl->clearParameters($this);
1138  }
1139  $table_gui->setUsers($wait);
1140  $table_gui->setTitle($this->lng->txt('grp_header_waiting_list'),'icon_usr.gif',$this->lng->txt('group_new_registrations'));
1141  $this->tpl->setVariable('TABLE_SUB',$table_gui->getHTML());
1142  }
1143 
1144 
1145  // Subscriber table
1146  if(count($subscribers = $part->getSubscribers()))
1147  {
1148  include_once('./Services/Membership/classes/class.ilSubscriberTableGUI.php');
1149  if($ilUser->getPref('grp_subscriber_hide'))
1150  {
1151  $table_gui = new ilSubscriberTableGUI($this,$part,false);
1152  $this->ctrl->setParameter($this,'subscriber_hide',0);
1153  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1154  $this->lng->txt('show'),
1155  '',
1156  ilUtil::getImagePath('edit_add.png'));
1157  $this->ctrl->clearParameters($this);
1158  }
1159  else
1160  {
1161  $table_gui = new ilSubscriberTableGUI($this,$part,true);
1162  $this->ctrl->setParameter($this,'subscriber_hide',1);
1163  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1164  $this->lng->txt('hide'),
1165  '',
1166  ilUtil::getImagePath('edit_remove.png'));
1167  $this->ctrl->clearParameters($this);
1168  }
1169  $table_gui->setSubscribers($subscribers);
1170  $table_gui->setTitle($this->lng->txt('group_new_registrations'),'icon_usr.gif',$this->lng->txt('group_new_registrations'));
1171  $this->tpl->setVariable('TABLE_SUB',$table_gui->getHTML());
1172  }
1173 
1174  if(count($part->getAdmins()))
1175  {
1176  if($ilUser->getPref('grp_admin_hide'))
1177  {
1178  $table_gui = new ilGroupParticipantsTableGUI($this,'admin',false,$this->show_tracking);
1179  $this->ctrl->setParameter($this,'admin_hide',0);
1180  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1181  $this->lng->txt('show'),
1182  '',
1183  ilUtil::getImagePath('edit_add.png'));
1184  $this->ctrl->clearParameters($this);
1185  }
1186  else
1187  {
1188  $table_gui = new ilGroupParticipantsTableGUI($this,'admin',true,$this->show_tracking);
1189  $this->ctrl->setParameter($this,'admin_hide',1);
1190  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1191  $this->lng->txt('hide'),
1192  '',
1193  ilUtil::getImagePath('edit_remove.png'));
1194  $this->ctrl->clearParameters($this);
1195  }
1196  $table_gui->setTitle($this->lng->txt('grp_admins'),'icon_usr.gif',$this->lng->txt('grp_admins'));
1197  $table_gui->parse($this->readMemberData($part->getAdmins()));
1198  $this->tpl->setVariable('ADMINS',$table_gui->getHTML());
1199  }
1200 
1201  if(count($part->getMembers()))
1202  {
1203  if($ilUser->getPref('grp_member_hide'))
1204  {
1205  $table_gui = new ilGroupParticipantsTableGUI($this,'member',false,$this->show_tracking);
1206  $this->ctrl->setParameter($this,'member_hide',0);
1207  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1208  $this->lng->txt('show'),
1209  '',
1210  ilUtil::getImagePath('edit_add.png'));
1211  $this->ctrl->clearParameters($this);
1212  }
1213  else
1214  {
1215  $table_gui = new ilGroupParticipantsTableGUI($this,'member',true,$this->show_tracking);
1216  $this->ctrl->setParameter($this,'member_hide',1);
1217  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1218  $this->lng->txt('hide'),
1219  '',
1220  ilUtil::getImagePath('edit_remove.png'));
1221  $this->ctrl->clearParameters($this);
1222  }
1223 
1224  $table_gui->setTitle($this->lng->txt('grp_members'),'icon_usr.gif',$this->lng->txt('grp_members'));
1225  $table_gui->parse($this->readMemberData($part->getMembers()));
1226  $this->tpl->setVariable('MEMBERS',$table_gui->getHTML());
1227 
1228  }
1229 
1230  $this->tpl->setVariable('TXT_SELECTED_USER',$this->lng->txt('grp_selected_users'));
1231  $this->tpl->setVariable('BTN_FOOTER_EDIT',$this->lng->txt('edit'));
1232  $this->tpl->setVariable('BTN_FOOTER_VAL',$this->lng->txt('remove'));
1233  $this->tpl->setVariable('BTN_FOOTER_MAIL',$this->lng->txt('grp_mem_send_mail'));
1234  $this->tpl->setVariable('ARROW_DOWN',ilUtil::getImagePath('arrow_downright.gif'));
1235 
1236  }
1237 
1242  {
1243  include_once("./Services/Form/classes/class.ilUserLoginAutoCompleteInputGUI.php");
1245  }
1246 
1253  public function assignSubscribersObject()
1254  {
1255  global $lng, $ilIliasIniFile,$ilUser;
1256 
1257  $this->checkPermission('write');
1258 
1259  if(!count($_POST['subscribers']))
1260  {
1261  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
1262  $this->membersObject();
1263  return false;
1264  }
1265 
1266  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1267  foreach($_POST['subscribers'] as $usr_id)
1268  {
1269  $this->object->members_obj->sendNotification(
1271  $usr_id
1272  );
1273 
1274  $this->object->members_obj->add($usr_id,IL_GRP_MEMBER);
1275  $this->object->members_obj->deleteSubscriber($usr_id);
1276 
1277  }
1278  ilUtil::sendSuccess($this->lng->txt("grp_msg_applicants_assigned"),true);
1279  $this->ctrl->redirect($this,'members');
1280  return true;
1281  }
1282 
1289  public function refuseSubscribersObject()
1290  {
1291  global $lng;
1292 
1293  $this->checkPermission('write');
1294 
1295  if(!count($_POST['subscribers']))
1296  {
1297  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
1298  $this->membersObject();
1299  return false;
1300  }
1301 
1302  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1303  foreach($_POST['subscribers'] as $usr_id)
1304  {
1305  $this->object->members_obj->sendNotification(
1307  $usr_id
1308  );
1309  $this->object->members_obj->deleteSubscriber($usr_id);
1310  }
1311  ilUtil::sendSuccess($this->lng->txt("grp_msg_applicants_removed"));
1312  $this->membersObject();
1313  return true;
1314 
1315  }
1316 
1325  {
1326  $this->checkPermission('write');
1327 
1328  if(!count($_POST["waiting"]))
1329  {
1330  ilUtil::sendFailure($this->lng->txt("no_checkbox"));
1331  $this->membersObject();
1332  return false;
1333  }
1334 
1335  include_once('./Modules/Group/classes/class.ilGroupWaitingList.php');
1336  $waiting_list = new ilGroupWaitingList($this->object->getId());
1337 
1338  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1339 
1340  $added_users = 0;
1341  foreach($_POST["waiting"] as $user_id)
1342  {
1343  if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user_id,false))
1344  {
1345  continue;
1346  }
1347  if($this->object->members_obj->isAssigned($user_id))
1348  {
1349  continue;
1350  }
1351  $this->object->members_obj->add($user_id,IL_GRP_MEMBER);
1352  $this->object->members_obj->sendNotification(
1354  $user_id
1355  );
1356  $waiting_list->removeFromList($user_id);
1357 
1358  include_once('./Modules/Forum/classes/class.ilForumNotification.php');
1359  ilForumNotification::checkForumsExistsInsert($this->object->getRefId(), $user_id);
1360 
1361  ++$added_users;
1362  }
1363  if($added_users)
1364  {
1365  ilUtil::sendSuccess($this->lng->txt("grp_users_added"));
1366  $this->membersObject();
1367 
1368  return true;
1369  }
1370  else
1371  {
1372  ilUtil::sendFailure($this->lng->txt("grp_users_already_assigned"));
1373  $this->searchObject();
1374 
1375  return false;
1376  }
1377  }
1378 
1385  public function refuseFromListObject()
1386  {
1387  $this->checkPermission('write');
1388 
1389  if(!count($_POST['waiting']))
1390  {
1391  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
1392  $this->membersObject();
1393  return false;
1394  }
1395 
1396  include_once('./Modules/Group/classes/class.ilGroupWaitingList.php');
1397  $waiting_list = new ilGroupWaitingList($this->object->getId());
1398 
1399  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1400  foreach($_POST["waiting"] as $user_id)
1401  {
1402  $waiting_list->removeFromList($user_id);
1403  $this->object->members_obj->sendNotification(
1405  $user_id
1406  );
1407  }
1408 
1409  ilUtil::sendSuccess($this->lng->txt('grp_users_removed_from_list'));
1410  $this->membersObject();
1411  return true;
1412  }
1413 
1419  public function confirmDeleteMembersObject()
1420  {
1421  $this->checkPermission('write');
1422 
1423  $this->setSubTabs('members');
1424  $this->tabs_gui->setTabActive('members');
1425  $this->tabs_gui->setSubTabActive('grp_edit_members');
1426 
1427  $participants_to_delete = (array) array_unique(array_merge((array) $_POST['admins'],(array) $_POST['members']));
1428 
1429  if(!count($participants_to_delete))
1430  {
1431  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
1432  $this->membersObject();
1433  return false;
1434  }
1435 
1436  // Check last admin
1437  $admins = (array) ilGroupParticipants::_getInstanceByObjId($this->object->getId())->getAdmins();
1438 
1439  $admins_after = (array) array_diff($admins, $participants_to_delete);
1440  if(!count($admins_after) and count($admins))
1441  {
1442  ilUtil::sendFailure($this->lng->txt('grp_err_administrator_required'));
1443  $this->membersObject();
1444  return false;
1445  }
1446 
1447  include_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
1448  $confirm = new ilConfirmationGUI();
1449  $confirm->setFormAction($this->ctrl->getFormAction($this,'deleteMembers'));
1450  $confirm->setHeaderText($this->lng->txt('grp_dismiss_member'));
1451  $confirm->setConfirm($this->lng->txt('confirm'),'deleteMembers');
1452  $confirm->setCancel($this->lng->txt('cancel'),'members');
1453 
1454  foreach($this->readMemberData(array_merge((array) $_POST['admins'],(array) $_POST['members'])) as $participants)
1455  {
1456  $confirm->addItem('participants[]',
1457  $participants['usr_id'],
1458  $participants['lastname'].', '.$participants['firstname'].' ['.$participants['login'].']',
1459  ilUtil::getImagePath('icon_usr.gif'));
1460  }
1461 
1462  $this->tpl->setContent($confirm->getHTML());
1463  }
1464 
1472  public function deleteMembersObject()
1473  {
1474  $this->checkPermission('write');
1475 
1476  if(!count($_POST['participants']))
1477  {
1478  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
1479  $this->membersObject();
1480  return true;
1481  }
1482 
1483  $this->object->members_obj->deleteParticipants($_POST['participants']);
1484 
1485  // Send notification
1486  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1487  include_once './Modules/Forum/classes/class.ilForumNotification.php';
1488  foreach($_POST['participants'] as $part)
1489  {
1490  $this->object->members_obj->sendNotification(
1492  $part
1493  );
1494  ilForumNotification::checkForumsExistsDelete($this->object->getRefId(), $part);
1495  }
1496 
1497 
1498  ilUtil::sendSuccess($this->lng->txt("grp_msg_membership_annulled"));
1499  $this->membersObject();
1500  return true;
1501  }
1502 
1511  {
1512  if(isset($_GET['member_id']))
1513  {
1514  $_POST['participants'] = array($_GET['member_id']);
1515  }
1516  else
1517  {
1518  $_POST['participants'] = array_unique(array_merge((array) $_POST['admins'],
1519  (array) $_POST['members'],
1520  (array) $_POST['waiting'],
1521  (array) $_POST['subscribers']));
1522  }
1523  if (!count($_POST['participants']))
1524  {
1525  ilUtil::sendFailure($this->lng->txt("no_checkbox"));
1526  $this->membersObject();
1527  return false;
1528  }
1529  foreach($_POST['participants'] as $usr_id)
1530  {
1531  $rcps[] = ilObjUser::_lookupLogin($usr_id);
1532  }
1533 
1534  require_once 'Services/Mail/classes/class.ilMailFormCall.php';
1536  $this,
1537  'members',
1538  array(),
1539  array('type' => 'new', 'rcp_to' => implode(',',$rcps),'sig' => $this->createMailSignature())));
1540  return true;
1541  }
1542 
1549  public function setShowHidePrefs()
1550  {
1551  global $ilUser;
1552 
1553  if(isset($_GET['admin_hide']))
1554  {
1555  $ilUser->writePref('grp_admin_hide',(int) $_GET['admin_hide']);
1556  }
1557  if(isset($_GET['member_hide']))
1558  {
1559  $ilUser->writePref('grp_member_hide',(int) $_GET['member_hide']);
1560  }
1561  if(isset($_GET['subscriber_hide']))
1562  {
1563  $ilUser->writePref('grp_subscriber_hide',(int) $_GET['subscriber_hide']);
1564  }
1565  if(isset($_GET['wait_hide']))
1566  {
1567  $ilUser->writePref('grp_wait_hide',(int) $_GET['wait_hide']);
1568  }
1569  }
1570 
1576  public function editMemberObject()
1577  {
1578  $_POST['members'] = array((int) $_GET['member_id']);
1579  $this->editMembersObject();
1580  }
1581 
1588  public function editMembersObject()
1589  {
1590  $this->checkPermission('write');
1591 
1592  $participants = array_unique(array_merge((array) $_POST['admins'],(array) $_POST['members']));
1593 
1594  if(!count($participants))
1595  {
1596  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
1597  $this->membersObject();
1598  return false;
1599  }
1600 
1601  $this->setSubTabs('members');
1602  $this->tabs_gui->setTabActive('members');
1603  $this->tabs_gui->setSubTabActive('grp_edit_members');
1604 
1605  include_once('./Modules/Group/classes/class.ilGroupEditParticipantsTableGUI.php');
1606  $table_gui = new ilGroupEditParticipantsTableGUI($this);
1607  $table_gui->setTitle($this->lng->txt('grp_mem_change_status'),'icon_usr.gif',$this->lng->txt('grp_mem_change_status'));
1608  $table_gui->setData($this->readMemberData($participants));
1609 
1610  $this->tpl->setContent($table_gui->getHTML());
1611  return true;
1612  }
1613 
1621  public function updateMembersObject()
1622  {
1623  $this->checkPermission('write');
1624 
1625  if(!count($_POST['participants']))
1626  {
1627  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
1628  $this->membersObject();
1629  return false;
1630  }
1631 
1632  // Check minimum one admin
1633  $has_admin = false;
1634  $admin_role = $this->object->getDefaultAdminRole();
1635  foreach(ilGroupParticipants::_getInstanceByObjId($this->object->getId())->getAdmins() as $admin_id)
1636  {
1637  if(!isset($_POST['roles'][$admin_id]))
1638  {
1639  $has_admin = true;
1640  break;
1641  }
1642  if(in_array($admin_role,$_POST['roles'][$admin_id]))
1643  {
1644  $has_admin = true;
1645  break;
1646  }
1647  }
1648 
1649  if(!$has_admin and ilGroupParticipants::_getInstanceByObjId($this->object->getId())->getCountAdmins())
1650  {
1651  ilUtil::sendFailure($this->lng->txt('grp_min_one_admin'));
1652  $_POST['members'] = $_POST['participants'];
1653  $this->editMembersObject();
1654  return false;
1655  }
1656 
1657  $admin_role = $this->object->getDefaultAdminRole();
1658 
1659  $notifications = $_POST['notification'] ? $_POST['notification'] : array();
1660  foreach($_POST['participants'] as $usr_id)
1661  {
1662  // Check if a status changed mail is required
1663  $notification = false;
1664  if($this->object->members_obj->isAdmin($usr_id) and !in_array($admin_role,(array) $_POST['roles'][$usr_id]))
1665  {
1666  $notification = true;
1667  }
1668  if(!$this->object->members_obj->isAdmin($usr_id) and in_array($admin_role,(array) $_POST['roles'][$usr_id]))
1669  {
1670  $notification = true;
1671  }
1672 
1673  // TODO: check no role, owner
1674  $this->object->members_obj->updateRoleAssignments($usr_id,(array) $_POST['roles'][$usr_id]);
1675 
1676  // Disable notification for all of them
1677  $this->object->members_obj->updateNotification($usr_id,0);
1678 
1679  if($this->object->members_obj->isAdmin($usr_id) and in_array($usr_id,$notifications))
1680  {
1681  $this->object->members_obj->updateNotification($usr_id,1);
1682  }
1683 
1684  if($notification)
1685  {
1686  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1687  $this->object->members_obj->sendNotification(
1689  $usr_id
1690  );
1691  }
1692  }
1693  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"));
1694  $this->membersObject();
1695  return true;
1696  }
1697 
1705  public function updateStatusObject()
1706  {
1707  $this->checkPermission('write');
1708 
1709  $notification = $_POST['notification'] ? $_POST['notification'] : array();
1710  foreach($this->object->members_obj->getAdmins() as $admin_id)
1711  {
1712  $this->object->members_obj->updateNotification($admin_id,(int) in_array($admin_id,$notification));
1713  }
1714  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
1715  $this->membersObject();
1716  }
1717 
1718 
1719 
1720 
1721 
1726  function canceledObject()
1727  {
1728  $return_location = $_GET["cmd_return_location"];
1729  if (strcmp($return_location, "") == 0)
1730  {
1731  $return_location = "";
1732  }
1733 
1734  $this->ctrl->redirect($this, $return_location);
1735  }
1736 
1737 
1738 
1743  public function leaveObject()
1744  {
1745  $this->checkPermission('leave');
1746 
1747  $this->tabs_gui->setTabActive('grp_btn_unsubscribe');
1748 
1749  $tpl = new ilTemplate('tpl.unsubscribe.html',true,true,'Modules/Group');
1750  $tpl->setVariable('UNSUB_FORMACTION',$this->ctrl->getFormAction($this));
1751  $tpl->setVariable('TXT_SUBMIT',$this->lng->txt('grp_btn_unsubscribe'));
1752  $tpl->setVariable('TXT_CANCEL',$this->lng->txt('cancel'));
1753 
1754  ilUtil::sendQuestion($this->lng->txt('grp_dismiss_myself'));
1755  $this->tpl->setContent($tpl->get());
1756  }
1757 
1764  public function unsubscribeObject()
1765  {
1766  global $ilUser,$tree;
1767 
1768  $this->checkPermission('leave');
1769 
1770  $this->object->members_obj->delete($ilUser->getId());
1771 
1772  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1773  $this->object->members_obj->sendNotification(
1775  $ilUser->getId()
1776  );
1777  $this->object->members_obj->sendNotification(
1779  $ilUser->getId()
1780  );
1781 
1782  include_once './Modules/Forum/classes/class.ilForumNotification.php';
1783  ilForumNotification::checkForumsExistsDelete($this->object->getRefId(), $ilUser->getId());
1784 
1785  ilUtil::sendSuccess($this->lng->txt('grp_msg_membership_annulled'),true);
1786  ilUtil::redirect('repository.php?ref_id='.$tree->getParentId($this->object->getRefId()));
1787  }
1788 
1789 
1795  {
1796  $user_ids = $_POST["id"];
1797 
1798  if (empty($user_ids[0]))
1799  {
1800  // TODO: jumps back to grp content. go back to last search result
1801  $this->ilErr->raiseError($this->lng->txt("no_checkbox"),$this->ilErr->MESSAGE);
1802  }
1803 
1804  foreach ($user_ids as $new_member)
1805  {
1806  if (!$this->object->addMember($new_member,$this->object->getDefaultMemberRole()))
1807  {
1808  $this->ilErr->raiseError("An Error occured while assigning user to group !",$this->ilErr->MESSAGE);
1809  }
1810  }
1811 
1812  unset($_SESSION["saved_post"]);
1813 
1814  ilUtil::sendSuccess($this->lng->txt("grp_msg_member_assigned"),true);
1815  $this->ctrl->redirect($this,'members');
1816  }
1817 
1822  {
1823  $users = explode(',', $_POST['user_login']);
1824  foreach($users as $user)
1825  {
1826  $_POST['user'][] = ilObjUser::_lookupId($user);
1827  }
1828 
1829  if(!$this->addUserObject())
1830  {
1831  $this->membersObject();
1832  }
1833  }
1834 
1839  function addUserObject()
1840  {
1841  $user_ids = $_POST["user"];
1842 
1843  $mail = new ilMail($_SESSION["AccountId"]);
1844 
1845  if (empty($user_ids[0]))
1846  {
1847  // TODO: jumps back to grp content. go back to last search result
1848  #$this->ilErr->raiseError($this->lng->txt("no_checkbox"),$this->ilErr->MESSAGE);
1849  ilUtil::sendFailure($this->lng->txt("no_checkbox"));
1850  return false;
1851  }
1852 
1853  foreach ($user_ids as $new_member)
1854  {
1855  switch($_POST['member_type'])
1856  {
1858  if (!$this->object->addMember($new_member,$this->object->getDefaultMemberRole()))
1859  {
1860  $this->ilErr->raiseError("An Error occured while assigning user to group !",$this->ilErr->MESSAGE);
1861  }
1862  break;
1863 
1864  case ilObjGroup::GRP_ADMIN:
1865  if (!$this->object->addMember($new_member,$this->object->getDefaultAdminRole()))
1866  {
1867  $this->ilErr->raiseError("An Error occured while assigning user to group !",$this->ilErr->MESSAGE);
1868  }
1869  break;
1870  }
1871 
1872  ilObjUser::_addDesktopItem($new_member, $this->object->getRefId(), 'grp');
1873 
1874  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1875  $this->object->members_obj->sendNotification(
1877  $new_member
1878  );
1879 
1880  include_once './Modules/Forum/classes/class.ilForumNotification.php';
1881  ilForumNotification::checkForumsExistsInsert($this->object->getRefId(), $new_member);
1882  }
1883 
1884  unset($_SESSION["saved_post"]);
1885  unset($_SESSION['grp_usr_search_result']);
1886 
1887  ilUtil::sendSuccess($this->lng->txt("grp_msg_member_assigned"),true);
1888  $this->ctrl->redirect($this,'members');
1889  }
1890 
1895  {
1896  global $rbacreview, $ilObjDataCache, $ilias;
1897  include_once('./Services/AccessControl/classes/class.ilObjRole.php');
1898 
1899  $this->lng->loadLanguageModule('mail');
1900  ilUtil::sendInfo($this->lng->txt('mail_select_recipients'));
1901 
1902  //$this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.mail_members.html',"Services/Mail");
1903  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.mail_members.html','Services/Contact');
1904 
1905 
1906  $this->setSubTabs('members');
1907  $this->tabs_gui->setTabActive('members');
1908 
1909  require_once 'Services/Mail/classes/class.ilMailFormCall.php';
1910  $this->tpl->setVariable("MAILACTION", ilMailFormCall::_getLinkTarget($this, 'mailMembers', array(), array('type' => 'role','sig' => $this->createMailSignature())));
1911  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
1912  $this->tpl->setVariable("TXT_MARKED_ENTRIES",$this->lng->txt('marked_entries'));
1913  $this->tpl->setVariable("OK",$this->lng->txt('next'));
1914 
1915  // Get role mailbox addresses
1916  $role_folder = $rbacreview->getRoleFolderOfObject($this->object->getRefId());
1917  $role_ids = $rbacreview->getRolesOfRoleFolder($role_folder['ref_id'], false);
1918  $role_addrs = array();
1919 
1920  // Sort by relevance
1921  $sorted_role_ids = array();
1922  $counter = 2;
1923  foreach($role_ids as $role_id)
1924  {
1925  switch(substr(ilObject::_lookupTitle($role_id),0,8))
1926  {
1927  case 'il_grp_a':
1928  $sorted_role_ids[1] = $role_id;
1929  break;
1930 
1931  case 'il_grp_m':
1932  $sorted_role_ids[0] = $role_id;
1933  break;
1934 
1935  default:
1936  $sorted_role_ids[$counter++] = $role_id;
1937  break;
1938  }
1939  }
1940  ksort($sorted_role_ids,SORT_NUMERIC);
1941  foreach ((array) $sorted_role_ids as $role_id)
1942  {
1943  $this->tpl->setCurrentBlock("mailbox_row");
1944  $role_addr = $rbacreview->getRoleMailboxAddress($role_id);
1945 
1946  // check if role title is unique. if not force use pear mail for roles
1947  $ids_for_role_title = ilObject::_getIdsForTitle(ilObject::_lookupTitle($role_id), 'role');
1948  if(count($ids_for_role_title) >= 2)
1949  {
1950  $ilias->setSetting('pear_mail_enable',true);
1951  }
1952 
1953  $this->tpl->setVariable("CHECK_MAILBOX",ilUtil::formCheckbox(1,'roles[]',
1954  htmlspecialchars($role_addr)
1955  ));
1956 
1957  if (ilMail::_usePearMail())
1958  {
1959  // if pear mail is enabled, mailbox addresses are already localized in the language of the user
1960  $this->tpl->setVariable("MAILBOX",$role_addr);
1961  }
1962  else
1963  {
1964  // if pear mail is not enabled, we need to localize mailbox addresses in the language of the user
1965  $this->tpl->setVariable("MAILBOX",ilObjRole::_getTranslation($ilObjDataCache->lookupTitle($role_id)) . " (".$role_addr.")");
1966  }
1967  $this->tpl->parseCurrentBlock();
1968  }
1969  }
1970 
1976  {
1977  $user_ids = $_POST["user_id"];
1978 
1979  if (empty($user_ids[0]))
1980  {
1981  $this->ilErr->raiseError($this->lng->txt("no_checkbox"),$this->ilErr->MESSAGE);
1982  }
1983 
1984  $mail = new ilMail($_SESSION["AccountId"]);
1985 
1986  foreach ($user_ids as $new_member)
1987  {
1988  $user =& $this->ilias->obj_factory->getInstanceByObjId($new_member);
1989 
1990  $this->object->deleteApplicationListEntry($new_member);
1991  $mail->sendMail($user->getLogin(),"","","Membership application refused: Group ".$this->object->getTitle(),"Your application has been refused.",array(),array('system'));
1992  }
1993 
1994  ilUtil::sendSuccess($this->lng->txt("grp_msg_applicants_removed"),true);
1995  $this->ctrl->redirect($this,'members');
1996  }
1997 
1998  // get tabs
1999  function getTabs(&$tabs_gui)
2000  {
2001  global $rbacsystem, $ilUser, $ilAccess, $lng;
2002 
2003  if ($rbacsystem->checkAccess('read',$this->ref_id))
2004  {
2005  $tabs_gui->addTab("view_content", $lng->txt("content"),
2006  $this->ctrl->getLinkTarget($this, ""));
2007  }
2008  if ($rbacsystem->checkAccess('visible',$this->ref_id))
2009  {
2010  $tabs_gui->addTarget("info_short",
2011  $this->ctrl->getLinkTargetByClass(
2012  array("ilobjgroupgui", "ilinfoscreengui"), "showSummary"),
2013  "infoScreen",
2014  "", "",false);
2015  }
2016 
2017 
2018  if ($ilAccess->checkAccess('write','',$this->object->getRefId()))
2019  {
2020  $tabs_gui->addTarget("settings",
2021  $this->ctrl->getLinkTarget($this, "edit"), array("edit", "editMapSettings"), get_class($this),
2022  "");
2023  }
2024 
2025  // Members
2026  if($ilAccess->checkAccess('read','',$this->object->getRefId()))
2027  {
2028  $mem_cmd = $ilAccess->checkAccess('write','',$this->ref_id) ? "members" : "membersGallery";
2029  $tabs_gui->addTarget("members",$this->ctrl->getLinkTarget($this, $mem_cmd), array(),get_class($this));
2030  }
2031 
2032 
2033  // learning progress
2034  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
2035  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()))
2036  {
2037  $tabs_gui->addTarget('learning_progress',
2038  $this->ctrl->getLinkTargetByClass(array('ilobjgroupgui','illearningprogressgui'),''),
2039  '',
2040  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
2041  }
2042 
2043 
2044 
2045 
2046  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
2047  {
2048  $tabs_gui->addTarget(
2049  'export',
2050  $this->ctrl->getLinkTargetByClass('ilexportgui',''),
2051  'export',
2052  'ilexportgui'
2053  );
2054  }
2055 
2056  /*
2057  if ($rbacsystem->checkAccess('write',$this->object->getRefId()))
2058  {
2059 
2060 
2061  $tabs_gui->addTarget('export',
2062  $this->ctrl->getLinkTarget($this,'listExportFiles'),
2063  array('listExportFiles','exportXML','confirmDeleteExportFile','downloadExportFile'),
2064  get_class($this));
2065  }
2066  */
2067  // parent tabs (all container: edit_permission, clipboard, trash
2068  parent::getTabs($tabs_gui);
2069 
2070  if($ilAccess->checkAccess('join','',$this->object->getRefId()) and
2071  !$this->object->members_obj->isAssigned($ilUser->getId()))
2072  {
2073  include_once './Modules/Group/classes/class.ilGroupWaitingList.php';
2074  if(ilGroupWaitingList::_isOnList($ilUser->getId(), $this->object->getId()))
2075  {
2076  $tabs_gui->addTab(
2077  'leave',
2078  $this->lng->txt('membership_leave'),
2079  $this->ctrl->getLinkTargetByClass('ilgroupregistrationgui','show','')
2080  );
2081 
2082  }
2083  else
2084  {
2085 
2086  $tabs_gui->addTarget("join",
2087  $this->ctrl->getLinkTargetByClass('ilgroupregistrationgui', "show"),
2088  'show',
2089  "");
2090  }
2091  }
2092  if($ilAccess->checkAccess('leave','',$this->object->getRefId()) and
2093  $this->object->members_obj->isMember($ilUser->getId()))
2094  {
2095  $tabs_gui->addTarget("grp_btn_unsubscribe",
2096  $this->ctrl->getLinkTarget($this, "leave"),
2097  '',
2098  "");
2099  }
2100  }
2101 
2106  public function importFileObject()
2107  {
2108  global $lng;
2109 
2110  if($new_id = parent::importFileObject())
2111  {
2112  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
2113  $this->ctrl->returnToParent($this);
2114  }
2115  }
2116 
2117 
2118 
2119  // IMPORT FUNCTIONS
2120 
2122  {
2123  if(!is_array($_FILES['xmldoc']))
2124  {
2125  ilUtil::sendFailure($this->lng->txt("import_file_not_valid"));
2126  $this->createObject();
2127  return false;
2128  }
2129 
2130  include_once './Modules/Group/classes/class.ilObjGroup.php';
2131 
2132  if($ref_id = ilObjGroup::_importFromFile($_FILES['xmldoc'],(int) $_GET['ref_id']))
2133  {
2134  $this->ctrl->setParameter($this, "ref_id", $ref_id);
2135  ilUtil::sendSuccess($this->lng->txt("import_grp_finished"),true);
2136  ilUtil::redirect($this->ctrl->getLinkTarget($this,'edit','',false,false));
2137  }
2138 
2139  ilUtil::sendFailure($this->lng->txt("import_file_not_valid"));
2140  $this->createObject();
2141  }
2142 
2143  // Methods for ConditionHandlerInterface
2144  function initConditionHandlerGUI($item_id)
2145  {
2146  include_once './classes/class.ilConditionHandlerInterface.php';
2147 
2148  if(!is_object($this->chi_obj))
2149  {
2150  if($_GET['item_id'])
2151  {
2152  $this->chi_obj =& new ilConditionHandlerInterface($this,$item_id);
2153  $this->ctrl->saveParameter($this,'item_id',$_GET['item_id']);
2154  }
2155  else
2156  {
2157  $this->chi_obj =& new ilConditionHandlerInterface($this);
2158  }
2159  }
2160  return true;
2161  }
2162 
2163 
2170  function exportObject()
2171  {
2172  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.grp_members_export.html");
2173  $this->tpl->setCurrentBlock("adm_content");
2174  $this->tpl->setVariable("FORMACTION", $this->getFormAction("export",$this->ctrl->getFormAction($this)));
2175  $this->tpl->setVariable("BUTTON_EXPORT", $this->lng->txt("export_group_members"));
2176  $this->tpl->parseCurrentBlock();
2177  }
2178 
2186  {
2187  $title = preg_replace("/\s/", "_", $this->object->getTitle());
2188  include_once "./Services/Excel/classes/class.ilExcelWriterAdapter.php";
2189  $adapter = new ilExcelWriterAdapter("export_" . $title . ".xls");
2190  $workbook = $adapter->getWorkbook();
2191  // Creating a worksheet
2192  $format_bold =& $workbook->addFormat();
2193  $format_bold->setBold();
2194  $format_percent =& $workbook->addFormat();
2195  $format_percent->setNumFormat("0.00%");
2196  $format_datetime =& $workbook->addFormat();
2197  $format_datetime->setNumFormat("DD/MM/YYYY hh:mm:ss");
2198  $format_title =& $workbook->addFormat();
2199  $format_title->setBold();
2200  $format_title->setColor('black');
2201  $format_title->setPattern(1);
2202  $format_title->setFgColor('silver');
2203  $worksheet =& $workbook->addWorksheet();
2204  $column = 0;
2205  $profile_data = array("email", "gender", "firstname", "lastname", "person_title", "institution",
2206  "department", "street", "zipcode","city", "country", "phone_office", "phone_home", "phone_mobile",
2207  "fax", "matriculation");
2208  foreach ($profile_data as $data)
2209  {
2210  $worksheet->writeString(0, $column++, $this->cleanString($this->lng->txt($data)), $format_title);
2211  }
2212  $member_ids = $this->object->getGroupMemberIds();
2213  $row = 1;
2214  foreach ($member_ids as $member_id)
2215  {
2216  $column = 0;
2217  $member =& $this->ilias->obj_factory->getInstanceByObjId($member_id);
2218  if ($member->getPref("public_email")=="y")
2219  {
2220  $worksheet->writeString($row, $column++, $this->cleanString($member->getEmail()));
2221  }
2222  else
2223  {
2224  $column++;
2225  }
2226  $worksheet->writeString($row, $column++, $this->cleanString($this->lng->txt("gender_" . $member->getGender())));
2227  $worksheet->writeString($row, $column++, $this->cleanString($member->getFirstname()));
2228  $worksheet->writeString($row, $column++, $this->cleanString($member->getLastname()));
2229  $worksheet->writeString($row, $column++, $this->cleanString($member->getUTitle()));
2230  if ($member->getPref("public_institution")=="y")
2231  {
2232  $worksheet->writeString($row, $column++, $this->cleanString($member->getInstitution()));
2233  }
2234  else
2235  {
2236  $column++;
2237  }
2238  if ($member->getPref("public_department")=="y")
2239  {
2240  $worksheet->writeString($row, $column++, $this->cleanString($member->getDepartment()));
2241  }
2242  else
2243  {
2244  $column++;
2245  }
2246  if ($member->getPref("public_street")=="y")
2247  {
2248  $worksheet->writeString($row, $column++, $this->cleanString($member->getStreet()));
2249  }
2250  else
2251  {
2252  $column++;
2253  }
2254  if ($member->getPref("public_zip")=="y")
2255  {
2256  $worksheet->writeString($row, $column++, $this->cleanString($member->getZipcode()));
2257  }
2258  else
2259  {
2260  $column++;
2261  }
2262  if ($member->getPref("public_city")=="y")
2263  {
2264  $worksheet->writeString($row, $column++, $this->cleanString($member->getCity()));
2265  }
2266  else
2267  {
2268  $column++;
2269  }
2270  if ($member->getPref("public_country")=="y")
2271  {
2272  $worksheet->writeString($row, $column++, $this->cleanString($member->getCountry()));
2273  }
2274  else
2275  {
2276  $column++;
2277  }
2278  if ($member->getPref("public_phone_office")=="y")
2279  {
2280  $worksheet->writeString($row, $column++, $this->cleanString($member->getPhoneOffice()));
2281  }
2282  else
2283  {
2284  $column++;
2285  }
2286  if ($member->getPref("public_phone_home")=="y")
2287  {
2288  $worksheet->writeString($row, $column++, $this->cleanString($member->getPhoneHome()));
2289  }
2290  else
2291  {
2292  $column++;
2293  }
2294  if ($member->getPref("public_phone_mobile")=="y")
2295  {
2296  $worksheet->writeString($row, $column++, $this->cleanString($member->getPhoneMobile()));
2297  }
2298  else
2299  {
2300  $column++;
2301  }
2302  if ($member->getPref("public_fax")=="y")
2303  {
2304  $worksheet->writeString($row, $column++, $this->cleanString($member->getFax()));
2305  }
2306  else
2307  {
2308  $column++;
2309  }
2310  if ($member->getPref("public_matriculation")=="y")
2311  {
2312  $worksheet->writeString($row, $column++, $this->cleanString($member->getMatriculation()));
2313  }
2314  else
2315  {
2316  $column++;
2317  }
2318  $row++;
2319  }
2320  $workbook->close();
2321  }
2322 
2331  function cleanString($str)
2332  {
2333  return str_replace(array("��","��","��","��","��","��","��"), array("ae","oe","ue","ss","Ae","Oe","Ue"), $str);
2334  }
2335 
2346  function infoScreenObject()
2347  {
2348  $this->ctrl->setCmd("showSummary");
2349  $this->ctrl->setCmdClass("ilinfoscreengui");
2350  $this->infoScreen();
2351  }
2352 
2356  function infoScreen()
2357  {
2358  global $rbacsystem;
2359 
2360  $this->tabs_gui->setTabActive('info_short');
2361 
2362  if(!$rbacsystem->checkAccess("visible", $this->ref_id))
2363  {
2364  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
2365  }
2366 
2367  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
2368  $info = new ilInfoScreenGUI($this);
2369 
2370  if(strlen($this->object->getInformation()))
2371  {
2372  $info->addSection($this->lng->txt('grp_general_informations'));
2373  $info->addProperty($this->lng->txt('grp_information'), nl2br(
2374  ilUtil::makeClickable ($this->object->getInformation(), true)));
2375  }
2376 
2377  $info->enablePrivateNotes();
2378  $info->enableLearningProgress(true);
2379 
2380  $info->addSection($this->lng->txt('group_registration'));
2381  $info->showLDAPRoleGroupMappingInfo();
2382 
2383  if(!$this->object->isRegistrationEnabled())
2384  {
2385  $info->addProperty($this->lng->txt('group_registration_mode'),
2386  $this->lng->txt('grp_reg_deac_info_screen'));
2387 
2388  }
2389  else
2390  {
2391  switch($this->object->getRegistrationType())
2392  {
2394  $info->addProperty($this->lng->txt('group_registration_mode'),
2395  $this->lng->txt('grp_reg_direct_info_screen'));
2396  break;
2397 
2399  $info->addProperty($this->lng->txt('group_registration_mode'),
2400  $this->lng->txt('grp_reg_req_info_screen'));
2401  break;
2402 
2404  $info->addProperty($this->lng->txt('group_registration_mode'),
2405  $this->lng->txt('grp_reg_passwd_info_screen'));
2406  break;
2407 
2408  }
2409  /*
2410  $info->addProperty($this->lng->txt('group_registration_time'),
2411  ilDatePresentation::formatPeriod(
2412  $this->object->getRegistrationStart(),
2413  $this->object->getRegistrationEnd()));
2414  */
2415  if($this->object->isRegistrationUnlimited())
2416  {
2417  $info->addProperty($this->lng->txt('group_registration_time'),
2418  $this->lng->txt('grp_registration_unlimited'));
2419  }
2420  elseif($this->object->getRegistrationStart()->getUnixTime() < time())
2421  {
2422  $info->addProperty($this->lng->txt("group_registration_time"),
2423  $this->lng->txt('cal_until').' '.
2424  ilDatePresentation::formatDate($this->object->getRegistrationEnd()));
2425  }
2426  elseif($this->object->getRegistrationStart()->getUnixTime() >= time())
2427  {
2428  $info->addProperty($this->lng->txt("group_registration_time"),
2429  $this->lng->txt('cal_from').' '.
2430  ilDatePresentation::formatDate($this->object->getRegistrationStart()));
2431  }
2432  if ($this->object->isMembershipLimited())
2433  {
2434  $info->addProperty($this->lng->txt("mem_free_places"),
2435  max(0,$this->object->getMaxMembers() - $this->object->members_obj->getCountMembers()));
2436 
2437  }
2438 
2439  }
2440 
2441  // Confirmation
2442  include_once('Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
2443  $privacy = ilPrivacySettings::_getInstance();
2444 
2445  include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
2446  if($privacy->groupConfirmationRequired() or ilCourseDefinedFieldDefinition::_getFields($this->object->getId()) or $privacy->enabledGroupExport())
2447  {
2448  include_once('Services/PrivacySecurity/classes/class.ilExportFieldsInfo.php');
2449 
2450  $field_info = ilExportFieldsInfo::_getInstanceByType($this->object->getType());
2451 
2452  $this->lng->loadLanguageModule('ps');
2453  $info->addSection($this->lng->txt('grp_user_agreement_info'));
2454  $info->addProperty($this->lng->txt('ps_export_data'),$field_info->exportableFieldsToInfoString());
2455 
2456  if($fields = ilCourseDefinedFieldDefinition::_fieldsToInfoString($this->object->getId()))
2457  {
2458  $info->addProperty($this->lng->txt('ps_grp_user_fields'),$fields);
2459  }
2460  }
2461 
2462 
2463  // forward the command
2464  $this->ctrl->forwardCommand($info);
2465  }
2466 
2470  function _goto($a_target, $a_add = "")
2471  {
2472  global $ilAccess, $ilErr, $lng,$ilUser;
2473 
2474  include_once './Services/Membership/classes/class.ilMembershipRegistrationCodeUtils.php';
2475  if(substr($a_add,0,5) == 'rcode')
2476  {
2477  if($ilUser->getId() == ANONYMOUS_USER_ID)
2478  {
2479  // Redirect to login for anonymous
2481  "login.php?target=".$_GET["target"]."&cmd=force_login&lang=".
2482  $ilUser->getCurrentLanguage()
2483  );
2484  }
2485 
2486  // Redirects to target location after assigning user to course
2488  $a_target,
2490  substr($a_add,5)
2491  );
2492  }
2493 
2494  if ($a_add == "mem" && $ilAccess->checkAccess("write", "", $a_target))
2495  {
2496  $_GET["cmd"] = "members";
2497  $_GET["ref_id"] = $a_target;
2498  include("repository.php");
2499  exit;
2500  }
2501 
2502  if ($ilAccess->checkAccess("read", "", $a_target))
2503  {
2504  $_GET["cmd"] = "frameset";
2505  $_GET["ref_id"] = $a_target;
2506  include("repository.php");
2507  exit;
2508  }
2509  else
2510  {
2511  // to do: force flat view
2512  if ($ilAccess->checkAccess("visible", "", $a_target))
2513  {
2514  $_GET["cmd"] = "infoScreen";
2515  $_GET["ref_id"] = $a_target;
2516  include("repository.php");
2517  exit;
2518  }
2519  else
2520  {
2521  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
2522  {
2523  $_GET["cmd"] = "frameset";
2524  $_GET["target"] = "";
2525  $_GET["ref_id"] = ROOT_FOLDER_ID;
2526  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
2527  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
2528  include("repository.php");
2529  exit;
2530  }
2531  }
2532  }
2533  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
2534  }
2535 
2536 
2544  protected function initForm($a_mode = 'edit')
2545  {
2546  global $ilUser,$tpl,$tree;
2547 
2548  if(is_object($this->form))
2549  {
2550  return true;
2551  }
2552 
2553  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2554 
2555  $this->form = new ilPropertyFormGUI();
2556  switch($a_mode)
2557  {
2558  case 'edit':
2559  $this->form->setFormAction($this->ctrl->getFormAction($this,'update'));
2560  break;
2561 
2562  default:
2563  $this->form->setTableWidth('600px');
2564  $this->form->setFormAction($this->ctrl->getFormAction($this,'save'));
2565  break;
2566  }
2567 
2568  // title
2569  $title = new ilTextInputGUI($this->lng->txt('title'),'title');
2570  $title->setSubmitFormOnEnter(true);
2571  $title->setValue($this->object->getTitle());
2572  $title->setSize(40);
2573  $title->setMaxLength(128);
2574  $title->setRequired(true);
2575  $this->form->addItem($title);
2576 
2577  // desc
2578  $desc = new ilTextAreaInputGUI($this->lng->txt('description'),'desc');
2579  $desc->setValue($this->object->getLongDescription());
2580  $desc->setRows(2);
2581  $desc->setCols(40);
2582  $this->form->addItem($desc);
2583 
2584  // Group type
2585  $grp_type = new ilRadioGroupInputGUI($this->lng->txt('grp_typ'),'grp_type');
2586 
2587  if($a_mode == 'edit')
2588  {
2589  $type = ($this->object->getGroupType() ? $this->object->getGroupType() : $this->object->readGroupStatus());
2590  }
2591  else
2592  {
2593  $type = ($this->object->getGroupType() ? $this->object->getGroupType() : GRP_TYPE_PUBLIC);
2594  }
2595 
2596  $grp_type->setValue($type);
2597  $grp_type->setRequired(true);
2598 
2599  // OPEN GROUP
2600  #$opt_open = new ilRadioOption($this->lng->txt('grp_open'),GRP_TYPE_OPEN,$this->lng->txt('grp_open_info'));
2601  #$grp_type->addOption($opt_open);
2602 
2603 
2604  // PUBLIC GROUP
2605  $opt_public = new ilRadioOption($this->lng->txt('grp_public'),GRP_TYPE_PUBLIC,$this->lng->txt('grp_public_info'));
2606  $grp_type->addOption($opt_public);
2607 
2608  // Registration type
2609  $reg_type = new ilRadioGroupInputGUI('','registration_type');
2610  $reg_type->setValue($this->object->getRegistrationType());
2611 
2612  $opt_dir = new ilRadioOption($this->lng->txt('grp_reg_direct'),GRP_REGISTRATION_DIRECT);#$this->lng->txt('grp_reg_direct_info'));
2613  $reg_type->addOption($opt_dir);
2614 
2615  $opt_pass = new ilRadioOption($this->lng->txt('grp_pass_request'),GRP_REGISTRATION_PASSWORD);
2616  $pass = new ilTextInputGUI('','password');
2617  $pass->setInfo($this->lng->txt('grp_reg_password_info'));
2618  $pass->setValue($this->object->getPassword());
2619  $pass->setSize(10);
2620  $pass->setMaxLength(32);
2621  $opt_pass->addSubItem($pass);
2622  $reg_type->addOption($opt_pass);
2623  $opt_public->addSubItem($reg_type);
2624 
2625  $opt_req = new ilRadioOption($this->lng->txt('grp_reg_request'),GRP_REGISTRATION_REQUEST,$this->lng->txt('grp_reg_request_info'));
2626  $reg_type->addOption($opt_req);
2627 
2628  $opt_deact = new ilRadioOption($this->lng->txt('grp_reg_disabled'),GRP_REGISTRATION_DEACTIVATED,$this->lng->txt('grp_reg_disabled_info'));
2629  $reg_type->addOption($opt_deact);
2630 
2631  // Registration codes
2632  $reg_code = new ilCheckboxInputGUI($this->lng->txt('grp_reg_code'),'reg_code_enabled');
2633  $reg_code->setChecked($this->object->isRegistrationAccessCodeEnabled());
2634  $reg_code->setValue(1);
2635  $reg_code->setInfo($this->lng->txt('grp_reg_code_enabled_info'));
2636 
2637  /*
2638  $code = new ilNonEditableValueGUI($this->lng->txt('crs_reg_code_value'));
2639  $code->setValue($this->object->getRegistrationAccessCode());
2640  $reg_code->addSubItem($code);
2641  */
2642 
2643  // Create default access code
2644  if(!$this->object->getRegistrationAccessCode())
2645  {
2646  include_once './Services/Membership/classes/class.ilMembershipRegistrationCodeUtils.php';
2647  $this->object->setRegistrationAccessCode(ilMembershipRegistrationCodeUtils::generateCode());
2648  }
2649  $reg_link = new ilHiddenInputGUI('reg_code');
2650  $reg_link->setValue($this->object->getRegistrationAccessCode());
2651  $this->form->addItem($reg_link);
2652 
2653  $link = new ilCustomInputGUI($this->lng->txt('grp_reg_code_link'));
2654  include_once './classes/class.ilLink.php';
2655  $val = ilLink::_getLink($this->object->getRefId(),$this->object->getType(),array(),'_rcode'.$this->object->getRegistrationAccessCode());
2656  $link->setHTML('<font class="small">'.$val.'</font>');
2657  $reg_code->addSubItem($link);
2658  $opt_public->addSubItem($reg_code);
2659 
2660 
2661  // CLOSED GROUP
2662  $opt_closed = new ilRadioOption($this->lng->txt('grp_closed'),GRP_TYPE_CLOSED,$this->lng->txt('grp_closed_info'));
2663  $grp_type->addOption($opt_closed);
2664  if($a_mode == 'update_group_type')
2665  {
2666  $grp_type->setAlert($this->lng->txt('grp_type_changed_info'));
2667  }
2668  $this->form->addItem($grp_type);
2669 
2670  // Sorting
2671  if($a_mode == 'create')
2672  {
2673  $ref_id = (int) $_GET['ref_id'];
2674  }
2675  else
2676  {
2677  $ref_id = $this->object->getRefId();
2678  }
2679 
2680  $hasParentCourse = $tree->checkForParentType($ref_id,'crs');
2681 
2682  $sog = new ilRadioGroupInputGUI($this->lng->txt('sorting_header'),'sor');
2683  $sog->setRequired(true);
2684  if($a_mode == 'edit')
2685  {
2687  }
2688  elseif($hasParentCourse)
2689  {
2690  $sog->setValue(ilContainer::SORT_INHERIT);
2691  }
2692  else
2693  {
2694  $sog->setValue(ilContainer::SORT_TITLE);
2695  }
2696 
2697  if($hasParentCourse)
2698  {
2699  $sde = new ilRadioOption();
2700  $sde->setValue(ilContainer::SORT_INHERIT);
2701 
2702  $title = $this->lng->txt('sort_inherit_prefix');
2703  $title .= ' ('.ilContainerSortingSettings::sortModeToString(ilContainerSortingSettings::lookupSortModeFromParentContainer(ilObject::_lookupObjectId($ref_id))).') ';
2704  $sde->setTitle($title);
2705  $sde->setInfo($this->lng->txt('sorting_info_inherit'));
2706  $sog->addOption($sde);
2707  }
2708 
2709  $sma = new ilRadioOption();
2710  $sma->setValue(ilContainer::SORT_TITLE);
2711  $sma->setTitle($this->lng->txt('sorting_title_header'));
2712  $sma->setInfo($this->lng->txt('sorting_info_title'));
2713  $sog->addOption($sma);
2714 
2715  $sti = new ilRadioOption();
2716  $sti->setValue(ilContainer::SORT_MANUAL);
2717  $sti->setTitle($this->lng->txt('sorting_manual_header'));
2718  $sti->setInfo($this->lng->txt('sorting_info_manual'));
2719  $sog->addOption($sti);
2720 
2721  $this->form->addItem($sog);
2722 
2723  // time limit
2724  $time_limit = new ilCheckboxInputGUI($this->lng->txt('grp_reg_limited'),'reg_limit_time');
2725  $time_limit->setOptionTitle($this->lng->txt('grp_reg_limit_time'));
2726  $time_limit->setChecked($this->object->isRegistrationUnlimited() ? false : true);
2727 
2728  $this->lng->loadLanguageModule('dateplaner');
2729  include_once './Services/Form/classes/class.ilDateDurationInputGUI.php';
2730  $tpl->addJavaScript('./Services/Form/js/date_duration.js');
2731  $dur = new ilDateDurationInputGUI($this->lng->txt('grp_reg_period'),'reg');
2732  $dur->setStartText($this->lng->txt('cal_start'));
2733  $dur->setEndText($this->lng->txt('cal_end'));
2734  $dur->setMinuteStepSize(5);
2735  $dur->setShowDate(true);
2736  $dur->setShowTime(true);
2737  $dur->setStart($this->object->getRegistrationStart());
2738  $dur->setEnd($this->object->getRegistrationEnd());
2739 
2740  $time_limit->addSubItem($dur);
2741 
2742  /*
2743  $start = new ilDateTimeInputGUI($this->lng->txt('grp_reg_start'),'registration_start');
2744  $start->setShowTime(true);
2745  $start->setDate($this->object->getRegistrationStart());
2746  $time_limit->addSubItem($start);
2747 
2748  $end = new ilDateTimeInputGUI($this->lng->txt('grp_reg_end'),'registration_end');
2749  $end->setShowTime(true);
2750  $end->setDate($this->object->getRegistrationEnd());
2751 
2752  $time_limit->addSubItem($end);
2753  */
2754 
2755  $this->form->addItem($time_limit);
2756 
2757  // max member
2758  $lim = new ilCheckboxInputGUI($this->lng->txt('reg_grp_max_members_short'),'registration_membership_limited');
2759  $lim->setValue(1);
2760  $lim->setOptionTitle($this->lng->txt('reg_grp_max_members'));
2761  $lim->setChecked($this->object->isMembershipLimited());
2762 
2763 
2764  $max = new ilTextInputGUI('','registration_max_members');
2765  $max->setValue($this->object->getMaxMembers() ? $this->object->getMaxMembers() : '');
2766  $max->setTitle($this->lng->txt('members').':');
2767  $max->setSize(3);
2768  $max->setMaxLength(4);
2769  $max->setInfo($this->lng->txt('grp_reg_max_members_info'));
2770  $lim->addSubItem($max);
2771 
2772  $wait = new ilCheckboxInputGUI('','waiting_list');
2773  $wait->setValue(1);
2774  $wait->setOptionTitle($this->lng->txt('grp_waiting_list'));
2775  $wait->setInfo($this->lng->txt('grp_waiting_list_info'));
2776  $wait->setChecked($this->object->isWaitingListEnabled() ? true : false);
2777  $lim->addSubItem($wait);
2778  $this->form->addItem($lim);
2779 
2780  switch($a_mode)
2781  {
2782  case 'create':
2783  $this->form->setTitle($this->lng->txt('grp_new'));
2784  $this->form->setTitleIcon(ilUtil::getImagePath('icon_grp.gif'));
2785 
2786  $this->form->addCommandButton('save',$this->lng->txt('grp_new'));
2787  $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
2788  return true;
2789 
2790  case 'edit':
2791  $this->form->setTitle($this->lng->txt('grp_edit'));
2792  $this->form->setTitleIcon(ilUtil::getImagePath('icon_grp.gif'));
2793 
2794  $this->form->addCommandButton('update',$this->lng->txt('save'));
2795  $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
2796  return true;
2797 
2798  case 'update_group_type':
2799  $grp_type->setValue(
2800  $type == GRP_TYPE_PUBLIC ?
2801  GRP_TYPE_CLOSED :
2803  );
2804 
2805  $this->form->setTitle($this->lng->txt('grp_edit'));
2806  $this->form->setTitleIcon(ilUtil::getImagePath('icon_grp.gif'));
2807  return true;
2808  }
2809  return true;
2810  }
2811 
2818  public function load()
2819  {
2820  $this->object->setTitle(ilUtil::stripSlashes($_POST['title']));
2821  $this->object->setDescription(ilUtil::stripSlashes($_POST['desc']));
2822  $this->object->setGroupType(ilUtil::stripSlashes($_POST['grp_type']));
2823  $this->object->setRegistrationType(ilUtil::stripSlashes($_POST['registration_type']));
2824  $this->object->setPassword(ilUtil::stripSlashes($_POST['password']));
2825  $this->object->enableUnlimitedRegistration((bool) !$_POST['reg_limit_time']);
2826  $this->object->setRegistrationStart($this->loadDate('start'));
2827  $this->object->setRegistrationEnd($this->loadDate('end'));
2828  $this->object->enableMembershipLimitation((bool) $_POST['registration_membership_limited']);
2829  $this->object->setMaxMembers((int) $_POST['registration_max_members']);
2830  $this->object->enableWaitingList((bool) $_POST['waiting_list']);
2831  $this->object->enableRegistrationAccessCode((bool) $_POST['reg_code_enabled']);
2832  $this->object->setRegistrationAccessCode(ilUtil::stripSlashes($_POST['reg_code']));
2833 
2834  return true;
2835  }
2836 
2844  protected function loadDate($a_field)
2845  {
2846  global $ilUser;
2847 
2848  include_once('./Services/Calendar/classes/class.ilDateTime.php');
2849 
2850  $dt['year'] = (int) $_POST['reg'][$a_field]['date']['y'];
2851  $dt['mon'] = (int) $_POST['reg'][$a_field]['date']['m'];
2852  $dt['mday'] = (int) $_POST['reg'][$a_field]['date']['d'];
2853  $dt['hours'] = (int) $_POST['reg'][$a_field]['time']['h'];
2854  $dt['minutes'] = (int) $_POST['reg'][$a_field]['time']['m'];
2855  $dt['seconds'] = (int) $_POST['reg'][$a_field]['time']['s'];
2856 
2857  $date = new ilDateTime($dt,IL_CAL_FKT_GETDATE,$ilUser->getTimeZone());
2858  return $date;
2859  }
2860 
2868  protected function setSubTabs($a_tab)
2869  {
2870  global $rbacsystem,$ilUser,$ilAccess;
2871 
2872  switch($a_tab)
2873  {
2874  case 'members':
2875  // for admins
2876  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
2877  {
2878  $this->tabs_gui->addSubTabTarget("grp_edit_members",
2879  $this->ctrl->getLinkTarget($this,'members'),
2880  "members",
2881  get_class($this));
2882  }
2883  // for all
2884  $this->tabs_gui->addSubTabTarget("grp_members_gallery",
2885  $this->ctrl->getLinkTarget($this,'membersGallery'),
2886  "membersGallery", get_class($this));
2887 
2888  // members map
2889  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
2891  $this->object->getEnableGroupMap())
2892  {
2893  $this->tabs_gui->addSubTabTarget("grp_members_map",
2894  $this->ctrl->getLinkTarget($this,'membersMap'),
2895  "membersMap", get_class($this));
2896  }
2897 
2898  $this->tabs_gui->addSubTabTarget("mail_members",
2899  $this->ctrl->getLinkTarget($this,'mailMembers'),
2900  "mailMembers", get_class($this));
2901 
2902  include_once 'Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
2903  if(ilPrivacySettings::_getInstance()->checkExportAccess($this->object->getRefId()))
2904  {
2905  $this->tabs_gui->addSubTabTarget('grp_export_members',
2906  $this->ctrl->getLinkTargetByClass('ilmemberexportgui','show'),
2907  "", 'ilmemberexportgui');
2908  }
2909 
2910  break;
2911 
2912  case "activation":
2913  $this->tabs_gui->addSubTabTarget("activation",
2914  $this->ctrl->getLinkTargetByClass('ilCourseItemAdministrationGUI','edit'),
2915  "edit", get_class($this));
2916  $this->ctrl->setParameterByClass('ilconditionhandlerinterface','item_id',(int) $_GET['item_id']);
2917  $this->tabs_gui->addSubTabTarget("preconditions",
2918  $this->ctrl->getLinkTargetByClass('ilConditionHandlerInterface','listConditions'),
2919  "", "ilConditionHandlerInterface");
2920  break;
2921 
2922  case 'settings':
2923  $this->tabs_gui->addSubTabTarget("grp_settings",
2924  $this->ctrl->getLinkTarget($this,'edit'),
2925  "edit", get_class($this));
2926 
2927  $this->tabs_gui->addSubTabTarget("grp_info_settings",
2928  $this->ctrl->getLinkTarget($this,'editInfo'),
2929  "editInfo", get_class($this));
2930 
2931  // custom icon
2932  if ($this->ilias->getSetting("custom_icons"))
2933  {
2934  $this->tabs_gui->addSubTabTarget("grp_icon_settings",
2935  $this->ctrl->getLinkTarget($this,'editGroupIcons'),
2936  "editGroupIcons", get_class($this));
2937  }
2938 
2939  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
2941  {
2942  $this->tabs_gui->addSubTabTarget("grp_map_settings",
2943  $this->ctrl->getLinkTarget($this,'editMapSettings'),
2944  "editMapSettings", get_class($this));
2945  }
2946 
2947  $this->tabs_gui->addSubTabTarget('groupings',
2948  $this->ctrl->getLinkTargetByClass('ilobjcoursegroupinggui','listGroupings'),
2949  'listGroupings',
2950  get_class($this));
2951 
2952  include_once('Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
2953  include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
2954  // only show if export permission is granted
2955  if(ilPrivacySettings::_getInstance()->checkExportAccess($this->object->getRefId()) or ilCourseDefinedFieldDefinition::_hasFields($this->object->getId()))
2956  {
2957  $this->tabs_gui->addSubTabTarget('grp_custom_user_fields',
2958  $this->ctrl->getLinkTargetByClass('ilobjectcustomuserfieldsgui'),
2959  '',
2960  'ilobjectcustomuserfieldsgui');
2961  }
2962 
2963 
2964 
2965  break;
2966 
2967 
2968  }
2969  }
2970 
2977  private function checkAgreement()
2978  {
2979  global $ilUser,$ilAccess;
2980 
2981  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
2982  {
2983  return true;
2984  }
2985 
2986  // Disable aggrement if is not member of group
2987  if(!$this->object->members_obj->isAssigned($ilUser->getId()))
2988  {
2989  return true;
2990  }
2991 
2992  include_once './Services/Container/classes/class.ilMemberViewSettings.php';
2993  if(ilMemberViewSettings::getInstance()->isActive())
2994  {
2995  return true;
2996  }
2997 
2998  include_once('Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
2999  include_once('Services/Membership/classes/class.ilMemberAgreement.php');
3000  $privacy = ilPrivacySettings::_getInstance();
3001 
3002  // Check agreement
3003  if(($privacy->groupConfirmationRequired() or ilCourseDefinedFieldDefinition::_hasFields($this->object->getId()))
3004  and !ilMemberAgreement::_hasAccepted($ilUser->getId(),$this->object->getId()))
3005  {
3006  return false;
3007  }
3008  // Check required fields
3009  include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');
3010  if(!ilCourseUserData::_checkRequired($ilUser->getId(),$this->object->getId()))
3011  {
3012  return false;
3013  }
3014  return true;
3015  }
3016 
3017 
3022  public function prepareOutput()
3023  {
3024  global $rbacsystem;
3025  if(!$this->getCreationMode())
3026  {
3027  /*
3028  include_once './Services/Container/classes/class.ilMemberViewSettings.php';
3029  $settings = ilMemberViewSettings::getInstance();
3030  if($settings->isActive() and $settings->getContainer() != $this->object->getRefId())
3031  {
3032  $settings->setContainer($this->object->getRefId());
3033  $rbacsystem->initMemberView();
3034  }
3035  */
3036  }
3038  }
3039 
3044  protected function createMailSignature()
3045  {
3046  $link = chr(13).chr(10).chr(13).chr(10);
3047  $link .= $this->lng->txt('grp_mail_permanent_link');
3048  $link .= chr(13).chr(10).chr(13).chr(10);
3049  include_once './classes/class.ilLink.php';
3050  $link .= ilLink::_getLink($this->object->getRefId());
3051  return rawurlencode(base64_encode($link));
3052  }
3053 
3054 
3055 } // END class.ilObjGroupGUI
3056 ?>