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]))
63 return self::$instances[$a_rule_id];
76 $query =
'SELECT COUNT(*) num FROM ldap_role_assignments '.
77 'WHERE add_on_update = 1 '.
78 '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]))
106 if(!is_array($a_user_data[$attn]))
108 $attribute_val =
array(0 => $a_user_data[$attn]);
112 $attribute_val = $a_user_data[$attn];
115 foreach($attribute_val as $value)
125 case self::TYPE_GROUP:
133 $pattern = str_replace(
'*',
'.*?', $a_str1);
134 $this->logger->debug(
': Replace pattern:'. $pattern.
' => '.$a_str2);
135 return (
bool) preg_match(
'/^'.$pattern.
'$/i',$a_str2);
150 $user_cmp = $a_user_data[
'dn'];
154 $user_cmp = $a_user_data[
'ilExternalAccount'];
157 include_once(
'Services/LDAP/classes/class.ilLDAPQuery.php');
158 include_once(
'Services/LDAP/classes/class.ilLDAPServer.php');
172 return $res->numRows() ? true :
false;
176 $this->logger->warning(
': Caught Exception: '.$e->getMessage());
193 $query =
"SELECT rule_id FROM ldap_role_assignments ".
194 "WHERE server_id = ".$ilDB->quote($a_server_id,
'integer');
198 $rules[] = self::_getInstanceByRuleId(
$row->rule_id);
200 return $rules ? $rules :
array();
212 $this->role_id = $a_role_id;
223 return $this->role_id;
234 return $this->rule_id;
246 $this->server_id = $a_id;
316 $this->member_attribute = $a_attribute;
327 return $this->member_attribute;
339 $this->member_is_dn = $a_status;
350 return (
bool) $this->member_is_dn;
362 $this->attribute_name = $a_name;
373 return $this->attribute_name;
385 $this->attribute_value = $a_value;
396 return $this->attribute_value;
401 $this->add_on_update = $a_status;
411 $this->remove_on_update = $a_status;
421 $this->plugin_id = $a_id;
431 return (
bool) $this->
getType() == self::TYPE_PLUGIN;
447 case self::TYPE_PLUGIN:
450 case self::TYPE_GROUP:
451 $dn_arr = explode(
',',$this->
getDN());
455 case self::TYPE_ATTRIBUTE:
471 $next_id =
$ilDB->nextId(
'ldap_role_assignments');
473 $query =
"INSERT INTO ldap_role_assignments (server_id,rule_id,type,dn,attribute,isdn,att_name,att_value,role_id, ".
474 "add_on_update, remove_on_update, plugin_id ) ".
476 $this->db->quote($this->
getServerId(),
'integer').
", ".
477 $this->db->quote($next_id,
'integer').
", ".
478 $this->db->quote($this->
getType(),
'integer').
", ".
479 $this->db->quote($this->
getDN(),
'text').
", ".
484 $this->db->quote($this->
getRoleId(),
'integer').
", ".
487 $this->db->quote($this->
getPluginId(),
'integer').
' '.
490 $this->rule_id = $next_id;
505 $query =
"UPDATE ldap_role_assignments ".
506 "SET server_id = ".$this->db->quote($this->
getServerId(),
'integer').
", ".
507 "type = ".$this->db->quote($this->
getType(),
'integer').
", ".
508 "dn = ".$this->db->quote($this->
getDN(),
'text').
", ".
513 "role_id = ".$this->db->quote($this->
getRoleId(),
'integer').
", ".
516 'plugin_id = '.$this->db->quote($this->
getPluginId(),
'integer').
' '.
517 "WHERE rule_id = ".$this->db->quote($this->
getRuleId(),
'integer').
" ";
532 $ilErr->setMessage(
'');
536 $ilErr->setMessage(
'fill_out_all_required_fields');
541 case self::TYPE_GROUP:
544 $ilErr->setMessage(
'fill_out_all_required_fields');
548 case self::TYPE_ATTRIBUTE:
551 $ilErr->setMessage(
'fill_out_all_required_fields');
556 case self::TYPE_PLUGIN:
559 $ilErr->setMessage(
'ldap_err_missing_plugin_id');
565 $ilErr->setMessage(
'ldap_no_type_given');
577 public function delete()
581 $query =
"DELETE FROM ldap_role_assignments ".
582 "WHERE rule_id = ".$this->db->quote($this->
getRuleId(),
'integer').
" ";
597 $query =
"SELECT * FROM ldap_role_assignments ".
598 "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()
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