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];
77 $query =
'SELECT COUNT(*) num FROM ldap_role_assignments ' .
78 'WHERE add_on_update = 1 ' .
79 'OR remove_on_update = 1 ';
93 case self::TYPE_PLUGIN:
94 include_once
'./Services/LDAP/classes/class.ilLDAPRoleAssignmentRules.php';
97 case self::TYPE_ATTRIBUTE:
101 if (!isset($a_user_data[$attn])) {
105 if (!is_array($a_user_data[$attn])) {
106 $attribute_val = array(0 => $a_user_data[$attn]);
108 $attribute_val = $a_user_data[$attn];
111 foreach ($attribute_val as $value) {
119 case self::TYPE_GROUP:
127 $pattern = str_replace(
'*',
'.*?', $a_str1);
128 $this->logger->debug(
': Replace pattern:' . $pattern .
' => ' . $a_str2);
129 return (
bool) preg_match(
'/^' . $pattern .
'$/i', $a_str2);
145 if (
$server->enabledEscapeDN()) {
146 $user_cmp = ldap_escape($a_user_data[
'dn'],
"", LDAP_ESCAPE_FILTER);
148 $user_cmp = $a_user_data[
'dn'];
151 $user_cmp = $a_user_data[
'ilExternalAccount'];
167 return $res->numRows() ? true :
false;
169 $this->logger->warning(
': Caught Exception: ' . $e->getMessage());
186 $query =
"SELECT rule_id FROM ldap_role_assignments " .
187 "WHERE server_id = " .
$ilDB->quote($a_server_id,
'integer');
190 $rules[] = self::_getInstanceByRuleId(
$row->rule_id);
192 return $rules ? $rules : array();
204 $this->role_id = $a_role_id;
215 return $this->role_id;
226 return $this->rule_id;
238 $this->server_id = $a_id;
308 $this->member_attribute = $a_attribute;
319 return $this->member_attribute;
331 $this->member_is_dn = $a_status;
342 return (
bool) $this->member_is_dn;
354 $this->attribute_name = $a_name;
365 return $this->attribute_name;
377 $this->attribute_value = $a_value;
388 return $this->attribute_value;
393 $this->add_on_update = $a_status;
403 $this->remove_on_update = $a_status;
413 $this->plugin_id = $a_id;
423 return (
bool) $this->
getType() == self::TYPE_PLUGIN;
438 case self::TYPE_PLUGIN:
441 case self::TYPE_GROUP:
442 $dn_arr = explode(
',', $this->
getDN());
446 case self::TYPE_ATTRIBUTE:
462 $next_id =
$ilDB->nextId(
'ldap_role_assignments');
464 $query =
"INSERT INTO ldap_role_assignments (server_id,rule_id,type,dn,attribute,isdn,att_name,att_value,role_id, " .
465 "add_on_update, remove_on_update, plugin_id ) " .
467 $this->db->quote($this->
getServerId(),
'integer') .
", " .
468 $this->db->quote($next_id,
'integer') .
", " .
469 $this->db->quote($this->
getType(),
'integer') .
", " .
470 $this->db->quote($this->
getDN(),
'text') .
", " .
475 $this->db->quote($this->
getRoleId(),
'integer') .
", " .
478 $this->db->quote($this->
getPluginId(),
'integer') .
' ' .
481 $this->rule_id = $next_id;
496 $query =
"UPDATE ldap_role_assignments " .
497 "SET server_id = " . $this->db->quote($this->
getServerId(),
'integer') .
", " .
498 "type = " . $this->db->quote($this->
getType(),
'integer') .
", " .
499 "dn = " . $this->db->quote($this->
getDN(),
'text') .
", " .
502 "att_name = " . $this->db->quote($this->
getAttributeName(),
'text') .
", " .
504 "role_id = " . $this->db->quote($this->
getRoleId(),
'integer') .
", " .
507 'plugin_id = ' . $this->db->quote($this->
getPluginId(),
'integer') .
' ' .
508 "WHERE rule_id = " . $this->db->quote($this->
getRuleId(),
'integer') .
" ";
528 $ilErr->setMessage(
'fill_out_all_required_fields');
532 case self::TYPE_GROUP:
534 $ilErr->setMessage(
'fill_out_all_required_fields');
538 case self::TYPE_ATTRIBUTE:
540 $ilErr->setMessage(
'fill_out_all_required_fields');
545 case self::TYPE_PLUGIN:
547 $ilErr->setMessage(
'ldap_err_missing_plugin_id');
553 $ilErr->setMessage(
'ldap_no_type_given');
565 public function delete()
569 $query =
"DELETE FROM ldap_role_assignments " .
570 "WHERE rule_id = " . $this->db->quote($this->
getRuleId(),
'integer') .
" ";
584 $query =
"SELECT * FROM ldap_role_assignments " .
585 "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.
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)
setMemberIsDN($a_status)
set member attribute is dn
getAttributeValue()
get atrtibute value
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
setServerId($a_id)
set server id