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').
", ".
597 $ilDB->quote($this->
getViewMode(
false),
'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(
false),
'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');
763 include_once
'./Services/Membership/classes/class.ilMembershipRegistrationCodeUtils.php';
771 include_once(
'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
775 $ilLog->write(__METHOD__.
': Starting add user');
778 include_once(
'./Modules/Group/classes/class.ilGroupParticipants.php');
781 $part->updateNotification($ilUser->getId(),1);
784 include_once(
'Services/Tracking/classes/class.ilLPObjSettings.php');
786 $obj_settings->cloneSettings($new_obj->getId());
787 unset($obj_settings);
811 include_once(
'Services/Object/classes/class.ilObjectActivation.php');
814 include_once(
'Services/Tracking/classes/class.ilLPCollections.php');
816 $lp_collection->cloneCollections($a_target_id,$a_copy_id);
830 global
$ilLog,$rbacadmin,$rbacreview;
833 $new_admin = $new_obj->getDefaultAdminRole();
834 $source_rolf = $rbacreview->getRoleFolderIdOfObject($this->
getRefId());
835 $target_rolf = $rbacreview->getRoleFolderIdOfObject($new_obj->getRefId());
837 if(!$admin || !$new_admin || !$source_rolf || !$target_rolf)
839 $ilLog->write(__METHOD__.
' : Error cloning auto generated role: il_grp_admin');
841 $rbacadmin->copyRolePermissions($admin,$source_rolf,$target_rolf,$new_admin,
true);
842 $ilLog->write(__METHOD__.
' : Finished copying of role il_grp_admin.');
845 $new_member = $new_obj->getDefaultMemberRole();
846 if(!$member || !$new_member)
848 $ilLog->write(__METHOD__.
' : Error cloning auto generated role: il_grp_member');
850 $rbacadmin->copyRolePermissions($member,$source_rolf,$target_rolf,$new_member,
true);
851 $ilLog->write(__METHOD__.
' : Finished copying of role grp_member.');
860 function join($a_user_id, $a_mem_role=
"")
864 if (is_array($a_mem_role))
866 foreach ($a_mem_role as $role)
868 $rbacadmin->assignUser($role,$a_user_id,
false);
873 $rbacadmin->assignUser($a_mem_role,$a_user_id,
false);
887 return $local_group_Roles[
"il_grp_member_".$this->getRefId()];
898 return $local_group_Roles[
"il_grp_admin_".$this->getRefId()];
911 if (isset($a_user_id) && isset($a_mem_role) )
913 $this->
join($a_user_id,$a_mem_role);
918 $this->ilias->raiseError(get_class($this).
"::addMember(): Missing parameters !",$this->ilias->error_obj->WARNING);
932 global $rbacadmin, $rbacreview;
936 if (count($member_ids) <= 1 || !in_array($this->ilias->account->getId(), $member_ids))
942 if (!$this->
isAdmin($this->ilias->account->getId()))
944 $this->
leave($this->ilias->account->getId());
945 $member =
new ilObjUser($this->ilias->account->getId());
967 if (is_array($arr_groupRoles))
969 foreach ($arr_groupRoles as $groupRole)
971 $rbacadmin->deassignUser($groupRole, $a_user_id);
976 $rbacadmin->deassignUser($arr_groupRoles, $a_user_id);
990 global $rbacadmin, $rbacreview;
996 foreach ($rol as $value)
998 foreach ($rbacreview->assignedUsers($value) as $member_id)
1000 array_push($usr_arr,$member_id);
1004 $mem_arr = array_unique($usr_arr);
1006 return $mem_arr ? $mem_arr : array();
1018 global $rbacadmin, $rbacreview,
$ilBench, $ilDB;
1022 $q =
"SELECT login,firstname,lastname,title,usr_id,last_login ".
1026 if (is_numeric($active) && $active > -1)
1027 $q .=
"AND active = '$active'";
1029 $q .=
'ORDER BY lastname,firstname';
1031 $r = $ilDB->query($q);
1035 $mem_arr[] = array(
"id" =>
$row->usr_id,
1036 "login" =>
$row->login,
1037 "firstname" =>
$row->firstname,
1038 "lastname" =>
$row->lastname,
1039 "last_login" =>
$row->last_login
1043 return $mem_arr ? $mem_arr : array();
1061 if (!empty($a_grpId))
1073 foreach ($rbacreview->assignedUsers($this->getDefaultAdminRole()) as $member_id)
1075 array_push($usr_arr,$member_id);
1088 global $rbacadmin, $rbacreview;
1090 if (strlen($a_grp_id) > 0)
1092 $grp_id = $a_grp_id;
1099 $rolf = $rbacreview->getRoleFolderOfObject($grp_id);
1100 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"]);
1102 foreach ($role_arr as $role_id)
1104 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
1106 $grp_Member =
"il_grp_member_".$grp_id;
1107 $grp_Admin =
"il_grp_admin_".$grp_id;
1109 if (strcmp($role_Obj->getTitle(), $grp_Member) == 0 )
1111 $arr_grpDefaultRoles[
"grp_member_role"] = $role_Obj->getId();
1114 if (strcmp($role_Obj->getTitle(), $grp_Admin) == 0)
1116 $arr_grpDefaultRoles[
"grp_admin_role"] = $role_Obj->getId();
1120 return $arr_grpDefaultRoles;
1131 global $rbacadmin,$rbacreview;
1133 if (empty($this->local_roles))
1135 $this->local_roles = array();
1136 $rolf = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1137 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"]);
1139 foreach ($role_arr as $role_id)
1141 if ($rbacreview->isAssignable($role_id,$rolf[
"ref_id"]) ==
true)
1143 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
1151 $role_name = $role_Obj->getTitle();
1154 $this->local_roles[$role_name] = $role_Obj->getId();
1159 return $this->local_roles;
1169 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_closed'";
1170 $res = $this->ilias->db->query($q);
1173 return $row[
"obj_id"];
1183 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_open'";
1184 $res = $this->ilias->db->query($q);
1187 return $row[
"obj_id"];
1203 global $tree,$rbacreview,$rbacadmin;
1205 $parent_roles = $rbacreview->getParentRoleIds($this->
getRefId());
1207 $rolf_data = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1210 foreach($real_parent_roles as $role_id)
1213 if(isset($rolf_data[
'child']) and $rolf_data[
'child'])
1215 $rbacadmin->deleteLocalRole($role_id,$rolf_data[
'child']);
1218 $parent_roles = $rbacreview->getParentRoleIds($this->
getRefId());
1233 foreach($tree->getFilteredSubTree($this->getRefId(),array(
'rolf',
'grp')) as $subnode)
1236 $template_ops = $rbacreview->getOperationsOfRole($template_id,$subnode[
'type'], ROLE_FOLDER_ID);
1238 $rolf_data = $rbacreview->getRoleFolderOfObject($subnode[
'child']);
1242 foreach($real_parent_roles as $role_id)
1244 if($rbacreview->isProtected($parent_roles[$role_id][
'parent'],$role_id))
1250 if(isset($rolf_data[
'child']) and $rolf_data[
'child'])
1252 $rbacadmin->deleteLocalRole($role_id,$rolf_data[
'child']);
1256 $current_ops = $rbacreview->getOperationsOfRole($role_id,$subnode[
'type'],$parent_roles[$role_id][
'parent']);
1259 $rbacadmin->revokePermission($subnode[
'child'],$role_id);
1263 foreach($template_ops as $operation)
1265 if(in_array($operation,$current_ops))
1267 $granted[] = $operation;
1272 $rbacadmin->grantPermission($role_id, $granted,$subnode[
'child']);
1278 $rbacadmin->copyRolePermissionIntersection(
1279 $template_id, ROLE_FOLDER_ID,
1280 $role_id, $parent_roles[$role_id][
'parent'],
1281 $rolf_data[
"child"],$role_id);
1282 $rbacadmin->assignRoleToFolder($role_id,$rolf_data[
"child"],
"n");
1309 global $rbacadmin, $rbacreview, $rbacsystem;
1312 $rolf_data = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1315 $arr_parentRoles = $rbacreview->getParentRoleIds($this->
getRefId());
1317 $real_local_roles = $rbacreview->getRolesOfRoleFolder($rolf_data[
'ref_id'],
false);
1318 $arr_relevantParentRoleIds = array_diff(array_keys($arr_parentRoles),$real_local_roles);
1332 $template_ops = $rbacreview->getOperationsOfRole($template_id,
'grp', ROLE_FOLDER_ID);
1334 foreach ($arr_relevantParentRoleIds as $parentRole)
1336 if ($rbacreview->isProtected($arr_parentRoles[$parentRole][
'parent'],$parentRole))
1341 $granted_permissions = array();
1348 if(isset($rolf_data[
'child']) and $rolf_data[
'child'])
1350 $rbacadmin->deleteLocalRole($parentRole,$rolf_data[
"child"]);
1358 $current_ops = $rbacreview->getRoleOperationsOnObject($parentRole, $this->
getRefId());
1359 $rbacadmin->revokePermission($this->
getRefId(), $parentRole);
1360 foreach ($template_ops as $template_op)
1362 if (in_array($template_op,$current_ops))
1364 array_push($granted_permissions,$template_op);
1367 if (!empty($granted_permissions))
1369 $rbacadmin->grantPermission($parentRole, $granted_permissions, $this->
getRefId());
1376 $rbacadmin->copyRolePermissionIntersection(
1377 $template_id, ROLE_FOLDER_ID,
1378 $parentRole, $arr_parentRoles[$parentRole][
'parent'],
1379 $rolf_data[
"child"], $parentRole
1381 $rbacadmin->assignRoleToFolder($parentRole,$rolf_data[
"child"],
"false");
1395 $this->group_status = $a_status;
1407 return $this->group_status;
1417 global $rbacsystem,$rbacreview;
1419 $role_folder = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1420 $local_roles = $rbacreview->getRolesOfRoleFolder($role_folder[
"ref_id"]);
1423 $rolf_data = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1428 foreach ($arr_globalRoles as $globalRole)
1430 $ops_of_role = $rbacreview->getOperationsOfRole($globalRole,
"grp", ROLE_FOLDER_ID);
1432 if ($rbacsystem->checkPermission($this->getRefId(), $globalRole ,
"join"))
1449 global $rbacadmin, $rbacreview,
$ilBench;
1451 $ilBench->start(
"Group",
"getMemberRoles");
1453 $arr_assignedRoles = array();
1455 $arr_assignedRoles = array_intersect($rbacreview->assignedRoles($a_user_id),$this->
getLocalGroupRoles());
1457 $ilBench->stop(
"Group",
"getMemberRoles");
1459 return $arr_assignedRoles;
1474 if (in_array($a_userId,$rbacreview->assignedUsers($grp_Roles[
"grp_admin_role"])))
1493 global $rbacadmin, $rbacreview;
1500 $roleObj = $rfoldObj->createRole(
"il_grp_admin_".$this->
getRefId(),
"Groupadmin of group obj_no.".$this->
getId());
1501 $this->m_roleAdminId = $roleObj->getId();
1504 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_admin'";
1506 $rbacadmin->copyRoleTemplatePermissions($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
1509 $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),
"grp",$rfoldObj->getRefId());
1510 $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->
getRefId());
1518 $roleObj = $rfoldObj->createRole(
"il_grp_member_".$this->
getRefId(),
"Groupmember of group obj_no.".$this->
getId());
1519 $this->m_roleMemberId = $roleObj->getId();
1522 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_member'";
1524 $rbacadmin->copyRoleTemplatePermissions($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
1527 $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),
"grp",$rfoldObj->getRefId());
1528 $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->
getRefId());
1540 return $roles ? $roles : array();
1553 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
1557 $parent_id = (int) $tree->getParentId($a_node_id);
1559 if ($parent_id != 0)
1561 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
1562 $obj_data->notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$parent_id,$a_params);
1571 include_once
'Modules/Group/classes/class.ilGroupXMLWriter.php';
1574 $xml_writer->start();
1576 $xml = $xml_writer->getXML();
1578 $name = time().
'__'.$this->ilias->getSetting(
'inst_id').
'__grp_'.$this->
getId();
1582 $this->file_obj->addGroupDirectory();
1583 $this->file_obj->addDirectory($name);
1584 $this->file_obj->writeToFile($xml,$name.
'/'.$name.
'.xml');
1585 $this->file_obj->zipFile($name,$name.
'.zip');
1586 $this->file_obj->deleteDirectory($name);
1595 foreach($a_files as
$file)
1597 $this->file_obj->deleteFile($file);
1606 if($abs_name = $this->file_obj->getExportFile(
$file))
1624 include_once
'Modules/Group/classes/class.ilGroupXMLParser.php';
1628 return $import_parser->startParsing();
1642 include_once
'./Modules/Group/classes/class.ilFileDataGroup.php';
1646 $file_obj->createImportFile($_FILES[
"xmldoc"][
"tmp_name"],$_FILES[
'xmldoc'][
'name']);
1660 $query =
"SELECT * FROM object_data WHERE title = ".
1661 $ilDB->quote($a_title ,
'text').
" AND type = 'grp'";
1665 return $row->obj_id;
1673 global $rbacreview,$ilObjDataCache,$ilDB;
1675 $rolf = $rbacreview->getRoleFolderOfObject($a_ref_id);
1676 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
1677 $user_roles = $rbacreview->assignedRoles($a_user_id);
1682 include_once
'./Services/User/classes/class.ilObjUser.php';
1688 $and =
"AND login = '".$tmp_user->getLogin().
"' ";
1691 $and =
"AND email = '".$tmp_user->getEmail().
"' ";
1693 case 'matriculation':
1694 $and =
"AND matriculation = '".$tmp_user->getMatriculation().
"' ";
1698 $and =
"AND usr_id = '".$a_user_id.
"'";
1705 $query =
"SELECT * FROM usr_data as ud ".
1710 return $res->numRows() ?
true :
false;
1713 if (!array_intersect($local_roles,$user_roles))
1729 $rolf = $rbacreview->getRoleFolderOfObject(
$ref_id);
1730 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
'ref_id'],
false);
1733 foreach($local_roles as $role_id)
1735 $users = array_merge($users,$rbacreview->assignedUsers($role_id));
1738 return array_unique($users);
1750 $view = (int) $this->view_mode;
1757 if($a_translate_inherit)
1771 $this->view_mode = $a_view_mode;
1782 $query =
'SELECT view_mode FROM grp_settings '.
1783 'WHERE obj_id = '.$ilDB->quote($a_obj_id,
'integer');
1816 $a_ref_id = end($ref);
1819 $crs_ref = $tree->checkForParentType($a_ref_id,
'crs');
1825 include_once
'./Modules/Course/classes/class.ilObjCourse.php';
1838 return $a_view_mode;
1847 include_once
'./Services/Object/classes/class.ilObjectActivation.php';
1860 include_once
'./Modules/Group/classes/class.ilFileDataGroup.php';
1868 return $this->message;
1872 $this->message = $a_message;
1878 $this->message .=
"<br /> ";
1880 $this->message .= $a_message;
1892 include_once(
'./Services/Calendar/classes/class.ilCalendarAppointmentTemplate.php');
1904 $app->setSubtitle(
'grp_cal_reg_start');
1912 $app->setSubtitle(
'grp_cal_reg_end');
1935 include_once(
'./Modules/Group/classes/class.ilGroupParticipants.php');
1947 $query =
"SELECT obj_id FROM grp_settings ".
1948 "WHERE reg_ac_enabled = ".$ilDB->quote(1,
'integer').
" ".
1949 "AND reg_ac = ".$ilDB->quote($a_code,
'text');
1955 $obj_ids[] =
$row->obj_id;
1966 public function register($a_user_id,$a_role =
IL_GRP_MEMBER, $a_force_registration =
false)
1968 include_once
'./Services/Membership/exceptions/class.ilMembershipRegistrationException.php';
1969 include_once
"./Modules/Group/classes/class.ilGroupParticipants.php";
1972 if($part->isAssigned($a_user_id))
1977 if(!$a_force_registration)
1980 include_once
'./Modules/Group/classes/class.ilObjGroupAccess.php';
1983 $this->lng->loadLanguageModule(
'crs');
1989 $free = max(0,$this->
getMaxMembers() - $part->getCountMembers());
1990 include_once(
'./Modules/Group/classes/class.ilGroupWaitingList.php');
1999 $part->add($a_user_id,$a_role);
2000 $part->sendNotification($part->TYPE_NOTIFICATION_REGISTRATION, $a_user_id);