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