ILIAS  Release_5_0_x_branch Revision 61816
 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 
26 {
31  public function __construct($a_data,$a_id,$a_call_by_reference,$a_prepare_output = false)
32  {
33  $this->type = "grp";
34  $this->ilContainerGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
35 
36  $this->lng->loadLanguageModule('grp');
37  }
38 
39  function &executeCommand()
40  {
41  global $ilUser,$rbacsystem,$ilAccess, $ilNavigationHistory,$ilErr, $ilCtrl;
42 
43  $next_class = $this->ctrl->getNextClass($this);
44  $cmd = $this->ctrl->getCmd();
45  $this->prepareOutput();
46 
47  // show repository tree
48  $this->showRepTree(true);
49 
50  // add entry to navigation history
51  if (!$this->getCreationMode() &&
52  $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
53  {
54  include_once("./Services/Link/classes/class.ilLink.php");
55  $ilNavigationHistory->addItem($_GET["ref_id"],
56  ilLink::_getLink($_GET["ref_id"], "grp"), "grp");
57  }
58 
59  switch($next_class)
60  {
61  case 'ilgroupregistrationgui':
62  $this->ctrl->setReturn($this,'');
63  $this->tabs_gui->setTabActive('join');
64  include_once('./Modules/Group/classes/class.ilGroupRegistrationGUI.php');
65  $registration = new ilGroupRegistrationGUI($this->object);
66  $this->ctrl->forwardCommand($registration);
67  break;
68 
69  case 'ilpermissiongui':
70  $this->tabs_gui->setTabActive('perm_settings');
71  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
72  $perm_gui =& new ilPermissionGUI($this);
73  $ret =& $this->ctrl->forwardCommand($perm_gui);
74  break;
75 
76  case 'ilrepositorysearchgui':
77  include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
78  $rep_search =& new ilRepositorySearchGUI();
79  $rep_search->setCallback($this,
80  'addUserObject',
81  $this->getLocalRoles()
82  );
83 
84  // Set tabs
85  $this->tabs_gui->setTabActive('members');
86  $this->ctrl->setReturn($this,'members');
87  $ret =& $this->ctrl->forwardCommand($rep_search);
88  $this->setSubTabs('members');
89  $this->tabs_gui->setSubTabActive('members');
90  break;
91 
92  case "ilinfoscreengui":
93  $ret =& $this->infoScreen();
94  break;
95 
96  case "illearningprogressgui":
97  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
98 
100  $this->object->getRefId(),
101  $_GET['user_id'] ? $_GET['user_id'] : $ilUser->getId());
102  $this->ctrl->forwardCommand($new_gui);
103  $this->tabs_gui->setTabActive('learning_progress');
104  break;
105 
106  case 'ilobjcoursegroupinggui':
107  $this->setSubTabs('settings');
108 
109  include_once './Modules/Course/classes/class.ilObjCourseGroupingGUI.php';
110  $this->ctrl->setReturn($this,'edit');
111  $crs_grp_gui =& new ilObjCourseGroupingGUI($this->object,(int) $_GET['obj_id']);
112  $this->ctrl->forwardCommand($crs_grp_gui);
113 
114  $this->tabs_gui->setTabActive('settings');
115  $this->tabs_gui->setSubTabActive('groupings');
116  break;
117 
118  case 'ilcoursecontentgui':
119 
120  include_once './Modules/Course/classes/class.ilCourseContentGUI.php';
121  $course_content_obj = new ilCourseContentGUI($this);
122  $this->ctrl->forwardCommand($course_content_obj);
123  break;
124 
125  case 'ilpublicuserprofilegui':
126  require_once './Services/User/classes/class.ilPublicUserProfileGUI.php';
127  $this->setSubTabs('members');
128  $this->tabs_gui->setTabActive('group_members');
129  $this->tabs_gui->setSubTabActive('grp_members_gallery');
130  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
131  $profile_gui->setBackUrl($ilCtrl->getLinkTarget($this, "membersGallery"));
132  $html = $this->ctrl->forwardCommand($profile_gui);
133  $this->tpl->setVariable("ADM_CONTENT", $html);
134  break;
135 
136  case "ilcolumngui":
137  $this->tabs_gui->setTabActive('none');
138  $this->checkPermission("read");
139  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
140  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
141  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId()));
142  $this->renderObject();
143  break;
144 
145  // container page editing
146  case "ilcontainerpagegui":
147  $ret = $this->forwardToPageObject();
148  if ($ret != "")
149  {
150  $this->tpl->setContent($ret);
151  }
152  break;
153 
154  case 'ilobjectcopygui':
155  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
156  $cp = new ilObjectCopyGUI($this);
157  $cp->setType('grp');
158  $this->ctrl->forwardCommand($cp);
159  break;
160 
161  case "ilobjstylesheetgui":
162  $this->forwardToStyleSheet();
163  break;
164 
165  case 'ilobjectcustomuserfieldsgui':
166  if(isset($_REQUEST['member_id']))
167  {
168  $this->ctrl->setReturn($this,'members');
169  }
170  include_once './Services/Membership/classes/class.ilObjectCustomUserFieldsGUI.php';
171  $cdf_gui = new ilObjectCustomUserFieldsGUI($this->object->getId());
172  $this->setSubTabs('settings');
173  $this->tabs_gui->setTabActive('settings');
174  $this->ctrl->forwardCommand($cdf_gui);
175  break;
176 
177  case 'ilmemberagreementgui':
178  include_once('Services/Membership/classes/class.ilMemberAgreementGUI.php');
179  $this->ctrl->setReturn($this,'');
180  $this->tabs_gui->setTabActive('view_content');
181  $agreement = new ilMemberAgreementGUI($this->object->getRefId());
182  $this->ctrl->forwardCommand($agreement);
183  break;
184 
185  case 'ilexportgui':
186  $this->tabs_gui->setTabActive('export');
187  include_once './Services/Export/classes/class.ilExportGUI.php';
188  $exp = new ilExportGUI($this);
189  $exp->addFormat('xml');
190  $this->ctrl->forwardCommand($exp);
191  break;
192 
193  case 'ilmemberexportgui':
194  include_once('./Services/Membership/classes/Export/class.ilMemberExportGUI.php');
195 
196  $this->setSubTabs('members');
197  $this->tabs_gui->setTabActive('members');
198  $this->tabs_gui->setSubTabActive('export_members');
199  $export = new ilMemberExportGUI($this->object->getRefId());
200  $this->ctrl->forwardCommand($export);
201  break;
202 
203  case "ilcommonactiondispatchergui":
204  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
206  $this->ctrl->forwardCommand($gui);
207  break;
208 
209  case 'ilobjectservicesettingsgui':
210  $this->ctrl->setReturn($this,'edit');
211  $this->setSubTabs("settings");
212  $this->tabs_gui->activateTab('settings');
213  $this->tabs_gui->activateSubTab('tool_settings');
214 
215  include_once './Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
216  $service = new ilObjectServiceSettingsGUI(
217  $this,
218  $this->object->getId(),
219  array(
221  ));
222  $this->ctrl->forwardCommand($service);
223  break;
224 
225  case 'ilsessionoverviewgui':
226  $this->setSubTabs('members');
227  $this->tabs_gui->setTabActive('members');
228  $this->tabs_gui->setSubTabActive('events');
229 
230  include_once './Modules/Group/classes/class.ilGroupParticipants.php';
231  $prt = ilGroupParticipants::_getInstanceByObjId($this->object->getId());
232 
233  include_once('./Modules/Session/classes/class.ilSessionOverviewGUI.php');
234  $overview = new ilSessionOverviewGUI($this->object->getRefId(), $prt);
235  $this->ctrl->forwardCommand($overview);
236  break;
237 
238  default:
239 
240  // check visible permission
241  if (!$this->getCreationMode() and
242  !$ilAccess->checkAccess('visible','',$this->object->getRefId(),'grp') and
243  !$ilAccess->checkAccess('read','',$this->object->getRefId(),'grp') )
244  {
245  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"),$ilErr->MESSAGE);
246  }
247 
248  // #9401 - see also ilStartupGUI::_checkGoto()
249  if($cmd == 'infoScreenGoto')
250  {
251  if($this->object->isRegistrationEnabled())
252  {
253  $cmd = 'join';
254  }
255  else
256  {
257  $cmd = 'infoScreen';
258  }
259  }
260 
261  // check read permission
262  if ((!$this->getCreationMode()
263  && !$rbacsystem->checkAccess('read',$this->object->getRefId()) && $cmd != 'infoScreen')
264  || $cmd == 'join')
265  {
266  // no join permission -> redirect to info screen
267  if (!$rbacsystem->checkAccess('join',$this->object->getRefId()))
268  {
269  $this->ctrl->redirect($this, "infoScreen");
270  }
271  else // no read -> show registration
272  {
273  include_once('./Modules/Group/classes/class.ilGroupRegistrationGUI.php');
274  $this->ctrl->redirectByClass("ilGroupRegistrationGUI", "show");
275  }
276  }
277  if(!$cmd)
278  {
279  $cmd = 'view';
280  }
281  $cmd .= 'Object';
282  $this->$cmd();
283  break;
284  }
285 
286  $this->addHeaderAction();
287  }
288 
289  function viewObject()
290  {
291  global $tree,$rbacsystem,$ilUser;
292 
293  include_once 'Services/Tracking/classes/class.ilLearningProgress.php';
294  ilLearningProgress::_tracProgress($ilUser->getId(),$this->object->getId(),
295  $this->object->getRefId(),'grp');
296 
297  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
298  {
300  return true;
301  }
302 
303  if(!$this->checkAgreement())
304  {
305  include_once('Services/Membership/classes/class.ilMemberAgreementGUI.php');
306  $this->tabs_gui->setTabActive('view_content');
307  $this->ctrl->setReturn($this,'view');
308  $agreement = new ilMemberAgreementGUI($this->object->getRefId());
309  $this->ctrl->setCmdClass(get_class($agreement));
310  $this->ctrl->forwardCommand($agreement);
311  return true;
312  }
313 
314  $this->tabs_gui->setTabActive('view_content');
315  $this->renderObject();
316  }
317 
321  function renderObject()
322  {
323  global $ilTabs;
324 
325  $ilTabs->activateTab("view_content");
327  return $ret;
328 
329  }
330 
334  function modifyItemGUI($a_item_list_gui, $a_item_data, $a_show_path)
335  {
336  global $tree;
337 
338  // if folder is in a course, modify item list gui according to course requirements
339  if ($course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs'))
340  {
341  include_once("./Modules/Course/classes/class.ilObjCourse.php");
342  include_once("./Modules/Course/classes/class.ilObjCourseGUI.php");
343  $course_obj_id = ilObject::_lookupObjId($course_ref_id);
344  ilObjCourseGUI::_modifyItemGUI($a_item_list_gui,'ilcoursecontentgui',$a_item_data, $a_show_path,
345  ilObjCourse::_lookupAboStatus($course_obj_id), $course_ref_id, $course_obj_id,
346  $this->object->getRefId());
347  }
348  }
349 
350  protected function initCreateForm($a_new_type)
351  {
352  if(!is_object($this->object))
353  {
354  $this->object = new ilObjGroup();
355  }
356 
357  $this->initForm('create');
358  return $this->form;
359  }
360 
368  public function saveObject()
369  {
370  global $ilErr,$ilUser,$tree;
371 
372  $this->object = new ilObjGroup();
373 
374  // we reduced the form, only 3 values left
375  // $this->load();
376 
377  $grp_type = ilUtil::stripSlashes($_POST['grp_type']);
378  switch($grp_type)
379  {
380  case GRP_TYPE_PUBLIC:
381  $this->object->setRegistrationType(GRP_REGISTRATION_DIRECT);
382  break;
383 
384  default:
385  $this->object->setRegistrationType(GRP_REGISTRATION_DEACTIVATED);
386  break;
387  }
388  $this->object->setTitle(ilUtil::stripSlashes($_POST['title']));
389  $this->object->setDescription(ilUtil::stripSlashes($_POST['desc']));
390  $this->object->setGroupType(ilUtil::stripSlashes($_POST['grp_type']));
391  $this->object->setViewMode(ilContainer::VIEW_INHERIT);
392 
393  $ilErr->setMessage('');
394 
395  if(!$this->object->validate())
396  {
397  $err = $this->lng->txt('err_check_input');
398  ilUtil::sendFailure($err);
399  $err = $ilErr->getMessage();
400  ilUtil::sendInfo($err);
401  $this->createObject();
402  return true;
403  }
404 
405  $this->object->create();
406  $this->putObjectInTree($this->object, $_GET["ref_id"]);
407  $this->object->initGroupStatus($this->object->getGroupType());
408 
409  // check for parent group or course => SORT_INHERIT
410  $sort_mode = ilContainer::SORT_TITLE;
411  if(
412  $GLOBALS['tree']->checkForParentType($this->object->getRefId(),'crs') ||
413  $GLOBALS['tree']->checkForParentType($this->object->getRefId(),'grp')
414  )
415  {
416  $sort_mode = ilContainer::SORT_INHERIT;
417  }
418  // Save sorting
419  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
420  $sort = new ilContainerSortingSettings($this->object->getId());
421  $sort->setSortMode($sort_mode);
422  $sort->update();
423 
424 
425  // Add user as admin and enable notification
426  include_once('./Modules/Group/classes/class.ilGroupParticipants.php');
427  $members_obj = ilGroupParticipants::_getInstanceByObjId($this->object->getId());
428  $members_obj->add($ilUser->getId(),IL_GRP_ADMIN);
429  $members_obj->updateNotification($ilUser->getId(),1);
430 
431 
432  ilUtil::sendSuccess($this->lng->txt("grp_added"),true);
433  $this->ctrl->setParameter($this,'ref_id',$this->object->getRefId());
434  $this->ctrl->redirect($this, "edit");
435  }
436 
444  public function editObject()
445  {
446  $this->checkPermission("write");
447 
448  $this->setSubTabs('settings');
449  $this->tabs_gui->setTabActive('settings');
450  $this->tabs_gui->setSubTabActive('grp_settings');
451 
452  $this->initForm('edit');
453 
454  $this->tpl->setVariable('ADM_CONTENT',$this->form->getHTML());
455  }
456 
464  public function updateGroupTypeObject()
465  {
466  $type = $this->object->getGroupType() ?
467  $this->object->getGroupType() :
468  $this->object->readGroupStatus();
469 
470  if($type == GRP_TYPE_PUBLIC)
471  {
472  $this->object->setGroupType(GRP_TYPE_CLOSED);
473  }
474  else
475  {
476  $this->object->setGroupType(GRP_TYPE_PUBLIC);
477  }
478  $this->object->updateGroupType();
479  $this->object->update();
480  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
481  $this->ctrl->redirect($this,'edit');
482  }
483 
484 
490  public function updateObject()
491  {
492  global $ilErr;
493 
494  $this->checkPermission('write');
495 
496 
497  $this->initForm();
498  $this->form->checkInput();
499 
500  $old_type = $this->object->getGroupType();
501 
502  $this->load();
503  $ilErr->setMessage('');
504 
505  if(!$this->object->validate())
506  {
507  $err = $this->lng->txt('err_check_input');
508  ilUtil::sendFailure($err);
509  $err = $ilErr->getMessage();
510  ilUtil::sendInfo($err);
511  $this->editObject();
512  return true;
513  }
514 
515  $modified = false;
516  if($this->object->isGroupTypeModified($old_type))
517  {
518  $modified = true;
519  $this->object->setGroupType($old_type);
520  }
521 
522  $this->object->update();
523 
524 
525  include_once './Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
527  $this->object->getId(),
528  $this->form,
529  array(
534  )
535  );
536 
537  // Save sorting
538  $this->saveSortingSettings($this->form);
539 
540  // BEGIN ChangeEvents: Record update Object.
541  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
542  global $ilUser;
543  ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
544  ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
545  // END PATCH ChangeEvents: Record update Object.
546 
547  // Update ecs export settings
548  include_once 'Modules/Group/classes/class.ilECSGroupSettings.php';
549  $ecs = new ilECSGroupSettings($this->object);
550  $ecs->handleSettingsUpdate();
551 
552  if($modified)
553  {
554  include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
555  ilUtil::sendQuestion($this->lng->txt('grp_warn_grp_type_changed'));
556  $confirm = new ilConfirmationGUI();
557  $confirm->setFormAction($this->ctrl->getFormAction($this));
558  $confirm->addItem(
559  'grp_type',
560  $this->object->getGroupType(),
561  $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'))
562  );
563  $confirm->addButton($this->lng->txt('grp_change_type'), 'updateGroupType');
564  $confirm->setCancel($this->lng->txt('cancel'), 'edit');
565 
566  $this->tpl->setContent($confirm->getHTML());
567  return true;
568  }
569  else
570  {
571  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
572  $this->ctrl->redirect($this,'edit');
573  return true;
574  }
575  }
576 
580  public function editGroupIconsObject($a_form = null)
581  {
582  global $tpl;
583 
584  $this->checkPermission('write');
585 
586  $this->setSubTabs("settings");
587  $this->tabs_gui->setTabActive('settings');
588  $this->tabs_gui->setSubTabActive('grp_icon_settings');
589 
590  if(!$a_form)
591  {
592  $a_form = $this->initGroupIconsForm();
593  }
594 
595  $tpl->setContent($a_form->getHTML());
596  }
597 
599  {
600  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
601  $form = new ilPropertyFormGUI();
602  $form->setFormAction($this->ctrl->getFormAction($this));
603 
604  $this->showCustomIconsEditing(1, $form);
605 
606  // $form->setTitle($this->lng->txt('edit_grouping'));
607  $form->addCommandButton('updateGroupIcons', $this->lng->txt('save'));
608 
609  return $form;
610  }
611 
618  public function updateGroupIconsObject()
619  {
620  global $ilSetting;
621 
622  $this->checkPermission('write');
623 
624  $form = $this->initGroupIconsForm();
625  if($form->checkInput())
626  {
627  //save custom icons
628  if ($ilSetting->get("custom_icons"))
629  {
630  if($_POST["cont_icon_delete"])
631  {
632  $this->object->removeCustomIcon();
633  }
634  $this->object->saveIcons($_FILES["cont_icon"]['tmp_name']);
635  }
636  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
637  $this->ctrl->redirect($this,"editGroupIcons");
638  }
639 
640  $form->setValuesByPost();
641  $this->editGroupIconsObject($form);
642  }
643 
647  public function editMapSettingsObject()
648  {
649  global $ilUser, $ilCtrl, $ilUser, $ilAccess;
650 
651  $this->setSubTabs("settings");
652  $this->tabs_gui->setTabActive('settings');
653  $this->tabs_gui->setSubTabActive('grp_map_settings');
654 
655  include_once('./Services/Maps/classes/class.ilMapUtil.php');
656  if (!ilMapUtil::isActivated() ||
657  !$ilAccess->checkAccess("write", "", $this->object->getRefId()))
658  {
659  return;
660  }
661 
662  $latitude = $this->object->getLatitude();
663  $longitude = $this->object->getLongitude();
664  $zoom = $this->object->getLocationZoom();
665 
666  // Get Default settings, when nothing is set
667  if ($latitude == 0 && $longitude == 0 && $zoom == 0)
668  {
670  $latitude = $def["latitude"];
671  $longitude = $def["longitude"];
672  $zoom = $def["zoom"];
673  }
674 
675 
676  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
677  $form = new ilPropertyFormGUI();
678  $form->setFormAction($ilCtrl->getFormAction($this));
679 
680  $form->setTitle($this->lng->txt("grp_map_settings"));
681 
682  // enable map
683  $public = new ilCheckboxInputGUI($this->lng->txt("grp_enable_map"),
684  "enable_map");
685  $public->setValue("1");
686  $public->setChecked($this->object->getEnableGroupMap());
687  $form->addItem($public);
688 
689  // map location
690  $loc_prop = new ilLocationInputGUI($this->lng->txt("grp_map_location"),
691  "location");
692  $loc_prop->setLatitude($latitude);
693  $loc_prop->setLongitude($longitude);
694  $loc_prop->setZoom($zoom);
695  $form->addItem($loc_prop);
696 
697  $form->addCommandButton("saveMapSettings", $this->lng->txt("save"));
698 
699  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
700  }
701 
702  public function saveMapSettingsObject()
703  {
704  global $ilCtrl, $ilUser;
705 
706  $this->object->setLatitude(ilUtil::stripSlashes($_POST["location"]["latitude"]));
707  $this->object->setLongitude(ilUtil::stripSlashes($_POST["location"]["longitude"]));
708  $this->object->setLocationZoom(ilUtil::stripSlashes($_POST["location"]["zoom"]));
709  $this->object->setEnableGroupMap(ilUtil::stripSlashes($_POST["enable_map"]));
710  $this->object->update();
711 
712  $ilCtrl->redirect($this, "editMapSettings");
713  }
714 
718  public function membersMapObject()
719  {
720  global $tpl;
721 
722  $this->setSubTabs('members');
723  $this->tabs_gui->setTabActive('members');
724 
725  include_once("./Services/Maps/classes/class.ilMapUtil.php");
726  if (!ilMapUtil::isActivated() || !$this->object->getEnableGroupMap())
727  {
728  return;
729  }
730 
731  $map = ilMapUtil::getMapGUI();
732  $map->setMapId("group_map")
733  ->setWidth("700px")
734  ->setHeight("500px")
735  ->setLatitude($this->object->getLatitude())
736  ->setLongitude($this->object->getLongitude())
737  ->setZoom($this->object->getLocationZoom())
738  ->setEnableTypeControl(true)
739  ->setEnableNavigationControl(true)
740  ->setEnableCentralMarker(true);
741 
742 
743  $member_ids = $this->object->getGroupMemberIds();
744  $admin_ids = $this->object->getGroupAdminIds();
745 
746  // fetch all users data in one shot to improve performance
747  $members = $this->object->getGroupMemberData($member_ids);
748  foreach($member_ids as $user_id)
749  {
750  $map->addUserMarker($user_id);
751  }
752  $tpl->setContent($map->getHTML());
753  $tpl->setLeftContent($map->getUserListHTML());
754  }
755 
756 
763  public function editInfoObject()
764  {
765  global $ilErr,$ilAccess;
766 
767  $this->checkPermission('write');
768 
769  $this->setSubTabs('settings');
770  $this->tabs_gui->setTabActive('settings');
771  $this->tabs_gui->setSubTabActive('grp_info_settings');
772 
773  $this->initInfoEditor();
774  $this->tpl->setContent($this->form->getHTML());
775  }
776 
783  protected function initInfoEditor()
784  {
785  if(is_object($this->form))
786  {
787  return true;
788  }
789 
790  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
791  $this->form = new ilPropertyFormGUI();
792  $this->form->setFormAction($this->ctrl->getFormAction($this,'updateInfo'));
793  $this->form->setTitle($this->lng->txt('grp_general_informations'));
794  $this->form->addCommandButton('updateInfo',$this->lng->txt('save'));
795  $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
796 
797  $area = new ilTextAreaInputGUI($this->lng->txt('grp_information'),'important');
798  $area->setInfo($this->lng->txt('grp_information_info'));
799  $area->setValue($this->object->getInformation());
800  $area->setRows(8);
801  $area->setCols(80);
802  $this->form->addItem($area);
803  }
804 
811  public function updateInfoObject()
812  {
813  $this->checkPermission('write');
814 
815  $this->object->setInformation(ilUtil::stripSlashes($_POST['important']));
816  $this->object->update();
817 
818  ilUtil::sendSuccess($this->lng->txt("settings_saved"));
819  $this->editInfoObject();
820  return true;
821  }
822 
824 
829  public function membersGalleryObject()
830  {
831  global $rbacsystem, $ilAccess, $ilUser, $ilToolbar;
832 
833  $is_admin = (bool) $rbacsystem->checkAccess("write", $this->object->getRefId());
834 
835  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.crs_members_gallery.html','Modules/Course');
836 
837  $this->setSubTabs('members');
838  $this->tabs_gui->setTabActive('members');
839 
840  $member_ids = $this->object->getGroupMemberIds();
841  $admin_ids = $this->object->getGroupAdminIds();
842 
843  // fetch all users data in one shot to improve performance
844  $members = $this->object->getGroupMemberData($member_ids);
845 
846  $this->addMailToMemberButton($ilToolbar, "membersGallery");
847 
848  // MEMBERS
849  if(count($members))
850  {
851  $ordered_members = array();
852 
853  foreach($members as $member)
854  {
855  // get user object
856  if(!($usr_obj = ilObjectFactory::getInstanceByObjId($member["id"],false)))
857  {
858  continue;
859  }
860 
861  if(!$usr_obj->getActive())
862  {
863  continue;
864  }
865 
866  // please do not use strtoupper on first/last name for output
867  // this messes up with some unicode characters, i guess
868  // depending on php verion, alex
869  array_push($ordered_members,array("id" => $member["id"],
870  "login" => $usr_obj->getLogin(),
871  "lastname" => $usr_obj->getLastName(),
872  "firstname" => $usr_obj->getFirstName(),
873  "sortlastname" => strtoupper($usr_obj->getLastName()).strtoupper($usr_obj->getFirstName()),
874  "usr_obj" => $usr_obj));
875  }
876 
877  $ordered_members=ilUtil::sortArray($ordered_members,"sortlastname","asc");
878 
879  foreach($ordered_members as $member) {
880 
881  $usr_obj = $member["usr_obj"];
882 
883  $public_profile = $usr_obj->getPref("public_profile");
884  if ($public_profile == "g")
885  {
886  $public_profile = "y";
887  }
888 
889  // SET LINK TARGET FOR USER PROFILE
890  $this->ctrl->setParameterByClass("ilpublicuserprofilegui", "user", $member["id"]);
891  $profile_target = $this->ctrl->getLinkTargetByClass("ilpublicuserprofilegui","getHTML");
892 
893  // GET USER IMAGE
894  $file = $usr_obj->getPersonalPicturePath("xsmall");
895 
896  switch(in_array($member["id"],$admin_ids))
897  {
898  //admins
899  case 1:
900  if ($public_profile == "y")
901  {
902  $this->tpl->setCurrentBlock("member_linked");
903  $this->tpl->setVariable("LINK_PROFILE", $profile_target);
904  $this->tpl->setVariable("SRC_USR_IMAGE", $file);
905  $this->tpl->parseCurrentBlock();
906  }
907  else
908  {
909  $this->tpl->setCurrentBlock("member_not_linked");
910  $this->tpl->setVariable("SRC_USR_IMAGE", $file);
911  $this->tpl->parseCurrentBlock();
912  }
913  $this->tpl->setCurrentBlock("member");
914  break;
915 
916  case 0:
917  if ($public_profile == "y")
918  {
919  $this->tpl->setCurrentBlock("member_linked");
920  $this->tpl->setVariable("LINK_PROFILE", $profile_target);
921  $this->tpl->setVariable("SRC_USR_IMAGE", $file);
922  $this->tpl->parseCurrentBlock();
923  }
924  else
925  {
926  $this->tpl->setCurrentBlock("member_not_linked");
927  $this->tpl->setVariable("SRC_USR_IMAGE", $file);
928  $this->tpl->parseCurrentBlock();
929  }
930  $this->tpl->setCurrentBlock("member");
931  break;
932  }
933 
934  if (in_array($member["id"],$admin_ids)) {
935  $this->tpl->setVariable("MEMBER_CLASS", "il_Admin");
936  }
937  else {
938  $this->tpl->setVariable("MEMBER_CLASS", "il_Member");
939  }
940 
941 
942  // do not show name, if public profile is not activated
943  if ($public_profile == "y")
944  {
945  $this->tpl->setVariable("FIRSTNAME", $member["firstname"]);
946  $this->tpl->setVariable("LASTNAME", $member["lastname"]);
947  }
948  $this->tpl->setVariable("LOGIN", $usr_obj->getLogin());
949  $this->tpl->parseCurrentBlock();
950  }
951  $this->tpl->setCurrentBlock("members");
952  //$this->tpl->setVariable("MEMBERS_TABLE_HEADER",$this->lng->txt('crs_members_title'));
953  $this->tpl->parseCurrentBlock();
954  }
955 
956  $this->tpl->setVariable("TITLE",$this->lng->txt('crs_members_print_title'));
957  $this->tpl->setVariable("CSS_PATH",ilUtil::getStyleSheetLocation());
958  }
959 
960 
961  public function readMemberData($ids,$role = 'admin',$selected_columns = null)
962  {
963  include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
964  $privacy = ilPrivacySettings::_getInstance();
965 
966  if($this->show_tracking)
967  {
968  include_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
969  $completed = ilLPStatusWrapper::_lookupCompletedForObject($this->object->getId());
970  $in_progress = ilLPStatusWrapper::_lookupInProgressForObject($this->object->getId());
971  $failed = ilLPStatusWrapper::_lookupFailedForObject($this->object->getId());
972  }
973 
974  if($privacy->enabledGroupAccessTimes())
975  {
976  include_once('./Services/Tracking/classes/class.ilLearningProgress.php');
977  $progress = ilLearningProgress::_lookupProgressByObjId($this->object->getId());
978  }
979 
980  $do_prtf = (is_array($selected_columns) &&
981  in_array('prtf', $selected_columns) &&
982  is_array($ids));
983  if($do_prtf)
984  {
985  include_once "Modules/Portfolio/classes/class.ilObjPortfolio.php";
987  $this->ctrl->getLinkTarget($this, "members"));
988  }
989 
990  foreach($ids as $usr_id)
991  {
992  $name = ilObjUser::_lookupName($usr_id);
993  $tmp_data['firstname'] = $name['firstname'];
994  $tmp_data['lastname'] = $name['lastname'];
995  $tmp_data['login'] = ilObjUser::_lookupLogin($usr_id);
996  $tmp_data['notification'] = $this->object->members_obj->isNotificationEnabled($usr_id) ? 1 : 0;
997  $tmp_data['usr_id'] = $usr_id;
998  $tmp_data['login'] = ilObjUser::_lookupLogin($usr_id);
999 
1000  if($this->show_tracking)
1001  {
1002  if(in_array($usr_id,$completed))
1003  {
1004  $tmp_data['progress'] = ilLPStatus::LP_STATUS_COMPLETED;
1005  }
1006  elseif(in_array($usr_id,$in_progress))
1007  {
1008  $tmp_data['progress'] = ilLPStatus::LP_STATUS_IN_PROGRESS;
1009  }
1010  elseif(in_array($usr_id,$failed))
1011  {
1012  $tmp_data['progress'] = ilLPStatus::LP_STATUS_FAILED;
1013  }
1014  else
1015  {
1016  $tmp_data['progress'] = ilLPStatus::LP_STATUS_NOT_ATTEMPTED;
1017  }
1018  }
1019 
1020  if($privacy->enabledGroupAccessTimes())
1021  {
1022  if(isset($progress[$usr_id]['ts']) and $progress[$usr_id]['ts'])
1023  {
1024  $tmp_data['access_time'] = ilDatePresentation::formatDate(
1025  $tmp_date = new ilDateTime($progress[$usr_id]['ts'],IL_CAL_UNIX));
1026  $tmp_data['access_time_unix'] = $tmp_date->get(IL_CAL_UNIX);
1027  }
1028  else
1029  {
1030  $tmp_data['access_time'] = $this->lng->txt('no_date');
1031  $tmp_data['access_time_unix'] = 0;
1032  }
1033  }
1034 
1035  if($do_prtf)
1036  {
1037  $tmp_data['prtf'] = $all_prtf[$usr_id];
1038  }
1039 
1040  $members[$usr_id] = $tmp_data;
1041  }
1042  return $members ? $members : array();
1043  }
1044 
1051  public function membersObject()
1052  {
1053  global $ilUser, $ilToolbar, $lng, $ilCtrl;
1054 
1055  include_once('./Modules/Group/classes/class.ilGroupParticipants.php');
1056  include_once('./Modules/Group/classes/class.ilGroupParticipantsTableGUI.php');
1057 
1058  $this->checkPermission('write');
1059 
1060  include_once './Services/Tracking/classes/class.ilObjUserTracking.php';
1061  $this->show_tracking = (ilObjUserTracking::_enabledLearningProgress() and
1063  if($this->show_tracking)
1064  {
1065  include_once('./Services/Object/classes/class.ilObjectLP.php');
1066  $olp = ilObjectLP::getInstance($this->object->getId());
1067  $this->show_tracking = $olp->isActive();
1068  }
1069 
1070  $part = ilGroupParticipants::_getInstanceByObjId($this->object->getId());
1071 
1072  $this->setSubTabs('members');
1073  $this->tabs_gui->setTabActive('members');
1074  $this->tabs_gui->setSubTabActive('grp_edit_members');
1075 
1076  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.grp_edit_members.html','Modules/Group');
1077  $this->tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
1078 
1079  // add members
1080  include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
1082  $this,
1083  $ilToolbar,
1084  array(
1085  'auto_complete_name' => $lng->txt('user'),
1086  'user_type' => $this->getLocalRoles(),
1087  'submit_name' => $lng->txt('add')
1088  )
1089  );
1090 
1091  // spacer
1092  $ilToolbar->addSeparator();
1093 
1094  // search button
1095  $ilToolbar->addButton($this->lng->txt("grp_search_users"),
1096  $this->ctrl->getLinkTargetByClass('ilRepositorySearchGUI','start'));
1097 
1098  $ilToolbar->addSeparator();
1099 
1100  // print button
1101  $ilToolbar->addButton($this->lng->txt("grp_print_list"),
1102  $this->ctrl->getLinkTarget($this, 'printMembers'));
1103 
1104  $this->addMailToMemberButton($ilToolbar, "members", true);
1105 
1106  $this->setShowHidePrefs();
1107 
1108 
1109  // Waiting list table
1110  include_once('./Modules/Group/classes/class.ilGroupWaitingList.php');
1111  $waiting_list = new ilGroupWaitingList($this->object->getId());
1112  if(count($wait = $waiting_list->getAllUsers()))
1113  {
1114  include_once('./Services/Membership/classes/class.ilWaitingListTableGUI.php');
1115  if($ilUser->getPref('grp_wait_hide'))
1116  {
1117  $table_gui = new ilWaitingListTableGUI($this,$waiting_list,false);
1118  $this->ctrl->setParameter($this,'wait_hide',0);
1119  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1120  $this->lng->txt('show'));
1121  $this->ctrl->clearParameters($this);
1122  }
1123  else
1124  {
1125  $table_gui = new ilWaitingListTableGUI($this,$waiting_list,true);
1126  $this->ctrl->setParameter($this,'wait_hide',1);
1127  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1128  $this->lng->txt('hide'));
1129  $this->ctrl->clearParameters($this);
1130  }
1131  $table_gui->setUsers($wait);
1132  $table_gui->setTitle($this->lng->txt('grp_header_waiting_list'),'icon_usr.svg',$this->lng->txt('group_new_registrations'));
1133  $this->tpl->setVariable('TABLE_SUB',$table_gui->getHTML());
1134  }
1135 
1136 
1137  // Subscriber table
1138  if($part->getSubscribers())
1139  {
1140  include_once('./Services/Membership/classes/class.ilSubscriberTableGUI.php');
1141  if($ilUser->getPref('grp_subscriber_hide'))
1142  {
1143  $table_gui = new ilSubscriberTableGUI($this,false);
1144  $this->ctrl->setParameter($this,'subscriber_hide',0);
1145  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1146  $this->lng->txt('show'));
1147  $this->ctrl->clearParameters($this);
1148  }
1149  else
1150  {
1151  $table_gui = new ilSubscriberTableGUI($this,true);
1152  $this->ctrl->setParameter($this,'subscriber_hide',1);
1153  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1154  $this->lng->txt('hide'));
1155  $this->ctrl->clearParameters($this);
1156  }
1157  $table_gui->readSubscriberData();
1158  $table_gui->setTitle($this->lng->txt('group_new_registrations'),'icon_usr.svg',$this->lng->txt('group_new_registrations'));
1159  $this->tpl->setVariable('TABLE_SUB',$table_gui->getHTML());
1160  }
1161 
1162  if(count($part->getAdmins()))
1163  {
1164  if($ilUser->getPref('grp_admin_hide'))
1165  {
1166  $table_gui = new ilGroupParticipantsTableGUI($this,'admin',false,false);
1167  $this->ctrl->setParameter($this,'admin_hide',0);
1168  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1169  $this->lng->txt('show'));
1170  $this->ctrl->clearParameters($this);
1171  }
1172  else
1173  {
1174  $table_gui = new ilGroupParticipantsTableGUI($this,'admin',true,false);
1175  $this->ctrl->setParameter($this,'admin_hide',1);
1176  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1177  $this->lng->txt('hide'));
1178  $this->ctrl->clearParameters($this);
1179  }
1180  $table_gui->setTitle($this->lng->txt('grp_admins'),'icon_usr.svg',$this->lng->txt('grp_admins'));
1181  $table_gui->parse($this->readMemberData($part->getAdmins()));
1182  $this->tpl->setVariable('ADMINS',$table_gui->getHTML());
1183  }
1184 
1185  if($GLOBALS['rbacreview']->getNumberOfAssignedUsers(array($this->object->getDefaultMemberRole())))
1186  {
1187  if($ilUser->getPref('grp_member_hide'))
1188  {
1189  $table_gui = new ilGroupParticipantsTableGUI($this,'member',false,$this->show_tracking,$this->object->getDEfaultMemberRole());
1190  $this->ctrl->setParameter($this,'member_hide',0);
1191  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1192  $this->lng->txt('show'));
1193  $this->ctrl->clearParameters($this);
1194  }
1195  else
1196  {
1197  $table_gui = new ilGroupParticipantsTableGUI($this,'member',true,$this->show_tracking,$this->object->getDefaultMemberRole());
1198  $this->ctrl->setParameter($this,'member_hide',1);
1199  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1200  $this->lng->txt('hide'));
1201  $this->ctrl->clearParameters($this);
1202  }
1203 
1204  $table_gui->setTitle($this->lng->txt('grp_members'),'icon_usr.svg',$this->lng->txt('grp_members'));
1205  $table_gui->parse($this->readMemberData($GLOBALS['rbacreview']->assignedUsers($this->object->getDefaultMemberRole()),
1206  null, $table_gui->getSelectedColumns()));
1207  $this->tpl->setCurrentBlock('member_block');
1208  $this->tpl->setVariable('MEMBERS',$table_gui->getHTML());
1209  $this->tpl->parseCurrentBlock();
1210  }
1211 
1212  foreach(ilGroupParticipants::getMemberRoles($this->object->getRefId()) as $role_id)
1213  {
1214  // Do not show table if no user is assigned
1215  if(!($GLOBALS['rbacreview']->getNumberOfAssignedUsers(array($role_id))))
1216  {
1217  continue;
1218  }
1219  if($ilUser->getPref('grp_role_hide'.$role_id))
1220  {
1221  $table_gui = new ilGroupParticipantsTableGUI($this,'role',false,$this->show_tracking,$role_id);
1222  $this->ctrl->setParameter($this,'role_hide_'.$role_id,0);
1223  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1224  $this->lng->txt('show'));
1225  $this->ctrl->clearParameters($this);
1226  }
1227  else
1228  {
1229  $table_gui = new ilGroupParticipantsTableGUI($this,'role',true,$this->show_tracking,$role_id);
1230  $this->ctrl->setParameter($this,'role_hide_'.$role_id,1);
1231  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1232  $this->lng->txt('hide'));
1233  $this->ctrl->clearParameters($this);
1234  }
1235 
1236  $table_gui->setTitle(ilObject::_lookupTitle($role_id),'icon_usr.gif',ilObject::_lookupTitle($role_id));
1237  $table_gui->parse($this->readMemberData($GLOBALS['rbacreview']->assignedUsers($role_id)));
1238  $this->tpl->setCurrentBlock('member_block');
1239  $this->tpl->setVariable('MEMBERS',$table_gui->getHTML());
1240  $this->tpl->parseCurrentBlock();
1241  }
1242 
1243  $this->tpl->setVariable('TXT_SELECTED_USER',$this->lng->txt('grp_selected_users'));
1244  $this->tpl->setVariable('BTN_FOOTER_EDIT',$this->lng->txt('edit'));
1245  $this->tpl->setVariable('BTN_FOOTER_VAL',$this->lng->txt('remove'));
1246  $this->tpl->setVariable('BTN_FOOTER_MAIL',$this->lng->txt('grp_mem_send_mail'));
1247  $this->tpl->setVariable('ARROW_DOWN',ilUtil::getImagePath('arrow_downright.svg'));
1248 
1249  }
1250 
1257  public function assignSubscribersObject()
1258  {
1259  global $lng, $ilIliasIniFile,$ilUser;
1260 
1261  $this->checkPermission('write');
1262 
1263  if(!count($_POST['subscribers']))
1264  {
1265  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
1266  $this->membersObject();
1267  return false;
1268  }
1269 
1270  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1271  foreach($_POST['subscribers'] as $usr_id)
1272  {
1273  $this->object->members_obj->sendNotification(
1275  $usr_id
1276  );
1277 
1278  $this->object->members_obj->add($usr_id,IL_GRP_MEMBER);
1279  $this->object->members_obj->deleteSubscriber($usr_id);
1280 
1281  }
1282  ilUtil::sendSuccess($this->lng->txt("grp_msg_applicants_assigned"),true);
1283  $this->ctrl->redirect($this,'members');
1284  return true;
1285  }
1286 
1293  public function refuseSubscribersObject()
1294  {
1295  global $lng;
1296 
1297  $this->checkPermission('write');
1298 
1299  if(!count($_POST['subscribers']))
1300  {
1301  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
1302  $this->membersObject();
1303  return false;
1304  }
1305 
1306  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1307  foreach($_POST['subscribers'] as $usr_id)
1308  {
1309  $this->object->members_obj->sendNotification(
1311  $usr_id
1312  );
1313  $this->object->members_obj->deleteSubscriber($usr_id);
1314  }
1315  ilUtil::sendSuccess($this->lng->txt("grp_msg_applicants_removed"));
1316  $this->membersObject();
1317  return true;
1318 
1319  }
1320 
1329  {
1330  $this->checkPermission('write');
1331 
1332  if(!count($_POST["waiting"]))
1333  {
1334  ilUtil::sendFailure($this->lng->txt("no_checkbox"));
1335  $this->membersObject();
1336  return false;
1337  }
1338 
1339  include_once('./Modules/Group/classes/class.ilGroupWaitingList.php');
1340  $waiting_list = new ilGroupWaitingList($this->object->getId());
1341 
1342  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1343 
1344  $added_users = 0;
1345  foreach($_POST["waiting"] as $user_id)
1346  {
1347  if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user_id,false))
1348  {
1349  continue;
1350  }
1351  if($this->object->members_obj->isAssigned($user_id))
1352  {
1353  continue;
1354  }
1355  $this->object->members_obj->add($user_id,IL_GRP_MEMBER);
1356  $this->object->members_obj->sendNotification(
1358  $user_id
1359  );
1360  $waiting_list->removeFromList($user_id);
1361 
1362  ++$added_users;
1363  }
1364  if($added_users)
1365  {
1366  ilUtil::sendSuccess($this->lng->txt("grp_users_added"), true);
1367  $this->ctrl->redirect($this, "members");
1368 
1369  return true;
1370  }
1371  else
1372  {
1373  ilUtil::sendFailure($this->lng->txt("grp_users_already_assigned"));
1374  $this->searchObject();
1375 
1376  return false;
1377  }
1378  }
1379 
1386  public function refuseFromListObject()
1387  {
1388  $this->checkPermission('write');
1389 
1390  if(!count($_POST['waiting']))
1391  {
1392  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
1393  $this->membersObject();
1394  return false;
1395  }
1396 
1397  include_once('./Modules/Group/classes/class.ilGroupWaitingList.php');
1398  $waiting_list = new ilGroupWaitingList($this->object->getId());
1399 
1400  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1401  foreach($_POST["waiting"] as $user_id)
1402  {
1403  $waiting_list->removeFromList($user_id);
1404  $this->object->members_obj->sendNotification(
1406  $user_id
1407  );
1408  }
1409 
1410  ilUtil::sendSuccess($this->lng->txt('grp_users_removed_from_list'), true);
1411  $this->ctrl->redirect($this, "members");
1412  return true;
1413  }
1414 
1420  public function confirmDeleteMembersObject()
1421  {
1422  $this->checkPermission('write');
1423 
1424  $participants_to_delete = (array) array_unique(array_merge((array) $_POST['admins'],(array) $_POST['members'], (array) $_POST['roles']));
1425 
1426  if(!count($participants_to_delete))
1427  {
1428  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
1429  $this->membersObject();
1430  return false;
1431  }
1432 
1433  // Check last admin
1434  $admins = (array) ilGroupParticipants::_getInstanceByObjId($this->object->getId())->getAdmins();
1435 
1436  $admins_after = (array) array_diff($admins, $participants_to_delete);
1437  if(!count($admins_after) and count($admins))
1438  {
1439  ilUtil::sendFailure($this->lng->txt('grp_err_administrator_required'));
1440  $this->membersObject();
1441  return false;
1442  }
1443 
1444  $this->setSubTabs('members');
1445  $this->tabs_gui->setTabActive('members');
1446  $this->tabs_gui->setSubTabActive('grp_edit_members');
1447 
1448  include_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
1449  $confirm = new ilConfirmationGUI();
1450  $confirm->setFormAction($this->ctrl->getFormAction($this,'deleteMembers'));
1451  $confirm->setHeaderText($this->lng->txt('grp_dismiss_member'));
1452  $confirm->setConfirm($this->lng->txt('confirm'),'deleteMembers');
1453  $confirm->setCancel($this->lng->txt('cancel'),'members');
1454 
1455  foreach($this->readMemberData(array_merge((array) $_POST['admins'],(array) $_POST['members'], (array) $_POST['roles'])) as $participants)
1456  {
1457  $confirm->addItem('participants[]',
1458  $participants['usr_id'],
1459  $participants['lastname'].', '.$participants['firstname'].' ['.$participants['login'].']',
1460  ilUtil::getImagePath('icon_usr.svg'));
1461  }
1462 
1463  $this->tpl->setContent($confirm->getHTML());
1464  }
1465 
1473  public function deleteMembersObject()
1474  {
1475  $this->checkPermission('write');
1476 
1477  if(!count($_POST['participants']))
1478  {
1479  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
1480  $this->membersObject();
1481  return true;
1482  }
1483 
1484  $this->object->members_obj->deleteParticipants($_POST['participants']);
1485 
1486  // Send notification
1487  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1488  foreach($_POST['participants'] as $part)
1489  {
1490  $this->object->members_obj->sendNotification(
1492  $part
1493  );
1494  }
1495 
1496 
1497  ilUtil::sendSuccess($this->lng->txt("grp_msg_membership_annulled"), true);
1498  $this->ctrl->redirect($this, "members");
1499  return true;
1500  }
1501 
1510  {
1511  if(isset($_GET['member_id']))
1512  {
1513  $_POST['participants'] = array($_GET['member_id']);
1514  }
1515  else
1516  {
1517  $_POST['participants'] = array_unique(array_merge((array) $_POST['admins'],
1518  (array) $_POST['members'],
1519  (array) $_POST['roles'],
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  $post_participants = array_unique(array_merge((array) $_POST['admins'],(array) $_POST['members'], (array) $_POST['roles']));
1593  $real_participants = ilGroupParticipants::_getInstanceByObjId($this->object->getId())->getParticipants();
1594  $participants = array_intersect((array) $post_participants, (array) $real_participants);
1595 
1596  if(!count($participants))
1597  {
1598  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
1599  $this->membersObject();
1600  return false;
1601  }
1602 
1603  $this->setSubTabs('members');
1604  $this->tabs_gui->setTabActive('members');
1605  $this->tabs_gui->setSubTabActive('grp_edit_members');
1606 
1607  include_once('./Modules/Group/classes/class.ilGroupEditParticipantsTableGUI.php');
1608  $table_gui = new ilGroupEditParticipantsTableGUI($this);
1609  $table_gui->setTitle($this->lng->txt('grp_mem_change_status'),'icon_usr.svg',$this->lng->txt('grp_mem_change_status'));
1610  $table_gui->setData($this->readMemberData($participants));
1611 
1612  $this->tpl->setContent($table_gui->getHTML());
1613  return true;
1614  }
1615 
1623  public function updateMembersObject()
1624  {
1625  $this->checkPermission('write');
1626 
1627  if(!count($_POST['participants']))
1628  {
1629  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
1630  $this->membersObject();
1631  return false;
1632  }
1633 
1634  // Check minimum one admin
1635  $has_admin = false;
1636  $admin_role = $this->object->getDefaultAdminRole();
1637  foreach(ilGroupParticipants::_getInstanceByObjId($this->object->getId())->getAdmins() as $admin_id)
1638  {
1639  if(!isset($_POST['roles'][$admin_id]))
1640  {
1641  $has_admin = true;
1642  break;
1643  }
1644  if(in_array($admin_role,$_POST['roles'][$admin_id]))
1645  {
1646  $has_admin = true;
1647  break;
1648  }
1649  }
1650 
1651  if(!$has_admin and ilGroupParticipants::_getInstanceByObjId($this->object->getId())->getCountAdmins())
1652  {
1653  ilUtil::sendFailure($this->lng->txt('grp_min_one_admin'));
1654  $_POST['members'] = $_POST['participants'];
1655  $this->editMembersObject();
1656  return false;
1657  }
1658 
1659  $admin_role = $this->object->getDefaultAdminRole();
1660 
1661  $notifications = $_POST['notification'] ? $_POST['notification'] : array();
1662  foreach($_POST['participants'] as $usr_id)
1663  {
1664  // Check if a status changed mail is required
1665  $notification = false;
1666  if($this->object->members_obj->isAdmin($usr_id) and !in_array($admin_role,(array) $_POST['roles'][$usr_id]))
1667  {
1668  $notification = true;
1669  }
1670  if(!$this->object->members_obj->isAdmin($usr_id) and in_array($admin_role,(array) $_POST['roles'][$usr_id]))
1671  {
1672  $notification = true;
1673  }
1674 
1675  // TODO: check no role, owner
1676  $this->object->members_obj->updateRoleAssignments($usr_id,(array) $_POST['roles'][$usr_id]);
1677 
1678  // Disable notification for all of them
1679  $this->object->members_obj->updateNotification($usr_id,0);
1680 
1681  if($this->object->members_obj->isAdmin($usr_id) and in_array($usr_id,$notifications))
1682  {
1683  $this->object->members_obj->updateNotification($usr_id,1);
1684  }
1685 
1686  if($notification)
1687  {
1688  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1689  $this->object->members_obj->sendNotification(
1691  $usr_id
1692  );
1693  }
1694  }
1695  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1696  $this->ctrl->redirect($this, "members");
1697  return true;
1698  }
1699 
1707  public function updateStatusObject()
1708  {
1709  $this->checkPermission('write');
1710 
1711  $notification = $_POST['notification'] ? $_POST['notification'] : array();
1712  foreach($this->object->members_obj->getAdmins() as $admin_id)
1713  {
1714  $this->object->members_obj->updateNotification($admin_id,(int) in_array($admin_id,$notification));
1715  }
1716  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
1717  $this->membersObject();
1718  }
1719 
1720 
1721 
1722 
1723 
1728  function canceledObject()
1729  {
1730  $return_location = $_GET["cmd_return_location"];
1731  if (strcmp($return_location, "") == 0)
1732  {
1733  $return_location = "";
1734  }
1735 
1736  $this->ctrl->redirect($this, $return_location);
1737  }
1738 
1739 
1740 
1745  public function leaveObject()
1746  {
1747  global $ilUser;
1748 
1749  $this->checkPermission('leave');
1750 
1751  $part = ilGroupParticipants::_getInstanceByObjId($this->object->getId());
1752  if($part->isLastAdmin($ilUser->getId()))
1753  {
1754  ilUtil::sendFailure($this->lng->txt('grp_err_administrator_required'));
1755  $this->viewObject();
1756  return false;
1757  }
1758 
1759  $this->tabs_gui->setTabActive('grp_btn_unsubscribe');
1760 
1761  include_once "Services/Utilities/classes/class.ilConfirmationGUI.php";
1762  $cgui = new ilConfirmationGUI();
1763  $cgui->setHeaderText($this->lng->txt('grp_dismiss_myself'));
1764  $cgui->setFormAction($this->ctrl->getFormAction($this));
1765  $cgui->setCancel($this->lng->txt("cancel"), "cancel");
1766  $cgui->setConfirm($this->lng->txt("grp_btn_unsubscribe"), "unsubscribe");
1767  $this->tpl->setContent($cgui->getHTML());
1768  }
1769 
1776  public function unsubscribeObject()
1777  {
1778  global $ilUser,$tree, $ilCtrl;
1779 
1780  $this->checkPermission('leave');
1781 
1782  $this->object->members_obj->delete($ilUser->getId());
1783 
1784  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1785  $this->object->members_obj->sendNotification(
1787  $ilUser->getId()
1788  );
1789  $this->object->members_obj->sendNotification(
1791  $ilUser->getId()
1792  );
1793 
1794  ilUtil::sendSuccess($this->lng->txt('grp_msg_membership_annulled'),true);
1795  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id",
1796  $tree->getParentId($this->object->getRefId()));
1797  $ilCtrl->redirectByClass("ilrepositorygui", "");
1798  }
1799 
1800 
1806  {
1807  $user_ids = $_POST["id"];
1808 
1809  if (empty($user_ids[0]))
1810  {
1811  // TODO: jumps back to grp content. go back to last search result
1812  $this->ilErr->raiseError($this->lng->txt("no_checkbox"),$this->ilErr->MESSAGE);
1813  }
1814 
1815  foreach ($user_ids as $new_member)
1816  {
1817  if (!$this->object->addMember($new_member,$this->object->getDefaultMemberRole()))
1818  {
1819  $this->ilErr->raiseError("An Error occured while assigning user to group !",$this->ilErr->MESSAGE);
1820  }
1821  }
1822 
1823  unset($_SESSION["saved_post"]);
1824 
1825  ilUtil::sendSuccess($this->lng->txt("grp_msg_member_assigned"),true);
1826  $this->ctrl->redirect($this,'members');
1827  }
1828 
1833  public function addUserObject($user_ids, $a_type)
1834  {
1835  if (empty($user_ids[0]))
1836  {
1837  $GLOBALS['lng']->loadLanguageModule('search');
1838  ilUtil::sendFailure($this->lng->txt('search_err_user_not_exist'),true);
1839  return false;
1840  }
1841 
1842  $part = ilGroupParticipants::_getInstanceByObjId($this->object->getId());
1843  $assigned = FALSE;
1844  foreach((array) $user_ids as $new_member)
1845  {
1846  if($part->isAssigned($new_member))
1847  {
1848  continue;
1849  }
1850  switch($a_type)
1851  {
1852  case $this->object->getDefaultAdminRole():
1853  $part->add($new_member, IL_GRP_ADMIN);
1854  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1855  $part->sendNotification(
1857  $new_member
1858  );
1859  $assigned = TRUE;
1860  break;
1861 
1862  default:
1863  $part->add($new_member, IL_GRP_MEMBER);
1864  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1865  $part->sendNotification(
1867  $new_member
1868  );
1869  $assigned = TRUE;
1870  break;
1871  }
1872  }
1873 
1874  if($assigned)
1875  {
1876  ilUtil::sendSuccess($this->lng->txt("grp_msg_member_assigned"),true);
1877  }
1878  else
1879  {
1880  ilUtil::sendSuccess($this->lng->txt('grp_users_already_assigned'),TRUE);
1881  }
1882  $this->ctrl->redirect($this,'members');
1883  }
1884 
1889  {
1890  global $rbacreview, $ilObjDataCache, $ilias;
1891  include_once('./Services/AccessControl/classes/class.ilObjRole.php');
1892 
1893  $this->lng->loadLanguageModule('mail');
1894  if(!isset($_GET['returned_from_mail']))
1895  {
1896  ilUtil::sendInfo($this->lng->txt('mail_select_recipients'));
1897  }
1898 
1899  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.mail_members.html','Services/Contact');
1900 
1901 
1902  $this->tabs_gui->setTabActive('members');
1903  $b_cmd = $_GET["back_cmd"] ? $_GET["back_cmd"] : "members";
1904  $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this,$b_cmd));
1905 
1906 
1907  require_once 'Services/Mail/classes/class.ilMailFormCall.php';
1908  $this->tpl->setVariable("MAILACTION", ilMailFormCall::getLinkTarget($this, $b_cmd, array(), array('type' => 'role','sig' => $this->createMailSignature())));
1909  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.svg'));
1910  $this->tpl->setVariable("TXT_MARKED_ENTRIES",$this->lng->txt('marked_entries'));
1911  $this->tpl->setVariable("OK",$this->lng->txt('next'));
1912 
1913  // Get role mailbox addresses
1914  $role_ids = $rbacreview->getRolesOfRoleFolder($this->object->getRefId(), false);
1915  $role_addrs = array();
1916 
1917  // Sort by relevance
1918  $sorted_role_ids = array();
1919  $counter = 2;
1920  foreach($role_ids as $role_id)
1921  {
1922  switch(substr(ilObject::_lookupTitle($role_id),0,8))
1923  {
1924  case 'il_grp_a':
1925  $sorted_role_ids[1] = $role_id;
1926  break;
1927 
1928  case 'il_grp_m':
1929  $sorted_role_ids[0] = $role_id;
1930  break;
1931 
1932  default:
1933  $sorted_role_ids[$counter++] = $role_id;
1934  break;
1935  }
1936  }
1937  ksort($sorted_role_ids,SORT_NUMERIC);
1938  foreach ((array) $sorted_role_ids as $role_id)
1939  {
1940  $this->tpl->setCurrentBlock("mailbox_row");
1941  $role_addr = $rbacreview->getRoleMailboxAddress($role_id);
1942 
1943  // check if role title is unique. if not force use pear mail for roles
1944  $ids_for_role_title = ilObject::_getIdsForTitle(ilObject::_lookupTitle($role_id), 'role');
1945  if(count($ids_for_role_title) >= 2)
1946  {
1947  $ilias->setSetting('pear_mail_enable', 1);
1948  }
1949 
1950  $this->tpl->setVariable("CHECK_MAILBOX",ilUtil::formCheckbox(1,'roles[]',
1951  htmlspecialchars($role_addr)
1952  ));
1953 
1954  if (ilMail::_usePearMail() && substr($role_addr, 0, 4) != '#il_')
1955  {
1956  // if pear mail is enabled, mailbox addresses are already localized in the language of the user
1957  $this->tpl->setVariable("MAILBOX",$role_addr);
1958  }
1959  else
1960  {
1961  // if pear mail is not enabled, we need to localize mailbox addresses in the language of the user
1962  $this->tpl->setVariable("MAILBOX",ilObjRole::_getTranslation($ilObjDataCache->lookupTitle($role_id)) . " (".$role_addr.")");
1963  }
1964  $this->tpl->parseCurrentBlock();
1965  }
1966  }
1967 
1973  {
1974  $user_ids = $_POST["user_id"];
1975 
1976  if (empty($user_ids[0]))
1977  {
1978  $this->ilErr->raiseError($this->lng->txt("no_checkbox"),$this->ilErr->MESSAGE);
1979  }
1980  include_once 'Services/Mail/classes/class.ilMail.php';
1981  $mail = new ilMail($_SESSION["AccountId"]);
1982 
1983  foreach ($user_ids as $new_member)
1984  {
1985  $user =& $this->ilias->obj_factory->getInstanceByObjId($new_member);
1986 
1987  $this->object->deleteApplicationListEntry($new_member);
1988  $mail->sendMail($user->getLogin(),"","","Membership application refused: Group ".$this->object->getTitle(),"Your application has been refused.",array(),array('system'));
1989  }
1990 
1991  ilUtil::sendSuccess($this->lng->txt("grp_msg_applicants_removed"),true);
1992  $this->ctrl->redirect($this,'members');
1993  }
1994 
1995  // get tabs
1996  function getTabs(&$tabs_gui)
1997  {
1998  global $rbacsystem, $ilUser, $ilAccess, $lng, $ilHelp;
1999 
2000  $ilHelp->setScreenIdComponent("grp");
2001 
2002  if ($rbacsystem->checkAccess('read',$this->ref_id))
2003  {
2004  $tabs_gui->addTab("view_content", $lng->txt("content"),
2005  $this->ctrl->getLinkTarget($this, ""));
2006  }
2007  if ($rbacsystem->checkAccess('visible',$this->ref_id))
2008  {
2009  $tabs_gui->addTarget("info_short",
2010  $this->ctrl->getLinkTargetByClass(
2011  array("ilobjgroupgui", "ilinfoscreengui"), "showSummary"),
2012  "infoScreen",
2013  "", "",false);
2014  }
2015 
2016 
2017  if ($ilAccess->checkAccess('write','',$this->object->getRefId()))
2018  {
2019  $tabs_gui->addTarget("settings",
2020  $this->ctrl->getLinkTarget($this, "edit"), array("edit", "editMapSettings"), get_class($this),
2021  "");
2022  }
2023 
2024 
2025  $is_participant = ilGroupParticipants::_isParticipant($this->ref_id, $ilUser->getId());
2026 
2027  // Members
2028  $mem_cmd = $ilAccess->checkAccess('write','',$this->ref_id) ? "members" : "membersGallery";
2029  if($mem_cmd != "membersGallery" || $is_participant)
2030  {
2031  $tabs_gui->addTarget("members",
2032  $this->ctrl->getLinkTarget($this, $mem_cmd),
2033  array(),
2034  get_class($this));
2035  }
2036 
2037  // learning progress
2038  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
2039  if(ilLearningProgressAccess::checkAccess($this->object->getRefId(), $is_participant))
2040  {
2041  $tabs_gui->addTarget('learning_progress',
2042  $this->ctrl->getLinkTargetByClass(array('ilobjgroupgui','illearningprogressgui'),''),
2043  '',
2044  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
2045  }
2046 
2047 
2048  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
2049  {
2050  $tabs_gui->addTarget(
2051  'export',
2052  $this->ctrl->getLinkTargetByClass('ilexportgui',''),
2053  'export',
2054  'ilexportgui'
2055  );
2056  }
2057 
2058  /*
2059  if ($rbacsystem->checkAccess('write',$this->object->getRefId()))
2060  {
2061 
2062 
2063  $tabs_gui->addTarget('export',
2064  $this->ctrl->getLinkTarget($this,'listExportFiles'),
2065  array('listExportFiles','exportXML','confirmDeleteExportFile','downloadExportFile'),
2066  get_class($this));
2067  }
2068  */
2069  // parent tabs (all container: edit_permission, clipboard, trash
2070  parent::getTabs($tabs_gui);
2071 
2072  if($ilAccess->checkAccess('join','',$this->object->getRefId()) and
2073  !$this->object->members_obj->isAssigned($ilUser->getId()))
2074  {
2075  include_once './Modules/Group/classes/class.ilGroupWaitingList.php';
2076  if(ilGroupWaitingList::_isOnList($ilUser->getId(), $this->object->getId()))
2077  {
2078  $tabs_gui->addTab(
2079  'leave',
2080  $this->lng->txt('membership_leave'),
2081  $this->ctrl->getLinkTargetByClass('ilgroupregistrationgui','show','')
2082  );
2083 
2084  }
2085  else
2086  {
2087 
2088  $tabs_gui->addTarget("join",
2089  $this->ctrl->getLinkTargetByClass('ilgroupregistrationgui', "show"),
2090  'show',
2091  "");
2092  }
2093  }
2094  if($ilAccess->checkAccess('leave','',$this->object->getRefId()) and
2095  $this->object->members_obj->isMember($ilUser->getId()))
2096  {
2097  $tabs_gui->addTarget("grp_btn_unsubscribe",
2098  $this->ctrl->getLinkTarget($this, "leave"),
2099  '',
2100  "");
2101  }
2102  }
2103 
2104  // IMPORT FUNCTIONS
2105 
2107  {
2108  if(!is_array($_FILES['xmldoc']))
2109  {
2110  ilUtil::sendFailure($this->lng->txt("import_file_not_valid"));
2111  $this->createObject();
2112  return false;
2113  }
2114 
2115  include_once './Modules/Group/classes/class.ilObjGroup.php';
2116 
2117  if($ref_id = ilObjGroup::_importFromFile($_FILES['xmldoc'],(int) $_GET['ref_id']))
2118  {
2119  $this->ctrl->setParameter($this, "ref_id", $ref_id);
2120  ilUtil::sendSuccess($this->lng->txt("import_grp_finished"),true);
2121  ilUtil::redirect($this->ctrl->getLinkTarget($this,'edit','',false,false));
2122  }
2123 
2124  ilUtil::sendFailure($this->lng->txt("import_file_not_valid"));
2125  $this->createObject();
2126  }
2127 
2134  function exportObject()
2135  {
2136  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.grp_members_export.html",
2137  "Modules/Group");
2138  $this->tpl->setCurrentBlock("adm_content");
2139  $this->tpl->setVariable("FORMACTION", $this->getFormAction("export",$this->ctrl->getFormAction($this)));
2140  $this->tpl->setVariable("BUTTON_EXPORT", $this->lng->txt("export_group_members"));
2141  $this->tpl->parseCurrentBlock();
2142  }
2143 
2151  {
2152  $title = preg_replace("/\s/", "_", $this->object->getTitle());
2153  include_once "./Services/Excel/classes/class.ilExcelWriterAdapter.php";
2154  $adapter = new ilExcelWriterAdapter("export_" . $title . ".xls");
2155  $workbook = $adapter->getWorkbook();
2156  // Creating a worksheet
2157  $format_bold =& $workbook->addFormat();
2158  $format_bold->setBold();
2159  $format_percent =& $workbook->addFormat();
2160  $format_percent->setNumFormat("0.00%");
2161  $format_datetime =& $workbook->addFormat();
2162  $format_datetime->setNumFormat("DD/MM/YYYY hh:mm:ss");
2163  $format_title =& $workbook->addFormat();
2164  $format_title->setBold();
2165  $format_title->setColor('black');
2166  $format_title->setPattern(1);
2167  $format_title->setFgColor('silver');
2168  $worksheet =& $workbook->addWorksheet();
2169  $column = 0;
2170  $profile_data = array("email", "gender", "firstname", "lastname", "person_title", "institution",
2171  "department", "street", "zipcode","city", "country", "phone_office", "phone_home", "phone_mobile",
2172  "fax", "matriculation");
2173  foreach ($profile_data as $data)
2174  {
2175  $worksheet->writeString(0, $column++, $this->cleanString($this->lng->txt($data)), $format_title);
2176  }
2177  $member_ids = $this->object->getGroupMemberIds();
2178  $row = 1;
2179  foreach ($member_ids as $member_id)
2180  {
2181  $column = 0;
2182  $member =& $this->ilias->obj_factory->getInstanceByObjId($member_id);
2183  if ($member->getPref("public_email")=="y")
2184  {
2185  $worksheet->writeString($row, $column++, $this->cleanString($member->getEmail()));
2186  }
2187  else
2188  {
2189  $column++;
2190  }
2191  $worksheet->writeString($row, $column++, $this->cleanString($this->lng->txt("gender_" . $member->getGender())));
2192  $worksheet->writeString($row, $column++, $this->cleanString($member->getFirstname()));
2193  $worksheet->writeString($row, $column++, $this->cleanString($member->getLastname()));
2194  $worksheet->writeString($row, $column++, $this->cleanString($member->getUTitle()));
2195  if ($member->getPref("public_institution")=="y")
2196  {
2197  $worksheet->writeString($row, $column++, $this->cleanString($member->getInstitution()));
2198  }
2199  else
2200  {
2201  $column++;
2202  }
2203  if ($member->getPref("public_department")=="y")
2204  {
2205  $worksheet->writeString($row, $column++, $this->cleanString($member->getDepartment()));
2206  }
2207  else
2208  {
2209  $column++;
2210  }
2211  if ($member->getPref("public_street")=="y")
2212  {
2213  $worksheet->writeString($row, $column++, $this->cleanString($member->getStreet()));
2214  }
2215  else
2216  {
2217  $column++;
2218  }
2219  if ($member->getPref("public_zip")=="y")
2220  {
2221  $worksheet->writeString($row, $column++, $this->cleanString($member->getZipcode()));
2222  }
2223  else
2224  {
2225  $column++;
2226  }
2227  if ($member->getPref("public_city")=="y")
2228  {
2229  $worksheet->writeString($row, $column++, $this->cleanString($member->getCity()));
2230  }
2231  else
2232  {
2233  $column++;
2234  }
2235  if ($member->getPref("public_country")=="y")
2236  {
2237  $worksheet->writeString($row, $column++, $this->cleanString($member->getCountry()));
2238  }
2239  else
2240  {
2241  $column++;
2242  }
2243  if ($member->getPref("public_phone_office")=="y")
2244  {
2245  $worksheet->writeString($row, $column++, $this->cleanString($member->getPhoneOffice()));
2246  }
2247  else
2248  {
2249  $column++;
2250  }
2251  if ($member->getPref("public_phone_home")=="y")
2252  {
2253  $worksheet->writeString($row, $column++, $this->cleanString($member->getPhoneHome()));
2254  }
2255  else
2256  {
2257  $column++;
2258  }
2259  if ($member->getPref("public_phone_mobile")=="y")
2260  {
2261  $worksheet->writeString($row, $column++, $this->cleanString($member->getPhoneMobile()));
2262  }
2263  else
2264  {
2265  $column++;
2266  }
2267  if ($member->getPref("public_fax")=="y")
2268  {
2269  $worksheet->writeString($row, $column++, $this->cleanString($member->getFax()));
2270  }
2271  else
2272  {
2273  $column++;
2274  }
2275  if ($member->getPref("public_matriculation")=="y")
2276  {
2277  $worksheet->writeString($row, $column++, $this->cleanString($member->getMatriculation()));
2278  }
2279  else
2280  {
2281  $column++;
2282  }
2283  $row++;
2284  }
2285  $workbook->close();
2286  }
2287 
2296  function cleanString($str)
2297  {
2298  return str_replace(array("��","��","��","��","��","��","��"), array("ae","oe","ue","ss","Ae","Oe","Ue"), $str);
2299  }
2300 
2311  function infoScreenObject()
2312  {
2313  $this->ctrl->setCmd("showSummary");
2314  $this->ctrl->setCmdClass("ilinfoscreengui");
2315  $this->infoScreen();
2316  }
2317 
2321  function infoScreen()
2322  {
2323  global $rbacsystem, $ilUser, $ilSetting;
2324 
2325  $this->tabs_gui->setTabActive('info_short');
2326 
2327  if(!$rbacsystem->checkAccess("visible", $this->ref_id))
2328  {
2329  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
2330  }
2331 
2332  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
2333  $info = new ilInfoScreenGUI($this);
2334 
2335  if(strlen($this->object->getInformation()))
2336  {
2337  $info->addSection($this->lng->txt('grp_general_informations'));
2338  $info->addProperty($this->lng->txt('grp_information'), nl2br(
2339  ilUtil::makeClickable ($this->object->getInformation(), true)));
2340  }
2341 
2342  $info->enablePrivateNotes();
2343  $info->enableLearningProgress(true);
2344 
2345  $info->addSection($this->lng->txt('group_registration'));
2346  $info->showLDAPRoleGroupMappingInfo();
2347 
2348  if(!$this->object->isRegistrationEnabled())
2349  {
2350  $info->addProperty($this->lng->txt('group_registration_mode'),
2351  $this->lng->txt('grp_reg_deac_info_screen'));
2352 
2353  }
2354  else
2355  {
2356  switch($this->object->getRegistrationType())
2357  {
2359  $info->addProperty($this->lng->txt('group_registration_mode'),
2360  $this->lng->txt('grp_reg_direct_info_screen'));
2361  break;
2362 
2364  $info->addProperty($this->lng->txt('group_registration_mode'),
2365  $this->lng->txt('grp_reg_req_info_screen'));
2366  break;
2367 
2369  $info->addProperty($this->lng->txt('group_registration_mode'),
2370  $this->lng->txt('grp_reg_passwd_info_screen'));
2371  break;
2372 
2373  }
2374  /*
2375  $info->addProperty($this->lng->txt('group_registration_time'),
2376  ilDatePresentation::formatPeriod(
2377  $this->object->getRegistrationStart(),
2378  $this->object->getRegistrationEnd()));
2379  */
2380  if($this->object->isRegistrationUnlimited())
2381  {
2382  $info->addProperty($this->lng->txt('group_registration_time'),
2383  $this->lng->txt('grp_registration_unlimited'));
2384  }
2385  elseif($this->object->getRegistrationStart()->getUnixTime() < time())
2386  {
2387  $info->addProperty($this->lng->txt("group_registration_time"),
2388  $this->lng->txt('cal_until').' '.
2389  ilDatePresentation::formatDate($this->object->getRegistrationEnd()));
2390  }
2391  elseif($this->object->getRegistrationStart()->getUnixTime() >= time())
2392  {
2393  $info->addProperty($this->lng->txt("group_registration_time"),
2394  $this->lng->txt('cal_from').' '.
2395  ilDatePresentation::formatDate($this->object->getRegistrationStart()));
2396  }
2397  if ($this->object->isMembershipLimited())
2398  {
2399  $info->addProperty($this->lng->txt("mem_free_places"),
2400  max(0,$this->object->getMaxMembers() - $this->object->members_obj->getCountMembers()));
2401 
2402  }
2403 
2404  }
2405 
2406  // Confirmation
2407  include_once('Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
2408  $privacy = ilPrivacySettings::_getInstance();
2409 
2410  include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
2411  if($privacy->groupConfirmationRequired() or ilCourseDefinedFieldDefinition::_getFields($this->object->getId()) or $privacy->enabledGroupExport())
2412  {
2413  include_once('Services/PrivacySecurity/classes/class.ilExportFieldsInfo.php');
2414 
2415  $field_info = ilExportFieldsInfo::_getInstanceByType($this->object->getType());
2416 
2417  $this->lng->loadLanguageModule('ps');
2418  $info->addSection($this->lng->txt('grp_user_agreement_info'));
2419  $info->addProperty($this->lng->txt('ps_export_data'),$field_info->exportableFieldsToInfoString());
2420 
2421  if($fields = ilCourseDefinedFieldDefinition::_fieldsToInfoString($this->object->getId()))
2422  {
2423  $info->addProperty($this->lng->txt('ps_grp_user_fields'),$fields);
2424  }
2425  }
2426 
2427 
2428  // forward the command
2429  $this->ctrl->forwardCommand($info);
2430  }
2431 
2436  {
2437  global $ilUser;
2438 
2439  $ilUser->setPref("grpcrs_ntf_".$this->ref_id, (bool)$_REQUEST["grp_ntf"]);
2440  $ilUser->writePrefs();
2441 
2442  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
2443  $this->ctrl->redirect($this, "infoScreen");
2444  }
2445 
2449  public static function _goto($a_target, $a_add = "")
2450  {
2451  global $ilAccess, $ilErr, $lng,$ilUser;
2452 
2453  include_once './Services/Membership/classes/class.ilMembershipRegistrationCodeUtils.php';
2454  if(substr($a_add,0,5) == 'rcode')
2455  {
2456  if($ilUser->getId() == ANONYMOUS_USER_ID)
2457  {
2458  // Redirect to login for anonymous
2460  "login.php?target=".$_GET["target"]."&cmd=force_login&lang=".
2461  $ilUser->getCurrentLanguage()
2462  );
2463  }
2464 
2465  // Redirects to target location after assigning user to course
2467  $a_target,
2469  substr($a_add,5)
2470  );
2471  }
2472 
2473  if ($a_add == "mem" && $ilAccess->checkAccess("write", "", $a_target))
2474  {
2475  ilObjectGUI::_gotoRepositoryNode($a_target, "members");
2476  }
2477 
2478  if ($ilAccess->checkAccess("read", "", $a_target))
2479  {
2481  }
2482  else
2483  {
2484  // to do: force flat view
2485  if ($ilAccess->checkAccess("visible", "", $a_target))
2486  {
2487  ilObjectGUI::_gotoRepositoryNode($a_target, "infoScreenGoto");
2488  }
2489  else
2490  {
2491  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
2492  {
2493  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
2494  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
2496  }
2497  }
2498  }
2499  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
2500  }
2501 
2502 
2510  protected function initForm($a_mode = 'edit')
2511  {
2512  global $ilUser,$tpl,$tree;
2513 
2514  if(is_object($this->form))
2515  {
2516  return true;
2517  }
2518 
2519  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2520 
2521  $this->form = new ilPropertyFormGUI();
2522  switch($a_mode)
2523  {
2524  case 'edit':
2525  $this->form->setFormAction($this->ctrl->getFormAction($this,'update'));
2526  break;
2527 
2528  default:
2529  $this->form->setTableWidth('600px');
2530  $this->form->setFormAction($this->ctrl->getFormAction($this,'save'));
2531  break;
2532  }
2533 
2534  // title
2535  $title = new ilTextInputGUI($this->lng->txt('title'),'title');
2536  $title->setSubmitFormOnEnter(true);
2537  $title->setValue($this->object->getTitle());
2538  $title->setSize(min(40, ilObject::TITLE_LENGTH));
2539  $title->setMaxLength(ilObject::TITLE_LENGTH);
2540  $title->setRequired(true);
2541  $this->form->addItem($title);
2542 
2543  // desc
2544  $desc = new ilTextAreaInputGUI($this->lng->txt('description'),'desc');
2545  $desc->setValue($this->object->getLongDescription());
2546  $desc->setRows(2);
2547  $desc->setCols(40);
2548  $this->form->addItem($desc);
2549 
2550  // Group type
2551  $grp_type = new ilRadioGroupInputGUI($this->lng->txt('grp_typ'),'grp_type');
2552 
2553  if($a_mode == 'edit')
2554  {
2555  $type = ($this->object->getGroupType() ? $this->object->getGroupType() : $this->object->readGroupStatus());
2556  }
2557  else
2558  {
2559  $type = ($this->object->getGroupType() ? $this->object->getGroupType() : GRP_TYPE_PUBLIC);
2560  }
2561 
2562  $grp_type->setValue($type);
2563  $grp_type->setRequired(true);
2564 
2565 
2566  // PUBLIC GROUP
2567  $opt_public = new ilRadioOption($this->lng->txt('grp_public'),GRP_TYPE_PUBLIC,$this->lng->txt('grp_public_info'));
2568  $grp_type->addOption($opt_public);
2569 
2570 
2571  // CLOSED GROUP
2572  $opt_closed = new ilRadioOption($this->lng->txt('grp_closed'),GRP_TYPE_CLOSED,$this->lng->txt('grp_closed_info'));
2573  $grp_type->addOption($opt_closed);
2574 
2575  $this->form->addItem($grp_type);
2576 
2577  if($a_mode == 'edit')
2578  {
2579  // Group registration ############################################################
2580  $pres = new ilFormSectionHeaderGUI();
2581  $pres->setTitle($this->lng->txt('grp_setting_header_registration'));
2582  $this->form->addItem($pres);
2583 
2584  // Registration type
2585  $reg_type = new ilRadioGroupInputGUI($this->lng->txt('group_registration_mode'),'registration_type');
2586  $reg_type->setValue($this->object->getRegistrationType());
2587 
2588  $opt_dir = new ilRadioOption($this->lng->txt('grp_reg_direct'),GRP_REGISTRATION_DIRECT);#$this->lng->txt('grp_reg_direct_info'));
2589  $reg_type->addOption($opt_dir);
2590 
2591  $opt_pass = new ilRadioOption($this->lng->txt('grp_pass_request'),GRP_REGISTRATION_PASSWORD);
2592  $pass = new ilTextInputGUI($this->lng->txt("password"),'password');
2593  $pass->setInfo($this->lng->txt('grp_reg_password_info'));
2594  $pass->setValue($this->object->getPassword());
2595  $pass->setSize(10);
2596  $pass->setMaxLength(32);
2597  $opt_pass->addSubItem($pass);
2598  $reg_type->addOption($opt_pass);
2599 
2600  $opt_req = new ilRadioOption($this->lng->txt('grp_reg_request'),GRP_REGISTRATION_REQUEST,$this->lng->txt('grp_reg_request_info'));
2601  $reg_type->addOption($opt_req);
2602 
2603  $opt_deact = new ilRadioOption($this->lng->txt('grp_reg_no_selfreg'),GRP_REGISTRATION_DEACTIVATED,$this->lng->txt('grp_reg_disabled_info'));
2604  $reg_type->addOption($opt_deact);
2605 
2606  // Registration codes
2607  $reg_code = new ilCheckboxInputGUI($this->lng->txt('grp_reg_code'),'reg_code_enabled');
2608  $reg_code->setChecked($this->object->isRegistrationAccessCodeEnabled());
2609  $reg_code->setValue(1);
2610  $reg_code->setInfo($this->lng->txt('grp_reg_code_enabled_info'));
2611  $this->form->addItem($reg_type);
2612 
2613  // Registration codes
2614  if(!$this->object->getRegistrationAccessCode())
2615  {
2616  include_once './Services/Membership/classes/class.ilMembershipRegistrationCodeUtils.php';
2617  $this->object->setRegistrationAccessCode(ilMembershipRegistrationCodeUtils::generateCode());
2618  }
2619  $reg_link = new ilHiddenInputGUI('reg_code');
2620  $reg_link->setValue($this->object->getRegistrationAccessCode());
2621  $this->form->addItem($reg_link);
2622 
2623  $link = new ilCustomInputGUI($this->lng->txt('grp_reg_code_link'));
2624  include_once './Services/Link/classes/class.ilLink.php';
2625  $val = ilLink::_getLink($this->object->getRefId(),$this->object->getType(),array(),'_rcode'.$this->object->getRegistrationAccessCode());
2626  $link->setHTML('<font class="small">'.$val.'</font>');
2627  $reg_code->addSubItem($link);
2628  $this->form->addItem($reg_code);
2629 
2630 
2631  // time limit
2632  $time_limit = new ilCheckboxInputGUI($this->lng->txt('grp_reg_limited'),'reg_limit_time');
2633 // $time_limit->setOptionTitle($this->lng->txt('grp_reg_limit_time'));
2634  $time_limit->setChecked($this->object->isRegistrationUnlimited() ? false : true);
2635 
2636  $this->lng->loadLanguageModule('dateplaner');
2637  include_once './Services/Form/classes/class.ilDateDurationInputGUI.php';
2638  $tpl->addJavaScript('./Services/Form/js/date_duration.js');
2639  $dur = new ilDateDurationInputGUI($this->lng->txt('grp_reg_period'),'reg');
2640  $dur->setStartText($this->lng->txt('cal_start'));
2641  $dur->setEndText($this->lng->txt('cal_end'));
2642  $dur->setShowTime(true);
2643  $dur->setStart($this->object->getRegistrationStart());
2644  $dur->setEnd($this->object->getRegistrationEnd());
2645 
2646  $time_limit->addSubItem($dur);
2647  $this->form->addItem($time_limit);
2648 
2649  // max member
2650  $lim = new ilCheckboxInputGUI($this->lng->txt('reg_grp_max_members_short'),'registration_membership_limited');
2651  $lim->setValue(1);
2652 // $lim->setOptionTitle($this->lng->txt('reg_grp_max_members'));
2653  $lim->setChecked($this->object->isMembershipLimited());
2654 
2655 
2656  $max = new ilTextInputGUI($this->lng->txt('reg_grp_max_members'),'registration_max_members');
2657  $max->setValue($this->object->getMaxMembers() ? $this->object->getMaxMembers() : '');
2658  //$max->setTitle($this->lng->txt('members'));
2659  $max->setSize(3);
2660  $max->setMaxLength(4);
2661  $max->setInfo($this->lng->txt('grp_reg_max_members_info'));
2662  $lim->addSubItem($max);
2663 
2664  $wait = new ilCheckboxInputGUI($this->lng->txt('grp_waiting_list'),'waiting_list');
2665  $wait->setValue(1);
2666  //$wait->setOptionTitle($this->lng->txt('grp_waiting_list'));
2667  $wait->setInfo($this->lng->txt('grp_waiting_list_info'));
2668  $wait->setChecked($this->object->isWaitingListEnabled() ? true : false);
2669  $lim->addSubItem($wait);
2670  $this->form->addItem($lim);
2671 
2672  // Group presentation
2673  $hasParentMembership =
2674  (
2675  $tree->checkForParentType($this->object->getRefId(),'crs') ||
2676  $tree->checkForParentType($this->object->getRefId(),'grp')
2677  );
2678 
2679  $pres = new ilFormSectionHeaderGUI();
2680  $pres->setTitle($this->lng->txt('grp_setting_header_presentation'));
2681  $this->form->addItem($pres);
2682 
2683  // presentation type
2684  $view_type = new ilRadioGroupInputGUI($this->lng->txt('grp_presentation_type'),'view_mode');
2685  if($hasParentMembership)
2686  {
2687  switch($this->object->getViewMode())
2688  {
2690  $course_view_mode = ': '.$this->lng->txt('cntr_view_sessions');
2691  break;
2692 
2694  $course_view_mode = ': '.$this->lng->txt('cntr_view_simple');
2695  break;
2696 
2698  $course_view_mode = ': '.$this->lng->txt('cntr_view_by_type');
2699  break;
2700  }
2701 
2702  $opt = new ilRadioOption($this->lng->txt('grp_view_inherit').$course_view_mode,ilContainer::VIEW_INHERIT);
2703  $opt->setInfo($this->lng->txt('grp_view_inherit_info'));
2704  $view_type->addOption($opt);
2705  }
2706 
2707  if($hasParentMembership &&
2708  $this->object->getViewMode(false) == ilContainer::VIEW_INHERIT)
2709  {
2710  $view_type->setValue(ilContainer::VIEW_INHERIT);
2711  }
2712  else
2713  {
2714  $view_type->setValue($this->object->getViewMode(true));
2715  }
2716 
2717  $opt = new ilRadioOption($this->lng->txt('cntr_view_simple'),ilContainer::VIEW_SIMPLE);
2718  $opt->setInfo($this->lng->txt('grp_view_info_simple'));
2719  $view_type->addOption($opt);
2720 
2721  $opt = new ilRadioOption($this->lng->txt('cntr_view_by_type'), ilContainer::VIEW_BY_TYPE);
2722  $opt->setInfo($this->lng->txt('grp_view_info_by_type'));
2723  $view_type->addOption($opt);
2724  $this->form->addItem($view_type);
2725 
2726 
2727  // Sorting
2728  $sorting_settings = array();
2729  if($hasParentMembership)
2730  {
2731  $sorting_settings[] = ilContainer::SORT_INHERIT;
2732  }
2733  $sorting_settings[] = ilContainer::SORT_TITLE;
2734  $sorting_settings[] = ilContainer::SORT_CREATION;
2735  $sorting_settings[] = ilContainer::SORT_MANUAL;
2736  $this->initSortingForm($this->form, $sorting_settings);
2737 
2738  // additional features
2739  $feat = new ilFormSectionHeaderGUI();
2740  $feat->setTitle($this->lng->txt('obj_features'));
2741  $this->form->addItem($feat);
2742 
2743  include_once './Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
2745  $this->object->getId(),
2746  $this->form,
2747  array(
2752  )
2753  );
2754 
2755  // Notification Settings
2756  /*$notification = new ilFormSectionHeaderGUI();
2757  $notification->setTitle($this->lng->txt('grp_notification'));
2758  $this->form->addItem($notification);*/
2759 
2760  // Show members type
2761  $mail_type = new ilRadioGroupInputGUI($this->lng->txt('grp_mail_type'), 'mail_type');
2762  $mail_type->setValue($this->object->getMailToMembersType());
2763 
2764  $mail_tutors = new ilRadioOption($this->lng->txt('grp_mail_tutors_only'), ilObjGroup::MAIL_ALLOWED_TUTORS,
2765  $this->lng->txt('grp_mail_tutors_only_info'));
2766  $mail_type->addOption($mail_tutors);
2767 
2768  $mail_all = new ilRadioOption($this->lng->txt('grp_mail_all'), ilObjGroup::MAIL_ALLOWED_ALL,
2769  $this->lng->txt('grp_mail_all_info'));
2770  $mail_type->addOption($mail_all);
2771  $this->form->addItem($mail_type);
2772  }
2773 
2774  switch($a_mode)
2775  {
2776  case 'create':
2777  $this->form->setTitle($this->lng->txt('grp_new'));
2778  $this->form->setTitleIcon(ilUtil::getImagePath('icon_grp.svg'));
2779 
2780  $this->form->addCommandButton('save',$this->lng->txt('grp_new'));
2781  $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
2782  return true;
2783 
2784  case 'edit':
2785  $this->form->setTitle($this->lng->txt('grp_edit'));
2786  $this->form->setTitleIcon(ilUtil::getImagePath('icon_grp.svg'));
2787 
2788  // Edit ecs export settings
2789  include_once 'Modules/Group/classes/class.ilECSGroupSettings.php';
2790  $ecs = new ilECSGroupSettings($this->object);
2791  $ecs->addSettingsToForm($this->form, 'grp');
2792 
2793  $this->form->addCommandButton('update',$this->lng->txt('save'));
2794  $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
2795  return true;
2796 
2797  }
2798  return true;
2799  }
2800 
2807  public function load()
2808  {
2809  $this->object->setTitle(ilUtil::stripSlashes($_POST['title']));
2810  $this->object->setDescription(ilUtil::stripSlashes($_POST['desc']));
2811  $this->object->setGroupType(ilUtil::stripSlashes($_POST['grp_type']));
2812  $this->object->setRegistrationType(ilUtil::stripSlashes($_POST['registration_type']));
2813  $this->object->setPassword(ilUtil::stripSlashes($_POST['password']));
2814  $this->object->enableUnlimitedRegistration((bool) !$_POST['reg_limit_time']);
2815  $this->object->setRegistrationStart($this->loadDate('start'));
2816  $this->object->setRegistrationEnd($this->loadDate('end'));
2817  $this->object->enableMembershipLimitation((bool) $_POST['registration_membership_limited']);
2818  $this->object->setMaxMembers((int) $_POST['registration_max_members']);
2819  $this->object->enableWaitingList((bool) $_POST['waiting_list']);
2820  $this->object->enableRegistrationAccessCode((bool) $_POST['reg_code_enabled']);
2821  $this->object->setRegistrationAccessCode(ilUtil::stripSlashes($_POST['reg_code']));
2822  $this->object->setViewMode(ilUtil::stripSlashes($_POST['view_mode']));
2823  $this->object->setMailToMembersType((int) $_POST['mail_type']);
2824 
2825  return true;
2826  }
2827 
2835  protected function loadDate($a_field)
2836  {
2837  global $ilUser;
2838 
2839  include_once('./Services/Calendar/classes/class.ilDateTime.php');
2840 
2841  $dt['year'] = (int) $_POST['reg'][$a_field]['date']['y'];
2842  $dt['mon'] = (int) $_POST['reg'][$a_field]['date']['m'];
2843  $dt['mday'] = (int) $_POST['reg'][$a_field]['date']['d'];
2844  $dt['hours'] = (int) $_POST['reg'][$a_field]['time']['h'];
2845  $dt['minutes'] = (int) $_POST['reg'][$a_field]['time']['m'];
2846  $dt['seconds'] = (int) $_POST['reg'][$a_field]['time']['s'];
2847 
2848  $date = new ilDateTime($dt,IL_CAL_FKT_GETDATE,$ilUser->getTimeZone());
2849  return $date;
2850  }
2851 
2859  protected function setSubTabs($a_tab)
2860  {
2861  global $rbacsystem,$ilUser,$ilAccess;
2862 
2863  switch($a_tab)
2864  {
2865  case 'members':
2866  // for admins
2867  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
2868  {
2869  $this->tabs_gui->addSubTabTarget("grp_edit_members",
2870  $this->ctrl->getLinkTarget($this,'members'),
2871  "members",
2872  get_class($this));
2873  }
2874  // for all
2875  $this->tabs_gui->addSubTabTarget("grp_members_gallery",
2876  $this->ctrl->getLinkTarget($this,'membersGallery'),
2877  "membersGallery", get_class($this));
2878 
2879  // members map
2880  include_once("./Services/Maps/classes/class.ilMapUtil.php");
2881  if (ilMapUtil::isActivated() &&
2882  $this->object->getEnableGroupMap())
2883  {
2884  $this->tabs_gui->addSubTabTarget("grp_members_map",
2885  $this->ctrl->getLinkTarget($this,'membersMap'),
2886  "membersMap", get_class($this));
2887  }
2888 
2889  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
2890  {
2891  $this->tabs_gui->addSubTabTarget("events",
2892  $this->ctrl->getLinkTargetByClass('ilsessionoverviewgui','listSessions'),
2893  "", 'ilsessionoverviewgui');
2894  }
2895 
2896  include_once 'Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
2897  if(ilPrivacySettings::_getInstance()->checkExportAccess($this->object->getRefId()))
2898  {
2899  $this->tabs_gui->addSubTabTarget('grp_export_members',
2900  $this->ctrl->getLinkTargetByClass('ilmemberexportgui','show'),
2901  "", 'ilmemberexportgui');
2902  }
2903 
2904  break;
2905 
2906  case 'settings':
2907  $this->tabs_gui->addSubTabTarget("grp_settings",
2908  $this->ctrl->getLinkTarget($this,'edit'),
2909  "edit", get_class($this));
2910 
2911  $this->tabs_gui->addSubTabTarget("grp_info_settings",
2912  $this->ctrl->getLinkTarget($this,'editInfo'),
2913  "editInfo", get_class($this));
2914 
2915  // custom icon
2916  if ($this->ilias->getSetting("custom_icons"))
2917  {
2918  $this->tabs_gui->addSubTabTarget("grp_icon_settings",
2919  $this->ctrl->getLinkTarget($this,'editGroupIcons'),
2920  "editGroupIcons", get_class($this));
2921  }
2922 
2923  include_once("./Services/Maps/classes/class.ilMapUtil.php");
2924  if (ilMapUtil::isActivated())
2925  {
2926  $this->tabs_gui->addSubTabTarget("grp_map_settings",
2927  $this->ctrl->getLinkTarget($this,'editMapSettings'),
2928  "editMapSettings", get_class($this));
2929  }
2930 
2931  $this->tabs_gui->addSubTabTarget('groupings',
2932  $this->ctrl->getLinkTargetByClass('ilobjcoursegroupinggui','listGroupings'),
2933  'listGroupings',
2934  get_class($this));
2935 
2936  include_once('Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
2937  include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
2938  // only show if export permission is granted
2939  if(ilPrivacySettings::_getInstance()->checkExportAccess($this->object->getRefId()) or ilCourseDefinedFieldDefinition::_hasFields($this->object->getId()))
2940  {
2941  $this->tabs_gui->addSubTabTarget('grp_custom_user_fields',
2942  $this->ctrl->getLinkTargetByClass('ilobjectcustomuserfieldsgui'),
2943  '',
2944  'ilobjectcustomuserfieldsgui');
2945  }
2946 
2947 
2948 
2949  break;
2950 
2951 
2952  }
2953  }
2954 
2961  private function checkAgreement()
2962  {
2963  global $ilUser,$ilAccess;
2964 
2965  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
2966  {
2967  return true;
2968  }
2969 
2970  // Disable aggrement if is not member of group
2971  if(!$this->object->members_obj->isAssigned($ilUser->getId()))
2972  {
2973  return true;
2974  }
2975 
2976  include_once './Services/Container/classes/class.ilMemberViewSettings.php';
2977  if(ilMemberViewSettings::getInstance()->isActive())
2978  {
2979  return true;
2980  }
2981 
2982  include_once('Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
2983  include_once('Services/Membership/classes/class.ilMemberAgreement.php');
2984  $privacy = ilPrivacySettings::_getInstance();
2985 
2986  // Check agreement
2987  if(($privacy->groupConfirmationRequired() or ilCourseDefinedFieldDefinition::_hasFields($this->object->getId()))
2988  and !ilMemberAgreement::_hasAccepted($ilUser->getId(),$this->object->getId()))
2989  {
2990  return false;
2991  }
2992  // Check required fields
2993  include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');
2994  if(!ilCourseUserData::_checkRequired($ilUser->getId(),$this->object->getId()))
2995  {
2996  return false;
2997  }
2998  return true;
2999  }
3000 
3001 
3006  public function prepareOutput()
3007  {
3008  global $rbacsystem;
3009  if(!$this->getCreationMode())
3010  {
3011  /*
3012  include_once './Services/Container/classes/class.ilMemberViewSettings.php';
3013  $settings = ilMemberViewSettings::getInstance();
3014  if($settings->isActive() and $settings->getContainer() != $this->object->getRefId())
3015  {
3016  $settings->setContainer($this->object->getRefId());
3017  $rbacsystem->initMemberView();
3018  }
3019  */
3020  }
3022  }
3023 
3028  protected function createMailSignature()
3029  {
3030  $link = chr(13).chr(10).chr(13).chr(10);
3031  $link .= $this->lng->txt('grp_mail_permanent_link');
3032  $link .= chr(13).chr(10).chr(13).chr(10);
3033  include_once 'Services/Link/classes/class.ilLink.php';
3034  $link .= ilLink::_getLink($this->object->getRefId());
3035  return rawurlencode(base64_encode($link));
3036  }
3037 
3038  protected function initHeaderAction($a_sub_type = null, $a_sub_id = null)
3039  {
3040  global $ilSetting, $ilUser;
3041 
3042  $lg = parent::initHeaderAction($a_sub_type, $a_sub_id);
3043 
3044  include_once('./Modules/Group/classes/class.ilGroupParticipants.php');
3045  if($ilSetting->get("crsgrp_ntf") &&
3046  ilGroupParticipants::_isParticipant($this->ref_id, $ilUser->getId()))
3047  {
3048  if(!$ilUser->getPref("grpcrs_ntf_".$this->ref_id))
3049  {
3050  $lg->addHeaderIcon("not_icon",
3051  ilUtil::getImagePath("notification_off.svg"),
3052  $this->lng->txt("grp_notification_deactivated"));
3053 
3054  $this->ctrl->setParameter($this, "grp_ntf", 1);
3055  $caption = "grp_activate_notification";
3056  }
3057  else
3058  {
3059  $lg->addHeaderIcon("not_icon",
3060  ilUtil::getImagePath("notification_on.svg"),
3061  $this->lng->txt("grp_notification_activated"));
3062 
3063  $this->ctrl->setParameter($this, "grp_ntf", 0);
3064  $caption = "grp_deactivate_notification";
3065  }
3066 
3067  $lg->addCustomCommand($this->ctrl->getLinkTarget($this, "saveNotification"),
3068  $caption);
3069 
3070 
3071  $this->ctrl->setParameter($this, "grp_ntf", "");
3072  }
3073 
3074  return $lg;
3075  }
3076 
3078  {
3079  global $ilTabs;
3080 
3081  $this->checkPermission('write');
3082 
3083  $ilTabs->clearTargets();
3084  $ilTabs->setBackTarget($this->lng->txt('back'),
3085  $this->ctrl->getLinkTarget($this, 'members'));
3086 
3087  $list = $this->initAttendanceList();
3088  $form = $list->initForm('printMembersOutput');
3089  $this->tpl->setContent($form->getHTML());
3090  }
3091 
3097  protected function initAttendanceList()
3098  {
3099  include_once('./Modules/Group/classes/class.ilGroupParticipants.php');
3100  $members_obj = ilGroupParticipants::_getInstanceByObjId($this->object->getId());
3101 
3102  include_once('./Modules/Group/classes/class.ilGroupWaitingList.php');
3103  $waiting_list = new ilGroupWaitingList($this->object->getId());
3104 
3105  include_once 'Services/Membership/classes/class.ilAttendanceList.php';
3106  $list = new ilAttendanceList($this, $members_obj, $waiting_list);
3107  $list->setId('grpmemlst');
3108 
3109  $list->setTitle($this->lng->txt('grp_members_print_title'),
3110  $this->lng->txt('obj_grp').': '.$this->object->getTitle());
3111 
3112  include_once './Services/Tracking/classes/class.ilObjUserTracking.php';
3113  $this->show_tracking = (ilObjUserTracking::_enabledLearningProgress() and
3115  if($this->show_tracking)
3116  {
3117  include_once('./Services/Object/classes/class.ilObjectLP.php');
3118  $olp = ilObjectLP::getInstance($this->object->getId());
3119  $this->show_tracking = $olp->isActive();
3120  }
3121  if($this->show_tracking)
3122  {
3123  $this->lng->loadLanguageModule('trac');
3124  $list->addPreset('progress', $this->lng->txt('learning_progress'), true);
3125  }
3126 
3127  include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
3128  $privacy = ilPrivacySettings::_getInstance();
3129  if($privacy->enabledGroupAccessTimes())
3130  {
3131  $list->addPreset('access', $this->lng->txt('last_access'), true);
3132  }
3133 
3134  return $list;
3135  }
3136 
3137  public function getAttendanceListUserData($a_user_id)
3138  {
3139  $data = $this->members_data[$a_user_id];
3140  $data['access'] = $data['access_time'];
3141  $data['progress'] = $this->lng->txt($data['progress']);
3142 
3143  return $data;
3144  }
3145 
3147  {
3148  $list = $this->initAttendanceList();
3149  $list->initFromForm();
3150  $list->setCallback(array($this, 'getAttendanceListUserData'));
3151 
3152  $part = ilGroupParticipants::_getInstanceByObjId($this->object->getId());
3153  $this->members_data = $this->readMemberData($part->getParticipants());
3154  $list->getNonMemberUserData($this->members_data);
3155 
3156  echo $list->getFullscreenHTML();
3157  exit();
3158  }
3159 
3164  protected function getLocalRoles()
3165  {
3166  $local_roles = $this->object->getLocalGroupRoles(false);
3167  $grp_member = $this->object->getDefaultMemberRole();
3168  $grp_roles = array();
3169 
3170  //put the group member role to the top of the crs_roles array
3171  if(in_array($grp_member, $local_roles))
3172  {
3173  $grp_roles[$grp_member] = ilObjRole::_getTranslation(array_search ($grp_member, $local_roles));
3174  unset($local_roles[$grp_roles[$grp_member]]);
3175  }
3176 
3177  foreach($local_roles as $title => $role_id)
3178  {
3179  $grp_roles[$role_id] = ilObjRole::_getTranslation($title);
3180  }
3181  return $grp_roles;
3182  }
3183 
3184 
3192  protected function addMailToMemberButton($ilToolbar, $back_cmd = null, $a_separator = false)
3193  {
3194  global $ilAccess, $ilUser, $rbacsystem;
3195  include_once 'Services/Mail/classes/class.ilMail.php';
3196  $mail = new ilMail($ilUser->getId());
3197 
3198  if(
3199  ($ilAccess->checkAccess('write','',$this->object->getRefId()) or
3200  $this->object->getMailToMembersType() == ilObjGroup::MAIL_ALLOWED_ALL) and
3201  $rbacsystem->checkAccess('internal_mail',$mail->getMailObjectReferenceId()))
3202  {
3203 
3204  if($a_separator)
3205  {
3206  $ilToolbar->addSeparator();
3207  }
3208 
3209  if($back_cmd)
3210  {
3211  $this->ctrl->setParameter($this, "back_cmd", $back_cmd);
3212  }
3213 
3214  $ilToolbar->addButton($this->lng->txt("mail_members"),
3215  $this->ctrl->getLinkTarget($this,'mailMembers'));
3216  }
3217  }
3218 
3220  {
3221  if(!is_array($_POST["subscribers"]))
3222  {
3223  ilUtil::sendFailure($this->lng->txt("no_checkbox"));
3224  $this->membersObject();
3225 
3226  return false;
3227  }
3228 
3229  $this->lng->loadLanguageModule('mmbr');
3230 
3231  $this->checkPermission('write');
3232  $this->setSubTabs('members');
3233  $this->tabs_gui->setTabActive('members');
3234  $this->tabs_gui->setSubTabActive('grp_edit_members');
3235 
3236  include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
3237  $c_gui = new ilConfirmationGUI();
3238 
3239  // set confirm/cancel commands
3240  $c_gui->setFormAction($this->ctrl->getFormAction($this, "refuseSubscribers"));
3241  $c_gui->setHeaderText($this->lng->txt("info_refuse_sure"));
3242  $c_gui->setCancel($this->lng->txt("cancel"), "members");
3243  $c_gui->setConfirm($this->lng->txt("confirm"), "refuseSubscribers");
3244 
3245  foreach($_POST["subscribers"] as $subscribers)
3246  {
3247  $name = ilObjUser::_lookupName($subscribers);
3248 
3249  $c_gui->addItem('subscribers[]',
3250  $name['user_id'],
3251  $name['lastname'].', '.$name['firstname'].' ['.$name['login'].']',
3252  ilUtil::getImagePath('icon_usr.svg'));
3253  }
3254 
3255  $this->tpl->setContent($c_gui->getHTML());
3256  }
3257 
3259  {
3260  if(!is_array($_POST["subscribers"]))
3261  {
3262  ilUtil::sendFailure($this->lng->txt("no_checkbox"));
3263  $this->membersObject();
3264 
3265  return false;
3266  }
3267  $this->checkPermission('write');
3268  $this->setSubTabs('members');
3269  $this->tabs_gui->setTabActive('members');
3270  $this->tabs_gui->setSubTabActive('grp_edit_members');
3271 
3272  include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
3273  $c_gui = new ilConfirmationGUI();
3274 
3275  // set confirm/cancel commands
3276  $c_gui->setFormAction($this->ctrl->getFormAction($this, "assignSubscribers"));
3277  $c_gui->setHeaderText($this->lng->txt("info_assign_sure"));
3278  $c_gui->setCancel($this->lng->txt("cancel"), "members");
3279  $c_gui->setConfirm($this->lng->txt("confirm"), "assignSubscribers");
3280 
3281  foreach($_POST["subscribers"] as $subscribers)
3282  {
3283  $name = ilObjUser::_lookupName($subscribers);
3284 
3285  $c_gui->addItem('subscribers[]',
3286  $name['user_id'],
3287  $name['lastname'].', '.$name['firstname'].' ['.$name['login'].']',
3288  ilUtil::getImagePath('icon_usr.svg'));
3289  }
3290 
3291  $this->tpl->setContent($c_gui->getHTML());
3292  return true;
3293  }
3294 
3296  {
3297  if(!is_array($_POST["waiting"]))
3298  {
3299  ilUtil::sendFailure($this->lng->txt("no_checkbox"));
3300  $this->membersObject();
3301 
3302  return false;
3303  }
3304 
3305  $this->lng->loadLanguageModule('mmbr');
3306 
3307  $this->checkPermission('write');
3308  $this->setSubTabs('members');
3309  $this->tabs_gui->setTabActive('members');
3310  $this->tabs_gui->setSubTabActive('grp_edit_members');
3311 
3312  include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
3313  $c_gui = new ilConfirmationGUI();
3314 
3315  // set confirm/cancel commands
3316  $c_gui->setFormAction($this->ctrl->getFormAction($this, "refuseFromList"));
3317  $c_gui->setHeaderText($this->lng->txt("info_refuse_sure"));
3318  $c_gui->setCancel($this->lng->txt("cancel"), "members");
3319  $c_gui->setConfirm($this->lng->txt("confirm"), "refuseFromList");
3320 
3321  foreach($_POST["waiting"] as $waiting)
3322  {
3323  $name = ilObjUser::_lookupName($waiting);
3324 
3325  $c_gui->addItem('waiting[]',
3326  $name['user_id'],
3327  $name['lastname'].', '.$name['firstname'].' ['.$name['login'].']',
3328  ilUtil::getImagePath('icon_usr.svg'));
3329  }
3330 
3331  $this->tpl->setContent($c_gui->getHTML());
3332  return true;
3333  }
3334 
3336  {
3337  if(!is_array($_POST["waiting"]))
3338  {
3339  ilUtil::sendFailure($this->lng->txt("no_checkbox"));
3340  $this->membersObject();
3341 
3342  return false;
3343  }
3344  $this->checkPermission('write');
3345  $this->setSubTabs('members');
3346  $this->tabs_gui->setTabActive('members');
3347  $this->tabs_gui->setSubTabActive('grp_edit_members');
3348 
3349  include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
3350  $c_gui = new ilConfirmationGUI();
3351 
3352  // set confirm/cancel commands
3353  $c_gui->setFormAction($this->ctrl->getFormAction($this, "assignFromWaitingList"));
3354  $c_gui->setHeaderText($this->lng->txt("info_assign_sure"));
3355  $c_gui->setCancel($this->lng->txt("cancel"), "members");
3356  $c_gui->setConfirm($this->lng->txt("confirm"), "assignFromWaitingList");
3357 
3358  foreach($_POST["waiting"] as $waiting)
3359  {
3360  $name = ilObjUser::_lookupName($waiting);
3361 
3362  $c_gui->addItem('waiting[]',
3363  $name['user_id'],
3364  $name['lastname'].', '.$name['firstname'].' ['.$name['login'].']',
3365  ilUtil::getImagePath('icon_usr.svg'));
3366  }
3367 
3368  $this->tpl->setContent($c_gui->getHTML());
3369  return true;
3370  }
3371 
3372 } // END class.ilObjGroupGUI
3373 ?>