ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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)

private

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

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

49  {
50  global $DIC;
51 
52  $ilDB = $DIC['ilDB'];
53  $lng = $DIC['lng'];
54 
55  $this->db = $ilDB;
56  $this->lng = $lng;
57  $this->server_id = $a_server_id;
58  $this->read();
59  }
global $DIC
Definition: saml.php:7
read()
Read mapping setttings from db.
global $ilDB
+ 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.

public

Parameters
intserver id

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

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

Referenced by ilLDAPServer\delete().

85  {
86  global $DIC;
87 
88  $ilDB = $DIC['ilDB'];
89 
90  $query = "DELETE FROM ldap_attribute_mapping " .
91  "WHERE server_id =" . $ilDB->quote($a_server_id, 'integer');
92  $res = $ilDB->manipulate($query);
93  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ _getInstanceByServerId()

static ilLDAPAttributeMapping::_getInstanceByServerId (   $a_server_id)
static

Get instance of class.

public

Parameters
intserver_id

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

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

69  {
70  if (array_key_exists($a_server_id, self::$instances) and is_object(self::$instances[$a_server_id])) {
71  return self::$instances[$a_server_id];
72  }
73  return self::$instances[$a_server_id] = new ilLDAPAttributeMapping($a_server_id);
74  }
This class stores the settings that define the mapping between LDAP attribute and user profile fields...
+ Here is the caller graph for this function:

◆ _lookupGlobalRole()

static ilLDAPAttributeMapping::_lookupGlobalRole (   $a_server_id)
static

Lookup global role assignment.

public

Parameters

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

References $DIC, $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

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

103  {
104  global $DIC;
105 
106  $ilDB = $DIC['ilDB'];
107 
108  $query = "SELECT value FROM ldap_attribute_mapping " .
109  "WHERE server_id =" . $ilDB->quote($a_server_id, 'integer') . " " .
110  "AND keyword = " . $ilDB->quote('global_role', 'text');
111 
112  $res = $ilDB->query($query);
113  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
114  return (int) $row->value;
115  }
116  return 0;
117  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the caller graph for this function:

◆ clearRules()

ilLDAPAttributeMapping::clearRules ( )

Clear rules => Does not perform an update.

public

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

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

◆ delete()

ilLDAPAttributeMapping::delete ( )

Delete all entries.

public

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

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

◆ enabledUpdate()

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.

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

◆ getFields()

ilLDAPAttributeMapping::getFields ( )

Get all mapping fields.

public

Parameters

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

References $rule.

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

◆ getFieldsForUpdate()

ilLDAPAttributeMapping::getFieldsForUpdate ( )

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

public

Parameters

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

References $rule.

173  {
174  foreach ($this->rules_for_update as $field => $rule) {
175  if (!strlen($rule['value'])) {
176  continue;
177  }
178  if (strpos($rule['value'], ',') === false) {
179  $fields[] = strtolower($rule['value']);
180  continue;
181  }
182  $tmp_fields = explode(',', $rule['value']);
183  $value = '';
184  foreach ($tmp_fields as $tmp_field) {
185  $fields[] = trim(strtolower($tmp_field));
186  }
187  }
188  return $fields ? $fields : array();
189  }
$rule
Definition: showstats.php:43

◆ getRules()

ilLDAPAttributeMapping::getRules ( )

Get all rules.

public

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

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

References $mapping_rules.

◆ getRulesForUpdate()

ilLDAPAttributeMapping::getRulesForUpdate ( )

Get all mapping rules with option 'update'.

public

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

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

161  {
162  return $this->rules_for_update ? $this->rules_for_update : array();
163  }

◆ getValue()

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 300 of file class.ilLDAPAttributeMapping.php.

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

◆ 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 125 of file class.ilLDAPAttributeMapping.php.

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

Referenced by ilLDAPUserSynchronisation\isUpdateRequired().

126  {
127  global $DIC;
128 
129  $ilDB = $DIC['ilDB'];
130 
131  $query = 'SELECT perform_update FROM ldap_attribute_mapping ' .
132  'WHERE server_id = ' . $ilDB->quote($a_server_id, 'integer') . ' ' .
133  'AND perform_update = 1';
134  $res = $ilDB->query($query);
135  return $res->numRows() ? true : false;
136  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ read()

ilLDAPAttributeMapping::read ( )
private

Read mapping setttings from db.

private

Parameters

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

References $DIC, $ilDB, $query, $res, $row, ilDBConstants\FETCHMODE_OBJECT, and if.

Referenced by __construct().

316  {
317  global $DIC;
318 
319  $ilDB = $DIC['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(ilDBConstants::FETCHMODE_OBJECT)) {
326  $this->mapping_rules[$row->keyword]['value'] = $row->value;
327  $this->mapping_rules[$row->keyword]['performUpdate'] = (bool) $row->perform_update;
328 
329  if ($row->perform_update) {
330  $this->rules_for_update[$row->keyword]['value'] = $row->value;
331  }
332  }
333  }
global $DIC
Definition: saml.php:7
if(!file_exists(getcwd() . '/ilias.ini.php'))
registration confirmation script for ilias
Definition: confirmReg.php:12
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the caller graph for this function:

◆ save()

ilLDAPAttributeMapping::save ( )

Save mapping rules to db.

public

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

References $DIC, $ilDB, PHPMailer\PHPMailer\$options, $query, and $res.

247  {
248  global $DIC;
249 
250  $ilDB = $DIC['ilDB'];
251 
252  $this->delete();
253 
254  foreach ($this->mapping_rules as $keyword => $options) {
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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB

◆ setRule()

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 147 of file class.ilLDAPAttributeMapping.php.

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

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: