27 require_once
"./Services/Container/classes/class.ilContainer.php";
28 include_once(
'./Services/Calendar/classes/class.ilDateTime.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);
108 public function __construct($a_id = 0,$a_call_by_reference =
true)
112 $this->tree =& $tree;
115 $this->
ilObject($a_id,$a_call_by_reference);
128 $query =
"SELECT grp_type FROM grp_settings ".
129 "WHERE obj_id = ".$ilDB->quote($a_id,
'integer');
133 return $row->grp_type;
148 $this->information = $a_information;
171 $this->group_type = $a_type;
214 $this->reg_type = $a_type;
248 $this->reg_unlimited = $a_status;
271 $this->reg_start = $a_start;
282 return $this->reg_start ? $this->reg_start : $this->reg_start =
new ilDateTime(date(
'Y-m-d').
' 08:00:00',
IL_CAL_DATETIME);
295 $this->reg_end = $a_end;
317 $this->reg_password = $a_pass;
340 $this->reg_membership_limitation = $a_status;
362 $this->reg_max_members = $a_max;
385 $this->waiting_list = $a_status;
407 $this->latitude = $a_latitude;
427 $this->longitude = $a_longitude;
447 $this->locationzoom = $a_locationzoom;
467 $this->enablemap = $a_enablemap;
493 $ilErr->appendMessage($this->lng->txt(self::ERR_MISSING_TITLE));
497 $ilErr->appendMessage($this->lng->txt(self::ERR_MISSING_GROUP_TYPE));
501 $ilErr->appendMessage($this->lng->txt(self::ERR_MISSING_PASSWORD));
505 $ilErr->appendMessage($this->lng->txt(self::ERR_WRONG_REG_TIME_LIMIT));
509 $ilErr->appendMessage($this->lng->txt(self::ERR_WRONG_MAX_MEMBERS));
511 return strlen($ilErr->getMessage()) == 0;
522 global
$ilDB,$ilAppEventHandler;
524 if(!parent::create())
529 $query =
"INSERT INTO grp_settings (obj_id,information,grp_type,registration_type,registration_enabled,".
530 "registration_unlimited,registration_start,registration_end,registration_password,registration_mem_limit,".
531 "registration_max_members,waiting_list,latitude,longitude,location_zoom,enablemap) ".
533 $ilDB->quote($this->
getId() ,
'integer').
", ".
535 $ilDB->quote((
int) $this->
getGroupType() ,
'integer').
", ".
552 $ilAppEventHandler->raise(
'Modules/Group',
554 array(
'object' => $this,
555 'obj_id' => $this->
getId(),
558 return $this->
getId();
566 global
$ilDB,$ilAppEventHandler;
568 if (!parent::update())
573 $query =
"UPDATE grp_settings ".
574 "SET information = ".$ilDB->quote($this->
getInformation() ,
'text').
", ".
575 "grp_type = ".$ilDB->quote((
int) $this->
getGroupType() ,
'integer').
", ".
581 "registration_password = ".$ilDB->quote($this->
getPassword() ,
'text').
", ".
583 "registration_mem_limit = ".$ilDB->quote((
int) $this->
isMembershipLimited() ,
'integer').
", ".
584 "registration_max_members = ".$ilDB->quote($this->
getMaxMembers() ,
'integer').
", ".
586 "latitude = ".$ilDB->quote($this->
getLatitude() ,
'text').
", ".
587 "longitude = ".$ilDB->quote($this->
getLongitude() ,
'text').
", ".
588 "location_zoom = ".$ilDB->quote($this->
getLocationZoom() ,
'integer').
", ".
590 "WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer').
" ";
593 $ilAppEventHandler->raise(
'Modules/Group',
595 array(
'object' => $this,
596 'obj_id' => $this->
getId(),
609 public function delete()
611 global
$ilDB,$ilAppEventHandler;
614 if (!parent::delete())
619 $query =
"DELETE FROM grp_settings ".
620 "WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer');
623 include_once(
'./Modules/Group/classes/class.ilGroupParticipants.php');
626 $ilAppEventHandler->raise(
'Modules/Group',
628 array(
'object' => $this,
629 'obj_id' => $this->
getId(),
646 $query =
"SELECT * FROM grp_settings ".
647 "WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer');
670 include_once(
'./Services/Container/classes/class.ilContainerSortingSettings.php');
684 global
$ilDB,$ilUser;
709 $ilLog->write(__METHOD__.
': Starting add user');
712 include_once(
'./Modules/Group/classes/class.ilGroupParticipants.php');
715 $part->updateNotification($ilUser->getId(),1);
718 include_once(
'Services/Tracking/classes/class.ilLPObjSettings.php');
720 $obj_settings->cloneSettings($new_obj->getId());
721 unset($obj_settings);
745 if($course_ref_id = $tree->checkForParentType($this->getRefId(),
'crs') and
746 $new_course_ref_id = $tree->checkForParentType($a_target_id,
'crs'))
748 include_once(
'Modules/Course/classes/class.ilCourseItems.php');
751 $course_items->cloneDependencies($a_target_id,$a_copy_id);
754 include_once(
'Services/Tracking/classes/class.ilLPCollections.php');
756 $lp_collection->cloneCollections($a_target_id,$a_copy_id);
770 global
$ilLog,$rbacadmin,$rbacreview;
773 $new_admin = $new_obj->getDefaultAdminRole();
774 $source_rolf = $rbacreview->getRoleFolderIdOfObject($this->
getRefId());
775 $target_rolf = $rbacreview->getRoleFolderIdOfObject($new_obj->getRefId());
777 if(!$admin || !$new_admin || !$source_rolf || !$target_rolf)
779 $ilLog->write(__METHOD__.
' : Error cloning auto generated role: il_grp_admin');
781 $rbacadmin->copyRolePermissions($admin,$source_rolf,$target_rolf,$new_admin,
true);
782 $ilLog->write(__METHOD__.
' : Finished copying of role il_grp_admin.');
785 $new_member = $new_obj->getDefaultMemberRole();
786 if(!$member || !$new_member)
788 $ilLog->write(__METHOD__.
' : Error cloning auto generated role: il_grp_member');
790 $rbacadmin->copyRolePermissions($member,$source_rolf,$target_rolf,$new_member,
true);
791 $ilLog->write(__METHOD__.
' : Finished copying of role grp_member.');
800 function join($a_user_id, $a_mem_role=
"")
804 if (is_array($a_mem_role))
806 foreach ($a_mem_role as $role)
808 $rbacadmin->assignUser($role,$a_user_id,
false);
813 $rbacadmin->assignUser($a_mem_role,$a_user_id,
false);
827 return $local_group_Roles[
"il_grp_member_".$this->getRefId()];
838 return $local_group_Roles[
"il_grp_admin_".$this->getRefId()];
851 if (isset($a_user_id) && isset($a_mem_role) )
853 $this->
join($a_user_id,$a_mem_role);
858 $this->ilias->raiseError(get_class($this).
"::addMember(): Missing parameters !",$this->ilias->error_obj->WARNING);
872 global $rbacadmin, $rbacreview;
876 if (count($member_ids) <= 1 || !in_array($this->ilias->account->getId(), $member_ids))
882 if (!$this->
isAdmin($this->ilias->account->getId()))
884 $this->
leave($this->ilias->account->getId());
885 $member =
new ilObjUser($this->ilias->account->getId());
907 if (is_array($arr_groupRoles))
909 foreach ($arr_groupRoles as $groupRole)
911 $rbacadmin->deassignUser($groupRole, $a_user_id);
916 $rbacadmin->deassignUser($arr_groupRoles, $a_user_id);
930 global $rbacadmin, $rbacreview;
936 foreach ($rol as $value)
938 foreach ($rbacreview->assignedUsers($value) as $member_id)
940 array_push($usr_arr,$member_id);
944 $mem_arr = array_unique($usr_arr);
946 return $mem_arr ? $mem_arr : array();
962 $q =
"SELECT login,firstname,lastname,title,usr_id,last_login ".
966 if (is_numeric($active) && $active > -1)
967 $q .=
"AND active = '$active'";
969 $q .=
'ORDER BY lastname,firstname';
971 $r = $ilDB->query(
$q);
975 $mem_arr[] = array(
"id" =>
$row->usr_id,
976 "login" =>
$row->login,
977 "firstname" =>
$row->firstname,
978 "lastname" =>
$row->lastname,
979 "last_login" =>
$row->last_login
983 return $mem_arr ? $mem_arr : array();
1001 if (!empty($a_grpId))
1013 foreach ($rbacreview->assignedUsers($this->getDefaultAdminRole()) as $member_id)
1015 array_push($usr_arr,$member_id);
1028 global $rbacadmin, $rbacreview;
1030 if (strlen($a_grp_id) > 0)
1032 $grp_id = $a_grp_id;
1039 $rolf = $rbacreview->getRoleFolderOfObject($grp_id);
1040 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"]);
1042 foreach ($role_arr as $role_id)
1044 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
1046 $grp_Member =
"il_grp_member_".$grp_id;
1047 $grp_Admin =
"il_grp_admin_".$grp_id;
1049 if (strcmp($role_Obj->getTitle(), $grp_Member) == 0 )
1051 $arr_grpDefaultRoles[
"grp_member_role"] = $role_Obj->getId();
1054 if (strcmp($role_Obj->getTitle(), $grp_Admin) == 0)
1056 $arr_grpDefaultRoles[
"grp_admin_role"] = $role_Obj->getId();
1060 return $arr_grpDefaultRoles;
1071 global $rbacadmin,$rbacreview;
1073 if (empty($this->local_roles))
1075 $this->local_roles = array();
1076 $rolf = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1077 $role_arr = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"]);
1079 foreach ($role_arr as $role_id)
1081 if ($rbacreview->isAssignable($role_id,$rolf[
"ref_id"]) ==
true)
1083 $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
1091 $role_name = $role_Obj->getTitle();
1094 $this->local_roles[$role_name] = $role_Obj->getId();
1099 return $this->local_roles;
1109 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_closed'";
1110 $res = $this->ilias->db->query(
$q);
1113 return $row[
"obj_id"];
1123 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_open'";
1124 $res = $this->ilias->db->query(
$q);
1127 return $row[
"obj_id"];
1143 global $tree,$rbacreview,$rbacadmin;
1145 $parent_roles = $rbacreview->getParentRoleIds($this->
getRefId());
1147 $rolf_data = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1150 foreach($real_parent_roles as $role_id)
1153 if(isset($rolf_data[
'child']) and $rolf_data[
'child'])
1155 $rbacadmin->deleteLocalRole($role_id,$rolf_data[
'child']);
1158 $parent_roles = $rbacreview->getParentRoleIds($this->
getRefId());
1173 foreach($tree->getFilteredSubTree($this->getRefId(),array(
'rolf',
'grp')) as $subnode)
1176 $template_ops = $rbacreview->getOperationsOfRole($template_id,$subnode[
'type'], ROLE_FOLDER_ID);
1178 $rolf_data = $rbacreview->getRoleFolderOfObject($subnode[
'child']);
1182 foreach($real_parent_roles as $role_id)
1184 if($rbacreview->isProtected($parent_roles[$role_id][
'parent'],$role_id))
1190 if(isset($rolf_data[
'child']) and $rolf_data[
'child'])
1192 $rbacadmin->deleteLocalRole($role_id,$rolf_data[
'child']);
1196 $current_ops = $rbacreview->getOperationsOfRole($role_id,$subnode[
'type'],$parent_roles[$role_id][
'parent']);
1199 $rbacadmin->revokePermission($subnode[
'child'],$role_id);
1203 foreach($template_ops as $operation)
1205 if(in_array($operation,$current_ops))
1207 $granted[] = $operation;
1212 $rbacadmin->grantPermission($role_id, $granted,$subnode[
'child']);
1218 $rbacadmin->copyRolePermissionIntersection(
1219 $template_id, ROLE_FOLDER_ID,
1220 $role_id, $parent_roles[$role_id][
'parent'],
1221 $rolf_data[
"child"],$role_id);
1222 $rbacadmin->assignRoleToFolder($role_id,$rolf_data[
"child"],
"n");
1249 global $rbacadmin, $rbacreview, $rbacsystem;
1252 $rolf_data = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1255 $arr_parentRoles = $rbacreview->getParentRoleIds($this->
getRefId());
1257 $real_local_roles = $rbacreview->getRolesOfRoleFolder($rolf_data[
'ref_id'],
false);
1258 $arr_relevantParentRoleIds = array_diff(array_keys($arr_parentRoles),$real_local_roles);
1272 $template_ops = $rbacreview->getOperationsOfRole($template_id,
'grp', ROLE_FOLDER_ID);
1274 foreach ($arr_relevantParentRoleIds as $parentRole)
1276 if ($rbacreview->isProtected($arr_parentRoles[$parentRole][
'parent'],$parentRole))
1281 $granted_permissions = array();
1288 if(isset($rolf_data[
'child']) and $rolf_data[
'child'])
1290 $rbacadmin->deleteLocalRole($parentRole,$rolf_data[
"child"]);
1298 $current_ops = $rbacreview->getRoleOperationsOnObject($parentRole, $this->
getRefId());
1299 $rbacadmin->revokePermission($this->
getRefId(), $parentRole);
1300 foreach ($template_ops as $template_op)
1302 if (in_array($template_op,$current_ops))
1304 array_push($granted_permissions,$template_op);
1307 if (!empty($granted_permissions))
1309 $rbacadmin->grantPermission($parentRole, $granted_permissions, $this->
getRefId());
1316 $rbacadmin->copyRolePermissionIntersection(
1317 $template_id, ROLE_FOLDER_ID,
1318 $parentRole, $arr_parentRoles[$parentRole][
'parent'],
1319 $rolf_data[
"child"], $parentRole
1321 $rbacadmin->assignRoleToFolder($parentRole,$rolf_data[
"child"],
"false");
1335 $this->group_status = $a_status;
1347 return $this->group_status;
1357 global $rbacsystem,$rbacreview;
1359 $role_folder = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1360 $local_roles = $rbacreview->getRolesOfRoleFolder($role_folder[
"ref_id"]);
1363 $rolf_data = $rbacreview->getRoleFolderOfObject($this->
getRefId());
1368 foreach ($arr_globalRoles as $globalRole)
1370 $ops_of_role = $rbacreview->getOperationsOfRole($globalRole,
"grp", ROLE_FOLDER_ID);
1372 if ($rbacsystem->checkPermission($this->getRefId(), $globalRole ,
"join"))
1389 global $rbacadmin, $rbacreview,
$ilBench;
1391 $ilBench->start(
"Group",
"getMemberRoles");
1393 $arr_assignedRoles = array();
1395 $arr_assignedRoles = array_intersect($rbacreview->assignedRoles($a_user_id),$this->
getLocalGroupRoles());
1397 $ilBench->stop(
"Group",
"getMemberRoles");
1399 return $arr_assignedRoles;
1414 if (in_array($a_userId,$rbacreview->assignedUsers($grp_Roles[
"grp_admin_role"])))
1433 global $rbacadmin, $rbacreview;
1440 $roleObj = $rfoldObj->createRole(
"il_grp_admin_".$this->
getRefId(),
"Groupadmin of group obj_no.".$this->
getId());
1441 $this->m_roleAdminId = $roleObj->getId();
1444 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_admin'";
1446 $rbacadmin->copyRoleTemplatePermissions($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
1449 $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),
"grp",$rfoldObj->getRefId());
1450 $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->
getRefId());
1458 $roleObj = $rfoldObj->createRole(
"il_grp_member_".$this->
getRefId(),
"Groupmember of group obj_no.".$this->
getId());
1459 $this->m_roleMemberId = $roleObj->getId();
1462 $q =
"SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_member'";
1464 $rbacadmin->copyRoleTemplatePermissions($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
1467 $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),
"grp",$rfoldObj->getRefId());
1468 $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->
getRefId());
1480 return $roles ? $roles : array();
1493 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
1497 $parent_id = (int) $tree->getParentId($a_node_id);
1499 if ($parent_id != 0)
1501 $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
1502 $obj_data->notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$parent_id,$a_params);
1511 include_once
'Modules/Group/classes/class.ilGroupXMLWriter.php';
1514 $xml_writer->start();
1516 $xml = $xml_writer->getXML();
1518 $name = time().
'__'.$this->ilias->getSetting(
'inst_id').
'__grp_'.$this->
getId();
1522 $this->file_obj->addGroupDirectory();
1523 $this->file_obj->addDirectory(
$name);
1524 $this->file_obj->writeToFile($xml,
$name.
'/'.
$name.
'.xml');
1525 $this->file_obj->zipFile(
$name,
$name.
'.zip');
1526 $this->file_obj->deleteDirectory(
$name);
1535 foreach($a_files as
$file)
1537 $this->file_obj->deleteFile($file);
1546 if($abs_name = $this->file_obj->getExportFile(
$file))
1564 include_once
'Modules/Group/classes/class.ilGroupXMLParser.php';
1568 return $import_parser->startParsing();
1582 include_once
'classes/class.ilFileDataGroup.php';
1586 $file_obj->createImportFile($_FILES[
"xmldoc"][
"tmp_name"],$_FILES[
'xmldoc'][
'name']);
1606 return array(
"repository.php?ref_id=".$a_id.
"&set_mode=flat&cmdClass=ilobjgroupgui",
"");
1613 $query =
"SELECT * FROM object_data WHERE title = ".
1614 $ilDB->quote($a_title ,
'text').
" AND type = 'grp'";
1618 return $row->obj_id;
1626 global $rbacreview,$ilObjDataCache,
$ilDB;
1628 $rolf = $rbacreview->getRoleFolderOfObject($a_ref_id);
1629 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
"ref_id"],
false);
1630 $user_roles = $rbacreview->assignedRoles($a_user_id);
1635 include_once
'./Services/User/classes/class.ilObjUser.php';
1641 $and =
"AND login = '".$tmp_user->getLogin().
"' ";
1644 $and =
"AND email = '".$tmp_user->getEmail().
"' ";
1646 case 'matriculation':
1647 $and =
"AND matriculation = '".$tmp_user->getMatriculation().
"' ";
1651 $and =
"AND usr_id = '".$a_user_id.
"'";
1658 $query =
"SELECT * FROM usr_data as ud ".
1663 return $res->numRows() ?
true :
false;
1666 if (!array_intersect($local_roles,$user_roles))
1682 $rolf = $rbacreview->getRoleFolderOfObject(
$ref_id);
1683 $local_roles = $rbacreview->getRolesOfRoleFolder($rolf[
'ref_id'],
false);
1686 foreach($local_roles as $role_id)
1688 $users = array_merge($users,$rbacreview->assignedUsers($role_id));
1691 return array_unique($users);
1707 if ($course_ref_id = $tree->checkForParentType($this->ref_id,
'crs'))
1709 include_once(
"./Modules/Course/classes/class.ilObjCourse.php");
1730 static $items = null;
1732 if(!is_object($items[$this->
getRefId()]))
1734 if ($course_ref_id = $tree->checkForParentType($this->getRefId(),
'crs'))
1736 include_once(
"./Modules/Course/classes/class.ilObjCourse.php");
1737 include_once(
"./Modules/Course/classes/class.ilCourseItems.php");
1742 if(is_object($items[$this->
getRefId()]))
1744 $items[$this->
getRefId()]->addAdditionalSubItemInformation($a_item_data);
1758 include_once
'classes/class.ilFileDataGroup.php';
1766 return $this->message;
1770 $this->message = $a_message;
1776 $this->message .=
"<br /> ";
1778 $this->message .= $a_message;
1790 include_once(
'./Services/Calendar/classes/class.ilCalendarAppointmentTemplate.php');
1802 $app->setSubtitle(
'grp_cal_reg_start');
1810 $app->setSubtitle(
'grp_cal_reg_end');
1833 include_once(
'./Modules/Group/classes/class.ilGroupParticipants.php');