ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 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 38 of file class.ilDidacticTemplateAction.php.

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

39  {
40  $this->logger = $GLOBALS['DIC']->logger()->otpl();
41 
42  $this->setActionId($action_id);
43  $this->read();
44  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
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 202 of file class.ilDidacticTemplateAction.php.

References setActionId(), and toXml().

203  {
204  $this->setActionId(0);
205  }
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 151 of file class.ilDidacticTemplateAction.php.

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

152  {
153  global $ilDB;
154 
155  $query = 'DELETE FROM didactic_tpl_a '.
156  'WHERE id = '.$ilDB->quote($this->getActionId(),'integer');
157  $ilDB->manipulate($query);
158  }
global $ilDB
+ Here is the call graph for this function:

◆ filterRoles()

ilDidacticTemplateAction::filterRoles ( ilObject  $source)
protected

Filter roles.

Parameters
ilObject$object

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

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

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

231  {
232  global $rbacreview;
233 
234  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateFilterPatternFactory.php';
236  $this->getActionId(),
237  self::PATTERN_PARENT_TYPE
238  );
239 
240  $filtered = array();
241  foreach($rbacreview->getParentRoleIds($source->getRefId()) as $role_id => $role)
242  {
243  switch($this->getFilterType())
244  {
245  case self::FILTER_PARENT_ROLES:
246 
247  ilLoggerFactory::getLogger('dtpl')->dump($role);
248  if(
249  ($role['parent'] == $source->getRefId()) &&
250  ($role['assign'] == 'y')
251  )
252  {
253  ilLoggerFactory::getLogger('dtpl')->debug('Excluding local role: ' . $role['title']);
254  break;
255  }
256  foreach($patterns as $pattern)
257  {
258  if($pattern->valid(ilObject::_lookupTitle($role_id)))
259  {
260  ilLoggerFactory::getLogger('otpl')->debug('Role is valid: '. ilObject::_lookupTitle($role_id));
261  $filtered[$role_id] = $role;
262  }
263  }
264  break;
265 
266  default:
267  case self::FILTER_SOURCE_TITLE:
268  foreach($patterns as $pattern)
269  {
270  if($pattern->valid(ilObject::_lookupTitle($role_id)))
271  {
272  ilLoggerFactory::getLogger('otpl')->debug('Role is valid: '. ilObject::_lookupTitle($role_id));
273  $filtered[$role_id] = $role;
274  }
275  }
276  break;
277  }
278 
279 
280  }
281  return $filtered;
282  }
static lookupPatternsByParentId($a_parent_id, $a_parent_type)
Get patterns by template id.
static _lookupTitle($a_id)
lookup object title
Create styles array
The data for the language used.
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
type

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

References $logger.

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

+ Here is the caller graph for this function:

◆ getRefId()

ilDidacticTemplateAction::getRefId ( )

Get ref id of target object.

Definition at line 114 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 96 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 219 of file class.ilDidacticTemplateAction.php.

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

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

220  {
221  include_once './Services/Object/classes/class.ilObjectFactory.php';
222  $s = ilObjectFactory::getInstanceByRefId($this->getRefId(),false);
223  return $s;
224  }
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 164 of file class.ilDidacticTemplateAction.php.

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

Referenced by __construct().

165  {
166  global $ilDB;
167 
168  $query = 'SELECT * FROM didactic_tpl_a '.
169  'WHERE id = '.$ilDB->quote($this->getActionId(), 'integer');
170  $res = $ilDB->query($query);
171  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
172  {
173  $this->setTemplateId($row->tpl_id);
174  }
175  return true;
176  }
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 125 of file class.ilDidacticTemplateAction.php.

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

126  {
127  global $ilDB;
128 
129  if($this->getActionId())
130  {
131  return false;
132  }
133 
134  $this->setActionId($ilDB->nextId('didactic_tpl_a'));
135  $query = 'INSERT INTO didactic_tpl_a (id, tpl_id, type_id) '.
136  'VALUES( '.
137  $ilDB->quote($this->getActionId(),'integer').', '.
138  $ilDB->quote($this->getTemplateId(),'integer').', '.
139  $ilDB->quote($this->getType(),'integer').
140  ')';
141  $ilDB->manipulate($query);
142  return $this->getActionId();
143  }
getType()
Get type of template.
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 68 of file class.ilDidacticTemplateAction.php.

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

69  {
70  $this->action_id = $a_action_id;
71  }
+ 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 106 of file class.ilDidacticTemplateAction.php.

107  {
108  $this->ref_id = $a_ref_id;
109  }

◆ setTemplateId()

ilDidacticTemplateAction::setTemplateId (   $a_id)

Set template id.

Parameters
int$a_id

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

Referenced by read().

88  {
89  $this->tpl_id = $a_id;
90  }
+ Here is the caller graph for this function:

◆ setType()

ilDidacticTemplateAction::setType (   $a_type_id)

Set type id.

Parameters
intref id

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

79  {
80  $this->type = $a_type_id;
81  }

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

Referenced by getLogger().

◆ $ref_id

ilDidacticTemplateAction::$ref_id = 0
private

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

Referenced by getRefId().

◆ $tpl_id

ilDidacticTemplateAction::$tpl_id = 0
private

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

Referenced by getTemplateId().

◆ $type

ilDidacticTemplateAction::$type = 0
private

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

◆ FILTER_PARENT_ROLES

const ilDidacticTemplateAction::FILTER_PARENT_ROLES = 3

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

◆ FILTER_SOURCE_OBJ_ID

const ilDidacticTemplateAction::FILTER_SOURCE_OBJ_ID = 2

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

◆ FILTER_SOURCE_TITLE

const ilDidacticTemplateAction::FILTER_SOURCE_TITLE = 1

◆ PATTERN_PARENT_TYPE

const ilDidacticTemplateAction::PATTERN_PARENT_TYPE = 'action'

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