ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilLDAPRoleGroupMappingSettings Class Reference
+ 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 smeye.nosp@m.r@da.nosp@m.tabay.nosp@m..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 $ilDB, $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.

References $ilDB, $query, and $res.

Referenced by ilObjRole\delete().

{
global $ilDB;
$query = "DELETE FROM ldap_rg_mapping ".
"WHERE role = ".$ilDB->quote($a_role_id,'integer');
$res = $ilDB->manipulate($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.

References $ilDB, $query, and $res.

{
global $ilDB;
$query = "DELETE FROM ldap_rg_mapping ".
"WHERE server_id = ".$ilDB->quote($a_server_id,'integer');
$res = $ilDB->manipulate($query);
return true;
}
static ilLDAPRoleGroupMappingSettings::_getAllActiveMappings ( )
static

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

References $data, $ilDB, $query, $res, and $row.

Referenced by ilLDAPRoleGroupMapping\initServers().

{
global $ilDB,$rbacreview;
$query = "SELECT rgm.* FROM ldap_rg_mapping rgm JOIN ldap_server_settings lss ".
"ON rgm.server_id = lss.server_id ".
"WHERE lss.active = 1 ".
"AND lss.role_sync_active = 1 ";
$res = $ilDB->query($query);
while($row = $ilDB->fetchObject($res))
{
$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
intserver_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
intmapping_id

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

References $ilDB, $query, $res, getServerId(), and read().

{
global $ilDB;
$query = "DELETE FROM ldap_rg_mapping ".
"WHERE server_id = ".$this->db->quote($this->getServerId(),'integer')." ".
"AND mapping_id = ".$this->db->quote($a_mapping_id ,'integer');
$res = $ilDB->manipulate($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
intmapping_id

Definition at line 272 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.

References $server_id.

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

{
}

+ Here is the caller graph for this function:

ilLDAPRoleGroupMappingSettings::loadFromPost (   $a_mappings)

Definition at line 140 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 287 of file class.ilLDAPRoleGroupMappingSettings.php.

References $query, $res, $row, DB_FETCHMODE_OBJECT, and getServerId().

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

{
global $ilObjDataCache,$rbacreview,$tree;
$this->mappings = array();
$query = "SELECT * FROM ldap_rg_mapping LEFT JOIN object_data ".
"ON role = obj_id ".
"WHERE server_id =".$this->db->quote($this->getServerId(),'integer').' '.
"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 204 of file class.ilLDAPRoleGroupMappingSettings.php.

References $data, $ilDB, $query, $res, getServerId(), and read().

{
global $ilDB;
foreach($this->mappings as $mapping_id => $data)
{
if(!$mapping_id)
{
$next_id = $ilDB->nextId('ldap_rg_mapping');
$query = "INSERT INTO ldap_rg_mapping (mapping_id,server_id,url,dn,member_attribute,member_isdn,role,mapping_info,mapping_info_type) ".
"VALUES ( ".
$ilDB->quote($next_id,'integer').", ".
$this->db->quote($this->getServerId(),'integer').", ".
$this->db->quote($data['url'],'text').", ".
$this->db->quote($data['dn'],'text').", ".
$this->db->quote($data['member_attribute'],'text').", ".
$this->db->quote($data['member_isdn'],'integer').", ".
$this->db->quote($data['role'],'integer').", ".
$this->db->quote($data['info'],'text').", ".
$this->db->quote($data['info_type'],'integer').
")";
$res = $ilDB->manipulate($query);
}
else
{
$query = "UPDATE ldap_rg_mapping ".
"SET server_id = ".$this->db->quote($this->getServerId(),'integer').", ".
"url = ".$this->db->quote($data['url'],'text').", ".
"dn =".$this->db->quote($data['dn'],'text').", ".
"member_attribute = ".$this->db->quote($data['member_attribute'],'text').", ".
"member_isdn = ".$this->db->quote($data['member_isdn'],'integer').", ".
"role = ".$this->db->quote($data['role'],'integer').", ".
"mapping_info = ".$this->db->quote($data['info'],'text').", ".
"mapping_info_type = ".$this->db->quote($data['info_type'],'integer')." ".
"WHERE mapping_id = ".$this->db->quote($mapping_id,'integer');
$res = $ilDB->manipulate($query);
}
}
$this->read();
}

+ Here is the call graph for this function:

ilLDAPRoleGroupMappingSettings::validate ( )

Validate mappings.

public

Definition at line 171 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()
staticprivate

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.

Referenced by getServerId().

const ilLDAPRoleGroupMappingSettings::MAPPING_INFO_ALL = 1
const ilLDAPRoleGroupMappingSettings::MAPPING_INFO_INFO_ONLY = 0

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


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