ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjGroup.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 
25 //TODO: function getRoleId($groupRole) returns the object-id of grouprole
26 
27 require_once "./Services/Container/classes/class.ilContainer.php";
28 include_once('./Services/Calendar/classes/class.ilDateTime.php');
29 
30 
31 define('GRP_REGISTRATION_DEACTIVATED',-1);
32 define('GRP_REGISTRATION_DIRECT',0);
33 define('GRP_REGISTRATION_REQUEST',1);
34 define('GRP_REGISTRATION_PASSWORD',2);
35 
36 define('GRP_REGISTRATION_LIMITED',1);
37 define('GRP_REGISTRATION_UNLIMITED',2);
38 
39 define('GRP_TYPE_UNKNOWN',0);
40 define('GRP_TYPE_CLOSED',1);
41 define('GRP_TYPE_OPEN',2);
42 define('GRP_TYPE_PUBLIC',3);
43 
54 class ilObjGroup extends ilContainer
55 {
56  const CAL_REG_START = 1;
57  const CAL_REG_END = 2;
58 
59 
60  const ERR_MISSING_TITLE = 'msg_no_title';
61  const ERR_MISSING_GROUP_TYPE = 'grp_missing_grp_type';
62  const ERR_MISSING_PASSWORD = 'grp_missing_password';
63  const ERR_WRONG_MAX_MEMBERS = 'grp_wrong_max_members';
64  const ERR_WRONG_REG_TIME_LIMIT = 'grp_wrong_reg_time_limit';
65 
66  protected $information;
67  protected $group_type = null;
69  protected $reg_enabled = true;
70  protected $reg_unlimited = true;
71  protected $reg_start = null;
72  protected $reg_end = null;
73  protected $reg_password = '';
74  protected $reg_membership_limitation = false;
75  protected $reg_max_members = 0;
76  protected $waiting_list = false;
77 
78 
79  // Map
80  protected $latitude;
81  protected $longitude;
82  protected $location_zoom;
83  protected $enablemap;
84 
85  public $members_obj;
86 
87 
91  var $file_obj = null;
92 
94 
96 
98 
105  public function __construct($a_id = 0,$a_call_by_reference = true)
106  {
107  global $tree;
108 
109  $this->tree =& $tree;
110 
111  $this->type = "grp";
112  $this->ilObject($a_id,$a_call_by_reference);
113  $this->setRegisterMode(true); // ???
114  }
115 
116  // Setter/Getter
124  public function setInformation($a_information)
125  {
126  $this->information = $a_information;
127  }
128 
136  public function getInformation()
137  {
138  return $this->information;
139  }
140 
147  public function setGroupType($a_type)
148  {
149  $this->group_type = $a_type;
150  }
151 
158  public function getGroupType()
159  {
160  return $this->group_type;
161  }
162 
170  public function isGroupTypeModified($a_old_type)
171  {
172  if($a_old_type == GRP_TYPE_UNKNOWN)
173  {
174  $group_type = $this->readGroupStatus();
175  }
176  else
177  {
178  $group_type = $a_old_type;
179  }
180  return $group_type != $this->getGroupType();
181  }
182 
190  public function setRegistrationType($a_type)
191  {
192  $this->reg_type = $a_type;
193  }
194 
201  public function getRegistrationType()
202  {
203  return $this->reg_type;
204  }
205 
212  public function isRegistrationEnabled()
213  {
215  }
216 
224  public function enableUnlimitedRegistration($a_status)
225  {
226  $this->reg_unlimited = $a_status;
227  }
228 
235  public function isRegistrationUnlimited()
236  {
237  return $this->reg_unlimited;
238  }
239 
247  public function setRegistrationStart($a_start)
248  {
249  $this->reg_start = $a_start;
250  }
251 
258  public function getRegistrationStart()
259  {
260  return $this->reg_start ? $this->reg_start : $this->reg_start = new ilDateTime(date('Y-m-d').' 08:00:00',IL_CAL_DATETIME);
261  }
262 
263 
271  public function setRegistrationEnd($a_end)
272  {
273  $this->reg_end = $a_end;
274  }
275 
282  public function getRegistrationEnd()
283  {
284  return $this->reg_end ? $this->reg_end : $this->reg_end = new ilDateTime(date('Y-m-d').' 16:00:00',IL_CAL_DATETIME);
285  }
286 
293  public function setPassword($a_pass)
294  {
295  $this->reg_password = $a_pass;
296  }
297 
304  public function getPassword()
305  {
306  return $this->reg_password;
307  }
308 
316  public function enableMembershipLimitation($a_status)
317  {
318  $this->reg_membership_limitation = $a_status;
319  }
320 
327  public function isMembershipLimited()
328  {
329  return (bool) $this->reg_membership_limitation;
330  }
331 
338  public function setMaxMembers($a_max)
339  {
340  $this->reg_max_members = $a_max;
341  }
342 
349  public function getMaxMembers()
350  {
351  return $this->reg_max_members;
352  }
353 
361  public function enableWaitingList($a_status)
362  {
363  $this->waiting_list = $a_status;
364  }
365 
373  public function isWaitingListEnabled()
374  {
375  return $this->waiting_list;
376  }
377 
383  function setLatitude($a_latitude)
384  {
385  $this->latitude = $a_latitude;
386  }
387 
393  function getLatitude()
394  {
395  return $this->latitude;
396  }
397 
403  function setLongitude($a_longitude)
404  {
405  $this->longitude = $a_longitude;
406  }
407 
413  function getLongitude()
414  {
415  return $this->longitude;
416  }
417 
423  function setLocationZoom($a_locationzoom)
424  {
425  $this->locationzoom = $a_locationzoom;
426  }
427 
433  function getLocationZoom()
434  {
435  return $this->locationzoom;
436  }
437 
443  function setEnableGroupMap($a_enablemap)
444  {
445  $this->enablemap = $a_enablemap;
446  }
447 
453  function getEnableGroupMap()
454  {
455  return $this->enablemap;
456  }
457 
464  public function validate()
465  {
466  global $ilErr;
467 
468  if($this->getTitle() == 'NO TITLE')
469  {
470  $this->title = '';
471  $ilErr->appendMessage(self::ERR_MISSING_TITLE);
472  }
473  if(!$this->getGroupType())
474  {
475  $ilErr->appendMessage(self::ERR_MISSING_GROUP_TYPE);
476  }
477  if($this->getRegistrationType() == GRP_REGISTRATION_PASSWORD and !strlen($this->getPassword()))
478  {
479  $ilErr->appendMessage(self::ERR_MISSING_PASSWORD);
480  }
482  {
483  $ilErr->appendMessage(self::ERR_WRONG_REG_TIME_LIMIT);
484  }
485  if($this->isMembershipLimited() and (!is_numeric($this->getMaxMembers()) or $this->getMaxMembers() <= 0))
486  {
487  $ilErr->appendMessage(self::ERR_WRONG_MAX_MEMBERS);
488  }
489  return strlen($ilErr->getMessage()) == 0;
490  }
491 
492 
493 
494 
498  function create()
499  {
500  global $ilDB,$ilAppEventHandler;
501 
502  if(!parent::create())
503  {
504  return false;
505  }
506 
507  $query = "INSERT INTO grp_settings ".
508  "SET obj_id = ".$ilDB->quote($this->getId()).", ".
509  "information = ".$ilDB->quote($this->getInformation()).", ".
510  "grp_type = ".$ilDB->quote((int) $this->getGroupType()).", ".
511  "registration_type = ".$ilDB->quote($this->getRegistrationType()).", ".
512  "registration_enabled = ".($this->isRegistrationEnabled() ? 1 : 0).", ".
513  "registration_unlimited = ".($this->isRegistrationUnlimited() ? 1 : 0).", ".
514  "registration_start = ".$ilDB->quote($this->getRegistrationStart()->get(IL_CAL_DATETIME,'')).", ".
515  "registration_end = ".$ilDB->quote($this->getRegistrationEnd()->get(IL_CAL_DATETIME,'')).", ".
516  "registration_password = ".$ilDB->quote($this->getPassword()).", ".
517  "registration_membership_limited = ".$ilDB->quote((int) $this->isMembershipLimited()).", ".
518  "registration_max_members = ".$ilDB->quote($this->getMaxMembers()).", ".
519  "waiting_list = ".$ilDB->quote($this->isWaitingListEnabled() ? 1 : 0).", ".
520  "latitude = ".$ilDB->quote($this->getLatitude()).", ".
521  "longitude = ".$ilDB->quote($this->getLongitude()).", ".
522  "location_zoom = ".$ilDB->quote($this->getLocationZoom()).", ".
523  "enablemap = ".$ilDB->quote($this->getEnableGroupMap())." ";
524 
525  $ilDB->query($query);
526 
527  $ilAppEventHandler->raise('Modules/Group',
528  'create',
529  array('object' => $this,
530  'obj_id' => $this->getId(),
531  'appointments' => $this->prepareAppointments('create')));
532 
533  return $this->getId();
534  }
535 
539  function update()
540  {
541  global $ilDB,$ilAppEventHandler;
542 
543  if (!parent::update())
544  {
545  return false;
546  }
547 
548  $query = "UPDATE grp_settings ".
549  "SET information = ".$ilDB->quote($this->getInformation()).", ".
550  "grp_type = ".$ilDB->quote((int) $this->getGroupType()).", ".
551  "registration_type = ".$ilDB->quote($this->getRegistrationType()).", ".
552  "registration_enabled = ".($this->isRegistrationEnabled() ? 1 : 0).", ".
553  "registration_unlimited = ".($this->isRegistrationUnlimited() ? 1 : 0).", ".
554  "registration_start = ".$ilDB->quote($this->getRegistrationStart()->get(IL_CAL_DATETIME,'')).", ".
555  "registration_end = ".$ilDB->quote($this->getRegistrationEnd()->get(IL_CAL_DATETIME,'')).", ".
556  "registration_password = ".$ilDB->quote($this->getPassword()).", ".
557  "registration_membership_limited = ".$ilDB->quote((int) $this->isMembershipLimited()).", ".
558  "registration_max_members = ".$ilDB->quote($this->getMaxMembers()).", ".
559  "waiting_list = ".$ilDB->quote($this->isWaitingListEnabled() ? 1 : 0).", ".
560  "latitude = ".$ilDB->quote($this->getLatitude()).", ".
561  "longitude = ".$ilDB->quote($this->getLongitude()).", ".
562  "location_zoom = ".$ilDB->quote($this->getLocationZoom()).", ".
563  "enablemap = ".$ilDB->quote($this->getEnableGroupMap())." ".
564  "WHERE obj_id = ".$ilDB->quote($this->getId())." ";
565 
566  $ilDB->query($query);
567 
568  $ilAppEventHandler->raise('Modules/Group',
569  'update',
570  array('object' => $this,
571  'obj_id' => $this->getId(),
572  'appointments' => $this->prepareAppointments('update')));
573 
574 
575  return true;
576  }
577 
584  public function delete()
585  {
586  global $ilDB,$ilAppEventHandler;
587 
588  // always call parent delete function first!!
589  if (!parent::delete())
590  {
591  return false;
592  }
593 
594  $query = "DELETE FROM grp_settings ".
595  "WHERE obj_id = ".$ilDB->quote($this->getId());
596  $ilDB->query($query);
597 
598  include_once('./Modules/Group/classes/class.ilGroupParticipants.php');
600 
601  $ilAppEventHandler->raise('Modules/Group',
602  'delete',
603  array('object' => $this,
604  'obj_id' => $this->getId(),
605  'appointments' => $this->prepareAppointments('delete')));
606 
607 
608  return true;
609  }
610 
611 
615  function read()
616  {
617  global $ilDB;
618 
619  parent::read();
620 
621  $query = "SELECT * FROM grp_settings ".
622  "WHERE obj_id = ".$ilDB->quote($this->getId());
623 
624  $res = $ilDB->query($query);
625  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
626  {
627  $this->setInformation($row->information);
628  $this->setGroupType($row->grp_type);
629  $this->setRegistrationType($row->registration_type);
630  $this->enableUnlimitedRegistration($row->registration_unlimited);
631  $this->setRegistrationStart(new ilDateTime($row->registration_start,IL_CAL_DATETIME));
632  $this->setRegistrationEnd(new ilDateTime($row->registration_end,IL_CAL_DATETIME));
633  $this->setPassword($row->registration_password);
634  $this->enableMembershipLimitation((bool) $row->registration_membership_limited);
635  $this->setMaxMembers($row->registration_max_members);
636  $this->enableWaitingList($row->waiting_list);
637  $this->setLatitude($row->latitude);
638  $this->setLongitude($row->longitude);
639  $this->setLocationZoom($row->location_zoom);
640  $this->setEnableGroupMap($row->enablemap);
641  }
642  $this->initParticipants();
643 
644  // Inherit order type from parent course (if exists)
645  include_once('./Services/Container/classes/class.ilContainerSortingSettings.php');
647  }
648 
657  public function cloneObject($a_target_id,$a_copy_id = 0)
658  {
659  global $ilDB,$ilUser;
660 
661  $new_obj = parent::cloneObject($a_target_id,$a_copy_id);
662  $new_obj->setGroupType($this->getGroupType());
663  $new_obj->initGroupStatus($this->getGroupType() ? $this->getGroupType() : $this->readGroupStatus());
664 
665  $this->cloneAutoGeneratedRoles($new_obj);
666 
667  $new_obj->setInformation($this->getInformation());
668  $new_obj->setRegistrationStart($this->getRegistrationStart());
669  $new_obj->setRegistrationEnd($this->getRegistrationEnd());
670  $new_obj->enableUnlimitedRegistration($this->isRegistrationUnlimited());
671  $new_obj->setPassword($this->getPassword());
672  $new_obj->enableMembershipLimitation($this->isMembershipLimited());
673  $new_obj->setMaxMembers($this->getMaxMembers());
674  $new_obj->enableWaitingList($this->isWaitingListEnabled());
675 
676  // map
677  $new_obj->setLatitude($this->getLatitude());
678  $new_obj->setLongitude($this->getLongitude());
679  $new_obj->setLocationZoom($this->getLocationZoom());
680  $new_obj->setEnableGroupMap($this->getEnableGroupMap());
681  $new_obj->update();
682 
683  global $ilLog;
684  $ilLog->write(__METHOD__.': Starting add user');
685 
686  // Assign user as admin
687  include_once('./Modules/Group/classes/class.ilGroupParticipants.php');
688  $part = ilGroupParticipants::_getInstanceByObjId($new_obj->getId());
689  $part->add($ilUser->getId(),IL_GRP_ADMIN);
690  $part->updateNotification($ilUser->getId(),1);
691 
692  // Copy learning progress settings
693  include_once('Services/Tracking/classes/class.ilLPObjSettings.php');
694  $obj_settings = new ilLPObjSettings($this->getId());
695  $obj_settings->cloneSettings($new_obj->getId());
696  unset($obj_settings);
697 
698  // clone icons
699  $new_obj->saveIcons($this->getBigIconPath(),
700  $this->getSmallIconPath(),
701  $this->getTinyIconPath());
702 
703  return $new_obj;
704  }
705 
714  public function cloneDependencies($a_target_id,$a_copy_id)
715  {
716  global $tree;
717 
718  parent::cloneDependencies($a_target_id,$a_copy_id);
719 
720  if($course_ref_id = $tree->checkForParentType($this->getRefId(),'crs') and
721  $new_course_ref_id = $tree->checkForParentType($a_target_id,'crs'))
722  {
723  include_once('Modules/Course/classes/class.ilCourseItems.php');
724  $course_obj =& ilObjectFactory::getInstanceByRefId($course_ref_id,false);
725  $course_items = new ilCourseItems($course_obj,$this->getRefId());
726  $course_items->cloneDependencies($a_target_id,$a_copy_id);
727  }
728 
729  include_once('Services/Tracking/classes/class.ilLPCollections.php');
730  $lp_collection = new ilLPCollections($this->getId());
731  $lp_collection->cloneCollections($a_target_id,$a_copy_id);
732 
733  return true;
734  }
735 
743  public function cloneAutoGeneratedRoles($new_obj)
744  {
745  global $ilLog,$rbacadmin,$rbacreview;
746 
747  $admin = $this->getDefaultAdminRole();
748  $new_admin = $new_obj->getDefaultAdminRole();
749  $source_rolf = $rbacreview->getRoleFolderIdOfObject($this->getRefId());
750  $target_rolf = $rbacreview->getRoleFolderIdOfObject($new_obj->getRefId());
751 
752  if(!$admin || !$new_admin || !$source_rolf || !$target_rolf)
753  {
754  $ilLog->write(__METHOD__.' : Error cloning auto generated role: il_grp_admin');
755  }
756  $rbacadmin->copyRolePermissions($admin,$source_rolf,$target_rolf,$new_admin,true);
757  $ilLog->write(__METHOD__.' : Finished copying of role il_grp_admin.');
758 
759  $member = $this->getDefaultMemberRole();
760  $new_member = $new_obj->getDefaultMemberRole();
761  if(!$member || !$new_member)
762  {
763  $ilLog->write(__METHOD__.' : Error cloning auto generated role: il_grp_member');
764  }
765  $rbacadmin->copyRolePermissions($member,$source_rolf,$target_rolf,$new_member,true);
766  $ilLog->write(__METHOD__.' : Finished copying of role grp_member.');
767  }
768 
769 
775  function join($a_user_id, $a_mem_role="")
776  {
777  global $rbacadmin;
778 
779  if (is_array($a_mem_role))
780  {
781  foreach ($a_mem_role as $role)
782  {
783  $rbacadmin->assignUser($role,$a_user_id, false);
784  }
785  }
786  else
787  {
788  $rbacadmin->assignUser($a_mem_role,$a_user_id, false);
789  }
790 
791  return true;
792  }
793 
799  {
800  $local_group_Roles = $this->getLocalGroupRoles();
801 
802  return $local_group_Roles["il_grp_member_".$this->getRefId()];
803  }
804 
810  {
811  $local_group_Roles = $this->getLocalGroupRoles();
812 
813  return $local_group_Roles["il_grp_admin_".$this->getRefId()];
814  }
815 
822  function addMember($a_user_id, $a_mem_role)
823  {
824  global $rbacadmin;
825 
826  if (isset($a_user_id) && isset($a_mem_role) )
827  {
828  $this->join($a_user_id,$a_mem_role);
829  return true;
830  }
831  else
832  {
833  $this->ilias->raiseError(get_class($this)."::addMember(): Missing parameters !",$this->ilias->error_obj->WARNING);
834  return false;
835  }
836  }
837 
838 
845  function leaveGroup()
846  {
847  global $rbacadmin, $rbacreview;
848 
849  $member_ids = $this->getGroupMemberIds();
850 
851  if (count($member_ids) <= 1 || !in_array($this->ilias->account->getId(), $member_ids))
852  {
853  return 2;
854  }
855  else
856  {
857  if (!$this->isAdmin($this->ilias->account->getId()))
858  {
859  $this->leave($this->ilias->account->getId());
860  $member = new ilObjUser($this->ilias->account->getId());
861  $member->dropDesktopItem($this->getRefId(), "grp");
862 
863  return 0;
864  }
865  else if (count($this->getGroupAdminIds()) == 1)
866  {
867  return 1;
868  }
869  }
870  }
871 
876  function leave($a_user_id)
877  {
878  global $rbacadmin;
879 
880  $arr_groupRoles = $this->getMemberRoles($a_user_id);
881 
882  if (is_array($arr_groupRoles))
883  {
884  foreach ($arr_groupRoles as $groupRole)
885  {
886  $rbacadmin->deassignUser($groupRole, $a_user_id);
887  }
888  }
889  else
890  {
891  $rbacadmin->deassignUser($arr_groupRoles, $a_user_id);
892  }
893 
894  return true;
895  }
896 
903  function getGroupMemberIds()
904  {
905  global $rbacadmin, $rbacreview;
906 
907  $usr_arr= array();
908 
909  $rol = $this->getLocalGroupRoles();
910 
911  foreach ($rol as $value)
912  {
913  foreach ($rbacreview->assignedUsers($value) as $member_id)
914  {
915  array_push($usr_arr,$member_id);
916  }
917  }
918 
919  $mem_arr = array_unique($usr_arr);
920 
921  return $mem_arr ? $mem_arr : array();
922  }
923 
931  function getGroupMemberData($a_mem_ids, $active = 1)
932  {
933  global $rbacadmin, $rbacreview, $ilBench, $ilDB;
934 
935  $usr_arr= array();
936 
937  $q = "SELECT login,firstname,lastname,title,usr_id,last_login ".
938  "FROM usr_data ".
939  "WHERE usr_id IN (".implode(',',ilUtil::quoteArray($a_mem_ids)).") ";
940 
941  if (is_numeric($active) && $active > -1)
942  $q .= "AND active = '$active'";
943 
944  $q .= 'ORDER BY lastname,firstname';
945 
946  $r = $ilDB->query($q);
947 
948  while($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
949  {
950  $mem_arr[] = array("id" => $row->usr_id,
951  "login" => $row->login,
952  "firstname" => $row->firstname,
953  "lastname" => $row->lastname,
954  "last_login" => $row->last_login
955  );
956  }
957 
958  return $mem_arr ? $mem_arr : array();
959  }
960 
961  function getCountMembers()
962  {
963  return count($this->getGroupMemberIds());
964  }
965 
972  function getGroupAdminIds($a_grpId="")
973  {
974  global $rbacreview;
975 
976  if (!empty($a_grpId))
977  {
978  $grp_id = $a_grpId;
979  }
980  else
981  {
982  $grp_id = $this->getRefId();
983  }
984 
985  $usr_arr = array();
986  $roles = $this->getDefaultGroupRoles($this->getRefId());
987 
988  foreach ($rbacreview->assignedUsers($this->getDefaultAdminRole()) as $member_id)
989  {
990  array_push($usr_arr,$member_id);
991  }
992 
993  return $usr_arr;
994  }
995 
1001  function getDefaultGroupRoles($a_grp_id="")
1002  {
1003  global $rbacadmin, $rbacreview;
1004 
1005  if (strlen($a_grp_id) > 0)
1006  {
1007  $grp_id = $a_grp_id;
1008  }
1009  else
1010  {
1011  $grp_id = $this->getRefId();
1012  }
1013 
1014  $rolf = $rbacreview->getRoleFolderOfObject($grp_id);
1015  $role_arr = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"]);
1016 
1017  foreach ($role_arr as $role_id)
1018  {
1019  $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
1020 
1021  $grp_Member ="il_grp_member_".$grp_id;
1022  $grp_Admin ="il_grp_admin_".$grp_id;
1023 
1024  if (strcmp($role_Obj->getTitle(), $grp_Member) == 0 )
1025  {
1026  $arr_grpDefaultRoles["grp_member_role"] = $role_Obj->getId();
1027  }
1028 
1029  if (strcmp($role_Obj->getTitle(), $grp_Admin) == 0)
1030  {
1031  $arr_grpDefaultRoles["grp_admin_role"] = $role_Obj->getId();
1032  }
1033  }
1034 
1035  return $arr_grpDefaultRoles;
1036  }
1037 
1044  function getLocalGroupRoles($a_translate = false)
1045  {
1046  global $rbacadmin,$rbacreview;
1047 
1048  if (empty($this->local_roles))
1049  {
1050  $this->local_roles = array();
1051  $rolf = $rbacreview->getRoleFolderOfObject($this->getRefId());
1052  $role_arr = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"]);
1053 
1054  foreach ($role_arr as $role_id)
1055  {
1056  if ($rbacreview->isAssignable($role_id,$rolf["ref_id"]) == true)
1057  {
1058  $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
1059 
1060  if ($a_translate)
1061  {
1062  $role_name = ilObjRole::_getTranslation($role_Obj->getTitle());
1063  }
1064  else
1065  {
1066  $role_name = $role_Obj->getTitle();
1067  }
1068 
1069  $this->local_roles[$role_name] = $role_Obj->getId();
1070  }
1071  }
1072  }
1073 
1074  return $this->local_roles;
1075  }
1076 
1083  {
1084  $q = "SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_closed'";
1085  $res = $this->ilias->db->query($q);
1086  $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
1087 
1088  return $row["obj_id"];
1089  }
1090 
1097  {
1098  $q = "SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_open'";
1099  $res = $this->ilias->db->query($q);
1100  $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
1101 
1102  return $row["obj_id"];
1103  }
1104 
1110  function setExpirationDateTime($a_date)
1111  {
1112  global $ilDB;
1113 
1114  $q = "SELECT * FROM grp_data WHERE grp_id= ".
1115  $ilDB->quote($this->getId());
1116  $res = $this->ilias->db->query($q);
1117  $date = ilFormat::input2date($a_date);
1118 
1119  if ($res->numRows() == 0)
1120  {
1121  $q = "INSERT INTO grp_data (grp_id, expiration) VALUES(".
1122  $ilDB->quote($this->getId()).",".$ilDB->quote($date).")";
1123  $res = $this->ilias->db->query($q);
1124  }
1125  else
1126  {
1127  $q = "UPDATE grp_data SET expiration=".
1128  $ilDB->quote($date)." WHERE grp_id=".$ilDB->quote($this->getId());
1129  $res = $this->ilias->db->query($q);
1130  }
1131  }
1132 
1140  public function getExpiration()
1141  {
1142  global $ilDB;
1143 
1144  $q = "SELECT * FROM grp_data WHERE grp_id= ".
1145  $ilDB->quote($this->getId());
1146  $res = $this->ilias->db->query($q);
1147  $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
1148  return $datetime = $row["expiration"];
1149  }
1150 
1151 
1153  {
1154  global $ilDB;
1155 
1156  $query = "SELECT UNIX_TIMESTAMP(expiration) as timest FROM grp_data WHERE grp_id = ".
1157  $ilDB->quote($this->getId());
1158 
1159  $res = $this->ilias->db->query($query);
1160  $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
1161  return $row['timest'];
1162  }
1163 
1164 
1174  public function updateGroupType()
1175  {
1176  global $tree,$rbacreview,$rbacadmin;
1177 
1178  $parent_roles = $rbacreview->getParentRoleIds($this->getRefId());
1179  $real_parent_roles = array_diff(array_keys($parent_roles),$this->getDefaultGroupRoles());
1180  $rolf_data = $rbacreview->getRoleFolderOfObject($this->getRefId());
1181 
1182  // Delete parent roles with stopped inheritance
1183  foreach($real_parent_roles as $role_id)
1184  {
1185  // Delete local role
1186  if(isset($rolf_data['child']) and $rolf_data['child'])
1187  {
1188  $rbacadmin->deleteLocalRole($role_id,$rolf_data['child']);
1189  }
1190  }
1191  $parent_roles = $rbacreview->getParentRoleIds($this->getRefId());
1192  $real_parent_roles = array_diff(array_keys($parent_roles),$this->getDefaultGroupRoles());
1193 
1194  switch($this->getGroupType())
1195  {
1196  case GRP_TYPE_PUBLIC:
1197  $template_id = $this->getGrpStatusOpenTemplateId();
1198  break;
1199 
1200  case GRP_TYPE_CLOSED:
1201  $template_id = $this->getGrpStatusClosedTemplateId();
1202  break;
1203  }
1204 
1205  $first = true;
1206  foreach($tree->getFilteredSubTree($this->getRefId(),array('rolf','grp')) as $subnode)
1207  {
1208  // Read template operations
1209  $template_ops = $rbacreview->getOperationsOfRole($template_id,$subnode['type'], ROLE_FOLDER_ID);
1210 
1211  $rolf_data = $rbacreview->getRoleFolderOfObject($subnode['child']);
1212 
1213 
1214  // for all parent roles
1215  foreach($real_parent_roles as $role_id)
1216  {
1217  if($rbacreview->isProtected($parent_roles[$role_id]['parent'],$role_id))
1218  {
1219  continue;
1220  }
1221 
1222  // Delete local role
1223  if(isset($rolf_data['child']) and $rolf_data['child'])
1224  {
1225  $rbacadmin->deleteLocalRole($role_id,$rolf_data['child']);
1226  }
1227 
1228  // Store current operations
1229  $current_ops = $rbacreview->getOperationsOfRole($role_id,$subnode['type'],$parent_roles[$role_id]['parent']);
1230 
1231  // Revoke permissions
1232  $rbacadmin->revokePermission($subnode['child'],$role_id);
1233 
1234  // Grant permissions
1235  $granted = array();
1236  foreach($template_ops as $operation)
1237  {
1238  if(in_array($operation,$current_ops))
1239  {
1240  $granted[] = $operation;
1241  }
1242  }
1243  if($granted)
1244  {
1245  $rbacadmin->grantPermission($role_id, $granted,$subnode['child']);
1246  }
1247 
1248  if($first)
1249  {
1250  // This is the group itself
1251  $rbacadmin->copyRolePermissionIntersection(
1252  $template_id, ROLE_FOLDER_ID,
1253  $role_id, $parent_roles[$role_id]['parent'],
1254  $rolf_data["child"],$role_id);
1255  $rbacadmin->assignRoleToFolder($role_id,$rolf_data["child"],"n");
1256 
1257  }
1258  }
1259  $first = false;
1260  }
1261  }
1262 
1280  function initGroupStatus($a_grpStatus = GRP_TYPE_PUBLIC)
1281  {
1282  global $rbacadmin, $rbacreview, $rbacsystem;
1283 
1284  //get Rolefolder of group
1285  $rolf_data = $rbacreview->getRoleFolderOfObject($this->getRefId());
1286 
1287  //define all relevant roles that rights are needed to be changed
1288  $arr_parentRoles = $rbacreview->getParentRoleIds($this->getRefId());
1289 
1290  $real_local_roles = $rbacreview->getRolesOfRoleFolder($rolf_data['ref_id'],false);
1291  $arr_relevantParentRoleIds = array_diff(array_keys($arr_parentRoles),$real_local_roles);
1292 
1293  //group status open (aka public) or group status closed
1294  if ($a_grpStatus == GRP_TYPE_PUBLIC || $a_grpStatus == GRP_TYPE_CLOSED)
1295  {
1296  if ($a_grpStatus == GRP_TYPE_PUBLIC)
1297  {
1298  $template_id = $this->getGrpStatusOpenTemplateId();
1299  }
1300  else
1301  {
1302  $template_id = $this->getGrpStatusClosedTemplateId();
1303  }
1304  //get defined operations from template
1305  $template_ops = $rbacreview->getOperationsOfRole($template_id, 'grp', ROLE_FOLDER_ID);
1306 
1307  foreach ($arr_relevantParentRoleIds as $parentRole)
1308  {
1309  if ($rbacreview->isProtected($arr_parentRoles[$parentRole]['parent'],$parentRole))
1310  {
1311  continue;
1312  }
1313 
1314  $granted_permissions = array();
1315 
1316  // Delete the linked role for the parent role
1317  // (just in case if it already exists).
1318 
1319  // Added additional check, since this operation is very dangerous.
1320  // If there is no role folder ALL parent roles are deleted.
1321  if(isset($rolf_data['child']) and $rolf_data['child'])
1322  {
1323  $rbacadmin->deleteLocalRole($parentRole,$rolf_data["child"]);
1324  }
1325 
1326  // Grant permissions on the group object for
1327  // the parent role. In the foreach loop we
1328  // compute the intersection of the role
1329  // template il_grp_status_open/_closed and the
1330  // permission template of the parent role.
1331  $current_ops = $rbacreview->getRoleOperationsOnObject($parentRole, $this->getRefId());
1332  $rbacadmin->revokePermission($this->getRefId(), $parentRole);
1333  foreach ($template_ops as $template_op)
1334  {
1335  if (in_array($template_op,$current_ops))
1336  {
1337  array_push($granted_permissions,$template_op);
1338  }
1339  }
1340  if (!empty($granted_permissions))
1341  {
1342  $rbacadmin->grantPermission($parentRole, $granted_permissions, $this->getRefId());
1343  }
1344 
1345  // Create a linked role for the parent role and
1346  // initialize it with the intersection of
1347  // il_grp_status_open/_closed and the permission
1348  // template of the parent role
1349  $rbacadmin->copyRolePermissionIntersection(
1350  $template_id, ROLE_FOLDER_ID,
1351  $parentRole, $arr_parentRoles[$parentRole]['parent'],
1352  $rolf_data["child"], $parentRole
1353  );
1354  $rbacadmin->assignRoleToFolder($parentRole,$rolf_data["child"],"false");
1355  }//END foreach
1356  }
1357  }
1358 
1366  public function setGroupStatus($a_status)
1367  {
1368  $this->group_status = $a_status;
1369  }
1370 
1378  public function getGroupStatus()
1379  {
1380  return $this->group_status;
1381  }
1382 
1388  function readGroupStatus()
1389  {
1390  global $rbacsystem,$rbacreview;
1391 
1392  $role_folder = $rbacreview->getRoleFolderOfObject($this->getRefId());
1393  $local_roles = $rbacreview->getRolesOfRoleFolder($role_folder["ref_id"]);
1394 
1395  //get Rolefolder of group
1396  $rolf_data = $rbacreview->getRoleFolderOfObject($this->getRefId());
1397  //get all relevant roles
1398  $arr_globalRoles = array_diff($local_roles, $this->getDefaultGroupRoles());
1399 
1400  //if one global role has no permission to join the group is officially closed !
1401  foreach ($arr_globalRoles as $globalRole)
1402  {
1403  $ops_of_role = $rbacreview->getOperationsOfRole($globalRole,"grp", ROLE_FOLDER_ID);
1404 
1405  if ($rbacsystem->checkPermission($this->getRefId(), $globalRole ,"join"))
1406  {
1407  return $this->group_status = GRP_TYPE_PUBLIC;
1408  }
1409  }
1410 
1411  return $this->group_status = GRP_TYPE_CLOSED;
1412  }
1413 
1420  function getMemberRoles($a_user_id)
1421  {
1422  global $rbacadmin, $rbacreview,$ilBench;
1423 
1424  $ilBench->start("Group", "getMemberRoles");
1425 
1426  $arr_assignedRoles = array();
1427 
1428  $arr_assignedRoles = array_intersect($rbacreview->assignedRoles($a_user_id),$this->getLocalGroupRoles());
1429 
1430  $ilBench->stop("Group", "getMemberRoles");
1431 
1432  return $arr_assignedRoles;
1433  }
1434 
1441  function getMemberRolesTitle($a_user_id)
1442  {
1443  global $ilDB,$ilBench;
1444 
1445  include_once ('./Services/AccessControl/classes/class.ilObjRole.php');
1446 
1447  $ilBench->start("Group", "getMemberRolesTitle");
1448 
1449  $str_member_roles ="";
1450 
1451  $q = "SELECT title ".
1452  "FROM object_data ".
1453  "LEFT JOIN rbac_ua ON object_data.obj_id=rbac_ua.rol_id ".
1454  "WHERE object_data.type = 'role' ".
1455  "AND rbac_ua.usr_id = ".$ilDB->quote($a_user_id)." ".
1456  "AND rbac_ua.rol_id IN (".implode(',',ilUtil::quoteArray($this->getLocalGroupRoles())).")";
1457 
1458  $r = $ilDB->query($q);
1459 
1460  while($row = $r->fetchRow(DB_FETCHMODE_ASSOC))
1461  {
1462  // display human readable role names for autogenerated roles
1463  $str_member_roles .= ilObjRole::_getTranslation($row["title"]).", ";
1464  }
1465 
1466  $ilBench->stop("Group", "getMemberRolesTitle");
1467 
1468  return substr($str_member_roles,0,-2);
1469  }
1470 
1471 
1478  function isAdmin($a_userId)
1479  {
1480  global $rbacreview;
1481 
1482  $grp_Roles = $this->getDefaultGroupRoles();
1483 
1484  if (in_array($a_userId,$rbacreview->assignedUsers($grp_Roles["grp_admin_role"])))
1485  {
1486  return true;
1487  }
1488  else
1489  {
1490  return false;
1491  }
1492  }
1493 
1494 
1495 
1501  function initDefaultRoles()
1502  {
1503  global $rbacadmin, $rbacreview;
1504 
1505  // create a local role folder
1506  $rfoldObj =& $this->createRoleFolder();
1507 
1508  // ADMIN ROLE
1509  // create role and assign role to rolefolder...
1510  $roleObj = $rfoldObj->createRole("il_grp_admin_".$this->getRefId(),"Groupadmin of group obj_no.".$this->getId());
1511  $this->m_roleAdminId = $roleObj->getId();
1512 
1513  //set permission template of new local role
1514  $q = "SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_admin'";
1515  $r = $this->ilias->db->getRow($q, DB_FETCHMODE_OBJECT);
1516  $rbacadmin->copyRoleTemplatePermissions($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
1517 
1518  // set object permissions of group object
1519  $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),"grp",$rfoldObj->getRefId());
1520  $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->getRefId());
1521 
1522  // set object permissions of role folder object
1523  //$ops = $rbacreview->getOperationsOfRole($roleObj->getId(),"rolf",$rfoldObj->getRefId());
1524  //$rbacadmin->grantPermission($roleObj->getId(),$ops,$rfoldObj->getRefId());
1525 
1526  // MEMBER ROLE
1527  // create role and assign role to rolefolder...
1528  $roleObj = $rfoldObj->createRole("il_grp_member_".$this->getRefId(),"Groupmember of group obj_no.".$this->getId());
1529  $this->m_roleMemberId = $roleObj->getId();
1530 
1531  //set permission template of new local role
1532  $q = "SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_member'";
1533  $r = $this->ilias->db->getRow($q, DB_FETCHMODE_OBJECT);
1534  $rbacadmin->copyRoleTemplatePermissions($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
1535 
1536  // set object permissions of group object
1537  $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),"grp",$rfoldObj->getRefId());
1538  $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->getRefId());
1539 
1540  // set object permissions of role folder object
1541  //$ops = $rbacreview->getOperationsOfRole($roleObj->getId(),"rolf",$rfoldObj->getRefId());
1542  //$rbacadmin->grantPermission($roleObj->getId(),$ops,$rfoldObj->getRefId());
1543 
1544  unset($rfoldObj);
1545  unset($roleObj);
1546 
1547  $roles[] = $this->m_roleAdminId;
1548  $roles[] = $this->m_roleMemberId;
1549 
1550  return $roles ? $roles : array();
1551  }
1552 
1563  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
1564  {
1565  global $tree;
1566 
1567  $parent_id = (int) $tree->getParentId($a_node_id);
1568 
1569  if ($parent_id != 0)
1570  {
1571  $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
1572  $obj_data->notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$parent_id,$a_params);
1573  }
1574 
1575  return true;
1576  }
1577 
1578 
1579  function exportXML()
1580  {
1581  include_once 'Modules/Group/classes/class.ilGroupXMLWriter.php';
1582 
1583  $xml_writer = new ilGroupXMLWriter($this);
1584  $xml_writer->start();
1585 
1586  $xml = $xml_writer->getXML();
1587 
1588  $name = time().'__'.$this->ilias->getSetting('inst_id').'__grp_'.$this->getId();
1589 
1590  $this->__initFileObject();
1591 
1592  $this->file_obj->addGroupDirectory();
1593  $this->file_obj->addDirectory($name);
1594  $this->file_obj->writeToFile($xml,$name.'/'.$name.'.xml');
1595  $this->file_obj->zipFile($name,$name.'.zip');
1596  $this->file_obj->deleteDirectory($name);
1597 
1598  return true;
1599  }
1600 
1601  function deleteExportFiles($a_files)
1602  {
1603  $this->__initFileObject();
1604 
1605  foreach($a_files as $file)
1606  {
1607  $this->file_obj->deleteFile($file);
1608  }
1609  return true;
1610  }
1611 
1613  {
1614  $this->__initFileObject();
1615 
1616  if($abs_name = $this->file_obj->getExportFile($file))
1617  {
1618  ilUtil::deliverFile($abs_name,$file);
1619  // Not reached
1620  }
1621  return false;
1622  }
1623 
1632  function _importFromXMLString($xml,$parent_id)
1633  {
1634  include_once 'Modules/Group/classes/class.ilGroupXMLParser.php';
1635 
1636  $import_parser = new ilGroupXMLParser($xml,$parent_id);
1637 
1638  return $import_parser->startParsing();
1639  }
1640 
1648  function _importFromFile($file,$parent_id)
1649  {
1650  global $lng;
1651 
1652  include_once 'classes/class.ilFileDataGroup.php';
1653 
1654  $file_obj = new ilFileDataGroup(null);
1655  $file_obj->addImportDirectory();
1656  $file_obj->createImportFile($_FILES["xmldoc"]["tmp_name"],$_FILES['xmldoc']['name']);
1657  $file_obj->unpackImportFile();
1658 
1659  if(!$file_obj->validateImportFile())
1660  {
1661  return false;
1662  }
1663  return ilObjGroup::_importFromXMLString(file_get_contents($file_obj->getImportFile()),$parent_id);
1664  }
1665 
1674  function _search(&$a_search_obj)
1675  {
1676  global $ilBench;
1677 
1678  // NO CLASS VARIABLES IN STATIC METHODS
1679 
1680  $where_condition = $a_search_obj->getWhereCondition("like",array("title","description"));
1681  $in = $a_search_obj->getInStatement("ore.ref_id");
1682 
1683  $query = "SELECT ore.ref_id AS ref_id FROM object_data AS od, object_reference AS ore ".
1684  $where_condition." ".
1685  $in." ".
1686  "AND od.obj_id = ore.obj_id ".
1687  "AND od.type = 'grp' ";
1688 
1689  $ilBench->start("Search", "ilObjGroup_search");
1690  $res = $a_search_obj->ilias->db->query($query);
1691  $ilBench->stop("Search", "ilObjGroup_search");
1692 
1693  $counter = 0;
1694 
1695  while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
1696  {
1697  $result_data[$counter++]["id"] = $row->ref_id;
1698  #$result_data[$counter]["link"] = "group.php?cmd=view&ref_id=".$row->ref_id;
1699  #$result_data[$counter++]["target"] = "";
1700  }
1701 
1702  return $result_data ? $result_data : array();
1703  }
1704 
1713  function _getLinkToObject($a_id)
1714  {
1715  return array("repository.php?ref_id=".$a_id."&set_mode=flat&cmdClass=ilobjgroupgui","");
1716  }
1717 
1718  function _lookupIdByTitle($a_title)
1719  {
1720  global $ilDB;
1721 
1722  $query = "SELECT * FROM object_data WHERE title = ".
1723  $ilDB->quote($a_title)." AND type = 'grp'";
1724  $res = $ilDB->query($query);
1725  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
1726  {
1727  return $row->obj_id;
1728  }
1729  return 0;
1730  }
1731 
1732 
1733  function _isMember($a_user_id,$a_ref_id,$a_field = '')
1734  {
1735  global $rbacreview,$ilObjDataCache,$ilDB;
1736 
1737  $rolf = $rbacreview->getRoleFolderOfObject($a_ref_id);
1738  $local_roles = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"],false);
1739  $user_roles = $rbacreview->assignedRoles($a_user_id);
1740 
1741  // Used for membership limitations -> check membership by given field
1742  if($a_field)
1743  {
1744  include_once './Services/User/classes/class.ilObjUser.php';
1745 
1746  $tmp_user =& ilObjectFactory::getInstanceByObjId($a_user_id);
1747  switch($a_field)
1748  {
1749  case 'login':
1750  $and = "AND login = '".$tmp_user->getLogin()."' ";
1751  break;
1752  case 'email':
1753  $and = "AND email = '".$tmp_user->getEmail()."' ";
1754  break;
1755  case 'matriculation':
1756  $and = "AND matriculation = '".$tmp_user->getMatriculation()."' ";
1757  break;
1758 
1759  default:
1760  $and = "AND usr_id = '".$a_user_id."'";
1761  break;
1762  }
1763  if(!$members = ilObjGroup::_getMembers($ilObjDataCache->lookupObjId($a_ref_id)))
1764  {
1765  return false;
1766  }
1767  $query = "SELECT * FROM usr_data as ud ".
1768  "WHERE usr_id IN (".implode(",",ilUtil::quoteArray($members)).") ".
1769  $and;
1770  $res = $ilDB->query($query);
1771 
1772  return $res->numRows() ? true : false;
1773  }
1774 
1775  if (!array_intersect($local_roles,$user_roles))
1776  {
1777  return false;
1778  }
1779 
1780  return true;
1781  }
1782 
1783  function _getMembers($a_obj_id)
1784  {
1785  global $rbacreview;
1786 
1787  // get reference
1788  $ref_ids = ilObject::_getAllReferences($a_obj_id);
1789  $ref_id = current($ref_ids);
1790 
1791  $rolf = $rbacreview->getRoleFolderOfObject($ref_id);
1792  $local_roles = $rbacreview->getRolesOfRoleFolder($rolf['ref_id'],false);
1793 
1794  $users = array();
1795  foreach($local_roles as $role_id)
1796  {
1797  $users = array_merge($users,$rbacreview->assignedUsers($role_id));
1798  }
1799 
1800  return array_unique($users);
1801  }
1802 
1809  public function getViewMode()
1810  {
1811  global $tree;
1812 
1813  // default: by type
1814  $view = ilContainer::VIEW_BY_TYPE;
1815 
1816  if ($course_ref_id = $tree->checkForParentType($this->ref_id,'crs'))
1817  {
1818  include_once("./Modules/Course/classes/class.ilObjCourse.php");
1819  $view_mode = ilObjCourse::_lookupViewMode(
1820  ilObject::_lookupObjId($course_ref_id));
1821  if ($view_mode == ilContainer::VIEW_SESSIONS ||
1822  $view_mode == ilContainer::VIEW_BY_TYPE ||
1823  $view_mode == ilContainer::VIEW_SIMPLE)
1824  {
1825  $view = $view_mode;
1826  }
1827  }
1828  return $view;
1829  }
1830 
1835  function addAdditionalSubItemInformation(&$a_item_data)
1836  {
1837  global $tree;
1838 
1839  static $items = null;
1840 
1841  if(!is_object($items[$this->getRefId()]))
1842  {
1843  if ($course_ref_id = $tree->checkForParentType($this->getRefId(),'crs'))
1844  {
1845  include_once("./Modules/Course/classes/class.ilObjCourse.php");
1846  include_once("./Modules/Course/classes/class.ilCourseItems.php");
1847  $course_obj = new ilObjCourse($course_ref_id);
1848  $items[$this->getRefId()] = new ilCourseItems($course_obj, $this->getRefId());
1849  }
1850  }
1851  if(is_object($items[$this->getRefId()]))
1852  {
1853  $items[$this->getRefId()]->addAdditionalSubItemInformation($a_item_data);
1854  }
1855  }
1856 
1857 
1858  // Private / Protected
1859  function __initFileObject()
1860  {
1861  if($this->file_obj)
1862  {
1863  return $this->file_obj;
1864  }
1865  else
1866  {
1867  include_once 'classes/class.ilFileDataGroup.php';
1868 
1869  return $this->file_obj = new ilFileDataGroup($this);
1870  }
1871  }
1872 
1873  function getMessage()
1874  {
1875  return $this->message;
1876  }
1877  function setMessage($a_message)
1878  {
1879  $this->message = $a_message;
1880  }
1881  function appendMessage($a_message)
1882  {
1883  if($this->getMessage())
1884  {
1885  $this->message .= "<br /> ";
1886  }
1887  $this->message .= $a_message;
1888  }
1889 
1897  protected function prepareAppointments($a_mode = 'create')
1898  {
1899  include_once('./Services/Calendar/classes/class.ilCalendarAppointmentTemplate.php');
1900 
1901  switch($a_mode)
1902  {
1903  case 'create':
1904  case 'update':
1905  if($this->isRegistrationUnlimited())
1906  {
1907  return array();
1908  }
1909  $app = new ilCalendarAppointmentTemplate(self::CAL_REG_START);
1910  $app->setTitle($this->getTitle());
1911  $app->setSubtitle('grp_cal_reg_start');
1912  $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
1913  $app->setDescription($this->getLongDescription());
1914  $app->setStart($this->getRegistrationStart());
1915  $apps[] = $app;
1916 
1917  $app = new ilCalendarAppointmentTemplate(self::CAL_REG_END);
1918  $app->setTitle($this->getTitle());
1919  $app->setSubtitle('grp_cal_reg_end');
1920  $app->setTranslationType(IL_CAL_TRANSLATION_SYSTEM);
1921  $app->setDescription($this->getLongDescription());
1922  $app->setStart($this->getRegistrationEnd());
1923  $apps[] = $app;
1924 
1925  return $apps;
1926 
1927  case 'delete':
1928  // Nothing to do: The category and all assigned appointments will be deleted.
1929  return array();
1930  }
1931  }
1932 
1940  protected function initParticipants()
1941  {
1942  include_once('./Modules/Group/classes/class.ilGroupParticipants.php');
1943  $this->members_obj = ilGroupParticipants::_getInstanceByObjId($this->getId());
1944  }
1945 
1946 } //END class.ilObjGroup
1947 ?>