Public Member Functions | Static Public Member Functions | Data Fields

ilObjGroup Class Reference

Inheritance diagram for ilObjGroup:
Collaboration diagram for ilObjGroup:

Public Member Functions

 ilObjGroup ($a_id=0, $a_call_by_reference=true)
 Constructor public.
 join ($a_user_id, $a_mem_role="")
 join Group, assigns user to role private
 getDefaultMemberRole ()
 returns object id of created default member role public
 getDefaultAdminRole ()
 returns object id of created default adminstrator role public
 addMember ($a_user_id, $a_mem_role)
 add Member to Group public
 getNewRegistrations ()
 displays list of applicants public
 deleteApplicationListEntry ($a_userId)
 deletes an Entry from application list public
 leaveGroup ()
 is called when a member decides to leave group public
 leave ($a_user_id)
 deassign member from group role private
 removeMember ($a_user_id, $a_grp_id="")
 removes Member from group public
 getGroupMemberIds ()
 get all group Member ids regardless of role public
 getGroupMemberData ($a_mem_ids, $active=1)
 get all group Members regardless of group role.
 getCountMembers ()
 getGroupAdminIds ($a_grpId="")
 get Group Admin Id public
 getDefaultGroupRoles ($a_grp_id="")
 get default group roles, returns the defaultlike create roles il_grp_member, il_grp_admin public
 getLocalGroupRoles ($a_translate=false)
 get ALL local roles of group, also those created and defined afterwards only fetch data once from database.
 getGrpStatusClosedTemplateId ()
 get group status closed template public
 getGrpStatusOpenTemplateId ()
 get group status open template public
 setRegistrationFlag ($a_regFlag="")
 set Registration Flag public
 getRegistrationFlag ()
 get Registration Flag public
 getPassword ()
 get Password public
 setPassword ($a_password="")
 set Password public
 setExpirationDateTime ($a_date)
 set Expiration Date and Time public
 getExpirationDateTime ()
 get Expiration Date and Time public
 getExpirationTimestamp ()
 registrationPossible ()
 __setGroupStatus ($a_grpStatus)
 set group status
 getGroupStatus ()
 get group status, redundant method because public
 getMemberRoles ($a_user_id)
 get group member status public
 getMemberRolesTitle ($a_user_id)
 get group member status public
 setMemberStatus ($a_user_id, $a_member_role)
 set member status public
 isMember ($a_userId="")
 is Member public
 isAdmin ($a_userId)
 is Admin public
 ilClone ($a_parent_ref)
 copy all properties and subobjects of a group.
 delete ()
 delete group and all related data
 initDefaultRoles ()
 init default roles settings public
 notify ($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
 notifys an object about an event occured Based on the event happend, each object may decide how it reacts.
 exportXML ()
 deleteExportFiles ($a_files)
 downloadExportFile ($file)
 _lookupIdByTitle ($a_title)
 isUserRegistered ($a_user_id=0)
 _isMember ($a_user_id, $a_ref_id)
 __initFileObject ()
 _goto ($a_target)

Static Public Member Functions

 _importFromXMLString ($xml, $parent_id)
 Static used for importing a group from xml string.
 _importFromFile ($file, $parent_id)
 Static used for importing an group from xml zip file.
 _search (&$a_search_obj)
 STATIC METHOD search for group data.
 _getLinkToObject ($a_id)
 STATIC METHOD create a link to the object.

Data Fields

 $file_obj = null
 Group file object for handling of export files.
 $m_grpStatus
 $m_roleMemberId
 $m_roleAdminId

Detailed Description

Definition at line 39 of file class.ilObjGroup.php.


Member Function Documentation

ilObjGroup::__initFileObject (  ) 

Definition at line 1227 of file class.ilObjGroup.php.

Referenced by deleteExportFiles(), downloadExportFile(), and exportXML().

        {
                if($this->file_obj)
                {
                        return $this->file_obj;
                }
                else
                {
                        include_once 'classes/class.ilFileDataGroup.php';

                        return $this->file_obj = new ilFileDataGroup($this);
                }
        }

Here is the caller graph for this function:

ilObjGroup::__setGroupStatus ( a_grpStatus  ) 

set group status

Grants permissions on the group object for all parent roles. Each permission is granted by computing the intersection of the role template il_grp_status_open/_closed and the permission template of the parent role.

Creates linked roles in the local role folder object for all parent roles and initializes their permission templates. Each permission template is initialized by computing the intersection of the role template il_grp_status_open/_closed and the permission template of the parent role.

public

Parameters:
integer group id (optional)
integer group status (0=public|1=private|2=closed)

Definition at line 656 of file class.ilObjGroup.php.

References $rbacadmin, $rbacreview, $rbacsystem, getDefaultGroupRoles(), getGrpStatusClosedTemplateId(), getGrpStatusOpenTemplateId(), and ilObject::getRefId().

Referenced by initDefaultRoles().

        {
                global $rbacadmin, $rbacreview, $rbacsystem;

                //get Rolefolder of group
                $rolf_data = $rbacreview->getRoleFolderOfObject($this->getRefId());

                //define all relevant roles that rights are needed to be changed
                $arr_parentRoles = $rbacreview->getParentRoleIds($this->getRefId());
                $arr_relevantParentRoleIds = array_diff(array_keys($arr_parentRoles),$this->getDefaultGroupRoles());

                //group status open (aka public) or group status closed
                if ($a_grpStatus == 0 || $a_grpStatus == 1)
                {
                        if ($a_grpStatus == 0)
                        {
                                $template_id = $this->getGrpStatusOpenTemplateId();
                        } else {
                                $template_id = $this->getGrpStatusClosedTemplateId();
                        }
                        //get defined operations from template
                        $template_ops = $rbacreview->getOperationsOfRole($template_id, 'grp', ROLE_FOLDER_ID);

                        foreach ($arr_relevantParentRoleIds as $parentRole)
                        {
                                if ($rbacreview->isProtected($arr_parentRoles[$parentRole]['parent'],$parentRole))
                                {
                                        continue;
                                }
                                
                                $granted_permissions = array();

                                // Delete the linked role for the parent role
                                // (just in case if it already exists).
                                $rbacadmin->deleteLocalRole($parentRole,$rolf_data["child"]);

                                // Grant permissions on the group object for 
                                // the parent role. In the foreach loop we
                                // compute the intersection of the role     
                                // template il_grp_status_open/_closed and the 
                                // permission template of the parent role.
                                $current_ops = $rbacreview->getRoleOperationsOnObject($parentRole, $this->getRefId());
                                $rbacadmin->revokePermission($this->getRefId(), $parentRole);
                                foreach ($template_ops as $template_op) 
                                {
                                        if (in_array($template_op,$current_ops)) 
                                        {
                                                array_push($granted_permissions,$template_op);
                                        }
                                }
                                if (!empty($granted_permissions))
                                {
                                        $rbacadmin->grantPermission($parentRole, $granted_permissions, $this->getRefId());
                                }

                                // Create a linked role for the parent role and
                                // initialize it with the intersection of 
                                // il_grp_status_open/_closed and the permission
                                // template of the parent role
                                $rbacadmin->copyRolePermissionIntersection(
                                        $template_id, ROLE_FOLDER_ID, 
                                        $parentRole, $arr_parentRoles[$parentRole]['parent'], 
                                        $rolf_data["child"], $parentRole
                                );      
                                $rbacadmin->assignRoleToFolder($parentRole,$rolf_data["child"],"false");
                        }//END foreach
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjGroup::_getLinkToObject ( a_id  )  [static]

STATIC METHOD create a link to the object.

Parameters:
int uniq id
Returns:
array array('link','target') public

Definition at line 1173 of file class.ilObjGroup.php.

Referenced by ilSearchGUI::__formatGroupResult(), and ilSearchResult::createLink().

        {
                return array("repository.php?ref_id=".$a_id."&set_mode=flat&cmdClass=ilobjgroupgui","");
        }

Here is the caller graph for this function:

ilObjGroup::_goto ( a_target  ) 

Definition at line 1241 of file class.ilObjGroup.php.

References $_GET, $ilAccess, $ilErr, and ilObject::$lng.

        {
                global $ilAccess, $ilErr, $lng;

                if ($ilAccess->checkAccess("read", "", $a_target))
                {
                        $_GET["cmd"] = "frameset";
                        $_GET["ref_id"] = $a_target;
                }
                else
                {
                        $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
                }
        }

ilObjGroup::_importFromFile ( file,
parent_id 
) [static]

Static used for importing an group from xml zip file.

Parameters:
xml file array structure like $_FILE from upload public

Definition at line 1108 of file class.ilObjGroup.php.

References $file_obj, ilObject::$lng, and _importFromXMLString().

Referenced by ilObjGroupGUI::importFileObject().

        {
                global $lng;

                include_once 'classes/class.ilFileDataGroup.php';
                
                $file_obj = new ilFileDataGroup(null);
                $file_obj->addImportDirectory();
                $file_obj->createImportFile($_FILES["xmldoc"]["tmp_name"],$_FILES['xmldoc']['name']);
                $file_obj->unpackImportFile();

                if(!$file_obj->validateImportFile())
                {
                        return false;
                }
                return ilObjGroup::_importFromXMLString(file_get_contents($file_obj->getImportFile()),$parent_id);
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjGroup::_importFromXMLString ( xml,
parent_id 
) [static]

Static used for importing a group from xml string.

Parameters:
xml string public

Definition at line 1092 of file class.ilObjGroup.php.

References $xml.

Referenced by _importFromFile().

        {
                include_once 'classes/class.ilGroupImportParser.php';

                $import_parser = new ilGroupImportParser($xml,$parent_id);

                return $import_parser->startParsing();
        }

Here is the caller graph for this function:

ilObjGroup::_isMember ( a_user_id,
a_ref_id 
)

Definition at line 1210 of file class.ilObjGroup.php.

References $rbacreview.

Referenced by ilObjGroupAccess::_checkAccess(), and ilObjGroupGUI::getTabs().

        {
                global $rbacreview;
                
                $rolf = $rbacreview->getRoleFolderOfObject($a_ref_id);
                $local_roles = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"],false);
                $user_roles = $rbacreview->assignedRoles($a_user_id);
                
                if (!array_intersect($local_roles,$user_roles))
                {
                        return false;
                }
                
                return true;
        }

Here is the caller graph for this function:

ilObjGroup::_lookupIdByTitle ( a_title  ) 

Definition at line 1178 of file class.ilObjGroup.php.

References $query, $res, and $row.

Referenced by ilMail::getEmailsOfRecipients(), and ilMail::getUserIds().

        {
                global $ilDB;

                $query = "SELECT * FROM object_data WHERE title = '".$a_title."' AND type = 'grp'";
                $res = $ilDB->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        return $row->obj_id;
                }
                return 0;
        }

Here is the caller graph for this function:

ilObjGroup::_search ( &$  a_search_obj  )  [static]

STATIC METHOD search for group data.

This method is called from class.ilSearch This method used by class.ilSearchGUI.php to a link to the results

Parameters:
object object of search class public

Definition at line 1134 of file class.ilObjGroup.php.

References $counter, $ilBench, $query, $res, and $row.

Referenced by ilSearch::performSearch().

        {
                global $ilBench;

                // NO CLASS VARIABLES IN STATIC METHODS

                $where_condition = $a_search_obj->getWhereCondition("like",array("title","description"));
                $in = $a_search_obj->getInStatement("ore.ref_id");

                $query = "SELECT ore.ref_id AS ref_id FROM object_data AS od, object_reference AS ore ".
                        $where_condition." ".
                        $in." ".
                        "AND od.obj_id = ore.obj_id ".
                        "AND od.type = 'grp' ";

                $ilBench->start("Search", "ilObjGroup_search");
                $res = $a_search_obj->ilias->db->query($query);
                $ilBench->stop("Search", "ilObjGroup_search");

                $counter = 0;

                while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $result_data[$counter++]["id"]                          =  $row->ref_id;
                        #$result_data[$counter]["link"]                         =  "group.php?cmd=view&ref_id=".$row->ref_id;
                        #$result_data[$counter++]["target"]                     =  "";
                }

                return $result_data ? $result_data : array();
        }

Here is the caller graph for this function:

ilObjGroup::addMember ( a_user_id,
a_mem_role 
)

add Member to Group public

Parameters:
integer user_id
integer member role_id of local group_role

Definition at line 122 of file class.ilObjGroup.php.

References $rbacadmin, and join().

Referenced by setMemberStatus().

        {
                global $rbacadmin;

                if (isset($a_user_id) && isset($a_mem_role) )
                {
                        $this->join($a_user_id,$a_mem_role);
                        return true;
                }
                else
                {
                        $this->ilias->raiseError(get_class($this)."::addMember(): Missing parameters !",$this->ilias->error_obj->WARNING);
                        return false;
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjGroup::delete (  ) 

delete group and all related data

public

Returns:
boolean true if all object data were removed; false if only a references were removed TODO: Grouplinking is not longer permitted -> no other referneces possible TODO: If entire group is deleted entries of object in group that are lying in trash (-> negative tree ID) are not removed!

Reimplemented from ilObject.

Definition at line 937 of file class.ilObjGroup.php.

References $query.

        {
                // always call parent delete function first!!
                if (!parent::delete())
                {
                        return false;
                }
                
                $query = "DELETE FROM grp_data WHERE grp_id=".$this->getId();
                $this->ilias->db->query($query);

                return true;
        }

ilObjGroup::deleteApplicationListEntry ( a_userId  ) 

deletes an Entry from application list public

Definition at line 163 of file class.ilObjGroup.php.

References $q, $res, and ilObject::getId().

        {
                $q = "DELETE FROM grp_registration WHERE user_id=".$a_userId." AND grp_id=".$this->getId();
                $res = $this->ilias->db->query($q);
        }

Here is the call graph for this function:

ilObjGroup::deleteExportFiles ( a_files  ) 

Definition at line 1061 of file class.ilObjGroup.php.

References $file, and __initFileObject().

        {
                $this->__initFileObject();
                
                foreach($a_files as $file)
                {
                        $this->file_obj->deleteFile($file);
                }
                return true;
        }

Here is the call graph for this function:

ilObjGroup::downloadExportFile ( file  ) 

Definition at line 1072 of file class.ilObjGroup.php.

References $file, __initFileObject(), and ilUtil::deliverFile().

        {
                $this->__initFileObject();

                if($abs_name = $this->file_obj->getExportFile($file))
                {
                        ilUtil::deliverFile($abs_name,$file);
                        // Not reached
                }
                return false;
        }

Here is the call graph for this function:

ilObjGroup::exportXML (  ) 

Definition at line 1039 of file class.ilObjGroup.php.

References $xml, __initFileObject(), and ilObject::getId().

        {
                include_once 'classes/class.ilGroupXMLWriter.php';

                $xml_writer = new ilGroupXMLWriter($this);
                $xml_writer->start();
                
                $xml = $xml_writer->getXML();

                $name = time().'__'.$this->ilias->getSetting('inst_id').'__grp_'.$this->getId();

                $this->__initFileObject();
                
                $this->file_obj->addGroupDirectory();
                $this->file_obj->addDirectory($name);
                $this->file_obj->writeToFile($xml,$name.'/'.$name.'.xml');
                $this->file_obj->zipFile($name,$name.'.zip');
                $this->file_obj->deleteDirectory($name);

                return true;
        }

Here is the call graph for this function:

ilObjGroup::getCountMembers (  ) 

Definition at line 325 of file class.ilObjGroup.php.

References getGroupMemberIds().

        {
                return count($this->getGroupMemberIds());
        }

Here is the call graph for this function:

ilObjGroup::getDefaultAdminRole (  ) 

returns object id of created default adminstrator role public

Definition at line 109 of file class.ilObjGroup.php.

References getLocalGroupRoles().

        {
                $local_group_Roles = $this->getLocalGroupRoles();

                return $local_group_Roles["il_grp_admin_".$this->getRefId()];
        }

Here is the call graph for this function:

ilObjGroup::getDefaultGroupRoles ( a_grp_id = ""  ) 

get default group roles, returns the defaultlike create roles il_grp_member, il_grp_admin public

Parameters:
returns the obj_ids of group specific roles(il_grp_member,il_grp_admin)

Definition at line 365 of file class.ilObjGroup.php.

References $rbacadmin, $rbacreview, $role_id, and ilObject::getRefId().

Referenced by __setGroupStatus(), getGroupAdminIds(), getGroupStatus(), and isAdmin().

        {
                global $rbacadmin, $rbacreview;

                if (strlen($a_grp_id) > 0)
                {
                        $grp_id = $a_grp_id;
                }
                else
                {
                        $grp_id = $this->getRefId();
                }

                $rolf      = $rbacreview->getRoleFolderOfObject($grp_id);
                $role_arr  = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"]);

                foreach ($role_arr as $role_id)
                {
                        $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);

                        $grp_Member ="il_grp_member_".$grp_id;
                        $grp_Admin  ="il_grp_admin_".$grp_id;

                        if (strcmp($role_Obj->getTitle(), $grp_Member) == 0 )
                        {
                                $arr_grpDefaultRoles["grp_member_role"] = $role_Obj->getId();
                        }

                        if (strcmp($role_Obj->getTitle(), $grp_Admin) == 0)
                        {
                                $arr_grpDefaultRoles["grp_admin_role"] = $role_Obj->getId();
                        }
                }

                return $arr_grpDefaultRoles;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjGroup::getDefaultMemberRole (  ) 

returns object id of created default member role public

Definition at line 98 of file class.ilObjGroup.php.

References getLocalGroupRoles().

        {
                $local_group_Roles = $this->getLocalGroupRoles();

                return $local_group_Roles["il_grp_member_".$this->getRefId()];
        }

Here is the call graph for this function:

ilObjGroup::getExpirationDateTime (  ) 

get Expiration Date and Time public

Parameters:
return array(0=>date, 1=>time)

Definition at line 576 of file class.ilObjGroup.php.

References $q, $res, $row, and ilFormat::fdateDB2dateDE().

Referenced by registrationPossible().

        {
                $q = "SELECT * FROM grp_data WHERE grp_id='".$this->getId()."'";
                $res = $this->ilias->db->query($q);
                $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
                $datetime = $row["expiration"];
                $date = ilFormat::fdateDB2dateDE($datetime);
                $time = substr($row["expiration"], -8);
                $datetime = array(0=>$date, 1=>$time);

                return $datetime;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjGroup::getExpirationTimestamp (  ) 

Definition at line 589 of file class.ilObjGroup.php.

References $query, $res, $row, and ilFormat::datetime2unixTS().

        {
                $query = "SELECT * FROM grp_data WHERE grp_id = '".$this->getId()."'";

                $res = $this->ilias->db->query($query);
                $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
                $datetime = $row["expiration"];

                return ($timest = ilFormat::datetime2unixTS($datetime)) ? $timest : 0;
        }

Here is the call graph for this function:

ilObjGroup::getGroupAdminIds ( a_grpId = ""  ) 

get Group Admin Id public

Parameters:
integer group id
returns userids that are assigned to a group administrator! role

Definition at line 336 of file class.ilObjGroup.php.

References $rbacreview, $roles, getDefaultGroupRoles(), and ilObject::getRefId().

Referenced by leaveGroup(), and removeMember().

        {
                global $rbacreview;

                if (!empty($a_grpId))
                {
                        $grp_id = $a_grpId;
                }
                else
                {
                        $grp_id = $this->getRefId();
                }

                $usr_arr = array();
                $roles = $this->getDefaultGroupRoles($this->getRefId());

                foreach ($rbacreview->assignedUsers($this->getDefaultAdminRole()) as $member_id)
                {
                        array_push($usr_arr,$member_id);
                }

                return $usr_arr;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjGroup::getGroupMemberData ( a_mem_ids,
active = 1 
)

get all group Members regardless of group role.

fetch all users data in one shot to improve performance public

Parameters:
array of user ids
Returns:
return array of userdata

Definition at line 297 of file class.ilObjGroup.php.

References $ilBench, $q, $rbacadmin, $rbacreview, and $row.

        {
                global $rbacadmin, $rbacreview, $ilBench, $ilDB;

                $usr_arr= array();
                
                $q = "SELECT login,firstname,lastname,title,usr_id,last_login ".
                         "FROM usr_data ".
                         "WHERE usr_id IN (".implode(',',$a_mem_ids).")";
                         
                if (is_numeric($active) && $active > -1)
                        $q .= "AND active = '$active'";                  
                
                $r = $ilDB->query($q);
                
                while($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $mem_arr[] = array("id" => $row->usr_id,
                                                                "login" => $row->login,
                                                                "firstname" => $row->firstname,
                                                                "lastname" => $row->lastname,
                                                                "last_login" => $row->last_login
                                                                );
                }

                return $mem_arr ? $mem_arr : array();
        }

ilObjGroup::getGroupMemberIds (  ) 

get all group Member ids regardless of role public

Returns:
return array of users (obj_ids) that are assigned to the groupspecific roles (grp_member,grp_admin)

Definition at line 269 of file class.ilObjGroup.php.

References $rbacadmin, $rbacreview, and getLocalGroupRoles().

Referenced by getCountMembers(), isMember(), leaveGroup(), and removeMember().

        {
                global $rbacadmin, $rbacreview;

                $usr_arr= array();

                $rol  = $this->getLocalGroupRoles();

                foreach ($rol as $value)
                {
                        foreach ($rbacreview->assignedUsers($value) as $member_id)
                        {
                                array_push($usr_arr,$member_id);
                        }
                }

                $mem_arr = array_unique($usr_arr);
                
                return $mem_arr ? $mem_arr : array();
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjGroup::getGroupStatus (  ) 

get group status, redundant method because public

Parameters:
return group status[0=public|2=closed]

Definition at line 730 of file class.ilObjGroup.php.

References $rbacreview, $rbacsystem, getDefaultGroupRoles(), and ilObject::getRefId().

        {
                global $rbacsystem,$rbacreview;

                $role_folder = $rbacreview->getRoleFolderOfObject($this->getRefId());
                $local_roles = $rbacreview->getRolesOfRoleFolder($role_folder["ref_id"]);

                //get Rolefolder of group
                $rolf_data = $rbacreview->getRoleFolderOfObject($this->getRefId());
                //get all relevant roles
                $arr_globalRoles = array_diff($local_roles, $this->getDefaultGroupRoles());

                //if one global role has no permission to join the group is officially closed !
                foreach ($arr_globalRoles as $globalRole)
                {
                        $ops_of_role = $rbacreview->getOperationsOfRole($globalRole,"grp", ROLE_FOLDER_ID);

                        if ($rbacsystem->checkPermission($this->getRefId(), $globalRole ,"join"))
                        {
                                return 0;
                        }
                }

                return 1;
        }

Here is the call graph for this function:

ilObjGroup::getGrpStatusClosedTemplateId (  ) 

get group status closed template public

Parameters:
return obj_id of roletemplate containing permissionsettings for a closed group

Definition at line 446 of file class.ilObjGroup.php.

References $q, $res, and $row.

Referenced by __setGroupStatus().

        {
                $q = "SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_closed'";
                $res = $this->ilias->db->query($q);
                $row = $res->fetchRow(DB_FETCHMODE_ASSOC);

                return $row["obj_id"];
        }

Here is the caller graph for this function:

ilObjGroup::getGrpStatusOpenTemplateId (  ) 

get group status open template public

Parameters:
return obj_id of roletemplate containing permissionsettings for an open group

Definition at line 460 of file class.ilObjGroup.php.

References $q, $res, and $row.

Referenced by __setGroupStatus().

        {
                $q = "SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_status_open'";
                $res = $this->ilias->db->query($q);
                $row = $res->fetchRow(DB_FETCHMODE_ASSOC);

                return $row["obj_id"];
        }

Here is the caller graph for this function:

ilObjGroup::getLocalGroupRoles ( a_translate = false  ) 

get ALL local roles of group, also those created and defined afterwards only fetch data once from database.

info is stored in object variable public

Returns:
return array [title|id] of roles...

Definition at line 408 of file class.ilObjGroup.php.

References $rbacadmin, $rbacreview, $role_id, ilObjRole::_getTranslation(), and ilObject::getRefId().

Referenced by getDefaultAdminRole(), getDefaultMemberRole(), getGroupMemberIds(), getMemberRoles(), and getMemberRolesTitle().

        {
                global $rbacadmin,$rbacreview;
                
                if (empty($this->local_roles))
                {
                        $this->local_roles = array();
                        $rolf      = $rbacreview->getRoleFolderOfObject($this->getRefId());
                        $role_arr  = $rbacreview->getRolesOfRoleFolder($rolf["ref_id"]);

                        foreach ($role_arr as $role_id)
                        {
                                if ($rbacreview->isAssignable($role_id,$rolf["ref_id"]) == true)
                                {
                                        $role_Obj =& $this->ilias->obj_factory->getInstanceByObjId($role_id);
                                        
                                        if ($a_translate)
                                        {
                                                $role_name = ilObjRole::_getTranslation($role_Obj->getTitle());
                                        }
                                        else
                                        {
                                                $role_name = $role_Obj->getTitle();
                                        }
                                        
                                        $this->local_roles[$role_name] = $role_Obj->getId();
                                }
                        }
                }
                
                return $this->local_roles;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjGroup::getMemberRoles ( a_user_id  ) 

get group member status public

Parameters:
integer user_id
Returns:
returns array of obj_ids of assigned local roles

Definition at line 762 of file class.ilObjGroup.php.

References $ilBench, $rbacadmin, $rbacreview, and getLocalGroupRoles().

Referenced by leave().

        {
                global $rbacadmin, $rbacreview,$ilBench;

                $ilBench->start("Group", "getMemberRoles");

                $arr_assignedRoles = array();

                $arr_assignedRoles = array_intersect($rbacreview->assignedRoles($a_user_id),$this->getLocalGroupRoles());

                $ilBench->stop("Group", "getMemberRoles");

                return $arr_assignedRoles;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjGroup::getMemberRolesTitle ( a_user_id  ) 

get group member status public

Parameters:
integer user_id
Returns:
returns string of role titles

Definition at line 783 of file class.ilObjGroup.php.

References $ilBench, $q, $row, ilObjRole::_getTranslation(), and getLocalGroupRoles().

        {
                global $ilDB,$ilBench;
                
                include_once ('class.ilObjRole.php');

                $ilBench->start("Group", "getMemberRolesTitle");
                
                $str_member_roles ="";

                $q = "SELECT title ".
                         "FROM object_data ".
                         "LEFT JOIN rbac_ua ON object_data.obj_id=rbac_ua.rol_id ".
                         "WHERE object_data.type = 'role' ".
                         "AND rbac_ua.usr_id = ".$ilDB->quote($a_user_id)." ".
                         "AND rbac_ua.rol_id IN (".implode(',',$this->getLocalGroupRoles()).")";

                $r = $ilDB->query($q);

                while($row = $r->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        // display human readable role names for autogenerated roles
                        $str_member_roles .= ilObjRole::_getTranslation($row["title"]).", ";
                }

                $ilBench->stop("Group", "getMemberRolesTitle");
                                
                return substr($str_member_roles,0,-2);
        }

Here is the call graph for this function:

ilObjGroup::getNewRegistrations (  ) 

displays list of applicants public

Definition at line 142 of file class.ilObjGroup.php.

References $q, $res, $row, ilObject::_exists(), and ilObject::_lookupType().

        {
                $appList = array();
                $q = "SELECT * FROM grp_registration WHERE grp_id=".$this->getId();
                $res = $this->ilias->db->query($q);
                while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        if (ilObject::_exists($row->user_id) &&
                                ilObject::_lookupType($row->user_id) == "usr")
                        {
                                array_push($appList,$row);
                        }
                }

                return ($appList) ? $appList : false;
        }

Here is the call graph for this function:

ilObjGroup::getPassword (  ) 

get Password public

Parameters:
return password

Definition at line 515 of file class.ilObjGroup.php.

References $q, $res, and $row.

        {
                $q = "SELECT * FROM grp_data WHERE grp_id='".$this->getId()."'";
                $res = $this->ilias->db->query($q);
                $row = $res->fetchRow(DB_FETCHMODE_ASSOC);

                return $row["password"];
        }

ilObjGroup::getRegistrationFlag (  ) 

get Registration Flag public

Parameters:
return flag => [ 0 = no registration| 1 = registration]

Definition at line 501 of file class.ilObjGroup.php.

References $q, $res, and $row.

        {
                $q = "SELECT * FROM grp_data WHERE grp_id='".$this->getId()."'";
                $res = $this->ilias->db->query($q);
                $row = $res->fetchRow(DB_FETCHMODE_ASSOC);

                return $row["register"];
        }

ilObjGroup::ilClone ( a_parent_ref  ) 

copy all properties and subobjects of a group.

Does not copy the settings in the group's local role folder. Instead a new local role folder is created from the template settings (same process as creating a new group manually)

public

Returns:
integer new ref id

Reimplemented from ilObject.

Definition at line 890 of file class.ilObjGroup.php.

References $rbacadmin, $roles, ilUtil::groupNameExists(), and ilObjUser::updateActiveRoles().

        {
                global $rbacadmin;

                // always call parent ilClone function first!!
                $new_ref_id = parent::ilClone($a_parent_ref);
                
                // get object instance of cloned group
                $groupObj =& $this->ilias->obj_factory->getInstanceByRefId($new_ref_id);
                
                // find a free number
                for ($n = 1;$n < 99;$n++)
                {
                        $groupname_copy = $groupObj->getTitle()."_(copy_".$n.")";

                        if (!ilUtil::groupNameExists($groupname_copy))
                        {
                                $groupObj->setTitle($groupname_copy);
                                $groupObj->update();
                                break;
                        }
                }

                // setup rolefolder & default local roles (admin & member)
                $roles = $groupObj->initDefaultRoles();

                // ...finally assign groupadmin role to creator of group object
                $rbacadmin->assignUser($roles[0], $groupObj->getOwner(), "n");
                ilObjUser::updateActiveRoles($groupObj->getOwner());

                // always destroy objects in ilClone method because clone() is recursive and creates instances for each object in subtree!
                unset($groupObj);
                unset($rfoldObj);
                unset($roleObj);

                // ... and finally always return new reference ID!!
                return $new_ref_id;
        }

Here is the call graph for this function:

ilObjGroup::ilObjGroup ( a_id = 0,
a_call_by_reference = true 
)

Constructor public.

Parameters:
integer reference_id or object_id
boolean treat the id as reference_id (true) or object_id (false)

Definition at line 58 of file class.ilObjGroup.php.

References $tree, ilObject::ilObject(), and ilObject::setRegisterMode().

        {
                global $tree;

                $this->tree =& $tree;

                $this->type = "grp";
                $this->ilObject($a_id,$a_call_by_reference);
                $this->setRegisterMode(true);
        }

Here is the call graph for this function:

ilObjGroup::initDefaultRoles (  ) 

init default roles settings public

Returns:
array object IDs of created local roles.

Reimplemented from ilObject.

Definition at line 956 of file class.ilObjGroup.php.

References $_POST, $ops, $q, $rbacadmin, $rbacreview, $roles, __setGroupStatus(), ilObject::createRoleFolder(), ilObject::getId(), and ilObject::getRefId().

        {
                global $rbacadmin, $rbacreview;

                // create a local role folder
                $rfoldObj =& $this->createRoleFolder();

                // ADMIN ROLE
                // create role and assign role to rolefolder...
                $roleObj = $rfoldObj->createRole("il_grp_admin_".$this->getRefId(),"Groupadmin of group obj_no.".$this->getId());
                $this->m_roleAdminId = $roleObj->getId();

                //set permission template of new local role
                $q = "SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_admin'";
                $r = $this->ilias->db->getRow($q, DB_FETCHMODE_OBJECT);
                $rbacadmin->copyRolePermission($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());

                // set object permissions of group object
                $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),"grp",$rfoldObj->getRefId());
                $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->getRefId());

                // set object permissions of role folder object
                //$ops = $rbacreview->getOperationsOfRole($roleObj->getId(),"rolf",$rfoldObj->getRefId());
                //$rbacadmin->grantPermission($roleObj->getId(),$ops,$rfoldObj->getRefId());

                // MEMBER ROLE
                // create role and assign role to rolefolder...
                $roleObj = $rfoldObj->createRole("il_grp_member_".$this->getRefId(),"Groupmember of group obj_no.".$this->getId());
                $this->m_roleMemberId = $roleObj->getId();

                //set permission template of new local role
                $q = "SELECT obj_id FROM object_data WHERE type='rolt' AND title='il_grp_member'";
                $r = $this->ilias->db->getRow($q, DB_FETCHMODE_OBJECT);
                $rbacadmin->copyRolePermission($r->obj_id,ROLE_FOLDER_ID,$rfoldObj->getRefId(),$roleObj->getId());
                
                // set object permissions of group object
                $ops = $rbacreview->getOperationsOfRole($roleObj->getId(),"grp",$rfoldObj->getRefId());
                $rbacadmin->grantPermission($roleObj->getId(),$ops,$this->getRefId());

                // set object permissions of role folder object
                //$ops = $rbacreview->getOperationsOfRole($roleObj->getId(),"rolf",$rfoldObj->getRefId());
                //$rbacadmin->grantPermission($roleObj->getId(),$ops,$rfoldObj->getRefId());

                unset($rfoldObj);
                unset($roleObj);

                $roles[] = $this->m_roleAdminId;
                $roles[] = $this->m_roleMemberId;
                
                // Break inheritance and initialize permission for existing roles depending on group status
                // TODO: eliminate POST-Parameter here. ilClone won't work with it.
                // This will be changed anyway to non_member_template
                $this->__setGroupStatus($_POST["group_status"]);                //0=public,1=private,2=closed

                return $roles ? $roles : array();
        }

Here is the call graph for this function:

ilObjGroup::isAdmin ( a_userId  ) 

is Admin public

Parameters:
integer user_id
boolean,true if user is group administrator

Definition at line 866 of file class.ilObjGroup.php.

References $rbacreview, and getDefaultGroupRoles().

Referenced by leaveGroup(), and removeMember().

        {
                global $rbacreview;

                $grp_Roles = $this->getDefaultGroupRoles();

                if (in_array($a_userId,$rbacreview->assignedUsers($grp_Roles["grp_admin_role"])))
                {
                        return true;
                }
                else
                {
                        return false;
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjGroup::isMember ( a_userId = ""  ) 

is Member public

Parameters:
integer user_id
return true if user is member

Definition at line 834 of file class.ilObjGroup.php.

References $user_id, getGroupMemberIds(), and ilObject::getType().

Referenced by isUserRegistered(), and removeMember().

        {
                if (strlen($a_userId) == 0)
                {
                        $user_id = $this->ilias->account->getId();
                }
                else 
                {
                        $user_id = $a_userId;
                }
                
                if ($this->getType() == "grp")
                {
                        $arr_members = $this->getGroupMemberIds();

                        if (in_array($user_id, $arr_members))
                        {
                                return true;
                        }
                        else
                        {
                                return false;
                        }
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjGroup::isUserRegistered ( a_user_id = 0  ) 

Reimplemented from ilObject.

Definition at line 1192 of file class.ilObjGroup.php.

References $rbacsystem, and isMember().

        {
                global $rbacsystem;
                
                // exclude system role from check
                /*if (in_array(SYSTEM_ROLE_ID,$_SESSION["RoleId"]))
                {
                        return true;            
                }*/

                if (!$this->isMember() or !$rbacsystem->checkAccess("join", $this->ref_id))
                {
                        return false;
                }
                
                return true;
        }

Here is the call graph for this function:

ilObjGroup::join ( a_user_id,
a_mem_role = "" 
)

join Group, assigns user to role private

Parameters:
integer member status = obj_id of local_group_role

Definition at line 74 of file class.ilObjGroup.php.

References $rbacadmin, and ilObjUser::updateActiveRoles().

Referenced by addMember().

        {
                global $rbacadmin;

                if (is_array($a_mem_role))
                {
                        foreach ($a_mem_role as $role)
                        {
                                $rbacadmin->assignUser($role,$a_user_id, false);
                        }
                }
                else
                {
                        $rbacadmin->assignUser($a_mem_role,$a_user_id, false);
                }

                ilObjUser::updateActiveRoles($a_user_id);
                return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjGroup::leave ( a_user_id  ) 

deassign member from group role private

Definition at line 206 of file class.ilObjGroup.php.

References $rbacadmin, getMemberRoles(), and ilObjUser::updateActiveRoles().

Referenced by leaveGroup(), and removeMember().

        {
                global $rbacadmin;

                $arr_groupRoles = $this->getMemberRoles($a_user_id);

                if (is_array($arr_groupRoles))
                {
                        foreach ($arr_groupRoles as $groupRole)
                        {
                                $rbacadmin->deassignUser($groupRole, $a_user_id);
                        }
                }
                else
                {
                        $rbacadmin->deassignUser($arr_groupRoles, $a_user_id);
                }

                ilObjUser::updateActiveRoles($a_user_id);

                return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjGroup::leaveGroup (  ) 

is called when a member decides to leave group public

Parameters:
integer user-Id
integer group-Id

Definition at line 175 of file class.ilObjGroup.php.

References $rbacadmin, $rbacreview, getGroupAdminIds(), getGroupMemberIds(), ilObject::getRefId(), isAdmin(), and leave().

        {
                global $rbacadmin, $rbacreview;

                $member_ids = $this->getGroupMemberIds();

                if (count($member_ids) <= 1 || !in_array($this->ilias->account->getId(), $member_ids))
                {
                        return 2;
                }
                else
                {
                        if (!$this->isAdmin($this->ilias->account->getId()))
                        {
                                $this->leave($this->ilias->account->getId());
                                $member = new ilObjUser($this->ilias->account->getId());
                                $member->dropDesktopItem($this->getRefId(), "grp");

                                return 0;
                        }
                        else if (count($this->getGroupAdminIds()) == 1)
                        {
                                return 1;
                        }
                }
        }

Here is the call graph for this function:

ilObjGroup::notify ( a_event,
a_ref_id,
a_parent_non_rbac_id,
a_node_id,
a_params = 0 
)

notifys an object about an event occured Based on the event happend, each object may decide how it reacts.

public

Parameters:
string event
integer reference id of object where the event occured
array passes optional parameters if required
Returns:
boolean

Reimplemented from ilObject.

Definition at line 1023 of file class.ilObjGroup.php.

References $tree.

        {
                global $tree;
                
                $parent_id = (int) $tree->getParentId($a_node_id);
                
                if ($parent_id != 0)
                {
                        $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
                        $obj_data->notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$parent_id,$a_params);
                }
                                
                return true;
        }

ilObjGroup::registrationPossible (  ) 

Definition at line 601 of file class.ilObjGroup.php.

References ilFormat::dateDE2timestamp(), ilFormat::getDateDE(), and getExpirationDateTime().

        {
                $datetime = $this->getExpirationDateTime();
                $today_date = ilFormat::getDateDE();
                $today_time = date("H:i:s");
       
                $ts_exp_date = ilFormat::dateDE2timestamp($datetime[0]);
                $ts_today_date = ilFormat::dateDE2timestamp($today_date);
        
                $ts_exp_time = substr($datetime[1], 0, 2).
                                                substr($datetime[1], 3, 2).
                                                substr($datetime[1], 6, 2);
                
                $ts_today_time = substr($today_time, 0, 2).
                                                substr($today_time, 3, 2).
                                                substr($today_time, 6, 2);
                                                
                // no timelimit given -> unlimited
                if ($ts_exp_date == 0)
                {
                        return true;
                }
                
                if ($ts_today_date < $ts_exp_date) 
                {
                        return true;
                }
                elseif (($ts_today_date == $ts_exp_date) and (strcmp($ts_exp_time,$ts_today_time) >= 0)) 
                {
                        return true;
                }
                else 
                {
                        return false;
                }
        }

Here is the call graph for this function:

ilObjGroup::removeMember ( a_user_id,
a_grp_id = "" 
)

removes Member from group public

Definition at line 233 of file class.ilObjGroup.php.

References getGroupAdminIds(), getGroupMemberIds(), ilObject::getRefId(), isAdmin(), isMember(), and leave().

Referenced by setMemberStatus().

        {
                if (isset($a_user_id) && isset($a_grp_id) && $this->isMember($a_user_id))
                {
                        if (count($this->getGroupMemberIds()) > 1)
                        {
                                if ($this->isAdmin($a_user_id) && count($this->getGroupAdminIds()) < 2)
                                {
                                        return "grp_err_administrator_required";
                                }
                                else
                                {
                                        $this->leave($a_user_id);
                                        $member = new ilObjUser($a_user_id);
                                        $member->dropDesktopItem($this->getRefId(), "grp");

                                        return "";
                                }
                        }
                        else
                        {
                                return "grp_err_last_member";
                        }
                }
                else
                {
                        $this->ilias->raiseError(get_class($this)."::removeMember(): Missing parameters !",$this->ilias->error_obj->WARNING);
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjGroup::setExpirationDateTime ( a_date  ) 

set Expiration Date and Time public

Parameters:
date 

Definition at line 553 of file class.ilObjGroup.php.

References $q, $res, ilObject::getId(), and ilFormat::input2date().

        {
                $q = "SELECT * FROM grp_data WHERE grp_id='".$this->getId()."'";
                $res = $this->ilias->db->query($q);
                $date = ilFormat::input2date($a_date);

                if ($res->numRows() == 0)
                {
                        $q = "INSERT INTO grp_data (grp_id, expiration) VALUES(".$this->getId().",'".$date."')";
                        $res = $this->ilias->db->query($q);
                }
                else
                {
                        $q = "UPDATE grp_data SET expiration='".$date."' WHERE grp_id=".$this->getId()."";
                        $res = $this->ilias->db->query($q);
                }
        }

Here is the call graph for this function:

ilObjGroup::setMemberStatus ( a_user_id,
a_member_role 
)

set member status public

Parameters:
integer user id
integer member role id

Definition at line 819 of file class.ilObjGroup.php.

References addMember(), and removeMember().

        {
                if (isset($a_user_id) && isset($a_member_role))
                {
                        $this->removeMember($a_user_id);
                        $this->addMember($a_user_id, $a_member_role);
                }
        }

Here is the call graph for this function:

ilObjGroup::setPassword ( a_password = ""  ) 

set Password public

Parameters:
password 

Definition at line 529 of file class.ilObjGroup.php.

References $q, $res, and ilObject::getId().

        {
                global $ilDB;
                
                $q = "SELECT * FROM grp_data WHERE grp_id='".$this->getId()."'";
                $res = $this->ilias->db->query($q);

                if ($res->numRows() == 0)
                {
                        $q = "INSERT INTO grp_data (grp_id, password) VALUES(".$this->getId().",".$ilDB->quote($a_password).")";
                        $res = $this->ilias->db->query($q);
                }
                else
                {
                        $q = "UPDATE grp_data SET password=".$ilDB->quote($a_password)." WHERE grp_id=".$this->getId()."";
                        $res = $this->ilias->db->query($q);
                }
        }

Here is the call graph for this function:

ilObjGroup::setRegistrationFlag ( a_regFlag = ""  ) 

set Registration Flag public

Parameters:
integer [ 0 = no registration| 1 = registration]

Definition at line 474 of file class.ilObjGroup.php.

References $q, $res, and ilObject::getId().

        {
                $q = "SELECT * FROM grp_data WHERE grp_id='".$this->getId()."'";
                $res = $this->ilias->db->query($q);

                if (!isset($a_regFlag))
                {
                        $a_regFlag = 0;
                }

                if ($res->numRows() == 0)
                {
                        $q = "INSERT INTO grp_data (grp_id, register) VALUES(".$this->getId().",".$a_regFlag.")";
                        $res = $this->ilias->db->query($q);
                }
                else
                {
                        $q = "UPDATE grp_data SET register=".$a_regFlag." WHERE grp_id=".$this->getId()."";
                        $res = $this->ilias->db->query($q);
                }
        }

Here is the call graph for this function:


Field Documentation

ilObjGroup::$file_obj = null

Group file object for handling of export files.

Definition at line 44 of file class.ilObjGroup.php.

Referenced by _importFromFile().

ilObjGroup::$m_grpStatus

Definition at line 46 of file class.ilObjGroup.php.

ilObjGroup::$m_roleAdminId

Definition at line 50 of file class.ilObjGroup.php.

ilObjGroup::$m_roleMemberId

Definition at line 48 of file class.ilObjGroup.php.


The documentation for this class was generated from the following file: