ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilLDAPAttributeMapping Class Reference

This class stores the settings that define the mapping between LDAP attribute and user profile fields. More...

+ Collaboration diagram for ilLDAPAttributeMapping:

Public Member Functions

 setRule ($a_field_name, $a_ldap_attribute, $a_perform_update)
 Set mapping rule.
 getRulesForUpdate ()
 Get all mapping rules with option 'update'.
 getFieldsForUpdate ()
 Get field names of all mapping rules with option 'update'.
 getFields ()
 Get all mapping fields.
 getRules ()
 Get all rules.
 clearRules ()
 Clear rules => Does not perform an update.
 save ()
 Save mapping rules to db.
 delete ()
 Delete all entries.
 enabledUpdate ($a_field_name)
 Check whether an update should be performed on a specific user attribute or not.
 getValue ($a_field_name)
 Get LDAP attribute name by given ILIAS profile field.

Static Public Member Functions

static _getInstanceByServerId ($a_server_id)
 Get instance of class.
static _delete ($a_server_id)
 Delete mapping rules by server id.
static _lookupGlobalRole ($a_server_id)
 Lookup global role assignment.
static hasRulesForUpdate ($a_server_id)
 Check if there is ldap attribute -> user data mapping which which is updated on login.

Private Member Functions

 __construct ($a_server_id)
 Private constructor (Singleton for each server_id)
 read ()
 Read mapping setttings from db.

Private Attributes

 $server_id = null
 $db = null
 $mapping_rules = array()
 $rules_for_update = array()
 $lng

Static Private Attributes

static $instances = array()

Detailed Description

This class stores the settings that define the mapping between LDAP attribute and user profile fields.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 33 of file class.ilLDAPAttributeMapping.php.

Constructor & Destructor Documentation

ilLDAPAttributeMapping::__construct (   $a_server_id)
private

Private constructor (Singleton for each server_id)

private

Definition at line 48 of file class.ilLDAPAttributeMapping.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 ilLDAPAttributeMapping::_delete (   $a_server_id)
static

Delete mapping rules by server id.

public

Parameters
intserver id

Definition at line 82 of file class.ilLDAPAttributeMapping.php.

References $ilDB, $query, and $res.

Referenced by delete().

{
global $ilDB;
$query = "DELETE FROM ldap_attribute_mapping ".
"WHERE server_id =".$ilDB->quote($a_server_id,'integer');
$res = $ilDB->manipulate($query);
}

+ Here is the caller graph for this function:

static ilLDAPAttributeMapping::_getInstanceByServerId (   $a_server_id)
static

Get instance of class.

public

Parameters
intserver_id

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

Referenced by ilLDAPQuery\__construct(), ilLDAPServer\getPearAtributeArray(), ilLDAPSettingsGUI\initAttributeMapping(), and ilLDAPAttributeToUser\initLDAPAttributeMapping().

{
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 ilLDAPAttributeMapping($a_server_id);
}

+ Here is the caller graph for this function:

static ilLDAPAttributeMapping::_lookupGlobalRole (   $a_server_id)
static

Lookup global role assignment.

public

Parameters

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

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

Referenced by ilLDAPRoleAssignmentRules\getDefaultRole(), ilLDAPSettingsGUI\prepareRoleSelect(), and ilLDAPSettingsGUI\setServerFormValues().

{
global $ilDB;
$query = "SELECT value FROM ldap_attribute_mapping ".
"WHERE server_id =".$ilDB->quote($a_server_id,'integer')." ".
"AND keyword = ".$ilDB->quote('global_role','text');
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
return (int) $row->value;
}
return 0;
}

+ Here is the caller graph for this function:

ilLDAPAttributeMapping::clearRules ( )

Clear rules => Does not perform an update.

public

Definition at line 236 of file class.ilLDAPAttributeMapping.php.

{
$this->mapping_rules = array();
}
ilLDAPAttributeMapping::delete ( )

Delete all entries.

public

Definition at line 272 of file class.ilLDAPAttributeMapping.php.

References _delete().

{
self::_delete($this->server_id);
}

+ Here is the call graph for this function:

ilLDAPAttributeMapping::enabledUpdate (   $a_field_name)

Check whether an update should be performed on a specific user attribute or not.

public

Parameters
stringILIAS user attribute
Returns
bool

Definition at line 285 of file class.ilLDAPAttributeMapping.php.

{
if(array_key_exists($a_field_name,$this->mapping_rules))
{
return (bool) $this->mapping_rules[$a_field_name]['performUpdate'];
}
return false;
}
ilLDAPAttributeMapping::getFields ( )

Get all mapping fields.

public

Parameters

Definition at line 195 of file class.ilLDAPAttributeMapping.php.

{
foreach($this->mapping_rules as $field => $rule)
{
if(!strlen($rule['value']))
{
continue;
}
if(strpos($rule['value'],',') === false)
{
$fields[] = strtolower($rule['value']);
continue;
}
$tmp_fields = explode(',',$rule['value']);
$value = '';
foreach($tmp_fields as $tmp_field)
{
$fields[] = trim(strtolower($tmp_field));
}
}
return $fields ? $fields : array();
}
ilLDAPAttributeMapping::getFieldsForUpdate ( )

Get field names of all mapping rules with option 'update'.

public

Parameters

Definition at line 165 of file class.ilLDAPAttributeMapping.php.

{
foreach($this->rules_for_update as $field => $rule)
{
if(!strlen($rule['value']))
{
continue;
}
if(strpos($rule['value'],',') === false)
{
$fields[] = strtolower($rule['value']);
continue;
}
$tmp_fields = explode(',',$rule['value']);
$value = '';
foreach($tmp_fields as $tmp_field)
{
$fields[] = trim(strtolower($tmp_field));
}
}
return $fields ? $fields : array();
}
ilLDAPAttributeMapping::getRules ( )

Get all rules.

public

Returns
array mapping rules. E.g. array('firstname' => 'name',...)

Definition at line 225 of file class.ilLDAPAttributeMapping.php.

References $mapping_rules.

{
}
ilLDAPAttributeMapping::getRulesForUpdate ( )

Get all mapping rules with option 'update'.

public

Returns
array mapping rules. E.g. array('firstname' => 'name',...)

Definition at line 153 of file class.ilLDAPAttributeMapping.php.

{
return $this->rules_for_update ? $this->rules_for_update : array();
}
ilLDAPAttributeMapping::getValue (   $a_field_name)

Get LDAP attribute name by given ILIAS profile field.

public

Parameters
stringILIAS user attribute
Returns
string LDAP attribute name

Definition at line 301 of file class.ilLDAPAttributeMapping.php.

{
if(array_key_exists($a_field_name,$this->mapping_rules))
{
return $this->mapping_rules[$a_field_name]['value'];
}
return '';
}
static ilLDAPAttributeMapping::hasRulesForUpdate (   $a_server_id)
static

Check if there is ldap attribute -> user data mapping which which is updated on login.

Returns
Parameters
int$a_server_id

Definition at line 120 of file class.ilLDAPAttributeMapping.php.

References $ilDB, $query, and $res.

Referenced by ilAuthContainerApache\updateRequired(), and ilAuthContainerLDAP\updateRequired().

{
global $ilDB;
$query = 'SELECT perform_update FROM ldap_attribute_mapping '.
'WHERE server_id = '.$ilDB->quote($a_server_id,'integer').' '.
'AND perform_update = 1';
$res = $ilDB->query($query);
return $res->numRows() ? true : false;
}

+ Here is the caller graph for this function:

ilLDAPAttributeMapping::read ( )
private

Read mapping setttings from db.

private

Parameters

Definition at line 317 of file class.ilLDAPAttributeMapping.php.

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

Referenced by __construct().

{
global $ilDB;
$query = "SELECT * FROM ldap_attribute_mapping ".
"WHERE server_id =".$this->db->quote($this->server_id,'integer')." ";
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->mapping_rules[$row->keyword]['value'] = $row->value;
$this->mapping_rules[$row->keyword]['performUpdate'] = (bool) $row->perform_update;
if($row->perform_update)
{
$this->rules_for_update[$row->keyword]['value'] = $row->value;
}
}
}

+ Here is the caller graph for this function:

ilLDAPAttributeMapping::save ( )

Save mapping rules to db.

public

Definition at line 247 of file class.ilLDAPAttributeMapping.php.

References $ilDB, $query, and $res.

{
global $ilDB;
$this->delete();
foreach($this->mapping_rules as $keyword => $options)
{
$query = "INSERT INTO ldap_attribute_mapping (server_id,keyword,value,perform_update) ".
"VALUES( ".
$this->db->quote($this->server_id,'integer').", ".
$this->db->quote($keyword,'text').", ".
$this->db->quote($options['value'],'text').", ".
$this->db->quote($options['performUpdate'],'integer').
')';
$res = $ilDB->manipulate($query);
}
}
ilLDAPAttributeMapping::setRule (   $a_field_name,
  $a_ldap_attribute,
  $a_perform_update 
)

Set mapping rule.

public

Parameters
stringILIAS user attribute
stringldap attribute
boolperform update

Definition at line 140 of file class.ilLDAPAttributeMapping.php.

{
$this->mapping_rules[$a_field_name]['value'] = $a_ldap_attribute;
$this->mapping_rules[$a_field_name]['performUpdate'] = $a_perform_update;
}

Field Documentation

ilLDAPAttributeMapping::$db = null
private

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

ilLDAPAttributeMapping::$instances = array()
staticprivate

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

ilLDAPAttributeMapping::$lng
private

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

Referenced by __construct().

ilLDAPAttributeMapping::$mapping_rules = array()
private

Definition at line 38 of file class.ilLDAPAttributeMapping.php.

Referenced by getRules().

ilLDAPAttributeMapping::$rules_for_update = array()
private

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

ilLDAPAttributeMapping::$server_id = null
private

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


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