19 declare(strict_types=1);
    39         $this->db = $DIC->database();
    41         $this->server_id = $a_server_id;
    47         if (array_key_exists($a_server_id, self::$instances) && is_object(self::$instances[$a_server_id])) {
    48             return self::$instances[$a_server_id];
    54     public static function _delete(
int $a_server_id): void
    60         $query = 
"DELETE FROM ldap_attribute_mapping " .
    61             "WHERE server_id =" . 
$ilDB->quote($a_server_id, 
'integer');
    62         $ilDB->manipulate($query);
    71         $query = 
"SELECT value FROM ldap_attribute_mapping " .
    72             "WHERE server_id =" . 
$ilDB->quote($a_server_id, 
'integer') . 
" " .
    73             "AND keyword = " . 
$ilDB->quote(
'global_role', 
'text');
    77             return (
int) $row->value;
    93         $query = 
'SELECT perform_update FROM ldap_attribute_mapping ' .
    94             'WHERE server_id = ' . 
$ilDB->quote($a_server_id, 
'integer') . 
' ' .
    95             'AND perform_update = 1';
    97         return $res->numRows() > 0;
   100     public function setRule(
string $a_field_name, 
string $a_ldap_attribute, 
bool $a_perform_update): void
   102         $this->mapping_rules[$a_field_name][
'value'] = $a_ldap_attribute;
   103         $this->mapping_rules[$a_field_name][
'performUpdate'] = $a_perform_update;
   121         return self::getMappedFields($this->rules_for_update);
   129         return self::getMappedFields($this->mapping_rules);
   135         foreach ($rules as $rule) {
   136             if (!$rule[
'value']) {
   139             if (strpos($rule[
'value'], 
',') === 
false) {
   140                 $fields[] = strtolower($rule[
'value']);
   143             $tmp_fields = explode(
',', $rule[
'value']);
   144             foreach ($tmp_fields as $tmp_field) {
   145                 $fields[] = strtolower(trim($tmp_field));
   156     public function getRules(
bool $onlyApplicable = 
false): array
   158         if (!$onlyApplicable) {
   161         return array_filter($this->mapping_rules, 
static function (array $rule): 
bool {
   162             return $rule[
'value'] !== 
'';
   171         $this->mapping_rules = array();
   181         foreach ($this->mapping_rules as $keyword => $options) {
   182             $query = 
"INSERT INTO ldap_attribute_mapping (server_id,keyword,value,perform_update) " .
   184                 $this->db->quote($this->server_id, 
'integer') . 
", " .
   185                 $this->db->quote($keyword, 
'text') . 
", " .
   186                 $this->db->quote($options[
'value'], 
'text') . 
", " .
   187                 $this->db->quote($options[
'performUpdate'], 
'integer') .
   189             $this->db->manipulate($query);
   196     public function delete(): 
void   198         self::_delete($this->server_id);
   208         if (array_key_exists($a_field_name, $this->mapping_rules)) {
   209             return (
bool) $this->mapping_rules[$a_field_name][
'performUpdate'];
   221     public function getValue(
string $a_field_name): string
   223         if (array_key_exists($a_field_name, $this->mapping_rules)) {
   224             return $this->mapping_rules[$a_field_name][
'value'];
   235         $query = 
"SELECT * FROM ldap_attribute_mapping " .
   236             "WHERE server_id =" . $this->db->quote($this->server_id, 
'integer');
   238         $res = $this->db->query($query);
   240             if (!is_null($row->value)) {
   241                 $this->mapping_rules[$row->keyword][
'value'] = $row->value;
   242                 $this->mapping_rules[$row->keyword][
'performUpdate'] = (bool) $row->perform_update;
   244                 if ($row->perform_update) {
   245                     $this->rules_for_update[$row->keyword][
'value'] = $row->value;
 
clearRules()
Clear rules => Does not perform an update. 
 
getFieldsForUpdate()
Get field names of all mapping rules with option 'update'. 
 
if(!file_exists('../ilias.ini.php'))
 
getFields()
Get all mapping fields. 
 
getRulesForUpdate()
Get all mapping rules with option 'update'. 
 
getValue(string $a_field_name)
Get LDAP attribute name by given ILIAS profile field. 
 
static getMappedFields(array $rules)
 
__construct(int $a_server_id)
 
getRules(bool $onlyApplicable=false)
Get all rules. 
 
static _lookupGlobalRole(int $a_server_id)
 
This class stores the settings that define the mapping between LDAP attribute and user profile fields...
 
read()
Read mapping settings from db. 
 
enabledUpdate(string $a_field_name)
Check whether an update should be performed on a specific user attribute or not. 
 
setRule(string $a_field_name, string $a_ldap_attribute, bool $a_perform_update)
 
static _delete(int $a_server_id)
 
save()
Save mapping rules to db. 
 
static _getInstanceByServerId(int $a_server_id)
 
static hasRulesForUpdate(int $a_server_id)
Check if there is ldap attribute -> user data mapping which which is updated on login.