ILIAS  release_4-4 Revision
ilLDAPRoleGroupMappingSettings Class Reference
+ Collaboration diagram for ilLDAPRoleGroupMappingSettings:

Public Member Functions

 getServerId ()
 
 getMappings ()
 Get already configured mappings. More...
 
 loadFromPost ($a_mappings)
 
 validate ()
 Validate mappings. More...
 
 save ()
 Save mappings. More...
 
 delete ($a_mapping_id)
 Delete a mapping. More...
 
 getMappingInfoString ($a_mapping_id)
 Create an info string for a role group mapping. More...
 

Static Public Member Functions

static _getInstanceByServerId ($a_server_id)
 Get instance of class. More...
 
static _deleteByRole ($a_role_id)
 
static _deleteByServerId ($a_server_id)
 
static _getAllActiveMappings ()
 

Data Fields

const MAPPING_INFO_ALL = 1
 
const MAPPING_INFO_INFO_ONLY = 0
 

Private Member Functions

 __construct ($a_server_id)
 Private constructor (Singleton for each server_id) More...
 
 read ()
 Read mappings. More...
 

Private Attributes

 $server_id = null
 
 $db = null
 
 $mappings = null
 

Static Private Attributes

static $instances = array()
 

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 32 of file class.ilLDAPRoleGroupMappingSettings.php.

Constructor & Destructor Documentation

◆ __construct()

ilLDAPRoleGroupMappingSettings::__construct (   $a_server_id)
private

Private constructor (Singleton for each server_id)

private

Definition at line 48 of file class.ilLDAPRoleGroupMappingSettings.php.

References $lng, and read().

49  {
50  global $ilDB,$lng;
51 
52  $this->db = $ilDB;
53  $this->lng = $lng;
54  $this->server_id = $a_server_id;
55  $this->read();
56  }
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:

Member Function Documentation

◆ _deleteByRole()

static ilLDAPRoleGroupMappingSettings::_deleteByRole (   $a_role_id)
static

Definition at line 74 of file class.ilLDAPRoleGroupMappingSettings.php.

References $query, and $res.

Referenced by ilObjRole\delete().

75  {
76  global $ilDB;
77 
78  $query = "DELETE FROM ldap_rg_mapping ".
79  "WHERE role = ".$ilDB->quote($a_role_id,'integer');
80  $res = $ilDB->manipulate($query);
81 
82  return true;
83  }
+ Here is the caller graph for this function:

◆ _deleteByServerId()

static ilLDAPRoleGroupMappingSettings::_deleteByServerId (   $a_server_id)
static

Definition at line 85 of file class.ilLDAPRoleGroupMappingSettings.php.

References $query, and $res.

86  {
87  global $ilDB;
88 
89  $query = "DELETE FROM ldap_rg_mapping ".
90  "WHERE server_id = ".$ilDB->quote($a_server_id,'integer');
91  $res = $ilDB->manipulate($query);
92 
93  return true;
94  }

◆ _getAllActiveMappings()

static ilLDAPRoleGroupMappingSettings::_getAllActiveMappings ( )
static

Definition at line 96 of file class.ilLDAPRoleGroupMappingSettings.php.

References $data, $query, $res, and $row.

Referenced by ilLDAPRoleGroupMapping\initServers().

97  {
98  global $ilDB,$rbacreview;
99 
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 ";
104  $res = $ilDB->query($query);
105  while($row = $ilDB->fetchObject($res))
106  {
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;
115  // read assigned object
116  $data['object_id'] = $rbacreview->getObjectOfRole($row->role);
117 
118 
119  $active[$row->role][] = $data;
120  }
121  return $active ? $active : array();
122  }
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
+ Here is the caller graph for this function:

◆ _getInstanceByServerId()

static ilLDAPRoleGroupMappingSettings::_getInstanceByServerId (   $a_server_id)
static

Get instance of class.

public

Parameters
intserver_id
Returns
ilLDAPRoleGroupMappingSettings

Definition at line 65 of file class.ilLDAPRoleGroupMappingSettings.php.

Referenced by ilLDAPRoleMappingTableGUI\getItems(), ilLDAPSettingsGUI\initRoleMapping(), and ilLDAPSettingsGUI\roleMapping().

66  {
67  if(array_key_exists($a_server_id,self::$instances) and is_object(self::$instances[$a_server_id]))
68  {
69  return self::$instances[$a_server_id];
70  }
71  return self::$instances[$a_server_id] = new ilLDAPRoleGroupMappingSettings($a_server_id);
72  }
+ Here is the caller graph for this function:

◆ delete()

ilLDAPRoleGroupMappingSettings::delete (   $a_mapping_id)

Delete a mapping.

public

Parameters
intmapping_id

Definition at line 259 of file class.ilLDAPRoleGroupMappingSettings.php.

References $query, $res, getServerId(), and read().

260  {
261  global $ilDB;
262 
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');
266  $res = $ilDB->manipulate($query);
267  $this->read();
268  }
+ Here is the call graph for this function:

◆ getMappingInfoString()

ilLDAPRoleGroupMappingSettings::getMappingInfoString (   $a_mapping_id)

Create an info string for a role group mapping.

public

Parameters
intmapping_id

Definition at line 277 of file class.ilLDAPRoleGroupMappingSettings.php.

278  {
279  $role = $this->mappings[$a_mapping_id]['role_name'];
280  $dn_parts = explode(',',$this->mappings[$a_mapping_id]['dn']);
281 
282  return (array_key_exists(0,$dn_parts) ? $dn_parts[0] : "''");
283  }

◆ getMappings()

ilLDAPRoleGroupMappingSettings::getMappings ( )

Get already configured mappings.

public

Definition at line 135 of file class.ilLDAPRoleGroupMappingSettings.php.

136  {
137  return $this->mappings ? $this->mappings : array();
138  }

◆ getServerId()

ilLDAPRoleGroupMappingSettings::getServerId ( )

Definition at line 124 of file class.ilLDAPRoleGroupMappingSettings.php.

References $server_id.

Referenced by delete(), read(), and save().

+ Here is the caller graph for this function:

◆ loadFromPost()

ilLDAPRoleGroupMappingSettings::loadFromPost (   $a_mappings)

Definition at line 140 of file class.ilLDAPRoleGroupMappingSettings.php.

References $data, and ilUtil\stripSlashes().

141  {
142  global $rbacreview;
143 
144  if(!$a_mappings)
145  {
146  return;
147  }
148 
149  $this->mappings = array();
150  foreach($a_mappings as $mapping_id => $data)
151  {
152  if($mapping_id == 0)
153  {
154  if(!$data['dn'] and !$data['member'] and !$data['memberisdn'] and !$data['role'])
155  {
156  continue;
157  }
158  }
159  $this->mappings[$mapping_id]['dn'] = ilUtil::stripSlashes($data['dn']);
160  $this->mappings[$mapping_id]['url'] = ilUtil::stripSlashes($data['url']);
161  $this->mappings[$mapping_id]['member_attribute'] = ilUtil::stripSlashes($data['member']);
162  $this->mappings[$mapping_id]['member_isdn'] = ilUtil::stripSlashes($data['memberisdn']);
163  $this->mappings[$mapping_id]['role_name'] = ilUtil::stripSlashes($data['role']);
164  $this->mappings[$mapping_id]['role'] = $rbacreview->roleExists(ilUtil::stripSlashes($data['role']));
165  $this->mappings[$mapping_id]['info'] = ilUtil::stripSlashes($data['info']);
166  $this->mappings[$mapping_id]['info_type'] = ilUtil::stripSlashes($data['info_type']);
167  }
168  }
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
+ Here is the call graph for this function:

◆ read()

ilLDAPRoleGroupMappingSettings::read ( )
private

Read mappings.

private

Definition at line 292 of file class.ilLDAPRoleGroupMappingSettings.php.

References $query, $res, $row, DB_FETCHMODE_OBJECT, and getServerId().

Referenced by __construct(), delete(), and save().

293  {
294  global $ilObjDataCache,$rbacreview,$tree;
295 
296  $this->mappings = array();
297  $query = "SELECT * FROM ldap_rg_mapping LEFT JOIN object_data ".
298  "ON role = obj_id ".
299  "WHERE server_id =".$this->db->quote($this->getServerId(),'integer').' '.
300  "ORDER BY title,dn";
301 
302  $res = $this->db->query($query);
303  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
304  {
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')
314  {
315  $this->mappings[$row->mapping_id]['role_name'] = $ilObjDataCache->lookupTitle($row->role);
316  }
317  else
318  {
319  $this->mappings[$row->mapping_id]['role_name'] = $row->role;
320  }
321 
322  }
323  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilLDAPRoleGroupMappingSettings::save ( )

Save mappings.

public

Parameters

Definition at line 209 of file class.ilLDAPRoleGroupMappingSettings.php.

References $data, $query, $res, getServerId(), and read().

210  {
211  global $ilDB;
212 
213  foreach($this->mappings as $mapping_id => $data)
214  {
215  if(!$mapping_id)
216  {
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) ".
219  "VALUES ( ".
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').
229  ")";
230  $res = $ilDB->manipulate($query);
231  }
232  else
233  {
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');
244  $res = $ilDB->manipulate($query);
245 
246  }
247  }
248  $this->read();
249  }
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
+ Here is the call graph for this function:

◆ validate()

ilLDAPRoleGroupMappingSettings::validate ( )

Validate mappings.

public

Definition at line 176 of file class.ilLDAPRoleGroupMappingSettings.php.

References $data, and $ilErr.

177  {
178  global $ilErr,$rbacreview;
179 
180  $ilErr->setMessage('');
181  $found_missing = false;
182  foreach($this->mappings as $mapping_id => $data)
183  {
184  // Check if all required fields are available
185  if(!strlen($data['dn']) || !strlen($data['member_attribute']) || !strlen($data['role_name']))
186  {
187  if(!$found_missing)
188  {
189  $found_missing = true;
190  $ilErr->appendMessage($this->lng->txt('fill_out_all_required_fields'));
191  }
192  }
193  // Check role valid
194  if(strlen($data['role_name']) and !$rbacreview->roleExists($data['role_name']))
195  {
196  $ilErr->appendMessage($this->lng->txt('ldap_role_not_exists').' '.$data['role_name']);
197  }
198  }
199  return strlen($ilErr->getMessage()) ? false : true;
200  }
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data

Field Documentation

◆ $db

ilLDAPRoleGroupMappingSettings::$db = null
private

Definition at line 36 of file class.ilLDAPRoleGroupMappingSettings.php.

◆ $instances

ilLDAPRoleGroupMappingSettings::$instances = array()
staticprivate

Definition at line 34 of file class.ilLDAPRoleGroupMappingSettings.php.

◆ $mappings

ilLDAPRoleGroupMappingSettings::$mappings = null
private

Definition at line 37 of file class.ilLDAPRoleGroupMappingSettings.php.

◆ $server_id

ilLDAPRoleGroupMappingSettings::$server_id = null
private

Definition at line 35 of file class.ilLDAPRoleGroupMappingSettings.php.

Referenced by getServerId().

◆ MAPPING_INFO_ALL

const ilLDAPRoleGroupMappingSettings::MAPPING_INFO_ALL = 1

◆ MAPPING_INFO_INFO_ONLY

const ilLDAPRoleGroupMappingSettings::MAPPING_INFO_INFO_ONLY = 0

Definition at line 40 of file class.ilLDAPRoleGroupMappingSettings.php.


The documentation for this class was generated from the following file: