48 $this->rule_id = $a_rule_id;
54 $this->rule_id = $a_id;
64 $this->role_id = $a_id;
72 public function setName(
string $a_name): void
74 $this->attribute_name = $a_name;
82 public function setValue(
string $a_value): void
84 $this->attribute_value = $a_value;
94 $this->plugin_active = $a_status;
104 $this->add_on_update = $a_status;
114 $this->remove_on_update = $a_status;
124 $this->plugin_id = $a_id;
146 return self::ERR_MISSING_ROLE;
150 return self::ERR_MISSING_NAME;
153 return self::ERR_MISSING_VALUE;
156 return self::ERR_MISSING_PLUGIN_ID;
162 public function delete():
bool 164 $query =
'DELETE FROM ' . self::TABLE_NAME .
' ' .
'WHERE rule_id = ' . $this->db->quote(
168 $this->db->manipulate(
$query);
173 public function add(): bool
175 $next_id = $this->db->nextId(self::TABLE_NAME);
176 $query =
'INSERT INTO ' . self::TABLE_NAME .
' (rule_id,role_id,name,value,plugin,plugin_id,add_on_update,remove_on_update ) ' .
'VALUES( ' 177 . $this->db->quote($next_id,
'integer') .
', ' . $this->db->quote($this->
getRoleId(),
'integer') .
', ' 178 . $this->db->quote($this->
getName(),
'text') .
', ' . $this->db->quote($this->
getValue(),
'text') .
', ' 179 . $this->db->quote((
int) $this->
isPluginActive(),
'integer') .
', ' . $this->db->quote(
185 $this->db->manipulate(
$query);
186 $this->
setRuleId($this->db->getLastInsertId());
193 $query =
'UPDATE ' . self::TABLE_NAME .
' ' .
'SET role_id = ' . $this->db->quote(
197 . $this->db->quote($this->
getName(),
'text') .
', ' .
'value = ' . $this->db->quote(
200 ) .
', ' .
'plugin = ' 201 . $this->db->quote((
int) $this->
isPluginActive(),
'integer') .
', ' .
'plugin_id = ' 202 . $this->db->quote($this->
getPluginId() ?? 0,
'integer') .
', ' .
'add_on_update = ' 203 . $this->db->quote((
int) $this->
isAddOnUpdateEnabled(),
'integer') .
', ' .
'remove_on_update = ' 205 .
'WHERE rule_id = ' . $this->db->quote($this->
getRuleId(),
'integer');
206 $this->db->manipulate(
$query);
220 if (!isset($a_data[$this->
getName()])) {
223 $values = $a_data[$this->
getName()];
224 if (is_array($values)) {
225 return in_array($this->
getValue(), $values);
236 $pattern = str_replace(
'*',
'.*?', $a_str1);
238 return (
bool) preg_match(
"/" . $pattern .
"/us", $a_str2);
247 if (!isset($a_data[$this->
getName()])) {
251 $values = $a_data[$this->
getName()];
252 if (is_array($values)) {
253 return in_array($this->
getValue(), $values);
256 $pattern = str_replace(
'*',
'.*?', $this->
getValue());
258 return (
bool) preg_match(
'/^' . $pattern .
'$/us', $values);
267 $query =
'SELECT * FROM ' . self::TABLE_NAME .
' ' .
'WHERE rule_id = ' . $this->db->quote(
274 $this->
setName((
string) $row->name);
275 $this->
setValue((
string) $row->value);
wildcardCompare(string $a_str1, string $a_str2)
static callPlugin(string $a_plugin_id, array $a_user_data)
enableRemoveOnUpdate(bool $a_status)
isRemoveOnUpdateEnabled()
__construct(int $a_rule_id=0)
enablePlugin(bool $a_status)
setPluginId(?string $a_id)
setValue(string $a_value)
const ERR_MISSING_PLUGIN_ID
enableAddOnUpdate(bool $a_status)
Shibboleth role assignment rule.