ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilShibbolethRoleAssignmentRule Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilShibbolethRoleAssignmentRule:

Public Member Functions

 __construct (private int $rule_id=0)
 
 setRuleId (int $a_id)
 
 getRuleId ()
 
 setRoleId (int $a_id)
 
 getRoleId ()
 
 setName (string $a_name)
 
 getName ()
 
 setValue (string $a_value)
 
 getValue ()
 
 enablePlugin (bool $a_status)
 
 isPluginActive ()
 
 enableAddOnUpdate (bool $a_status)
 
 isAddOnUpdateEnabled ()
 
 enableRemoveOnUpdate (bool $a_status)
 
 isRemoveOnUpdateEnabled ()
 
 setPluginId (?string $a_id)
 
 getPluginId ()
 
 conditionToString ()
 
 validate ()
 
 delete ()
 
 add ()
 
 update ()
 
 matches (array $a_data)
 
 doesMatch (array $a_data)
 

Protected Member Functions

 wildcardCompare (string $a_str1, string $a_str2)
 

Private Member Functions

 read ()
 

Private Attributes

const ERR_MISSING_NAME = 'shib_missing_attr_name'
 
const ERR_MISSING_VALUE = 'shib_missing_attr_value'
 
const ERR_MISSING_ROLE = 'shib_missing_role'
 
const ERR_MISSING_PLUGIN_ID = 'shib_missing_plugin_id'
 
const TABLE_NAME = 'shib_role_assignment'
 
ilDBInterface $db
 
int $role_id = 0
 
string $attribute_name = ''
 
string $attribute_value = ''
 
bool $plugin_active = false
 
bool $add_on_update = false
 
bool $remove_on_update = false
 
string $plugin_id = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Shibboleth role assignment rule

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Fabian Schmid fabia.nosp@m.n.sc.nosp@m.hmid@.nosp@m.ilub.nosp@m..unib.nosp@m.e.ch
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilShibbolethRoleAssignmentRule::__construct ( private int  $rule_id = 0)

Definition at line 61 of file class.ilShibbolethRoleAssignmentRule.php.

62 {
63 global $DIC;
64 $this->db = $DIC->database();
65 $this->read();
66 }
global $DIC
Definition: shib_login.php:26

References $DIC, and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ add()

ilShibbolethRoleAssignmentRule::add ( )

Definition at line 189 of file class.ilShibbolethRoleAssignmentRule.php.

189 : bool
190 {
191 $next_id = $this->db->nextId(self::TABLE_NAME);
192 $query = 'INSERT INTO ' . self::TABLE_NAME . ' (rule_id,role_id,name,value,plugin,plugin_id,add_on_update,remove_on_update ) ' . 'VALUES( '
193 . $this->db->quote($next_id, 'integer') . ', ' . $this->db->quote($this->getRoleId(), 'integer') . ', '
194 . $this->db->quote($this->getName(), 'text') . ', ' . $this->db->quote($this->getValue(), 'text') . ', '
195 . $this->db->quote((int) $this->isPluginActive(), 'integer') . ', ' . $this->db->quote(
196 $this->getPluginId() ?? '0',
197 'integer'
198 ) . ', '
199 . $this->db->quote((int) $this->isAddOnUpdateEnabled(), 'integer') . ', '
200 . $this->db->quote((int) $this->isRemoveOnUpdateEnabled(), 'integer') . ') ';
201 $this->db->manipulate($query);
202 $this->setRuleId($this->db->getLastInsertId());
203
204 return true;
205 }

References getName(), getPluginId(), getRoleId(), getValue(), isAddOnUpdateEnabled(), isPluginActive(), isRemoveOnUpdateEnabled(), and setRuleId().

+ Here is the call graph for this function:

◆ conditionToString()

ilShibbolethRoleAssignmentRule::conditionToString ( )

Definition at line 148 of file class.ilShibbolethRoleAssignmentRule.php.

148 : ?string
149 {
150 global $DIC;
151 $lng = $DIC['lng'];
152 if ($this->isPluginActive()) {
153 return $lng->txt('shib_plugin_id') . ': ' . $this->getPluginId();
154 }
155
156 return $this->getName() . '=' . $this->getValue();
157 }
global $lng
Definition: privfeed.php:31

References $DIC, $lng, getName(), getPluginId(), getValue(), and isPluginActive().

Referenced by ilAuthShibbolethSettingsGUI\confirmDeleteRules().

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

◆ delete()

ilShibbolethRoleAssignmentRule::delete ( )

Definition at line 178 of file class.ilShibbolethRoleAssignmentRule.php.

178 : bool
179 {
180 $query = 'DELETE FROM ' . self::TABLE_NAME . ' ' . 'WHERE rule_id = ' . $this->db->quote(
181 $this->getRuleId(),
182 'integer'
183 );
184 $this->db->manipulate($query);
185
186 return true;
187 }

References getRuleId().

Referenced by ilAuthShibbolethSettingsGUI\deleteRules().

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

◆ doesMatch()

ilShibbolethRoleAssignmentRule::doesMatch ( array  $a_data)

Definition at line 257 of file class.ilShibbolethRoleAssignmentRule.php.

257 : bool
258 {
259 if ($this->isPluginActive()) {
261 }
262
263 if (!isset($a_data[$this->getName()])) {
264 return false;
265 }
266
267 $values = $a_data[$this->getName()];
268 if (is_array($values)) {
269 return in_array($this->getValue(), $values);
270 }
271
272 $pattern = str_replace('*', '.*?', $this->getValue());
273
274 return (bool) preg_match('/^' . $pattern . '$/us', (string) $values);
275 }
static callPlugin(string $a_plugin_id, array $a_user_data)

References ilShibbolethRoleAssignmentRules\callPlugin(), getName(), getPluginId(), getValue(), and isPluginActive().

+ Here is the call graph for this function:

◆ enableAddOnUpdate()

ilShibbolethRoleAssignmentRule::enableAddOnUpdate ( bool  $a_status)

Definition at line 118 of file class.ilShibbolethRoleAssignmentRule.php.

118 : void
119 {
120 $this->add_on_update = $a_status;
121 }

Referenced by read().

+ Here is the caller graph for this function:

◆ enablePlugin()

ilShibbolethRoleAssignmentRule::enablePlugin ( bool  $a_status)

Definition at line 108 of file class.ilShibbolethRoleAssignmentRule.php.

108 : void
109 {
110 $this->plugin_active = $a_status;
111 }

Referenced by read().

+ Here is the caller graph for this function:

◆ enableRemoveOnUpdate()

ilShibbolethRoleAssignmentRule::enableRemoveOnUpdate ( bool  $a_status)

Definition at line 128 of file class.ilShibbolethRoleAssignmentRule.php.

128 : void
129 {
130 $this->remove_on_update = $a_status;
131 }

Referenced by read().

+ Here is the caller graph for this function:

◆ getName()

ilShibbolethRoleAssignmentRule::getName ( )

Definition at line 93 of file class.ilShibbolethRoleAssignmentRule.php.

References $attribute_name.

Referenced by add(), conditionToString(), doesMatch(), ilAuthShibbolethSettingsGUI\getRuleValues(), matches(), update(), and validate().

+ Here is the caller graph for this function:

◆ getPluginId()

ilShibbolethRoleAssignmentRule::getPluginId ( )

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

143 : ?string
144 {
145 return $this->plugin_id;
146 }

References $plugin_id.

Referenced by add(), conditionToString(), doesMatch(), ilAuthShibbolethSettingsGUI\getRuleValues(), matches(), update(), and validate().

+ Here is the caller graph for this function:

◆ getRoleId()

ilShibbolethRoleAssignmentRule::getRoleId ( )

◆ getRuleId()

ilShibbolethRoleAssignmentRule::getRuleId ( )

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

73 : int
74 {
75 return $this->rule_id;
76 }

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

+ Here is the caller graph for this function:

◆ getValue()

ilShibbolethRoleAssignmentRule::getValue ( )

Definition at line 103 of file class.ilShibbolethRoleAssignmentRule.php.

103 : string
104 {
106 }

References $attribute_value.

Referenced by add(), conditionToString(), doesMatch(), ilAuthShibbolethSettingsGUI\getRuleValues(), matches(), update(), and validate().

+ Here is the caller graph for this function:

◆ isAddOnUpdateEnabled()

ilShibbolethRoleAssignmentRule::isAddOnUpdateEnabled ( )

Definition at line 123 of file class.ilShibbolethRoleAssignmentRule.php.

References $add_on_update.

Referenced by add(), ilAuthShibbolethSettingsGUI\getRuleValues(), and update().

+ Here is the caller graph for this function:

◆ isPluginActive()

ilShibbolethRoleAssignmentRule::isPluginActive ( )

Definition at line 113 of file class.ilShibbolethRoleAssignmentRule.php.

References $plugin_active.

Referenced by add(), conditionToString(), doesMatch(), ilAuthShibbolethSettingsGUI\getRuleValues(), matches(), update(), and validate().

+ Here is the caller graph for this function:

◆ isRemoveOnUpdateEnabled()

ilShibbolethRoleAssignmentRule::isRemoveOnUpdateEnabled ( )

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

References $remove_on_update.

Referenced by add(), ilAuthShibbolethSettingsGUI\getRuleValues(), and update().

+ Here is the caller graph for this function:

◆ matches()

ilShibbolethRoleAssignmentRule::matches ( array  $a_data)
Deprecated:

Definition at line 230 of file class.ilShibbolethRoleAssignmentRule.php.

230 : bool
231 {
232 if ($this->isPluginActive()) {
234 }
235 // No value
236 if (!isset($a_data[$this->getName()])) {
237 return false;
238 }
239 $values = $a_data[$this->getName()];
240 if (is_array($values)) {
241 return in_array($this->getValue(), $values);
242 }
243
244 return $this->wildcardCompare($this->getValue(), $values);
245 }

References ilShibbolethRoleAssignmentRules\callPlugin(), getName(), getPluginId(), getValue(), isPluginActive(), and wildcardCompare().

+ Here is the call graph for this function:

◆ read()

ilShibbolethRoleAssignmentRule::read ( )
private

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

277 : void
278 {
279 if ($this->getRuleId() === 0) {
280 return;
281 }
282
283 $query = 'SELECT * FROM ' . self::TABLE_NAME . ' ' . 'WHERE rule_id = ' . $this->db->quote(
284 $this->getRuleId(),
285 'integer'
286 );
287 $res = $this->db->query($query);
288 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
289 $this->setRoleId((int) $row->role_id);
290 $this->setName((string) $row->name);
291 $this->setValue((string) $row->value);
292 $this->enablePlugin((bool) $row->plugin);
293 $this->setPluginId($row->plugin_id);
294 $this->enableAddOnUpdate((bool) $row->add_on_update);
295 $this->enableRemoveOnUpdate((bool) $row->remove_on_update);
296 }
297 }
$res
Definition: ltiservices.php:69

References $res, enableAddOnUpdate(), enablePlugin(), enableRemoveOnUpdate(), ilDBConstants\FETCHMODE_OBJECT, getRuleId(), setName(), setPluginId(), setRoleId(), and setValue().

Referenced by __construct().

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

◆ setName()

ilShibbolethRoleAssignmentRule::setName ( string  $a_name)

Definition at line 88 of file class.ilShibbolethRoleAssignmentRule.php.

88 : void
89 {
90 $this->attribute_name = $a_name;
91 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setPluginId()

ilShibbolethRoleAssignmentRule::setPluginId ( ?string  $a_id)

Definition at line 138 of file class.ilShibbolethRoleAssignmentRule.php.

138 : void
139 {
140 $this->plugin_id = $a_id;
141 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setRoleId()

ilShibbolethRoleAssignmentRule::setRoleId ( int  $a_id)

Definition at line 78 of file class.ilShibbolethRoleAssignmentRule.php.

78 : void
79 {
80 $this->role_id = $a_id;
81 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setRuleId()

ilShibbolethRoleAssignmentRule::setRuleId ( int  $a_id)

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

68 : void
69 {
70 $this->rule_id = $a_id;
71 }

Referenced by add().

+ Here is the caller graph for this function:

◆ setValue()

ilShibbolethRoleAssignmentRule::setValue ( string  $a_value)

Definition at line 98 of file class.ilShibbolethRoleAssignmentRule.php.

98 : void
99 {
100 $this->attribute_value = $a_value;
101 }

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilShibbolethRoleAssignmentRule::update ( )

Definition at line 207 of file class.ilShibbolethRoleAssignmentRule.php.

207 : bool
208 {
209 $query = 'UPDATE ' . self::TABLE_NAME . ' ' . 'SET role_id = ' . $this->db->quote(
210 $this->getRoleId(),
211 'integer'
212 ) . ', ' . 'name = '
213 . $this->db->quote($this->getName(), 'text') . ', ' . 'value = ' . $this->db->quote(
214 $this->getValue(),
215 'text'
216 ) . ', ' . 'plugin = '
217 . $this->db->quote((int) $this->isPluginActive(), 'integer') . ', ' . 'plugin_id = '
218 . $this->db->quote($this->getPluginId() ?? '0', 'integer') . ', ' . 'add_on_update = '
219 . $this->db->quote((int) $this->isAddOnUpdateEnabled(), 'integer') . ', ' . 'remove_on_update = '
220 . $this->db->quote((int) $this->isRemoveOnUpdateEnabled(), 'integer') . ' '
221 . 'WHERE rule_id = ' . $this->db->quote($this->getRuleId(), 'integer');
222 $this->db->manipulate($query);
223
224 return true;
225 }

References getName(), getPluginId(), getRoleId(), getRuleId(), getValue(), isAddOnUpdateEnabled(), isPluginActive(), and isRemoveOnUpdateEnabled().

+ Here is the call graph for this function:

◆ validate()

ilShibbolethRoleAssignmentRule::validate ( )

Definition at line 159 of file class.ilShibbolethRoleAssignmentRule.php.

159 : string
160 {
161 if ($this->getRoleId() === 0) {
163 }
164 if (!$this->isPluginActive()) {
165 if ($this->getName() === '' || $this->getName() === '0') {
167 }
168 if ($this->getValue() === '' || $this->getValue() === '0') {
170 }
171 } elseif ($this->getPluginId() === 0) {
173 }
174
175 return '';
176 }

References ERR_MISSING_NAME, ERR_MISSING_PLUGIN_ID, ERR_MISSING_ROLE, ERR_MISSING_VALUE, getName(), getPluginId(), getRoleId(), getValue(), and isPluginActive().

+ Here is the call graph for this function:

◆ wildcardCompare()

ilShibbolethRoleAssignmentRule::wildcardCompare ( string  $a_str1,
string  $a_str2 
)
protected
Deprecated:

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

250 : bool
251 {
252 $pattern = str_replace('*', '.*?', $a_str1);
253
254 return (bool) preg_match("/" . $pattern . "/us", $a_str2);
255 }

Referenced by matches().

+ Here is the caller graph for this function:

Field Documentation

◆ $add_on_update

bool ilShibbolethRoleAssignmentRule::$add_on_update = false
private

Definition at line 57 of file class.ilShibbolethRoleAssignmentRule.php.

Referenced by isAddOnUpdateEnabled().

◆ $attribute_name

string ilShibbolethRoleAssignmentRule::$attribute_name = ''
private

Definition at line 54 of file class.ilShibbolethRoleAssignmentRule.php.

Referenced by getName().

◆ $attribute_value

string ilShibbolethRoleAssignmentRule::$attribute_value = ''
private

Definition at line 55 of file class.ilShibbolethRoleAssignmentRule.php.

Referenced by getValue().

◆ $db

ilDBInterface ilShibbolethRoleAssignmentRule::$db
private

Definition at line 52 of file class.ilShibbolethRoleAssignmentRule.php.

◆ $plugin_active

bool ilShibbolethRoleAssignmentRule::$plugin_active = false
private

Definition at line 56 of file class.ilShibbolethRoleAssignmentRule.php.

Referenced by isPluginActive().

◆ $plugin_id

string ilShibbolethRoleAssignmentRule::$plugin_id = null
private

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

Referenced by getPluginId().

◆ $remove_on_update

bool ilShibbolethRoleAssignmentRule::$remove_on_update = false
private

Definition at line 58 of file class.ilShibbolethRoleAssignmentRule.php.

Referenced by isRemoveOnUpdateEnabled().

◆ $role_id

int ilShibbolethRoleAssignmentRule::$role_id = 0
private

Definition at line 53 of file class.ilShibbolethRoleAssignmentRule.php.

Referenced by getRoleId().

◆ ERR_MISSING_NAME

const ilShibbolethRoleAssignmentRule::ERR_MISSING_NAME = 'shib_missing_attr_name'
private

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

Referenced by validate().

◆ ERR_MISSING_PLUGIN_ID

const ilShibbolethRoleAssignmentRule::ERR_MISSING_PLUGIN_ID = 'shib_missing_plugin_id'
private

Definition at line 46 of file class.ilShibbolethRoleAssignmentRule.php.

Referenced by validate().

◆ ERR_MISSING_ROLE

const ilShibbolethRoleAssignmentRule::ERR_MISSING_ROLE = 'shib_missing_role'
private

Definition at line 42 of file class.ilShibbolethRoleAssignmentRule.php.

Referenced by validate().

◆ ERR_MISSING_VALUE

const ilShibbolethRoleAssignmentRule::ERR_MISSING_VALUE = 'shib_missing_attr_value'
private

Definition at line 38 of file class.ilShibbolethRoleAssignmentRule.php.

Referenced by validate().

◆ TABLE_NAME

const ilShibbolethRoleAssignmentRule::TABLE_NAME = 'shib_role_assignment'
private

Definition at line 50 of file class.ilShibbolethRoleAssignmentRule.php.


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