ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjGroupGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once "./Services/Container/classes/class.ilContainerGUI.php";
25 include_once('./Modules/Group/classes/class.ilObjGroup.php');
26 
42 {
47  public function __construct($a_data,$a_id,$a_call_by_reference,$a_prepare_output = false)
48  {
49  $this->type = "grp";
50  $this->ilContainerGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
51 
52  $this->lng->loadLanguageModule('grp');
53  }
54 
55  function &executeCommand()
56  {
57  global $ilUser,$rbacsystem,$ilAccess, $ilNavigationHistory,$ilErr;
58 
59  $next_class = $this->ctrl->getNextClass($this);
60  $cmd = $this->ctrl->getCmd();
61  $this->prepareOutput();
62 
63  // add entry to navigation history
64  if (!$this->getCreationMode() &&
65  $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
66  {
67  $ilNavigationHistory->addItem($_GET["ref_id"],
68  "repository.php?cmd=frameset&ref_id=".$_GET["ref_id"], "grp");
69  }
70 
71  switch($next_class)
72  {
73  case "ilconditionhandlerinterface":
74  include_once './classes/class.ilConditionHandlerInterface.php';
75 
76  if($_GET['item_id'])
77  {
78  $this->ctrl->saveParameter($this,'item_id',$_GET['item_id']);
79  $this->setSubTabs('activation');
80  $this->tabs_gui->setTabActive('view_content');
81 
82  $new_gui =& new ilConditionHandlerInterface($this,(int) $_GET['item_id']);
83  $this->ctrl->forwardCommand($new_gui);
84  }
85  else
86  {
87  $new_gui =& new ilConditionHandlerInterface($this);
88  $this->ctrl->forwardCommand($new_gui);
89  }
90  break;
91 
92  case 'ilgroupregistrationgui':
93  $this->ctrl->setReturn($this,'');
94  include_once('./Modules/Group/classes/class.ilGroupRegistrationGUI.php');
95  $registration = new ilGroupRegistrationGUI($this->object);
96  $this->ctrl->forwardCommand($registration);
97  $this->tabs_gui->setTabActive('join');
98  break;
99 
100  case 'ilpermissiongui':
101  $this->tabs_gui->setTabActive('perm_settings');
102  include_once("./classes/class.ilPermissionGUI.php");
103  $perm_gui =& new ilPermissionGUI($this);
104  $ret =& $this->ctrl->forwardCommand($perm_gui);
105  break;
106 
107  case 'ilrepositorysearchgui':
108  include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
109  $rep_search =& new ilRepositorySearchGUI();
110  $rep_search->setCallback($this,'addUserObject');
111 
112  // Set tabs
113  $this->tabs_gui->setTabActive('members');
114  $this->ctrl->setReturn($this,'members');
115  $ret =& $this->ctrl->forwardCommand($rep_search);
116  $this->setSubTabs('members');
117  $this->tabs_gui->setSubTabActive('members');
118  break;
119 
120  case 'ilcourseitemadministrationgui':
121  include_once 'Modules/Course/classes/class.ilCourseItemAdministrationGUI.php';
122  $this->tabs_gui->clearSubTabs();
123  $this->ctrl->setReturn($this,'view');
124  $item_adm_gui = new ilCourseItemAdministrationGUI($this->object,(int) $_REQUEST['item_id']);
125  $this->ctrl->forwardCommand($item_adm_gui);
126  break;
127 
128  case "ilinfoscreengui":
129  $ret =& $this->infoScreen();
130  break;
131 
132  case "illearningprogressgui":
133  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
134 
136  $this->object->getRefId(),
137  $_GET['user_id'] ? $_GET['user_id'] : $ilUser->getId());
138  $this->ctrl->forwardCommand($new_gui);
139  $this->tabs_gui->setTabActive('learning_progress');
140  break;
141 
142  case 'ilobjcoursegroupinggui':
143  include_once './Modules/Course/classes/class.ilObjCourseGroupingGUI.php';
144 
145  $this->ctrl->setReturn($this,'edit');
146  $crs_grp_gui =& new ilObjCourseGroupingGUI($this->object,(int) $_GET['obj_id']);
147  $this->ctrl->forwardCommand($crs_grp_gui);
148  $this->setSubTabs('settings');
149  $this->tabs_gui->setTabActive('settings');
150  $this->tabs_gui->setSubTabActive('groupings');
151  break;
152 
153  case 'ilcoursecontentgui':
154 
155  include_once './Modules/Course/classes/class.ilCourseContentGUI.php';
156  $course_content_obj = new ilCourseContentGUI($this);
157  $this->ctrl->forwardCommand($course_content_obj);
158  break;
159 
160  case 'ilcourseitemadministrationgui':
161 
162  include_once 'Modules/Course/classes/class.ilCourseItemAdministrationGUI.php';
163 
164  $this->ctrl->setReturn($this,'');
165  $item_adm_gui = new ilCourseItemAdministrationGUI($this->object,(int) $_GET['item_id']);
166  $this->ctrl->forwardCommand($item_adm_gui);
167 
168  // (Sub)tabs
169  $this->setSubTabs('activation');
170  $this->tabs_gui->setTabActive('view_content');
171  $this->tabs_gui->setSubTabActive('activation');
172  break;
173 
174  case 'ilpublicuserprofilegui':
175  require_once './Services/User/classes/class.ilPublicUserProfileGUI.php';
176  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
177  $html = $this->ctrl->forwardCommand($profile_gui);
178  $this->setSubTabs('members');
179  $this->tabs_gui->setTabActive('group_members');
180  $this->tabs_gui->setSubTabActive('grp_members_gallery');
181  $this->tpl->setVariable("ADM_CONTENT", $html);
182  break;
183 
184  case "ilcolumngui":
185  $this->tabs_gui->setTabActive('none');
186  $this->checkPermission("read");
187  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
188  //$this->getSubItems();
189  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
191  $this->renderObject();
192  break;
193 
194  // container page editing
195  case "ilpageobjectgui":
196  $this->checkPermission("write");
197  //$this->prepareOutput(false);
198  $ret = $this->forwardToPageObject();
199  if ($ret != "")
200  {
201  $this->tpl->setContent($ret);
202  }
203  break;
204 
205  default:
206 
207  // check visible permission
208  if (!$this->getCreationMode() and !$ilAccess->checkAccess('visible','',$this->object->getRefId(),'grp'))
209  {
210  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"),$ilErr->MESSAGE);
211  }
212 
213  // check read permission
214  if ((!$this->getCreationMode()
215  && !$rbacsystem->checkAccess('read',$this->object->getRefId()) && $cmd != 'infoScreen')
216  || $cmd == 'join')
217  {
218  // no join permission -> redirect to info screen
219  if (!$rbacsystem->checkAccess('join',$this->object->getRefId()))
220  {
221  $this->ctrl->redirect($this, "infoScreen");
222  }
223  else // no read -> show registration
224  {
225  include_once('./Modules/Group/classes/class.ilGroupRegistrationGUI.php');
226  $this->ctrl->redirectByClass("ilGroupRegistrationGUI", "show");
227  }
228  }
229  if(!$cmd)
230  {
231  $cmd = 'view';
232  }
233  $cmd .= 'Object';
234  $this->$cmd();
235  break;
236  }
237  }
238 
239  function viewObject()
240  {
241  global $tree,$rbacsystem,$ilUser;
242 
243  include_once 'Services/Tracking/classes/class.ilLearningProgress.php';
244  ilLearningProgress::_tracProgress($ilUser->getId(),$this->object->getId(),'grp');
245 
246  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
247  {
249  return true;
250  }
251  $this->tabs_gui->setTabActive('view_content');
252  $this->renderObject();
253 
254  /*
255  else if($tree->checkForParentType($this->ref_id,'crs'))
256  {
257  $this->renderObject();
258  //$this->ctrl->returnToParent($this);
259  }
260  else
261  {
262  include_once './Modules/Course/classes/class.ilCourseContentGUI.php';
263  $course_content_obj = new ilCourseContentGUI($this);
264 
265  $this->ctrl->setCmdClass(get_class($course_content_obj));
266  $this->ctrl->forwardCommand($course_content_obj);
267  }
268 
269  $this->tabs_gui->setTabActive('view_content');
270  return true;
271  */
272  }
273 
277  function modifyItemGUI($a_item_list_gui, $a_item_data, $a_show_path)
278  {
279  global $tree;
280 
281  // if folder is in a course, modify item list gui according to course requirements
282  if ($course_ref_id = $tree->checkForParentType($this->object->getRefId(),'crs'))
283  {
284  include_once("./Modules/Course/classes/class.ilObjCourse.php");
285  include_once("./Modules/Course/classes/class.ilObjCourseGUI.php");
286  $course_obj_id = ilObject::_lookupObjId($course_ref_id);
287  ilObjCourseGUI::_modifyItemGUI($a_item_list_gui, $a_item_data, $a_show_path,
288  ilObjCourse::_lookupAboStatus($course_obj_id), $course_ref_id, $course_obj_id,
289  $this->object->getRefId());
290  }
291  }
292 
293 
303  public function createObject()
304  {
305  if(!is_object($this->object))
306  {
307  $this->object = new ilObjGroup();
308  }
309 
310  $this->ctrl->setParameter($this,'new_type','grp');
311  $this->initForm('create');
312  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.grp_create.html','Modules/Group');
313  $this->tpl->setVariable('CREATE_FORM',$this->form->getHTML());
314 
315  // IMPORT
316  $this->tpl->setVariable('IMP_FORMACTION',$this->ctrl->getFormAction($this));
317  $this->tpl->setVariable("TYPE_IMG",
318  ilUtil::getImagePath("icon_grp.gif"));
319  $this->tpl->setVariable("ALT_IMG", $this->lng->txt("obj_grp"));
320 
321  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
322  $this->tpl->setVariable("TXT_IMPORT_CRS", $this->lng->txt("import_grp"));
323  $this->tpl->setVariable("TXT_CRS_FILE", $this->lng->txt("file"));
324  $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
325  $this->tpl->setVariable('TXT_CANCEL',$this->lng->txt('cancel'));
326 
327  // get the value for the maximal uploadable filesize from the php.ini (if available)
328  $umf=get_cfg_var("upload_max_filesize");
329  // get the value for the maximal post data from the php.ini (if available)
330  $pms=get_cfg_var("post_max_size");
331 
332  // use the smaller one as limit
333  $max_filesize=min($umf, $pms);
334  if (!$max_filesize)
335  $max_filesize=max($umf, $pms);
336 
337  // gives out the limit as a littel notice :)
338  $this->tpl->setVariable("TXT_FILE_INFO", $this->lng->txt("file_notice").$max_filesize);
339 
340 
341  $this->fillCloneTemplate('DUPLICATE','grp');
342  }
343 
350  public function saveObject()
351  {
352  global $ilErr,$ilUser;
353 
354  $this->object = new ilObjGroup();
355 
356  $this->load();
357  $ilErr->setMessage('');
358 
359  if(!$this->object->validate())
360  {
361  $err = $this->lng->txt('err_check_input').'<br />';
362  $err .= $this->lng->txt($ilErr->getMessage());
363  ilUtil::sendInfo($err);
364  $this->createObject();
365  return true;
366  }
367 
368  $this->object->create();
369  $this->object->createReference();
370  $this->object->putInTree($_GET["ref_id"]);
371  $this->object->setPermissions($_GET["ref_id"]);
372  $this->object->initDefaultRoles();
373  $this->object->initGroupStatus($this->object->getGroupType());
374 
375 
376  // Add user as admin and enable notification
377  include_once('./Modules/Group/classes/class.ilGroupParticipants.php');
378  $members_obj = ilGroupParticipants::_getInstanceByObjId($this->object->getId());
379  $members_obj->add($ilUser->getId(),IL_GRP_ADMIN);
380  $members_obj->updateNotification($ilUser->getId(),1);
381 
382 
383  // BEGIN ChangeEvent: Record save object.
384  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
386  {
387  ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'create');
388  }
389  // END ChangeEvent: Record save object.
390 
391 
392  ilUtil::sendInfo($this->lng->txt("grp_added"),true);
393  $this->redirectToRefId($_GET["ref_id"]);
394  }
395 
403  public function editObject($a_group_type_warning = false)
404  {
405  $this->checkPermission("write");
406 
407  $this->setSubTabs('settings');
408  $this->tabs_gui->setTabActive('settings');
409  $this->tabs_gui->setSubTabActive('grp_settings');
410 
411  if($a_group_type_warning)
412  {
413  unset($this->form);
414  $this->initForm('update_group_type');
415  }
416  else
417  {
418  $this->initForm('edit');
419  }
420  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.grp_edit.html','Modules/Group');
421  $this->tpl->setVariable('EDIT_FORM',$this->form->getHTML());
422  }
423 
431  public function updateGroupTypeObject()
432  {
433  $this->updateObject(true);
434  }
435 
436 
442  public function updateObject($update_group_type = false)
443  {
444  global $ilErr;
445 
446  $this->checkPermission('write');
447 
448  $old_type = $this->object->getGroupType();
449 
450  $this->load();
451  $ilErr->setMessage('');
452 
453  if(!$this->object->validate())
454  {
455  $err = $this->lng->txt('err_check_input').'<br />';
456  $err .= $this->lng->txt($ilErr->getMessage());
457  ilUtil::sendInfo($err);
458  $this->editObject();
459  return true;
460  }
461 
462  if($this->object->isGroupTypeModified($old_type) and !$update_group_type)
463  {
464  ilUtil::sendInfo($this->lng->txt('grp_warn_grp_type_changed'));
465  $this->editObject(true);
466  return true;
467  }
468  if($update_group_type)
469  {
470  $this->object->updateGroupType();
471  }
472 
473  $this->object->update();
474 
475  // BEGIN ChangeEvents: Record update Object.
476  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
478  {
479  global $ilUser;
480  ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
481  ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
482  }
483  // END PATCH ChangeEvents: Record update Object.
484 
485  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"),true);
486  $this->ctrl->redirect($this,'edit');
487  return true;
488  }
489 
493  public function editGroupIconsObject()
494  {
495  global $rbacsystem;
496 
497  $this->checkPermission('write');
498 
499  $this->setSubTabs("settings");
500  $this->tabs_gui->setTabActive('settings');
501  $this->tabs_gui->setSubTabActive('grp_icon_settings');
502 
503  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.grp_edit_icons.html",'Modules/Group');
504  $this->showCustomIconsEditing();
505  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this,'updateGroupIcons'));
506  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
507  $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
508  $this->tpl->setVariable("CMD_CANCEL", "cancel");
509  $this->tpl->setVariable("CMD_SUBMIT", "updateGroupIcons");
510  $this->tpl->parseCurrentBlock();
511  }
512 
519  public function updateGroupIconsObject()
520  {
521  $this->checkPermission('write');
522 
523  //save custom icons
524  if ($this->ilias->getSetting("custom_icons"))
525  {
526  $this->object->saveIcons($_FILES["cont_big_icon"]['tmp_name'],
527  $_FILES["cont_small_icon"]['tmp_name'], $_FILES["cont_tiny_icon"]['tmp_name']);
528  }
529 
530  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"),true);
531  $this->ctrl->redirect($this,"editGroupIcons");
532  }
533 
539  public function removeSmallIconObject()
540  {
541  $this->object->removeSmallIcon();
542  ilUtil::redirect($this->ctrl->getLinkTarget($this, "editGroupIcons"));
543  }
544 
550  public function removeBigIconObject()
551  {
552  $this->object->removeBigIcon();
553  ilUtil::redirect($this->ctrl->getLinkTarget($this, "editGroupIcons"));
554  }
555 
561  public function removeTinyIconObject()
562  {
563  $this->object->removeTinyIcon();
564  ilUtil::redirect($this->ctrl->getLinkTarget($this, "editGroupIcons"));
565  }
566 
570  public function editMapSettingsObject()
571  {
572  global $ilUser, $ilCtrl, $ilUser, $ilAccess;
573 
574  $this->setSubTabs("settings");
575  $this->tabs_gui->setTabActive('settings');
576  $this->tabs_gui->setSubTabActive('grp_map_settings');
577 
578  include_once('./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php');
580  !$ilAccess->checkAccess("write", "", $this->object->getRefId()))
581  {
582  return;
583  }
584 
585  $latitude = $this->object->getLatitude();
586  $longitude = $this->object->getLongitude();
587  $zoom = $this->object->getLocationZoom();
588 
589  // Get Default settings, when nothing is set
590  if ($latitude == 0 && $longitude == 0 && $zoom == 0)
591  {
593  $latitude = $def["latitude"];
594  $longitude = $def["longitude"];
595  $zoom = $def["zoom"];
596  }
597 
598 
599  //$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_pd_b.gif"), $this->lng->txt("personal_desktop"));
600  //$this->tpl->setVariable("HEADER", $this->lng->txt("personal_desktop"));
601 
602  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
603  $form = new ilPropertyFormGUI();
604  $form->setFormAction($ilCtrl->getFormAction($this));
605 
606  $form->setTitle($this->lng->txt("grp_map_settings"));
607 
608  // enable map
609  $public = new ilCheckboxInputGUI($this->lng->txt("grp_enable_map"),
610  "enable_map");
611  $public->setValue("1");
612  $public->setChecked($this->object->getEnableGroupMap());
613  $form->addItem($public);
614 
615  // map location
616  $loc_prop = new ilLocationInputGUI($this->lng->txt("grp_map_location"),
617  "location");
618  $loc_prop->setLatitude($latitude);
619  $loc_prop->setLongitude($longitude);
620  $loc_prop->setZoom($zoom);
621  $form->addItem($loc_prop);
622 
623  $form->addCommandButton("saveMapSettings", $this->lng->txt("save"));
624 
625  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
626  }
627 
628  public function saveMapSettingsObject()
629  {
630  global $ilCtrl, $ilUser;
631 
632  $this->object->setLatitude(ilUtil::stripSlashes($_POST["location"]["latitude"]));
633  $this->object->setLongitude(ilUtil::stripSlashes($_POST["location"]["longitude"]));
634  $this->object->setLocationZoom(ilUtil::stripSlashes($_POST["location"]["zoom"]));
635  $this->object->setEnableGroupMap(ilUtil::stripSlashes($_POST["enable_map"]));
636  $this->object->update();
637 
638  $ilCtrl->redirect($this, "editMapSettings");
639  }
640 
644  public function membersMapObject()
645  {
646  global $tpl;
647 
648  $this->setSubTabs('members');
649  $this->tabs_gui->setTabActive('members');
650 
651  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
652  if (!ilGoogleMapUtil::isActivated() || !$this->object->getEnableGroupMap())
653  {
654  return;
655  }
656 
657  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapGUI.php");
658  $map = new ilGoogleMapGUI();
659  $map->setMapId("group_map");
660  $map->setWidth("700px");
661  $map->setHeight("500px");
662  $map->setLatitude($this->object->getLatitude());
663  $map->setLongitude($this->object->getLongitude());
664  $map->setZoom($this->object->getLocationZoom());
665  $map->setEnableTypeControl(true);
666  $map->setEnableNavigationControl(true);
667 
668  $member_ids = $this->object->getGroupMemberIds();
669  $admin_ids = $this->object->getGroupAdminIds();
670 
671  // fetch all users data in one shot to improve performance
672  $members = $this->object->getGroupMemberData($member_ids);
673  foreach($member_ids as $user_id)
674  {
675  $map->addUserMarker($user_id);
676  }
677  $tpl->setContent($map->getHTML());
678  $tpl->setLeftContent($map->getUserListHTML());
679  }
680 
681 
688  public function editInfoObject()
689  {
690  global $ilErr,$ilAccess;
691 
692  $this->checkPermission('write');
693 
694  $this->setSubTabs('settings');
695  $this->tabs_gui->setTabActive('settings');
696  $this->tabs_gui->setSubTabActive('grp_info_settings');
697 
698  $this->initInfoEditor();
699  $this->tpl->setContent($this->form->getHTML());
700  }
701 
708  protected function initInfoEditor()
709  {
710  if(is_object($this->form))
711  {
712  return true;
713  }
714 
715  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
716  $this->form = new ilPropertyFormGUI();
717  $this->form->setFormAction($this->ctrl->getFormAction($this,'updateInfo'));
718  $this->form->setTitle($this->lng->txt('grp_general_informations'));
719  $this->form->addCommandButton('updateInfo',$this->lng->txt('save'));
720  $this->form->addCommandButton('editInfo',$this->lng->txt('cancel'));
721 
722  $area = new ilTextAreaInputGUI($this->lng->txt('grp_information'),'important');
723  $area->setInfo($this->lng->txt('grp_information_info'));
724  $area->setValue($this->object->getInformation());
725  $area->setRows(8);
726  $area->setCols(80);
727  $this->form->addItem($area);
728  }
729 
736  public function updateInfoObject()
737  {
738  $this->checkPermission('write');
739 
740  $this->object->setInformation(ilUtil::stripSlashes($_POST['important']));
741  $this->object->update();
742 
743  ilUtil::sendInfo($this->lng->txt("settings_saved"));
744  $this->editInfoObject();
745  return true;
746  }
747 
749 
754  public function membersGalleryObject()
755  {
756  global $rbacsystem, $ilAccess, $ilUser;
757 
758  $is_admin = (bool) $rbacsystem->checkAccess("write", $this->object->getRefId());
759 
760  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.crs_members_gallery.html','Modules/Course');
761 
762  $this->setSubTabs('members');
763  $this->tabs_gui->setTabActive('members');
764 
765  $member_ids = $this->object->getGroupMemberIds();
766  $admin_ids = $this->object->getGroupAdminIds();
767 
768  // fetch all users data in one shot to improve performance
769  $members = $this->object->getGroupMemberData($member_ids);
770 
771  // MEMBERS
772  if(count($members))
773  {
774  $ordered_members = array();
775 
776  foreach($members as $member)
777  {
778  // get user object
779  if(!($usr_obj = ilObjectFactory::getInstanceByObjId($member["id"],false)))
780  {
781  continue;
782  }
783 
784  // please do not use strtoupper on first/last name for output
785  // this messes up with some unicode characters, i guess
786  // depending on php verion, alex
787  array_push($ordered_members,array("id" => $member["id"],
788  "login" => $usr_obj->getLogin(),
789  "lastname" => $usr_obj->getLastName(),
790  "firstname" => $usr_obj->getFirstName(),
791  "sortlastname" => strtoupper($usr_obj->getLastName()).strtoupper($usr_obj->getFirstName()),
792  "usr_obj" => $usr_obj));
793  }
794 
795  $ordered_members=ilUtil::sortArray($ordered_members,"sortlastname","asc");
796 
797  foreach($ordered_members as $member) {
798 
799  $usr_obj = $member["usr_obj"];
800 
801  $public_profile = $usr_obj->getPref("public_profile");
802 
803  // SET LINK TARGET FOR USER PROFILE
804  $this->ctrl->setParameterByClass("ilpublicuserprofilegui", "user", $member["id"]);
805  $profile_target = $this->ctrl->getLinkTargetByClass("ilpublicuserprofilegui","getHTML");
806 
807  // GET USER IMAGE
808  $file = $usr_obj->getPersonalPicturePath("xsmall");
809 
810  switch(in_array($member["id"],$admin_ids))
811  {
812  //admins
813  case 1:
814  if ($public_profile == "y")
815  {
816  $this->tpl->setCurrentBlock("tutor_linked");
817  $this->tpl->setVariable("LINK_PROFILE", $profile_target);
818  $this->tpl->setVariable("SRC_USR_IMAGE", $file);
819  $this->tpl->parseCurrentBlock();
820  }
821  else
822  {
823  $this->tpl->setCurrentBlock("tutor_not_linked");
824  $this->tpl->setVariable("SRC_USR_IMAGE", $file);
825  $this->tpl->parseCurrentBlock();
826  }
827  $this->tpl->setCurrentBlock("tutor");
828  break;
829 
830  case 0:
831  if ($public_profile == "y")
832  {
833  $this->tpl->setCurrentBlock("member_linked");
834  $this->tpl->setVariable("LINK_PROFILE", $profile_target);
835  $this->tpl->setVariable("SRC_USR_IMAGE", $file);
836  $this->tpl->parseCurrentBlock();
837  }
838  else
839  {
840  $this->tpl->setCurrentBlock("member_not_linked");
841  $this->tpl->setVariable("SRC_USR_IMAGE", $file);
842  $this->tpl->parseCurrentBlock();
843  }
844  $this->tpl->setCurrentBlock("member");
845  break;
846  }
847 
848  // do not show name, if public profile is not activated
849  if ($public_profile == "y")
850  {
851  $this->tpl->setVariable("FIRSTNAME", $member["firstname"]);
852  $this->tpl->setVariable("LASTNAME", $member["lastname"]);
853  }
854  $this->tpl->setVariable("LOGIN", $usr_obj->getLogin());
855  $this->tpl->parseCurrentBlock();
856  }
857  $this->tpl->setCurrentBlock("members");
858  //$this->tpl->setVariable("MEMBERS_TABLE_HEADER",$this->lng->txt('crs_members_title'));
859  $this->tpl->parseCurrentBlock();
860  }
861 
862  $this->tpl->setVariable("TITLE",$this->lng->txt('crs_members_print_title'));
863  $this->tpl->setVariable("CSS_PATH",ilUtil::getStyleSheetLocation());
864  }
865 
866 
867  protected function readMemberData($ids,$role = 'admin')
868  {
869  include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
870  $privacy = ilPrivacySettings::_getInstance();
871 
872  if($this->show_tracking)
873  {
874  include_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
875  $completed = ilLPStatusWrapper::_getCompleted($this->object->getId());
876  $in_progress = ilLPStatusWrapper::_getInProgress($this->object->getId());
877  $not_attempted = ilLPStatusWrapper::_getNotAttempted($this->object->getId());
878  $failed = ilLPStatusWrapper::_getFailed($this->object->getId());
879  }
880 
881  if($privacy->enabledGroupAccessTimes())
882  {
883  include_once('./Services/Tracking/classes/class.ilLearningProgress.php');
884  $progress = ilLearningProgress::_lookupProgressByObjId($this->object->getId());
885  }
886 
887  foreach($ids as $usr_id)
888  {
889  $name = ilObjUser::_lookupName($usr_id);
890  $tmp_data['firstname'] = $name['firstname'];
891  $tmp_data['lastname'] = $name['lastname'];
892  $tmp_data['login'] = ilObjUser::_lookupLogin($usr_id);
893  $tmp_data['notification'] = $this->object->members_obj->isNotificationEnabled($usr_id) ? 1 : 0;
894  $tmp_data['usr_id'] = $usr_id;
895  $tmp_data['login'] = ilObjUser::_lookupLogin($usr_id);
896 
897  if($this->show_tracking)
898  {
899  if(in_array($usr_id,$completed))
900  {
901  $tmp_data['progress'] = LP_STATUS_COMPLETED;
902  }
903  elseif(in_array($usr_id,$in_progress))
904  {
905  $tmp_data['progress'] = LP_STATUS_IN_PROGRESS;
906  }
907  elseif(in_array($usr_id,$failed))
908  {
909  $tmp_data['progress'] = LP_STATUS_FAILED;
910  }
911  else
912  {
913  $tmp_data['progress'] = LP_STATUS_NOT_ATTEMPTED;
914  }
915  }
916 
917  if($privacy->enabledGroupAccessTimes())
918  {
919  if(isset($progress[$usr_id]['ts']) and $progress[$usr_id]['ts'])
920  {
921  $tmp_data['access_time'] = ilDatePresentation::formatDate(
922  $tmp_date = new ilDateTime($progress[$usr_id]['ts'],IL_CAL_DATETIME));
923  $tmp_data['access_time_unix'] = $tmp_date->get('IL_CAL_UNIX');
924  }
925  else
926  {
927  $tmp_data['access_time'] = $this->lng->txt('no_date');
928  $tmp_data['access_time_unix'] = 0;
929  }
930  }
931 
932  $members[] = $tmp_data;
933  }
934  return $members ? $members : array();
935  }
936 
943  public function membersObject()
944  {
945  global $ilUser;
946 
947  include_once('./Modules/Group/classes/class.ilGroupParticipants.php');
948  include_once('./Modules/Group/classes/class.ilGroupParticipantsTableGUI.php');
949 
950  $this->checkPermission('write');
951 
952  include_once './Services/Tracking/classes/class.ilObjUserTracking.php';
953  include_once('./Services/Tracking/classes/class.ilLPObjSettings.php');
954  $this->show_tracking = (ilObjUserTracking::_enabledLearningProgress() and
956  ilLPObjSettings::_lookupMode($this->object->getId()) != LP_MODE_DEACTIVATED);
957 
958 
959  $part = ilGroupParticipants::_getInstanceByObjId($this->object->getId());
960 
961  $this->setSubTabs('members');
962  $this->tabs_gui->setTabActive('members');
963  $this->tabs_gui->setSubTabActive('grp_edit_members');
964 
965  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.grp_edit_members.html','Modules/Group');
966  $this->tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this));
967 
968  // add members
969  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
970  $this->tpl->setCurrentBlock("btn_cell");
971  $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTargetByClass('ilRepositorySearchGUI','start'));
972  $this->tpl->setVariable("BTN_TXT",$this->lng->txt("grp_add_member"));
973  $this->tpl->parseCurrentBlock();
974 
975  $this->setShowHidePrefs();
976 
977 
978  // Waiting list table
979  include_once('./Modules/Group/classes/class.ilGroupWaitingList.php');
980  $waiting_list = new ilGroupWaitingList($this->object->getId());
981  if(count($wait = $waiting_list->getAllUsers()))
982  {
983  include_once('./Services/Membership/classes/class.ilWaitingListTableGUI.php');
984  if($ilUser->getPref('grp_wait_hide'))
985  {
986  $table_gui = new ilWaitingListTableGUI($this,$waiting_list,false);
987  $this->ctrl->setParameter($this,'wait_hide',0);
988  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
989  $this->lng->txt('show'),
990  '',
991  ilUtil::getImagePath('edit_add.png'));
992  $this->ctrl->clearParameters($this);
993  }
994  else
995  {
996  $table_gui = new ilWaitingListTableGUI($this,$waiting_list,true);
997  $this->ctrl->setParameter($this,'wait_hide',1);
998  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
999  $this->lng->txt('hide'),
1000  '',
1001  ilUtil::getImagePath('edit_remove.png'));
1002  $this->ctrl->clearParameters($this);
1003  }
1004  $table_gui->setUsers($wait);
1005  $table_gui->setTitle($this->lng->txt('grp_header_waiting_list'),'icon_usr.gif',$this->lng->txt('group_new_registrations'));
1006  $this->tpl->setVariable('TABLE_SUB',$table_gui->getHTML());
1007  }
1008 
1009 
1010  // Subscriber table
1011  if(count($subscribers = $part->getSubscribers()))
1012  {
1013  include_once('./Services/Membership/classes/class.ilSubscriberTableGUI.php');
1014  if($ilUser->getPref('grp_subscriber_hide'))
1015  {
1016  $table_gui = new ilSubscriberTableGUI($this,$part,false);
1017  $this->ctrl->setParameter($this,'subscriber_hide',0);
1018  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1019  $this->lng->txt('show'),
1020  '',
1021  ilUtil::getImagePath('edit_add.png'));
1022  $this->ctrl->clearParameters($this);
1023  }
1024  else
1025  {
1026  $table_gui = new ilSubscriberTableGUI($this,$part,true);
1027  $this->ctrl->setParameter($this,'subscriber_hide',1);
1028  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1029  $this->lng->txt('hide'),
1030  '',
1031  ilUtil::getImagePath('edit_remove.png'));
1032  $this->ctrl->clearParameters($this);
1033  }
1034  $table_gui->setSubscribers($subscribers);
1035  $table_gui->setTitle($this->lng->txt('group_new_registrations'),'icon_usr.gif',$this->lng->txt('group_new_registrations'));
1036  $this->tpl->setVariable('TABLE_SUB',$table_gui->getHTML());
1037  }
1038 
1039  if(count($part->getAdmins()))
1040  {
1041  if($ilUser->getPref('grp_admin_hide'))
1042  {
1043  $table_gui = new ilGroupParticipantsTableGUI($this,'admin',false,$this->show_tracking);
1044  $this->ctrl->setParameter($this,'admin_hide',0);
1045  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1046  $this->lng->txt('show'),
1047  '',
1048  ilUtil::getImagePath('edit_add.png'));
1049  $this->ctrl->clearParameters($this);
1050  }
1051  else
1052  {
1053  $table_gui = new ilGroupParticipantsTableGUI($this,'admin',true,$this->show_tracking);
1054  $this->ctrl->setParameter($this,'admin_hide',1);
1055  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1056  $this->lng->txt('hide'),
1057  '',
1058  ilUtil::getImagePath('edit_remove.png'));
1059  $this->ctrl->clearParameters($this);
1060  }
1061  $table_gui->setTitle($this->lng->txt('grp_admins'),'icon_usr.gif',$this->lng->txt('grp_admins'));
1062  $table_gui->setData($this->readMemberData($part->getAdmins()));
1063  $this->tpl->setVariable('ADMINS',$table_gui->getHTML());
1064  }
1065 
1066  if(count($part->getMembers()))
1067  {
1068  if($ilUser->getPref('grp_member_hide'))
1069  {
1070  $table_gui = new ilGroupParticipantsTableGUI($this,'member',false,$this->show_tracking);
1071  $this->ctrl->setParameter($this,'member_hide',0);
1072  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1073  $this->lng->txt('show'),
1074  '',
1075  ilUtil::getImagePath('edit_add.png'));
1076  $this->ctrl->clearParameters($this);
1077  }
1078  else
1079  {
1080  $table_gui = new ilGroupParticipantsTableGUI($this,'member',true,$this->show_tracking);
1081  $this->ctrl->setParameter($this,'member_hide',1);
1082  $table_gui->addHeaderCommand($this->ctrl->getLinkTarget($this,'members'),
1083  $this->lng->txt('hide'),
1084  '',
1085  ilUtil::getImagePath('edit_remove.png'));
1086  $this->ctrl->clearParameters($this);
1087  }
1088 
1089  $table_gui->setTitle($this->lng->txt('grp_members'),'icon_usr.gif',$this->lng->txt('grp_members'));
1090  $table_gui->setData($this->readMemberData($part->getMembers()));
1091  $this->tpl->setVariable('MEMBERS',$table_gui->getHTML());
1092 
1093  }
1094 
1095  $this->tpl->setVariable('TXT_SELECTED_USER',$this->lng->txt('grp_selected_users'));
1096  $this->tpl->setVariable('BTN_FOOTER_EDIT',$this->lng->txt('edit'));
1097  $this->tpl->setVariable('BTN_FOOTER_VAL',$this->lng->txt('remove'));
1098  $this->tpl->setVariable('BTN_FOOTER_MAIL',$this->lng->txt('grp_mem_send_mail'));
1099  $this->tpl->setVariable('ARROW_DOWN',ilUtil::getImagePath('arrow_downright.gif'));
1100 
1101  }
1102 
1109  public function assignSubscribersObject()
1110  {
1111  global $lng, $ilIliasIniFile,$ilUser;
1112 
1113  $this->checkPermission('write');
1114 
1115  if(!count($_POST['subscribers']))
1116  {
1117  ilUtil::sendInfo($this->lng->txt('no_checkbox'));
1118  $this->membersObject();
1119  return false;
1120  }
1121 
1122  foreach($_POST['subscribers'] as $usr_id)
1123  {
1124  $mail = new ilMail($ilUser->getId());
1125 
1126  // XXX - The message should be sent in the language of the receiver,
1127  // instead of in the language of the current user
1128  $mail->sendMail(ilObjUser::_lookupLogin($usr_id),"","",
1129  sprintf($lng->txt('grp_accept_subscriber'), $this->object->getTitle()),
1130  sprintf(str_replace('\n',"\n",$lng->txt('grp_accept_subscriber_body')),
1131  $this->object->getTitle(), $ilIliasIniFile->readVariable('server','http_path').'/goto.php?client_id='.CLIENT_ID.'&target=grp_'.$this->object->getRefId()),
1132  array(),array('system'));
1133  $this->object->members_obj->add($usr_id,IL_GRP_MEMBER);
1134  $this->object->members_obj->deleteSubscriber($usr_id);
1135  }
1136  ilUtil::sendInfo($this->lng->txt("grp_msg_applicants_assigned"));
1137  $this->membersObject();
1138  return true;
1139  }
1140 
1147  public function refuseSubscribersObject()
1148  {
1149  global $lng;
1150 
1151  $this->checkPermission('write');
1152 
1153  if(!count($_POST['subscribers']))
1154  {
1155  ilUtil::sendInfo($this->lng->txt('no_checkbox'));
1156  $this->membersObject();
1157  return false;
1158  }
1159 
1160  foreach($_POST['subscribers'] as $usr_id)
1161  {
1162  $mail = new ilMail($_SESSION["AccountId"]);
1163  // XXX - The message should be sent in the language of the receiver,
1164  // instead of in the language of the current user
1165  $mail->sendMail(ilObjUser::_lookupLogin($usr_id),"","",
1166  sprintf($lng->txt('grp_reject_subscriber'), $this->object->getTitle()),
1167  sprintf(str_replace('\n',"\n",$lng->txt('grp_reject_subscriber_body')),
1168  $this->object->getTitle()),
1169  array(),array('system'));
1170  $this->object->members_obj->deleteSubscriber($usr_id);
1171  }
1172  ilUtil::sendInfo($this->lng->txt("grp_msg_applicants_removed"));
1173  $this->membersObject();
1174  return true;
1175 
1176  }
1177 
1186  {
1187  $this->checkPermission('write');
1188 
1189  if(!count($_POST["waiting"]))
1190  {
1191  ilUtil::sendInfo($this->lng->txt("no_checkbox"));
1192  $this->membersObject();
1193  return false;
1194  }
1195 
1196  include_once('./Modules/Group/classes/class.ilGroupWaitingList.php');
1197  $waiting_list = new ilGroupWaitingList($this->object->getId());
1198 
1199  $added_users = 0;
1200  foreach($_POST["waiting"] as $user_id)
1201  {
1202  if(!$tmp_obj = ilObjectFactory::getInstanceByObjId($user_id,false))
1203  {
1204  continue;
1205  }
1206  if($this->object->members_obj->isAssigned($user_id))
1207  {
1208  continue;
1209  }
1210  $this->object->members_obj->add($user_id,IL_GRP_MEMBER);
1211  #$this->object->members_obj->sendNotification($this->object->members_obj->NOTIFY_ACCEPT_USER,$user_id);
1212  $waiting_list->removeFromList($user_id);
1213 
1214  ++$added_users;
1215  }
1216  if($added_users)
1217  {
1218  ilUtil::sendInfo($this->lng->txt("grp_users_added"));
1219  $this->membersObject();
1220 
1221  return true;
1222  }
1223  else
1224  {
1225  ilUtil::sendInfo($this->lng->txt("grp_users_already_assigned"));
1226  $this->searchObject();
1227 
1228  return false;
1229  }
1230  }
1231 
1238  public function refuseFromListObject()
1239  {
1240  $this->checkPermission('write');
1241 
1242  if(!count($_POST['waiting']))
1243  {
1244  ilUtil::sendInfo($this->lng->txt('no_checkbox'));
1245  $this->membersObject();
1246  return false;
1247  }
1248 
1249  include_once('./Modules/Group/classes/class.ilGroupWaitingList.php');
1250  $waiting_list = new ilGroupWaitingList($this->object->getId());
1251 
1252  foreach($_POST["waiting"] as $user_id)
1253  {
1254  $waiting_list->removeFromList($user_id);
1255  }
1256 
1257  ilUtil::sendInfo($this->lng->txt('grp_users_removed_from_list'));
1258  $this->membersObject();
1259  return true;
1260  }
1261 
1267  public function confirmDeleteMembersObject()
1268  {
1269  $this->checkPermission('write');
1270 
1271  $this->setSubTabs('members');
1272  $this->tabs_gui->setTabActive('members');
1273  $this->tabs_gui->setSubTabActive('grp_edit_members');
1274 
1275  if(!count($_POST['admins']) and !count($_POST['members']))
1276  {
1277  ilUtil::sendInfo($this->lng->txt('no_checkbox'));
1278  $this->membersObject();
1279  return true;
1280  }
1281 
1282  include_once('./Services/Utilities/classes/class.ilConfirmationGUI.php');
1283  $confirm = new ilConfirmationGUI();
1284  $confirm->setFormAction($this->ctrl->getFormAction($this,'deleteMembers'));
1285  $confirm->setHeaderText($this->lng->txt('grp_dismiss_member'));
1286  $confirm->setConfirm($this->lng->txt('confirm'),'deleteMembers');
1287  $confirm->setCancel($this->lng->txt('cancel'),'members');
1288 
1289  foreach($this->readMemberData(array_merge((array) $_POST['admins'],(array) $_POST['members'])) as $participants)
1290  {
1291  $confirm->addItem('participants[]',
1292  $participants['usr_id'],
1293  $participants['lastname'].', '.$participants['firstname'].' ['.$participants['login'].']',
1294  ilUtil::getImagePath('icon_usr.gif'));
1295  }
1296 
1297  $this->tpl->setContent($confirm->getHTML());
1298  }
1299 
1307  public function deleteMembersObject()
1308  {
1309  $this->checkPermission('write');
1310 
1311  if(!count($_POST['participants']))
1312  {
1313  ilUtil::sendInfo($this->lng->txt('no_checkbox'));
1314  $this->membersObject();
1315  return true;
1316  }
1317 
1318  $this->object->members_obj->deleteParticipants($_POST['participants']);
1319  ilUtil::sendInfo($this->lng->txt("grp_msg_membership_annulled"));
1320  $this->membersObject();
1321  return true;
1322  }
1323 
1332  {
1333  if(isset($_GET['member_id']))
1334  {
1335  $_POST['participants'] = array($_GET['member_id']);
1336  }
1337  else
1338  {
1339  $_POST['participants'] = array_unique(array_merge((array) $_POST['admins'],
1340  (array) $_POST['members'],
1341  (array) $_POST['waiting'],
1342  (array) $_POST['subscribers']));
1343  }
1344  if (!count($_POST['participants']))
1345  {
1346  ilUtil::sendInfo($this->lng->txt("no_checkbox"));
1347  $this->membersObject();
1348  return false;
1349  }
1350  foreach($_POST['participants'] as $usr_id)
1351  {
1352  $rcps[] = ilObjUser::_lookupLogin($usr_id);
1353  }
1354  ilUtil::redirect("ilias.php?baseClass=ilmailgui&type=new&rcp_to=".implode(',',$rcps));
1355  return true;
1356  }
1357 
1364  public function setShowHidePrefs()
1365  {
1366  global $ilUser;
1367 
1368  if(isset($_GET['admin_hide']))
1369  {
1370  $ilUser->writePref('grp_admin_hide',(int) $_GET['admin_hide']);
1371  }
1372  if(isset($_GET['member_hide']))
1373  {
1374  $ilUser->writePref('grp_member_hide',(int) $_GET['member_hide']);
1375  }
1376  if(isset($_GET['subscriber_hide']))
1377  {
1378  $ilUser->writePref('grp_subscriber_hide',(int) $_GET['subscriber_hide']);
1379  }
1380  if(isset($_GET['wait_hide']))
1381  {
1382  $ilUser->writePref('grp_wait_hide',(int) $_GET['wait_hide']);
1383  }
1384  }
1385 
1391  public function editMemberObject()
1392  {
1393  $_POST['members'] = array((int) $_GET['member_id']);
1394  $this->editMembersObject();
1395  }
1396 
1403  public function editMembersObject()
1404  {
1405  $this->checkPermission('write');
1406 
1407  $participants = array_unique(array_merge((array) $_POST['admins'],(array) $_POST['members']));
1408 
1409  if(!count($participants))
1410  {
1411  ilUtil::sendInfo($this->lng->txt('no_checkbox'));
1412  $this->membersObject();
1413  return false;
1414  }
1415 
1416  $this->setSubTabs('members');
1417  $this->tabs_gui->setTabActive('members');
1418  $this->tabs_gui->setSubTabActive('grp_edit_members');
1419 
1420  include_once('./Modules/Group/classes/class.ilGroupEditParticipantsTableGUI.php');
1421  $table_gui = new ilGroupEditParticipantsTableGUI($this);
1422  $table_gui->setTitle($this->lng->txt('grp_mem_change_status'),'icon_usr.gif',$this->lng->txt('grp_mem_change_status'));
1423  $table_gui->setData($this->readMemberData($participants));
1424 
1425  $this->tpl->setContent($table_gui->getHTML());
1426  return true;
1427  }
1428 
1436  public function updateMembersObject()
1437  {
1438  $this->checkPermission('write');
1439 
1440  if(!count($_POST['participants']))
1441  {
1442  ilUtil::sendInfo($this->lng->txt('no_checkbox'));
1443  $this->membersObject();
1444  return false;
1445  }
1446 
1447  $notifications = $_POST['notification'] ? $_POST['notification'] : array();
1448  foreach($_POST['participants'] as $usr_id)
1449  {
1450  // TODO: check no role, owner, self status changed
1451  $this->object->members_obj->updateRoleAssignments($usr_id,(array) $_POST['roles'][$usr_id]);
1452 
1453  // Disable notification for all of them
1454  $this->object->members_obj->updateNotification($usr_id,0);
1455 
1456  if($this->object->members_obj->isAdmin($usr_id) and in_array($usr_id,$notifications))
1457  {
1458  $this->object->members_obj->updateNotification($usr_id,1);
1459  }
1460  }
1461  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"));
1462  $this->membersObject();
1463  return true;
1464  }
1465 
1473  public function updateStatusObject()
1474  {
1475  $this->checkPermission('write');
1476 
1477  $notification = $_POST['notification'] ? $_POST['notification'] : array();
1478  foreach($this->object->members_obj->getAdmins() as $admin_id)
1479  {
1480  $this->object->members_obj->updateNotification($admin_id,(int) in_array($admin_id,$notification));
1481  }
1482  ilUtil::sendInfo($this->lng->txt('settings_saved'));
1483  $this->membersObject();
1484  }
1485 
1486 
1487 
1489  {
1490  global $rbacsystem;
1491 
1492  $this->tabs_gui->setTabActive('export');
1493 
1494  $this->lng->loadLanguageModule('content');
1495 
1496  if (!$rbacsystem->checkAccess("write",$this->object->getRefId()))
1497  {
1498  $this->ilErr->raiseError($this->lng->txt("permission_denied"),$this->ilErr->MESSAGE);
1499  }
1500 
1501  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
1502  $this->__exportMenu();
1503 
1504  $this->object->__initFileObject();
1505  $export_files = $this->object->file_obj->getExportFiles();
1506 
1507  require_once("./Services/Table/classes/class.ilTableGUI.php");
1508  $tbl = new ilTableGUI();
1509 
1510  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
1511  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.grp_export_file_row.html");
1512 
1513  $num = 0;
1514 
1515  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1516 
1517  $tbl->setTitle($this->lng->txt("cont_export_files"));
1518  $tbl->setHeaderNames(array("", $this->lng->txt("type"),
1519  $this->lng->txt("cont_file"),
1520  $this->lng->txt("cont_size"), $this->lng->txt("date") ));
1521 
1522  $cols = array("", "type", "file", "size", "date");
1523  $header_params = array("ref_id" => $_GET["ref_id"],
1524  "cmd" => "listExportFiles", "cmdClass" => strtolower(get_class($this)));
1525  $tbl->setHeaderVars($cols, $header_params);
1526  $tbl->setColumnWidth(array("1%", "9%", "40%", "25%", "25%"));
1527 
1528  // control
1529  $tbl->setOrderColumn($_GET["sort_by"]);
1530  $tbl->setOrderDirection($_GET["sort_order"]);
1531  $tbl->setLimit($_GET["limit"]);
1532  $tbl->setOffset($_GET["offset"]);
1533  $tbl->setMaxCount($this->maxcount); // ???
1534  $tbl->disable("sort");
1535 
1536  $this->tpl->setVariable("COLUMN_COUNTS", 5);
1537 
1538  // delete button
1539  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
1540  $this->tpl->setCurrentBlock("tbl_action_btn");
1541  $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
1542  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
1543  $this->tpl->parseCurrentBlock();
1544 
1545  $this->tpl->setCurrentBlock("tbl_action_btn");
1546  $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
1547  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
1548  $this->tpl->parseCurrentBlock();
1549 
1550  // footer
1551  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1552 
1553  $tbl->setMaxCount(count($export_files));
1554  $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
1555  $tbl->render();
1556  foreach($export_files as $exp_file)
1557  {
1558  $this->tpl->setCurrentBlock("tbl_content");
1559  $this->tpl->setVariable("TXT_FILENAME", $exp_file["file"]);
1560 
1561  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
1562  $this->tpl->setVariable("CSS_ROW", $css_row);
1563 
1564  $this->tpl->setVariable("TXT_SIZE", $exp_file["size"]);
1565  $this->tpl->setVariable("TXT_TYPE", $exp_file["type"]);
1566  $this->tpl->setVariable("CHECKBOX_ID",$exp_file["file"]);
1567 
1568  $file_arr = explode("__", $exp_file["file"]);
1569  $this->tpl->setVariable('TXT_DATE',ilDatePresentation::formatDate(new ilDateTime($file_arr[0],IL_CAL_UNIX)));
1570 
1571 
1572  $this->tpl->parseCurrentBlock();
1573  }
1574  if(!count($export_files))
1575  {
1576  $tbl->disable('footer');
1577  $this->tpl->setCurrentBlock("notfound");
1578  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
1579  $this->tpl->setVariable("NUM_COLS", 4);
1580  $this->tpl->parseCurrentBlock();
1581  }
1582 
1583  $this->tpl->parseCurrentBlock();
1584  }
1585 
1586  function __exportMenu()
1587  {
1588  // create xml export file button
1589  $this->tpl->setCurrentBlock("btn_cell");
1590  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "exportXML"));
1591  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("cont_create_export_file_xml"));
1592  $this->tpl->parseCurrentBlock();
1593  }
1594 
1595  function exportXMLObject()
1596  {
1597  global $rbacsystem;
1598 
1599  if (!$rbacsystem->checkAccess("write",$this->object->getRefId()))
1600  {
1601  $this->ilErr->raiseError($this->lng->txt("permission_denied"),$this->ilErr->MESSAGE);
1602  }
1603 
1604  $this->object->exportXML();
1605 
1606  $this->listExportFilesObject();
1607 
1608  return true;
1609  }
1610 
1612  {
1613  global $rbacsystem;
1614 
1615  if (!$rbacsystem->checkAccess("write",$this->object->getRefId()))
1616  {
1617  $this->ilErr->raiseError($this->lng->txt("permission_denied"),$this->ilErr->MESSAGE);
1618  }
1619 
1620  if(!count($_POST['file']))
1621  {
1622  ilUtil::sendInfo($this->lng->txt('grp_select_one_file'));
1623  }
1624  else
1625  {
1626  $this->object->deleteExportFiles($_POST['file']);
1627  ilUtil::sendInfo($this->lng->txt('grp_deleted_export_files'));
1628  }
1629 
1630  $this->listExportFilesObject();
1631 
1632  return true;
1633  }
1634 
1636  {
1637  if(!count($_POST['file']))
1638  {
1639  ilUtil::sendInfo($this->lng->txt('grp_select_one_file'));
1640  $this->listExportFilesObject();
1641  return false;
1642  }
1643  if(count($_POST['file']) > 1)
1644  {
1645  ilUtil::sendInfo($this->lng->txt('grp_select_one_file_only'));
1646  $this->listExportFilesObject();
1647  return false;
1648  }
1649 
1650  $this->object->downloadExportFile(ilUtil::stripSlashes($_POST['file'][0]));
1651 
1652  // If file wasn't sent
1653  ilUtil::sendInfo($this->lng->txt('grp_error_sending_file'));
1654 
1655  return true;
1656  }
1657 
1658 
1659 
1660 
1665  function canceledObject()
1666  {
1667  $return_location = $_GET["cmd_return_location"];
1668  if (strcmp($return_location, "") == 0)
1669  {
1670  $return_location = "";
1671  }
1672 
1673  ilUtil::sendInfo($this->lng->txt("action_aborted"),true);
1674  $this->ctrl->redirect($this, $return_location);
1675  }
1676 
1677 
1678 
1683  public function leaveObject()
1684  {
1685  $this->checkPermission('leave');
1686 
1687  $this->tabs_gui->setTabActive('grp_btn_unsubscribe');
1688 
1689  $tpl = new ilTemplate('tpl.unsubscribe.html',true,true,'Modules/Group');
1690  $tpl->setVariable('UNSUB_FORMACTION',$this->ctrl->getFormAction($this));
1691  $tpl->setVariable('TXT_SUBMIT',$this->lng->txt('grp_btn_unsubscribe'));
1692  $tpl->setVariable('TXT_CANCEL',$this->lng->txt('cancel'));
1693 
1694  ilUtil::sendInfo($this->lng->txt('grp_dismiss_myself'));
1695  $this->tpl->setContent($tpl->get());
1696  }
1697 
1704  public function unsubscribeObject()
1705  {
1706  global $ilUser,$tree;
1707 
1708  $this->checkPermission('leave');
1709 
1710  $this->object->members_obj->delete($ilUser->getId());
1711 
1712  ilUtil::sendInfo($this->lng->txt('grp_msg_membership_annulled'));
1713  ilUtil::redirect('repository.php?ref_id='.$tree->getParentId($this->object->getRefId()));
1714  }
1715 
1716 
1722  {
1723  $user_ids = $_POST["id"];
1724 
1725  if (empty($user_ids[0]))
1726  {
1727  // TODO: jumps back to grp content. go back to last search result
1728  $this->ilErr->raiseError($this->lng->txt("no_checkbox"),$this->ilErr->MESSAGE);
1729  }
1730 
1731  foreach ($user_ids as $new_member)
1732  {
1733  if (!$this->object->addMember($new_member,$this->object->getDefaultMemberRole()))
1734  {
1735  $this->ilErr->raiseError("An Error occured while assigning user to group !",$this->ilErr->MESSAGE);
1736  }
1737  }
1738 
1739  unset($_SESSION["saved_post"]);
1740 
1741  ilUtil::sendInfo($this->lng->txt("grp_msg_member_assigned"),true);
1742  ilUtil::redirect($this->ctrl->getLinkTarget($this,"members"));
1743  }
1744 
1749  function addUserObject()
1750  {
1751  $user_ids = $_POST["user"];
1752 
1753  $mail = new ilMail($_SESSION["AccountId"]);
1754 
1755  if (empty($user_ids[0]))
1756  {
1757  // TODO: jumps back to grp content. go back to last search result
1758  #$this->ilErr->raiseError($this->lng->txt("no_checkbox"),$this->ilErr->MESSAGE);
1759  ilUtil::sendInfo($this->lng->txt("no_checkbox"));
1760 
1761  return false;
1762  }
1763 
1764  foreach ($user_ids as $new_member)
1765  {
1766  if (!$this->object->addMember($new_member,$this->object->getDefaultMemberRole()))
1767  {
1768  $this->ilErr->raiseError("An Error occured while assigning user to group !",$this->ilErr->MESSAGE);
1769  }
1770 
1771  $user_obj = $this->ilias->obj_factory->getInstanceByObjId($new_member);
1772 
1773  // SEND A SYSTEM MESSAGE EACH TIME A MEMBER IS ADDED TO THE GROUP
1774  $user_obj->addDesktopItem($this->object->getRefId(),"grp");
1775  $mail->sendMail($user_obj->getLogin(),"","",$this->lng->txtlng("common","grp_mail_subj_new_subscription",$user_obj->getLanguage()).": ".$this->object->getTitle(),$this->lng->txtlng("common","grp_mail_body_new_subscription",$user_obj->getLanguage()),array(),array('system'));
1776 
1777  unset($user_obj);
1778  }
1779 
1780  unset($_SESSION["saved_post"]);
1781  unset($_SESSION['grp_usr_search_result']);
1782 
1783  ilUtil::sendInfo($this->lng->txt("grp_msg_member_assigned"),true);
1784  ilUtil::redirect($this->ctrl->getLinkTarget($this,"members"));
1785  }
1786 
1791  {
1792  global $rbacreview, $ilObjDataCache;
1793  include_once('./Services/AccessControl/classes/class.ilObjRole.php');
1794 
1795  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.mail_members.html',"Services/Mail");
1796 
1797  $this->setSubTabs('members');
1798  $this->tabs_gui->setTabActive('members');
1799 
1800  $this->tpl->setVariable("MAILACTION",'ilias.php?baseClass=ilMailGUI&type=role');
1801  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
1802  $this->tpl->setVariable("TXT_MARKED_ENTRIES",$this->lng->txt('marked_entries'));
1803  $this->tpl->setVariable("OK",$this->lng->txt('ok'));
1804 
1805  // Get role mailbox addresses
1806  $role_folder = $rbacreview->getRoleFolderOfObject($this->object->getRefId());
1807  $role_ids = $rbacreview->getRolesOfRoleFolder($role_folder['ref_id'], false);
1808  $role_addrs = array();
1809 
1810  // Sort by relevance
1811  $sorted_role_ids = array();
1812  $counter = 2;
1813  foreach($role_ids as $role_id)
1814  {
1815  switch(substr(ilObject::_lookupTitle($role_id),0,8))
1816  {
1817  case 'il_grp_a':
1818  $sorted_role_ids[1] = $role_id;
1819  break;
1820 
1821  case 'il_grp_m':
1822  $sorted_role_ids[0] = $role_id;
1823  break;
1824 
1825  default:
1826  $sorted_role_ids[$counter++] = $role_id;
1827  break;
1828  }
1829  }
1830  ksort($sorted_role_ids,SORT_NUMERIC);
1831  foreach ((array) $sorted_role_ids as $role_id)
1832  {
1833  $this->tpl->setCurrentBlock("mailbox_row");
1834  $role_addr = $rbacreview->getRoleMailboxAddress($role_id);
1835  $this->tpl->setVariable("CHECK_MAILBOX",ilUtil::formCheckbox(1,'roles[]',
1836  htmlspecialchars($role_addr)
1837  ));
1838 
1839  if (ilMail::_usePearMail())
1840  {
1841  // if pear mail is enabled, mailbox addresses are already localized in the language of the user
1842  $this->tpl->setVariable("MAILBOX",$role_addr);
1843  }
1844  else
1845  {
1846  // if pear mail is not enabled, we need to localize mailbox addresses in the language of the user
1847  $this->tpl->setVariable("MAILBOX",ilObjRole::_getTranslation($ilObjDataCache->lookupTitle($role_id)) . " (".$role_addr.")");
1848  }
1849  $this->tpl->parseCurrentBlock();
1850  }
1851  }
1852 
1858  {
1859  $user_ids = $_POST["user_id"];
1860 
1861  if (empty($user_ids[0]))
1862  {
1863  $this->ilErr->raiseError($this->lng->txt("no_checkbox"),$this->ilErr->MESSAGE);
1864  }
1865 
1866  $mail = new ilMail($_SESSION["AccountId"]);
1867 
1868  foreach ($user_ids as $new_member)
1869  {
1870  $user =& $this->ilias->obj_factory->getInstanceByObjId($new_member);
1871 
1872  $this->object->deleteApplicationListEntry($new_member);
1873  $mail->sendMail($user->getLogin(),"","","Membership application refused: Group ".$this->object->getTitle(),"Your application has been refused.",array(),array('system'));
1874  }
1875 
1876  ilUtil::sendInfo($this->lng->txt("grp_msg_applicants_removed"),true);
1877  ilUtil::redirect($this->ctrl->getLinkTarget($this,"members"));
1878  }
1879 
1880  // get tabs
1881  function getTabs(&$tabs_gui)
1882  {
1883  global $rbacsystem,$ilUser,$ilAccess;
1884 
1885  if ($rbacsystem->checkAccess('read',$this->ref_id))
1886  {
1887  $force_active = (($_GET["cmd"] == "view" || $_GET["cmd"] == "")
1888  && $_GET["cmdClass"] == "")
1889  ? true
1890  : false;
1891  $tabs_gui->addTarget("view_content",
1892  $this->ctrl->getLinkTarget($this, ""), array("", "view","addToDesk","removeFromDesk"), get_class($this),
1893  "", $force_active);
1894  }
1895  if ($rbacsystem->checkAccess('visible',$this->ref_id))
1896  {
1897  $tabs_gui->addTarget("info_short",
1898  $this->ctrl->getLinkTargetByClass(
1899  array("ilobjgroupgui", "ilinfoscreengui"), "showSummary"),
1900  "infoScreen",
1901  "", "",false);
1902  }
1903 
1904 
1905  if ($ilAccess->checkAccess('write','',$this->object->getRefId()))
1906  {
1907  $tabs_gui->addTarget("settings",
1908  $this->ctrl->getLinkTarget($this, "edit"), array("edit", "editMapSettings"), get_class($this),
1909  "");
1910  }
1911 
1912  // Members
1913  if($ilAccess->checkAccess('read','',$this->object->getRefId()))
1914  {
1915  $mem_cmd = $ilAccess->checkAccess('write','',$this->ref_id) ? "members" : "membersGallery";
1916  $tabs_gui->addTarget("members",$this->ctrl->getLinkTarget($this, $mem_cmd), array(),get_class($this));
1917  }
1918 
1919 
1920  // learning progress
1921  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
1922  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()))
1923  {
1924  $tabs_gui->addTarget('learning_progress',
1925  $this->ctrl->getLinkTargetByClass(array('ilobjgroupgui','illearningprogressgui'),''),
1926  '',
1927  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
1928  }
1929 
1930  if ($rbacsystem->checkAccess('write',$this->object->getRefId()))
1931  {
1932  $tabs_gui->addTarget('export',
1933  $this->ctrl->getLinkTarget($this,'listExportFiles'),
1934  array('listExportFiles','exportXML','confirmDeleteExportFile','downloadExportFile'),
1935  get_class($this));
1936  }
1937 
1938  // parent tabs (all container: edit_permission, clipboard, trash
1939  parent::getTabs($tabs_gui);
1940 
1941  if($ilAccess->checkAccess('join','',$this->object->getRefId()) and
1942  !$this->object->members_obj->isAssigned($ilUser->getId()))
1943  {
1944  $tabs_gui->addTarget("join",
1945  $this->ctrl->getLinkTargetByClass('ilgroupregistrationgui', "show"),
1946  '',
1947  "");
1948  }
1949  if($ilAccess->checkAccess('leave','',$this->object->getRefId()) and
1950  $this->object->members_obj->isMember($ilUser->getId()))
1951  {
1952  $tabs_gui->addTarget("grp_btn_unsubscribe",
1953  $this->ctrl->getLinkTarget($this, "leave"),
1954  '',
1955  "");
1956  }
1957  }
1958 
1959 
1960  // IMPORT FUNCTIONS
1961 
1962  function importFileObject()
1963  {
1964  if(!is_array($_FILES['xmldoc']))
1965  {
1966  ilUtil::sendInfo($this->lng->txt("import_file_not_valid"));
1967  $this->createObject();
1968  return false;
1969  }
1970 
1971  include_once './Modules/Group/classes/class.ilObjGroup.php';
1972 
1973  if($ref_id = ilObjGroup::_importFromFile($_FILES['xmldoc'],(int) $_GET['ref_id']))
1974  {
1975  $this->ctrl->setParameter($this, "ref_id", $ref_id);
1976  ilUtil::sendInfo($this->lng->txt("import_grp_finished"),true);
1977  ilUtil::redirect($this->ctrl->getLinkTarget($this,'edit'));
1978  }
1979 
1980  ilUtil::sendInfo($this->lng->txt("import_file_not_valid"));
1981  $this->createObject();
1982  }
1983 
1984  // Methods for ConditionHandlerInterface
1985  function initConditionHandlerGUI($item_id)
1986  {
1987  include_once './classes/class.ilConditionHandlerInterface.php';
1988 
1989  if(!is_object($this->chi_obj))
1990  {
1991  if($_GET['item_id'])
1992  {
1993  $this->chi_obj =& new ilConditionHandlerInterface($this,$item_id);
1994  $this->ctrl->saveParameter($this,'item_id',$_GET['item_id']);
1995  }
1996  else
1997  {
1998  $this->chi_obj =& new ilConditionHandlerInterface($this);
1999  }
2000  }
2001  return true;
2002  }
2003 
2004 
2011  function exportObject()
2012  {
2013  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.grp_members_export.html");
2014  $this->tpl->setCurrentBlock("adm_content");
2015  $this->tpl->setVariable("FORMACTION", $this->getFormAction("export",$this->ctrl->getFormAction($this)));
2016  $this->tpl->setVariable("BUTTON_EXPORT", $this->lng->txt("export_group_members"));
2017  $this->tpl->parseCurrentBlock();
2018  }
2019 
2027  {
2028  $title = preg_replace("/\s/", "_", $this->object->getTitle());
2029  include_once "./classes/class.ilExcelWriterAdapter.php";
2030  $adapter = new ilExcelWriterAdapter("export_" . $title . ".xls");
2031  $workbook = $adapter->getWorkbook();
2032  // Creating a worksheet
2033  $format_bold =& $workbook->addFormat();
2034  $format_bold->setBold();
2035  $format_percent =& $workbook->addFormat();
2036  $format_percent->setNumFormat("0.00%");
2037  $format_datetime =& $workbook->addFormat();
2038  $format_datetime->setNumFormat("DD/MM/YYYY hh:mm:ss");
2039  $format_title =& $workbook->addFormat();
2040  $format_title->setBold();
2041  $format_title->setColor('black');
2042  $format_title->setPattern(1);
2043  $format_title->setFgColor('silver');
2044  $worksheet =& $workbook->addWorksheet();
2045  $column = 0;
2046  $profile_data = array("email", "gender", "firstname", "lastname", "person_title", "institution",
2047  "department", "street", "zipcode","city", "country", "phone_office", "phone_home", "phone_mobile",
2048  "fax", "matriculation");
2049  foreach ($profile_data as $data)
2050  {
2051  $worksheet->writeString(0, $column++, $this->cleanString($this->lng->txt($data)), $format_title);
2052  }
2053  $member_ids = $this->object->getGroupMemberIds();
2054  $row = 1;
2055  foreach ($member_ids as $member_id)
2056  {
2057  $column = 0;
2058  $member =& $this->ilias->obj_factory->getInstanceByObjId($member_id);
2059  if ($member->getPref("public_email")=="y")
2060  {
2061  $worksheet->writeString($row, $column++, $this->cleanString($member->getEmail()));
2062  }
2063  else
2064  {
2065  $column++;
2066  }
2067  $worksheet->writeString($row, $column++, $this->cleanString($this->lng->txt("gender_" . $member->getGender())));
2068  $worksheet->writeString($row, $column++, $this->cleanString($member->getFirstname()));
2069  $worksheet->writeString($row, $column++, $this->cleanString($member->getLastname()));
2070  $worksheet->writeString($row, $column++, $this->cleanString($member->getUTitle()));
2071  if ($member->getPref("public_institution")=="y")
2072  {
2073  $worksheet->writeString($row, $column++, $this->cleanString($member->getInstitution()));
2074  }
2075  else
2076  {
2077  $column++;
2078  }
2079  if ($member->getPref("public_department")=="y")
2080  {
2081  $worksheet->writeString($row, $column++, $this->cleanString($member->getDepartment()));
2082  }
2083  else
2084  {
2085  $column++;
2086  }
2087  if ($member->getPref("public_street")=="y")
2088  {
2089  $worksheet->writeString($row, $column++, $this->cleanString($member->getStreet()));
2090  }
2091  else
2092  {
2093  $column++;
2094  }
2095  if ($member->getPref("public_zip")=="y")
2096  {
2097  $worksheet->writeString($row, $column++, $this->cleanString($member->getZipcode()));
2098  }
2099  else
2100  {
2101  $column++;
2102  }
2103  if ($member->getPref("public_city")=="y")
2104  {
2105  $worksheet->writeString($row, $column++, $this->cleanString($member->getCity()));
2106  }
2107  else
2108  {
2109  $column++;
2110  }
2111  if ($member->getPref("public_country")=="y")
2112  {
2113  $worksheet->writeString($row, $column++, $this->cleanString($member->getCountry()));
2114  }
2115  else
2116  {
2117  $column++;
2118  }
2119  if ($member->getPref("public_phone_office")=="y")
2120  {
2121  $worksheet->writeString($row, $column++, $this->cleanString($member->getPhoneOffice()));
2122  }
2123  else
2124  {
2125  $column++;
2126  }
2127  if ($member->getPref("public_phone_home")=="y")
2128  {
2129  $worksheet->writeString($row, $column++, $this->cleanString($member->getPhoneHome()));
2130  }
2131  else
2132  {
2133  $column++;
2134  }
2135  if ($member->getPref("public_phone_mobile")=="y")
2136  {
2137  $worksheet->writeString($row, $column++, $this->cleanString($member->getPhoneMobile()));
2138  }
2139  else
2140  {
2141  $column++;
2142  }
2143  if ($member->getPref("public_fax")=="y")
2144  {
2145  $worksheet->writeString($row, $column++, $this->cleanString($member->getFax()));
2146  }
2147  else
2148  {
2149  $column++;
2150  }
2151  if ($member->getPref("public_matriculation")=="y")
2152  {
2153  $worksheet->writeString($row, $column++, $this->cleanString($member->getMatriculation()));
2154  }
2155  else
2156  {
2157  $column++;
2158  }
2159  $row++;
2160  }
2161  $workbook->close();
2162  }
2163 
2172  function cleanString($str)
2173  {
2174  return str_replace(array("��","��","��","��","��","��","��"), array("ae","oe","ue","ss","Ae","Oe","Ue"), $str);
2175  }
2176 
2187  function infoScreenObject()
2188  {
2189  $this->ctrl->setCmd("showSummary");
2190  $this->ctrl->setCmdClass("ilinfoscreengui");
2191  $this->infoScreen();
2192  }
2193 
2197  function infoScreen()
2198  {
2199  global $rbacsystem;
2200 
2201  $this->tabs_gui->setTabActive('info_short');
2202 
2203  if(!$rbacsystem->checkAccess("visible", $this->ref_id))
2204  {
2205  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
2206  }
2207 
2208  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
2209  $info = new ilInfoScreenGUI($this);
2210 
2211  if(strlen($this->object->getInformation()))
2212  {
2213  $info->addSection($this->lng->txt('grp_general_informations'));
2214  $info->addProperty($this->lng->txt('grp_information'), nl2br(
2215  ilUtil::makeClickable ($this->object->getInformation(), true)));
2216  }
2217 
2218  $info->enablePrivateNotes();
2219  $info->enableLearningProgress(true);
2220 
2221  $info->addSection($this->lng->txt('group_registration'));
2222  $info->showLDAPRoleGroupMappingInfo();
2223 
2224  if(!$this->object->isRegistrationEnabled())
2225  {
2226  $info->addProperty($this->lng->txt('group_registration_mode'),
2227  $this->lng->txt('grp_reg_deac_info_screen'));
2228 
2229  }
2230  else
2231  {
2232  switch($this->object->getRegistrationType())
2233  {
2235  $info->addProperty($this->lng->txt('group_registration_mode'),
2236  $this->lng->txt('grp_reg_direct_info_screen'));
2237  break;
2238 
2240  $info->addProperty($this->lng->txt('group_registration_mode'),
2241  $this->lng->txt('grp_reg_req_info_screen'));
2242  break;
2243 
2245  $info->addProperty($this->lng->txt('group_registration_mode'),
2246  $this->lng->txt('grp_reg_passwd_info_screen'));
2247  break;
2248 
2249  }
2250  /*
2251  $info->addProperty($this->lng->txt('group_registration_time'),
2252  ilDatePresentation::formatPeriod(
2253  $this->object->getRegistrationStart(),
2254  $this->object->getRegistrationEnd()));
2255  */
2256  if($this->object->isRegistrationUnlimited())
2257  {
2258  $info->addProperty($this->lng->txt('group_registration_time'),
2259  $this->lng->txt('grp_registration_unlimited'));
2260  }
2261  elseif($this->object->getRegistrationStart()->getUnixTime() < time())
2262  {
2263  $info->addProperty($this->lng->txt("group_registration_time"),
2264  $this->lng->txt('cal_until').' '.
2265  ilDatePresentation::formatDate($this->object->getRegistrationEnd()));
2266  }
2267  elseif($this->object->getRegistrationStart()->getUnixTime() >= time())
2268  {
2269  $info->addProperty($this->lng->txt("group_registration_time"),
2270  $this->lng->txt('cal_from').' '.
2271  ilDatePresentation::formatDate($this->object->getRegistrationStart()));
2272  }
2273  if ($this->object->isMembershipLimited())
2274  {
2275  $info->addProperty($this->lng->txt("mem_free_places"),
2276  max(0,$this->object->getMaxMembers() - $this->object->members_obj->getCountMembers()));
2277 
2278  }
2279 
2280  }
2281 
2282  // forward the command
2283  $this->ctrl->forwardCommand($info);
2284  }
2285 
2289  function _goto($a_target)
2290  {
2291  global $ilAccess, $ilErr, $lng;
2292 
2293  if ($ilAccess->checkAccess("read", "", $a_target))
2294  {
2295  $_GET["cmd"] = "frameset";
2296  $_GET["ref_id"] = $a_target;
2297  include("repository.php");
2298  exit;
2299  }
2300  else
2301  {
2302  // to do: force flat view
2303  if ($ilAccess->checkAccess("visible", "", $a_target))
2304  {
2305  $_GET["cmd"] = "infoScreen";
2306  $_GET["ref_id"] = $a_target;
2307  include("repository.php");
2308  exit;
2309  }
2310  else
2311  {
2312  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
2313  {
2314  $_GET["cmd"] = "frameset";
2315  $_GET["target"] = "";
2316  $_GET["ref_id"] = ROOT_FOLDER_ID;
2317  ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
2318  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
2319  include("repository.php");
2320  exit;
2321  }
2322  }
2323  }
2324  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
2325  }
2326 
2327 
2335  protected function initForm($a_mode = 'edit')
2336  {
2337  global $ilUser;
2338 
2339  if(is_object($this->form))
2340  {
2341  return true;
2342  }
2343 
2344  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2345 
2346  $this->form = new ilPropertyFormGUI();
2347  $this->form->setTableWidth('60%');
2348  $this->form->setFormAction($this->ctrl->getFormAction($this));
2349 
2350  // title
2351  $title = new ilTextInputGUI($this->lng->txt('title'),'title');
2352  $title->setValue($this->object->getTitle());
2353  $title->setSize(40);
2354  $title->setMaxLength(128);
2355  $title->setRequired(true);
2356  $this->form->addItem($title);
2357 
2358  // desc
2359  $desc = new ilTextAreaInputGUI($this->lng->txt('description'),'desc');
2360  $desc->setValue($this->object->getLongDescription());
2361  $desc->setRows(2);
2362  $desc->setCols(40);
2363  $this->form->addItem($desc);
2364 
2365  // Group type
2366  $grp_type = new ilRadioGroupInputGUI($this->lng->txt('grp_typ'),'grp_type');
2367 
2368  if($a_mode == 'edit')
2369  {
2370  $type = ($this->object->getGroupType() ? $this->object->getGroupType() : $this->object->readGroupStatus());
2371  }
2372  else
2373  {
2374  $type = ($this->object->getGroupType() ? $this->object->getGroupType() : GRP_TYPE_PUBLIC);
2375  }
2376 
2377  $grp_type->setValue($type);
2378  $grp_type->setRequired(true);
2379 
2380  // OPEN GROUP
2381  #$opt_open = new ilRadioOption($this->lng->txt('grp_open'),GRP_TYPE_OPEN,$this->lng->txt('grp_open_info'));
2382  #$grp_type->addOption($opt_open);
2383 
2384 
2385  // PUBLIC GROUP
2386  $opt_public = new ilRadioOption($this->lng->txt('grp_public'),GRP_TYPE_PUBLIC,$this->lng->txt('grp_public_info'));
2387  $grp_type->addOption($opt_public);
2388 
2389  // Registration type
2390  $reg_type = new ilRadioGroupInputGUI('','registration_type');
2391  $reg_type->setValue($this->object->getRegistrationType());
2392 
2393  $opt_dir = new ilRadioOption($this->lng->txt('grp_reg_direct'),GRP_REGISTRATION_DIRECT);#$this->lng->txt('grp_reg_direct_info'));
2394  $reg_type->addOption($opt_dir);
2395 
2396  $opt_pass = new ilRadioOption($this->lng->txt('grp_pass_request'),GRP_REGISTRATION_PASSWORD);
2397  $pass = new ilTextInputGUI('','password');
2398  $pass->setInfo($this->lng->txt('grp_reg_password_info'));
2399  $pass->setValue($this->object->getPassword());
2400  $pass->setSize(10);
2401  $pass->setMaxLength(32);
2402  $opt_pass->addSubItem($pass);
2403  $reg_type->addOption($opt_pass);
2404  $opt_public->addSubItem($reg_type);
2405 
2406  $opt_req = new ilRadioOption($this->lng->txt('grp_reg_request'),GRP_REGISTRATION_REQUEST,$this->lng->txt('grp_reg_request_info'));
2407  $reg_type->addOption($opt_req);
2408 
2409  $opt_deact = new ilRadioOption($this->lng->txt('grp_reg_disabled'),GRP_REGISTRATION_DEACTIVATED,$this->lng->txt('grp_reg_disabled_info'));
2410  $reg_type->addOption($opt_deact);
2411 
2412  // CLOSED GROUP
2413  $opt_closed = new ilRadioOption($this->lng->txt('grp_closed'),GRP_TYPE_CLOSED,$this->lng->txt('grp_closed_info'));
2414  $grp_type->addOption($opt_closed);
2415  if($a_mode == 'update_group_type')
2416  {
2417  $grp_type->setAlert($this->lng->txt('grp_type_changed_info'));
2418  }
2419  $this->form->addItem($grp_type);
2420 
2421  // time limit
2422  $time_limit = new ilCheckboxInputGUI($this->lng->txt('grp_reg_limited'),'reg_limit_time');
2423  $time_limit->setOptionTitle($this->lng->txt('grp_reg_limit_time'));
2424  $time_limit->setChecked($this->object->isRegistrationUnlimited() ? false : true);
2425 
2426  $start = new ilDateTimeInputGUI($this->lng->txt('grp_reg_start'),'registration_start');
2427  $start->setShowTime(true);
2428  $start->setDate($this->object->getRegistrationStart());
2429  $time_limit->addSubItem($start);
2430 
2431  $end = new ilDateTimeInputGUI($this->lng->txt('grp_reg_end'),'registration_end');
2432  $end->setShowTime(true);
2433  $end->setDate($this->object->getRegistrationEnd());
2434 
2435  $time_limit->addSubItem($end);
2436 
2437  $this->form->addItem($time_limit);
2438 
2439  // max member
2440  $lim = new ilCheckboxInputGUI($this->lng->txt('reg_grp_max_members_short'),'registration_membership_limited');
2441  $lim->setValue(1);
2442  $lim->setOptionTitle($this->lng->txt('reg_grp_max_members'));
2443  $lim->setChecked($this->object->isMembershipLimited());
2444 
2445 
2446  $max = new ilTextInputGUI('','registration_max_members');
2447  $max->setValue($this->object->getMaxMembers() ? $this->object->getMaxMembers() : '');
2448  $max->setTitle($this->lng->txt('members').':');
2449  $max->setSize(3);
2450  $max->setMaxLength(4);
2451  $max->setInfo($this->lng->txt('grp_reg_max_members_info'));
2452  $lim->addSubItem($max);
2453 
2454  $wait = new ilCheckboxInputGUI('','waiting_list');
2455  $wait->setValue(1);
2456  $wait->setOptionTitle($this->lng->txt('grp_waiting_list'));
2457  $wait->setInfo($this->lng->txt('grp_waiting_list_info'));
2458  $wait->setChecked($this->object->isWaitingListEnabled() ? true : false);
2459  $lim->addSubItem($wait);
2460  $this->form->addItem($lim);
2461 
2462  switch($a_mode)
2463  {
2464  case 'create':
2465  $this->form->setTitle($this->lng->txt('grp_new'));
2466  $this->form->setTitleIcon(ilUtil::getImagePath('icon_grp.gif'));
2467 
2468  $this->form->addCommandButton('save',$this->lng->txt('grp_new'));
2469  $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
2470  return true;
2471 
2472  case 'edit':
2473  $this->form->setTitle($this->lng->txt('grp_edit'));
2474  $this->form->setTitleIcon(ilUtil::getImagePath('icon_grp.gif'));
2475 
2476  $this->form->addCommandButton('update',$this->lng->txt('save'));
2477  $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
2478  return true;
2479 
2480  case 'update_group_type':
2481  $this->form->setTitle($this->lng->txt('grp_edit'));
2482  $this->form->setTitleIcon(ilUtil::getImagePath('icon_grp.gif'));
2483 
2484  $this->form->addCommandButton('updateGroupType',$this->lng->txt('grp_change_type'));
2485  $this->form->addCommandButton('cancel',$this->lng->txt('cancel'));
2486  return true;
2487  }
2488  return true;
2489  }
2490 
2497  public function load()
2498  {
2499  $this->object->setTitle(ilUtil::stripSlashes($_POST['title']));
2500  $this->object->setDescription(ilUtil::stripSlashes($_POST['desc']));
2501  $this->object->setGroupType(ilUtil::stripSlashes($_POST['grp_type']));
2502  $this->object->setRegistrationType(ilUtil::stripSlashes($_POST['registration_type']));
2503  $this->object->setPassword(ilUtil::stripSlashes($_POST['password']));
2504  $this->object->enableUnlimitedRegistration((bool) !$_POST['reg_limit_time']);
2505  $this->object->setRegistrationStart($this->loadDate('registration_start'));
2506  $this->object->setRegistrationEnd($this->loadDate('registration_end'));
2507  $this->object->enableMembershipLimitation((bool) $_POST['registration_membership_limited']);
2508  $this->object->setMaxMembers((int) $_POST['registration_max_members']);
2509  $this->object->enableWaitingList((bool) $_POST['waiting_list']);
2510 
2511  return true;
2512  }
2513 
2521  protected function loadDate($a_field)
2522  {
2523  global $ilUser;
2524 
2525  include_once('./Services/Calendar/classes/class.ilDateTime.php');
2526 
2527  $dt['year'] = (int) $_POST[$a_field]['date']['y'];
2528  $dt['mon'] = (int) $_POST[$a_field]['date']['m'];
2529  $dt['mday'] = (int) $_POST[$a_field]['date']['d'];
2530  $dt['hours'] = (int) $_POST[$a_field]['time']['h'];
2531  $dt['minutes'] = (int) $_POST[$a_field]['time']['m'];
2532  $dt['seconds'] = (int) $_POST[$a_field]['time']['s'];
2533 
2534  $date = new ilDateTime($dt,IL_CAL_FKT_GETDATE,$ilUser->getTimeZone());
2535  return $date;
2536  }
2537 
2545  protected function setSubTabs($a_tab)
2546  {
2547  global $rbacsystem,$ilUser,$ilAccess;
2548 
2549  switch($a_tab)
2550  {
2551  case 'members':
2552  // for admins
2553  if($ilAccess->checkAccess('write','',$this->object->getRefId()))
2554  {
2555  $this->tabs_gui->addSubTabTarget("grp_edit_members",
2556  $this->ctrl->getLinkTarget($this,'members'),
2557  "members",
2558  get_class($this));
2559  }
2560  // for all
2561  $this->tabs_gui->addSubTabTarget("grp_members_gallery",
2562  $this->ctrl->getLinkTarget($this,'membersGallery'),
2563  "membersGallery", get_class($this));
2564 
2565  // members map
2566  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
2568  $this->object->getEnableGroupMap())
2569  {
2570  $this->tabs_gui->addSubTabTarget("grp_members_map",
2571  $this->ctrl->getLinkTarget($this,'membersMap'),
2572  "membersMap", get_class($this));
2573  }
2574 
2575  $this->tabs_gui->addSubTabTarget("mail_members",
2576  $this->ctrl->getLinkTarget($this,'mailMembers'),
2577  "mailMembers", get_class($this));
2578 
2579  break;
2580 
2581  case "activation":
2582  $this->tabs_gui->addSubTabTarget("activation",
2583  $this->ctrl->getLinkTargetByClass('ilCourseItemAdministrationGUI','edit'),
2584  "edit", get_class($this));
2585  $this->ctrl->setParameterByClass('ilconditionhandlerinterface','item_id',(int) $_GET['item_id']);
2586  $this->tabs_gui->addSubTabTarget("preconditions",
2587  $this->ctrl->getLinkTargetByClass('ilConditionHandlerInterface','listConditions'),
2588  "", "ilConditionHandlerInterface");
2589  break;
2590 
2591  case 'settings':
2592  $this->tabs_gui->addSubTabTarget("grp_settings",
2593  $this->ctrl->getLinkTarget($this,'edit'),
2594  "edit", get_class($this));
2595 
2596  $this->tabs_gui->addSubTabTarget("grp_info_settings",
2597  $this->ctrl->getLinkTarget($this,'editInfo'),
2598  "editInfo", get_class($this));
2599 
2600  // custom icon
2601  if ($this->ilias->getSetting("custom_icons"))
2602  {
2603  $this->tabs_gui->addSubTabTarget("grp_icon_settings",
2604  $this->ctrl->getLinkTarget($this,'editGroupIcons'),
2605  "editGroupIcons", get_class($this));
2606  }
2607 
2608 
2609  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapUtil.php");
2611  {
2612  $this->tabs_gui->addSubTabTarget("grp_map_settings",
2613  $this->ctrl->getLinkTarget($this,'editMapSettings'),
2614  "editMapSettings", get_class($this));
2615  }
2616 
2617  $this->tabs_gui->addSubTabTarget('groupings',
2618  $this->ctrl->getLinkTargetByClass('ilobjcoursegroupinggui','listGroupings'),
2619  'listGroupings',
2620  get_class($this));
2621 
2622  break;
2623  }
2624  }
2625 } // END class.ilObjGroupGUI
2626 ?>