ILIAS  release_8 Revision v8.24
ilDidacticTemplateAction Class Reference

Abstract class for template actions. More...

+ Inheritance diagram for ilDidacticTemplateAction:
+ Collaboration diagram for ilDidacticTemplateAction:

Public Member Functions

 __construct (int $action_id=0)
 
 getLogger ()
 
 getActionId ()
 
 setActionId (int $a_action_id)
 
 setType (int $a_type_id)
 
 setTemplateId (int $a_id)
 
 getTemplateId ()
 
 setRefId (int $a_ref_id)
 
 getRefId ()
 
 save ()
 Write action to db Overwrite for filling additional db fields. More...
 
 delete ()
 Delete didactic template action Overwrite for filling additional db fields. More...
 
 read ()
 
 getType ()
 Get type of template. More...
 
 apply ()
 Apply action. More...
 
 revert ()
 Implement everthing that is necessary to revert a didactic template return bool. More...
 
 __clone ()
 
 toXml (ilXmlWriter $writer)
 

Data Fields

const TYPE_LOCAL_POLICY = 1
 
const TYPE_LOCAL_ROLE = 2
 
const TYPE_BLOCK_ROLE = 3
 
const FILTER_SOURCE_TITLE = 1
 
const FILTER_SOURCE_OBJ_ID = 2
 
const FILTER_PARENT_ROLES = 3
 
const FILTER_LOCAL_ROLES = 4
 
const PATTERN_PARENT_TYPE = 'action'
 

Protected Member Functions

 initSourceObject ()
 
 filterRoles (ilObject $source)
 

Protected Attributes

ilLogger $logger
 
ilDBInterface $db
 
ilRbacReview $review
 
ilRbacAdmin $admin
 

Private Attributes

int $action_id = 0
 
int $tpl_id = 0
 
int $type = 0
 
int $ref_id = 0
 

Detailed Description

Abstract class for template actions.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 11 of file class.ilDidacticTemplateAction.php.

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateAction::__construct ( int  $action_id = 0)

Reimplemented in ilDidacticTemplateLocalRoleAction, ilDidacticTemplateBlockRoleAction, and ilDidacticTemplateLocalPolicyAction.

Definition at line 35 of file class.ilDidacticTemplateAction.php.

36 {
37 global $DIC;
38
39 $this->logger = $DIC->logger()->otpl();
40 $this->db = $DIC->database();
41 $this->review = $DIC->rbac()->review();
42 $this->admin = $DIC->rbac()->admin();
43
44 $this->setActionId($action_id);
45 $this->read();
46 }
global $DIC
Definition: feed.php:28

References $DIC, ILIAS\Repository\logger(), read(), and setActionId().

+ Here is the call graph for this function:

Member Function Documentation

◆ __clone()

ilDidacticTemplateAction::__clone ( )

Reimplemented in ilDidacticTemplateBlockRoleAction, and ilDidacticTemplateLocalPolicyAction.

Definition at line 150 of file class.ilDidacticTemplateAction.php.

151 {
152 $this->setActionId(0);
153 }

References setActionId().

+ Here is the call graph for this function:

◆ apply()

ilDidacticTemplateAction::apply ( )
abstract

◆ delete()

ilDidacticTemplateAction::delete ( )

Delete didactic template action Overwrite for filling additional db fields.

Reimplemented in ilDidacticTemplateBlockRoleAction, ilDidacticTemplateLocalPolicyAction, and ilDidacticTemplateLocalRoleAction.

Definition at line 115 of file class.ilDidacticTemplateAction.php.

115 : void
116 {
117 $query = 'DELETE FROM didactic_tpl_a ' .
118 'WHERE id = ' . $this->db->quote($this->getActionId(), 'integer');
119 $this->db->manipulate($query);
120 }
$query

References $query, and getActionId().

+ Here is the call graph for this function:

◆ filterRoles()

ilDidacticTemplateAction::filterRoles ( ilObject  $source)
protected

Definition at line 163 of file class.ilDidacticTemplateAction.php.

163 : array
164 {
166 $this->getActionId(),
167 self::PATTERN_PARENT_TYPE
168 );
169
170 $filtered = array();
171 foreach ($this->review->getParentRoleIds($source->getRefId()) as $role_id => $role) {
172 $role_id = (int) $role_id;
173 switch ($this->getFilterType()) {
175 $this->logger->dump($role);
176 if (
177 $role['assign'] === 'y' &&
178 (int) $role['parent'] === $source->getRefId()
179
180 ) {
181 $this->logger->debug('Excluding local role: ' . $role['title']);
182 break;
183 }
184 foreach ($patterns as $pattern) {
185 if ($pattern->valid(ilObject::_lookupTitle($role_id))) {
186 $this->logger->debug('Role is valid: ' . ilObject::_lookupTitle($role_id));
187 $filtered[$role_id] = $role;
188 }
189 }
190 break;
191
193 if (
194 $role['assign'] === 'n' ||
195 (int) $role['parent'] !== $source->getRefId()
196 ) {
197 $this->logger->debug('Excluding non local role' . $role['title']);
198 break;
199 }
200 foreach ($patterns as $pattern) {
201 if ($pattern->valid(ilObject::_lookupTitle($role_id))) {
202 $this->logger->debug('Role is valid ' . ilObject::_lookupTitle($role_id));
203 $filtered[$role_id] = $role;
204 }
205 }
206 break;
207
208 default:
210 foreach ($patterns as $pattern) {
211 if ($pattern->valid(ilObject::_lookupTitle($role_id))) {
212 $this->logger->debug('Role is valid: ' . ilObject::_lookupTitle($role_id));
213 $filtered[$role_id] = $role;
214 }
215 }
216 break;
217 }
218 }
219
220 return $filtered;
221 }
static lookupPatternsByParentId(int $a_parent_id, string $a_parent_type)
static _lookupTitle(int $obj_id)
$source
Definition: metadata.php:93

References $source, ilObject\_lookupTitle(), FILTER_LOCAL_ROLES, FILTER_PARENT_ROLES, FILTER_SOURCE_TITLE, getActionId(), ILIAS\Repository\int(), ILIAS\Repository\logger(), and ilDidacticTemplateFilterPatternFactory\lookupPatternsByParentId().

Referenced by ilDidacticTemplateBlockRoleAction\apply(), ilDidacticTemplateLocalPolicyAction\apply(), ilDidacticTemplateBlockRoleAction\revert(), and ilDidacticTemplateLocalPolicyAction\revert().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActionId()

◆ getLogger()

ilDidacticTemplateAction::getLogger ( )

Definition at line 48 of file class.ilDidacticTemplateAction.php.

48 : ilLogger
49 {
50 return $this->logger;
51 }
Component logger with individual log levels by component id.

References $logger.

Referenced by ilDidacticTemplateLocalPolicyAction\apply(), ilDidacticTemplateLocalPolicyAction\createLocalPolicy(), and ilDidacticTemplateLocalPolicyAction\revert().

+ Here is the caller graph for this function:

◆ getRefId()

ilDidacticTemplateAction::getRefId ( )

Definition at line 83 of file class.ilDidacticTemplateAction.php.

83 : int
84 {
85 return $this->ref_id;
86 }

References $ref_id.

Referenced by ilDidacticTemplateLocalRoleAction\apply(), and initSourceObject().

+ Here is the caller graph for this function:

◆ getTemplateId()

ilDidacticTemplateAction::getTemplateId ( )

Definition at line 73 of file class.ilDidacticTemplateAction.php.

73 : int
74 {
75 return $this->tpl_id;
76 }

References $tpl_id.

Referenced by save().

+ Here is the caller graph for this function:

◆ getType()

ilDidacticTemplateAction::getType ( )
abstract

Get type of template.

Returns
int $type

Reimplemented in ilDidacticTemplateBlockRoleAction, ilDidacticTemplateLocalPolicyAction, and ilDidacticTemplateLocalRoleAction.

Referenced by save().

+ Here is the caller graph for this function:

◆ initSourceObject()

ilDidacticTemplateAction::initSourceObject ( )
protected

Definition at line 157 of file class.ilDidacticTemplateAction.php.

157 : ilObject
158 {
159 $s = ilObjectFactory::getInstanceByRefId($this->getRefId(), false);
160 return $s;
161 }
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ilObjectFactory\getInstanceByRefId(), and getRefId().

Referenced by ilDidacticTemplateBlockRoleAction\apply(), ilDidacticTemplateLocalPolicyAction\apply(), ilDidacticTemplateLocalRoleAction\apply(), ilDidacticTemplateBlockRoleAction\revert(), and ilDidacticTemplateLocalPolicyAction\revert().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilDidacticTemplateAction::read ( )

Reimplemented in ilDidacticTemplateBlockRoleAction, ilDidacticTemplateLocalPolicyAction, and ilDidacticTemplateLocalRoleAction.

Definition at line 122 of file class.ilDidacticTemplateAction.php.

122 : void
123 {
124 $query = 'SELECT * FROM didactic_tpl_a ' .
125 'WHERE id = ' . $this->db->quote($this->getActionId(), 'integer');
126 $res = $this->db->query($query);
127 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
128 $this->setTemplateId((int) $row->tpl_id);
129 }
130 }
$res
Definition: ltiservices.php:69

References $query, $res, ilDBConstants\FETCHMODE_OBJECT, getActionId(), and setTemplateId().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ revert()

ilDidacticTemplateAction::revert ( )
abstract

Implement everthing that is necessary to revert a didactic template return bool.

Reimplemented in ilDidacticTemplateBlockRoleAction, ilDidacticTemplateLocalPolicyAction, and ilDidacticTemplateLocalRoleAction.

◆ save()

ilDidacticTemplateAction::save ( )

Write action to db Overwrite for filling additional db fields.

Returns
int

Reimplemented in ilDidacticTemplateBlockRoleAction, ilDidacticTemplateLocalPolicyAction, and ilDidacticTemplateLocalRoleAction.

Definition at line 93 of file class.ilDidacticTemplateAction.php.

93 : int
94 {
95 if ($this->getActionId()) {
96 return 0;
97 }
98
99 $this->setActionId($this->db->nextId('didactic_tpl_a'));
100 $query = 'INSERT INTO didactic_tpl_a (id, tpl_id, type_id) ' .
101 'VALUES( ' .
102 $this->db->quote($this->getActionId(), 'integer') . ', ' .
103 $this->db->quote($this->getTemplateId(), 'integer') . ', ' .
104 $this->db->quote($this->getType(), 'integer') .
105 ')';
106 $this->db->manipulate($query);
107
108 return $this->getActionId();
109 }
getType()
Get type of template.

References $query, getActionId(), getTemplateId(), getType(), and setActionId().

+ Here is the call graph for this function:

◆ setActionId()

ilDidacticTemplateAction::setActionId ( int  $a_action_id)

Definition at line 58 of file class.ilDidacticTemplateAction.php.

58 : void
59 {
60 $this->action_id = $a_action_id;
61 }

Referenced by __clone(), __construct(), and save().

+ Here is the caller graph for this function:

◆ setRefId()

ilDidacticTemplateAction::setRefId ( int  $a_ref_id)

Definition at line 78 of file class.ilDidacticTemplateAction.php.

78 : void
79 {
80 $this->ref_id = $a_ref_id;
81 }

◆ setTemplateId()

ilDidacticTemplateAction::setTemplateId ( int  $a_id)

Definition at line 68 of file class.ilDidacticTemplateAction.php.

68 : void
69 {
70 $this->tpl_id = $a_id;
71 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setType()

ilDidacticTemplateAction::setType ( int  $a_type_id)

Definition at line 63 of file class.ilDidacticTemplateAction.php.

63 : void
64 {
65 $this->type = $a_type_id;
66 }

◆ toXml()

ilDidacticTemplateAction::toXml ( ilXmlWriter  $writer)
abstract

Field Documentation

◆ $action_id

◆ $admin

ilRbacAdmin ilDidacticTemplateAction::$admin
protected

Definition at line 27 of file class.ilDidacticTemplateAction.php.

◆ $db

ilDBInterface ilDidacticTemplateAction::$db
protected

Definition at line 25 of file class.ilDidacticTemplateAction.php.

◆ $logger

ilLogger ilDidacticTemplateAction::$logger
protected

Definition at line 24 of file class.ilDidacticTemplateAction.php.

Referenced by getLogger().

◆ $ref_id

int ilDidacticTemplateAction::$ref_id = 0
private

Definition at line 33 of file class.ilDidacticTemplateAction.php.

Referenced by getRefId().

◆ $review

ilRbacReview ilDidacticTemplateAction::$review
protected

Definition at line 26 of file class.ilDidacticTemplateAction.php.

◆ $tpl_id

int ilDidacticTemplateAction::$tpl_id = 0
private

Definition at line 30 of file class.ilDidacticTemplateAction.php.

Referenced by getTemplateId().

◆ $type

int ilDidacticTemplateAction::$type = 0
private

Definition at line 31 of file class.ilDidacticTemplateAction.php.

◆ FILTER_LOCAL_ROLES

const ilDidacticTemplateAction::FILTER_LOCAL_ROLES = 4

◆ FILTER_PARENT_ROLES

◆ FILTER_SOURCE_OBJ_ID

const ilDidacticTemplateAction::FILTER_SOURCE_OBJ_ID = 2

◆ FILTER_SOURCE_TITLE

◆ PATTERN_PARENT_TYPE

const ilDidacticTemplateAction::PATTERN_PARENT_TYPE = 'action'

Definition at line 22 of file class.ilDidacticTemplateAction.php.

◆ TYPE_BLOCK_ROLE

◆ TYPE_LOCAL_POLICY

◆ TYPE_LOCAL_ROLE


The documentation for this class was generated from the following file: