27 require_once
"./Services/Container/classes/class.ilContainer.php";
28 include_once(
'./Services/Calendar/classes/class.ilDateTime.php');
29 include_once
'./Services/Membership/interfaces/interface.ilMembershipRegistrationCodes.php';
31 define(
'GRP_REGISTRATION_DEACTIVATED',-1);
32 define(
'GRP_REGISTRATION_DIRECT',0);
33 define(
'GRP_REGISTRATION_REQUEST',1);
34 define(
'GRP_REGISTRATION_PASSWORD',2);
36 define(
'GRP_REGISTRATION_LIMITED',1);
37 define(
'GRP_REGISTRATION_UNLIMITED',2);
39 define(
'GRP_TYPE_UNKNOWN',0);
40 define(
'GRP_TYPE_CLOSED',1);
41 define(
'GRP_TYPE_OPEN',2);
42 define(
'GRP_TYPE_PUBLIC',3);
114 public function __construct($a_id = 0,$a_call_by_reference =
true)
118 $this->tree =& $tree;
121 $this->
ilObject($a_id,$a_call_by_reference);
134 $query =
"SELECT grp_type FROM grp_settings ".
135 "WHERE obj_id = ".$ilDB->quote($a_id,
'integer');
139 return $row->grp_type;
154 $this->information = $a_information;
177 $this->group_type = $a_type;
220 $this->reg_type = $a_type;
254 $this->reg_unlimited = $a_status;
277 $this->reg_start = $a_start;
288 return $this->reg_start ? $this->reg_start : $this->reg_start =
new ilDateTime(date(
'Y-m-d').
' 08:00:00',
IL_CAL_DATETIME);
301 $this->reg_end = $a_end;
323 $this->reg_password = $a_pass;
346 $this->reg_membership_limitation = $a_status;
368 $this->reg_max_members = $a_max;
391 $this->waiting_list = $a_status;
413 $this->latitude = $a_latitude;
433 $this->longitude = $a_longitude;
453 $this->locationzoom = $a_locationzoom;
473 $this->enablemap = $a_enablemap;
502 $this->reg_access_code = $a_code;
521 $this->reg_access_code_enabled = $a_status;
539 $ilErr->appendMessage($this->lng->txt(self::ERR_MISSING_TITLE));
543 $ilErr->appendMessage($this->lng->txt(self::ERR_MISSING_GROUP_TYPE));
547 $ilErr->appendMessage($this->lng->txt(self::ERR_MISSING_PASSWORD));
551 $ilErr->appendMessage($this->lng->txt(self::ERR_WRONG_REG_TIME_LIMIT));
555 $ilErr->appendMessage($this->lng->txt(self::ERR_WRONG_MAX_MEMBERS));
557 return strlen($ilErr->getMessage()) == 0;
568 global
$ilDB,$ilAppEventHandler;
570 if(!parent::create())
575 $query =
"INSERT INTO grp_settings (obj_id,information,grp_type,registration_type,registration_enabled,".
576 "registration_unlimited,registration_start,registration_end,registration_password,registration_mem_limit,".
577 "registration_max_members,waiting_list,latitude,longitude,location_zoom,enablemap,reg_ac_enabled,reg_ac,view_mode) ".
579 $ilDB->quote($this->
getId() ,
'integer').
", ".
581 $ilDB->quote((
int) $this->
getGroupType() ,
'integer').
", ".
601 $ilAppEventHandler->raise(
'Modules/Group',
603 array(
'object' => $this,
604 'obj_id' => $this->
getId(),
607 return $this->
getId();
615 global
$ilDB,$ilAppEventHandler;
617 if (!parent::update())
622 $query =
"UPDATE grp_settings ".
623 "SET information = ".$ilDB->quote($this->
getInformation() ,
'text').
", ".
624 "grp_type = ".$ilDB->quote((
int) $this->
getGroupType() ,
'integer').
", ".
630 "registration_password = ".$ilDB->quote($this->
getPassword() ,
'text').
", ".
632 "registration_mem_limit = ".$ilDB->quote((
int) $this->
isMembershipLimited() ,
'integer').
", ".
633 "registration_max_members = ".$ilDB->quote($this->
getMaxMembers() ,
'integer').
", ".
635 "latitude = ".$ilDB->quote($this->
getLatitude() ,
'text').
", ".
636 "longitude = ".$ilDB->quote($this->
getLongitude() ,
'text').
", ".
637 "location_zoom = ".$ilDB->quote($this->
getLocationZoom() ,
'integer').
", ".
641 'view_mode = '.$ilDB->quote($this->
getViewMode(),
'integer').
' '.
642 "WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer').
" ";
645 $ilAppEventHandler->raise(
'Modules/Group',
647 array(
'object' => $this,
648 'obj_id' => $this->
getId(),
661 public function delete()
663 global
$ilDB,$ilAppEventHandler;
666 if (!parent::delete())
671 $query =
"DELETE FROM grp_settings ".
672 "WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer');
675 include_once(
'./Modules/Group/classes/class.ilGroupParticipants.php');
678 $ilAppEventHandler->raise(
'Modules/Group',
680 array(
'object' => $this,
681 'obj_id' => $this->
getId(),
698 $query =
"SELECT * FROM grp_settings ".
699 "WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer');
725 include_once(
'./Services/Container/classes/class.ilContainerSortingSettings.php');
739 global
$ilDB,$ilUser;
763 include_once
'./Services/Membership/classes/class.ilMembershipRegistrationCodeUtils.php';
771 $ilLog->write(__METHOD__.
': Starting add user');
774 include_once(
'./Modules/Group/classes/class.ilGroupParticipants.php');
777 $part->updateNotification($ilUser->getId(),1);
780 include_once(
'Services/Tracking/classes/class.ilLPObjSettings.php');
782 $obj_settings->cloneSettings($new_obj->getId());
783 unset($obj_settings);
807 if($course_ref_id = $tree->checkForParentType($this->getRefId(),
'crs') and
808 $new_course_ref_id = $tree->checkForParentType($a_target_id,
'crs'))
810 include_once(
'Modules/Course/classes/class.ilCourseItems.php');
816 include_once(
'Services/Tracking/classes/class.ilLPCollections.php');
818 $lp_collection->cloneCollections($a_target_id,$a_copy_id);
832 global
$ilLog,$rbacadmin,$rbacreview;
835 $new_admin = $new_obj->getDefaultAdminRole();
836 $source_rolf = $rbacreview->getRoleFolderIdOfObject($this->
getRefId());
837 $target_rolf = $rbacreview->getRoleFolderIdOfObject($new_obj->getRefId());
839 if(!$admin || !$new_admin || !$source_rolf || !$target_rolf)
841 $ilLog->write(__METHOD__.
' : Error cloning auto generated role: il_grp_admin');
843 $rbacadmin->copyRolePermissions($admin,$source_rolf,$target_rolf,$new_admin,
true);
844 $ilLog->write(__METHOD__.
' : Finished copying of role il_grp_admin.');
847 $new_member = $new_obj->getDefaultMemberRole();
848 if(!$member || !$new_member)
850 $ilLog->write(__METHOD__.
' : Error cloning auto generated role: il_grp_member');
852 $rbacadmin->copyRolePermissions($member,$source_rolf,$target_rolf,$new_member,
true);
853 $ilLog->write(__METHOD__.
' : Finished copying of role grp_member.');
862 function join($a_user_id, $a_mem_role=
"")
866 if (is_array($a_mem_role))
868 foreach ($a_mem_role as $role)
870 $rbacadmin->assignUser($role,$a_user_id,
false);
875 $rbacadmin->assignUser($a_mem_role,$a_user_id,
false);
889 return $local_group_Roles[
"il_grp_member_".$this->getRefId()];
900 return $local_group_Roles[
"il_grp_admin_".$this->getRefId()];
913 if (isset($a_user_id) && isset($a_mem_role) )
915 $this->
join($a_user_id,$a_mem_role);
920 $this->ilias->raiseError(get_class($this).
"::addMember(): Missing parameters !",$this->ilias->error_obj->WARNING);
934 global $rbacadmin, $rbacreview;
938 if (count($member_ids) <= 1 || !in_array($this->ilias->account->getId(), $member_ids))
944 if (!$this->
isAdmin($this->ilias->account->getId()))
946 $this->
leave($this->ilias->account->getId());
947 $member =
new ilObjUser($this->ilias->account->getId());
969 if (is_array($arr_groupRoles))
971 foreach ($arr_groupRoles as $groupRole)
973 $rbacadmin->deassignUser($groupRole, $a_user_id);
978 $rbacadmin->deassignUser($arr_groupRoles, $a_user_id);
992 global $rbacadmin, $rbacreview;
998 foreach ($rol as $value)
1000 foreach ($rbacreview->assignedUsers($value) as $member_id)
1002 array_push($usr_arr,$member_id);
1006 $mem_arr = array_unique($usr_arr);
1008 return $mem_arr ? $mem_arr : array();
1024 $q =
"SELECT login,firstname,lastname,title,usr_id,last_login ".
1028 if (is_numeric($active) && $active > -1)
1029 $q .=
"AND active = '$active'";
1031 $q .=
'ORDER BY lastname,firstname';
1033 $r = $ilDB->query($q);
1037 $mem_arr[] = array(
"id" =>
$row->usr_id,
1038 "login" =>
$row->login,
1039 "firstname" =>
$row->firstname,
1040 "lastname" =>
$row->lastname,
1041 "last_login" =>
$row->last_login
1045 return $mem_arr ? $mem_arr : array();
1063 if (!empty($a_grpId))
1075 foreach ($rbacreview->assignedUsers($this->getDefaultAdminRole()) as $member_id)
1077 array_push($usr_arr,$member_id);
1090 global $rbacadmin, $rbacreview;
1092 if (strlen($a_grp_id) > 0)
1094 $grp_id = $a_grp_id;
1101 $rolf = $rbacreview->getRoleFolderOfObject($grp_id);
1102 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"]);
1104 foreach ($role_arr as $role_id)
1106 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
1108 $grp_Member =
"il_grp_member_".$grp_id;
1109 $grp_Admin =
"il_grp_admin_".$grp_id;
1111 if (strcmp($role_Obj->getTitle(), $grp_Member) == 0 )
1113 $arr_grpDefaultRoles[
"grp_member_role"] = $role_Obj->getId();
1116 if (strcmp($role_Obj->getTitle(), $grp_Admin) == 0)
1118 $arr_grpDefaultRoles[
"grp_admin_role"] = $role_Obj->getId();
1122 return $arr_grpDefaultRoles;
1133 global $rbacadmin,$rbacreview;
1135 if (empty($this->local_roles))
1137 $this->local_roles = array();
1138 $rolf = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1139 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"]);
1141 foreach ($role_arr as $role_id)
1143 if ($rbacreview->isAssignable($role_id,$rolf[
"ref_id"]) ==
true)
1145 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
1153 $role_name = $role_Obj->getTitle();
1156 $this->local_roles[$role_name] = $role_Obj->getId();
1161 return $this->local_roles;
1171 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_closed'";
1172 $res = $this->ilias->db->query($q);
1175 return $row[
"obj_id"];
1185 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_open'";
1186 $res = $this->ilias->db->query($q);
1189 return $row[
"obj_id"];
1205 global $tree,$rbacreview,$rbacadmin;
1207 $parent_roles = $rbacreview->getParentRoleIds($this->
getRefId());
1209 $rolf_data = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1212 foreach($real_parent_roles as $role_id)
1215 if(isset($rolf_data[
'child']) and $rolf_data[
'child'])
1217 $rbacadmin->deleteLocalRole($role_id,$rolf_data[
'child']);
1220 $parent_roles = $rbacreview->getParentRoleIds($this->
getRefId());
1235 foreach($tree->getFilteredSubTree($this->getRefId(),array(
'rolf',
'grp')) as $subnode)
1238 $template_ops = $rbacreview->getOperationsOfRole($template_id,$subnode[
'type'], ROLE_FOLDER_ID);
1240 $rolf_data = $rbacreview->getRoleFolderOfObject($subnode[
'child']);
1244 foreach($real_parent_roles as $role_id)
1246 if($rbacreview->isProtected($parent_roles[$role_id][
'parent'],$role_id))
1252 if(isset($rolf_data[
'child']) and $rolf_data[
'child'])
1254 $rbacadmin->deleteLocalRole($role_id,$rolf_data[
'child']);
1258 $current_ops = $rbacreview->getOperationsOfRole($role_id,$subnode[
'type'],$parent_roles[$role_id][
'parent']);
1261 $rbacadmin->revokePermission($subnode[
'child'],$role_id);
1265 foreach($template_ops as $operation)
1267 if(in_array($operation,$current_ops))
1269 $granted[] = $operation;
1274 $rbacadmin->grantPermission($role_id, $granted,$subnode[
'child']);
1280 $rbacadmin->copyRolePermissionIntersection(
1281 $template_id, ROLE_FOLDER_ID,
1282 $role_id, $parent_roles[$role_id][
'parent'],
1283 $rolf_data[
"child"],$role_id);
1284 $rbacadmin->assignRoleToFolder($role_id,$rolf_data[
"child"],
"n");
1311 global $rbacadmin, $rbacreview, $rbacsystem;
1314 $rolf_data = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1317 $arr_parentRoles = $rbacreview->getParentRoleIds($this->
getRefId());
1319 $real_local_roles = $rbacreview->getRolesOfRoleFolder($rolf_data[
'ref_id'],
false);
1320 $arr_relevantParentRoleIds = array_diff(array_keys($arr_parentRoles),$real_local_roles);
1334 $template_ops = $rbacreview->getOperationsOfRole($template_id,
'grp', ROLE_FOLDER_ID);
1336 foreach ($arr_relevantParentRoleIds as $parentRole)
1338 if ($rbacreview->isProtected($arr_parentRoles[$parentRole][
'parent'],$parentRole))
1343 $granted_permissions = array();
1350 if(isset($rolf_data[
'child']) and $rolf_data[
'child'])
1352 $rbacadmin->deleteLocalRole($parentRole,$rolf_data[
"child"]);
1360 $current_ops = $rbacreview->getRoleOperationsOnObject($parentRole, $this->
getRefId());
1361 $rbacadmin->revokePermission($this->
getRefId(), $parentRole);
1362 foreach ($template_ops as $template_op)
1364 if (in_array($template_op,$current_ops))
1366 array_push($granted_permissions,$template_op);
1369 if (!empty($granted_permissions))
1371 $rbacadmin->grantPermission($parentRole, $granted_permissions, $this->
getRefId());
1378 $rbacadmin->copyRolePermissionIntersection(
1379 $template_id, ROLE_FOLDER_ID,
1380 $parentRole, $arr_parentRoles[$parentRole][
'parent'],
1381 $rolf_data[
"child"], $parentRole
1383 $rbacadmin->assignRoleToFolder($parentRole,$rolf_data[
"child"],
"false");
1397 $this->group_status = $a_status;
1409 return $this->group_status;
1419 global $rbacsystem,$rbacreview;
1421 $role_folder = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1422 $local_roles = $rbacreview->getRolesOfRoleFolder($role_folder[
"ref_id"]);
1425 $rolf_data = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1430 foreach ($arr_globalRoles as $globalRole)
1432 $ops_of_role = $rbacreview->getOperationsOfRole($globalRole,
"grp", ROLE_FOLDER_ID);
1434 if ($rbacsystem->checkPermission($this->getRefId(), $globalRole ,
"join"))
1451 global $rbacadmin, $rbacreview,
$ilBench;
1453 $ilBench->start(
"Group",
"getMemberRoles");
1455 $arr_assignedRoles = array();
1457 $arr_assignedRoles = array_intersect($rbacreview->assignedRoles($a_user_id),$this->
getLocalGroupRoles());
1459 $ilBench->stop(
"Group",
"getMemberRoles");
1461 return $arr_assignedRoles;
1476 if (in_array($a_userId,$rbacreview->assignedUsers($grp_Roles[
"grp_admin_role"])))
1495 global $rbacadmin, $rbacreview;
1502 $roleObj = $rfoldObj->createRole(
"il_grp_admin_".$this->
getRefId(),
"Groupadmin of group obj_no.".$this->
getId());
1503 $this->m_roleAdminId = $roleObj->getId();
1506 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_admin'";
1508 $rbacadmin->copyRoleTemplatePermissions($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
1511 $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),
"grp",$rfoldObj->getRefId());
1512 $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->
getRefId());
1520 $roleObj = $rfoldObj->createRole(
"il_grp_member_".$this->
getRefId(),
"Groupmember of group obj_no.".$this->
getId());
1521 $this->m_roleMemberId = $roleObj->getId();
1524 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_member'";
1526 $rbacadmin->copyRoleTemplatePermissions($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
1529 $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),
"grp",$rfoldObj->getRefId());
1530 $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->
getRefId());
1542 return $roles ? $roles : array();
1555 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
1559 $parent_id = (int) $tree->getParentId($a_node_id);
1561 if ($parent_id != 0)
1563 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
1564 $obj_data->notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$parent_id,$a_params);
1573 include_once
'Modules/Group/classes/class.ilGroupXMLWriter.php';
1576 $xml_writer->start();
1578 $xml = $xml_writer->getXML();
1580 $name = time().
'__'.$this->ilias->getSetting(
'inst_id').
'__grp_'.$this->
getId();
1584 $this->file_obj->addGroupDirectory();
1585 $this->file_obj->addDirectory($name);
1586 $this->file_obj->writeToFile($xml,$name.
'/'.$name.
'.xml');
1587 $this->file_obj->zipFile($name,$name.
'.zip');
1588 $this->file_obj->deleteDirectory($name);
1597 foreach($a_files as
$file)
1599 $this->file_obj->deleteFile($file);
1608 if($abs_name = $this->file_obj->getExportFile(
$file))
1626 include_once
'Modules/Group/classes/class.ilGroupXMLParser.php';
1630 return $import_parser->startParsing();
1644 include_once
'classes/class.ilFileDataGroup.php';
1648 $file_obj->createImportFile($_FILES[
"xmldoc"][
"tmp_name"],$_FILES[
'xmldoc'][
'name']);
1668 return array(
"repository.php?ref_id=".$a_id.
"&set_mode=flat&cmdClass=ilobjgroupgui",
"");
1675 $query =
"SELECT * FROM object_data WHERE title = ".
1676 $ilDB->quote($a_title ,
'text').
" AND type = 'grp'";
1680 return $row->obj_id;
1688 global $rbacreview,$ilObjDataCache,
$ilDB;
1690 $rolf = $rbacreview->getRoleFolderOfObject($a_ref_id);
1691 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
1692 $user_roles = $rbacreview->assignedRoles($a_user_id);
1697 include_once
'./Services/User/classes/class.ilObjUser.php';
1703 $and =
"AND login = '".$tmp_user->getLogin().
"' ";
1706 $and =
"AND email = '".$tmp_user->getEmail().
"' ";
1708 case 'matriculation':
1709 $and =
"AND matriculation = '".$tmp_user->getMatriculation().
"' ";
1713 $and =
"AND usr_id = '".$a_user_id.
"'";
1720 $query =
"SELECT * FROM usr_data as ud ".
1725 return $res->numRows() ?
true :
false;
1728 if (!array_intersect($local_roles,$user_roles))
1744 $rolf = $rbacreview->getRoleFolderOfObject(
$ref_id);
1745 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
'ref_id'],
false);
1748 foreach($local_roles as $role_id)
1750 $users = array_merge($users,$rbacreview->assignedUsers($role_id));
1753 return array_unique($users);
1771 if ($course_ref_id = $tree->checkForParentType($this->ref_id,
'crs'))
1773 include_once(
"./Modules/Course/classes/class.ilObjCourse.php");
1792 $this->view_mode = $a_view_mode;
1803 $query =
'SELECT view_mode FROM grp_settings '.
1804 'WHERE obj_id = '.$ilDB->quote($a_obj_id,
'integer');
1827 return $a_view_mode;
1835 $crs_ref = $tree->checkForParentType(
$ref_id,
'crs');
1841 include_once
'./Modules/Course/classes/class.ilObjCourse.php';
1848 return $a_view_mode;
1861 static $items = null;
1863 if(!is_object($items[$this->
getRefId()]))
1865 if ($course_ref_id = $tree->checkForParentType($this->getRefId(),
'crs'))
1867 include_once(
"./Modules/Course/classes/class.ilObjCourse.php");
1868 include_once(
"./Modules/Course/classes/class.ilCourseItems.php");
1873 if(is_object($items[$this->
getRefId()]))
1889 include_once
'classes/class.ilFileDataGroup.php';
1897 return $this->message;
1901 $this->message = $a_message;
1907 $this->message .=
"<br /> ";
1909 $this->message .= $a_message;
1921 include_once(
'./Services/Calendar/classes/class.ilCalendarAppointmentTemplate.php');
1933 $app->setSubtitle(
'grp_cal_reg_start');
1941 $app->setSubtitle(
'grp_cal_reg_end');
1964 include_once(
'./Modules/Group/classes/class.ilGroupParticipants.php');
1976 $query =
"SELECT obj_id FROM grp_settings ".
1977 "WHERE reg_ac_enabled = ".$ilDB->quote(1,
'integer').
" ".
1978 "AND reg_ac = ".$ilDB->quote($a_code,
'text');
1984 $obj_ids[] =
$row->obj_id;
1995 public function register($a_user_id,$a_role =
IL_GRP_MEMBER, $a_force_registration =
false)
1997 include_once
'./Services/Membership/exceptions/class.ilMembershipRegistrationException.php';
1998 include_once
"./Modules/Group/classes/class.ilGroupParticipants.php";
2001 if($part->isAssigned($a_user_id))
2006 if(!$a_force_registration)
2009 include_once
'./Modules/Group/classes/class.ilObjGroupAccess.php';
2012 $this->lng->loadLanguageModule(
'crs');
2018 $free = max(0,$this->
getMaxMembers() - $part->getCountMembers());
2019 include_once(
'./Modules/Group/classes/class.ilGroupWaitingList.php');
2028 $part->add($a_user_id,$a_role);
2029 $part->sendNotification($part->TYPE_NOTIFICATION_REGISTRATION, $a_user_id);