ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 ()
 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.

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

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

40  {
41  global $DIC;
42 
43  $this->logger = $DIC->logger()->otpl();
44 
45  $this->setActionId($action_id);
46  $this->read();
47  }
global $DIC
Definition: saml.php:7
setActionId($a_action_id)
Set action id.
+ Here is the call graph for this function:

Member Function Documentation

◆ __clone()

ilDidacticTemplateAction::__clone ( )

Clone method.

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

References setActionId(), and toXml().

210  {
211  $this->setActionId(0);
212  }
setActionId($a_action_id)
Set action id.
+ 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.

Returns
bool

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

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

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  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ 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.

References $DIC, ilObject\_lookupTitle(), getActionId(), ilLoggerFactory\getLogger(), ilObject\getRefId(), and ilDidacticTemplateFilterPatternFactory\lookupPatternsByParentId().

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

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()) {
252  case self::FILTER_PARENT_ROLES:
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 
270  case self::FILTER_LOCAL_ROLES:
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:
288  case self::FILTER_SOURCE_TITLE:
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.
global $DIC
Definition: saml.php:7
static _lookupTitle($a_id)
lookup object title
getRefId()
get reference id public
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActionId()

◆ getLogger()

ilDidacticTemplateAction::getLogger ( )

Get logger.

Returns

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

Referenced by read(), and 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.

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

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

227  {
228  include_once './Services/Object/classes/class.ilObjectFactory.php';
230  return $s;
231  }
$s
Definition: pwgen.php:45
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
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilDidacticTemplateAction::read ( )

ilDB $ilDB

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

References $DIC, $ilDB, $query, $res, $row, apply(), ilDBConstants\FETCHMODE_OBJECT, getActionId(), getType(), revert(), and setTemplateId().

Referenced by __construct().

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ 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
bool

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

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

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  }
global $DIC
Definition: saml.php:7
getType()
Get type of template.
$query
global $ilDB
setActionId($a_action_id)
Set action id.
+ 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.

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

72  {
73  $this->action_id = $a_action_id;
74  }
+ Here is the caller graph for this function:

◆ setRefId()

ilDidacticTemplateAction::setRefId (   $a_ref_id)

Set ref id of target object.

Parameters
intref id 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.

Referenced by read().

91  {
92  $this->tpl_id = $a_id;
93  }
+ 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

Write xml for export.

Referenced by __clone().

+ Here is the caller graph for this function:

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

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: