ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 25 of file class.ilDidacticTemplateAction.php.

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateAction::__construct ( int  $action_id = 0)

Reimplemented in ilDidacticTemplateLocalRoleAction, ilDidacticTemplateBlockRoleAction, and ilDidacticTemplateLocalPolicyAction.

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

50 {
51 global $DIC;
52
53 $this->logger = $DIC->logger()->otpl();
54 $this->db = $DIC->database();
55 $this->review = $DIC->rbac()->review();
56 $this->admin = $DIC->rbac()->admin();
57
58 $this->setActionId($action_id);
59 $this->read();
60 }
global $DIC
Definition: shib_login.php:26

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 164 of file class.ilDidacticTemplateAction.php.

165 {
166 $this->setActionId(0);
167 }

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 129 of file class.ilDidacticTemplateAction.php.

129 : void
130 {
131 $query = 'DELETE FROM didactic_tpl_a ' .
132 'WHERE id = ' . $this->db->quote($this->getActionId(), 'integer');
133 $this->db->manipulate($query);
134 }

References getActionId().

+ Here is the call graph for this function:

◆ filterRoles()

ilDidacticTemplateAction::filterRoles ( ilObject  $source)
protected

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

177 : array
178 {
180 $this->getActionId(),
181 self::PATTERN_PARENT_TYPE
182 );
183
184 $filtered = array();
185 foreach ($this->review->getParentRoleIds($source->getRefId()) as $role_id => $role) {
186 $role_id = (int) $role_id;
187 switch ($this->getFilterType()) {
189 $this->logger->dump($role);
190 if (
191 $role['assign'] === 'y' &&
192 (int) $role['parent'] === $source->getRefId()
193
194 ) {
195 $this->logger->debug('Excluding local role: ' . $role['title']);
196 break;
197 }
198 foreach ($patterns as $pattern) {
199 if ($pattern->valid(ilObject::_lookupTitle($role_id))) {
200 $this->logger->debug('Role is valid: ' . ilObject::_lookupTitle($role_id));
201 $filtered[$role_id] = $role;
202 }
203 }
204 break;
205
207 if (
208 $role['assign'] === 'n' ||
209 (int) $role['parent'] !== $source->getRefId()
210 ) {
211 $this->logger->debug('Excluding non local role' . $role['title']);
212 break;
213 }
214 foreach ($patterns as $pattern) {
215 if ($pattern->valid(ilObject::_lookupTitle($role_id))) {
216 $this->logger->debug('Role is valid ' . ilObject::_lookupTitle($role_id));
217 $filtered[$role_id] = $role;
218 }
219 }
220 break;
221
222 default:
224 foreach ($patterns as $pattern) {
225 if ($pattern->valid(ilObject::_lookupTitle($role_id))) {
226 $this->logger->debug('Role is valid: ' . ilObject::_lookupTitle($role_id));
227 $filtered[$role_id] = $role;
228 }
229 }
230 break;
231 }
232 }
233
234 return $filtered;
235 }
static lookupPatternsByParentId(int $a_parent_id, string $a_parent_type)
static _lookupTitle(int $obj_id)

References ilObject\_lookupTitle(), FILTER_LOCAL_ROLES, FILTER_PARENT_ROLES, FILTER_SOURCE_TITLE, getActionId(), ilObject\getRefId(), 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 62 of file class.ilDidacticTemplateAction.php.

62 : ilLogger
63 {
64 return $this->logger;
65 }
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 97 of file class.ilDidacticTemplateAction.php.

97 : int
98 {
99 return $this->ref_id;
100 }

References $ref_id.

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

+ Here is the caller graph for this function:

◆ getTemplateId()

ilDidacticTemplateAction::getTemplateId ( )

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

87 : int
88 {
89 return $this->tpl_id;
90 }

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 171 of file class.ilDidacticTemplateAction.php.

171 : ilObject
172 {
173 $s = ilObjectFactory::getInstanceByRefId($this->getRefId(), false);
174 return $s;
175 }
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilObject Basic functions for all objects.

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 136 of file class.ilDidacticTemplateAction.php.

136 : void
137 {
138 $query = 'SELECT * FROM didactic_tpl_a ' .
139 'WHERE id = ' . $this->db->quote($this->getActionId(), 'integer');
140 $res = $this->db->query($query);
141 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
142 $this->setTemplateId((int) $row->tpl_id);
143 }
144 }
$res
Definition: ltiservices.php:69

References $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 107 of file class.ilDidacticTemplateAction.php.

107 : int
108 {
109 if ($this->getActionId()) {
110 return 0;
111 }
112
113 $this->setActionId($this->db->nextId('didactic_tpl_a'));
114 $query = 'INSERT INTO didactic_tpl_a (id, tpl_id, type_id) ' .
115 'VALUES( ' .
116 $this->db->quote($this->getActionId(), 'integer') . ', ' .
117 $this->db->quote($this->getTemplateId(), 'integer') . ', ' .
118 $this->db->quote($this->getType(), 'integer') .
119 ')';
120 $this->db->manipulate($query);
121
122 return $this->getActionId();
123 }
getType()
Get type of template.

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

+ Here is the call graph for this function:

◆ setActionId()

ilDidacticTemplateAction::setActionId ( int  $a_action_id)

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

72 : void
73 {
74 $this->action_id = $a_action_id;
75 }

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

+ Here is the caller graph for this function:

◆ setRefId()

ilDidacticTemplateAction::setRefId ( int  $a_ref_id)

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

92 : void
93 {
94 $this->ref_id = $a_ref_id;
95 }

◆ setTemplateId()

ilDidacticTemplateAction::setTemplateId ( int  $a_id)

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

82 : void
83 {
84 $this->tpl_id = $a_id;
85 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setType()

ilDidacticTemplateAction::setType ( int  $a_type_id)

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

77 : void
78 {
79 $this->type = $a_type_id;
80 }

◆ toXml()

ilDidacticTemplateAction::toXml ( ilXmlWriter  $writer)
abstract

Field Documentation

◆ $action_id

◆ $admin

ilRbacAdmin ilDidacticTemplateAction::$admin
protected

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

◆ $db

ilDBInterface ilDidacticTemplateAction::$db
protected

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

◆ $logger

ilLogger ilDidacticTemplateAction::$logger
protected

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

Referenced by getLogger().

◆ $ref_id

int ilDidacticTemplateAction::$ref_id = 0
private

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

Referenced by getRefId().

◆ $review

ilRbacReview ilDidacticTemplateAction::$review
protected

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

◆ $tpl_id

int ilDidacticTemplateAction::$tpl_id = 0
private

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

Referenced by getTemplateId().

◆ $type

int ilDidacticTemplateAction::$type = 0
private

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

◆ FILTER_LOCAL_ROLES

const ilDidacticTemplateAction::FILTER_LOCAL_ROLES = 4

◆ FILTER_PARENT_ROLES

◆ FILTER_SOURCE_OBJ_ID

◆ FILTER_SOURCE_TITLE

◆ PATTERN_PARENT_TYPE

const ilDidacticTemplateAction::PATTERN_PARENT_TYPE = 'action'

Definition at line 36 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: