54 $this->server_id = $a_server_id;
67 if(array_key_exists($a_server_id,self::$instances)
and is_object(self::$instances[$a_server_id]))
69 return self::$instances[$a_server_id];
82 public static function _delete($a_server_id)
86 $query =
"DELETE FROM ldap_attribute_mapping ".
87 "WHERE server_id =".$ilDB->quote($a_server_id,
'integer');
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');
109 return (
int)
$row->value;
124 $query =
'SELECT perform_update FROM ldap_attribute_mapping '.
125 'WHERE server_id = '.$ilDB->quote($a_server_id,
'integer').
' '.
126 'AND perform_update = 1';
128 return $res->numRows() ? true :
false;
140 public function setRule($a_field_name,$a_ldap_attribute,$a_perform_update)
142 $this->mapping_rules[$a_field_name][
'value'] = $a_ldap_attribute;
143 $this->mapping_rules[$a_field_name][
'performUpdate'] = $a_perform_update;
155 return $this->rules_for_update ? $this->rules_for_update :
array();
167 foreach($this->rules_for_update as $field => $rule)
169 if(!strlen($rule[
'value']))
173 if(strpos($rule[
'value'],
',') ===
false)
175 $fields[] = strtolower($rule[
'value']);
178 $tmp_fields = explode(
',',$rule[
'value']);
180 foreach($tmp_fields as $tmp_field)
182 $fields[] = trim(strtolower($tmp_field));
185 return $fields ? $fields :
array();
197 foreach($this->mapping_rules as $field => $rule)
199 if(!strlen($rule[
'value']))
203 if(strpos($rule[
'value'],
',') ===
false)
205 $fields[] = strtolower($rule[
'value']);
208 $tmp_fields = explode(
',',$rule[
'value']);
210 foreach($tmp_fields as $tmp_field)
212 $fields[] = trim(strtolower($tmp_field));
215 return $fields ? $fields :
array();
238 $this->mapping_rules =
array();
253 foreach($this->mapping_rules as $keyword =>
$options)
255 $query =
"INSERT INTO ldap_attribute_mapping (server_id,keyword,value,perform_update) ".
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').
272 public function delete()
274 self::_delete($this->server_id);
287 if(array_key_exists($a_field_name,$this->mapping_rules))
289 return (
bool) $this->mapping_rules[$a_field_name][
'performUpdate'];
303 if(array_key_exists($a_field_name,$this->mapping_rules))
305 return $this->mapping_rules[$a_field_name][
'value'];
321 $query =
"SELECT * FROM ldap_attribute_mapping ".
322 "WHERE server_id =".$this->db->quote($this->server_id,
'integer').
" ";
327 $this->mapping_rules[
$row->keyword][
'value'] =
$row->value;
328 $this->mapping_rules[
$row->keyword][
'performUpdate'] = (bool)
$row->perform_update;
330 if(
$row->perform_update)
332 $this->rules_for_update[
$row->keyword][
'value'] =
$row->value;
clearRules()
Clear rules => Does not perform an update.
static _getInstanceByServerId($a_server_id)
Get instance of class.
setRule($a_field_name, $a_ldap_attribute, $a_perform_update)
Set mapping rule.
static hasRulesForUpdate($a_server_id)
Check if there is ldap attribute -> user data mapping which which is updated on login.
enabledUpdate($a_field_name)
Check whether an update should be performed on a specific user attribute or not.
getFieldsForUpdate()
Get field names of all mapping rules with option 'update'.
static _lookupGlobalRole($a_server_id)
Lookup global role assignment.
getFields()
Get all mapping fields.
getRulesForUpdate()
Get all mapping rules with option 'update'.
if(!is_array($argv)) $options
static _delete($a_server_id)
Delete mapping rules by server id.
Create styles array
The data for the language used.
This class stores the settings that define the mapping between LDAP attribute and user profile fields...
read()
Read mapping setttings from db.
__construct($a_server_id)
Private constructor (Singleton for each server_id)
getValue($a_field_name)
Get LDAP attribute name by given ILIAS profile field.
save()
Save mapping rules to db.