Public Member Functions | Static Public Member Functions | Data Fields | Private Member Functions | Private Attributes | Static Private Attributes

ilLDAPRoleGroupMappingSettings Class Reference
[Services/LDAP]

Collaboration diagram for ilLDAPRoleGroupMappingSettings:

Public Member Functions

 getServerId ()
 getMappings ()
 Get already configured mappings.
 loadFromPost ($a_mappings)
 validate ()
 Validate mappings.
 save ()
 Save mappings.
 delete ($a_mapping_id)
 Delete a mapping.
 getMappingInfoString ($a_mapping_id)
 Create an info string for a role group mapping.

Static Public Member Functions

static _getInstanceByServerId ($a_server_id)
 Get instance of class.
static _deleteByRole ($a_role_id)
static _deleteByServerId ($a_server_id)
static _getAllActiveMappings ()

Data Fields

const MAPPING_INFO_ALL = 1
const MAPPING_INFO_INFO_ONLY = 0

Private Member Functions

 __construct ($a_server_id)
 Private constructor (Singleton for each server_id).
 read ()
 Read mappings.

Private Attributes

 $server_id = null
 $db = null
 $mappings = null

Static Private Attributes

static $instances = array()

Detailed Description

Author:
Stefan Meyer <smeyer@databay.de>
Version:
$Id$

Definition at line 32 of file class.ilLDAPRoleGroupMappingSettings.php.


Constructor & Destructor Documentation

ilLDAPRoleGroupMappingSettings::__construct ( a_server_id  )  [private]

Private constructor (Singleton for each server_id).

private

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

References $lng, and read().

        {
                global $ilDB,$lng;
                
                $this->db = $ilDB;
                $this->lng = $lng;
                $this->server_id = $a_server_id;
                $this->read();  
        }

Here is the call graph for this function:


Member Function Documentation

static ilLDAPRoleGroupMappingSettings::_deleteByRole ( a_role_id  )  [static]

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

Referenced by ilObjRole::delete().

        {
                global $ilDB;
                
                $query = "DELETE FROM ldap_role_group_mapping ".
                        "WHERE role = ".$ilDB->quote($a_role_id);
                $ilDB->query($query);
                
                return true;    
        }

Here is the caller graph for this function:

static ilLDAPRoleGroupMappingSettings::_deleteByServerId ( a_server_id  )  [static]

Definition at line 85 of file class.ilLDAPRoleGroupMappingSettings.php.

        {
                global $ilDB;
                
                $query = "DELETE FROM ldap_role_group_mapping ".
                        "WHERE server_id = ".$ilDB->quote($a_server_id);
                        
                $ilDB->query($query);
                return true;
        }

static ilLDAPRoleGroupMappingSettings::_getAllActiveMappings (  )  [static]

Definition at line 96 of file class.ilLDAPRoleGroupMappingSettings.php.

References $data, and $res.

Referenced by ilLDAPRoleGroupMapping::initServers().

        {
                global $ilDB,$rbacreview;
                
                $query = "SELECT rgm.* FROM ldap_role_group_mapping as rgm JOIN ldap_server_settings as lss ".
                        "ON rgm.server_id = lss.server_id ".
                        "WHERE lss.active = 1 ".
                        "AND lss.role_sync_active = 1 ";
                $res = $ilDB->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $data['server_id']              = $row->server_id;
                        $data['url']                    = $row->url;
                        $data['mapping_id']             = $row->mapping_id;
                        $data['dn']                             = $row->dn;
                        $data['member']                 = $row->member_attribute;
                        $data['isdn']                   = $row->member_isdn;
                        $data['info']                   = $row->mapping_info;
                        $data['info_type']              = $row->mapping_info_type;
                        // read assigned object
                        $data['object_id']              = $rbacreview->getObjectOfRole($row->role);
                        
                        
                        $active[$row->role][] = $data;
                }
                return $active ? $active : array();
        }

Here is the caller graph for this function:

static ilLDAPRoleGroupMappingSettings::_getInstanceByServerId ( a_server_id  )  [static]

Get instance of class.

public

Parameters:
int server_id

Definition at line 65 of file class.ilLDAPRoleGroupMappingSettings.php.

Referenced by ilLDAPSettingsGUI::initRoleMapping().

        {
                if(array_key_exists($a_server_id,self::$instances) and is_object(self::$instances[$a_server_id]))
                {
                        return self::$instances[$a_server_id];
                }
                return self::$instances[$a_server_id] = new ilLDAPRoleGroupMappingSettings($a_server_id);
        }

Here is the caller graph for this function:

ilLDAPRoleGroupMappingSettings::delete ( a_mapping_id  ) 

Delete a mapping.

public

Parameters:
int mapping_id

Definition at line 252 of file class.ilLDAPRoleGroupMappingSettings.php.

References getServerId(), and read().

        {
                $query = "DELETE FROM ldap_role_group_mapping ".
                        "WHERE server_id = ".$this->db->quote($this->getServerId())." ".
                        "AND mapping_id = ".$this->db->quote($a_mapping_id);
                $this->db->query($query);
                        
                $this->read();
        }

Here is the call graph for this function:

ilLDAPRoleGroupMappingSettings::getMappingInfoString ( a_mapping_id  ) 

Create an info string for a role group mapping.

public

Parameters:
int mapping_id

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

        {
                $role = $this->mappings[$a_mapping_id]['role_name'];
                $dn_parts = explode(',',$this->mappings[$a_mapping_id]['dn']);
                
                return (array_key_exists(0,$dn_parts) ? $dn_parts[0] : "''");
        }

ilLDAPRoleGroupMappingSettings::getMappings (  ) 

Get already configured mappings.

public

Definition at line 135 of file class.ilLDAPRoleGroupMappingSettings.php.

        {
                return $this->mappings ? $this->mappings : array();
        }

ilLDAPRoleGroupMappingSettings::getServerId (  ) 

Definition at line 124 of file class.ilLDAPRoleGroupMappingSettings.php.

Referenced by delete(), read(), and save().

        {
                return $this->server_id;
        }

Here is the caller graph for this function:

ilLDAPRoleGroupMappingSettings::loadFromPost ( a_mappings  ) 

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

References $data, and ilUtil::stripSlashes().

        {
                global $rbacreview;
                
                $this->mappings = array();
                foreach($a_mappings as $mapping_id => $data)
                {
                        if($mapping_id == 0)
                        {
                                if(!$data['dn'] and !$data['member'] and !$data['memberisdn'] and !$data['role'])
                                {
                                        continue;
                                }
                        }
                        $this->mappings[$mapping_id]['dn'] = ilUtil::stripSlashes($data['dn']);
                        $this->mappings[$mapping_id]['url'] = ilUtil::stripSlashes($data['url']);
                        $this->mappings[$mapping_id]['member_attribute'] = ilUtil::stripSlashes($data['member']);
                        $this->mappings[$mapping_id]['member_isdn'] = ilUtil::stripSlashes($data['memberisdn']);
                        $this->mappings[$mapping_id]['role_name'] = ilUtil::stripSlashes($data['role']);
                        $this->mappings[$mapping_id]['role'] = $rbacreview->roleExists(ilUtil::stripSlashes($data['role']));
                        $this->mappings[$mapping_id]['info'] = ilUtil::stripSlashes($data['info']);
                        $this->mappings[$mapping_id]['info_type'] = ilUtil::stripSlashes($data['info_type']);
                }
        }

Here is the call graph for this function:

ilLDAPRoleGroupMappingSettings::read (  )  [private]

Read mappings.

private

Definition at line 284 of file class.ilLDAPRoleGroupMappingSettings.php.

References $res, and getServerId().

Referenced by __construct(), delete(), and save().

        {
                global $ilObjDataCache,$rbacreview,$tree;
                
                $this->mappings = array();
                $query = "SELECT * FROM ldap_role_group_mapping LEFT JOIN object_data ".
                        "ON role = obj_id ".
                        "WHERE server_id =".$this->db->quote($this->getServerId()).' '.
                        "ORDER BY title,dn";
                        
                $res = $this->db->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $this->mappings[$row->mapping_id]['dn']                                         = $row->dn;
                        $this->mappings[$row->mapping_id]['url']                                        = $row->url;
                        $this->mappings[$row->mapping_id]['member_attribute']           = $row->member_attribute;
                        $this->mappings[$row->mapping_id]['member_isdn']                        = $row->member_isdn;
                        $this->mappings[$row->mapping_id]['role']                                       = $row->role;
                        $this->mappings[$row->mapping_id]['info']                                       = $row->mapping_info;
                        $this->mappings[$row->mapping_id]['info_type']                          = $row->mapping_info_type;
                        if($ilObjDataCache->lookupType($row->role) == 'role')
                        {
                                $this->mappings[$row->mapping_id]['role_name']                  = $ilObjDataCache->lookupTitle($row->role);
                        }
                        else
                        {
                                $this->mappings[$row->mapping_id]['role_name']                  = $row->role;
                        }
                
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilLDAPRoleGroupMappingSettings::save (  ) 

Save mappings.

public

Parameters:
 

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

References $data, getServerId(), and read().

        {
                foreach($this->mappings as $mapping_id => $data)
                {
                        if(!$mapping_id)
                        {
                                $query = "INSERT INTO ldap_role_group_mapping ".
                                        "SET server_id = ".$this->db->quote($this->getServerId()).", ".
                                        "url = ".$this->db->quote($data['url']).", ".
                                        "dn = ".$this->db->quote($data['dn']).", ".
                                        "member_attribute = ".$this->db->quote($data['member_attribute']).", ".
                                        "member_isdn = ".$this->db->quote($data['member_isdn']).", ".
                                        "role = ".$this->db->quote($data['role']).", ".
                                        "mapping_info = ".$this->db->quote($data['info']).", ".
                                        "mapping_info_type = ".$this->db->quote($data['info_type']);
                                        
                        
                                $this->db->query($query);
                        }
                        else
                        {
                                $query = "UPDATE ldap_role_group_mapping ".
                                        "SET server_id = ".$this->db->quote($this->getServerId()).", ".
                                        "url = ".$this->db->quote($data['url']).", ".
                                        "dn =".$this->db->quote($data['dn']).", ".
                                        "member_attribute = ".$this->db->quote($data['member_attribute']).", ".
                                        "member_isdn = ".$this->db->quote($data['member_isdn']).", ".
                                        "role = ".$this->db->quote($data['role']).", ".
                                        "mapping_info = ".$this->db->quote($data['info']).", ".
                                        "mapping_info_type = ".$this->db->quote($data['info_type'])." ".
                                        "WHERE mapping_id = ".$this->db->quote($mapping_id);

                                $this->db->query($query);
                        }
                }
                $this->read();
        }

Here is the call graph for this function:

ilLDAPRoleGroupMappingSettings::validate (  ) 

Validate mappings.

public

Definition at line 173 of file class.ilLDAPRoleGroupMappingSettings.php.

References $data, and $ilErr.

        {
                global $ilErr,$rbacreview;
                
                $ilErr->setMessage('');
                $found_missing = false;
                foreach($this->mappings as $mapping_id => $data)
                {
                        // Check if all required fields are available
                        if(!strlen($data['dn']) || !strlen($data['member_attribute']) || !strlen($data['role_name']))
                        {
                                if(!$found_missing)
                                {
                                        $found_missing = true;
                                        $ilErr->appendMessage($this->lng->txt('fill_out_all_required_fields'));
                                }
                        }
                        // Check role valid
                        if(strlen($data['role_name']) and !$rbacreview->roleExists($data['role_name']))
                        {
                                $ilErr->appendMessage($this->lng->txt('ldap_role_not_exists').' '.$data['role_name']);
                        }
                }
                return strlen($ilErr->getMessage()) ? false : true;
        }


Field Documentation

ilLDAPRoleGroupMappingSettings::$db = null [private]

Definition at line 36 of file class.ilLDAPRoleGroupMappingSettings.php.

ilLDAPRoleGroupMappingSettings::$instances = array() [static, private]

Definition at line 34 of file class.ilLDAPRoleGroupMappingSettings.php.

ilLDAPRoleGroupMappingSettings::$mappings = null [private]

Definition at line 37 of file class.ilLDAPRoleGroupMappingSettings.php.

ilLDAPRoleGroupMappingSettings::$server_id = null [private]

Definition at line 35 of file class.ilLDAPRoleGroupMappingSettings.php.

Definition at line 40 of file class.ilLDAPRoleGroupMappingSettings.php.


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