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);
112 public function __construct($a_id = 0,$a_call_by_reference =
true)
116 $this->tree =& $tree;
119 $this->
ilObject($a_id,$a_call_by_reference);
132 $query =
"SELECT grp_type FROM grp_settings ".
133 "WHERE obj_id = ".$ilDB->quote($a_id,
'integer');
137 return $row->grp_type;
152 $this->information = $a_information;
175 $this->group_type = $a_type;
218 $this->reg_type = $a_type;
252 $this->reg_unlimited = $a_status;
275 $this->reg_start = $a_start;
286 return $this->reg_start ? $this->reg_start : $this->reg_start =
new ilDateTime(date(
'Y-m-d').
' 08:00:00',
IL_CAL_DATETIME);
299 $this->reg_end = $a_end;
321 $this->reg_password = $a_pass;
344 $this->reg_membership_limitation = $a_status;
366 $this->reg_max_members = $a_max;
389 $this->waiting_list = $a_status;
411 $this->latitude = $a_latitude;
431 $this->longitude = $a_longitude;
451 $this->locationzoom = $a_locationzoom;
471 $this->enablemap = $a_enablemap;
500 $this->reg_access_code = $a_code;
519 $this->reg_access_code_enabled = $a_status;
537 $ilErr->appendMessage($this->lng->txt(self::ERR_MISSING_TITLE));
541 $ilErr->appendMessage($this->lng->txt(self::ERR_MISSING_GROUP_TYPE));
545 $ilErr->appendMessage($this->lng->txt(self::ERR_MISSING_PASSWORD));
549 $ilErr->appendMessage($this->lng->txt(self::ERR_WRONG_REG_TIME_LIMIT));
553 $ilErr->appendMessage($this->lng->txt(self::ERR_WRONG_MAX_MEMBERS));
555 return strlen($ilErr->getMessage()) == 0;
566 global
$ilDB,$ilAppEventHandler;
568 if(!parent::create())
573 $query =
"INSERT INTO grp_settings (obj_id,information,grp_type,registration_type,registration_enabled,".
574 "registration_unlimited,registration_start,registration_end,registration_password,registration_mem_limit,".
575 "registration_max_members,waiting_list,latitude,longitude,location_zoom,enablemap,reg_ac_enabled,reg_ac) ".
577 $ilDB->quote($this->
getId() ,
'integer').
", ".
579 $ilDB->quote((
int) $this->
getGroupType() ,
'integer').
", ".
598 $ilAppEventHandler->raise(
'Modules/Group',
600 array(
'object' => $this,
601 'obj_id' => $this->
getId(),
604 return $this->
getId();
612 global
$ilDB,$ilAppEventHandler;
614 if (!parent::update())
619 $query =
"UPDATE grp_settings ".
620 "SET information = ".$ilDB->quote($this->
getInformation() ,
'text').
", ".
621 "grp_type = ".$ilDB->quote((
int) $this->
getGroupType() ,
'integer').
", ".
627 "registration_password = ".$ilDB->quote($this->
getPassword() ,
'text').
", ".
629 "registration_mem_limit = ".$ilDB->quote((
int) $this->
isMembershipLimited() ,
'integer').
", ".
630 "registration_max_members = ".$ilDB->quote($this->
getMaxMembers() ,
'integer').
", ".
632 "latitude = ".$ilDB->quote($this->
getLatitude() ,
'text').
", ".
633 "longitude = ".$ilDB->quote($this->
getLongitude() ,
'text').
", ".
634 "location_zoom = ".$ilDB->quote($this->
getLocationZoom() ,
'integer').
", ".
638 "WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer').
" ";
641 $ilAppEventHandler->raise(
'Modules/Group',
643 array(
'object' => $this,
644 'obj_id' => $this->
getId(),
657 public function delete()
659 global
$ilDB,$ilAppEventHandler;
662 if (!parent::delete())
667 $query =
"DELETE FROM grp_settings ".
668 "WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer');
671 include_once(
'./Modules/Group/classes/class.ilGroupParticipants.php');
674 $ilAppEventHandler->raise(
'Modules/Group',
676 array(
'object' => $this,
677 'obj_id' => $this->
getId(),
694 $query =
"SELECT * FROM grp_settings ".
695 "WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer');
720 include_once(
'./Services/Container/classes/class.ilContainerSortingSettings.php');
734 global
$ilDB,$ilUser;
758 include_once
'./Services/Membership/classes/class.ilMembershipRegistrationCodeUtils.php';
764 $ilLog->write(__METHOD__.
': Starting add user');
767 include_once(
'./Modules/Group/classes/class.ilGroupParticipants.php');
770 $part->updateNotification($ilUser->getId(),1);
773 include_once(
'Services/Tracking/classes/class.ilLPObjSettings.php');
775 $obj_settings->cloneSettings($new_obj->getId());
776 unset($obj_settings);
800 if($course_ref_id = $tree->checkForParentType($this->getRefId(),
'crs') and
801 $new_course_ref_id = $tree->checkForParentType($a_target_id,
'crs'))
803 include_once(
'Modules/Course/classes/class.ilCourseItems.php');
809 include_once(
'Services/Tracking/classes/class.ilLPCollections.php');
811 $lp_collection->cloneCollections($a_target_id,$a_copy_id);
825 global
$ilLog,$rbacadmin,$rbacreview;
828 $new_admin = $new_obj->getDefaultAdminRole();
829 $source_rolf = $rbacreview->getRoleFolderIdOfObject($this->
getRefId());
830 $target_rolf = $rbacreview->getRoleFolderIdOfObject($new_obj->getRefId());
832 if(!$admin || !$new_admin || !$source_rolf || !$target_rolf)
834 $ilLog->write(__METHOD__.
' : Error cloning auto generated role: il_grp_admin');
836 $rbacadmin->copyRolePermissions($admin,$source_rolf,$target_rolf,$new_admin,
true);
837 $ilLog->write(__METHOD__.
' : Finished copying of role il_grp_admin.');
840 $new_member = $new_obj->getDefaultMemberRole();
841 if(!$member || !$new_member)
843 $ilLog->write(__METHOD__.
' : Error cloning auto generated role: il_grp_member');
845 $rbacadmin->copyRolePermissions($member,$source_rolf,$target_rolf,$new_member,
true);
846 $ilLog->write(__METHOD__.
' : Finished copying of role grp_member.');
855 function join($a_user_id, $a_mem_role=
"")
859 if (is_array($a_mem_role))
861 foreach ($a_mem_role as $role)
863 $rbacadmin->assignUser($role,$a_user_id,
false);
868 $rbacadmin->assignUser($a_mem_role,$a_user_id,
false);
882 return $local_group_Roles[
"il_grp_member_".$this->getRefId()];
893 return $local_group_Roles[
"il_grp_admin_".$this->getRefId()];
906 if (isset($a_user_id) && isset($a_mem_role) )
908 $this->
join($a_user_id,$a_mem_role);
913 $this->ilias->raiseError(get_class($this).
"::addMember(): Missing parameters !",$this->ilias->error_obj->WARNING);
927 global $rbacadmin, $rbacreview;
931 if (count($member_ids) <= 1 || !in_array($this->ilias->account->getId(), $member_ids))
937 if (!$this->
isAdmin($this->ilias->account->getId()))
939 $this->
leave($this->ilias->account->getId());
940 $member =
new ilObjUser($this->ilias->account->getId());
962 if (is_array($arr_groupRoles))
964 foreach ($arr_groupRoles as $groupRole)
966 $rbacadmin->deassignUser($groupRole, $a_user_id);
971 $rbacadmin->deassignUser($arr_groupRoles, $a_user_id);
985 global $rbacadmin, $rbacreview;
991 foreach ($rol as $value)
993 foreach ($rbacreview->assignedUsers($value) as $member_id)
995 array_push($usr_arr,$member_id);
999 $mem_arr = array_unique($usr_arr);
1001 return $mem_arr ? $mem_arr : array();
1017 $q =
"SELECT login,firstname,lastname,title,usr_id,last_login ".
1021 if (is_numeric($active) && $active > -1)
1022 $q .=
"AND active = '$active'";
1024 $q .=
'ORDER BY lastname,firstname';
1026 $r = $ilDB->query($q);
1030 $mem_arr[] = array(
"id" =>
$row->usr_id,
1031 "login" =>
$row->login,
1032 "firstname" =>
$row->firstname,
1033 "lastname" =>
$row->lastname,
1034 "last_login" =>
$row->last_login
1038 return $mem_arr ? $mem_arr : array();
1056 if (!empty($a_grpId))
1068 foreach ($rbacreview->assignedUsers($this->getDefaultAdminRole()) as $member_id)
1070 array_push($usr_arr,$member_id);
1083 global $rbacadmin, $rbacreview;
1085 if (strlen($a_grp_id) > 0)
1087 $grp_id = $a_grp_id;
1094 $rolf = $rbacreview->getRoleFolderOfObject($grp_id);
1095 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"]);
1097 foreach ($role_arr as $role_id)
1099 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
1101 $grp_Member =
"il_grp_member_".$grp_id;
1102 $grp_Admin =
"il_grp_admin_".$grp_id;
1104 if (strcmp($role_Obj->getTitle(), $grp_Member) == 0 )
1106 $arr_grpDefaultRoles[
"grp_member_role"] = $role_Obj->getId();
1109 if (strcmp($role_Obj->getTitle(), $grp_Admin) == 0)
1111 $arr_grpDefaultRoles[
"grp_admin_role"] = $role_Obj->getId();
1115 return $arr_grpDefaultRoles;
1126 global $rbacadmin,$rbacreview;
1128 if (empty($this->local_roles))
1130 $this->local_roles = array();
1131 $rolf = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1132 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"]);
1134 foreach ($role_arr as $role_id)
1136 if ($rbacreview->isAssignable($role_id,$rolf[
"ref_id"]) ==
true)
1138 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
1146 $role_name = $role_Obj->getTitle();
1149 $this->local_roles[$role_name] = $role_Obj->getId();
1154 return $this->local_roles;
1164 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_closed'";
1165 $res = $this->ilias->db->query($q);
1168 return $row[
"obj_id"];
1178 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_open'";
1179 $res = $this->ilias->db->query($q);
1182 return $row[
"obj_id"];
1198 global $tree,$rbacreview,$rbacadmin;
1200 $parent_roles = $rbacreview->getParentRoleIds($this->
getRefId());
1202 $rolf_data = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1205 foreach($real_parent_roles as $role_id)
1208 if(isset($rolf_data[
'child']) and $rolf_data[
'child'])
1210 $rbacadmin->deleteLocalRole($role_id,$rolf_data[
'child']);
1213 $parent_roles = $rbacreview->getParentRoleIds($this->
getRefId());
1228 foreach($tree->getFilteredSubTree($this->getRefId(),array(
'rolf',
'grp')) as $subnode)
1231 $template_ops = $rbacreview->getOperationsOfRole($template_id,$subnode[
'type'], ROLE_FOLDER_ID);
1233 $rolf_data = $rbacreview->getRoleFolderOfObject($subnode[
'child']);
1237 foreach($real_parent_roles as $role_id)
1239 if($rbacreview->isProtected($parent_roles[$role_id][
'parent'],$role_id))
1245 if(isset($rolf_data[
'child']) and $rolf_data[
'child'])
1247 $rbacadmin->deleteLocalRole($role_id,$rolf_data[
'child']);
1251 $current_ops = $rbacreview->getOperationsOfRole($role_id,$subnode[
'type'],$parent_roles[$role_id][
'parent']);
1254 $rbacadmin->revokePermission($subnode[
'child'],$role_id);
1258 foreach($template_ops as $operation)
1260 if(in_array($operation,$current_ops))
1262 $granted[] = $operation;
1267 $rbacadmin->grantPermission($role_id, $granted,$subnode[
'child']);
1273 $rbacadmin->copyRolePermissionIntersection(
1274 $template_id, ROLE_FOLDER_ID,
1275 $role_id, $parent_roles[$role_id][
'parent'],
1276 $rolf_data[
"child"],$role_id);
1277 $rbacadmin->assignRoleToFolder($role_id,$rolf_data[
"child"],
"n");
1304 global $rbacadmin, $rbacreview, $rbacsystem;
1307 $rolf_data = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1310 $arr_parentRoles = $rbacreview->getParentRoleIds($this->
getRefId());
1312 $real_local_roles = $rbacreview->getRolesOfRoleFolder($rolf_data[
'ref_id'],
false);
1313 $arr_relevantParentRoleIds = array_diff(array_keys($arr_parentRoles),$real_local_roles);
1327 $template_ops = $rbacreview->getOperationsOfRole($template_id,
'grp', ROLE_FOLDER_ID);
1329 foreach ($arr_relevantParentRoleIds as $parentRole)
1331 if ($rbacreview->isProtected($arr_parentRoles[$parentRole][
'parent'],$parentRole))
1336 $granted_permissions = array();
1343 if(isset($rolf_data[
'child']) and $rolf_data[
'child'])
1345 $rbacadmin->deleteLocalRole($parentRole,$rolf_data[
"child"]);
1353 $current_ops = $rbacreview->getRoleOperationsOnObject($parentRole, $this->
getRefId());
1354 $rbacadmin->revokePermission($this->
getRefId(), $parentRole);
1355 foreach ($template_ops as $template_op)
1357 if (in_array($template_op,$current_ops))
1359 array_push($granted_permissions,$template_op);
1362 if (!empty($granted_permissions))
1364 $rbacadmin->grantPermission($parentRole, $granted_permissions, $this->
getRefId());
1371 $rbacadmin->copyRolePermissionIntersection(
1372 $template_id, ROLE_FOLDER_ID,
1373 $parentRole, $arr_parentRoles[$parentRole][
'parent'],
1374 $rolf_data[
"child"], $parentRole
1376 $rbacadmin->assignRoleToFolder($parentRole,$rolf_data[
"child"],
"false");
1390 $this->group_status = $a_status;
1402 return $this->group_status;
1412 global $rbacsystem,$rbacreview;
1414 $role_folder = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1415 $local_roles = $rbacreview->getRolesOfRoleFolder($role_folder[
"ref_id"]);
1418 $rolf_data = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1423 foreach ($arr_globalRoles as $globalRole)
1425 $ops_of_role = $rbacreview->getOperationsOfRole($globalRole,
"grp", ROLE_FOLDER_ID);
1427 if ($rbacsystem->checkPermission($this->getRefId(), $globalRole ,
"join"))
1444 global $rbacadmin, $rbacreview,
$ilBench;
1446 $ilBench->start(
"Group",
"getMemberRoles");
1448 $arr_assignedRoles = array();
1450 $arr_assignedRoles = array_intersect($rbacreview->assignedRoles($a_user_id),$this->
getLocalGroupRoles());
1452 $ilBench->stop(
"Group",
"getMemberRoles");
1454 return $arr_assignedRoles;
1469 if (in_array($a_userId,$rbacreview->assignedUsers($grp_Roles[
"grp_admin_role"])))
1488 global $rbacadmin, $rbacreview;
1495 $roleObj = $rfoldObj->createRole(
"il_grp_admin_".$this->
getRefId(),
"Groupadmin of group obj_no.".$this->
getId());
1496 $this->m_roleAdminId = $roleObj->getId();
1499 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_admin'";
1501 $rbacadmin->copyRoleTemplatePermissions($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
1504 $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),
"grp",$rfoldObj->getRefId());
1505 $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->
getRefId());
1513 $roleObj = $rfoldObj->createRole(
"il_grp_member_".$this->
getRefId(),
"Groupmember of group obj_no.".$this->
getId());
1514 $this->m_roleMemberId = $roleObj->getId();
1517 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_member'";
1519 $rbacadmin->copyRoleTemplatePermissions($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
1522 $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),
"grp",$rfoldObj->getRefId());
1523 $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->
getRefId());
1535 return $roles ? $roles : array();
1548 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
1552 $parent_id = (int) $tree->getParentId($a_node_id);
1554 if ($parent_id != 0)
1556 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
1557 $obj_data->notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$parent_id,$a_params);
1566 include_once
'Modules/Group/classes/class.ilGroupXMLWriter.php';
1569 $xml_writer->start();
1571 $xml = $xml_writer->getXML();
1573 $name = time().
'__'.$this->ilias->getSetting(
'inst_id').
'__grp_'.$this->
getId();
1577 $this->file_obj->addGroupDirectory();
1578 $this->file_obj->addDirectory($name);
1579 $this->file_obj->writeToFile($xml,$name.
'/'.$name.
'.xml');
1580 $this->file_obj->zipFile($name,$name.
'.zip');
1581 $this->file_obj->deleteDirectory($name);
1590 foreach($a_files as
$file)
1592 $this->file_obj->deleteFile($file);
1601 if($abs_name = $this->file_obj->getExportFile(
$file))
1619 include_once
'Modules/Group/classes/class.ilGroupXMLParser.php';
1623 return $import_parser->startParsing();
1637 include_once
'classes/class.ilFileDataGroup.php';
1641 $file_obj->createImportFile($_FILES[
"xmldoc"][
"tmp_name"],$_FILES[
'xmldoc'][
'name']);
1661 return array(
"repository.php?ref_id=".$a_id.
"&set_mode=flat&cmdClass=ilobjgroupgui",
"");
1668 $query =
"SELECT * FROM object_data WHERE title = ".
1669 $ilDB->quote($a_title ,
'text').
" AND type = 'grp'";
1673 return $row->obj_id;
1681 global $rbacreview,$ilObjDataCache,
$ilDB;
1683 $rolf = $rbacreview->getRoleFolderOfObject($a_ref_id);
1684 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
1685 $user_roles = $rbacreview->assignedRoles($a_user_id);
1690 include_once
'./Services/User/classes/class.ilObjUser.php';
1696 $and =
"AND login = '".$tmp_user->getLogin().
"' ";
1699 $and =
"AND email = '".$tmp_user->getEmail().
"' ";
1701 case 'matriculation':
1702 $and =
"AND matriculation = '".$tmp_user->getMatriculation().
"' ";
1706 $and =
"AND usr_id = '".$a_user_id.
"'";
1713 $query =
"SELECT * FROM usr_data as ud ".
1718 return $res->numRows() ?
true :
false;
1721 if (!array_intersect($local_roles,$user_roles))
1737 $rolf = $rbacreview->getRoleFolderOfObject(
$ref_id);
1738 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
'ref_id'],
false);
1741 foreach($local_roles as $role_id)
1743 $users = array_merge($users,$rbacreview->assignedUsers($role_id));
1746 return array_unique($users);
1762 if ($course_ref_id = $tree->checkForParentType($this->ref_id,
'crs'))
1764 include_once(
"./Modules/Course/classes/class.ilObjCourse.php");
1785 static $items = null;
1787 if(!is_object($items[$this->
getRefId()]))
1789 if ($course_ref_id = $tree->checkForParentType($this->getRefId(),
'crs'))
1791 include_once(
"./Modules/Course/classes/class.ilObjCourse.php");
1792 include_once(
"./Modules/Course/classes/class.ilCourseItems.php");
1797 if(is_object($items[$this->
getRefId()]))
1813 include_once
'classes/class.ilFileDataGroup.php';
1821 return $this->message;
1825 $this->message = $a_message;
1831 $this->message .=
"<br /> ";
1833 $this->message .= $a_message;
1845 include_once(
'./Services/Calendar/classes/class.ilCalendarAppointmentTemplate.php');
1857 $app->setSubtitle(
'grp_cal_reg_start');
1865 $app->setSubtitle(
'grp_cal_reg_end');
1888 include_once(
'./Modules/Group/classes/class.ilGroupParticipants.php');
1900 $query =
"SELECT obj_id FROM grp_settings ".
1901 "WHERE reg_ac_enabled = ".$ilDB->quote(1,
'integer').
" ".
1902 "AND reg_ac = ".$ilDB->quote($a_code,
'text');
1908 $obj_ids[] =
$row->obj_id;
1919 public function register($a_user_id,$a_role =
IL_GRP_MEMBER, $a_force_registration =
false)
1921 include_once
'./Services/Membership/exceptions/class.ilMembershipRegistrationException.php';
1922 include_once
"./Modules/Group/classes/class.ilGroupParticipants.php";
1925 if($part->isAssigned($a_user_id))
1930 if(!$a_force_registration)
1933 include_once
'./Modules/Group/classes/class.ilObjGroupAccess.php';
1936 $this->lng->loadLanguageModule(
'crs');
1942 $free = max(0,$this->
getMaxMembers() - $part->getCountMembers());
1943 include_once(
'./Modules/Group/classes/class.ilGroupWaitingList.php');
1952 $part->add($a_user_id,$a_role);
1953 $part->sendNotification($part->TYPE_NOTIFICATION_REGISTRATION, $a_user_id);