3 declare(strict_types=1);
39 $this->
logger = $DIC->logger()->otpl();
40 $this->db = $DIC->database();
41 $this->review = $DIC->rbac()->review();
42 $this->admin = $DIC->rbac()->admin();
60 $this->action_id = $a_action_id;
63 public function setType(
int $a_type_id): void
65 $this->type = $a_type_id;
70 $this->tpl_id = $a_id;
80 $this->ref_id = $a_ref_id;
99 $this->
setActionId($this->db->nextId(
'didactic_tpl_a'));
100 $query =
'INSERT INTO didactic_tpl_a (id, tpl_id, type_id) ' .
102 $this->db->quote($this->
getActionId(),
'integer') .
', ' .
104 $this->db->quote($this->
getType(),
'integer') .
106 $this->db->manipulate($query);
115 public function delete():
void 117 $query =
'DELETE FROM didactic_tpl_a ' .
118 'WHERE id = ' . $this->db->quote($this->
getActionId(),
'integer');
119 $this->db->manipulate(
$query);
124 $query =
'SELECT * FROM didactic_tpl_a ' .
125 'WHERE id = ' . $this->db->quote($this->
getActionId(),
'integer');
142 abstract public function apply(): bool;
148 abstract public function revert(): bool;
167 self::PATTERN_PARENT_TYPE
171 foreach ($this->review->getParentRoleIds($source->
getRefId()) as $role_id => $role) {
172 $role_id = (
int) $role_id;
173 switch ($this->getFilterType()) {
174 case self::FILTER_PARENT_ROLES:
175 $this->
logger->dump($role);
177 $role[
'assign'] ===
'y' &&
178 (
int) $role[
'parent'] === $source->
getRefId()
181 $this->
logger->debug(
'Excluding local role: ' . $role[
'title']);
184 foreach ($patterns as $pattern) {
187 $filtered[$role_id] = $role;
192 case self::FILTER_LOCAL_ROLES:
194 $role[
'assign'] ===
'n' ||
195 (
int) $role[
'parent'] !== $source->
getRefId()
197 $this->
logger->debug(
'Excluding non local role' . $role[
'title']);
200 foreach ($patterns as $pattern) {
203 $filtered[$role_id] = $role;
209 case self::FILTER_SOURCE_TITLE:
210 foreach ($patterns as $pattern) {
213 $filtered[$role_id] = $role;
const FILTER_PARENT_ROLES
save()
Write action to db Overwrite for filling additional db fields.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
filterRoles(ilObject $source)
getType()
Get type of template.
static _lookupTitle(int $obj_id)
const PATTERN_PARENT_TYPE
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
const FILTER_SOURCE_OBJ_ID
Abstract class for template actions.
static lookupPatternsByParentId(int $a_parent_id, string $a_parent_type)
Class ilRbacAdmin Core functions for role based access control.
__construct(int $action_id=0)
const FILTER_SOURCE_TITLE
setActionId(int $a_action_id)
toXml(ilXmlWriter $writer)
revert()
Implement everthing that is necessary to revert a didactic template return bool.