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))
111 $data[
'member'] =
$row->member_attribute;
114 $data[
'info_type'] =
$row->mapping_info_type;
116 $data[
'object_id'] = $rbacreview->getObjectOfRole(
$row->role);
121 return $active ? $active : array();
137 return $this->mappings ? $this->mappings : array();
144 $this->mappings = array();
145 foreach($a_mappings as $mapping_id =>
$data)
173 global
$ilErr,$rbacreview;
175 $ilErr->setMessage(
'');
176 $found_missing =
false;
177 foreach($this->mappings as $mapping_id =>
$data)
180 if(!strlen(
$data[
'dn']) || !strlen(
$data[
'member_attribute']) || !strlen(
$data[
'role_name']))
184 $found_missing =
true;
185 $ilErr->appendMessage($this->lng->txt(
'fill_out_all_required_fields'));
189 if(strlen(
$data[
'role_name']) and !$rbacreview->roleExists(
$data[
'role_name']))
191 $ilErr->appendMessage($this->lng->txt(
'ldap_role_not_exists').
' '.
$data[
'role_name']);
194 return strlen($ilErr->getMessage()) ?
false :
true;
208 foreach($this->mappings as $mapping_id =>
$data)
212 $next_id = $ilDB->nextId(
'ldap_rg_mapping');
213 $query =
"INSERT INTO ldap_rg_mapping (mapping_id,server_id,url,dn,member_attribute,member_isdn,role,mapping_info,mapping_info_type) ".
215 $ilDB->quote($next_id,
'integer').
", ".
216 $this->db->quote($this->
getServerId(),
'integer').
", ".
217 $this->db->quote(
$data[
'url'],
'text').
", ".
218 $this->db->quote(
$data[
'dn'],
'text').
", ".
219 $this->db->quote(
$data[
'member_attribute'],
'text').
", ".
220 $this->db->quote(
$data[
'member_isdn'],
'integer').
", ".
221 $this->db->quote(
$data[
'role'],
'integer').
", ".
222 $this->db->quote(
$data[
'info'],
'text').
", ".
223 $this->db->quote(
$data[
'info_type'],
'integer').
229 $query =
"UPDATE ldap_rg_mapping ".
230 "SET server_id = ".$this->db->quote($this->
getServerId(),
'integer').
", ".
231 "url = ".$this->db->quote(
$data[
'url'],
'text').
", ".
232 "dn =".$this->db->quote(
$data[
'dn'],
'text').
", ".
233 "member_attribute = ".$this->db->quote(
$data[
'member_attribute'],
'text').
", ".
234 "member_isdn = ".$this->db->quote(
$data[
'member_isdn'],
'integer').
", ".
235 "role = ".$this->db->quote(
$data[
'role'],
'integer').
", ".
236 "mapping_info = ".$this->db->quote(
$data[
'info'],
'text').
", ".
237 "mapping_info_type = ".$this->db->quote(
$data[
'info_type'],
'integer').
" ".
238 "WHERE mapping_id = ".$this->db->quote($mapping_id,
'integer');
254 public function delete($a_mapping_id)
258 $query =
"DELETE FROM ldap_rg_mapping ".
259 "WHERE server_id = ".$this->db->quote($this->
getServerId(),
'integer').
" ".
260 "AND mapping_id = ".$this->db->quote($a_mapping_id ,
'integer');
274 $role = $this->mappings[$a_mapping_id][
'role_name'];
275 $dn_parts = explode(
',',$this->mappings[$a_mapping_id][
'dn']);
277 return (array_key_exists(0,$dn_parts) ? $dn_parts[0] :
"''");
289 global $ilObjDataCache,$rbacreview,$tree;
291 $this->mappings = array();
292 $query =
"SELECT * FROM ldap_rg_mapping LEFT JOIN object_data ".
294 "WHERE server_id =".$this->db->quote($this->
getServerId(),
'integer').
' '.
300 $this->mappings[
$row->mapping_id][
'dn'] =
$row->dn;
301 $this->mappings[
$row->mapping_id][
'url'] =
$row->url;
302 $this->mappings[
$row->mapping_id][
'member_attribute'] =
$row->member_attribute;
303 $this->mappings[
$row->mapping_id][
'member_isdn'] =
$row->member_isdn;
304 $this->mappings[
$row->mapping_id][
'role'] =
$row->role;
305 $this->mappings[
$row->mapping_id][
'info'] =
$row->mapping_info;
306 $this->mappings[
$row->mapping_id][
'info_type'] =
$row->mapping_info_type;
307 if($ilObjDataCache->lookupType(
$row->role) ==
'role')
309 $this->mappings[
$row->mapping_id][
'role_name'] = $ilObjDataCache->lookupTitle(
$row->role);
313 $this->mappings[
$row->mapping_id][
'role_name'] =
$row->role;