64 $this->db =
$DIC->database();
70 $this->rule_id = $a_id;
75 return $this->rule_id;
80 $this->role_id = $a_id;
88 public function setName(
string $a_name): void
90 $this->attribute_name = $a_name;
98 public function setValue(
string $a_value): void
100 $this->attribute_value = $a_value;
110 $this->plugin_active = $a_status;
120 $this->add_on_update = $a_status;
130 $this->remove_on_update = $a_status;
140 $this->plugin_id = $a_id;
178 public function delete():
bool
180 $query =
'DELETE FROM ' . self::TABLE_NAME .
' ' .
'WHERE rule_id = ' . $this->db->quote(
184 $this->db->manipulate($query);
189 public function add(): bool
191 $next_id = $this->db->nextId(self::TABLE_NAME);
192 $query =
'INSERT INTO ' . self::TABLE_NAME .
' (rule_id,role_id,name,value,plugin,plugin_id,add_on_update,remove_on_update ) ' .
'VALUES( '
193 . $this->db->quote($next_id,
'integer') .
', ' . $this->db->quote($this->
getRoleId(),
'integer') .
', '
194 . $this->db->quote($this->
getName(),
'text') .
', ' . $this->db->quote($this->
getValue(),
'text') .
', '
195 . $this->db->quote((
int) $this->
isPluginActive(),
'integer') .
', ' . $this->db->quote(
201 $this->db->manipulate($query);
202 $this->
setRuleId($this->db->getLastInsertId());
209 $query =
'UPDATE ' . self::TABLE_NAME .
' ' .
'SET role_id = ' . $this->db->quote(
213 . $this->db->quote($this->
getName(),
'text') .
', ' .
'value = ' . $this->db->quote(
216 ) .
', ' .
'plugin = '
217 . $this->db->quote((
int) $this->
isPluginActive(),
'integer') .
', ' .
'plugin_id = '
218 . $this->db->quote($this->
getPluginId() ??
'0',
'integer') .
', ' .
'add_on_update = '
219 . $this->db->quote((
int) $this->
isAddOnUpdateEnabled(),
'integer') .
', ' .
'remove_on_update = '
221 .
'WHERE rule_id = ' . $this->db->quote($this->
getRuleId(),
'integer');
222 $this->db->manipulate($query);
236 if (!isset($a_data[$this->
getName()])) {
239 $values = $a_data[$this->
getName()];
240 if (is_array($values)) {
241 return in_array($this->
getValue(), $values);
252 $pattern = str_replace(
'*',
'.*?', $a_str1);
254 return (
bool) preg_match(
"/" . $pattern .
"/us", $a_str2);
263 if (!isset($a_data[$this->
getName()])) {
267 $values = $a_data[$this->
getName()];
268 if (is_array($values)) {
269 return in_array($this->
getValue(), $values);
272 $pattern = str_replace(
'*',
'.*?', $this->
getValue());
274 return (
bool) preg_match(
'/^' . $pattern .
'$/us', (
string) $values);
283 $query =
'SELECT * FROM ' . self::TABLE_NAME .
' ' .
'WHERE rule_id = ' . $this->db->quote(
287 $res = $this->db->query($query);
290 $this->
setName((
string) $row->name);
291 $this->
setValue((
string) $row->value);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
enablePlugin(bool $a_status)
__construct(private int $rule_id=0)
const ERR_MISSING_PLUGIN_ID
wildcardCompare(string $a_str1, string $a_str2)
setValue(string $a_value)
enableAddOnUpdate(bool $a_status)
isRemoveOnUpdateEnabled()
setPluginId(?string $a_id)
enableRemoveOnUpdate(bool $a_status)
static callPlugin(string $a_plugin_id, array $a_user_data)