44 $this->db =
$GLOBALS[
'DIC']->database();
45 $this->logger =
$GLOBALS[
'DIC']->logger()->auth();
47 $this->rule_id = $a_id;
61 if (isset(self::$instances[$a_rule_id])) {
62 return self::$instances[$a_rule_id];
75 $query =
'SELECT COUNT(*) num FROM ldap_role_assignments ' .
76 'WHERE add_on_update = 1 ' .
77 'OR remove_on_update = 1 ';
91 case self::TYPE_PLUGIN:
92 include_once
'./Services/LDAP/classes/class.ilLDAPRoleAssignmentRules.php';
95 case self::TYPE_ATTRIBUTE:
99 if (!isset($a_user_data[$attn])) {
103 if (!is_array($a_user_data[$attn])) {
104 $attribute_val =
array(0 => $a_user_data[$attn]);
106 $attribute_val = $a_user_data[$attn];
109 foreach ($attribute_val as $value) {
117 case self::TYPE_GROUP:
125 $pattern = str_replace(
'*',
'.*?', $a_str1);
126 $this->logger->debug(
': Replace pattern:' . $pattern .
' => ' . $a_str2);
127 return (
bool) preg_match(
'/^' . $pattern .
'$/i', $a_str2);
141 $user_cmp = $a_user_data[
'dn'];
143 $user_cmp = $a_user_data[
'ilExternalAccount'];
146 include_once(
'Services/LDAP/classes/class.ilLDAPQuery.php');
147 include_once(
'Services/LDAP/classes/class.ilLDAPServer.php');
164 return $res->numRows() ? true :
false;
166 $this->logger->warning(
': Caught Exception: ' . $e->getMessage());
183 $query =
"SELECT rule_id FROM ldap_role_assignments " .
184 "WHERE server_id = " .
$ilDB->quote($a_server_id,
'integer');
187 $rules[] = self::_getInstanceByRuleId(
$row->rule_id);
189 return $rules ? $rules :
array();
201 $this->role_id = $a_role_id;
212 return $this->role_id;
223 return $this->rule_id;
235 $this->server_id = $a_id;
305 $this->member_attribute = $a_attribute;
316 return $this->member_attribute;
328 $this->member_is_dn = $a_status;
339 return (
bool) $this->member_is_dn;
351 $this->attribute_name = $a_name;
362 return $this->attribute_name;
374 $this->attribute_value = $a_value;
385 return $this->attribute_value;
390 $this->add_on_update = $a_status;
400 $this->remove_on_update = $a_status;
410 $this->plugin_id = $a_id;
420 return (
bool) $this->
getType() == self::TYPE_PLUGIN;
435 case self::TYPE_PLUGIN:
438 case self::TYPE_GROUP:
439 $dn_arr = explode(
',', $this->
getDN());
443 case self::TYPE_ATTRIBUTE:
459 $next_id =
$ilDB->nextId(
'ldap_role_assignments');
461 $query =
"INSERT INTO ldap_role_assignments (server_id,rule_id,type,dn,attribute,isdn,att_name,att_value,role_id, " .
462 "add_on_update, remove_on_update, plugin_id ) " .
464 $this->db->quote($this->
getServerId(),
'integer') .
", " .
465 $this->db->quote($next_id,
'integer') .
", " .
466 $this->db->quote($this->
getType(),
'integer') .
", " .
467 $this->db->quote($this->
getDN(),
'text') .
", " .
472 $this->db->quote($this->
getRoleId(),
'integer') .
", " .
475 $this->db->quote($this->
getPluginId(),
'integer') .
' ' .
478 $this->rule_id = $next_id;
493 $query =
"UPDATE ldap_role_assignments " .
494 "SET server_id = " . $this->db->quote($this->
getServerId(),
'integer') .
", " .
495 "type = " . $this->db->quote($this->
getType(),
'integer') .
", " .
496 "dn = " . $this->db->quote($this->
getDN(),
'text') .
", " .
499 "att_name = " . $this->db->quote($this->
getAttributeName(),
'text') .
", " .
501 "role_id = " . $this->db->quote($this->
getRoleId(),
'integer') .
", " .
504 'plugin_id = ' . $this->db->quote($this->
getPluginId(),
'integer') .
' ' .
505 "WHERE rule_id = " . $this->db->quote($this->
getRuleId(),
'integer') .
" ";
520 $ilErr->setMessage(
'');
523 $ilErr->setMessage(
'fill_out_all_required_fields');
527 case self::TYPE_GROUP:
529 $ilErr->setMessage(
'fill_out_all_required_fields');
533 case self::TYPE_ATTRIBUTE:
535 $ilErr->setMessage(
'fill_out_all_required_fields');
540 case self::TYPE_PLUGIN:
542 $ilErr->setMessage(
'ldap_err_missing_plugin_id');
548 $ilErr->setMessage(
'ldap_no_type_given');
560 public function delete()
564 $query =
"DELETE FROM ldap_role_assignments " .
565 "WHERE rule_id = " . $this->db->quote($this->
getRuleId(),
'integer') .
" ";
579 $query =
"SELECT * FROM ldap_role_assignments " .
580 "WHERE rule_id = " . $this->db->quote($this->
getRuleId(),
'integer') .
" ";
static hasRulesForUpdate()
Check if there any rule for updates.
matches($a_user_data)
Check if a rule matches.
enableRemoveOnUpdate($a_status)
getMemberAttribute()
get attribute
setAttributeName($a_name)
set attribute name
__construct($a_id=0)
Constructor.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
isMemberAttributeDN()
is member attribute dn
static _lookupTitle($a_id)
lookup object title
isGroupMember($a_user_data)
Check if user is member of specific group.
setAttributeValue($a_value)
set attribute value
static getInstanceByServerId($a_server_id)
Get instance by server id.
static _getRules($a_server_id)
Get all rules.
getServerId()
get server id
wildcardCompare($a_str1, $a_str2)
getAttributeName()
get attribute name
static callPlugin($a_plugin_id, $a_user_data)
Call plugin check if the condition matches.
isRemoveOnUpdateEnabled()
foreach($_POST as $key=> $value) $res
setRoleId($a_role_id)
set role id
static _getInstanceByRuleId($a_rule_id)
get instance by rule id
conditionToString()
condition to string
setMemberAttribute($a_attribute)
public
enableAddOnUpdate($a_status)
Create styles array
The data for the language used.
setMemberIsDN($a_status)
set member attribute is dn
getAttributeValue()
get atrtibute value
setServerId($a_id)
set server id