ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilShibbolethRoleAssignmentRule Class Reference

Shibboleth role assignment rule. More...

+ Collaboration diagram for ilShibbolethRoleAssignmentRule:

Public Member Functions

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

Data Fields

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'
 

Protected Member Functions

 wildcardCompare ($a_str1, $a_str2)
 

Protected Attributes

 $db
 

Private Member Functions

 read ()
 

Private Attributes

 $rule_id = 0
 
 $role_id = 0
 
 $attribute_name = ''
 
 $attribute_value = ''
 
 $plugin_active = false
 
 $add_on_update = false
 
 $remove_on_update = false
 
 $plugin_id = 0
 

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

Constructor & Destructor Documentation

◆ __construct()

ilShibbolethRoleAssignmentRule::__construct (   $a_rule_id = 0)
Parameters
int$a_rule_id

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

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

83  {
84  global $DIC;
85  $ilDB = $DIC['ilDB'];
86  $this->db = $ilDB;
87  $this->rule_id = $a_rule_id;
88  $this->read();
89  }
global $ilDB
global $DIC
+ Here is the call graph for this function:

Member Function Documentation

◆ add()

ilShibbolethRoleAssignmentRule::add ( )
Returns
bool

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

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

273  {
274  $next_id = $this->db->nextId(self::TABLE_NAME);
275  $query = 'INSERT INTO ' . self::TABLE_NAME . ' (rule_id,role_id,name,value,plugin,plugin_id,add_on_update,remove_on_update ) ' . 'VALUES( '
276  . $this->db->quote($next_id, 'integer') . ', ' . $this->db->quote($this->getRoleId(), 'integer') . ', '
277  . $this->db->quote($this->getName(), 'text') . ', ' . $this->db->quote($this->getValue(), 'text') . ', '
278  . $this->db->quote((int)$this->isPluginActive(), 'integer') . ', ' . $this->db->quote((int)$this->getPluginId(), 'integer') . ', '
279  . $this->db->quote((int)$this->isAddOnUpdateEnabled(), 'integer') . ', '
280  . $this->db->quote((int)$this->isRemoveOnUpdateEnabled(), 'integer') . ') ';
281  $this->db->manipulate($query);
282  $this->setRuleId($this->db->getLastInsertId());
283 
284  return true;
285  }
+ Here is the call graph for this function:

◆ conditionToString()

ilShibbolethRoleAssignmentRule::conditionToString ( )
Returns
string

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

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

223  {
224  global $DIC;
225  $lng = $DIC['lng'];
226  if ($this->isPluginActive()) {
227  return $lng->txt('shib_plugin_id') . ': ' . $this->getPluginId();
228  } else {
229  return $this->getName() . '=' . $this->getValue();
230  }
231  }
global $lng
Definition: privfeed.php:17
global $DIC
+ Here is the call graph for this function:

◆ delete()

ilShibbolethRoleAssignmentRule::delete ( )
Returns
bool

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

References $query, and getRuleId().

262  {
263  $query = 'DELETE FROM ' . self::TABLE_NAME . ' ' . 'WHERE rule_id = ' . $this->db->quote($this->getRuleId(), 'integer');
264  $this->db->manipulate($query);
265 
266  return true;
267  }
+ Here is the call graph for this function:

◆ doesMatch()

ilShibbolethRoleAssignmentRule::doesMatch ( array  $a_data)
Parameters
array$a_data
Returns
bool

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

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

347  {
348  if ($this->isPluginActive()) {
350  }
351  if (! isset($a_data[$this->getName()])) {
352  return false;
353  }
354  $values = $a_data[$this->getName()];
355  if (is_array($values)) {
356  return in_array($this->getValue(), $values);
357  } else {
358  $pattern = str_replace('*', '.*?', $this->getValue());
359 
360  return (bool)preg_match('/^' . $pattern . '$/us', $values);
361  }
362  }
+ Here is the call graph for this function:

◆ enableAddOnUpdate()

ilShibbolethRoleAssignmentRule::enableAddOnUpdate (   $a_status)
Parameters
$a_status

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

Referenced by read().

175  {
176  $this->add_on_update = $a_status;
177  }
+ Here is the caller graph for this function:

◆ enablePlugin()

ilShibbolethRoleAssignmentRule::enablePlugin (   $a_status)
Parameters
$a_status

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

Referenced by read().

159  {
160  $this->plugin_active = $a_status;
161  }
+ Here is the caller graph for this function:

◆ enableRemoveOnUpdate()

ilShibbolethRoleAssignmentRule::enableRemoveOnUpdate (   $a_status)
Parameters
$a_status

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

Referenced by read().

191  {
192  $this->remove_on_update = $a_status;
193  }
+ Here is the caller graph for this function:

◆ getName()

ilShibbolethRoleAssignmentRule::getName ( )
Returns
string

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

References $attribute_name.

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

+ Here is the caller graph for this function:

◆ getPluginId()

ilShibbolethRoleAssignmentRule::getPluginId ( )
Returns
int

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

References $plugin_id.

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

+ Here is the caller graph for this function:

◆ getRoleId()

ilShibbolethRoleAssignmentRule::getRoleId ( )
Returns
int

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

References $role_id.

Referenced by add(), update(), and validate().

+ Here is the caller graph for this function:

◆ getRuleId()

ilShibbolethRoleAssignmentRule::getRuleId ( )
Returns
int

Definition at line 103 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 ( )
Returns
string

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

References $attribute_value.

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

+ Here is the caller graph for this function:

◆ isAddOnUpdateEnabled()

ilShibbolethRoleAssignmentRule::isAddOnUpdateEnabled ( )
Returns
bool

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

References $add_on_update.

Referenced by add(), and update().

+ Here is the caller graph for this function:

◆ isPluginActive()

ilShibbolethRoleAssignmentRule::isPluginActive ( )
Returns
bool

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

References $plugin_active.

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

+ Here is the caller graph for this function:

◆ isRemoveOnUpdateEnabled()

ilShibbolethRoleAssignmentRule::isRemoveOnUpdateEnabled ( )
Returns
bool

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

References $remove_on_update.

Referenced by add(), and update().

+ Here is the caller graph for this function:

◆ matches()

ilShibbolethRoleAssignmentRule::matches (   $a_data)
Parameters
$a_data
Deprecated:
Returns
bool

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

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

311  {
312  if ($this->isPluginActive()) {
314  }
315  // No value
316  if (! isset($a_data[$this->getName()])) {
317  return false;
318  }
319  $values = $a_data[$this->getName()];
320  if (is_array($values)) {
321  return in_array($this->getValue(), $values);
322  } else {
323  return $this->wildcardCompare($this->getValue(), $values);
324  }
325  }
+ Here is the call graph for this function:

◆ read()

ilShibbolethRoleAssignmentRule::read ( )
private
Returns
bool

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

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

Referenced by __construct().

368  {
369  if (! $this->getRuleId()) {
370  return true;
371  }
372  $query = 'SELECT * FROM ' . self::TABLE_NAME . ' ' . 'WHERE rule_id = ' . $this->db->quote($this->getRuleId(), 'integer');
373  $res = $this->db->query($query);
374  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
375  $this->setRoleId($row->role_id);
376  $this->setName($row->name);
377  $this->setValue($row->value);
378  $this->enablePlugin($row->plugin);
379  $this->setPluginId($row->plugin_id);
380  $this->enableAddOnUpdate($row->add_on_update);
381  $this->enableRemoveOnUpdate($row->remove_on_update);
382  }
383  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setName()

ilShibbolethRoleAssignmentRule::setName (   $a_name)
Parameters
$a_name

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

Referenced by read().

127  {
128  $this->attribute_name = $a_name;
129  }
+ Here is the caller graph for this function:

◆ setPluginId()

ilShibbolethRoleAssignmentRule::setPluginId (   $a_id)
Parameters
$a_id

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

Referenced by read().

207  {
208  $this->plugin_id = $a_id;
209  }
+ Here is the caller graph for this function:

◆ setRoleId()

ilShibbolethRoleAssignmentRule::setRoleId (   $a_id)
Parameters
$a_id

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

Referenced by read().

111  {
112  $this->role_id = $a_id;
113  }
+ Here is the caller graph for this function:

◆ setRuleId()

ilShibbolethRoleAssignmentRule::setRuleId (   $a_id)
Parameters
$a_id

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

Referenced by add().

95  {
96  $this->rule_id = $a_id;
97  }
+ Here is the caller graph for this function:

◆ setValue()

ilShibbolethRoleAssignmentRule::setValue (   $a_value)
Parameters
$a_value

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

Referenced by read().

143  {
144  $this->attribute_value = $a_value;
145  }
+ Here is the caller graph for this function:

◆ update()

ilShibbolethRoleAssignmentRule::update ( )
Returns
bool

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

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

291  {
292  $query = 'UPDATE ' . self::TABLE_NAME . ' ' . 'SET role_id = ' . $this->db->quote($this->getRoleId(), 'integer') . ', ' . 'name = '
293  . $this->db->quote($this->getName(), 'text') . ', ' . 'value = ' . $this->db->quote($this->getValue(), 'text') . ', ' . 'plugin = '
294  . $this->db->quote((int)$this->isPluginActive(), 'integer') . ', ' . 'plugin_id = '
295  . $this->db->quote((int)$this->getPluginId(), 'integer') . ', ' . 'add_on_update = '
296  . $this->db->quote((int)$this->isAddOnUpdateEnabled(), 'integer') . ', ' . 'remove_on_update = '
297  . $this->db->quote((int)$this->isRemoveOnUpdateEnabled(), 'integer') . ' '
298  . 'WHERE rule_id = ' . $this->db->quote($this->getRuleId(), 'integer');
299  $this->db->manipulate($query);
300 
301  return true;
302  }
+ Here is the call graph for this function:

◆ validate()

ilShibbolethRoleAssignmentRule::validate ( )
Returns
string

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

References getName(), getPluginId(), getRoleId(), getValue(), and isPluginActive().

237  {
238  if (! $this->getRoleId()) {
239  return self::ERR_MISSING_ROLE;
240  }
241  if (! $this->isPluginActive()) {
242  if (! $this->getName()) {
243  return self::ERR_MISSING_NAME;
244  }
245  if (! $this->getValue()) {
246  return self::ERR_MISSING_VALUE;
247  }
248  } else {
249  // check plugin id is given
250  if (! $this->getPluginId()) {
251  return self::ERR_MISSING_PLUGIN_ID;
252  }
253  }
254 
255  return '';
256  }
+ Here is the call graph for this function:

◆ wildcardCompare()

ilShibbolethRoleAssignmentRule::wildcardCompare (   $a_str1,
  $a_str2 
)
protected
Parameters
$a_str1
$a_str2
Deprecated:
Returns
bool

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

Referenced by matches().

335  {
336  $pattern = str_replace('*', '.*?', $a_str1);
337 
338  return (bool)preg_match("/" . $pattern . "/us", $a_str2);
339  }
+ Here is the caller graph for this function:

Field Documentation

◆ $add_on_update

ilShibbolethRoleAssignmentRule::$add_on_update = false
private

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

Referenced by isAddOnUpdateEnabled().

◆ $attribute_name

ilShibbolethRoleAssignmentRule::$attribute_name = ''
private

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

Referenced by getName().

◆ $attribute_value

ilShibbolethRoleAssignmentRule::$attribute_value = ''
private

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

Referenced by getValue().

◆ $db

ilShibbolethRoleAssignmentRule::$db
protected

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

◆ $plugin_active

ilShibbolethRoleAssignmentRule::$plugin_active = false
private

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

Referenced by isPluginActive().

◆ $plugin_id

ilShibbolethRoleAssignmentRule::$plugin_id = 0
private

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

Referenced by getPluginId().

◆ $remove_on_update

ilShibbolethRoleAssignmentRule::$remove_on_update = false
private

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

Referenced by isRemoveOnUpdateEnabled().

◆ $role_id

ilShibbolethRoleAssignmentRule::$role_id = 0
private

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

Referenced by getRoleId().

◆ $rule_id

ilShibbolethRoleAssignmentRule::$rule_id = 0
private

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

Referenced by getRuleId().

◆ ERR_MISSING_NAME

const ilShibbolethRoleAssignmentRule::ERR_MISSING_NAME = 'shib_missing_attr_name'

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

◆ ERR_MISSING_PLUGIN_ID

const ilShibbolethRoleAssignmentRule::ERR_MISSING_PLUGIN_ID = 'shib_missing_plugin_id'

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

◆ ERR_MISSING_ROLE

const ilShibbolethRoleAssignmentRule::ERR_MISSING_ROLE = 'shib_missing_role'

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

◆ ERR_MISSING_VALUE

const ilShibbolethRoleAssignmentRule::ERR_MISSING_VALUE = 'shib_missing_attr_value'

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

◆ TABLE_NAME

const ilShibbolethRoleAssignmentRule::TABLE_NAME = 'shib_role_assignment'

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


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