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