ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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. More...
 
 getRulesForUpdate ()
 Get all mapping rules with option 'update'. More...
 
 getFieldsForUpdate ()
 Get field names of all mapping rules with option 'update'. More...
 
 getFields ()
 Get all mapping fields. More...
 
 getRules ()
 Get all rules. More...
 
 clearRules ()
 Clear rules => Does not perform an update. More...
 
 save ()
 Save mapping rules to db. More...
 
 delete ()
 Delete all entries. More...
 
 enabledUpdate ($a_field_name)
 Check whether an update should be performed on a specific user attribute or not. More...
 
 getValue ($a_field_name)
 Get LDAP attribute name by given ILIAS profile field. More...
 

Static Public Member Functions

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

Private Member Functions

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

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

◆ __construct()

ilLDAPAttributeMapping::__construct (   $a_server_id)
private

Private constructor (Singleton for each server_id)

@access private

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

49 {
50 global $ilDB,$lng;
51
52 $this->db = $ilDB;
53 $this->lng = $lng;
54 $this->server_id = $a_server_id;
55 $this->read();
56 }
read()
Read mapping setttings from db.
global $ilDB

References $ilDB, $lng, and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ _delete()

static ilLDAPAttributeMapping::_delete (   $a_server_id)
static

Delete mapping rules by server id.

@access public

Parameters
intserver id

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

83 {
84 global $ilDB;
85
86 $query = "DELETE FROM ldap_attribute_mapping ".
87 "WHERE server_id =".$ilDB->quote($a_server_id,'integer');
88 $res = $ilDB->manipulate($query);
89 }

References $ilDB, $query, and $res.

Referenced by delete(), and ilLDAPServer\delete().

+ Here is the caller graph for this function:

◆ _getInstanceByServerId()

static ilLDAPAttributeMapping::_getInstanceByServerId (   $a_server_id)
static

Get instance of class.

@access public

Parameters
intserver_id

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

66 {
67 if(array_key_exists($a_server_id,self::$instances) and is_object(self::$instances[$a_server_id]))
68 {
69 return self::$instances[$a_server_id];
70 }
71 return self::$instances[$a_server_id] = new ilLDAPAttributeMapping($a_server_id);
72 }
This class stores the settings that define the mapping between LDAP attribute and user profile fields...

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

+ Here is the caller graph for this function:

◆ _lookupGlobalRole()

static ilLDAPAttributeMapping::_lookupGlobalRole (   $a_server_id)
static

Lookup global role assignment.

@access public

Parameters

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

99 {
100 global $ilDB;
101
102 $query = "SELECT value FROM ldap_attribute_mapping ".
103 "WHERE server_id =".$ilDB->quote($a_server_id,'integer')." ".
104 "AND keyword = ".$ilDB->quote('global_role','text');
105
106 $res = $ilDB->query($query);
107 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
108 {
109 return (int) $row->value;
110 }
111 return 0;
112 }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11

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

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

+ Here is the caller graph for this function:

◆ clearRules()

ilLDAPAttributeMapping::clearRules ( )

Clear rules => Does not perform an update.

@access public

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

237 {
238 $this->mapping_rules = array();
239 }

◆ delete()

ilLDAPAttributeMapping::delete ( )

Delete all entries.

@access public

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

273 {
274 self::_delete($this->server_id);
275 }
static _delete($a_server_id)
Delete mapping rules by server id.

References _delete().

+ Here is the call graph for this function:

◆ enabledUpdate()

ilLDAPAttributeMapping::enabledUpdate (   $a_field_name)

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

@access public

Parameters
stringILIAS user attribute
Returns
bool

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

286 {
287 if(array_key_exists($a_field_name,$this->mapping_rules))
288 {
289 return (bool) $this->mapping_rules[$a_field_name]['performUpdate'];
290 }
291 return false;
292 }

◆ getFields()

ilLDAPAttributeMapping::getFields ( )

Get all mapping fields.

@access public

Parameters

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

196 {
197 foreach($this->mapping_rules as $field => $rule)
198 {
199 if(!strlen($rule['value']))
200 {
201 continue;
202 }
203 if(strpos($rule['value'],',') === false)
204 {
205 $fields[] = strtolower($rule['value']);
206 continue;
207 }
208 $tmp_fields = explode(',',$rule['value']);
209 $value = '';
210 foreach($tmp_fields as $tmp_field)
211 {
212 $fields[] = trim(strtolower($tmp_field));
213 }
214 }
215 return $fields ? $fields : array();
216 }

◆ getFieldsForUpdate()

ilLDAPAttributeMapping::getFieldsForUpdate ( )

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

@access public

Parameters

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

166 {
167 foreach($this->rules_for_update as $field => $rule)
168 {
169 if(!strlen($rule['value']))
170 {
171 continue;
172 }
173 if(strpos($rule['value'],',') === false)
174 {
175 $fields[] = strtolower($rule['value']);
176 continue;
177 }
178 $tmp_fields = explode(',',$rule['value']);
179 $value = '';
180 foreach($tmp_fields as $tmp_field)
181 {
182 $fields[] = trim(strtolower($tmp_field));
183 }
184 }
185 return $fields ? $fields : array();
186 }

◆ getRules()

ilLDAPAttributeMapping::getRules ( )

Get all rules.

@access public

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

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

References $mapping_rules.

◆ getRulesForUpdate()

ilLDAPAttributeMapping::getRulesForUpdate ( )

Get all mapping rules with option 'update'.

@access public

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

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

154 {
155 return $this->rules_for_update ? $this->rules_for_update : array();
156 }

◆ getValue()

ilLDAPAttributeMapping::getValue (   $a_field_name)

Get LDAP attribute name by given ILIAS profile field.

@access public

Parameters
stringILIAS user attribute
Returns
string LDAP attribute name

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

302 {
303 if(array_key_exists($a_field_name,$this->mapping_rules))
304 {
305 return $this->mapping_rules[$a_field_name]['value'];
306 }
307 return '';
308 }

◆ hasRulesForUpdate()

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.

121 {
122 global $ilDB;
123
124 $query = 'SELECT perform_update FROM ldap_attribute_mapping '.
125 'WHERE server_id = '.$ilDB->quote($a_server_id,'integer').' '.
126 'AND perform_update = 1';
127 $res = $ilDB->query($query);
128 return $res->numRows() ? true : false;
129 }

References $ilDB, $query, and $res.

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

+ Here is the caller graph for this function:

◆ read()

ilLDAPAttributeMapping::read ( )
private

Read mapping setttings from db.

@access private

Parameters

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

318 {
319 global $ilDB;
320
321 $query = "SELECT * FROM ldap_attribute_mapping ".
322 "WHERE server_id =".$this->db->quote($this->server_id,'integer')." ";
323
324 $res = $this->db->query($query);
325 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
326 {
327 $this->mapping_rules[$row->keyword]['value'] = $row->value;
328 $this->mapping_rules[$row->keyword]['performUpdate'] = (bool) $row->perform_update;
329
330 if($row->perform_update)
331 {
332 $this->rules_for_update[$row->keyword]['value'] = $row->value;
333 }
334 }
335 }

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

Referenced by __construct().

+ Here is the caller graph for this function:

◆ save()

ilLDAPAttributeMapping::save ( )

Save mapping rules to db.

@access public

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

248 {
249 global $ilDB;
250
251 $this->delete();
252
253 foreach($this->mapping_rules as $keyword => $options)
254 {
255 $query = "INSERT INTO ldap_attribute_mapping (server_id,keyword,value,perform_update) ".
256 "VALUES( ".
257 $this->db->quote($this->server_id,'integer').", ".
258 $this->db->quote($keyword,'text').", ".
259 $this->db->quote($options['value'],'text').", ".
260 $this->db->quote($options['performUpdate'],'integer').
261 ')';
262 $res = $ilDB->manipulate($query);
263 }
264 }
if(!is_array($argv)) $options

References $ilDB, $options, $query, and $res.

◆ setRule()

ilLDAPAttributeMapping::setRule (   $a_field_name,
  $a_ldap_attribute,
  $a_perform_update 
)

Set mapping rule.

@access public

Parameters
stringILIAS user attribute
stringldap attribute
boolperform update

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

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

Field Documentation

◆ $db

ilLDAPAttributeMapping::$db = null
private

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

◆ $instances

ilLDAPAttributeMapping::$instances = array()
staticprivate

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

◆ $lng

ilLDAPAttributeMapping::$lng
private

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

Referenced by __construct().

◆ $mapping_rules

ilLDAPAttributeMapping::$mapping_rules = array()
private

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

Referenced by getRules().

◆ $rules_for_update

ilLDAPAttributeMapping::$rules_for_update = array()
private

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

◆ $server_id

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: