60 $this->rule_id = $a_id;
74 if(isset(self::$instances[$a_rule_id]))
76 return self::$instances[$a_rule_id];
89 $query =
'SELECT COUNT(*) num FROM ldap_role_assignments '.
90 'WHERE add_on_update = 1 '.
91 'OR remove_on_update = 1 ';
108 case self::TYPE_PLUGIN:
109 include_once
'./Services/LDAP/classes/class.ilLDAPRoleAssignmentRules.php';
112 case self::TYPE_ATTRIBUTE:
116 if(!isset($a_user_data[$attn]))
121 if(!is_array($a_user_data[$attn]))
123 $attribute_val = array(0 => $a_user_data[$attn]);
127 $attribute_val = $a_user_data[$attn];
130 foreach($attribute_val as $value)
147 case self::TYPE_GROUP:
155 $pattern = str_replace(
'*',
'.*?', $a_str1);
156 $GLOBALS[
'ilLog']->write(__METHOD__.
': Replace pattern:'. $pattern.
' => '.$a_str2);
157 return (
bool) preg_match(
'/^'.$pattern.
'$/i',$a_str2);
175 $user_cmp = $a_user_data[
'dn'];
179 $user_cmp = $a_user_data[
'ilExternalAccount'];
182 include_once(
'Services/LDAP/classes/class.ilLDAPQuery.php');
183 include_once(
'Services/LDAP/classes/class.ilLDAPServer.php');
197 return $res->numRows() ?
true :
false;
201 $ilLog->write(__METHOD__.
': Caught Exception: '.$e->getMessage());
218 $query =
"SELECT rule_id FROM ldap_role_assignments ";
224 return $rules ? $rules : array();
236 $this->role_id = $a_role_id;
247 return $this->role_id;
258 return $this->rule_id;
270 $this->server_id = $a_id;
293 $this->type = $a_type;
340 $this->member_attribute = $a_attribute;
351 return $this->member_attribute;
363 $this->member_is_dn = $a_status;
374 return (
bool) $this->member_is_dn;
386 $this->attribute_name = $a_name;
397 return $this->attribute_name;
409 $this->attribute_value = $a_value;
420 return $this->attribute_value;
425 $this->add_on_update = $a_status;
435 $this->remove_on_update = $a_status;
445 $this->plugin_id = $a_id;
471 case self::TYPE_PLUGIN:
472 return $lng->txt(
'ldap_plugin_id').
': '.$this->
getPluginId();
474 case self::TYPE_GROUP:
475 $dn_arr = explode(
',',$this->
getDN());
479 case self::TYPE_ATTRIBUTE:
496 $next_id = $ilDB->nextId(
'ldap_role_assignments');
498 $query =
"INSERT INTO ldap_role_assignments (server_id,rule_id,type,dn,attribute,isdn,att_name,att_value,role_id, ".
499 "add_on_update, remove_on_update, plugin_id ) ".
501 $this->db->quote($this->
getServerId(),
'integer').
", ".
502 $this->db->quote($next_id,
'integer').
", ".
503 $this->db->quote($this->
getType(),
'integer').
", ".
504 $this->db->quote($this->
getDN(),
'text').
", ".
509 $this->db->quote($this->
getRoleId(),
'integer').
", ".
512 $this->db->quote($this->
getPluginId(),
'integer').
' '.
515 $this->rule_id = $next_id;
530 $query =
"UPDATE ldap_role_assignments ".
531 "SET server_id = ".$this->db->quote($this->
getServerId(),
'integer').
", ".
532 "type = ".$this->db->quote($this->
getType(),
'integer').
", ".
533 "dn = ".$this->db->quote($this->
getDN(),
'text').
", ".
538 "role_id = ".$this->db->quote($this->
getRoleId(),
'integer').
", ".
541 'plugin_id = '.$this->db->quote($this->
getPluginId(),
'integer').
' '.
542 "WHERE rule_id = ".$this->db->quote($this->
getRuleId(),
'integer').
" ";
557 $ilErr->setMessage(
'');
561 $ilErr->setMessage(
'fill_out_all_required_fields');
566 case self::TYPE_GROUP:
569 $ilErr->setMessage(
'fill_out_all_required_fields');
573 case self::TYPE_ATTRIBUTE:
576 $ilErr->setMessage(
'fill_out_all_required_fields');
581 case self::TYPE_PLUGIN:
584 $ilErr->setMessage(
'ldap_err_missing_plugin_id');
590 $ilErr->setMessage(
'ldap_no_type_given');
602 public function delete()
606 $query =
"DELETE FROM ldap_role_assignments ".
607 "WHERE rule_id = ".$this->db->quote($this->
getRuleId(),
'integer').
" ";
622 $query =
"SELECT * FROM ldap_role_assignments ".
623 "WHERE rule_id = ".$this->db->quote($this->
getRuleId(),
'integer').
" ";