ILIAS  release_8 Revision v8.23
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)

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

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

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
+ Here is the call graph for this function:

Member Function Documentation

◆ __clone()

ilDidacticTemplateAction::__clone ( )

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

References setActionId(), and toXml().

151  {
152  $this->setActionId(0);
153  }
+ Here is the call graph for this function:

◆ apply()

ilDidacticTemplateAction::apply ( )
abstract

Apply action.

Returns
bool

Referenced by read().

+ Here is the caller graph for this function:

◆ delete()

ilDidacticTemplateAction::delete ( )

Delete didactic template action Overwrite for filling additional db fields.

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

References $query, and getActionId().

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
+ Here is the call graph for this function:

◆ filterRoles()

ilDidacticTemplateAction::filterRoles ( ilObject  $source)
protected

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

References ilObject\_lookupTitle(), getActionId(), ilObject\getRefId(), ILIAS\Repository\int(), ILIAS\Repository\logger(), and ilDidacticTemplateFilterPatternFactory\lookupPatternsByParentId().

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

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()) {
174  case self::FILTER_PARENT_ROLES:
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 
192  case self::FILTER_LOCAL_ROLES:
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:
209  case self::FILTER_SOURCE_TITLE:
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 _lookupTitle(int $obj_id)
static lookupPatternsByParentId(int $a_parent_id, string $a_parent_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActionId()

◆ getLogger()

ilDidacticTemplateAction::getLogger ( )

◆ getRefId()

ilDidacticTemplateAction::getRefId ( )

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

References $ref_id.

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

83  : int
84  {
85  return $this->ref_id;
86  }
+ Here is the caller graph for this function:

◆ getTemplateId()

ilDidacticTemplateAction::getTemplateId ( )

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

References $tpl_id.

Referenced by save().

73  : int
74  {
75  return $this->tpl_id;
76  }
+ Here is the caller graph for this function:

◆ getType()

ilDidacticTemplateAction::getType ( )
abstract

Get type of template.

Returns
int $type

Referenced by read(), and save().

+ Here is the caller graph for this function:

◆ initSourceObject()

ilDidacticTemplateAction::initSourceObject ( )
protected

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

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

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

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
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilDidacticTemplateAction::read ( )

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

References $query, $res, apply(), ilDBConstants\FETCHMODE_OBJECT, getActionId(), getType(), ILIAS\Repository\int(), revert(), and setTemplateId().

Referenced by __construct().

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
$query
+ 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.

Referenced by read().

+ Here is the caller graph for this function:

◆ save()

ilDidacticTemplateAction::save ( )

Write action to db Overwrite for filling additional db fields.

Returns
int

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

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

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.
$query
+ Here is the call graph for this function:

◆ setActionId()

ilDidacticTemplateAction::setActionId ( int  $a_action_id)

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

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

58  : void
59  {
60  $this->action_id = $a_action_id;
61  }
+ 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.

Referenced by read().

68  : void
69  {
70  $this->tpl_id = $a_id;
71  }
+ 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

Referenced by __clone().

+ Here is the caller graph for this function:

Field Documentation

◆ $action_id

int ilDidacticTemplateAction::$action_id = 0
private

◆ $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

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

◆ TYPE_BLOCK_ROLE

const ilDidacticTemplateAction::TYPE_BLOCK_ROLE = 3

◆ TYPE_LOCAL_POLICY

const ilDidacticTemplateAction::TYPE_LOCAL_POLICY = 1

◆ TYPE_LOCAL_ROLE

const ilDidacticTemplateAction::TYPE_LOCAL_ROLE = 2

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