ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilDidacticTemplateBlockRoleAction Class Reference

Description of ilDidacticTemplateBlockRoleAction. More...

+ Inheritance diagram for ilDidacticTemplateBlockRoleAction:
+ Collaboration diagram for ilDidacticTemplateBlockRoleAction:

Public Member Functions

 __construct ($action_id=0)
 Constructor. More...
 
 addFilterPattern (ilDidacticTemplateFilterPattern $pattern)
 Add filter. More...
 
 setFilterPatterns (Array $patterns)
 Set filter patterns. More...
 
 getFilterPattern ()
 Get filter pattern. More...
 
 setFilterType ($a_type)
 Set filter type. More...
 
 getFilterType ()
 Get filter type. More...
 
 save ()
 Save action. More...
 
 delete ()
 delete action filter ilDB $ilDB More...
 
 apply ()
 Apply action. More...
 
 revert ()
 Revert action. More...
 
 getType ()
 Get action type. More...
 
 toXml (ilXmlWriter $writer)
 Export to xml. More...
 
 __clone ()
 clone method More...
 
 read ()
 read action data ilDB $ilDB More...
 
- Public Member Functions inherited from ilDidacticTemplateAction
 __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 FILTER_SOURCE_TITLE = 1
 
const FILTER_SOURCE_OBJ_ID = 2
 
const FILTER_PARENT_ROLES = 3
 
const PATTERN_PARENT_TYPE = 'action'
 
- Data Fields inherited from ilDidacticTemplateAction
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

 blockRole ($a_role_id, $source)
 Blo k role. More...
 
 deleteLocalPolicy ($a_role_id, $source)
 Delete local policy. More...
 
- Protected Member Functions inherited from ilDidacticTemplateAction
 initSourceObject ()
 Init the source object. More...
 
 filterRoles (ilObject $source)
 Filter roles. More...
 

Private Attributes

 $pattern = array()
 
 $filter_type = self::FILTER_SOURCE_TITLE
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateBlockRoleAction::__construct (   $action_id = 0)

Constructor.

Parameters
int$action_id

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

References ilDidacticTemplateAction\$action_id.

29  {
30  parent::__construct($action_id);
31  }

Member Function Documentation

◆ __clone()

ilDidacticTemplateBlockRoleAction::__clone ( )

clone method

Definition at line 262 of file class.ilDidacticTemplateBlockRoleAction.php.

References $pattern, array, getFilterPattern(), and setFilterPatterns().

263  {
264  parent::__clone();
265 
266  // Clone patterns
267  $cloned = array();
268  foreach($this->getFilterPattern() as $pattern)
269  {
270  $clones[] = clone $pattern;
271  }
272  $this->setFilterPatterns($clones);
273  }
Create styles array
The data for the language used.
setFilterPatterns(Array $patterns)
Set filter patterns.
+ Here is the call graph for this function:

◆ addFilterPattern()

ilDidacticTemplateBlockRoleAction::addFilterPattern ( ilDidacticTemplateFilterPattern  $pattern)

Add filter.

Parameters
ilDidacticTemplateFilterPatter$pattern

Definition at line 37 of file class.ilDidacticTemplateBlockRoleAction.php.

References $pattern.

Referenced by read().

+ Here is the caller graph for this function:

◆ apply()

ilDidacticTemplateBlockRoleAction::apply ( )

Apply action.

Definition at line 131 of file class.ilDidacticTemplateBlockRoleAction.php.

References blockRole(), ilDidacticTemplateAction\filterRoles(), and ilDidacticTemplateAction\initSourceObject().

132  {
133  $source = $this->initSourceObject();
134  $roles = $this->filterRoles($source);
135 
136  // Create local policy for filtered roles
137  foreach($roles as $role_id => $role)
138  {
139  $this->blockRole($role_id, $source);
140  }
141  return true;
142  }
filterRoles(ilObject $source)
Filter roles.
initSourceObject()
Init the source object.
+ Here is the call graph for this function:

◆ blockRole()

ilDidacticTemplateBlockRoleAction::blockRole (   $a_role_id,
  $source 
)
protected

Blo k role.

Parameters
int$a_role_id
ilObject$source

Definition at line 149 of file class.ilDidacticTemplateBlockRoleAction.php.

Referenced by apply().

150  {
151  global $rbacadmin, $rbacreview;
152 
153  // Set assign to 'y' only if it is a local role
154  $assign = $rbacreview->isAssignable($a_role_id, $source->getRefId()) ? 'y' : 'n';
155 
156  // Delete permissions
157  $rbacadmin->revokeSubtreePermissions($source->getRefId(), $a_role_id);
158 
159  // Delete template permissions
160  $rbacadmin->deleteSubtreeTemplates($source->getRefId(), $a_role_id);
161 
162  $rbacadmin->assignRoleToFolder(
163  $a_role_id,
164  $source->getRefId(),
165  $assign
166  );
167  return true;
168  }
+ Here is the caller graph for this function:

◆ delete()

ilDidacticTemplateBlockRoleAction::delete ( )

delete action filter ilDB $ilDB

Returns
bool

Definition at line 108 of file class.ilDidacticTemplateBlockRoleAction.php.

References $ilDB, $pattern, $query, ilDidacticTemplateAction\getActionId(), and getFilterPattern().

109  {
110  global $ilDB;
111 
112  parent::delete();
113 
114  $query = 'DELETE FROM didactic_tpl_abr '.
115  'WHERE action_id = '.$ilDB->quote($this->getActionId(),'integer');
116  $ilDB->manipulate($query);
117 
118  foreach($this->getFilterPattern() as $pattern)
119  {
120  $pattern->delete();
121  }
122  return true;
123  }
global $ilDB
+ Here is the call graph for this function:

◆ deleteLocalPolicy()

ilDidacticTemplateBlockRoleAction::deleteLocalPolicy (   $a_role_id,
  $source 
)
protected

Delete local policy.

Parameters
int$a_role_id
ilObject$source

Definition at line 192 of file class.ilDidacticTemplateBlockRoleAction.php.

References ilObject\_lookupTitle(), array, ilLoggerFactory\getLogger(), and ilObjRole\MODE_UNPROTECTED_DELETE_LOCAL_POLICIES.

Referenced by revert().

193  {
194  global $rbacreview, $rbacadmin;
195 
196  // Create role folder if it does not exist
197  //$rolf = $rbacreview->getRoleFolderIdOfObject($source->getRefId());
198 
199  if($rbacreview->getRoleFolderOfRole($a_role_id) == $source->getRefId())
200  {
201  ilLoggerFactory::getLogger('otpl')->debug('Ignoring local role: '.ilObject::_lookupTitle($a_role_id));
202  return false;
203  }
204 
205  $rbacadmin->deleteLocalRole($a_role_id, $source->getRefId());
206 
207  // Change existing object
208  include_once './Services/AccessControl/classes/class.ilObjRole.php';
209  $role = new ilObjRole($a_role_id);
210  $role->changeExistingObjects(
211  $source->getRefId(),
213  array('all')
214  );
215 
216  return true;
217  }
Class ilObjRole.
static _lookupTitle($a_id)
lookup object title
Create styles array
The data for the language used.
const MODE_UNPROTECTED_DELETE_LOCAL_POLICIES
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFilterPattern()

ilDidacticTemplateBlockRoleAction::getFilterPattern ( )

Get filter pattern.

Returns
array

Definition at line 55 of file class.ilDidacticTemplateBlockRoleAction.php.

References $pattern.

Referenced by __clone(), delete(), save(), and toXml().

+ Here is the caller graph for this function:

◆ getFilterType()

ilDidacticTemplateBlockRoleAction::getFilterType ( )

Get filter type.

Returns
int

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

References $filter_type.

Referenced by save(), and toXml().

+ Here is the caller graph for this function:

◆ getType()

ilDidacticTemplateBlockRoleAction::getType ( )

Get action type.

Returns
int

Definition at line 224 of file class.ilDidacticTemplateBlockRoleAction.php.

225  {
226  return self::TYPE_BLOCK_ROLE;
227  }

◆ read()

ilDidacticTemplateBlockRoleAction::read ( )

read action data ilDB $ilDB

Returns
bool

Definition at line 280 of file class.ilDidacticTemplateBlockRoleAction.php.

References $ilDB, $pattern, $query, $res, $row, addFilterPattern(), ilDBConstants\FETCHMODE_OBJECT, ilDidacticTemplateAction\getActionId(), ilDidacticTemplateFilterPatternFactory\lookupPatternsByParentId(), and setFilterType().

281  {
282  global $ilDB;
283 
284  if(!parent::read())
285  {
286  return false;
287  }
288 
289  $query = 'SELECT * FROM didactic_tpl_abr '.
290  'WHERE action_id = '.$ilDB->quote($this->getActionId());
291  $res = $ilDB->query($query);
292  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
293  {
294  $this->setFilterType($row->filter_type);
295  }
296 
297  // Read filter
298  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateFilterPatternFactory.php';
299  foreach(ilDidacticTemplateFilterPatternFactory::lookupPatternsByParentId($this->getActionId(),self::PATTERN_PARENT_TYPE) as $pattern)
300  {
301  $this->addFilterPattern($pattern);
302  }
303  }
static lookupPatternsByParentId($a_parent_id, $a_parent_type)
Get patterns by template id.
addFilterPattern(ilDidacticTemplateFilterPattern $pattern)
Add filter.
global $ilDB
+ Here is the call graph for this function:

◆ revert()

ilDidacticTemplateBlockRoleAction::revert ( )

Revert action.

Definition at line 173 of file class.ilDidacticTemplateBlockRoleAction.php.

References deleteLocalPolicy(), ilDidacticTemplateAction\filterRoles(), and ilDidacticTemplateAction\initSourceObject().

174  {
175  $source = $this->initSourceObject();
176  $roles = $this->filterRoles($source);
177 
178  // Create local policy for filtered roles
179  foreach($roles as $role_id => $role)
180  {
181  $this->deleteLocalPolicy($role_id, $source);
182  }
183  return true;
184  }
deleteLocalPolicy($a_role_id, $source)
Delete local policy.
filterRoles(ilObject $source)
Filter roles.
initSourceObject()
Init the source object.
+ Here is the call graph for this function:

◆ save()

ilDidacticTemplateBlockRoleAction::save ( )

Save action.

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

References $ilDB, $pattern, $query, ilDidacticTemplateAction\getActionId(), getFilterPattern(), and getFilterType().

82  {
83  global $ilDB;
84 
85  parent::save();
86 
87  $query = 'INSERT INTO didactic_tpl_abr (action_id,filter_type) '.
88  'VALUES( '.
89  $ilDB->quote($this->getActionId(),'integer').', '.
90  $ilDB->quote($this->getFilterType(),'integer').' '.
91  ')';
92  $ilDB->manipulate($query);
93 
94  foreach($this->getFilterPattern() as $pattern)
95  {
96  /* @var ilDidacticTemplateFilterPattern $pattern */
97  $pattern->setParentId($this->getActionId());
98  $pattern->setParentType(self::PATTERN_PARENT_TYPE);
99  $pattern->save();
100  }
101  }
global $ilDB
+ Here is the call graph for this function:

◆ setFilterPatterns()

ilDidacticTemplateBlockRoleAction::setFilterPatterns ( Array  $patterns)

Set filter patterns.

Parameters
array$patterns

Definition at line 46 of file class.ilDidacticTemplateBlockRoleAction.php.

Referenced by __clone().

47  {
48  $this->pattern = $patterns;
49  }
+ Here is the caller graph for this function:

◆ setFilterType()

ilDidacticTemplateBlockRoleAction::setFilterType (   $a_type)

Set filter type.

Parameters
int$a_type

Definition at line 64 of file class.ilDidacticTemplateBlockRoleAction.php.

References $a_type.

Referenced by read().

65  {
66  $this->filter_type = $a_type;
67  }
$a_type
Definition: workflow.php:93
+ Here is the caller graph for this function:

◆ toXml()

ilDidacticTemplateBlockRoleAction::toXml ( ilXmlWriter  $writer)

Export to xml.

Parameters
ilXmlWriter$writer
Returns
void

Definition at line 234 of file class.ilDidacticTemplateBlockRoleAction.php.

References $pattern, array, getFilterPattern(), getFilterType(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

235  {
236  $writer->xmlStartTag('blockRoleAction');
237 
238  switch($this->getFilterType())
239  {
240  case self::FILTER_SOURCE_OBJ_ID:
241  $writer->xmlStartTag('roleFilter',array('source' => 'objId'));
242  break;
243 
244  default:
245  case self::FILTER_SOURCE_TITLE:
246  $writer->xmlStartTag('roleFilter',array('source' => 'title'));
247  break;
248  }
249 
250  foreach($this->getFilterPattern() as $pattern)
251  {
252  $pattern->toXml($writer);
253  }
254  $writer->xmlEndTag('roleFilter');
255  $writer->xmlEndTag('blockRoleAction');
256  return;
257  }
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
xmlEndTag($tag)
Writes an endtag.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

Field Documentation

◆ $filter_type

ilDidacticTemplateBlockRoleAction::$filter_type = self::FILTER_SOURCE_TITLE
private

Definition at line 22 of file class.ilDidacticTemplateBlockRoleAction.php.

Referenced by getFilterType().

◆ $pattern

ilDidacticTemplateBlockRoleAction::$pattern = array()
private

◆ FILTER_PARENT_ROLES

const ilDidacticTemplateBlockRoleAction::FILTER_PARENT_ROLES = 3

Definition at line 16 of file class.ilDidacticTemplateBlockRoleAction.php.

◆ FILTER_SOURCE_OBJ_ID

const ilDidacticTemplateBlockRoleAction::FILTER_SOURCE_OBJ_ID = 2

Definition at line 15 of file class.ilDidacticTemplateBlockRoleAction.php.

◆ FILTER_SOURCE_TITLE

const ilDidacticTemplateBlockRoleAction::FILTER_SOURCE_TITLE = 1

Definition at line 14 of file class.ilDidacticTemplateBlockRoleAction.php.

◆ PATTERN_PARENT_TYPE

const ilDidacticTemplateBlockRoleAction::PATTERN_PARENT_TYPE = 'action'

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


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