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