ILIAS  release_4-3 Revision
 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  // add entry to navigation history
48  if (!$this->getCreationMode() &&
49  $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
50  {
51  $ilNavigationHistory->addItem($_GET["ref_id"],
52  $ilCtrl->getLinkTargetByClass("ilrepositorygui", "frameset"), "grp");
53  }
54 
55  switch($next_class)
56  {
57  case 'ilgroupregistrationgui':
58  $this->ctrl->setReturn($this,'');
59  $this->tabs_gui->setTabActive('join');
60  include_once('./Modules/Group/classes/class.ilGroupRegistrationGUI.php');
61  $registration = new ilGroupRegistrationGUI($this->object);
62  $this->ctrl->forwardCommand($registration);
63  break;
64 
65  case 'ilpermissiongui':
66  $this->tabs_gui->setTabActive('perm_settings');
67  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
68  $perm_gui =& new ilPermissionGUI($this);
69  $ret =& $this->ctrl->forwardCommand($perm_gui);
70  break;
71 
72  case 'ilrepositorysearchgui':
73  include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
74  $rep_search =& new ilRepositorySearchGUI();
75  $rep_search->setCallback($this,
76  'addUserObject',
77  array(
78  ilObjGroup::GRP_MEMBER => $this->lng->txt('il_grp_member'),
79  ilObjGroup::GRP_ADMIN => $this->lng->txt('il_grp_admin')
80  ));
81 
82  // Set tabs
83  $this->tabs_gui->setTabActive('members');
84  $this->ctrl->setReturn($this,'members');
85  $ret =& $this->ctrl->forwardCommand($rep_search);
86  $this->setSubTabs('members');
87  $this->tabs_gui->setSubTabActive('members');
88  break;
89 
90  case "ilinfoscreengui":
91  $ret =& $this->infoScreen();
92  break;
93 
94  case "illearningprogressgui":
95  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
96 
98  $this->object->getRefId(),
99  $_GET['user_id'] ? $_GET['user_id'] : $ilUser->getId());
100  $this->ctrl->forwardCommand($new_gui);
101  $this->tabs_gui->setTabActive('learning_progress');
102  break;
103 
104  case 'ilobjcoursegroupinggui':
105  $this->setSubTabs('settings');
106 
107  include_once './Modules/Course/classes/class.ilObjCourseGroupingGUI.php';
108  $this->ctrl->setReturn($this,'edit');
109  $crs_grp_gui =& new ilObjCourseGroupingGUI($this->object,(int) $_GET['obj_id']);
110  $this->ctrl->forwardCommand($crs_grp_gui);
111 
112  $this->tabs_gui->setTabActive('settings');
113  $this->tabs_gui->setSubTabActive('groupings');
114  break;
115 
116  case 'ilcoursecontentgui':
117 
118  include_once './Modules/Course/classes/class.ilCourseContentGUI.php';
119  $course_content_obj = new ilCourseContentGUI($this);
120  $this->ctrl->forwardCommand($course_content_obj);
121  break;
122 
123  case 'ilpublicuserprofilegui':
124  require_once './Services/User/classes/class.ilPublicUserProfileGUI.php';
125  $this->setSubTabs('members');
126  $this->tabs_gui->setTabActive('group_members');
127  $this->tabs_gui->setSubTabActive('grp_members_gallery');
128  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
129  $profile_gui->setBackUrl($ilCtrl->getLinkTarget($this, "membersGallery"));
130  $html = $this->ctrl->forwardCommand($profile_gui);
131  $this->tpl->setVariable("ADM_CONTENT", $html);
132  break;
133 
134  case "ilcolumngui":
135  $this->tabs_gui->setTabActive('none');
136  $this->checkPermission("read");
137  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
138  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
139  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId()));
140  $this->renderObject();
141  break;
142 
143  // container page editing
144  case "ilpageobjectgui":
145  $ret = $this->forwardToPageObject();
146  if ($ret != "")
147  {
148  $this->tpl->setContent($ret);
149  }
150  break;
151 
152  case 'ilobjectcopygui':
153  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
154  $cp = new ilObjectCopyGUI($this);
155  $cp->setType('grp');
156  $this->ctrl->forwardCommand($cp);
157  break;
158 
159  case "ilobjstylesheetgui":
160  $this->forwardToStyleSheet();
161  break;
162 
163  case 'ilobjectcustomuserfieldsgui':
164  include_once './Services/Membership/classes/class.ilObjectCustomUserFieldsGUI.php';
165  $cdf_gui = new ilObjectCustomUserFieldsGUI($this->object->getId());
166  $this->setSubTabs('settings');
167  $this->tabs_gui->setTabActive('settings');
168  $this->ctrl->forwardCommand($cdf_gui);
169  break;
170 
171  case 'ilmemberagreementgui':
172  include_once('Services/Membership/classes/class.ilMemberAgreementGUI.php');
173  $this->ctrl->setReturn($this,'');
174  $this->tabs_gui->setTabActive('view_content');
175  $agreement = new ilMemberAgreementGUI($this->object->getRefId());
176  $this->ctrl->forwardCommand($agreement);
177  break;
178 
179  case 'ilexportgui':
180  $this->tabs_gui->setTabActive('export');
181  include_once './Services/Export/classes/class.ilExportGUI.php';
182  $exp = new ilExportGUI($this);
183  $exp->addFormat('xml');
184  $this->ctrl->forwardCommand($exp);
185  break;
186 
187  case 'ilmemberexportgui':
188  include_once('./Services/Membership/classes/Export/class.ilMemberExportGUI.php');
189 
190  $this->setSubTabs('members');
191  $this->tabs_gui->setTabActive('members');
192  $this->tabs_gui->setSubTabActive('export_members');
193  $export = new ilMemberExportGUI($this->object->getRefId());
194  $this->ctrl->forwardCommand($export);
195  break;
196 
197  case "ilcommonactiondispatchergui":
198  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
200  $this->ctrl->forwardCommand($gui);
201  break;
202 
203  case 'ilobjectservicesettingsgui':
204  $this->ctrl->setReturn($this,'edit');
205  $this->setSubTabs("settings");
206  $this->tabs_gui->activateTab('settings');
207  $this->tabs_gui->activateSubTab('tool_settings');
208 
209  include_once './Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
210  $service = new ilObjectServiceSettingsGUI(
211  $this,
212  $this->object->getId(),
213  array(
215  ));
216  $this->ctrl->forwardCommand($service);
217  break;
218 
219  case 'ilsessionoverviewgui':
220  $this->setSubTabs('members');
221  $this->tabs_gui->setTabActive('members');
222  $this->tabs_gui->setSubTabActive('events');
223 
224  include_once './Modules/Group/classes/class.ilGroupParticipants.php';
225  $prt = ilGroupParticipants::_getInstanceByObjId($this->object->getId());
226 
227  include_once('./Modules/Session/classes/class.ilSessionOverviewGUI.php');
228  $overview = new ilSessionOverviewGUI($this->object->getRefId(), $prt);
229  $this->ctrl->forwardCommand($overview);
230  break;
231 
232  default:
233 
234  // check visible permission
235  if (!$this->getCreationMode() and !$ilAccess->checkAccess('visible','',$this->object->getRefId(),'grp'))
236  {
237  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"),$ilErr->MESSAGE);
238  }
239 
240  // #9401 - see also ilStartupGUI::_checkGoto()
241  if($cmd == 'infoScreenGoto')
242  {
243  if($this->object->isRegistrationEnabled())
244  {
245  $cmd = 'join';
246  }
247  else
248  {
249  $cmd = 'infoScreen';
250  }
251  }
252 
253  // check read permission
254  if ((!$this->getCreationMode()
255  && !$rbacsystem->checkAccess('read',$this->object->getRefId()) && $cmd != 'infoScreen')
256  || $cmd == 'join')
257  {
258  // no join permission -> redirect to info screen
259  if (!$rbacsystem->checkAccess('join',$this->object->getRefId()))
260  {
261  $this->ctrl->redirect($this, "infoScreen");
262  }
263  else // no read -> show registration
264  {
265  include_once('./Modules/Group/classes/class.ilGroupRegistrationGUI.php');
266  $this->ctrl->redirectByClass("ilGroupRegistrationGUI", "show");
267  }
268  }
269  if(!$cmd)
270  {
271  $cmd = 'view';
272  }
273  $cmd .= 'Object';
274  $this->$cmd();
275  break;
276  }
277 
278  $this->addHeaderAction();
279  }
280 
281  function viewObject()
282  {
283  global $tree,$rbacsystem,$ilUser;
284 
285  include_once 'Services/Tracking/classes/class.ilLearningProgress.php';
286  ilLearningProgress::_tracProgress($ilUser->getId(),$this->object->getId(),
287  $this->object->getRefId(),'grp');
288 
289  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
290  {
292  return true;
293  }
294 
295  if(!$this->checkAgreement())
296  {
297  include_once('Services/Membership/classes/class.ilMemberAgreementGUI.php');
298  $this->tabs_gui->setTabActive('view_content');
299  $this->ctrl->setReturn($this,'view');
300  $agreement = new ilMemberAgreementGUI($this->object->getRefId());
301  $this->ctrl->setCmdClass(get_class($agreement));
302  $this->ctrl->forwardCommand($agreement);
303  return true;
304  }
305 
306  $this->tabs_gui->setTabActive('view_content');
307  $this->renderObject();
308  }
309 
313  function renderObject()
314  {
315  global $ilTabs;
316 
317  $ilTabs->activateTab("view_content");
319  return $ret;
320 
321  }
322 
326  function modifyItemGUI($a_item_list_gui, $a_item_data, $a_show_path)
327  {
328  global $tree;
329 
330  // if folder is in a course, modify item list gui according to course requirements
331  if ($course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs'))
332  {
333  include_once("./Modules/Course/classes/class.ilObjCourse.php");
334  include_once("./Modules/Course/classes/class.ilObjCourseGUI.php");
335  $course_obj_id = ilObject::_lookupObjId($course_ref_id);
336  ilObjCourseGUI::_modifyItemGUI($a_item_list_gui,'ilcoursecontentgui',$a_item_data, $a_show_path,
337  ilObjCourse::_lookupAboStatus($course_obj_id), $course_ref_id, $course_obj_id,
338  $this->object->getRefId());
339  }
340  }
341 
342  protected function initCreateForm($a_new_type)
343  {
344  if(!is_object($this->object))
345  {
346  $this->object = new ilObjGroup();
347  }
348 
349  $this->initForm('create');
350  return $this->form;
351  }
352 
360  public function saveObject()
361  {
362  global $ilErr,$ilUser,$tree;
363 
364  $this->object = new ilObjGroup();
365 
366  // we reduced the form, only 3 values left
367  // $this->load();
368 
369  $grp_type = ilUtil::stripSlashes($_POST['grp_type']);
370  switch($grp_type)
371  {
372  case GRP_TYPE_PUBLIC:
373  $this->object->setRegistrationType(GRP_REGISTRATION_DIRECT);
374  break;
375 
376  default:
377  $this->object->setRegistrationType(GRP_REGISTRATION_DEACTIVATED);
378  break;
379  }
380  $this->object->setTitle(ilUtil::stripSlashes($_POST['title']));
381  $this->object->setDescription(ilUtil::stripSlashes($_POST['desc']));
382  $this->object->setGroupType(ilUtil::stripSlashes($_POST['grp_type']));
383  $this->object->setViewMode(ilContainer::VIEW_INHERIT);
384 
385  $ilErr->setMessage('');
386 
387  if(!$this->object->validate())
388  {
389  $err = $this->lng->txt('err_check_input');
390  ilUtil::sendFailure($err);
391  $err = $ilErr->getMessage();
392  ilUtil::sendInfo($err);
393  $this->createObject();
394  return true;
395  }
396 
397  $this->object->create();
398  $this->putObjectInTree($this->object, $_GET["ref_id"]);
399  $this->object->initGroupStatus($this->object->getGroupType());
400 
401  // check for parent group or course => SORT_INHERIT
402  $sort_mode = ilContainer::SORT_TITLE;
403  if(
404  $GLOBALS['tree']->checkForParentType($this->object->getRefId(),'crs') ||
405  $GLOBALS['tree']->checkForParentType($this->object->getRefId(),'grp')
406  )
407  {
408  $sort_mode = ilContainer::SORT_INHERIT;
409  }
410  // Save sorting
411  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
412  $sort = new ilContainerSortingSettings($this->object->getId());
413  $sort->setSortMode($sort_mode);
414  $sort->update();
415 
416 
417  // Add user as admin and enable notification
418  include_once('./Modules/Group/classes/class.ilGroupParticipants.php');
419  $members_obj = ilGroupParticipants::_getInstanceByObjId($this->object->getId());
420  $members_obj->add($ilUser->getId(),IL_GRP_ADMIN);
421  $members_obj->updateNotification($ilUser->getId(),1);
422 
423 
424  ilUtil::sendSuccess($this->lng->txt("grp_added"),true);
425  $this->ctrl->setParameter($this,'ref_id',$this->object->getRefId());
426  $this->ctrl->redirect($this, "edit");
427  }
428 
436  public function editObject()
437  {
438  $this->checkPermission("write");
439 
440  $this->setSubTabs('settings');
441  $this->tabs_gui->setTabActive('settings');
442  $this->tabs_gui->setSubTabActive('grp_settings');
443 
444  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.grp_edit.html','Modules/Group');
445  if($_GET['group_type_changed'])
446  {
447  $this->ctrl->clearParameters($this);
448  $this->tpl->setVariable('GRP_FORMACTION',$this->ctrl->getFormAction($this));
449  $this->tpl->setVariable('TXT_SW_GRP_TYPE_S',$this->lng->txt('grp_change_type'));
450  $this->tpl->setVariable('TXT_SW_GRP_TYPE_C',$this->lng->txt('cancel'));
451  $this->initForm('update_group_type');
452  }
453  else
454  {
455  $this->initForm('edit');
456  }
457  $this->tpl->setVariable('EDIT_FORM',$this->form->getHTML());
458  }
459 
467  public function updateGroupTypeObject()
468  {
469  $type = $this->object->getGroupType() ?
470  $this->object->getGroupType() :
471  $this->object->readGroupStatus();
472 
473  if($type == GRP_TYPE_PUBLIC)
474  {
475  $this->object->setGroupType(GRP_TYPE_CLOSED);
476  }
477  else
478  {
479  $this->object->setGroupType(GRP_TYPE_PUBLIC);
480  }
481  $this->object->updateGroupType();
482  $this->object->update();
483  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
484  $this->ctrl->redirect($this,'edit');
485  }
486 
487 
493  public function updateObject()
494  {
495  global $ilErr;
496 
497  $this->checkPermission('write');
498 
499 
500  $this->initForm();
501  $this->form->checkInput();
502 
503  $old_type = $this->object->getGroupType();
504 
505  $this->load();
506  $ilErr->setMessage('');
507 
508  if(!$this->object->validate())
509  {
510  $err = $this->lng->txt('err_check_input');
511  ilUtil::sendFailure($err);
512  $err = $ilErr->getMessage();
513  ilUtil::sendInfo($err);
514  $this->editObject();
515  return true;
516  }
517 
518  $modified = false;
519  if($this->object->isGroupTypeModified($old_type) and !$update_group_type)
520  {
521  $modified = true;
522  $this->object->setGroupType($old_type);
523  }
524 
525  $this->object->update();
526 
527 
528  include_once './Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
530  $this->object->getId(),
531  $this->form,
532  array(
535  )
536  );
537 
538 
539  // Save sorting
540  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
541  $sort = new ilContainerSortingSettings($this->object->getId());
542  $sort->setSortMode((int) $_POST['sor']);
543  $sort->update();
544 
545  // BEGIN ChangeEvents: Record update Object.
546  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
547  global $ilUser;
548  ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
549  ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
550  // END PATCH ChangeEvents: Record update Object.
551 
552  // Update ecs export settings
553  include_once 'Modules/Group/classes/class.ilECSGroupSettings.php';
554  $ecs = new ilECSGroupSettings($this->object);
555  $ecs->handleSettingsUpdate();
556 
557  if($modified)
558  {
559  include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
560  ilUtil::sendQuestion($this->lng->txt('grp_warn_grp_type_changed'));
561  $confirm = new ilConfirmationGUI();
562  $confirm->setFormAction($this->ctrl->getFormAction($this));
563  $confirm->addItem(
564  'grp_type',
565  $this->object->getGroupType(),
566  $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'))
567  );
568  $confirm->addButton($this->lng->txt('grp_change_type'), 'updateGroupType');
569  $confirm->setCancel($this->lng->txt('cancel'), 'edit');
570 
571  $this->tpl->setContent($confirm->getHTML());
572  return true;
573  }
574  else
575  {
576  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
577  $this->ctrl->redirect($this,'edit');
578  return true;
579  }
580  }
581 
585  public function editGroupIconsObject($a_form = null)
586  {
587  global $tpl;
588 
589  $this->checkPermission('write');
590 
591  $this->setSubTabs("settings");
592  $this->tabs_gui->setTabActive('settings');
593  $this->tabs_gui->setSubTabActive('grp_icon_settings');
594 
595  if(!$a_form)
596  {
597  $a_form = $this->initGroupIconsForm();
598  }
599 
600  $tpl->setContent($a_form->getHTML());
601  }
602 
604  {
605  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
606  $form = new ilPropertyFormGUI();
607  $form->setFormAction($this->ctrl->getFormAction($this));
608 
609  $this->showCustomIconsEditing(1, $form);
610 
611  // $form->setTitle($this->lng->txt('edit_grouping'));
612  $form->addCommandButton('updateGroupIcons', $this->lng->txt('save'));
613 
614  return $form;
615  }
616 
623  public function updateGroupIconsObject()
624  {
625  $this->checkPermission('write');
626 
627  $form = $this->initGroupIconsForm();
628  if($form->checkInput())
629  {
630  //save custom icons
631  if ($this->ilias->getSetting("custom_icons"))
632  {
633  if($_POST["cont_big_icon_delete"])
634  {
635  $this->object->removeBigIcon();
636  }
637  if($_POST["cont_small_icon_delete"])
638  {
639  $this->object->removeSmallIcon();
640  }
641  if($_POST["cont_tiny_icon_delete"])
642  {
643  $this->object->removeTinyIcon();
644  }
645  $this->object->saveIcons($_FILES["cont_big_icon"]['tmp_name'],
646  $_FILES["cont_small_icon"]['tmp_name'], $_FILES["cont_tiny_icon"]['tmp_name']);
647  }
648 
649  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
650  $this->ctrl->redirect($this,"editGroupIcons");
651  }
652 
653  $form->setValuesByPost();
654  $this->editGroupIconsObject($form);
655  }
656 
660  public function editMapSettingsObject()
661  {
662  global $ilUser, $ilCtrl, $ilUser, $ilAccess;
663 
664  $this->setSubTabs("settings");
665  $this->tabs_gui->setTabActive('settings');
666  $this->tabs_gui->setSubTabActive('grp_map_settings');
667 
668  include_once('./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php');
670  !$ilAccess->checkAccess("write", "", $this->object->getRefId()))
671  {
672  return;
673  }
674 
675  $latitude = $this->object->getLatitude();
676  $longitude = $this->object->getLongitude();
677  $zoom = $this->object->getLocationZoom();
678 
679  // Get Default settings, when nothing is set
680  if ($latitude == 0 && $longitude == 0 && $zoom == 0)
681  {
683  $latitude = $def["latitude"];
684  $longitude = $def["longitude"];
685  $zoom = $def["zoom"];
686  }
687 
688 
689  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.png"), $this->lng->txt("personal_desktop"));
690  //$this->tpl->setVariable("HEADER", $this->lng->txt("personal_desktop"));
691 
692  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
693  $form = new ilPropertyFormGUI();
694  $form->setFormAction($ilCtrl->getFormAction($this));
695 
696  $form->setTitle($this->lng->txt("grp_map_settings"));
697 
698  // enable map
699  $public = new ilCheckboxInputGUI($this->lng->txt("grp_enable_map"),
700  "enable_map");
701  $public->setValue("1");
702  $public->setChecked($this->object->getEnableGroupMap());
703  $form->addItem($public);
704 
705  // map location
706  $loc_prop = new ilLocationInputGUI($this->lng->txt("grp_map_location"),
707  "location");
708  $loc_prop->setLatitude($latitude);
709  $loc_prop->setLongitude($longitude);
710  $loc_prop->setZoom($zoom);
711  $form->addItem($loc_prop);
712 
713  $form->addCommandButton("saveMapSettings", $this->lng->txt("save"));
714 
715  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
716  }
717 
718  public function saveMapSettingsObject()
719  {
720  global $ilCtrl, $ilUser;
721 
722  $this->object->setLatitude(ilUtil::stripSlashes($_POST["location"]["latitude"]));
723  $this->object->setLongitude(ilUtil::stripSlashes($_POST["location"]["longitude"]));
724  $this->object->setLocationZoom(ilUtil::stripSlashes($_POST["location"]["zoom"]));
725  $this->object->setEnableGroupMap(ilUtil::stripSlashes($_POST["enable_map"]));
726  $this->object->update();
727 
728  $ilCtrl->redirect($this, "editMapSettings");
729  }
730 
734  public function membersMapObject()
735  {
736  global $tpl;
737 
738  $this->setSubTabs('members');
739  $this->tabs_gui->setTabActive('members');
740 
741  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
742  if (!ilGoogleMapUtil::isActivated() || !$this->object->getEnableGroupMap())
743  {
744  return;
745  }
746 
747  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapGUI.php");
748  $map = new ilGoogleMapGUI();
749  $map->setMapId("group_map");
750  $map->setWidth("700px");
751  $map->setHeight("500px");
752  $map->setLatitude($this->object->getLatitude());
753  $map->setLongitude($this->object->getLongitude());
754  $map->setZoom($this->object->getLocationZoom());
755  $map->setEnableTypeControl(true);
756  $map->setEnableNavigationControl(true);
757  $map->setEnableCentralMarker(true);
758 
759 
760  $member_ids = $this->object->getGroupMemberIds();
761  $admin_ids = $this->object->getGroupAdminIds();
762 
763  // fetch all users data in one shot to improve performance
764  $members = $this->object->getGroupMemberData($member_ids);
765  foreach($member_ids as $user_id)
766  {
767  $map->addUserMarker($user_id);
768  }
769  $tpl->setContent($map->getHTML());
770  $tpl->setLeftContent($map->getUserListHTML());
771  }
772 
773 
780  public function editInfoObject()
781  {
782  global $ilErr,$ilAccess;
783 
784  $this->checkPermission('write');
785 
786  $this->setSubTabs('settings');
787  $this->tabs_gui->setTabActive('settings');
788  $this->tabs_gui->setSubTabActive('grp_info_settings');
789 
790  $this->initInfoEditor();
791  $this->tpl->setContent($this->form->getHTML());
792  }
793 
800  protected function initInfoEditor()
801  {
802  if(is_object($this->form))
803  {
804  return true;
805  }
806 
807  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
808  $this->form = new ilPropertyFormGUI();
809  $this->form->setFormAction($this->ctrl->getFormAction($this,'updateInfo'));
810  $this->form->setTitle($this->lng->txt('grp_general_informations'));
811  $this->form->addCommandButton('updateInfo',$this->lng->txt('save'));
812  $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
813 
814  $area = new ilTextAreaInputGUI($this->lng->txt('grp_information'),'important');
815  $area->setInfo($this->lng->txt('grp_information_info'));
816  $area->setValue($this->object->getInformation());
817  $area->setRows(8);
818  $area->setCols(80);
819  $this->form->addItem($area);
820  }
821 
828  public function updateInfoObject()
829  {
830  $this->checkPermission('write');
831 
832  $this->object->setInformation(ilUtil::stripSlashes($_POST['important']));
833  $this->object->update();
834 
835  ilUtil::sendSuccess($this->lng->txt("settings_saved"));
836  $this->editInfoObject();
837  return true;
838  }
839 
841 
846  public function membersGalleryObject()
847  {
848  global $rbacsystem, $ilAccess, $ilUser;
849 
850  $is_admin = (bool) $rbacsystem->checkAccess("write", $this->object->getRefId());
851 
852  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.crs_members_gallery.html','Modules/Course');
853 
854  $this->setSubTabs('members');
855  $this->tabs_gui->setTabActive('members');
856 
857  $member_ids = $this->object->getGroupMemberIds();
858  $admin_ids = $this->object->getGroupAdminIds();
859 
860  // fetch all users data in one shot to improve performance
861  $members = $this->object->getGroupMemberData($member_ids);
862 
863  // MEMBERS
864  if(count($members))
865  {
866  $ordered_members = array();
867 
868  foreach($members as $member)
869  {
870  // get user object
871  if(!($usr_obj = ilObjectFactory::getInstanceByObjId($member["id"],false)))
872  {
873  continue;
874  }
875 
876  if(!$usr_obj->getActive())
877  {
878  continue;
879  }
880 
881  // please do not use strtoupper on first/last name for output
882  // this messes up with some unicode characters, i guess
883  // depending on php verion, alex
884  array_push($ordered_members,array("id" => $member["id"],
885  "login" => $usr_obj->getLogin(),
886  "lastname" => $usr_obj->getLastName(),
887  "firstname" => $usr_obj->getFirstName(),
888  "sortlastname" => strtoupper($usr_obj->getLastName()).strtoupper($usr_obj->getFirstName()),
889  "usr_obj" => $usr_obj));
890  }
891 
892  $ordered_members=ilUtil::sortArray($ordered_members,"sortlastname","asc");
893 
894  foreach($ordered_members as $member) {
895 
896  $usr_obj = $member["usr_obj"];
897 
898  $public_profile = $usr_obj->getPref("public_profile");
899  if ($public_profile == "g")
900  {
901  $public_profile = "y";
902  }
903 
904  // SET LINK TARGET FOR USER PROFILE
905  $this->ctrl->setParameterByClass("ilpublicuserprofilegui", "user", $member["id"]);
906  $profile_target = $this->ctrl->getLinkTargetByClass("ilpublicuserprofilegui","getHTML");
907 
908  // GET USER IMAGE
909  $file = $usr_obj->getPersonalPicturePath("xsmall");
910 
911  switch(in_array($member["id"],$admin_ids))
912  {
913  //admins
914  case 1:
915  if ($public_profile == "y")
916  {
917  $this->tpl->setCurrentBlock("member_linked");
918  $this->tpl->setVariable("LINK_PROFILE", $profile_target);
919  $this->tpl->setVariable("SRC_USR_IMAGE", $file);
920  $this->tpl->parseCurrentBlock();
921  }
922  else
923  {
924  $this->tpl->setCurrentBlock("member_not_linked");
925  $this->tpl->setVariable("SRC_USR_IMAGE", $file);
926  $this->tpl->parseCurrentBlock();
927  }
928  $this->tpl->setCurrentBlock("member");
929  break;
930 
931  case 0:
932  if ($public_profile == "y")
933  {
934  $this->tpl->setCurrentBlock("member_linked");
935  $this->tpl->setVariable("LINK_PROFILE", $profile_target);
936  $this->tpl->setVariable("SRC_USR_IMAGE", $file);
937  $this->tpl->parseCurrentBlock();
938  }
939  else
940  {
941  $this->tpl->setCurrentBlock("member_not_linked");
942  $this->tpl->setVariable("SRC_USR_IMAGE", $file);
943  $this->tpl->parseCurrentBlock();
944  }
945  $this->tpl->setCurrentBlock("member");
946  break;
947  }
948 
949  if (in_array($member["id"],$admin_ids)) {
950  $this->tpl->setVariable("MEMBER_CLASS", "il_Admin");
951  }
952  else {
953  $this->tpl->setVariable("MEMBER_CLASS", "il_Member");
954  }
955 
956 
957  // do not show name, if public profile is not activated
958  if ($public_profile == "y")
959  {
960  $this->tpl->setVariable("FIRSTNAME", $member["firstname"]);
961  $this->tpl->setVariable("LASTNAME", $member["lastname"]);
962  }
963  $this->tpl->setVariable("LOGIN", $usr_obj->getLogin());
964  $this->tpl->parseCurrentBlock();
965  }
966  $this->tpl->setCurrentBlock("members");
967  //$this->tpl->setVariable("MEMBERS_TABLE_HEADER",$this->lng->txt('crs_members_title'));
968  $this->tpl->parseCurrentBlock();
969  }
970 
971  $this->tpl->setVariable("TITLE",$this->lng->txt('crs_members_print_title'));
972  $this->tpl->setVariable("CSS_PATH",ilUtil::getStyleSheetLocation());
973  }
974 
975 
976  public function readMemberData($ids,$role = 'admin')
977  {
978  include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
979  $privacy = ilPrivacySettings::_getInstance();
980 
981  if($this->show_tracking)
982  {
983  include_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
984  $completed = ilLPStatusWrapper::_lookupCompletedForObject($this->object->getId());
985  $in_progress = ilLPStatusWrapper::_lookupInProgressForObject($this->object->getId());
986  $failed = ilLPStatusWrapper::_lookupFailedForObject($this->object->getId());
987  }
988 
989  if($privacy->enabledGroupAccessTimes())
990  {
991  include_once('./Services/Tracking/classes/class.ilLearningProgress.php');
992  $progress = ilLearningProgress::_lookupProgressByObjId($this->object->getId());
993  }
994 
995  foreach($ids as $usr_id)
996  {
997  $name = ilObjUser::_lookupName($usr_id);
998  $tmp_data['firstname'] = $name['firstname'];
999  $tmp_data['lastname'] = $name['lastname'];
1000  $tmp_data['login'] = ilObjUser::_lookupLogin($usr_id);
1001  $tmp_data['notification'] = $this->object->members_obj->isNotificationEnabled($usr_id) ? 1 : 0;
1002  $tmp_data['usr_id'] = $usr_id;
1003  $tmp_data['login'] = ilObjUser::_lookupLogin($usr_id);
1004 
1005  if($this->show_tracking)
1006  {
1007  if(in_array($usr_id,$completed))
1008  {
1009  $tmp_data['progress'] = LP_STATUS_COMPLETED;
1010  }
1011  elseif(in_array($usr_id,$in_progress))
1012  {
1013  $tmp_data['progress'] = LP_STATUS_IN_PROGRESS;
1014  }
1015  elseif(in_array($usr_id,$failed))
1016  {
1017  $tmp_data['progress'] = LP_STATUS_FAILED;
1018  }
1019  else
1020  {
1021  $tmp_data['progress'] = LP_STATUS_NOT_ATTEMPTED;
1022  }
1023  }
1024 
1025  if($privacy->enabledGroupAccessTimes())
1026  {
1027  if(isset($progress[$usr_id]['ts']) and $progress[$usr_id]['ts'])
1028  {
1029  $tmp_data['access_time'] = ilDatePresentation::formatDate(
1030  $tmp_date = new ilDateTime($progress[$usr_id]['ts'],IL_CAL_UNIX));
1031  $tmp_data['access_time_unix'] = $tmp_date->get(IL_CAL_UNIX);
1032  }
1033  else
1034  {
1035  $tmp_data['access_time'] = $this->lng->txt('no_date');
1036  $tmp_data['access_time_unix'] = 0;
1037  }
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  include_once('./Services/Tracking/classes/class.ilLPObjSettings.php');
1062  $this->show_tracking = (ilObjUserTracking::_enabledLearningProgress() and
1064  ilLPObjSettings::_lookupMode($this->object->getId()) != LP_MODE_DEACTIVATED);
1065 
1066 
1067  $part = ilGroupParticipants::_getInstanceByObjId($this->object->getId());
1068 
1069  $this->setSubTabs('members');
1070  $this->tabs_gui->setTabActive('members');
1071  $this->tabs_gui->setSubTabActive('grp_edit_members');
1072 
1073  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.grp_edit_members.html','Modules/Group');
1074  $this->tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
1075 
1076  // add members
1077  include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
1079  $this,
1080  $ilToolbar,
1081  array(
1082  'auto_complete_name' => $lng->txt('user'),
1083  'user_type' => array(
1084  ilObjGroup::GRP_MEMBER => $lng->txt("member"),
1085  ilObjGroup::GRP_ADMIN => $lng->txt("administrator")
1086  ),
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->setShowHidePrefs();
1105 
1106 
1107  // Waiting list table
1108  include_once('./Modules/Group/classes/class.ilGroupWaitingList.php');
1109  $waiting_list = new ilGroupWaitingList($this->object->getId());
1110  if(count($wait = $waiting_list->getAllUsers()))
1111  {
1112  include_once('./Services/Membership/classes/class.ilWaitingListTableGUI.php');
1113  if($ilUser->getPref('grp_wait_hide'))
1114  {
1115  $table_gui = new ilWaitingListTableGUI($this,$waiting_list,false);
1116  $this->ctrl->setParameter($this,'wait_hide',0);
1117  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1118  $this->lng->txt('show'),
1119  '',
1120  ilUtil::getImagePath('edit_add.png'));
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  '',
1130  ilUtil::getImagePath('edit_remove.png'));
1131  $this->ctrl->clearParameters($this);
1132  }
1133  $table_gui->setUsers($wait);
1134  $table_gui->setTitle($this->lng->txt('grp_header_waiting_list'),'icon_usr.png',$this->lng->txt('group_new_registrations'));
1135  $this->tpl->setVariable('TABLE_SUB',$table_gui->getHTML());
1136  }
1137 
1138 
1139  // Subscriber table
1140  if($part->getSubscribers())
1141  {
1142  include_once('./Services/Membership/classes/class.ilSubscriberTableGUI.php');
1143  if($ilUser->getPref('grp_subscriber_hide'))
1144  {
1145  $table_gui = new ilSubscriberTableGUI($this,false);
1146  $this->ctrl->setParameter($this,'subscriber_hide',0);
1147  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1148  $this->lng->txt('show'),
1149  '',
1150  ilUtil::getImagePath('edit_add.png'));
1151  $this->ctrl->clearParameters($this);
1152  }
1153  else
1154  {
1155  $table_gui = new ilSubscriberTableGUI($this,true);
1156  $this->ctrl->setParameter($this,'subscriber_hide',1);
1157  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1158  $this->lng->txt('hide'),
1159  '',
1160  ilUtil::getImagePath('edit_remove.png'));
1161  $this->ctrl->clearParameters($this);
1162  }
1163  $table_gui->readSubscriberData();
1164  $table_gui->setTitle($this->lng->txt('group_new_registrations'),'icon_usr.png',$this->lng->txt('group_new_registrations'));
1165  $this->tpl->setVariable('TABLE_SUB',$table_gui->getHTML());
1166  }
1167 
1168  if(count($part->getAdmins()))
1169  {
1170  if($ilUser->getPref('grp_admin_hide'))
1171  {
1172  $table_gui = new ilGroupParticipantsTableGUI($this,'admin',false,false);
1173  $this->ctrl->setParameter($this,'admin_hide',0);
1174  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1175  $this->lng->txt('show'),
1176  '',
1177  ilUtil::getImagePath('edit_add.png'));
1178  $this->ctrl->clearParameters($this);
1179  }
1180  else
1181  {
1182  $table_gui = new ilGroupParticipantsTableGUI($this,'admin',true,false);
1183  $this->ctrl->setParameter($this,'admin_hide',1);
1184  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1185  $this->lng->txt('hide'),
1186  '',
1187  ilUtil::getImagePath('edit_remove.png'));
1188  $this->ctrl->clearParameters($this);
1189  }
1190  $table_gui->setTitle($this->lng->txt('grp_admins'),'icon_usr.png',$this->lng->txt('grp_admins'));
1191  $table_gui->parse($this->readMemberData($part->getAdmins()));
1192  $this->tpl->setVariable('ADMINS',$table_gui->getHTML());
1193  }
1194 
1195  if($GLOBALS['rbacreview']->getNumberOfAssignedUsers(array($this->object->getDefaultMemberRole())))
1196  {
1197  if($ilUser->getPref('grp_member_hide'))
1198  {
1199  $table_gui = new ilGroupParticipantsTableGUI($this,'member',false,$this->show_tracking,$this->object->getDEfaultMemberRole());
1200  $this->ctrl->setParameter($this,'member_hide',0);
1201  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1202  $this->lng->txt('show'),
1203  '',
1204  ilUtil::getImagePath('edit_add.png'));
1205  $this->ctrl->clearParameters($this);
1206  }
1207  else
1208  {
1209  $table_gui = new ilGroupParticipantsTableGUI($this,'member',true,$this->show_tracking,$this->object->getDefaultMemberRole());
1210  $this->ctrl->setParameter($this,'member_hide',1);
1211  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1212  $this->lng->txt('hide'),
1213  '',
1214  ilUtil::getImagePath('edit_remove.png'));
1215  $this->ctrl->clearParameters($this);
1216  }
1217 
1218  $table_gui->setTitle($this->lng->txt('grp_members'),'icon_usr.png',$this->lng->txt('grp_members'));
1219  $table_gui->parse($this->readMemberData($GLOBALS['rbacreview']->assignedUsers($this->object->getDefaultMemberRole())));
1220  $this->tpl->setCurrentBlock('member_block');
1221  $this->tpl->setVariable('MEMBERS',$table_gui->getHTML());
1222  $this->tpl->parseCurrentBlock();
1223  }
1224 
1225  foreach(ilGroupParticipants::getMemberRoles($this->object->getRefId()) as $role_id)
1226  {
1227  // Do not show table if no user is assigned
1228  if(!($GLOBALS['rbacreview']->getNumberOfAssignedUsers(array($role_id))))
1229  {
1230  continue;
1231  }
1232  if($ilUser->getPref('grp_role_hide'.$role_id))
1233  {
1234  $table_gui = new ilGroupParticipantsTableGUI($this,'role',false,$this->show_tracking,$role_id);
1235  $this->ctrl->setParameter($this,'role_hide_'.$role_id,0);
1236  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1237  $this->lng->txt('show'),
1238  '',
1239  ilUtil::getImagePath('edit_add.png'));
1240  $this->ctrl->clearParameters($this);
1241  }
1242  else
1243  {
1244  $table_gui = new ilGroupParticipantsTableGUI($this,'role',true,$this->show_tracking,$role_id);
1245  $this->ctrl->setParameter($this,'role_hide_'.$role_id,1);
1246  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1247  $this->lng->txt('hide'),
1248  '',
1249  ilUtil::getImagePath('edit_remove.png'));
1250  $this->ctrl->clearParameters($this);
1251  }
1252 
1253  $table_gui->setTitle(ilObject::_lookupTitle($role_id),'icon_usr.gif',ilObject::_lookupTitle($role_id));
1254  $table_gui->parse($this->readMemberData($GLOBALS['rbacreview']->assignedUsers($role_id)));
1255  $this->tpl->setCurrentBlock('member_block');
1256  $this->tpl->setVariable('MEMBERS',$table_gui->getHTML());
1257  $this->tpl->parseCurrentBlock();
1258  }
1259 
1260  $this->tpl->setVariable('TXT_SELECTED_USER',$this->lng->txt('grp_selected_users'));
1261  $this->tpl->setVariable('BTN_FOOTER_EDIT',$this->lng->txt('edit'));
1262  $this->tpl->setVariable('BTN_FOOTER_VAL',$this->lng->txt('remove'));
1263  $this->tpl->setVariable('BTN_FOOTER_MAIL',$this->lng->txt('grp_mem_send_mail'));
1264  $this->tpl->setVariable('ARROW_DOWN',ilUtil::getImagePath('arrow_downright.png'));
1265 
1266  }
1267 
1274  public function assignSubscribersObject()
1275  {
1276  global $lng, $ilIliasIniFile,$ilUser;
1277 
1278  $this->checkPermission('write');
1279 
1280  if(!count($_POST['subscribers']))
1281  {
1282  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
1283  $this->membersObject();
1284  return false;
1285  }
1286 
1287  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1288  foreach($_POST['subscribers'] as $usr_id)
1289  {
1290  $this->object->members_obj->sendNotification(
1292  $usr_id
1293  );
1294 
1295  $this->object->members_obj->add($usr_id,IL_GRP_MEMBER);
1296  $this->object->members_obj->deleteSubscriber($usr_id);
1297 
1298  include_once('./Modules/Forum/classes/class.ilForumNotification.php');
1299  ilForumNotification::checkForumsExistsInsert($this->object->getRefId(), $usr_id);
1300  }
1301  ilUtil::sendSuccess($this->lng->txt("grp_msg_applicants_assigned"),true);
1302  $this->ctrl->redirect($this,'members');
1303  return true;
1304  }
1305 
1312  public function refuseSubscribersObject()
1313  {
1314  global $lng;
1315 
1316  $this->checkPermission('write');
1317 
1318  if(!count($_POST['subscribers']))
1319  {
1320  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
1321  $this->membersObject();
1322  return false;
1323  }
1324 
1325  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1326  foreach($_POST['subscribers'] as $usr_id)
1327  {
1328  $this->object->members_obj->sendNotification(
1330  $usr_id
1331  );
1332  $this->object->members_obj->deleteSubscriber($usr_id);
1333  }
1334  ilUtil::sendSuccess($this->lng->txt("grp_msg_applicants_removed"));
1335  $this->membersObject();
1336  return true;
1337 
1338  }
1339 
1348  {
1349  $this->checkPermission('write');
1350 
1351  if(!count($_POST["waiting"]))
1352  {
1353  ilUtil::sendFailure($this->lng->txt("no_checkbox"));
1354  $this->membersObject();
1355  return false;
1356  }
1357 
1358  include_once('./Modules/Group/classes/class.ilGroupWaitingList.php');
1359  $waiting_list = new ilGroupWaitingList($this->object->getId());
1360 
1361  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1362 
1363  $added_users = 0;
1364  foreach($_POST["waiting"] as $user_id)
1365  {
1366  if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user_id,false))
1367  {
1368  continue;
1369  }
1370  if($this->object->members_obj->isAssigned($user_id))
1371  {
1372  continue;
1373  }
1374  $this->object->members_obj->add($user_id,IL_GRP_MEMBER);
1375  $this->object->members_obj->sendNotification(
1377  $user_id
1378  );
1379  $waiting_list->removeFromList($user_id);
1380 
1381  include_once('./Modules/Forum/classes/class.ilForumNotification.php');
1382  ilForumNotification::checkForumsExistsInsert($this->object->getRefId(), $user_id);
1383 
1384  ++$added_users;
1385  }
1386  if($added_users)
1387  {
1388  ilUtil::sendSuccess($this->lng->txt("grp_users_added"));
1389  $this->membersObject();
1390 
1391  return true;
1392  }
1393  else
1394  {
1395  ilUtil::sendFailure($this->lng->txt("grp_users_already_assigned"));
1396  $this->searchObject();
1397 
1398  return false;
1399  }
1400  }
1401 
1408  public function refuseFromListObject()
1409  {
1410  $this->checkPermission('write');
1411 
1412  if(!count($_POST['waiting']))
1413  {
1414  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
1415  $this->membersObject();
1416  return false;
1417  }
1418 
1419  include_once('./Modules/Group/classes/class.ilGroupWaitingList.php');
1420  $waiting_list = new ilGroupWaitingList($this->object->getId());
1421 
1422  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1423  foreach($_POST["waiting"] as $user_id)
1424  {
1425  $waiting_list->removeFromList($user_id);
1426  $this->object->members_obj->sendNotification(
1428  $user_id
1429  );
1430  }
1431 
1432  ilUtil::sendSuccess($this->lng->txt('grp_users_removed_from_list'));
1433  $this->membersObject();
1434  return true;
1435  }
1436 
1442  public function confirmDeleteMembersObject()
1443  {
1444  $this->checkPermission('write');
1445 
1446  $this->setSubTabs('members');
1447  $this->tabs_gui->setTabActive('members');
1448  $this->tabs_gui->setSubTabActive('grp_edit_members');
1449 
1450  $participants_to_delete = (array) array_unique(array_merge((array) $_POST['admins'],(array) $_POST['members'], (array) $_POST['roles']));
1451 
1452  if(!count($participants_to_delete))
1453  {
1454  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
1455  $this->membersObject();
1456  return false;
1457  }
1458 
1459  // Check last admin
1460  $admins = (array) ilGroupParticipants::_getInstanceByObjId($this->object->getId())->getAdmins();
1461 
1462  $admins_after = (array) array_diff($admins, $participants_to_delete);
1463  if(!count($admins_after) and count($admins))
1464  {
1465  ilUtil::sendFailure($this->lng->txt('grp_err_administrator_required'));
1466  $this->membersObject();
1467  return false;
1468  }
1469 
1470  include_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
1471  $confirm = new ilConfirmationGUI();
1472  $confirm->setFormAction($this->ctrl->getFormAction($this,'deleteMembers'));
1473  $confirm->setHeaderText($this->lng->txt('grp_dismiss_member'));
1474  $confirm->setConfirm($this->lng->txt('confirm'),'deleteMembers');
1475  $confirm->setCancel($this->lng->txt('cancel'),'members');
1476 
1477  foreach($this->readMemberData(array_merge((array) $_POST['admins'],(array) $_POST['members'], (array) $_POST['roles'])) as $participants)
1478  {
1479  $confirm->addItem('participants[]',
1480  $participants['usr_id'],
1481  $participants['lastname'].', '.$participants['firstname'].' ['.$participants['login'].']',
1482  ilUtil::getImagePath('icon_usr.png'));
1483  }
1484 
1485  $this->tpl->setContent($confirm->getHTML());
1486  }
1487 
1495  public function deleteMembersObject()
1496  {
1497  $this->checkPermission('write');
1498 
1499  if(!count($_POST['participants']))
1500  {
1501  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
1502  $this->membersObject();
1503  return true;
1504  }
1505 
1506  $this->object->members_obj->deleteParticipants($_POST['participants']);
1507 
1508  // Send notification
1509  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1510  include_once './Modules/Forum/classes/class.ilForumNotification.php';
1511  foreach($_POST['participants'] as $part)
1512  {
1513  $this->object->members_obj->sendNotification(
1515  $part
1516  );
1517  ilForumNotification::checkForumsExistsDelete($this->object->getRefId(), $part);
1518  }
1519 
1520 
1521  ilUtil::sendSuccess($this->lng->txt("grp_msg_membership_annulled"));
1522  $this->membersObject();
1523  return true;
1524  }
1525 
1534  {
1535  if(isset($_GET['member_id']))
1536  {
1537  $_POST['participants'] = array($_GET['member_id']);
1538  }
1539  else
1540  {
1541  $_POST['participants'] = array_unique(array_merge((array) $_POST['admins'],
1542  (array) $_POST['members'],
1543  (array) $_POST['roles'],
1544  (array) $_POST['waiting'],
1545  (array) $_POST['subscribers']));
1546  }
1547  if (!count($_POST['participants']))
1548  {
1549  ilUtil::sendFailure($this->lng->txt("no_checkbox"));
1550  $this->membersObject();
1551  return false;
1552  }
1553  foreach($_POST['participants'] as $usr_id)
1554  {
1555  $rcps[] = ilObjUser::_lookupLogin($usr_id);
1556  }
1557 
1558  require_once 'Services/Mail/classes/class.ilMailFormCall.php';
1560  $this,
1561  'members',
1562  array(),
1563  array('type' => 'new', 'rcp_to' => implode(',',$rcps),'sig' => $this->createMailSignature())));
1564  return true;
1565  }
1566 
1573  public function setShowHidePrefs()
1574  {
1575  global $ilUser;
1576 
1577  if(isset($_GET['admin_hide']))
1578  {
1579  $ilUser->writePref('grp_admin_hide',(int) $_GET['admin_hide']);
1580  }
1581  if(isset($_GET['member_hide']))
1582  {
1583  $ilUser->writePref('grp_member_hide',(int) $_GET['member_hide']);
1584  }
1585  if(isset($_GET['subscriber_hide']))
1586  {
1587  $ilUser->writePref('grp_subscriber_hide',(int) $_GET['subscriber_hide']);
1588  }
1589  if(isset($_GET['wait_hide']))
1590  {
1591  $ilUser->writePref('grp_wait_hide',(int) $_GET['wait_hide']);
1592  }
1593  }
1594 
1600  public function editMemberObject()
1601  {
1602  $_POST['members'] = array((int) $_GET['member_id']);
1603  $this->editMembersObject();
1604  }
1605 
1612  public function editMembersObject()
1613  {
1614  $this->checkPermission('write');
1615 
1616  $post_participants = array_unique(array_merge((array) $_POST['admins'],(array) $_POST['members'], (array) $_POST['roles']));
1617  $real_participants = ilGroupParticipants::_getInstanceByObjId($this->object->getId())->getParticipants();
1618  $participants = array_intersect((array) $post_participants, (array) $real_participants);
1619 
1620  if(!count($participants))
1621  {
1622  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
1623  $this->membersObject();
1624  return false;
1625  }
1626 
1627  $this->setSubTabs('members');
1628  $this->tabs_gui->setTabActive('members');
1629  $this->tabs_gui->setSubTabActive('grp_edit_members');
1630 
1631  include_once('./Modules/Group/classes/class.ilGroupEditParticipantsTableGUI.php');
1632  $table_gui = new ilGroupEditParticipantsTableGUI($this);
1633  $table_gui->setTitle($this->lng->txt('grp_mem_change_status'),'icon_usr.png',$this->lng->txt('grp_mem_change_status'));
1634  $table_gui->setData($this->readMemberData($participants));
1635 
1636  $this->tpl->setContent($table_gui->getHTML());
1637  return true;
1638  }
1639 
1647  public function updateMembersObject()
1648  {
1649  $this->checkPermission('write');
1650 
1651  if(!count($_POST['participants']))
1652  {
1653  ilUtil::sendFailure($this->lng->txt('no_checkbox'));
1654  $this->membersObject();
1655  return false;
1656  }
1657 
1658  // Check minimum one admin
1659  $has_admin = false;
1660  $admin_role = $this->object->getDefaultAdminRole();
1661  foreach(ilGroupParticipants::_getInstanceByObjId($this->object->getId())->getAdmins() as $admin_id)
1662  {
1663  if(!isset($_POST['roles'][$admin_id]))
1664  {
1665  $has_admin = true;
1666  break;
1667  }
1668  if(in_array($admin_role,$_POST['roles'][$admin_id]))
1669  {
1670  $has_admin = true;
1671  break;
1672  }
1673  }
1674 
1675  if(!$has_admin and ilGroupParticipants::_getInstanceByObjId($this->object->getId())->getCountAdmins())
1676  {
1677  ilUtil::sendFailure($this->lng->txt('grp_min_one_admin'));
1678  $_POST['members'] = $_POST['participants'];
1679  $this->editMembersObject();
1680  return false;
1681  }
1682 
1683  $admin_role = $this->object->getDefaultAdminRole();
1684 
1685  $notifications = $_POST['notification'] ? $_POST['notification'] : array();
1686  foreach($_POST['participants'] as $usr_id)
1687  {
1688  // Check if a status changed mail is required
1689  $notification = false;
1690  if($this->object->members_obj->isAdmin($usr_id) and !in_array($admin_role,(array) $_POST['roles'][$usr_id]))
1691  {
1692  $notification = true;
1693  }
1694  if(!$this->object->members_obj->isAdmin($usr_id) and in_array($admin_role,(array) $_POST['roles'][$usr_id]))
1695  {
1696  $notification = true;
1697  }
1698 
1699  // TODO: check no role, owner
1700  $this->object->members_obj->updateRoleAssignments($usr_id,(array) $_POST['roles'][$usr_id]);
1701 
1702  // Disable notification for all of them
1703  $this->object->members_obj->updateNotification($usr_id,0);
1704 
1705  if($this->object->members_obj->isAdmin($usr_id) and in_array($usr_id,$notifications))
1706  {
1707  $this->object->members_obj->updateNotification($usr_id,1);
1708  }
1709 
1710  if($notification)
1711  {
1712  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1713  $this->object->members_obj->sendNotification(
1715  $usr_id
1716  );
1717  }
1718  }
1719  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"));
1720  $this->membersObject();
1721  return true;
1722  }
1723 
1731  public function updateStatusObject()
1732  {
1733  $this->checkPermission('write');
1734 
1735  $notification = $_POST['notification'] ? $_POST['notification'] : array();
1736  foreach($this->object->members_obj->getAdmins() as $admin_id)
1737  {
1738  $this->object->members_obj->updateNotification($admin_id,(int) in_array($admin_id,$notification));
1739  }
1740  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
1741  $this->membersObject();
1742  }
1743 
1744 
1745 
1746 
1747 
1752  function canceledObject()
1753  {
1754  $return_location = $_GET["cmd_return_location"];
1755  if (strcmp($return_location, "") == 0)
1756  {
1757  $return_location = "";
1758  }
1759 
1760  $this->ctrl->redirect($this, $return_location);
1761  }
1762 
1763 
1764 
1769  public function leaveObject()
1770  {
1771  global $ilUser;
1772 
1773  $this->checkPermission('leave');
1774 
1775  $part = ilGroupParticipants::_getInstanceByObjId($this->object->getId());
1776  if($part->isLastAdmin($ilUser->getId()))
1777  {
1778  ilUtil::sendFailure($this->lng->txt('grp_err_administrator_required'));
1779  $this->viewObject();
1780  return false;
1781  }
1782 
1783  $this->tabs_gui->setTabActive('grp_btn_unsubscribe');
1784 
1785  include_once "Services/Utilities/classes/class.ilConfirmationGUI.php";
1786  $cgui = new ilConfirmationGUI();
1787  $cgui->setHeaderText($this->lng->txt('grp_dismiss_myself'));
1788  $cgui->setFormAction($this->ctrl->getFormAction($this));
1789  $cgui->setCancel($this->lng->txt("cancel"), "cancel");
1790  $cgui->setConfirm($this->lng->txt("grp_btn_unsubscribe"), "unsubscribe");
1791  $this->tpl->setContent($cgui->getHTML());
1792  }
1793 
1800  public function unsubscribeObject()
1801  {
1802  global $ilUser,$tree, $ilCtrl;
1803 
1804  $this->checkPermission('leave');
1805 
1806  $this->object->members_obj->delete($ilUser->getId());
1807 
1808  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1809  $this->object->members_obj->sendNotification(
1811  $ilUser->getId()
1812  );
1813  $this->object->members_obj->sendNotification(
1815  $ilUser->getId()
1816  );
1817 
1818  include_once './Modules/Forum/classes/class.ilForumNotification.php';
1819  ilForumNotification::checkForumsExistsDelete($this->object->getRefId(), $ilUser->getId());
1820 
1821  ilUtil::sendSuccess($this->lng->txt('grp_msg_membership_annulled'),true);
1822  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id",
1823  $tree->getParentId($this->object->getRefId()));
1824  $ilCtrl->redirectByClass("ilrepositorygui", "");
1825  }
1826 
1827 
1833  {
1834  $user_ids = $_POST["id"];
1835 
1836  if (empty($user_ids[0]))
1837  {
1838  // TODO: jumps back to grp content. go back to last search result
1839  $this->ilErr->raiseError($this->lng->txt("no_checkbox"),$this->ilErr->MESSAGE);
1840  }
1841 
1842  foreach ($user_ids as $new_member)
1843  {
1844  if (!$this->object->addMember($new_member,$this->object->getDefaultMemberRole()))
1845  {
1846  $this->ilErr->raiseError("An Error occured while assigning user to group !",$this->ilErr->MESSAGE);
1847  }
1848  }
1849 
1850  unset($_SESSION["saved_post"]);
1851 
1852  ilUtil::sendSuccess($this->lng->txt("grp_msg_member_assigned"),true);
1853  $this->ctrl->redirect($this,'members');
1854  }
1855 
1860  function addUserObject($user_ids, $a_type)
1861  {
1862  include_once 'Services/Mail/classes/class.ilMail.php';
1863  $mail = new ilMail($_SESSION["AccountId"]);
1864 
1865  if (empty($user_ids[0]))
1866  {
1867  $GLOBALS['lng']->loadLanguageModule('search');
1868  ilUtil::sendFailure($this->lng->txt('search_err_user_not_exist'),true);
1869  return false;
1870  }
1871 
1872  foreach ($user_ids as $new_member)
1873  {
1874  switch($a_type)
1875  {
1877  if (!$this->object->addMember($new_member,$this->object->getDefaultMemberRole()))
1878  {
1879  $this->ilErr->raiseError("An Error occured while assigning user to group !",$this->ilErr->MESSAGE);
1880  }
1881  break;
1882 
1883  case ilObjGroup::GRP_ADMIN:
1884  if (!$this->object->addMember($new_member,$this->object->getDefaultAdminRole()))
1885  {
1886  $this->ilErr->raiseError("An Error occured while assigning user to group !",$this->ilErr->MESSAGE);
1887  }
1888  break;
1889  }
1890 
1891  ilObjUser::_addDesktopItem($new_member, $this->object->getRefId(), 'grp');
1892 
1893  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
1894  $this->object->members_obj->sendNotification(
1896  $new_member
1897  );
1898 
1899  include_once './Modules/Forum/classes/class.ilForumNotification.php';
1900  ilForumNotification::checkForumsExistsInsert($this->object->getRefId(), $new_member);
1901  }
1902 
1903  unset($_SESSION["saved_post"]);
1904  unset($_SESSION['grp_usr_search_result']);
1905 
1906  ilUtil::sendSuccess($this->lng->txt("grp_msg_member_assigned"),true);
1907  $this->ctrl->redirect($this,'members');
1908  }
1909 
1914  {
1915  global $rbacreview, $ilObjDataCache, $ilias;
1916  include_once('./Services/AccessControl/classes/class.ilObjRole.php');
1917 
1918  $this->lng->loadLanguageModule('mail');
1919  if(!isset($_GET['returned_from_mail']))
1920  {
1921  ilUtil::sendInfo($this->lng->txt('mail_select_recipients'));
1922  }
1923 
1924  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.mail_members.html','Services/Contact');
1925 
1926 
1927  $this->setSubTabs('members');
1928  $this->tabs_gui->setTabActive('members');
1929 
1930  require_once 'Services/Mail/classes/class.ilMailFormCall.php';
1931  $this->tpl->setVariable("MAILACTION", ilMailFormCall::getLinkTarget($this, 'mailMembers', array(), array('type' => 'role','sig' => $this->createMailSignature())));
1932  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.png'));
1933  $this->tpl->setVariable("TXT_MARKED_ENTRIES",$this->lng->txt('marked_entries'));
1934  $this->tpl->setVariable("OK",$this->lng->txt('next'));
1935 
1936  // Get role mailbox addresses
1937  $role_folder = $rbacreview->getRoleFolderOfObject($this->object->getRefId());
1938  $role_ids = $rbacreview->getRolesOfRoleFolder($role_folder['ref_id'], false);
1939  $role_addrs = array();
1940 
1941  // Sort by relevance
1942  $sorted_role_ids = array();
1943  $counter = 2;
1944  foreach($role_ids as $role_id)
1945  {
1946  switch(substr(ilObject::_lookupTitle($role_id),0,8))
1947  {
1948  case 'il_grp_a':
1949  $sorted_role_ids[1] = $role_id;
1950  break;
1951 
1952  case 'il_grp_m':
1953  $sorted_role_ids[0] = $role_id;
1954  break;
1955 
1956  default:
1957  $sorted_role_ids[$counter++] = $role_id;
1958  break;
1959  }
1960  }
1961  ksort($sorted_role_ids,SORT_NUMERIC);
1962  foreach ((array) $sorted_role_ids as $role_id)
1963  {
1964  $this->tpl->setCurrentBlock("mailbox_row");
1965  $role_addr = $rbacreview->getRoleMailboxAddress($role_id);
1966 
1967  // check if role title is unique. if not force use pear mail for roles
1968  $ids_for_role_title = ilObject::_getIdsForTitle(ilObject::_lookupTitle($role_id), 'role');
1969  if(count($ids_for_role_title) >= 2)
1970  {
1971  $ilias->setSetting('pear_mail_enable', 1);
1972  }
1973 
1974  $this->tpl->setVariable("CHECK_MAILBOX",ilUtil::formCheckbox(1,'roles[]',
1975  htmlspecialchars($role_addr)
1976  ));
1977 
1978  if (ilMail::_usePearMail())
1979  {
1980  // if pear mail is enabled, mailbox addresses are already localized in the language of the user
1981  $this->tpl->setVariable("MAILBOX",$role_addr);
1982  }
1983  else
1984  {
1985  // if pear mail is not enabled, we need to localize mailbox addresses in the language of the user
1986  $this->tpl->setVariable("MAILBOX",ilObjRole::_getTranslation($ilObjDataCache->lookupTitle($role_id)) . " (".$role_addr.")");
1987  }
1988  $this->tpl->parseCurrentBlock();
1989  }
1990  }
1991 
1997  {
1998  $user_ids = $_POST["user_id"];
1999 
2000  if (empty($user_ids[0]))
2001  {
2002  $this->ilErr->raiseError($this->lng->txt("no_checkbox"),$this->ilErr->MESSAGE);
2003  }
2004  include_once 'Services/Mail/classes/class.ilMail.php';
2005  $mail = new ilMail($_SESSION["AccountId"]);
2006 
2007  foreach ($user_ids as $new_member)
2008  {
2009  $user =& $this->ilias->obj_factory->getInstanceByObjId($new_member);
2010 
2011  $this->object->deleteApplicationListEntry($new_member);
2012  $mail->sendMail($user->getLogin(),"","","Membership application refused: Group ".$this->object->getTitle(),"Your application has been refused.",array(),array('system'));
2013  }
2014 
2015  ilUtil::sendSuccess($this->lng->txt("grp_msg_applicants_removed"),true);
2016  $this->ctrl->redirect($this,'members');
2017  }
2018 
2019  // get tabs
2020  function getTabs(&$tabs_gui)
2021  {
2022  global $rbacsystem, $ilUser, $ilAccess, $lng, $ilHelp;
2023 
2024  $ilHelp->setScreenIdComponent("grp");
2025 
2026  if ($rbacsystem->checkAccess('read',$this->ref_id))
2027  {
2028  $tabs_gui->addTab("view_content", $lng->txt("content"),
2029  $this->ctrl->getLinkTarget($this, ""));
2030  }
2031  if ($rbacsystem->checkAccess('visible',$this->ref_id))
2032  {
2033  $tabs_gui->addTarget("info_short",
2034  $this->ctrl->getLinkTargetByClass(
2035  array("ilobjgroupgui", "ilinfoscreengui"), "showSummary"),
2036  "infoScreen",
2037  "", "",false);
2038  }
2039 
2040 
2041  if ($ilAccess->checkAccess('write','',$this->object->getRefId()))
2042  {
2043  $tabs_gui->addTarget("settings",
2044  $this->ctrl->getLinkTarget($this, "edit"), array("edit", "editMapSettings"), get_class($this),
2045  "");
2046  }
2047 
2048 
2049  $is_participant = ilGroupParticipants::_isParticipant($this->ref_id, $ilUser->getId());
2050 
2051  // Members
2052  $mem_cmd = $ilAccess->checkAccess('write','',$this->ref_id) ? "members" : "membersGallery";
2053  if($mem_cmd != "membersGallery" || $is_participant)
2054  {
2055  $tabs_gui->addTarget("members",
2056  $this->ctrl->getLinkTarget($this, $mem_cmd),
2057  array(),
2058  get_class($this));
2059  }
2060 
2061  // learning progress
2062  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
2063  if(ilLearningProgressAccess::checkAccess($this->object->getRefId(), $is_participant))
2064  {
2065  $tabs_gui->addTarget('learning_progress',
2066  $this->ctrl->getLinkTargetByClass(array('ilobjgroupgui','illearningprogressgui'),''),
2067  '',
2068  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
2069  }
2070 
2071 
2072  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
2073  {
2074  $tabs_gui->addTarget(
2075  'export',
2076  $this->ctrl->getLinkTargetByClass('ilexportgui',''),
2077  'export',
2078  'ilexportgui'
2079  );
2080  }
2081 
2082  /*
2083  if ($rbacsystem->checkAccess('write',$this->object->getRefId()))
2084  {
2085 
2086 
2087  $tabs_gui->addTarget('export',
2088  $this->ctrl->getLinkTarget($this,'listExportFiles'),
2089  array('listExportFiles','exportXML','confirmDeleteExportFile','downloadExportFile'),
2090  get_class($this));
2091  }
2092  */
2093  // parent tabs (all container: edit_permission, clipboard, trash
2094  parent::getTabs($tabs_gui);
2095 
2096  if($ilAccess->checkAccess('join','',$this->object->getRefId()) and
2097  !$this->object->members_obj->isAssigned($ilUser->getId()))
2098  {
2099  include_once './Modules/Group/classes/class.ilGroupWaitingList.php';
2100  if(ilGroupWaitingList::_isOnList($ilUser->getId(), $this->object->getId()))
2101  {
2102  $tabs_gui->addTab(
2103  'leave',
2104  $this->lng->txt('membership_leave'),
2105  $this->ctrl->getLinkTargetByClass('ilgroupregistrationgui','show','')
2106  );
2107 
2108  }
2109  else
2110  {
2111 
2112  $tabs_gui->addTarget("join",
2113  $this->ctrl->getLinkTargetByClass('ilgroupregistrationgui', "show"),
2114  'show',
2115  "");
2116  }
2117  }
2118  if($ilAccess->checkAccess('leave','',$this->object->getRefId()) and
2119  $this->object->members_obj->isMember($ilUser->getId()))
2120  {
2121  $tabs_gui->addTarget("grp_btn_unsubscribe",
2122  $this->ctrl->getLinkTarget($this, "leave"),
2123  '',
2124  "");
2125  }
2126  }
2127 
2128  // IMPORT FUNCTIONS
2129 
2131  {
2132  if(!is_array($_FILES['xmldoc']))
2133  {
2134  ilUtil::sendFailure($this->lng->txt("import_file_not_valid"));
2135  $this->createObject();
2136  return false;
2137  }
2138 
2139  include_once './Modules/Group/classes/class.ilObjGroup.php';
2140 
2141  if($ref_id = ilObjGroup::_importFromFile($_FILES['xmldoc'],(int) $_GET['ref_id']))
2142  {
2143  $this->ctrl->setParameter($this, "ref_id", $ref_id);
2144  ilUtil::sendSuccess($this->lng->txt("import_grp_finished"),true);
2145  ilUtil::redirect($this->ctrl->getLinkTarget($this,'edit','',false,false));
2146  }
2147 
2148  ilUtil::sendFailure($this->lng->txt("import_file_not_valid"));
2149  $this->createObject();
2150  }
2151 
2158  function exportObject()
2159  {
2160  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.grp_members_export.html",
2161  "Modules/Group");
2162  $this->tpl->setCurrentBlock("adm_content");
2163  $this->tpl->setVariable("FORMACTION", $this->getFormAction("export",$this->ctrl->getFormAction($this)));
2164  $this->tpl->setVariable("BUTTON_EXPORT", $this->lng->txt("export_group_members"));
2165  $this->tpl->parseCurrentBlock();
2166  }
2167 
2175  {
2176  $title = preg_replace("/\s/", "_", $this->object->getTitle());
2177  include_once "./Services/Excel/classes/class.ilExcelWriterAdapter.php";
2178  $adapter = new ilExcelWriterAdapter("export_" . $title . ".xls");
2179  $workbook = $adapter->getWorkbook();
2180  // Creating a worksheet
2181  $format_bold =& $workbook->addFormat();
2182  $format_bold->setBold();
2183  $format_percent =& $workbook->addFormat();
2184  $format_percent->setNumFormat("0.00%");
2185  $format_datetime =& $workbook->addFormat();
2186  $format_datetime->setNumFormat("DD/MM/YYYY hh:mm:ss");
2187  $format_title =& $workbook->addFormat();
2188  $format_title->setBold();
2189  $format_title->setColor('black');
2190  $format_title->setPattern(1);
2191  $format_title->setFgColor('silver');
2192  $worksheet =& $workbook->addWorksheet();
2193  $column = 0;
2194  $profile_data = array("email", "gender", "firstname", "lastname", "person_title", "institution",
2195  "department", "street", "zipcode","city", "country", "phone_office", "phone_home", "phone_mobile",
2196  "fax", "matriculation");
2197  foreach ($profile_data as $data)
2198  {
2199  $worksheet->writeString(0, $column++, $this->cleanString($this->lng->txt($data)), $format_title);
2200  }
2201  $member_ids = $this->object->getGroupMemberIds();
2202  $row = 1;
2203  foreach ($member_ids as $member_id)
2204  {
2205  $column = 0;
2206  $member =& $this->ilias->obj_factory->getInstanceByObjId($member_id);
2207  if ($member->getPref("public_email")=="y")
2208  {
2209  $worksheet->writeString($row, $column++, $this->cleanString($member->getEmail()));
2210  }
2211  else
2212  {
2213  $column++;
2214  }
2215  $worksheet->writeString($row, $column++, $this->cleanString($this->lng->txt("gender_" . $member->getGender())));
2216  $worksheet->writeString($row, $column++, $this->cleanString($member->getFirstname()));
2217  $worksheet->writeString($row, $column++, $this->cleanString($member->getLastname()));
2218  $worksheet->writeString($row, $column++, $this->cleanString($member->getUTitle()));
2219  if ($member->getPref("public_institution")=="y")
2220  {
2221  $worksheet->writeString($row, $column++, $this->cleanString($member->getInstitution()));
2222  }
2223  else
2224  {
2225  $column++;
2226  }
2227  if ($member->getPref("public_department")=="y")
2228  {
2229  $worksheet->writeString($row, $column++, $this->cleanString($member->getDepartment()));
2230  }
2231  else
2232  {
2233  $column++;
2234  }
2235  if ($member->getPref("public_street")=="y")
2236  {
2237  $worksheet->writeString($row, $column++, $this->cleanString($member->getStreet()));
2238  }
2239  else
2240  {
2241  $column++;
2242  }
2243  if ($member->getPref("public_zip")=="y")
2244  {
2245  $worksheet->writeString($row, $column++, $this->cleanString($member->getZipcode()));
2246  }
2247  else
2248  {
2249  $column++;
2250  }
2251  if ($member->getPref("public_city")=="y")
2252  {
2253  $worksheet->writeString($row, $column++, $this->cleanString($member->getCity()));
2254  }
2255  else
2256  {
2257  $column++;
2258  }
2259  if ($member->getPref("public_country")=="y")
2260  {
2261  $worksheet->writeString($row, $column++, $this->cleanString($member->getCountry()));
2262  }
2263  else
2264  {
2265  $column++;
2266  }
2267  if ($member->getPref("public_phone_office")=="y")
2268  {
2269  $worksheet->writeString($row, $column++, $this->cleanString($member->getPhoneOffice()));
2270  }
2271  else
2272  {
2273  $column++;
2274  }
2275  if ($member->getPref("public_phone_home")=="y")
2276  {
2277  $worksheet->writeString($row, $column++, $this->cleanString($member->getPhoneHome()));
2278  }
2279  else
2280  {
2281  $column++;
2282  }
2283  if ($member->getPref("public_phone_mobile")=="y")
2284  {
2285  $worksheet->writeString($row, $column++, $this->cleanString($member->getPhoneMobile()));
2286  }
2287  else
2288  {
2289  $column++;
2290  }
2291  if ($member->getPref("public_fax")=="y")
2292  {
2293  $worksheet->writeString($row, $column++, $this->cleanString($member->getFax()));
2294  }
2295  else
2296  {
2297  $column++;
2298  }
2299  if ($member->getPref("public_matriculation")=="y")
2300  {
2301  $worksheet->writeString($row, $column++, $this->cleanString($member->getMatriculation()));
2302  }
2303  else
2304  {
2305  $column++;
2306  }
2307  $row++;
2308  }
2309  $workbook->close();
2310  }
2311 
2320  function cleanString($str)
2321  {
2322  return str_replace(array("��","��","��","��","��","��","��"), array("ae","oe","ue","ss","Ae","Oe","Ue"), $str);
2323  }
2324 
2335  function infoScreenObject()
2336  {
2337  $this->ctrl->setCmd("showSummary");
2338  $this->ctrl->setCmdClass("ilinfoscreengui");
2339  $this->infoScreen();
2340  }
2341 
2345  function infoScreen()
2346  {
2347  global $rbacsystem, $ilUser, $ilSetting;
2348 
2349  $this->tabs_gui->setTabActive('info_short');
2350 
2351  if(!$rbacsystem->checkAccess("visible", $this->ref_id))
2352  {
2353  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
2354  }
2355 
2356  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
2357  $info = new ilInfoScreenGUI($this);
2358 
2359  if(strlen($this->object->getInformation()))
2360  {
2361  $info->addSection($this->lng->txt('grp_general_informations'));
2362  $info->addProperty($this->lng->txt('grp_information'), nl2br(
2363  ilUtil::makeClickable ($this->object->getInformation(), true)));
2364  }
2365 
2366  $info->enablePrivateNotes();
2367  $info->enableLearningProgress(true);
2368 
2369  $info->addSection($this->lng->txt('group_registration'));
2370  $info->showLDAPRoleGroupMappingInfo();
2371 
2372  if(!$this->object->isRegistrationEnabled())
2373  {
2374  $info->addProperty($this->lng->txt('group_registration_mode'),
2375  $this->lng->txt('grp_reg_deac_info_screen'));
2376 
2377  }
2378  else
2379  {
2380  switch($this->object->getRegistrationType())
2381  {
2383  $info->addProperty($this->lng->txt('group_registration_mode'),
2384  $this->lng->txt('grp_reg_direct_info_screen'));
2385  break;
2386 
2388  $info->addProperty($this->lng->txt('group_registration_mode'),
2389  $this->lng->txt('grp_reg_req_info_screen'));
2390  break;
2391 
2393  $info->addProperty($this->lng->txt('group_registration_mode'),
2394  $this->lng->txt('grp_reg_passwd_info_screen'));
2395  break;
2396 
2397  }
2398  /*
2399  $info->addProperty($this->lng->txt('group_registration_time'),
2400  ilDatePresentation::formatPeriod(
2401  $this->object->getRegistrationStart(),
2402  $this->object->getRegistrationEnd()));
2403  */
2404  if($this->object->isRegistrationUnlimited())
2405  {
2406  $info->addProperty($this->lng->txt('group_registration_time'),
2407  $this->lng->txt('grp_registration_unlimited'));
2408  }
2409  elseif($this->object->getRegistrationStart()->getUnixTime() < time())
2410  {
2411  $info->addProperty($this->lng->txt("group_registration_time"),
2412  $this->lng->txt('cal_until').' '.
2413  ilDatePresentation::formatDate($this->object->getRegistrationEnd()));
2414  }
2415  elseif($this->object->getRegistrationStart()->getUnixTime() >= time())
2416  {
2417  $info->addProperty($this->lng->txt("group_registration_time"),
2418  $this->lng->txt('cal_from').' '.
2419  ilDatePresentation::formatDate($this->object->getRegistrationStart()));
2420  }
2421  if ($this->object->isMembershipLimited())
2422  {
2423  $info->addProperty($this->lng->txt("mem_free_places"),
2424  max(0,$this->object->getMaxMembers() - $this->object->members_obj->getCountMembers()));
2425 
2426  }
2427 
2428  }
2429 
2430  // Confirmation
2431  include_once('Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
2432  $privacy = ilPrivacySettings::_getInstance();
2433 
2434  include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
2435  if($privacy->groupConfirmationRequired() or ilCourseDefinedFieldDefinition::_getFields($this->object->getId()) or $privacy->enabledGroupExport())
2436  {
2437  include_once('Services/PrivacySecurity/classes/class.ilExportFieldsInfo.php');
2438 
2439  $field_info = ilExportFieldsInfo::_getInstanceByType($this->object->getType());
2440 
2441  $this->lng->loadLanguageModule('ps');
2442  $info->addSection($this->lng->txt('grp_user_agreement_info'));
2443  $info->addProperty($this->lng->txt('ps_export_data'),$field_info->exportableFieldsToInfoString());
2444 
2445  if($fields = ilCourseDefinedFieldDefinition::_fieldsToInfoString($this->object->getId()))
2446  {
2447  $info->addProperty($this->lng->txt('ps_grp_user_fields'),$fields);
2448  }
2449  }
2450 
2451 
2452  // forward the command
2453  $this->ctrl->forwardCommand($info);
2454  }
2455 
2460  {
2461  global $ilUser;
2462 
2463  $ilUser->setPref("grpcrs_ntf_".$this->ref_id, (bool)$_REQUEST["grp_ntf"]);
2464  $ilUser->writePrefs();
2465 
2466  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
2467  $this->ctrl->redirect($this, "infoScreen");
2468  }
2469 
2473  function _goto($a_target, $a_add = "")
2474  {
2475  global $ilAccess, $ilErr, $lng,$ilUser;
2476 
2477  include_once './Services/Membership/classes/class.ilMembershipRegistrationCodeUtils.php';
2478  if(substr($a_add,0,5) == 'rcode')
2479  {
2480  if($ilUser->getId() == ANONYMOUS_USER_ID)
2481  {
2482  // Redirect to login for anonymous
2484  "login.php?target=".$_GET["target"]."&cmd=force_login&lang=".
2485  $ilUser->getCurrentLanguage()
2486  );
2487  }
2488 
2489  // Redirects to target location after assigning user to course
2491  $a_target,
2493  substr($a_add,5)
2494  );
2495  }
2496 
2497  if ($a_add == "mem" && $ilAccess->checkAccess("write", "", $a_target))
2498  {
2499  ilObjectGUI::_gotoRepositoryNode($a_target, "members");
2500  }
2501 
2502  if ($ilAccess->checkAccess("read", "", $a_target))
2503  {
2505  }
2506  else
2507  {
2508  // to do: force flat view
2509  if ($ilAccess->checkAccess("visible", "", $a_target))
2510  {
2511  ilObjectGUI::_gotoRepositoryNode($a_target, "infoScreenGoto");
2512  }
2513  else
2514  {
2515  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
2516  {
2517  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
2518  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
2520  }
2521  }
2522  }
2523  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
2524  }
2525 
2526 
2534  protected function initForm($a_mode = 'edit')
2535  {
2536  global $ilUser,$tpl,$tree;
2537 
2538  if(is_object($this->form))
2539  {
2540  return true;
2541  }
2542 
2543  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2544 
2545  $this->form = new ilPropertyFormGUI();
2546  switch($a_mode)
2547  {
2548  case 'edit':
2549  $this->form->setFormAction($this->ctrl->getFormAction($this,'update'));
2550  break;
2551 
2552  default:
2553  $this->form->setTableWidth('600px');
2554  $this->form->setFormAction($this->ctrl->getFormAction($this,'save'));
2555  break;
2556  }
2557 
2558  // title
2559  $title = new ilTextInputGUI($this->lng->txt('title'),'title');
2560  $title->setSubmitFormOnEnter(true);
2561  $title->setValue($this->object->getTitle());
2562  $title->setSize(40);
2563  $title->setMaxLength(128);
2564  $title->setRequired(true);
2565  $this->form->addItem($title);
2566 
2567  // desc
2568  $desc = new ilTextAreaInputGUI($this->lng->txt('description'),'desc');
2569  $desc->setValue($this->object->getLongDescription());
2570  $desc->setRows(2);
2571  $desc->setCols(40);
2572  $this->form->addItem($desc);
2573 
2574  // Group type
2575  $grp_type = new ilRadioGroupInputGUI($this->lng->txt('grp_typ'),'grp_type');
2576 
2577  if($a_mode == 'edit')
2578  {
2579  $type = ($this->object->getGroupType() ? $this->object->getGroupType() : $this->object->readGroupStatus());
2580  }
2581  else
2582  {
2583  $type = ($this->object->getGroupType() ? $this->object->getGroupType() : GRP_TYPE_PUBLIC);
2584  }
2585 
2586  $grp_type->setValue($type);
2587  $grp_type->setRequired(true);
2588 
2589 
2590  // PUBLIC GROUP
2591  $opt_public = new ilRadioOption($this->lng->txt('grp_public'),GRP_TYPE_PUBLIC,$this->lng->txt('grp_public_info'));
2592  $grp_type->addOption($opt_public);
2593 
2594 
2595  // CLOSED GROUP
2596  $opt_closed = new ilRadioOption($this->lng->txt('grp_closed'),GRP_TYPE_CLOSED,$this->lng->txt('grp_closed_info'));
2597  $grp_type->addOption($opt_closed);
2598  if($a_mode == 'update_group_type')
2599  {
2600  $grp_type->setAlert($this->lng->txt('grp_type_changed_info'));
2601  }
2602  $this->form->addItem($grp_type);
2603 
2604  if($a_mode == 'edit')
2605  {
2606  // Group registration ############################################################
2607  $pres = new ilFormSectionHeaderGUI();
2608  $pres->setTitle($this->lng->txt('grp_setting_header_registration'));
2609  $this->form->addItem($pres);
2610 
2611  // Registration type
2612  $reg_type = new ilRadioGroupInputGUI($this->lng->txt('group_registration_mode'),'registration_type');
2613  $reg_type->setValue($this->object->getRegistrationType());
2614 
2615  $opt_dir = new ilRadioOption($this->lng->txt('grp_reg_direct'),GRP_REGISTRATION_DIRECT);#$this->lng->txt('grp_reg_direct_info'));
2616  $reg_type->addOption($opt_dir);
2617 
2618  $opt_pass = new ilRadioOption($this->lng->txt('grp_pass_request'),GRP_REGISTRATION_PASSWORD);
2619  $pass = new ilTextInputGUI('','password');
2620  $pass->setInfo($this->lng->txt('grp_reg_password_info'));
2621  $pass->setValue($this->object->getPassword());
2622  $pass->setSize(10);
2623  $pass->setMaxLength(32);
2624  $opt_pass->addSubItem($pass);
2625  $reg_type->addOption($opt_pass);
2626 
2627  $opt_req = new ilRadioOption($this->lng->txt('grp_reg_request'),GRP_REGISTRATION_REQUEST,$this->lng->txt('grp_reg_request_info'));
2628  $reg_type->addOption($opt_req);
2629 
2630  $opt_deact = new ilRadioOption($this->lng->txt('grp_reg_disabled'),GRP_REGISTRATION_DEACTIVATED,$this->lng->txt('grp_reg_disabled_info'));
2631  $reg_type->addOption($opt_deact);
2632 
2633  // Registration codes
2634  $reg_code = new ilCheckboxInputGUI($this->lng->txt('grp_reg_code'),'reg_code_enabled');
2635  $reg_code->setChecked($this->object->isRegistrationAccessCodeEnabled());
2636  $reg_code->setValue(1);
2637  $reg_code->setInfo($this->lng->txt('grp_reg_code_enabled_info'));
2638  $this->form->addItem($reg_type);
2639 
2640  // time limit
2641  $time_limit = new ilCheckboxInputGUI($this->lng->txt('grp_reg_limited'),'reg_limit_time');
2642  $time_limit->setOptionTitle($this->lng->txt('grp_reg_limit_time'));
2643  $time_limit->setChecked($this->object->isRegistrationUnlimited() ? false : true);
2644 
2645  $this->lng->loadLanguageModule('dateplaner');
2646  include_once './Services/Form/classes/class.ilDateDurationInputGUI.php';
2647  $tpl->addJavaScript('./Services/Form/js/date_duration.js');
2648  $dur = new ilDateDurationInputGUI($this->lng->txt('grp_reg_period'),'reg');
2649  $dur->setStartText($this->lng->txt('cal_start'));
2650  $dur->setEndText($this->lng->txt('cal_end'));
2651  $dur->setMinuteStepSize(5);
2652  $dur->setShowDate(true);
2653  $dur->setShowTime(true);
2654  $dur->setStart($this->object->getRegistrationStart());
2655  $dur->setEnd($this->object->getRegistrationEnd());
2656 
2657  $time_limit->addSubItem($dur);
2658  $this->form->addItem($time_limit);
2659 
2660  // max member
2661  $lim = new ilCheckboxInputGUI($this->lng->txt('reg_grp_max_members_short'),'registration_membership_limited');
2662  $lim->setValue(1);
2663  $lim->setOptionTitle($this->lng->txt('reg_grp_max_members'));
2664  $lim->setChecked($this->object->isMembershipLimited());
2665 
2666 
2667  $max = new ilTextInputGUI('','registration_max_members');
2668  $max->setValue($this->object->getMaxMembers() ? $this->object->getMaxMembers() : '');
2669  $max->setTitle($this->lng->txt('members').':');
2670  $max->setSize(3);
2671  $max->setMaxLength(4);
2672  $max->setInfo($this->lng->txt('grp_reg_max_members_info'));
2673  $lim->addSubItem($max);
2674 
2675  $wait = new ilCheckboxInputGUI('','waiting_list');
2676  $wait->setValue(1);
2677  $wait->setOptionTitle($this->lng->txt('grp_waiting_list'));
2678  $wait->setInfo($this->lng->txt('grp_waiting_list_info'));
2679  $wait->setChecked($this->object->isWaitingListEnabled() ? true : false);
2680  $lim->addSubItem($wait);
2681  $this->form->addItem($lim);
2682 
2683 
2684  // Registration codes
2685  if(!$this->object->getRegistrationAccessCode())
2686  {
2687  include_once './Services/Membership/classes/class.ilMembershipRegistrationCodeUtils.php';
2688  $this->object->setRegistrationAccessCode(ilMembershipRegistrationCodeUtils::generateCode());
2689  }
2690  $reg_link = new ilHiddenInputGUI('reg_code');
2691  $reg_link->setValue($this->object->getRegistrationAccessCode());
2692  $this->form->addItem($reg_link);
2693 
2694  $link = new ilCustomInputGUI($this->lng->txt('grp_reg_code_link'));
2695  include_once './Services/Link/classes/class.ilLink.php';
2696  $val = ilLink::_getLink($this->object->getRefId(),$this->object->getType(),array(),'_rcode'.$this->object->getRegistrationAccessCode());
2697  $link->setHTML('<font class="small">'.$val.'</font>');
2698  $reg_code->addSubItem($link);
2699  $this->form->addItem($reg_code);
2700 
2701 
2702  // Group presentation
2703  $hasParentCourse = $tree->checkForParentType($this->object->getRefId(),'crs');
2704  $pres = new ilFormSectionHeaderGUI();
2705  $pres->setTitle($this->lng->txt('grp_setting_header_presentation'));
2706  $this->form->addItem($pres);
2707 
2708  // presentation type
2709  $view_type = new ilRadioGroupInputGUI($this->lng->txt('grp_presentation_type'),'view_mode');
2710  if($hasParentCourse)
2711  {
2712  switch($this->object->getViewMode())
2713  {
2715  $course_view_mode = ' ('.$this->lng->txt('cntr_view_sessions').')';
2716  break;
2717 
2719  $course_view_mode = ' ('.$this->lng->txt('cntr_view_simple').')';
2720  break;
2721 
2723  $course_view_mode = ' ('.$this->lng->txt('cntr_view_by_type').')';
2724  break;
2725  }
2726 
2727  $opt = new ilRadioOption($this->lng->txt('grp_view_inherit').$course_view_mode,ilContainer::VIEW_INHERIT);
2728  $opt->setInfo($this->lng->txt('grp_view_inherit_info'));
2729  $view_type->addOption($opt);
2730  }
2731 
2732  if($hasParentCourse &&
2733  $this->object->getViewMode(false) == ilContainer::VIEW_INHERIT)
2734  {
2735  $view_type->setValue(ilContainer::VIEW_INHERIT);
2736  }
2737  else
2738  {
2739  $view_type->setValue($this->object->getViewMode(true));
2740  }
2741 
2742  $opt = new ilRadioOption($this->lng->txt('cntr_view_simple'),ilContainer::VIEW_SIMPLE);
2743  $opt->setInfo($this->lng->txt('grp_view_info_simple'));
2744  $view_type->addOption($opt);
2745 
2746  $opt = new ilRadioOption($this->lng->txt('cntr_view_by_type'), ilContainer::VIEW_BY_TYPE);
2747  $opt->setInfo($this->lng->txt('grp_view_info_by_type'));
2748  $view_type->addOption($opt);
2749  $this->form->addItem($view_type);
2750 
2751 
2752  $sog = new ilRadioGroupInputGUI($this->lng->txt('sorting_header'),'sor');
2753 
2754  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
2755  $sort = new ilContainerSortingSettings($this->object->getId());
2756  $sog->setValue($sort->getSortMode());
2757  $sog->setRequired(true);
2758 
2759  if($hasParentCourse)
2760  {
2761  $sde = new ilRadioOption();
2762  $sde->setValue(ilContainer::SORT_INHERIT);
2763 
2764  $title = $this->lng->txt('sort_inherit_prefix');
2765  $title .= ' ('.ilContainerSortingSettings::sortModeToString(
2767  $sde->setTitle($title);
2768  $sde->setInfo($this->lng->txt('sorting_info_inherit'));
2769  $sog->addOption($sde);
2770  }
2771 
2772  $sma = new ilRadioOption();
2773  $sma->setValue(ilContainer::SORT_TITLE);
2774  $sma->setTitle($this->lng->txt('sorting_title_header'));
2775  $sma->setInfo($this->lng->txt('sorting_info_title'));
2776  $sog->addOption($sma);
2777 
2778  $sti = new ilRadioOption();
2779  $sti->setValue(ilContainer::SORT_MANUAL);
2780  $sti->setTitle($this->lng->txt('sorting_manual_header'));
2781  $sti->setInfo($this->lng->txt('sorting_info_manual'));
2782  $sog->addOption($sti);
2783 
2784  $this->form->addItem($sog);
2785 
2786  include_once './Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
2788  $this->object->getId(),
2789  $this->form,
2790  array(
2793  )
2794  );
2795  }
2796 
2797  switch($a_mode)
2798  {
2799  case 'create':
2800  $this->form->setTitle($this->lng->txt('grp_new'));
2801  $this->form->setTitleIcon(ilUtil::getImagePath('icon_grp.png'));
2802 
2803  $this->form->addCommandButton('save',$this->lng->txt('grp_new'));
2804  $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
2805  return true;
2806 
2807  case 'edit':
2808  $this->form->setTitle($this->lng->txt('grp_edit'));
2809  $this->form->setTitleIcon(ilUtil::getImagePath('icon_grp.png'));
2810 
2811  // Edit ecs export settings
2812  include_once 'Modules/Group/classes/class.ilECSGroupSettings.php';
2813  $ecs = new ilECSGroupSettings($this->object);
2814  $ecs->addSettingsToForm($this->form, 'grp');
2815 
2816  $this->form->addCommandButton('update',$this->lng->txt('save'));
2817  $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
2818  return true;
2819 
2820  case 'update_group_type':
2821  $grp_type->setValue(
2822  $type == GRP_TYPE_PUBLIC ?
2823  GRP_TYPE_CLOSED :
2825  );
2826 
2827  $this->form->setTitle($this->lng->txt('grp_edit'));
2828  $this->form->setTitleIcon(ilUtil::getImagePath('icon_grp.png'));
2829  return true;
2830  }
2831  return true;
2832  }
2833 
2840  public function load()
2841  {
2842  $this->object->setTitle(ilUtil::stripSlashes($_POST['title']));
2843  $this->object->setDescription(ilUtil::stripSlashes($_POST['desc']));
2844  $this->object->setGroupType(ilUtil::stripSlashes($_POST['grp_type']));
2845  $this->object->setRegistrationType(ilUtil::stripSlashes($_POST['registration_type']));
2846  $this->object->setPassword(ilUtil::stripSlashes($_POST['password']));
2847  $this->object->enableUnlimitedRegistration((bool) !$_POST['reg_limit_time']);
2848  $this->object->setRegistrationStart($this->loadDate('start'));
2849  $this->object->setRegistrationEnd($this->loadDate('end'));
2850  $this->object->enableMembershipLimitation((bool) $_POST['registration_membership_limited']);
2851  $this->object->setMaxMembers((int) $_POST['registration_max_members']);
2852  $this->object->enableWaitingList((bool) $_POST['waiting_list']);
2853  $this->object->enableRegistrationAccessCode((bool) $_POST['reg_code_enabled']);
2854  $this->object->setRegistrationAccessCode(ilUtil::stripSlashes($_POST['reg_code']));
2855  $this->object->setViewMode(ilUtil::stripSlashes($_POST['view_mode']));
2856 
2857  return true;
2858  }
2859 
2867  protected function loadDate($a_field)
2868  {
2869  global $ilUser;
2870 
2871  include_once('./Services/Calendar/classes/class.ilDateTime.php');
2872 
2873  $dt['year'] = (int) $_POST['reg'][$a_field]['date']['y'];
2874  $dt['mon'] = (int) $_POST['reg'][$a_field]['date']['m'];
2875  $dt['mday'] = (int) $_POST['reg'][$a_field]['date']['d'];
2876  $dt['hours'] = (int) $_POST['reg'][$a_field]['time']['h'];
2877  $dt['minutes'] = (int) $_POST['reg'][$a_field]['time']['m'];
2878  $dt['seconds'] = (int) $_POST['reg'][$a_field]['time']['s'];
2879 
2880  $date = new ilDateTime($dt,IL_CAL_FKT_GETDATE,$ilUser->getTimeZone());
2881  return $date;
2882  }
2883 
2891  protected function setSubTabs($a_tab)
2892  {
2893  global $rbacsystem,$ilUser,$ilAccess;
2894 
2895  switch($a_tab)
2896  {
2897  case 'members':
2898  // for admins
2899  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
2900  {
2901  $this->tabs_gui->addSubTabTarget("grp_edit_members",
2902  $this->ctrl->getLinkTarget($this,'members'),
2903  "members",
2904  get_class($this));
2905  }
2906  // for all
2907  $this->tabs_gui->addSubTabTarget("grp_members_gallery",
2908  $this->ctrl->getLinkTarget($this,'membersGallery'),
2909  "membersGallery", get_class($this));
2910 
2911  // members map
2912  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
2914  $this->object->getEnableGroupMap())
2915  {
2916  $this->tabs_gui->addSubTabTarget("grp_members_map",
2917  $this->ctrl->getLinkTarget($this,'membersMap'),
2918  "membersMap", get_class($this));
2919  }
2920 
2921  $this->tabs_gui->addSubTabTarget("mail_members",
2922  $this->ctrl->getLinkTarget($this,'mailMembers'),
2923  "mailMembers", get_class($this));
2924 
2925  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
2926  {
2927  $this->tabs_gui->addSubTabTarget("events",
2928  $this->ctrl->getLinkTargetByClass('ilsessionoverviewgui','listSessions'),
2929  "", 'ilsessionoverviewgui');
2930  }
2931 
2932  include_once 'Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
2933  if(ilPrivacySettings::_getInstance()->checkExportAccess($this->object->getRefId()))
2934  {
2935  $this->tabs_gui->addSubTabTarget('grp_export_members',
2936  $this->ctrl->getLinkTargetByClass('ilmemberexportgui','show'),
2937  "", 'ilmemberexportgui');
2938  }
2939 
2940  break;
2941 
2942  case 'settings':
2943  $this->tabs_gui->addSubTabTarget("grp_settings",
2944  $this->ctrl->getLinkTarget($this,'edit'),
2945  "edit", get_class($this));
2946 
2947  $this->tabs_gui->addSubTabTarget("grp_info_settings",
2948  $this->ctrl->getLinkTarget($this,'editInfo'),
2949  "editInfo", get_class($this));
2950 
2951  // custom icon
2952  if ($this->ilias->getSetting("custom_icons"))
2953  {
2954  $this->tabs_gui->addSubTabTarget("grp_icon_settings",
2955  $this->ctrl->getLinkTarget($this,'editGroupIcons'),
2956  "editGroupIcons", get_class($this));
2957  }
2958 
2959  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
2961  {
2962  $this->tabs_gui->addSubTabTarget("grp_map_settings",
2963  $this->ctrl->getLinkTarget($this,'editMapSettings'),
2964  "editMapSettings", get_class($this));
2965  }
2966 
2967  $this->tabs_gui->addSubTabTarget('groupings',
2968  $this->ctrl->getLinkTargetByClass('ilobjcoursegroupinggui','listGroupings'),
2969  'listGroupings',
2970  get_class($this));
2971 
2972  include_once('Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
2973  include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
2974  // only show if export permission is granted
2975  if(ilPrivacySettings::_getInstance()->checkExportAccess($this->object->getRefId()) or ilCourseDefinedFieldDefinition::_hasFields($this->object->getId()))
2976  {
2977  $this->tabs_gui->addSubTabTarget('grp_custom_user_fields',
2978  $this->ctrl->getLinkTargetByClass('ilobjectcustomuserfieldsgui'),
2979  '',
2980  'ilobjectcustomuserfieldsgui');
2981  }
2982 
2983 
2984 
2985  break;
2986 
2987 
2988  }
2989  }
2990 
2997  private function checkAgreement()
2998  {
2999  global $ilUser,$ilAccess;
3000 
3001  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
3002  {
3003  return true;
3004  }
3005 
3006  // Disable aggrement if is not member of group
3007  if(!$this->object->members_obj->isAssigned($ilUser->getId()))
3008  {
3009  return true;
3010  }
3011 
3012  include_once './Services/Container/classes/class.ilMemberViewSettings.php';
3013  if(ilMemberViewSettings::getInstance()->isActive())
3014  {
3015  return true;
3016  }
3017 
3018  include_once('Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
3019  include_once('Services/Membership/classes/class.ilMemberAgreement.php');
3020  $privacy = ilPrivacySettings::_getInstance();
3021 
3022  // Check agreement
3023  if(($privacy->groupConfirmationRequired() or ilCourseDefinedFieldDefinition::_hasFields($this->object->getId()))
3024  and !ilMemberAgreement::_hasAccepted($ilUser->getId(),$this->object->getId()))
3025  {
3026  return false;
3027  }
3028  // Check required fields
3029  include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');
3030  if(!ilCourseUserData::_checkRequired($ilUser->getId(),$this->object->getId()))
3031  {
3032  return false;
3033  }
3034  return true;
3035  }
3036 
3037 
3042  public function prepareOutput()
3043  {
3044  global $rbacsystem;
3045  if(!$this->getCreationMode())
3046  {
3047  /*
3048  include_once './Services/Container/classes/class.ilMemberViewSettings.php';
3049  $settings = ilMemberViewSettings::getInstance();
3050  if($settings->isActive() and $settings->getContainer() != $this->object->getRefId())
3051  {
3052  $settings->setContainer($this->object->getRefId());
3053  $rbacsystem->initMemberView();
3054  }
3055  */
3056  }
3058  }
3059 
3064  protected function createMailSignature()
3065  {
3066  $link = chr(13).chr(10).chr(13).chr(10);
3067  $link .= $this->lng->txt('grp_mail_permanent_link');
3068  $link .= chr(13).chr(10).chr(13).chr(10);
3069  include_once 'Services/Link/classes/class.ilLink.php';
3070  $link .= ilLink::_getLink($this->object->getRefId());
3071  return rawurlencode(base64_encode($link));
3072  }
3073 
3074  protected function initHeaderAction($a_sub_type = null, $a_sub_id = null)
3075  {
3076  global $ilSetting, $ilUser;
3077 
3078  $lg = parent::initHeaderAction($a_sub_type, $a_sub_id);
3079 
3080  include_once('./Modules/Group/classes/class.ilGroupParticipants.php');
3081  if($ilSetting->get("crsgrp_ntf") &&
3082  ilGroupParticipants::_isParticipant($this->ref_id, $ilUser->getId()))
3083  {
3084  if(!$ilUser->getPref("grpcrs_ntf_".$this->ref_id))
3085  {
3086  $lg->addHeaderIcon("not_icon",
3087  ilUtil::getImagePath("notification_off.png"),
3088  $this->lng->txt("grp_notification_deactivated"));
3089 
3090  $this->ctrl->setParameter($this, "grp_ntf", 1);
3091  $caption = "grp_activate_notification";
3092  }
3093  else
3094  {
3095  $lg->addHeaderIcon("not_icon",
3096  ilUtil::getImagePath("notification_on.png"),
3097  $this->lng->txt("grp_notification_activated"));
3098 
3099  $this->ctrl->setParameter($this, "grp_ntf", 0);
3100  $caption = "grp_deactivate_notification";
3101  }
3102 
3103  $lg->addCustomCommand($this->ctrl->getLinkTarget($this, "saveNotification"),
3104  $caption);
3105 
3106 
3107  $this->ctrl->setParameter($this, "grp_ntf", "");
3108  }
3109 
3110  return $lg;
3111  }
3112 
3114  {
3115  global $ilTabs;
3116 
3117  $this->checkPermission('write');
3118 
3119  $ilTabs->clearTargets();
3120  $ilTabs->setBackTarget($this->lng->txt('back'),
3121  $this->ctrl->getLinkTarget($this, 'members'));
3122 
3123  $list = $this->initAttendanceList();
3124  $form = $list->initForm('printMembersOutput');
3125  $this->tpl->setContent($form->getHTML());
3126  }
3127 
3133  protected function initAttendanceList()
3134  {
3135  include_once('./Modules/Group/classes/class.ilGroupParticipants.php');
3136  $members_obj = ilGroupParticipants::_getInstanceByObjId($this->object->getId());
3137 
3138  include_once 'Services/Membership/classes/class.ilAttendanceList.php';
3139  $list = new ilAttendanceList($this, $members_obj);
3140  $list->setId('grpmemlst');
3141 
3142  $list->setTitle($this->lng->txt('grp_members_print_title'),
3143  $this->lng->txt('obj_grp').': '.$this->object->getTitle());
3144 
3145  include_once './Services/Tracking/classes/class.ilObjUserTracking.php';
3146  include_once('./Services/Tracking/classes/class.ilLPObjSettings.php');
3147  $this->show_tracking = (ilObjUserTracking::_enabledLearningProgress() and
3149  ilLPObjSettings::_lookupMode($this->object->getId()) != LP_MODE_DEACTIVATED);
3150  if($this->show_tracking)
3151  {
3152  $this->lng->loadLanguageModule('trac');
3153  $list->addPreset('progress', $this->lng->txt('learning_progress'), true);
3154  }
3155 
3156  include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
3157  $privacy = ilPrivacySettings::_getInstance();
3158  if($privacy->enabledGroupAccessTimes())
3159  {
3160  $list->addPreset('access', $this->lng->txt('last_access'), true);
3161  }
3162 
3163  return $list;
3164  }
3165 
3166  public function getAttendanceListUserData($a_user_id)
3167  {
3168  $data = $this->members_data[$a_user_id];
3169  $data['access'] = $data['access_time'];
3170  $data['progress'] = $this->lng->txt($data['progress']);
3171 
3172  return $data;
3173  }
3174 
3176  {
3177  $list = $this->initAttendanceList();
3178  $list->initFromForm();
3179  $list->setCallback(array($this, 'getAttendanceListUserData'));
3180 
3181  $part = ilGroupParticipants::_getInstanceByObjId($this->object->getId());
3182  $this->members_data = $this->readMemberData($part->getParticipants());
3183 
3184  echo $list->getFullscreenHTML();
3185  exit();
3186  }
3187 
3188 } // END class.ilObjGroupGUI
3189 ?>