ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 81 of file class.ilLDAPAttributeMapping.php.

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

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 return self::$instances[$a_server_id];
69 }
70 return self::$instances[$a_server_id] = new ilLDAPAttributeMapping($a_server_id);
71 }
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 97 of file class.ilLDAPAttributeMapping.php.

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

References $ilDB, $query, $res, $row, and ilDBConstants\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 226 of file class.ilLDAPAttributeMapping.php.

227 {
228 $this->mapping_rules = array();
229 }

◆ delete()

ilLDAPAttributeMapping::delete ( )

Delete all entries.

@access public

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

262 {
263 self::_delete($this->server_id);
264 }
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 274 of file class.ilLDAPAttributeMapping.php.

275 {
276 if (array_key_exists($a_field_name, $this->mapping_rules)) {
277 return (bool) $this->mapping_rules[$a_field_name]['performUpdate'];
278 }
279 return false;
280 }

◆ getFields()

ilLDAPAttributeMapping::getFields ( )

Get all mapping fields.

@access public

Parameters

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

190 {
191 foreach ($this->mapping_rules as $field => $rule) {
192 if (!strlen($rule['value'])) {
193 continue;
194 }
195 if (strpos($rule['value'], ',') === false) {
196 $fields[] = strtolower($rule['value']);
197 continue;
198 }
199 $tmp_fields = explode(',', $rule['value']);
200 $value = '';
201 foreach ($tmp_fields as $tmp_field) {
202 $fields[] = trim(strtolower($tmp_field));
203 }
204 }
205 return $fields ? $fields : array();
206 }
$rule
Definition: showstats.php:43

References $rule.

◆ getFieldsForUpdate()

ilLDAPAttributeMapping::getFieldsForUpdate ( )

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

@access public

Parameters

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

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

References $rule.

◆ getRules()

ilLDAPAttributeMapping::getRules ( )

Get all rules.

@access public

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

Definition at line 215 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 151 of file class.ilLDAPAttributeMapping.php.

152 {
153 return $this->rules_for_update ? $this->rules_for_update : array();
154 }

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

290 {
291 if (array_key_exists($a_field_name, $this->mapping_rules)) {
292 return $this->mapping_rules[$a_field_name]['value'];
293 }
294 return '';
295 }

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

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

References $ilDB, $query, and $res.

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

+ Here is the caller graph for this function:

◆ read()

ilLDAPAttributeMapping::read ( )
private

Read mapping setttings from db.

@access private

Parameters

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

305 {
306 global $ilDB;
307
308 $query = "SELECT * FROM ldap_attribute_mapping " .
309 "WHERE server_id =" . $this->db->quote($this->server_id, 'integer') . " ";
310
311 $res = $this->db->query($query);
312 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
313 $this->mapping_rules[$row->keyword]['value'] = $row->value;
314 $this->mapping_rules[$row->keyword]['performUpdate'] = (bool) $row->perform_update;
315
316 if ($row->perform_update) {
317 $this->rules_for_update[$row->keyword]['value'] = $row->value;
318 }
319 }
320 }
PHPExcel root directory.
Definition: PHPExcel.php:30

References $ilDB, $query, $res, $row, and ilDBConstants\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 237 of file class.ilLDAPAttributeMapping.php.

238 {
239 global $ilDB;
240
241 $this->delete();
242
243 foreach ($this->mapping_rules as $keyword => $options) {
244 $query = "INSERT INTO ldap_attribute_mapping (server_id,keyword,value,perform_update) " .
245 "VALUES( " .
246 $this->db->quote($this->server_id, 'integer') . ", " .
247 $this->db->quote($keyword, 'text') . ", " .
248 $this->db->quote($options['value'], 'text') . ", " .
249 $this->db->quote($options['performUpdate'], 'integer') .
250 ')';
251 $res = $ilDB->manipulate($query);
252 }
253 }
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20

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

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

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: