ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilLDAPRoleGroupMappingSettings Class Reference
+ Collaboration diagram for ilLDAPRoleGroupMappingSettings:

Public Member Functions

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

Static Public Member Functions

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

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

ilDBInterface $db
 
ilLanguage $lng
 
ilRbacReview $rbacreview
 
ilErrorHandling $ilErr
 
ilObjectDataCache $ilObjDataCache
 
int $server_id
 
array $mappings = []
 

Static Private Attributes

static array $instances = []
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilLDAPRoleGroupMappingSettings::__construct (   $a_server_id)
private

Private constructor (Singleton for each server_id)

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

44 {
45 global $DIC;
46
47 $this->db = $DIC->database();
48 $this->lng = $DIC->language();
49 $this->rbacreview = $DIC->rbac()->review();
50 $this->ilErr = $DIC['ilErr'];
51 $this->ilObjDataCache = $DIC['ilObjDataCache'];
52 $this->server_id = $a_server_id;
53 $this->read();
54 }
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\lng(), and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ _deleteByRole()

static ilLDAPRoleGroupMappingSettings::_deleteByRole ( int  $a_role_id)
static

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

67 : bool
68 {
69 global $DIC;
70
71 $ilDB = $DIC['ilDB'];
72
73 $query = "DELETE FROM ldap_rg_mapping " .
74 "WHERE role = " . $ilDB->quote($a_role_id, 'integer');
75 $ilDB->manipulate($query);
76
77 return true;
78 }

References $DIC, and $ilDB.

Referenced by ilObjRole\delete().

+ Here is the caller graph for this function:

◆ _deleteByServerId()

static ilLDAPRoleGroupMappingSettings::_deleteByServerId ( int  $a_server_id)
static

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

80 : bool
81 {
82 global $DIC;
83
84 $ilDB = $DIC['ilDB'];
85
86 $query = "DELETE FROM ldap_rg_mapping " .
87 "WHERE server_id = " . $ilDB->quote($a_server_id, 'integer');
88 $ilDB->manipulate($query);
89
90 return true;
91 }

References $DIC, and $ilDB.

Referenced by ilLDAPServer\delete().

+ Here is the caller graph for this function:

◆ _getInstanceByServerId()

static ilLDAPRoleGroupMappingSettings::_getInstanceByServerId ( int  $a_server_id)
static

Get instance of class.

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

60 {
61 if (array_key_exists($a_server_id, self::$instances) && is_object(self::$instances[$a_server_id])) {
62 return self::$instances[$a_server_id];
63 }
64 return self::$instances[$a_server_id] = new ilLDAPRoleGroupMappingSettings($a_server_id);
65 }

Referenced by ilLDAPSettingsGUI\__construct(), LDAPRoleMappingTable\initRecords(), and ilLDAPSettingsGUI\initRoleMapping().

+ Here is the caller graph for this function:

◆ delete()

ilLDAPRoleGroupMappingSettings::delete (   $a_mapping_id)

Delete a mapping.

Parameters
intmapping_id

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

234 : void
235 {
236 $query = "DELETE FROM ldap_rg_mapping " .
237 "WHERE server_id = " . $this->db->quote($this->getServerId(), 'integer') . " " .
238 "AND mapping_id = " . $this->db->quote($a_mapping_id, 'integer');
239 $this->db->manipulate($query);
240 $this->read();
241 }

References getServerId(), and read().

+ Here is the call graph for this function:

◆ getMappingInfoString()

ilLDAPRoleGroupMappingSettings::getMappingInfoString ( int  $a_mapping_id)

Create an info string for a role group mapping.

Parameters
int$a_mapping_idmapping_id

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

250 : string
251 {
252 $dn_parts = explode(',', $this->mappings[$a_mapping_id]['dn']);
253
254 return $dn_parts ? $dn_parts[0] : "''";
255 }

◆ getMappings()

ilLDAPRoleGroupMappingSettings::getMappings ( )

Get already configured mappings.

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

132 : array
133 {
134 return $this->mappings;
135 }

References $mappings.

◆ 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 ( array  $a_mappings)

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

137 : void
138 {
139 if (!$a_mappings) {
140 return;
141 }
142
143 $this->mappings = [];
144 foreach ($a_mappings as $mapping_id => $data) {
145 if ($mapping_id === 0 && !$data['dn'] && !$data['member'] && !$data['memberisdn'] && !$data['role']) {
146 continue;
147 }
148 $this->mappings[$mapping_id]['dn'] = ilUtil::stripSlashes($data['dn']);
149 $this->mappings[$mapping_id]['url'] = ilUtil::stripSlashes($data['url']);
150 $this->mappings[$mapping_id]['member_attribute'] = ilUtil::stripSlashes($data['member']);
151 $this->mappings[$mapping_id]['member_isdn'] = ilUtil::stripSlashes($data['memberisdn']);
152 $this->mappings[$mapping_id]['role_name'] = ilUtil::stripSlashes($data['role']);
153 $this->mappings[$mapping_id]['role'] = $this->rbacreview->roleExists(ilUtil::stripSlashes($data['role']));
154 $this->mappings[$mapping_id]['info'] = ilUtil::stripSlashes($data['info']);
155 $this->mappings[$mapping_id]['info_type'] = ilUtil::stripSlashes($data['info_type']);
156 }
157 }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")

References $data, and ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ read()

ilLDAPRoleGroupMappingSettings::read ( )
private

Read mappings.

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

261 : void
262 {
263 $this->mappings = array();
264 $query = "SELECT * FROM ldap_rg_mapping LEFT JOIN object_data " .
265 "ON role = obj_id " .
266 "WHERE server_id =" . $this->db->quote($this->getServerId(), 'integer') . ' ' .
267 "ORDER BY title,dn";
268
269 $res = $this->db->query($query);
270 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
271 $this->mappings[$row->mapping_id]['mapping_id'] = $row->mapping_id;
272 $this->mappings[$row->mapping_id]['dn'] = $row->dn;
273 $this->mappings[$row->mapping_id]['url'] = $row->url;
274 $this->mappings[$row->mapping_id]['member_attribute'] = $row->member_attribute;
275 $this->mappings[$row->mapping_id]['member_isdn'] = $row->member_isdn;
276 $this->mappings[$row->mapping_id]['role'] = $row->role;
277 $this->mappings[$row->mapping_id]['info'] = $row->mapping_info;
278 $this->mappings[$row->mapping_id]['info_type'] = $row->mapping_info_type;
279 if ($this->ilObjDataCache->lookupType((int) $row->role) === 'role') {
280 $this->mappings[$row->mapping_id]['role_name'] = $this->ilObjDataCache->lookupTitle((int) $row->role);
281 } else {
282 $this->mappings[$row->mapping_id]['role_name'] = $row->role;
283 }
284 }
285 }
$res
Definition: ltiservices.php:69

References $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 193 of file class.ilLDAPRoleGroupMappingSettings.php.

193 : void
194 {
195 foreach ($this->mappings as $mapping_id => $data) {
196 if (!$mapping_id) {
197 $next_id = $this->db->nextId('ldap_rg_mapping');
198 $query = "INSERT INTO ldap_rg_mapping (mapping_id,server_id,url,dn,member_attribute,member_isdn,role,mapping_info,mapping_info_type) " .
199 "VALUES ( " .
200 $this->db->quote($next_id, 'integer') . ", " .
201 $this->db->quote($this->getServerId(), 'integer') . ", " .
202 $this->db->quote($data['url'], 'text') . ", " .
203 $this->db->quote($data['dn'], 'text') . ", " .
204 $this->db->quote($data['member_attribute'], 'text') . ", " .
205 $this->db->quote($data['member_isdn'], 'integer') . ", " .
206 $this->db->quote($data['role'], 'integer') . ", " .
207 $this->db->quote($data['info'], 'text') . ", " .
208 $this->db->quote($data['info_type'], 'integer') .
209 ")";
210 } else {
211 $query = "UPDATE ldap_rg_mapping " .
212 "SET server_id = " . $this->db->quote($this->getServerId(), 'integer') . ", " .
213 "url = " . $this->db->quote($data['url'], 'text') . ", " .
214 "dn =" . $this->db->quote($data['dn'], 'text') . ", " .
215 "member_attribute = " . $this->db->quote($data['member_attribute'], 'text') . ", " .
216 "member_isdn = " . $this->db->quote($data['member_isdn'], 'integer') . ", " .
217 "role = " . $this->db->quote($data['role'], 'integer') . ", " .
218 "mapping_info = " . $this->db->quote($data['info'], 'text') . ", " .
219 "mapping_info_type = " . $this->db->quote($data['info_type'], 'integer') . " " .
220 "WHERE mapping_id = " . $this->db->quote($mapping_id, 'integer');
221 }
222 $this->db->manipulate($query);
223 }
224 $this->read();
225 }

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

+ Here is the call graph for this function:

◆ validate()

ilLDAPRoleGroupMappingSettings::validate ( )

Validate mappings.

@access public

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

165 : bool
166 {
167 $this->ilErr->setMessage('');
168 $found_missing = false;
169 foreach ($this->mappings as $data) {
170 // Check if all required fields are available
171 if ($data['dn'] === '' || $data['member_attribute'] === '' || $data['role_name'] === '') {
172 if (!$found_missing) {
173 $found_missing = true;
174 $this->ilErr->appendMessage($this->lng->txt('fill_out_all_required_fields'));
175 }
176 }
177 // Check role valid
178 if ($data['role_name'] !== '' && !$this->rbacreview->roleExists($data['role_name'])) {
179 $this->ilErr->appendMessage($this->lng->txt('ldap_role_not_exists') . ' ' . $data['role_name']);
180 }
181 }
182
183 return $this->ilErr->getMessage() === '';
184 }

References $data, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilLDAPRoleGroupMappingSettings::$db
private

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

◆ $ilErr

ilErrorHandling ilLDAPRoleGroupMappingSettings::$ilErr
private

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

◆ $ilObjDataCache

ilObjectDataCache ilLDAPRoleGroupMappingSettings::$ilObjDataCache
private

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

◆ $instances

array ilLDAPRoleGroupMappingSettings::$instances = []
staticprivate

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

◆ $lng

ilLanguage ilLDAPRoleGroupMappingSettings::$lng
private

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

◆ $mappings

array ilLDAPRoleGroupMappingSettings::$mappings = []
private

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

Referenced by getMappings().

◆ $rbacreview

ilRbacReview ilLDAPRoleGroupMappingSettings::$rbacreview
private

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

◆ $server_id

int ilLDAPRoleGroupMappingSettings::$server_id
private

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


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