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 if(!$admin || !$new_admin || !$this->
getRefId() || !$new_obj->getRefId())
839 $ilLog->write(__METHOD__.
' : Error cloning auto generated role: il_grp_admin');
841 $rbacadmin->copyRolePermissions($admin,$this->
getRefId(),$new_obj->getRefId(),$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,$this->
getRefId(),$new_obj->getRefId(),$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();
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 $role_arr = $rbacreview->getRolesOfRoleFolder($grp_id);
1101 foreach ($role_arr as $role_id)
1103 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
1105 $grp_Member =
"il_grp_member_".$grp_id;
1106 $grp_Admin =
"il_grp_admin_".$grp_id;
1108 if (strcmp($role_Obj->getTitle(), $grp_Member) == 0 )
1110 $arr_grpDefaultRoles[
"grp_member_role"] = $role_Obj->getId();
1113 if (strcmp($role_Obj->getTitle(), $grp_Admin) == 0)
1115 $arr_grpDefaultRoles[
"grp_admin_role"] = $role_Obj->getId();
1119 return $arr_grpDefaultRoles;
1130 global $rbacadmin,$rbacreview;
1132 if (empty($this->local_roles))
1134 $this->local_roles = array();
1135 $role_arr = $rbacreview->getRolesOfRoleFolder($this->
getRefId());
1137 foreach ($role_arr as $role_id)
1139 if ($rbacreview->isAssignable($role_id,$this->getRefId()) ==
true)
1141 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
1149 $role_name = $role_Obj->getTitle();
1152 $this->local_roles[$role_name] = $role_Obj->getId();
1157 return $this->local_roles;
1167 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_closed'";
1168 $res = $this->ilias->db->query($q);
1171 return $row[
"obj_id"];
1181 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_open'";
1182 $res = $this->ilias->db->query($q);
1185 return $row[
"obj_id"];
1201 $query =
'SELECT obj_id FROM object_data WHERE type = '.$ilDB->quote(
'rolt',
'text').
' AND title = '.$ilDB->quote(
'il_grp_status_closed',
'text');
1205 $query =
'SELECT obj_id FROM object_data WHERE type = '.$ilDB->quote(
'rolt',
'text').
' AND title = '.$ilDB->quote(
'il_grp_status_open',
'text');
1210 return isset(
$row[
'obj_id']) ?
$row[
'obj_id'] : 0;
1226 global $tree,$rbacreview,$rbacadmin;
1228 $parent_roles = $rbacreview->getParentRoleIds($this->
getRefId());
1232 foreach($real_parent_roles as $role_id)
1235 $rbacadmin->deleteLocalRole($role_id,$this->
getRefId());
1237 $parent_roles = $rbacreview->getParentRoleIds($this->
getRefId());
1252 foreach($tree->getFilteredSubTree($this->getRefId(),array(
'grp')) as $subnode)
1255 $template_ops = $rbacreview->getOperationsOfRole($template_id,$subnode[
'type'], ROLE_FOLDER_ID);
1258 foreach($real_parent_roles as $role_id)
1260 if($rbacreview->isProtected($parent_roles[$role_id][
'parent'],$role_id))
1265 $rbacadmin->deleteLocalRole($role_id,$subnode[
'child']);
1268 $current_ops = $rbacreview->getOperationsOfRole($role_id,$subnode[
'type'],$parent_roles[$role_id][
'parent']);
1271 $rbacadmin->revokePermission($subnode[
'child'],$role_id);
1275 foreach($template_ops as $operation)
1277 if(in_array($operation,$current_ops))
1279 $granted[] = $operation;
1284 $rbacadmin->grantPermission($role_id, $granted,$subnode[
'child']);
1290 $rbacadmin->copyRolePermissionIntersection(
1291 $template_id, ROLE_FOLDER_ID,
1292 $role_id, $parent_roles[$role_id][
'parent'],
1293 $subnode[
"child"],$role_id);
1294 $rbacadmin->assignRoleToFolder($role_id,$subnode[
'child'],
"n");
1321 global $rbacadmin, $rbacreview, $rbacsystem;
1324 $arr_parentRoles = $rbacreview->getParentRoleIds($this->
getRefId());
1326 $real_local_roles = $rbacreview->getRolesOfRoleFolder($this->
getRefId(),
false);
1327 $arr_relevantParentRoleIds = array_diff(array_keys($arr_parentRoles),$real_local_roles);
1341 $template_ops = $rbacreview->getOperationsOfRole($template_id,
'grp', ROLE_FOLDER_ID);
1343 foreach ($arr_relevantParentRoleIds as $parentRole)
1345 if ($rbacreview->isProtected($arr_parentRoles[$parentRole][
'parent'],$parentRole))
1350 $granted_permissions = array();
1359 $rbacadmin->deleteLocalRole($parentRole,$this->
getRefId());
1366 $current_ops = $rbacreview->getRoleOperationsOnObject($parentRole, $this->
getRefId());
1367 $rbacadmin->revokePermission($this->
getRefId(), $parentRole);
1368 foreach ($template_ops as $template_op)
1370 if (in_array($template_op,$current_ops))
1372 array_push($granted_permissions,$template_op);
1375 if (!empty($granted_permissions))
1377 $rbacadmin->grantPermission($parentRole, $granted_permissions, $this->
getRefId());
1385 $rbacadmin->copyRolePermissionIntersection(
1386 $template_id, ROLE_FOLDER_ID,
1387 $parentRole, $arr_parentRoles[$parentRole][
'parent'],
1390 $rbacadmin->assignRoleToFolder($parentRole,$this->
getRefId(),
"false");
1404 $this->group_status = $a_status;
1416 return $this->group_status;
1426 global $rbacsystem,$rbacreview;
1428 $local_roles = $rbacreview->getRolesOfRoleFolder($this->
getRefId());
1434 foreach ($arr_globalRoles as $globalRole)
1436 if ($rbacsystem->checkPermission($this->getRefId(), $globalRole ,
"join"))
1453 global $rbacadmin, $rbacreview,
$ilBench;
1455 $ilBench->start(
"Group",
"getMemberRoles");
1457 $arr_assignedRoles = array();
1459 $arr_assignedRoles = array_intersect($rbacreview->assignedRoles($a_user_id),$this->
getLocalGroupRoles());
1461 $ilBench->stop(
"Group",
"getMemberRoles");
1463 return $arr_assignedRoles;
1478 if (in_array($a_userId,$rbacreview->assignedUsers($grp_Roles[
"grp_admin_role"])))
1497 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
1500 "Groupadmin group obj_no.".$this->
getId(),
1504 $this->m_roleAdminId = $role->getId();
1507 'il_grp_member_'.$this->
getRefId(),
1508 "Groupmember of group obj_no.".$this->
getId(),
1512 $this->m_roleMemberId = $role->getId();
1527 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
1531 $parent_id = (int) $tree->getParentId($a_node_id);
1533 if ($parent_id != 0)
1535 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
1536 $obj_data->notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$parent_id,$a_params);
1545 include_once
'Modules/Group/classes/class.ilGroupXMLWriter.php';
1548 $xml_writer->start();
1550 $xml = $xml_writer->getXML();
1552 $name = time().
'__'.$this->ilias->getSetting(
'inst_id').
'__grp_'.$this->
getId();
1556 $this->file_obj->addGroupDirectory();
1557 $this->file_obj->addDirectory($name);
1558 $this->file_obj->writeToFile($xml,$name.
'/'.$name.
'.xml');
1559 $this->file_obj->zipFile($name,$name.
'.zip');
1560 $this->file_obj->deleteDirectory($name);
1569 foreach($a_files as
$file)
1571 $this->file_obj->deleteFile($file);
1580 if($abs_name = $this->file_obj->getExportFile(
$file))
1598 include_once
'Modules/Group/classes/class.ilGroupXMLParser.php';
1602 return $import_parser->startParsing();
1616 include_once
'./Modules/Group/classes/class.ilFileDataGroup.php';
1620 $file_obj->createImportFile($_FILES[
"xmldoc"][
"tmp_name"],$_FILES[
'xmldoc'][
'name']);
1634 $query =
"SELECT * FROM object_data WHERE title = ".
1635 $ilDB->quote($a_title ,
'text').
" AND type = 'grp'";
1639 return $row->obj_id;
1647 global $rbacreview,$ilObjDataCache,
$ilDB;
1649 $local_roles = $rbacreview->getRolesOfRoleFolder($a_ref_id,
false);
1650 $user_roles = $rbacreview->assignedRoles($a_user_id);
1655 include_once
'./Services/User/classes/class.ilObjUser.php';
1661 $and =
"AND login = '".$tmp_user->getLogin().
"' ";
1664 $and =
"AND email = '".$tmp_user->getEmail().
"' ";
1666 case 'matriculation':
1667 $and =
"AND matriculation = '".$tmp_user->getMatriculation().
"' ";
1671 $and =
"AND usr_id = '".$a_user_id.
"'";
1678 $query =
"SELECT * FROM usr_data as ud ".
1683 return $res->numRows() ?
true :
false;
1686 if (!array_intersect($local_roles,$user_roles))
1702 $local_roles = $rbacreview->getRolesOfRoleFolder(
$ref_id,
false);
1705 foreach($local_roles as $role_id)
1707 $users = array_merge($users,$rbacreview->assignedUsers($role_id));
1710 return array_unique($users);
1722 $view = (int) $this->view_mode;
1729 if($a_translate_inherit)
1743 $this->view_mode = $a_view_mode;
1754 $query =
'SELECT view_mode FROM grp_settings '.
1755 'WHERE obj_id = '.$ilDB->quote($a_obj_id,
'integer');
1788 $a_ref_id = end($ref);
1791 $crs_ref = $tree->checkForParentType($a_ref_id,
'crs');
1797 include_once
'./Modules/Course/classes/class.ilObjCourse.php';
1810 return $a_view_mode;
1819 include_once
'./Services/Object/classes/class.ilObjectActivation.php';
1832 include_once
'./Modules/Group/classes/class.ilFileDataGroup.php';
1840 return $this->message;
1844 $this->message = $a_message;
1850 $this->message .=
"<br /> ";
1852 $this->message .= $a_message;
1864 include_once(
'./Services/Calendar/classes/class.ilCalendarAppointmentTemplate.php');
1876 $app->setSubtitle(
'grp_cal_reg_start');
1884 $app->setSubtitle(
'grp_cal_reg_end');
1907 include_once(
'./Modules/Group/classes/class.ilGroupParticipants.php');
1919 $query =
"SELECT obj_id FROM grp_settings ".
1920 "WHERE reg_ac_enabled = ".$ilDB->quote(1,
'integer').
" ".
1921 "AND reg_ac = ".$ilDB->quote($a_code,
'text');
1927 $obj_ids[] =
$row->obj_id;
1938 public function register($a_user_id,$a_role =
IL_GRP_MEMBER, $a_force_registration =
false)
1940 include_once
'./Services/Membership/exceptions/class.ilMembershipRegistrationException.php';
1941 include_once
"./Modules/Group/classes/class.ilGroupParticipants.php";
1944 if($part->isAssigned($a_user_id))
1949 if(!$a_force_registration)
1954 include_once
'./Modules/Group/classes/class.ilObjGroupAccess.php';
1959 ', group subscription is deactivated.',
'456');
1973 ', group is out of registration time.',
'789');
1980 $free = max(0,$this->
getMaxMembers() - $part->getCountMembers());
1981 include_once(
'./Modules/Group/classes/class.ilGroupWaitingList.php');
1985 $this->lng->loadLanguageModule(
"grp");
1988 $info = sprintf($this->lng->txt(
'grp_added_to_list'),
1992 include_once(
'./Modules/Group/classes/class.ilGroupParticipants.php');
1993 include_once(
'./Modules/Group/classes/class.ilGroupMembershipMailNotification.php');
2003 ', membership is limited.',
'123');
2008 $part->add($a_user_id,$a_role);
2009 $part->sendNotification($part->TYPE_NOTIFICATION_REGISTRATION, $a_user_id);