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_role_group_mapping ".
79 "WHERE role = ".$ilDB->quote($a_role_id);
89 $query =
"DELETE FROM ldap_role_group_mapping ".
90 "WHERE server_id = ".$ilDB->quote($a_server_id);
98 global $ilDB,$rbacreview;
100 $query =
"SELECT rgm.* FROM ldap_role_group_mapping as rgm JOIN ldap_server_settings as lss ".
101 "ON rgm.server_id = lss.server_id ".
102 "WHERE lss.active = 1 ".
103 "AND lss.role_sync_active = 1 ";
104 $res = $ilDB->query($query);
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();
146 $this->mappings = array();
147 foreach($a_mappings as $mapping_id =>
$data)
175 global
$ilErr,$rbacreview;
177 $ilErr->setMessage(
'');
178 $found_missing =
false;
179 foreach($this->mappings as $mapping_id =>
$data)
182 if(!strlen(
$data[
'dn']) || !strlen(
$data[
'member_attribute']) || !strlen(
$data[
'role_name']))
186 $found_missing =
true;
187 $ilErr->appendMessage($this->lng->txt(
'fill_out_all_required_fields'));
191 if(strlen(
$data[
'role_name']) and !$rbacreview->roleExists(
$data[
'role_name']))
193 $ilErr->appendMessage($this->lng->txt(
'ldap_role_not_exists').
' '.
$data[
'role_name']);
196 return strlen($ilErr->getMessage()) ?
false :
true;
208 foreach($this->mappings as $mapping_id =>
$data)
212 $query =
"INSERT INTO ldap_role_group_mapping ".
213 "SET server_id = ".$this->db->quote($this->
getServerId()).
", ".
214 "url = ".$this->db->quote(
$data[
'url']).
", ".
215 "dn = ".$this->db->quote(
$data[
'dn']).
", ".
216 "member_attribute = ".$this->db->quote(
$data[
'member_attribute']).
", ".
217 "member_isdn = ".$this->db->quote(
$data[
'member_isdn']).
", ".
218 "role = ".$this->db->quote(
$data[
'role']).
", ".
219 "mapping_info = ".$this->db->quote(
$data[
'info']).
", ".
220 "mapping_info_type = ".$this->db->quote(
$data[
'info_type']);
223 $this->db->query($query);
227 $query =
"UPDATE ldap_role_group_mapping ".
228 "SET server_id = ".$this->db->quote($this->
getServerId()).
", ".
229 "url = ".$this->db->quote(
$data[
'url']).
", ".
230 "dn =".$this->db->quote(
$data[
'dn']).
", ".
231 "member_attribute = ".$this->db->quote(
$data[
'member_attribute']).
", ".
232 "member_isdn = ".$this->db->quote(
$data[
'member_isdn']).
", ".
233 "role = ".$this->db->quote(
$data[
'role']).
", ".
234 "mapping_info = ".$this->db->quote(
$data[
'info']).
", ".
235 "mapping_info_type = ".$this->db->quote(
$data[
'info_type']).
" ".
236 "WHERE mapping_id = ".$this->db->quote($mapping_id);
238 $this->db->query($query);
252 public function delete($a_mapping_id)
254 $query =
"DELETE FROM ldap_role_group_mapping ".
255 "WHERE server_id = ".$this->db->quote($this->
getServerId()).
" ".
256 "AND mapping_id = ".$this->db->quote($a_mapping_id);
257 $this->db->query($query);
271 $role = $this->mappings[$a_mapping_id][
'role_name'];
272 $dn_parts = explode(
',',$this->mappings[$a_mapping_id][
'dn']);
274 return (array_key_exists(0,$dn_parts) ? $dn_parts[0] :
"''");
286 global $ilObjDataCache,$rbacreview,$tree;
288 $this->mappings = array();
289 $query =
"SELECT * FROM ldap_role_group_mapping LEFT JOIN object_data ".
291 "WHERE server_id =".$this->db->quote($this->
getServerId()).
' '.
294 $res = $this->db->query($query);
297 $this->mappings[$row->mapping_id][
'dn'] = $row->dn;
298 $this->mappings[$row->mapping_id][
'url'] = $row->url;
299 $this->mappings[$row->mapping_id][
'member_attribute'] = $row->member_attribute;
300 $this->mappings[$row->mapping_id][
'member_isdn'] = $row->member_isdn;
301 $this->mappings[$row->mapping_id][
'role'] = $row->role;
302 $this->mappings[$row->mapping_id][
'info'] = $row->mapping_info;
303 $this->mappings[$row->mapping_id][
'info_type'] = $row->mapping_info_type;
304 if($ilObjDataCache->lookupType($row->role) ==
'role')
306 $this->mappings[$row->mapping_id][
'role_name'] = $ilObjDataCache->lookupTitle($row->role);
310 $this->mappings[$row->mapping_id][
'role_name'] = $row->role;