ILIAS  release_7 Revision v7.30-3-g800a261c036
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)

@access private

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

49 {
50 global $DIC;
51
52 $ilDB = $DIC['ilDB'];
53 $lng = $DIC['lng'];
54
55 $this->db = $ilDB;
56 $this->lng = $lng;
57 $this->server_id = $a_server_id;
58 $this->read();
59 }
global $DIC
Definition: goto.php:24
$lng
global $ilDB

References $DIC, $ilDB, $lng, and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ _deleteByRole()

static ilLDAPRoleGroupMappingSettings::_deleteByRole (   $a_role_id)
static

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

77 {
78 global $DIC;
79
80 $ilDB = $DIC['ilDB'];
81
82 $query = "DELETE FROM ldap_rg_mapping " .
83 "WHERE role = " . $ilDB->quote($a_role_id, 'integer');
84 $res = $ilDB->manipulate($query);
85
86 return true;
87 }
$query
foreach($_POST as $key=> $value) $res

References $DIC, $ilDB, $query, and $res.

Referenced by ilObjRole\delete().

+ Here is the caller graph for this function:

◆ _deleteByServerId()

static ilLDAPRoleGroupMappingSettings::_deleteByServerId (   $a_server_id)
static

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

90 {
91 global $DIC;
92
93 $ilDB = $DIC['ilDB'];
94
95 $query = "DELETE FROM ldap_rg_mapping " .
96 "WHERE server_id = " . $ilDB->quote($a_server_id, 'integer');
97 $res = $ilDB->manipulate($query);
98
99 return true;
100 }

References $DIC, $ilDB, $query, and $res.

Referenced by ilLDAPServer\delete().

+ Here is the caller graph for this function:

◆ _getAllActiveMappings()

static ilLDAPRoleGroupMappingSettings::_getAllActiveMappings ( )
static

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

103 {
104 global $DIC;
105
106 $ilDB = $DIC['ilDB'];
107 $rbacreview = $DIC['rbacreview'];
108
109 $query = "SELECT rgm.* FROM ldap_rg_mapping rgm JOIN ldap_server_settings lss " .
110 "ON rgm.server_id = lss.server_id " .
111 "WHERE lss.active = 1 " .
112 "AND lss.role_sync_active = 1 ";
113 $res = $ilDB->query($query);
114 while ($row = $ilDB->fetchObject($res)) {
115 $data['server_id'] = $row->server_id;
116 $data['url'] = $row->url;
117 $data['mapping_id'] = $row->mapping_id;
118 $data['dn'] = $row->dn;
119 $data['member'] = $row->member_attribute;
120 $data['isdn'] = $row->member_isdn;
121 $data['info'] = $row->mapping_info;
122 $data['info_type'] = $row->mapping_info_type;
123 // read assigned object
124 $data['object_id'] = $rbacreview->getObjectOfRole($row->role);
125
126
127 $active[$row->role][] = $data;
128 }
129 return $active ? $active : array();
130 }
$data
Definition: storeScorm.php:23

References $data, $DIC, $ilDB, $query, and $res.

Referenced by ilLDAPRoleGroupMapping\initServers().

+ Here is the caller graph for this function:

◆ _getInstanceByServerId()

static ilLDAPRoleGroupMappingSettings::_getInstanceByServerId (   $a_server_id)
static

Get instance of class.

@access public

Parameters
intserver_id
Returns
ilLDAPRoleGroupMappingSettings

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

69 {
70 if (array_key_exists($a_server_id, self::$instances) and is_object(self::$instances[$a_server_id])) {
71 return self::$instances[$a_server_id];
72 }
73 return self::$instances[$a_server_id] = new ilLDAPRoleGroupMappingSettings($a_server_id);
74 }

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

+ Here is the caller graph for this function:

◆ delete()

ilLDAPRoleGroupMappingSettings::delete (   $a_mapping_id)

Delete a mapping.

@access public

Parameters
intmapping_id

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

262 {
263 global $DIC;
264
265 $ilDB = $DIC['ilDB'];
266
267 $query = "DELETE FROM ldap_rg_mapping " .
268 "WHERE server_id = " . $this->db->quote($this->getServerId(), 'integer') . " " .
269 "AND mapping_id = " . $this->db->quote($a_mapping_id, 'integer');
270 $res = $ilDB->manipulate($query);
271 $this->read();
272 }

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

+ Here is the call graph for this function:

◆ getMappingInfoString()

ilLDAPRoleGroupMappingSettings::getMappingInfoString (   $a_mapping_id)

Create an info string for a role group mapping.

@access public

Parameters
intmapping_id

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

282 {
283 $role = $this->mappings[$a_mapping_id]['role_name'];
284 $dn_parts = explode(',', $this->mappings[$a_mapping_id]['dn']);
285
286 return (array_key_exists(0, $dn_parts) ? $dn_parts[0] : "''");
287 }

◆ getMappings()

ilLDAPRoleGroupMappingSettings::getMappings ( )

Get already configured mappings.

@access public

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

144 {
145 return $this->mappings ? $this->mappings : array();
146 }

◆ getServerId()

ilLDAPRoleGroupMappingSettings::getServerId ( )

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

149 {
150 global $DIC;
151
152 $rbacreview = $DIC['rbacreview'];
153
154 if (!$a_mappings) {
155 return;
156 }
157
158 $this->mappings = array();
159 foreach ($a_mappings as $mapping_id => $data) {
160 if ($mapping_id == 0) {
161 if (!$data['dn'] and !$data['member'] and !$data['memberisdn'] and !$data['role']) {
162 continue;
163 }
164 }
165 $this->mappings[$mapping_id]['dn'] = ilUtil::stripSlashes($data['dn']);
166 $this->mappings[$mapping_id]['url'] = ilUtil::stripSlashes($data['url']);
167 $this->mappings[$mapping_id]['member_attribute'] = ilUtil::stripSlashes($data['member']);
168 $this->mappings[$mapping_id]['member_isdn'] = ilUtil::stripSlashes($data['memberisdn']);
169 $this->mappings[$mapping_id]['role_name'] = ilUtil::stripSlashes($data['role']);
170 $this->mappings[$mapping_id]['role'] = $rbacreview->roleExists(ilUtil::stripSlashes($data['role']));
171 $this->mappings[$mapping_id]['info'] = ilUtil::stripSlashes($data['info']);
172 $this->mappings[$mapping_id]['info_type'] = ilUtil::stripSlashes($data['info_type']);
173 }
174 }
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

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

+ Here is the call graph for this function:

◆ read()

ilLDAPRoleGroupMappingSettings::read ( )
private

Read mappings.

@access private

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

297 {
298 global $DIC;
299
300 $ilObjDataCache = $DIC['ilObjDataCache'];
301 $rbacreview = $DIC['rbacreview'];
302 $tree = $DIC['tree'];
303
304 $this->mappings = array();
305 $query = "SELECT * FROM ldap_rg_mapping LEFT JOIN object_data " .
306 "ON role = obj_id " .
307 "WHERE server_id =" . $this->db->quote($this->getServerId(), 'integer') . ' ' .
308 "ORDER BY title,dn";
309
310 $res = $this->db->query($query);
311 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
312 $this->mappings[$row->mapping_id]['mapping_id'] = $row->mapping_id;
313 $this->mappings[$row->mapping_id]['dn'] = $row->dn;
314 $this->mappings[$row->mapping_id]['url'] = $row->url;
315 $this->mappings[$row->mapping_id]['member_attribute'] = $row->member_attribute;
316 $this->mappings[$row->mapping_id]['member_isdn'] = $row->member_isdn;
317 $this->mappings[$row->mapping_id]['role'] = $row->role;
318 $this->mappings[$row->mapping_id]['info'] = $row->mapping_info;
319 $this->mappings[$row->mapping_id]['info_type'] = $row->mapping_info_type;
320 if ($ilObjDataCache->lookupType($row->role) == 'role') {
321 $this->mappings[$row->mapping_id]['role_name'] = $ilObjDataCache->lookupTitle($row->role);
322 } else {
323 $this->mappings[$row->mapping_id]['role_name'] = $row->role;
324 }
325 }
326 }

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

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilLDAPRoleGroupMappingSettings::save ( )

Save mappings.

@access public

Parameters

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

215 {
216 global $DIC;
217
218 $ilDB = $DIC['ilDB'];
219
220 foreach ($this->mappings as $mapping_id => $data) {
221 if (!$mapping_id) {
222 $next_id = $ilDB->nextId('ldap_rg_mapping');
223 $query = "INSERT INTO ldap_rg_mapping (mapping_id,server_id,url,dn,member_attribute,member_isdn,role,mapping_info,mapping_info_type) " .
224 "VALUES ( " .
225 $ilDB->quote($next_id, 'integer') . ", " .
226 $this->db->quote($this->getServerId(), 'integer') . ", " .
227 $this->db->quote($data['url'], 'text') . ", " .
228 $this->db->quote($data['dn'], 'text') . ", " .
229 $this->db->quote($data['member_attribute'], 'text') . ", " .
230 $this->db->quote($data['member_isdn'], 'integer') . ", " .
231 $this->db->quote($data['role'], 'integer') . ", " .
232 $this->db->quote($data['info'], 'text') . ", " .
233 $this->db->quote($data['info_type'], 'integer') .
234 ")";
235 $res = $ilDB->manipulate($query);
236 } else {
237 $query = "UPDATE ldap_rg_mapping " .
238 "SET server_id = " . $this->db->quote($this->getServerId(), 'integer') . ", " .
239 "url = " . $this->db->quote($data['url'], 'text') . ", " .
240 "dn =" . $this->db->quote($data['dn'], 'text') . ", " .
241 "member_attribute = " . $this->db->quote($data['member_attribute'], 'text') . ", " .
242 "member_isdn = " . $this->db->quote($data['member_isdn'], 'integer') . ", " .
243 "role = " . $this->db->quote($data['role'], 'integer') . ", " .
244 "mapping_info = " . $this->db->quote($data['info'], 'text') . ", " .
245 "mapping_info_type = " . $this->db->quote($data['info_type'], 'integer') . " " .
246 "WHERE mapping_id = " . $this->db->quote($mapping_id, 'integer');
247 $res = $ilDB->manipulate($query);
248 }
249 }
250 $this->read();
251 }

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

+ Here is the call graph for this function:

◆ validate()

ilLDAPRoleGroupMappingSettings::validate ( )

Validate mappings.

@access public

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

183 {
184 global $DIC;
185
186 $ilErr = $DIC['ilErr'];
187 $rbacreview = $DIC['rbacreview'];
188
189 $ilErr->setMessage('');
190 $found_missing = false;
191 foreach ($this->mappings as $mapping_id => $data) {
192 // Check if all required fields are available
193 if (!strlen($data['dn']) || !strlen($data['member_attribute']) || !strlen($data['role_name'])) {
194 if (!$found_missing) {
195 $found_missing = true;
196 $ilErr->appendMessage($this->lng->txt('fill_out_all_required_fields'));
197 }
198 }
199 // Check role valid
200 if (strlen($data['role_name']) and !$rbacreview->roleExists($data['role_name'])) {
201 $ilErr->appendMessage($this->lng->txt('ldap_role_not_exists') . ' ' . $data['role_name']);
202 }
203 }
204 return strlen($ilErr->getMessage()) ? false : true;
205 }
$ilErr
Definition: raiseError.php:18

References $data, $DIC, and $ilErr.

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: