ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 FILTER_LOCAL_ROLES = 4
 
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 273 of file class.ilDidacticTemplateBlockRoleAction.php.

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

274  {
275  parent::__clone();
276 
277  // Clone patterns
278  $cloned = array();
279  foreach ($this->getFilterPattern() as $pattern) {
280  $clones[] = clone $pattern;
281  }
282  $this->setFilterPatterns($clones);
283  }
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 133 of file class.ilDidacticTemplateBlockRoleAction.php.

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

134  {
135  $source = $this->initSourceObject();
136  $roles = $this->filterRoles($source);
137 
138  // Create local policy for filtered roles
139  foreach ($roles as $role_id => $role) {
140  $this->blockRole($role_id, $source);
141  }
142  return true;
143  }
filterRoles(ilObject $source)
Filter roles.
initSourceObject()
Init the source object.
$source
Definition: linkback.php:22
+ 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 150 of file class.ilDidacticTemplateBlockRoleAction.php.

References $DIC, and $source.

Referenced by apply().

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

◆ delete()

ilDidacticTemplateBlockRoleAction::delete ( )

delete action filter ilDB $ilDB

Returns
bool

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

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

110  {
111  global $DIC;
112 
113  $ilDB = $DIC['ilDB'];
114 
115  parent::delete();
116 
117  $query = 'DELETE FROM didactic_tpl_abr ' .
118  'WHERE action_id = ' . $ilDB->quote($this->getActionId(), 'integer');
119  $ilDB->manipulate($query);
120 
121  foreach ($this->getFilterPattern() as $pattern) {
122  $pattern->delete();
123  }
124  return true;
125  }
global $DIC
Definition: saml.php:7
$query
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 195 of file class.ilDidacticTemplateBlockRoleAction.php.

References $DIC, $source, ilObject\_lookupTitle(), ilLoggerFactory\getLogger(), and ilObjRole\MODE_UNPROTECTED_DELETE_LOCAL_POLICIES.

Referenced by revert().

196  {
197  global $DIC;
198 
199  $rbacreview = $DIC['rbacreview'];
200  $rbacadmin = $DIC['rbacadmin'];
201 
202  // Create role folder if it does not exist
203  //$rolf = $rbacreview->getRoleFolderIdOfObject($source->getRefId());
204 
205  if ($rbacreview->getRoleFolderOfRole($a_role_id) == $source->getRefId()) {
206  ilLoggerFactory::getLogger('otpl')->debug('Ignoring local role: ' . ilObject::_lookupTitle($a_role_id));
207  return false;
208  }
209 
210  $rbacadmin->deleteLocalRole($a_role_id, $source->getRefId());
211 
212  // Change existing object
213  include_once './Services/AccessControl/classes/class.ilObjRole.php';
214  $role = new ilObjRole($a_role_id);
215  $role->changeExistingObjects(
216  $source->getRefId(),
218  array('all')
219  );
220 
221  return true;
222  }
Class ilObjRole.
global $DIC
Definition: saml.php:7
static _lookupTitle($a_id)
lookup object title
const MODE_UNPROTECTED_DELETE_LOCAL_POLICIES
static getLogger($a_component_id)
Get component logger.
$source
Definition: linkback.php:22
+ 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 229 of file class.ilDidacticTemplateBlockRoleAction.php.

230  {
231  return self::TYPE_BLOCK_ROLE;
232  }

◆ read()

ilDidacticTemplateBlockRoleAction::read ( )

read action data ilDB $ilDB

Returns
bool

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

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

291  {
292  global $DIC;
293 
294  $ilDB = $DIC['ilDB'];
295 
296  if (!parent::read()) {
297  return false;
298  }
299 
300  $query = 'SELECT * FROM didactic_tpl_abr ' .
301  'WHERE action_id = ' . $ilDB->quote($this->getActionId());
302  $res = $ilDB->query($query);
303  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
304  $this->setFilterType($row->filter_type);
305  }
306 
307  // Read filter
308  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateFilterPatternFactory.php';
309  foreach (ilDidacticTemplateFilterPatternFactory::lookupPatternsByParentId($this->getActionId(), self::PATTERN_PARENT_TYPE) as $pattern) {
310  $this->addFilterPattern($pattern);
311  }
312  }
static lookupPatternsByParentId($a_parent_id, $a_parent_type)
Get patterns by template id.
global $DIC
Definition: saml.php:7
addFilterPattern(ilDidacticTemplateFilterPattern $pattern)
Add filter.
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the call graph for this function:

◆ revert()

ilDidacticTemplateBlockRoleAction::revert ( )

Revert action.

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

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

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

◆ save()

ilDidacticTemplateBlockRoleAction::save ( )

Save action.

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

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

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

◆ toXml()

ilDidacticTemplateBlockRoleAction::toXml ( ilXmlWriter  $writer)

Export to xml.

Parameters
ilXmlWriter$writer
Returns
void

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

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

240  {
241  $writer->xmlStartTag('blockRoleAction');
242 
243  switch ($this->getFilterType()) {
244  case self::FILTER_SOURCE_OBJ_ID:
245  $writer->xmlStartTag('roleFilter', ['source' => 'objId']);
246  break;
247 
248  case self::FILTER_SOURCE_TITLE:
249  $writer->xmlStartTag('roleFilter', ['source' => 'title']);
250  break;
251 
252  case self::FILTER_PARENT_ROLES:
253  $writer->xmlStartTag('roleFilter', ['source' => 'parentRoles']);
254  break;
255 
256  default:
257  $writer->xmlStartTag('roleFilter', ['source' => 'title']);
258  break;
259 
260  }
261 
262  foreach ($this->getFilterPattern() as $pattern) {
263  $pattern->toXml($writer);
264  }
265  $writer->xmlEndTag('roleFilter');
266  $writer->xmlEndTag('blockRoleAction');
267  return;
268  }
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
xmlEndTag($tag)
Writes an endtag.
+ 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: