ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilDB, $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:17
global $ilDB
+ Here is the call graph for this function:

Member Function Documentation

◆ _deleteByRole()

static ilLDAPRoleGroupMappingSettings::_deleteByRole (   $a_role_id)
static

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

References $ilDB, $query, and $res.

Referenced by ilObjRole\delete().

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

◆ _deleteByServerId()

static ilLDAPRoleGroupMappingSettings::_deleteByServerId (   $a_server_id)
static

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

References $ilDB, $query, and $res.

Referenced by ilLDAPServer\delete().

85  {
86  global $ilDB;
87 
88  $query = "DELETE FROM ldap_rg_mapping " .
89  "WHERE server_id = " . $ilDB->quote($a_server_id, 'integer');
90  $res = $ilDB->manipulate($query);
91 
92  return true;
93  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ _getAllActiveMappings()

static ilLDAPRoleGroupMappingSettings::_getAllActiveMappings ( )
static

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

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

Referenced by ilLDAPRoleGroupMapping\initServers().

96  {
97  global $ilDB,$rbacreview;
98 
99  $query = "SELECT rgm.* FROM ldap_rg_mapping rgm JOIN ldap_server_settings lss " .
100  "ON rgm.server_id = lss.server_id " .
101  "WHERE lss.active = 1 " .
102  "AND lss.role_sync_active = 1 ";
103  $res = $ilDB->query($query);
104  while ($row = $ilDB->fetchObject($res)) {
105  $data['server_id'] = $row->server_id;
106  $data['url'] = $row->url;
107  $data['mapping_id'] = $row->mapping_id;
108  $data['dn'] = $row->dn;
109  $data['member'] = $row->member_attribute;
110  $data['isdn'] = $row->member_isdn;
111  $data['info'] = $row->mapping_info;
112  $data['info_type'] = $row->mapping_info_type;
113  // read assigned object
114  $data['object_id'] = $rbacreview->getObjectOfRole($row->role);
115 
116 
117  $active[$row->role][] = $data;
118  }
119  return $active ? $active : array();
120  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
global $ilDB
+ 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  return self::$instances[$a_server_id];
69  }
70  return self::$instances[$a_server_id] = new ilLDAPRoleGroupMappingSettings($a_server_id);
71  }
+ Here is the caller graph for this function:

◆ delete()

ilLDAPRoleGroupMappingSettings::delete (   $a_mapping_id)

Delete a mapping.

public

Parameters
intmapping_id

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

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

245  {
246  global $ilDB;
247 
248  $query = "DELETE FROM ldap_rg_mapping " .
249  "WHERE server_id = " . $this->db->quote($this->getServerId(), 'integer') . " " .
250  "AND mapping_id = " . $this->db->quote($a_mapping_id, 'integer');
251  $res = $ilDB->manipulate($query);
252  $this->read();
253  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ 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 262 of file class.ilLDAPRoleGroupMappingSettings.php.

263  {
264  $role = $this->mappings[$a_mapping_id]['role_name'];
265  $dn_parts = explode(',', $this->mappings[$a_mapping_id]['dn']);
266 
267  return (array_key_exists(0, $dn_parts) ? $dn_parts[0] : "''");
268  }

◆ getMappings()

ilLDAPRoleGroupMappingSettings::getMappings ( )

Get already configured mappings.

public

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

References array.

134  {
135  return $this->mappings ? $this->mappings : array();
136  }
Create styles array
The data for the language used.

◆ getServerId()

ilLDAPRoleGroupMappingSettings::getServerId ( )

Definition at line 122 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 138 of file class.ilLDAPRoleGroupMappingSettings.php.

References $data, array, and ilUtil\stripSlashes().

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

◆ read()

ilLDAPRoleGroupMappingSettings::read ( )
private

Read mappings.

private

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

References $query, $res, $row, array, ilDBConstants\FETCHMODE_OBJECT, and getServerId().

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

278  {
279  global $ilObjDataCache,$rbacreview,$tree;
280 
281  $this->mappings = array();
282  $query = "SELECT * FROM ldap_rg_mapping LEFT JOIN object_data " .
283  "ON role = obj_id " .
284  "WHERE server_id =" . $this->db->quote($this->getServerId(), 'integer') . ' ' .
285  "ORDER BY title,dn";
286 
287  $res = $this->db->query($query);
288  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
289  $this->mappings[$row->mapping_id]['mapping_id'] = $row->mapping_id;
290  $this->mappings[$row->mapping_id]['dn'] = $row->dn;
291  $this->mappings[$row->mapping_id]['url'] = $row->url;
292  $this->mappings[$row->mapping_id]['member_attribute'] = $row->member_attribute;
293  $this->mappings[$row->mapping_id]['member_isdn'] = $row->member_isdn;
294  $this->mappings[$row->mapping_id]['role'] = $row->role;
295  $this->mappings[$row->mapping_id]['info'] = $row->mapping_info;
296  $this->mappings[$row->mapping_id]['info_type'] = $row->mapping_info_type;
297  if ($ilObjDataCache->lookupType($row->role) == 'role') {
298  $this->mappings[$row->mapping_id]['role_name'] = $ilObjDataCache->lookupTitle($row->role);
299  } else {
300  $this->mappings[$row->mapping_id]['role_name'] = $row->role;
301  }
302  }
303  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
+ 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 199 of file class.ilLDAPRoleGroupMappingSettings.php.

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

200  {
201  global $ilDB;
202 
203  foreach ($this->mappings as $mapping_id => $data) {
204  if (!$mapping_id) {
205  $next_id = $ilDB->nextId('ldap_rg_mapping');
206  $query = "INSERT INTO ldap_rg_mapping (mapping_id,server_id,url,dn,member_attribute,member_isdn,role,mapping_info,mapping_info_type) " .
207  "VALUES ( " .
208  $ilDB->quote($next_id, 'integer') . ", " .
209  $this->db->quote($this->getServerId(), 'integer') . ", " .
210  $this->db->quote($data['url'], 'text') . ", " .
211  $this->db->quote($data['dn'], 'text') . ", " .
212  $this->db->quote($data['member_attribute'], 'text') . ", " .
213  $this->db->quote($data['member_isdn'], 'integer') . ", " .
214  $this->db->quote($data['role'], 'integer') . ", " .
215  $this->db->quote($data['info'], 'text') . ", " .
216  $this->db->quote($data['info_type'], 'integer') .
217  ")";
218  $res = $ilDB->manipulate($query);
219  } else {
220  $query = "UPDATE ldap_rg_mapping " .
221  "SET server_id = " . $this->db->quote($this->getServerId(), 'integer') . ", " .
222  "url = " . $this->db->quote($data['url'], 'text') . ", " .
223  "dn =" . $this->db->quote($data['dn'], 'text') . ", " .
224  "member_attribute = " . $this->db->quote($data['member_attribute'], 'text') . ", " .
225  "member_isdn = " . $this->db->quote($data['member_isdn'], 'integer') . ", " .
226  "role = " . $this->db->quote($data['role'], 'integer') . ", " .
227  "mapping_info = " . $this->db->quote($data['info'], 'text') . ", " .
228  "mapping_info_type = " . $this->db->quote($data['info_type'], 'integer') . " " .
229  "WHERE mapping_id = " . $this->db->quote($mapping_id, 'integer');
230  $res = $ilDB->manipulate($query);
231  }
232  }
233  $this->read();
234  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:

◆ validate()

ilLDAPRoleGroupMappingSettings::validate ( )

Validate mappings.

public

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

References $data, and $ilErr.

171  {
172  global $ilErr,$rbacreview;
173 
174  $ilErr->setMessage('');
175  $found_missing = false;
176  foreach ($this->mappings as $mapping_id => $data) {
177  // Check if all required fields are available
178  if (!strlen($data['dn']) || !strlen($data['member_attribute']) || !strlen($data['role_name'])) {
179  if (!$found_missing) {
180  $found_missing = true;
181  $ilErr->appendMessage($this->lng->txt('fill_out_all_required_fields'));
182  }
183  }
184  // Check role valid
185  if (strlen($data['role_name']) and !$rbacreview->roleExists($data['role_name'])) {
186  $ilErr->appendMessage($this->lng->txt('ldap_role_not_exists') . ' ' . $data['role_name']);
187  }
188  }
189  return strlen($ilErr->getMessage()) ? false : true;
190  }
global $ilErr
Definition: raiseError.php:16

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: