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);
88 $res = $ilDB->query($query);
102 $query =
"SELECT value FROM ldap_attribute_mapping ".
103 "WHERE server_id =".$ilDB->quote($a_server_id).
" ".
104 "AND keyword = ".$ilDB->quote(
'global_role');
106 $res = $ilDB->query($query);
109 return (
int) $row->value;
124 $query =
'SELECT perform_update FROM ldap_attribute_mapping '.
125 'WHERE server_id = '.$ilDB->quote($a_server_id).
' '.
126 'AND perform_update = 1';
127 $res = $ilDB->query($query);
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();
251 foreach($this->mapping_rules as $keyword => $options)
253 $query =
"INSERT INTO ldap_attribute_mapping SET ".
254 "server_id =".$this->db->quote($this->server_id).
", ".
255 "keyword = ".$this->db->quote($keyword).
", ".
256 "value = ".$this->db->quote($options[
'value']).
", ".
257 "perform_update = ".$this->db->quote($options[
'performUpdate']);
258 $this->db->query($query);
268 public function delete()
283 if(array_key_exists($a_field_name,$this->mapping_rules))
285 return (
bool) $this->mapping_rules[$a_field_name][
'performUpdate'];
299 if(array_key_exists($a_field_name,$this->mapping_rules))
301 return $this->mapping_rules[$a_field_name][
'value'];
315 $query =
"SELECT * FROM ldap_attribute_mapping ".
316 "WHERE server_id =".$this->db->quote($this->server_id).
" ";
318 $res = $this->db->query($query);
321 $this->mapping_rules[$row->keyword][
'value'] = $row->value;
322 $this->mapping_rules[$row->keyword][
'performUpdate'] = (bool) $row->perform_update;
324 if($row->perform_update)
326 $this->rules_for_update[$row->keyword][
'value'] = $row->value;