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];
78 $query =
"DELETE FROM ldap_rg_mapping ".
79 "WHERE role = ".$ilDB->quote($a_role_id,
'integer');
89 $query =
"DELETE FROM ldap_rg_mapping ".
90 "WHERE server_id = ".$ilDB->quote($a_server_id,
'integer');
98 global
$ilDB,$rbacreview;
100 $query =
"SELECT rgm.* FROM ldap_rg_mapping rgm JOIN ldap_server_settings lss ".
101 "ON rgm.server_id = lss.server_id ".
102 "WHERE lss.active = 1 ".
103 "AND lss.role_sync_active = 1 ";
105 while(
$row = $ilDB->fetchObject(
$res))
107 $data[
'server_id'] =
$row->server_id;
108 $data[
'url'] =
$row->url;
109 $data[
'mapping_id'] =
$row->mapping_id;
110 $data[
'dn'] =
$row->dn;
111 $data[
'member'] =
$row->member_attribute;
112 $data[
'isdn'] =
$row->member_isdn;
113 $data[
'info'] =
$row->mapping_info;
114 $data[
'info_type'] =
$row->mapping_info_type;
116 $data[
'object_id'] = $rbacreview->getObjectOfRole(
$row->role);
119 $active[
$row->role][] = $data;
121 return $active ? $active : array();
137 return $this->mappings ? $this->mappings : array();
149 $this->mappings = array();
150 foreach($a_mappings as $mapping_id => $data)
154 if(!$data[
'dn'] and !$data[
'member'] and !$data[
'memberisdn'] and !$data[
'role'])
164 $this->mappings[$mapping_id][
'role'] = $rbacreview->roleExists(
ilUtil::stripSlashes($data[
'role']));
178 global
$ilErr,$rbacreview;
180 $ilErr->setMessage(
'');
181 $found_missing =
false;
182 foreach($this->mappings as $mapping_id => $data)
185 if(!strlen($data[
'dn']) || !strlen($data[
'member_attribute']) || !strlen($data[
'role_name']))
189 $found_missing =
true;
190 $ilErr->appendMessage($this->lng->txt(
'fill_out_all_required_fields'));
194 if(strlen($data[
'role_name']) and !$rbacreview->roleExists($data[
'role_name']))
196 $ilErr->appendMessage($this->lng->txt(
'ldap_role_not_exists').
' '.$data[
'role_name']);
199 return strlen($ilErr->getMessage()) ?
false :
true;
213 foreach($this->mappings as $mapping_id => $data)
217 $next_id = $ilDB->nextId(
'ldap_rg_mapping');
218 $query =
"INSERT INTO ldap_rg_mapping (mapping_id,server_id,url,dn,member_attribute,member_isdn,role,mapping_info,mapping_info_type) ".
220 $ilDB->quote($next_id,
'integer').
", ".
221 $this->db->quote($this->
getServerId(),
'integer').
", ".
222 $this->db->quote($data[
'url'],
'text').
", ".
223 $this->db->quote($data[
'dn'],
'text').
", ".
224 $this->db->quote($data[
'member_attribute'],
'text').
", ".
225 $this->db->quote($data[
'member_isdn'],
'integer').
", ".
226 $this->db->quote($data[
'role'],
'integer').
", ".
227 $this->db->quote($data[
'info'],
'text').
", ".
228 $this->db->quote($data[
'info_type'],
'integer').
234 $query =
"UPDATE ldap_rg_mapping ".
235 "SET server_id = ".$this->db->quote($this->
getServerId(),
'integer').
", ".
236 "url = ".$this->db->quote($data[
'url'],
'text').
", ".
237 "dn =".$this->db->quote($data[
'dn'],
'text').
", ".
238 "member_attribute = ".$this->db->quote($data[
'member_attribute'],
'text').
", ".
239 "member_isdn = ".$this->db->quote($data[
'member_isdn'],
'integer').
", ".
240 "role = ".$this->db->quote($data[
'role'],
'integer').
", ".
241 "mapping_info = ".$this->db->quote($data[
'info'],
'text').
", ".
242 "mapping_info_type = ".$this->db->quote($data[
'info_type'],
'integer').
" ".
243 "WHERE mapping_id = ".$this->db->quote($mapping_id,
'integer');
259 public function delete($a_mapping_id)
263 $query =
"DELETE FROM ldap_rg_mapping ".
264 "WHERE server_id = ".$this->db->quote($this->
getServerId(),
'integer').
" ".
265 "AND mapping_id = ".$this->db->quote($a_mapping_id ,
'integer');
279 $role = $this->mappings[$a_mapping_id][
'role_name'];
280 $dn_parts = explode(
',',$this->mappings[$a_mapping_id][
'dn']);
282 return (array_key_exists(0,$dn_parts) ? $dn_parts[0] :
"''");
294 global $ilObjDataCache,$rbacreview,$tree;
296 $this->mappings = array();
297 $query =
"SELECT * FROM ldap_rg_mapping LEFT JOIN object_data ".
299 "WHERE server_id =".$this->db->quote($this->
getServerId(),
'integer').
' '.
305 $this->mappings[
$row->mapping_id][
'mapping_id'] =
$row->mapping_id;
306 $this->mappings[
$row->mapping_id][
'dn'] =
$row->dn;
307 $this->mappings[
$row->mapping_id][
'url'] =
$row->url;
308 $this->mappings[
$row->mapping_id][
'member_attribute'] =
$row->member_attribute;
309 $this->mappings[
$row->mapping_id][
'member_isdn'] =
$row->member_isdn;
310 $this->mappings[
$row->mapping_id][
'role'] =
$row->role;
311 $this->mappings[
$row->mapping_id][
'info'] =
$row->mapping_info;
312 $this->mappings[
$row->mapping_id][
'info_type'] =
$row->mapping_info_type;
313 if($ilObjDataCache->lookupType(
$row->role) ==
'role')
315 $this->mappings[
$row->mapping_id][
'role_name'] = $ilObjDataCache->lookupTitle(
$row->role);
319 $this->mappings[
$row->mapping_id][
'role_name'] =
$row->role;