ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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)

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

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

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

Member Function Documentation

◆ __clone()

ilDidacticTemplateAction::__clone ( )

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

References setActionId(), and toXml().

165  {
166  $this->setActionId(0);
167  }
+ 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 129 of file class.ilDidacticTemplateAction.php.

References getActionId().

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

◆ filterRoles()

ilDidacticTemplateAction::filterRoles ( ilObject  $source)
protected

Definition at line 177 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().

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()) {
188  case self::FILTER_PARENT_ROLES:
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 
206  case self::FILTER_LOCAL_ROLES:
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:
223  case self::FILTER_SOURCE_TITLE:
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 _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 97 of file class.ilDidacticTemplateAction.php.

References $ref_id.

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

97  : int
98  {
99  return $this->ref_id;
100  }
+ Here is the caller graph for this function:

◆ getTemplateId()

ilDidacticTemplateAction::getTemplateId ( )

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

References $tpl_id.

Referenced by save().

87  : int
88  {
89  return $this->tpl_id;
90  }
+ 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 171 of file class.ilDidacticTemplateAction.php.

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

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

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

◆ read()

ilDidacticTemplateAction::read ( )

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

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

Referenced by __construct().

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:66
+ 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 107 of file class.ilDidacticTemplateAction.php.

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

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

◆ setActionId()

ilDidacticTemplateAction::setActionId ( int  $a_action_id)

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

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

72  : void
73  {
74  $this->action_id = $a_action_id;
75  }
+ 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.

Referenced by read().

82  : void
83  {
84  $this->tpl_id = $a_id;
85  }
+ 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

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

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 36 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: