6 require_once
"./Services/Container/classes/class.ilContainer.php";
7 include_once(
'./Services/Calendar/classes/class.ilDateTime.php');
8 include_once
'./Services/Membership/interfaces/interface.ilMembershipRegistrationCodes.php';
10 define(
'GRP_REGISTRATION_DEACTIVATED',-1);
11 define(
'GRP_REGISTRATION_DIRECT',0);
12 define(
'GRP_REGISTRATION_REQUEST',1);
13 define(
'GRP_REGISTRATION_PASSWORD',2);
15 define(
'GRP_REGISTRATION_LIMITED',1);
16 define(
'GRP_REGISTRATION_UNLIMITED',2);
18 define(
'GRP_TYPE_UNKNOWN',0);
19 define(
'GRP_TYPE_CLOSED',1);
20 define(
'GRP_TYPE_OPEN',2);
21 define(
'GRP_TYPE_PUBLIC',3);
97 public function __construct($a_id = 0,$a_call_by_reference =
true)
101 $this->tree =& $tree;
104 $this->
ilObject($a_id,$a_call_by_reference);
117 $query =
"SELECT grp_type FROM grp_settings ".
118 "WHERE obj_id = ".$ilDB->quote($a_id,
'integer');
122 return $row->grp_type;
137 $this->information = $a_information;
160 $this->group_type = $a_type;
203 $this->reg_type = $a_type;
237 $this->reg_unlimited = $a_status;
260 $this->reg_start = $a_start;
271 return $this->reg_start ? $this->reg_start : $this->reg_start =
new ilDateTime(date(
'Y-m-d').
' 08:00:00',
IL_CAL_DATETIME);
284 $this->reg_end = $a_end;
306 $this->reg_password = $a_pass;
329 $this->reg_membership_limitation = $a_status;
351 $this->reg_max_members = $a_max;
374 $this->waiting_list = $a_status;
396 $this->latitude = $a_latitude;
416 $this->longitude = $a_longitude;
436 $this->locationzoom = $a_locationzoom;
456 $this->enablemap = $a_enablemap;
485 $this->reg_access_code = $a_code;
504 $this->reg_access_code_enabled = $a_status;
514 $this->mail_members = $a_type;
542 $ilErr->appendMessage($this->lng->txt(self::ERR_MISSING_TITLE));
546 $ilErr->appendMessage($this->lng->txt(self::ERR_MISSING_GROUP_TYPE));
550 $ilErr->appendMessage($this->lng->txt(self::ERR_MISSING_PASSWORD));
554 $ilErr->appendMessage($this->lng->txt(self::ERR_WRONG_REG_TIME_LIMIT));
558 $ilErr->appendMessage($this->lng->txt(self::ERR_WRONG_MAX_MEMBERS));
560 return strlen($ilErr->getMessage()) == 0;
571 global $ilDB,$ilAppEventHandler;
573 if(!parent::create())
578 $query =
"INSERT INTO grp_settings (obj_id,information,grp_type,registration_type,registration_enabled,".
579 "registration_unlimited,registration_start,registration_end,registration_password,registration_mem_limit,".
580 "registration_max_members,waiting_list,latitude,longitude,location_zoom,enablemap,reg_ac_enabled,reg_ac,view_mode,mail_members_type) ".
582 $ilDB->quote($this->
getId() ,
'integer').
", ".
584 $ilDB->quote((
int) $this->
getGroupType() ,
'integer').
", ".
600 $ilDB->quote($this->
getViewMode(
false),
'integer').
', '.
605 $ilAppEventHandler->raise(
'Modules/Group',
607 array(
'object' => $this,
608 'obj_id' => $this->
getId(),
611 return $this->
getId();
619 global $ilDB,$ilAppEventHandler;
621 if (!parent::update())
626 $query =
"UPDATE grp_settings ".
627 "SET information = ".$ilDB->quote($this->
getInformation() ,
'text').
", ".
628 "grp_type = ".$ilDB->quote((
int) $this->
getGroupType() ,
'integer').
", ".
634 "registration_password = ".$ilDB->quote($this->
getPassword() ,
'text').
", ".
636 "registration_mem_limit = ".$ilDB->quote((
int) $this->
isMembershipLimited() ,
'integer').
", ".
637 "registration_max_members = ".$ilDB->quote($this->
getMaxMembers() ,
'integer').
", ".
639 "latitude = ".$ilDB->quote($this->
getLatitude() ,
'text').
", ".
640 "longitude = ".$ilDB->quote($this->
getLongitude() ,
'text').
", ".
641 "location_zoom = ".$ilDB->quote($this->
getLocationZoom() ,
'integer').
", ".
645 'view_mode = '.$ilDB->quote($this->
getViewMode(
false),
'integer').
', '.
647 "WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer').
" ";
650 $ilAppEventHandler->raise(
'Modules/Group',
652 array(
'object' => $this,
653 'obj_id' => $this->
getId(),
666 public function delete()
668 global $ilDB,$ilAppEventHandler;
671 if (!parent::delete())
676 $query =
"DELETE FROM grp_settings ".
677 "WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer');
680 include_once(
'./Modules/Group/classes/class.ilGroupParticipants.php');
683 $ilAppEventHandler->raise(
'Modules/Group',
685 array(
'object' => $this,
686 'obj_id' => $this->
getId(),
703 $query =
"SELECT * FROM grp_settings ".
704 "WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer');
731 include_once(
'./Services/Container/classes/class.ilContainerSortingSettings.php');
769 include_once
'./Services/Membership/classes/class.ilMembershipRegistrationCodeUtils.php';
778 include_once(
'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
782 $ilLog->write(__METHOD__.
': Starting add user');
785 include_once(
'./Modules/Group/classes/class.ilGroupParticipants.php');
788 $part->updateNotification($ilUser->getId(),1);
791 include_once(
'Services/Tracking/classes/class.ilLPObjSettings.php');
793 $obj_settings->cloneSettings($new_obj->getId());
794 unset($obj_settings);
818 include_once(
'Services/Object/classes/class.ilObjectActivation.php');
833 global
$ilLog,$rbacadmin,$rbacreview;
836 $new_admin = $new_obj->getDefaultAdminRole();
837 $source_rolf = $rbacreview->getRoleFolderIdOfObject($this->
getRefId());
838 $target_rolf = $rbacreview->getRoleFolderIdOfObject($new_obj->getRefId());
840 if(!$admin || !$new_admin || !$source_rolf || !$target_rolf)
842 $ilLog->write(__METHOD__.
' : Error cloning auto generated role: il_grp_admin');
844 $rbacadmin->copyRolePermissions($admin,$source_rolf,$target_rolf,$new_admin,
true);
845 $ilLog->write(__METHOD__.
' : Finished copying of role il_grp_admin.');
848 $new_member = $new_obj->getDefaultMemberRole();
849 if(!$member || !$new_member)
851 $ilLog->write(__METHOD__.
' : Error cloning auto generated role: il_grp_member');
853 $rbacadmin->copyRolePermissions($member,$source_rolf,$target_rolf,$new_member,
true);
854 $ilLog->write(__METHOD__.
' : Finished copying of role grp_member.');
863 function join($a_user_id, $a_mem_role=
"")
867 if (is_array($a_mem_role))
869 foreach ($a_mem_role as $role)
871 $rbacadmin->assignUser($role,$a_user_id,
false);
876 $rbacadmin->assignUser($a_mem_role,$a_user_id,
false);
890 return $local_group_Roles[
"il_grp_member_".$this->getRefId()];
901 return $local_group_Roles[
"il_grp_admin_".$this->getRefId()];
914 if (isset($a_user_id) && isset($a_mem_role) )
916 $this->
join($a_user_id,$a_mem_role);
921 $this->ilias->raiseError(get_class($this).
"::addMember(): Missing parameters !",$this->ilias->error_obj->WARNING);
935 global $rbacadmin, $rbacreview;
939 if (count($member_ids) <= 1 || !in_array($this->ilias->account->getId(), $member_ids))
945 if (!$this->
isAdmin($this->ilias->account->getId()))
947 $this->
leave($this->ilias->account->getId());
948 $member =
new ilObjUser($this->ilias->account->getId());
970 if (is_array($arr_groupRoles))
972 foreach ($arr_groupRoles as $groupRole)
974 $rbacadmin->deassignUser($groupRole, $a_user_id);
979 $rbacadmin->deassignUser($arr_groupRoles, $a_user_id);
993 global $rbacadmin, $rbacreview;
999 foreach ($rol as $value)
1001 foreach ($rbacreview->assignedUsers($value) as $member_id)
1003 array_push($usr_arr,$member_id);
1007 $mem_arr = array_unique($usr_arr);
1009 return $mem_arr ? $mem_arr : array();
1021 global $rbacadmin, $rbacreview,
$ilBench, $ilDB;
1025 $q =
"SELECT login,firstname,lastname,title,usr_id,last_login ".
1029 if (is_numeric($active) && $active > -1)
1030 $q .=
"AND active = '$active'";
1032 $q .=
'ORDER BY lastname,firstname';
1034 $r = $ilDB->query($q);
1038 $mem_arr[] = array(
"id" =>
$row->usr_id,
1039 "login" =>
$row->login,
1040 "firstname" =>
$row->firstname,
1041 "lastname" =>
$row->lastname,
1042 "last_login" =>
$row->last_login
1046 return $mem_arr ? $mem_arr : array();
1064 if (!empty($a_grpId))
1076 foreach ($rbacreview->assignedUsers($this->getDefaultAdminRole()) as $member_id)
1078 array_push($usr_arr,$member_id);
1091 global $rbacadmin, $rbacreview;
1093 if (strlen($a_grp_id) > 0)
1095 $grp_id = $a_grp_id;
1102 $rolf = $rbacreview->getRoleFolderOfObject($grp_id);
1103 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"]);
1105 foreach ($role_arr as $role_id)
1107 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
1109 $grp_Member =
"il_grp_member_".$grp_id;
1110 $grp_Admin =
"il_grp_admin_".$grp_id;
1112 if (strcmp($role_Obj->getTitle(), $grp_Member) == 0 )
1114 $arr_grpDefaultRoles[
"grp_member_role"] = $role_Obj->getId();
1117 if (strcmp($role_Obj->getTitle(), $grp_Admin) == 0)
1119 $arr_grpDefaultRoles[
"grp_admin_role"] = $role_Obj->getId();
1123 return $arr_grpDefaultRoles;
1134 global $rbacadmin,$rbacreview;
1136 if (empty($this->local_roles))
1138 $this->local_roles = array();
1139 $rolf = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1140 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"]);
1142 foreach ($role_arr as $role_id)
1144 if ($rbacreview->isAssignable($role_id,$rolf[
"ref_id"]) ==
true)
1146 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
1154 $role_name = $role_Obj->getTitle();
1157 $this->local_roles[$role_name] = $role_Obj->getId();
1162 return $this->local_roles;
1172 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_closed'";
1173 $res = $this->ilias->db->query($q);
1176 return $row[
"obj_id"];
1186 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_open'";
1187 $res = $this->ilias->db->query($q);
1190 return $row[
"obj_id"];
1206 global $tree,$rbacreview,$rbacadmin;
1208 $parent_roles = $rbacreview->getParentRoleIds($this->
getRefId());
1210 $rolf_data = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1213 foreach($real_parent_roles as $role_id)
1216 if(isset($rolf_data[
'child']) and $rolf_data[
'child'])
1218 $rbacadmin->deleteLocalRole($role_id,$rolf_data[
'child']);
1221 $parent_roles = $rbacreview->getParentRoleIds($this->
getRefId());
1236 foreach($tree->getFilteredSubTree($this->getRefId(),array(
'rolf',
'grp')) as $subnode)
1239 $template_ops = $rbacreview->getOperationsOfRole($template_id,$subnode[
'type'], ROLE_FOLDER_ID);
1241 $rolf_data = $rbacreview->getRoleFolderOfObject($subnode[
'child']);
1245 foreach($real_parent_roles as $role_id)
1247 if($rbacreview->isProtected($parent_roles[$role_id][
'parent'],$role_id))
1253 if(isset($rolf_data[
'child']) and $rolf_data[
'child'])
1255 $rbacadmin->deleteLocalRole($role_id,$rolf_data[
'child']);
1259 $current_ops = $rbacreview->getOperationsOfRole($role_id,$subnode[
'type'],$parent_roles[$role_id][
'parent']);
1262 $rbacadmin->revokePermission($subnode[
'child'],$role_id);
1266 foreach($template_ops as $operation)
1268 if(in_array($operation,$current_ops))
1270 $granted[] = $operation;
1275 $rbacadmin->grantPermission($role_id, $granted,$subnode[
'child']);
1281 $rbacadmin->copyRolePermissionIntersection(
1282 $template_id, ROLE_FOLDER_ID,
1283 $role_id, $parent_roles[$role_id][
'parent'],
1284 $rolf_data[
"child"],$role_id);
1285 $rbacadmin->assignRoleToFolder($role_id,$rolf_data[
"child"],
"n");
1312 global $rbacadmin, $rbacreview, $rbacsystem;
1315 $rolf_data = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1318 $arr_parentRoles = $rbacreview->getParentRoleIds($this->
getRefId());
1320 $real_local_roles = $rbacreview->getRolesOfRoleFolder($rolf_data[
'ref_id'],
false);
1321 $arr_relevantParentRoleIds = array_diff(array_keys($arr_parentRoles),$real_local_roles);
1335 $template_ops = $rbacreview->getOperationsOfRole($template_id,
'grp', ROLE_FOLDER_ID);
1337 foreach ($arr_relevantParentRoleIds as $parentRole)
1339 if ($rbacreview->isProtected($arr_parentRoles[$parentRole][
'parent'],$parentRole))
1344 $granted_permissions = array();
1351 if(isset($rolf_data[
'child']) and $rolf_data[
'child'])
1353 $rbacadmin->deleteLocalRole($parentRole,$rolf_data[
"child"]);
1361 $current_ops = $rbacreview->getRoleOperationsOnObject($parentRole, $this->
getRefId());
1362 $rbacadmin->revokePermission($this->
getRefId(), $parentRole);
1363 foreach ($template_ops as $template_op)
1365 if (in_array($template_op,$current_ops))
1367 array_push($granted_permissions,$template_op);
1370 if (!empty($granted_permissions))
1372 $rbacadmin->grantPermission($parentRole, $granted_permissions, $this->
getRefId());
1379 $rbacadmin->copyRolePermissionIntersection(
1380 $template_id, ROLE_FOLDER_ID,
1381 $parentRole, $arr_parentRoles[$parentRole][
'parent'],
1382 $rolf_data[
"child"], $parentRole
1384 $rbacadmin->assignRoleToFolder($parentRole,$rolf_data[
"child"],
"false");
1398 $this->group_status = $a_status;
1410 return $this->group_status;
1420 global $rbacsystem,$rbacreview;
1422 $role_folder = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1423 $local_roles = $rbacreview->getRolesOfRoleFolder($role_folder[
"ref_id"]);
1426 $rolf_data = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1431 foreach ($arr_globalRoles as $globalRole)
1433 $ops_of_role = $rbacreview->getOperationsOfRole($globalRole,
"grp", ROLE_FOLDER_ID);
1435 if ($rbacsystem->checkPermission($this->getRefId(), $globalRole ,
"join"))
1452 global $rbacadmin, $rbacreview,
$ilBench;
1454 $ilBench->start(
"Group",
"getMemberRoles");
1456 $arr_assignedRoles = array();
1458 $arr_assignedRoles = array_intersect($rbacreview->assignedRoles($a_user_id),$this->
getLocalGroupRoles());
1460 $ilBench->stop(
"Group",
"getMemberRoles");
1462 return $arr_assignedRoles;
1477 if (in_array($a_userId,$rbacreview->assignedUsers($grp_Roles[
"grp_admin_role"])))
1496 global $rbacadmin, $rbacreview;
1503 $roleObj = $rfoldObj->createRole(
"il_grp_admin_".$this->
getRefId(),
"Groupadmin of group obj_no.".$this->
getId());
1504 $this->m_roleAdminId = $roleObj->getId();
1507 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_admin'";
1509 $rbacadmin->copyRoleTemplatePermissions($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
1512 $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),
"grp",$rfoldObj->getRefId());
1513 $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->
getRefId());
1521 $roleObj = $rfoldObj->createRole(
"il_grp_member_".$this->
getRefId(),
"Groupmember of group obj_no.".$this->
getId());
1522 $this->m_roleMemberId = $roleObj->getId();
1525 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_member'";
1527 $rbacadmin->copyRoleTemplatePermissions($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
1530 $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),
"grp",$rfoldObj->getRefId());
1531 $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->
getRefId());
1543 return $roles ? $roles : array();
1556 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
1560 $parent_id = (int) $tree->getParentId($a_node_id);
1562 if ($parent_id != 0)
1564 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
1565 $obj_data->notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$parent_id,$a_params);
1574 include_once
'Modules/Group/classes/class.ilGroupXMLWriter.php';
1577 $xml_writer->start();
1579 $xml = $xml_writer->getXML();
1581 $name = time().
'__'.$this->ilias->getSetting(
'inst_id').
'__grp_'.$this->
getId();
1585 $this->file_obj->addGroupDirectory();
1586 $this->file_obj->addDirectory($name);
1587 $this->file_obj->writeToFile($xml,$name.
'/'.$name.
'.xml');
1588 $this->file_obj->zipFile($name,$name.
'.zip');
1589 $this->file_obj->deleteDirectory($name);
1598 foreach($a_files as
$file)
1600 $this->file_obj->deleteFile($file);
1609 if($abs_name = $this->file_obj->getExportFile(
$file))
1627 include_once
'Modules/Group/classes/class.ilGroupXMLParser.php';
1631 return $import_parser->startParsing();
1645 include_once
'./Modules/Group/classes/class.ilFileDataGroup.php';
1649 $file_obj->createImportFile($_FILES[
"xmldoc"][
"tmp_name"],$_FILES[
'xmldoc'][
'name']);
1663 $query =
"SELECT * FROM object_data WHERE title = ".
1664 $ilDB->quote($a_title ,
'text').
" AND type = 'grp'";
1668 return $row->obj_id;
1676 global $rbacreview,$ilObjDataCache,$ilDB;
1678 $rolf = $rbacreview->getRoleFolderOfObject($a_ref_id);
1679 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
1680 $user_roles = $rbacreview->assignedRoles($a_user_id);
1685 include_once
'./Services/User/classes/class.ilObjUser.php';
1691 $and =
"AND login = '".$tmp_user->getLogin().
"' ";
1694 $and =
"AND email = '".$tmp_user->getEmail().
"' ";
1696 case 'matriculation':
1697 $and =
"AND matriculation = '".$tmp_user->getMatriculation().
"' ";
1701 $and =
"AND usr_id = '".$a_user_id.
"'";
1708 $query =
"SELECT * FROM usr_data as ud ".
1713 return $res->numRows() ?
true :
false;
1716 if (!array_intersect($local_roles,$user_roles))
1732 $rolf = $rbacreview->getRoleFolderOfObject(
$ref_id);
1733 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
'ref_id'],
false);
1736 foreach($local_roles as $role_id)
1738 $users = array_merge($users,$rbacreview->assignedUsers($role_id));
1741 return array_unique($users);
1753 $view = (int) $this->view_mode;
1760 if($a_translate_inherit)
1774 $this->view_mode = $a_view_mode;
1785 $query =
'SELECT view_mode FROM grp_settings '.
1786 'WHERE obj_id = '.$ilDB->quote($a_obj_id,
'integer');
1819 $a_ref_id = end($ref);
1822 $crs_ref = $tree->checkForParentType($a_ref_id,
'crs');
1828 include_once
'./Modules/Course/classes/class.ilObjCourse.php';
1841 return $a_view_mode;
1850 include_once
'./Services/Object/classes/class.ilObjectActivation.php';
1863 include_once
'./Modules/Group/classes/class.ilFileDataGroup.php';
1871 return $this->message;
1875 $this->message = $a_message;
1881 $this->message .=
"<br /> ";
1883 $this->message .= $a_message;
1895 include_once(
'./Services/Calendar/classes/class.ilCalendarAppointmentTemplate.php');
1907 $app->setSubtitle(
'grp_cal_reg_start');
1915 $app->setSubtitle(
'grp_cal_reg_end');
1938 include_once(
'./Modules/Group/classes/class.ilGroupParticipants.php');
1950 $query =
"SELECT obj_id FROM grp_settings ".
1951 "WHERE reg_ac_enabled = ".$ilDB->quote(1,
'integer').
" ".
1952 "AND reg_ac = ".$ilDB->quote($a_code,
'text');
1958 $obj_ids[] =
$row->obj_id;
1969 public function register($a_user_id,$a_role =
IL_GRP_MEMBER, $a_force_registration =
false)
1971 include_once
'./Services/Membership/exceptions/class.ilMembershipRegistrationException.php';
1972 include_once
"./Modules/Group/classes/class.ilGroupParticipants.php";
1975 if($part->isAssigned($a_user_id))
1980 if(!$a_force_registration)
1985 include_once
'./Modules/Group/classes/class.ilObjGroupAccess.php';
1990 ', group subscription is deactivated.',
'456');
2004 ', group is out of registration time.',
'789');
2011 $free = max(0,$this->
getMaxMembers() - $part->getCountMembers());
2012 include_once(
'./Modules/Group/classes/class.ilGroupWaitingList.php');
2016 $this->lng->loadLanguageModule(
"grp");
2019 $info = sprintf($this->lng->txt(
'grp_added_to_list'),
2023 include_once(
'./Modules/Group/classes/class.ilGroupParticipants.php');
2024 include_once(
'./Modules/Group/classes/class.ilGroupMembershipMailNotification.php');
2034 ', membership is limited.',
'123');
2039 $part->add($a_user_id,$a_role);
2040 $part->sendNotification($part->TYPE_NOTIFICATION_REGISTRATION, $a_user_id);