ILIAS  release_8 Revision v8.24
ilShibbolethRoleAssignmentRule Class Reference

Shibboleth role assignment rule. More...

+ Collaboration diagram for ilShibbolethRoleAssignmentRule:

Public Member Functions

 __construct (int $a_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 $rule_id
 
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

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 25 of file class.ilShibbolethRoleAssignmentRule.php.

Constructor & Destructor Documentation

◆ __construct()

ilShibbolethRoleAssignmentRule::__construct ( int  $a_rule_id = 0)

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

44 {
45 global $DIC;
46 $ilDB = $DIC['ilDB'];
47 $this->db = $ilDB;
48 $this->rule_id = $a_rule_id;
49 $this->read();
50 }
global $DIC
Definition: feed.php:28

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

+ Here is the call graph for this function:

Member Function Documentation

◆ add()

ilShibbolethRoleAssignmentRule::add ( )

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

173 : bool
174 {
175 $next_id = $this->db->nextId(self::TABLE_NAME);
176 $query = 'INSERT INTO ' . self::TABLE_NAME . ' (rule_id,role_id,name,value,plugin,plugin_id,add_on_update,remove_on_update ) ' . 'VALUES( '
177 . $this->db->quote($next_id, 'integer') . ', ' . $this->db->quote($this->getRoleId(), 'integer') . ', '
178 . $this->db->quote($this->getName(), 'text') . ', ' . $this->db->quote($this->getValue(), 'text') . ', '
179 . $this->db->quote((int) $this->isPluginActive(), 'integer') . ', ' . $this->db->quote(
180 $this->getPluginId() ?? 0,
181 'integer'
182 ) . ', '
183 . $this->db->quote((int) $this->isAddOnUpdateEnabled(), 'integer') . ', '
184 . $this->db->quote((int) $this->isRemoveOnUpdateEnabled(), 'integer') . ') ';
185 $this->db->manipulate($query);
186 $this->setRuleId($this->db->getLastInsertId());
187
188 return true;
189 }
$query

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

+ Here is the call graph for this function:

◆ conditionToString()

ilShibbolethRoleAssignmentRule::conditionToString ( )

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

132 : ?string
133 {
134 global $DIC;
135 $lng = $DIC['lng'];
136 if ($this->isPluginActive()) {
137 return $lng->txt('shib_plugin_id') . ': ' . $this->getPluginId();
138 }
139
140 return $this->getName() . '=' . $this->getValue();
141 }
$lng

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 162 of file class.ilShibbolethRoleAssignmentRule.php.

162 : bool
163 {
164 $query = 'DELETE FROM ' . self::TABLE_NAME . ' ' . 'WHERE rule_id = ' . $this->db->quote(
165 $this->getRuleId(),
166 'integer'
167 );
168 $this->db->manipulate($query);
169
170 return true;
171 }

References $query, and 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 241 of file class.ilShibbolethRoleAssignmentRule.php.

241 : bool
242 {
243 if ($this->isPluginActive()) {
245 }
246
247 if (!isset($a_data[$this->getName()])) {
248 return false;
249 }
250
251 $values = $a_data[$this->getName()];
252 if (is_array($values)) {
253 return in_array($this->getValue(), $values);
254 }
255
256 $pattern = str_replace('*', '.*?', $this->getValue());
257
258 return (bool) preg_match('/^' . $pattern . '$/us', $values);
259 }
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 102 of file class.ilShibbolethRoleAssignmentRule.php.

102 : void
103 {
104 $this->add_on_update = $a_status;
105 }

Referenced by read().

+ Here is the caller graph for this function:

◆ enablePlugin()

ilShibbolethRoleAssignmentRule::enablePlugin ( bool  $a_status)

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

92 : void
93 {
94 $this->plugin_active = $a_status;
95 }

Referenced by read().

+ Here is the caller graph for this function:

◆ enableRemoveOnUpdate()

ilShibbolethRoleAssignmentRule::enableRemoveOnUpdate ( bool  $a_status)

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

112 : void
113 {
114 $this->remove_on_update = $a_status;
115 }

Referenced by read().

+ Here is the caller graph for this function:

◆ getName()

ilShibbolethRoleAssignmentRule::getName ( )

Definition at line 77 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 127 of file class.ilShibbolethRoleAssignmentRule.php.

127 : ?string
128 {
129 return $this->plugin_id;
130 }

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 57 of file class.ilShibbolethRoleAssignmentRule.php.

References $rule_id.

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

+ Here is the caller graph for this function:

◆ getValue()

ilShibbolethRoleAssignmentRule::getValue ( )

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

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 107 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 97 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 117 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 214 of file class.ilShibbolethRoleAssignmentRule.php.

214 : bool
215 {
216 if ($this->isPluginActive()) {
218 }
219 // No value
220 if (!isset($a_data[$this->getName()])) {
221 return false;
222 }
223 $values = $a_data[$this->getName()];
224 if (is_array($values)) {
225 return in_array($this->getValue(), $values);
226 }
227
228 return $this->wildcardCompare($this->getValue(), $values);
229 }

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

+ Here is the call graph for this function:

◆ read()

ilShibbolethRoleAssignmentRule::read ( )
private

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

261 : void
262 {
263 if ($this->getRuleId() === 0) {
264 return;
265 }
266
267 $query = 'SELECT * FROM ' . self::TABLE_NAME . ' ' . 'WHERE rule_id = ' . $this->db->quote(
268 $this->getRuleId(),
269 'integer'
270 );
271 $res = $this->db->query($query);
272 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
273 $this->setRoleId((int) $row->role_id);
274 $this->setName((string) $row->name);
275 $this->setValue((string) $row->value);
276 $this->enablePlugin((bool) $row->plugin);
277 $this->setPluginId($row->plugin_id);
278 $this->enableAddOnUpdate((bool) $row->add_on_update);
279 $this->enableRemoveOnUpdate((bool) $row->remove_on_update);
280 }
281 }
$res
Definition: ltiservices.php:69

References $query, $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 72 of file class.ilShibbolethRoleAssignmentRule.php.

72 : void
73 {
74 $this->attribute_name = $a_name;
75 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setPluginId()

ilShibbolethRoleAssignmentRule::setPluginId ( ?string  $a_id)

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

122 : void
123 {
124 $this->plugin_id = $a_id;
125 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setRoleId()

ilShibbolethRoleAssignmentRule::setRoleId ( int  $a_id)

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

62 : void
63 {
64 $this->role_id = $a_id;
65 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setRuleId()

ilShibbolethRoleAssignmentRule::setRuleId ( int  $a_id)

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

52 : void
53 {
54 $this->rule_id = $a_id;
55 }

Referenced by add().

+ Here is the caller graph for this function:

◆ setValue()

ilShibbolethRoleAssignmentRule::setValue ( string  $a_value)

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

82 : void
83 {
84 $this->attribute_value = $a_value;
85 }

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilShibbolethRoleAssignmentRule::update ( )

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

191 : bool
192 {
193 $query = 'UPDATE ' . self::TABLE_NAME . ' ' . 'SET role_id = ' . $this->db->quote(
194 $this->getRoleId(),
195 'integer'
196 ) . ', ' . 'name = '
197 . $this->db->quote($this->getName(), 'text') . ', ' . 'value = ' . $this->db->quote(
198 $this->getValue(),
199 'text'
200 ) . ', ' . 'plugin = '
201 . $this->db->quote((int) $this->isPluginActive(), 'integer') . ', ' . 'plugin_id = '
202 . $this->db->quote($this->getPluginId() ?? 0, 'integer') . ', ' . 'add_on_update = '
203 . $this->db->quote((int) $this->isAddOnUpdateEnabled(), 'integer') . ', ' . 'remove_on_update = '
204 . $this->db->quote((int) $this->isRemoveOnUpdateEnabled(), 'integer') . ' '
205 . 'WHERE rule_id = ' . $this->db->quote($this->getRuleId(), 'integer');
206 $this->db->manipulate($query);
207
208 return true;
209 }

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

+ Here is the call graph for this function:

◆ validate()

ilShibbolethRoleAssignmentRule::validate ( )

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

143 : string
144 {
145 if ($this->getRoleId() === 0) {
147 }
148 if (!$this->isPluginActive()) {
149 if ($this->getName() === '' || $this->getName() === '0') {
151 }
152 if ($this->getValue() === '' || $this->getValue() === '0') {
154 }
155 } elseif ($this->getPluginId() === 0) {
157 }
158
159 return '';
160 }

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 234 of file class.ilShibbolethRoleAssignmentRule.php.

234 : bool
235 {
236 $pattern = str_replace('*', '.*?', $a_str1);
237
238 return (bool) preg_match("/" . $pattern . "/us", $a_str2);
239 }

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 39 of file class.ilShibbolethRoleAssignmentRule.php.

Referenced by isAddOnUpdateEnabled().

◆ $attribute_name

string ilShibbolethRoleAssignmentRule::$attribute_name = ''
private

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

Referenced by getName().

◆ $attribute_value

string ilShibbolethRoleAssignmentRule::$attribute_value = ''
private

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

Referenced by getValue().

◆ $db

ilDBInterface ilShibbolethRoleAssignmentRule::$db
private

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

◆ $plugin_active

bool ilShibbolethRoleAssignmentRule::$plugin_active = false
private

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

Referenced by isPluginActive().

◆ $plugin_id

string ilShibbolethRoleAssignmentRule::$plugin_id = null
private

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

Referenced by getPluginId().

◆ $remove_on_update

bool ilShibbolethRoleAssignmentRule::$remove_on_update = false
private

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

Referenced by isRemoveOnUpdateEnabled().

◆ $role_id

int ilShibbolethRoleAssignmentRule::$role_id = 0
private

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

Referenced by getRoleId().

◆ $rule_id

int ilShibbolethRoleAssignmentRule::$rule_id
private

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

Referenced by getRuleId().

◆ ERR_MISSING_NAME

const ilShibbolethRoleAssignmentRule::ERR_MISSING_NAME = 'shib_missing_attr_name'
private

Definition at line 27 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 30 of file class.ilShibbolethRoleAssignmentRule.php.

Referenced by validate().

◆ ERR_MISSING_ROLE

const ilShibbolethRoleAssignmentRule::ERR_MISSING_ROLE = 'shib_missing_role'
private

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

Referenced by validate().

◆ ERR_MISSING_VALUE

const ilShibbolethRoleAssignmentRule::ERR_MISSING_VALUE = 'shib_missing_attr_value'
private

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

Referenced by validate().

◆ TABLE_NAME

const ilShibbolethRoleAssignmentRule::TABLE_NAME = 'shib_role_assignment'
private

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


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