ILIAS  release_7 Revision v7.30-3-g800a261c036
ilDidacticTemplateAction Class Reference

Abstract class for template actions. More...

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

Public Member Functions

 __construct ($action_id=0)
 Constructor. More...
 
 getLogger ()
 Get logger. More...
 
 getActionId ()
 Get action id. More...
 
 setActionId ($a_action_id)
 Set action id. More...
 
 setType ($a_type_id)
 Set type id. More...
 
 setTemplateId ($a_id)
 Set template id. More...
 
 getTemplateId ()
 Get template id. More...
 
 setRefId ($a_ref_id)
 Set ref id of target object. More...
 
 getRefId ()
 Get ref id of target object. More...
 
 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 ()
 @global ilDB $ilDB More...
 
 getType ()
 Get type of template. More...
 
 apply ()
 Apply action. More...
 
 revert ()
 Implement everthing that is necessary to revert a didactic template. More...
 
 __clone ()
 Clone method. More...
 
 toXml (ilXmlWriter $writer)
 Write xml for export. More...
 

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 ()
 Init the source object. More...
 
 filterRoles (ilObject $source)
 Filter roles. More...
 

Private Attributes

 $logger = null
 
 $action_id = 0
 
 $tpl_id = 0
 
 $type = 0
 
 $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 10 of file class.ilDidacticTemplateAction.php.

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateAction::__construct (   $action_id = 0)

Constructor.

Reimplemented in ilDidacticTemplateLocalRoleAction, ilDidacticTemplateBlockRoleAction, and ilDidacticTemplateLocalPolicyAction.

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

40 {
41 global $DIC;
42
43 $this->logger = $DIC->logger()->otpl();
44
45 $this->setActionId($action_id);
46 $this->read();
47 }
setActionId($a_action_id)
Set action id.
global $DIC
Definition: goto.php:24

References $action_id, $DIC, read(), and setActionId().

+ Here is the call graph for this function:

Member Function Documentation

◆ __clone()

ilDidacticTemplateAction::__clone ( )

Clone method.

Reimplemented in ilDidacticTemplateBlockRoleAction, and ilDidacticTemplateLocalPolicyAction.

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

210 {
211 $this->setActionId(0);
212 }

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.

Returns
bool

Reimplemented in ilDidacticTemplateBlockRoleAction, ilDidacticTemplateLocalPolicyAction, and ilDidacticTemplateLocalRoleAction.

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

156 {
157 global $DIC;
158
159 $ilDB = $DIC['ilDB'];
160
161 $query = 'DELETE FROM didactic_tpl_a ' .
162 'WHERE id = ' . $ilDB->quote($this->getActionId(), 'integer');
163 $ilDB->manipulate($query);
164 }
$query
global $ilDB

References $DIC, $ilDB, $query, and getActionId().

+ Here is the call graph for this function:

◆ filterRoles()

ilDidacticTemplateAction::filterRoles ( ilObject  $source)
protected

Filter roles.

Parameters
ilObject$object

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

238 {
239 global $DIC;
240
241 $rbacreview = $DIC['rbacreview'];
242
243 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateFilterPatternFactory.php';
245 $this->getActionId(),
246 self::PATTERN_PARENT_TYPE
247 );
248
249 $filtered = array();
250 foreach ($rbacreview->getParentRoleIds($source->getRefId()) as $role_id => $role) {
251 switch ($this->getFilterType()) {
253
254 ilLoggerFactory::getLogger('dtpl')->dump($role);
255 if (
256 ($role['parent'] == $source->getRefId()) &&
257 ($role['assign'] == 'y')
258 ) {
259 ilLoggerFactory::getLogger('dtpl')->debug('Excluding local role: ' . $role['title']);
260 break;
261 }
262 foreach ($patterns as $pattern) {
263 if ($pattern->valid(ilObject::_lookupTitle($role_id))) {
264 ilLoggerFactory::getLogger('otpl')->debug('Role is valid: ' . ilObject::_lookupTitle($role_id));
265 $filtered[$role_id] = $role;
266 }
267 }
268 break;
269
271
272 if (
273 $role['parent'] != $source->getRefId() ||
274 $role['assign'] == 'n'
275 ) {
276 $this->logger->debug('Excluding non local role' . $role['title']);
277 break;
278 }
279 foreach ($patterns as $pattern) {
280 if ($pattern->valid(\ilObject::_lookupTitle($role_id))) {
281 $this->logger->debug('Role is valid ' . \ilObject::_lookupTitle($role_id));
282 $filtered[$role_id] = $role;
283 }
284 }
285 break;
286
287 default:
289 foreach ($patterns as $pattern) {
290 if ($pattern->valid(ilObject::_lookupTitle($role_id))) {
291 ilLoggerFactory::getLogger('otpl')->debug('Role is valid: ' . ilObject::_lookupTitle($role_id));
292 $filtered[$role_id] = $role;
293 }
294 }
295 break;
296 }
297 }
298 return $filtered;
299 }
static lookupPatternsByParentId($a_parent_id, $a_parent_type)
Get patterns by template id.
static getLogger($a_component_id)
Get component logger.
static _lookupTitle($a_id)
lookup object title
$source
Definition: metadata.php:76

References $DIC, $source, ilObject\_lookupTitle(), FILTER_LOCAL_ROLES, FILTER_PARENT_ROLES, FILTER_SOURCE_TITLE, getActionId(), ilLoggerFactory\getLogger(), 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 ( )

Get logger.

Returns
\ilLogger

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

References $logger.

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

+ Here is the caller graph for this function:

◆ getRefId()

ilDidacticTemplateAction::getRefId ( )

Get ref id of target object.

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

References $ref_id.

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

+ Here is the caller graph for this function:

◆ getTemplateId()

ilDidacticTemplateAction::getTemplateId ( )

Get template id.

Returns
int

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

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

Init the source object.

Returns
ilObject $obj

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

227 {
228 include_once './Services/Object/classes/class.ilObjectFactory.php';
229 $s = ilObjectFactory::getInstanceByRefId($this->getRefId(), false);
230 return $s;
231 }
getRefId()
Get ref id of target object.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id

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 ( )

@global ilDB $ilDB

Reimplemented in ilDidacticTemplateBlockRoleAction, ilDidacticTemplateLocalPolicyAction, and ilDidacticTemplateLocalRoleAction.

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

171 {
172 global $DIC;
173
174 $ilDB = $DIC['ilDB'];
175
176 $query = 'SELECT * FROM didactic_tpl_a ' .
177 'WHERE id = ' . $ilDB->quote($this->getActionId(), 'integer');
178 $res = $ilDB->query($query);
179 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
180 $this->setTemplateId($row->tpl_id);
181 }
182 return true;
183 }
foreach($_POST as $key=> $value) $res

References $DIC, $ilDB, $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
bool

Reimplemented in ilDidacticTemplateBlockRoleAction, ilDidacticTemplateLocalPolicyAction, and ilDidacticTemplateLocalRoleAction.

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

129 {
130 global $DIC;
131
132 $ilDB = $DIC['ilDB'];
133
134 if ($this->getActionId()) {
135 return false;
136 }
137
138 $this->setActionId($ilDB->nextId('didactic_tpl_a'));
139 $query = 'INSERT INTO didactic_tpl_a (id, tpl_id, type_id) ' .
140 'VALUES( ' .
141 $ilDB->quote($this->getActionId(), 'integer') . ', ' .
142 $ilDB->quote($this->getTemplateId(), 'integer') . ', ' .
143 $ilDB->quote($this->getType(), 'integer') .
144 ')';
145 $ilDB->manipulate($query);
146 return $this->getActionId();
147 }
getType()
Get type of template.

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

+ Here is the call graph for this function:

◆ setActionId()

ilDidacticTemplateAction::setActionId (   $a_action_id)

Set action id.

Parameters
int$a_action_id

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

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

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

+ Here is the caller graph for this function:

◆ setRefId()

ilDidacticTemplateAction::setRefId (   $a_ref_id)

Set ref id of target object.

Parameters
intref id @reteurn void

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

110 {
111 $this->ref_id = $a_ref_id;
112 }

◆ setTemplateId()

ilDidacticTemplateAction::setTemplateId (   $a_id)

Set template id.

Parameters
int$a_id

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

91 {
92 $this->tpl_id = $a_id;
93 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setType()

ilDidacticTemplateAction::setType (   $a_type_id)

Set type id.

Parameters
intref id

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

82 {
83 $this->type = $a_type_id;
84 }

◆ toXml()

ilDidacticTemplateAction::toXml ( ilXmlWriter  $writer)
abstract

Field Documentation

◆ $action_id

ilDidacticTemplateAction::$action_id = 0
private

◆ $logger

ilDidacticTemplateAction::$logger = null
private

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

Referenced by getLogger().

◆ $ref_id

ilDidacticTemplateAction::$ref_id = 0
private

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

Referenced by getRefId().

◆ $tpl_id

ilDidacticTemplateAction::$tpl_id = 0
private

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

Referenced by getTemplateId().

◆ $type

ilDidacticTemplateAction::$type = 0
private

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

◆ FILTER_LOCAL_ROLES

const ilDidacticTemplateAction::FILTER_LOCAL_ROLES = 4

◆ FILTER_PARENT_ROLES

const ilDidacticTemplateAction::FILTER_PARENT_ROLES = 3

◆ FILTER_SOURCE_OBJ_ID

const ilDidacticTemplateAction::FILTER_SOURCE_OBJ_ID = 2

◆ FILTER_SOURCE_TITLE

const ilDidacticTemplateAction::FILTER_SOURCE_TITLE = 1

◆ PATTERN_PARENT_TYPE

const ilDidacticTemplateAction::PATTERN_PARENT_TYPE = 'action'

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