ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilDidacticTemplateBlockRoleAction Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 __construct (int $action_id=0)
 
 addFilterPattern (ilDidacticTemplateFilterPattern $pattern)
 
 setFilterPatterns (array $patterns)
 Set filter patterns. More...
 
 getFilterPattern ()
 Get filter patterns. More...
 
 setFilterType (int $a_type)
 
 getFilterType ()
 
 save ()
 
 delete ()
 
 apply ()
 
 revert ()
 
 getType ()
 
 toXml (ilXmlWriter $writer)
 
 __clone ()
 
 read ()
 
- Public Member Functions inherited from ilDidacticTemplateAction
 __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)
 

Protected Member Functions

 blockRole (int $a_role_id, ilObject $source)
 
 deleteLocalPolicy (int $a_role_id, ilObject $source)
 
- Protected Member Functions inherited from ilDidacticTemplateAction
 initSourceObject ()
 
 filterRoles (ilObject $source)
 

Private Attributes

array $pattern = []
 
int $filter_type = self::FILTER_SOURCE_TITLE
 

Additional Inherited Members

- 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 Attributes inherited from ilDidacticTemplateAction
ilLogger $logger
 
ilDBInterface $db
 
ilRbacReview $review
 
ilRbacAdmin $admin
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Description of ilDidacticTemplateBlockRoleAction

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

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

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateBlockRoleAction::__construct ( int  $action_id = 0)

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

References ilDidacticTemplateAction\$action_id, and ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ __clone()

ilDidacticTemplateBlockRoleAction::__clone ( )

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

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

203  {
204  parent::__clone();
205 
206  $clones = [];
207  foreach ($this->getFilterPattern() as $pattern) {
208  $clones[] = clone $pattern;
209  }
210  $this->setFilterPatterns($clones);
211  }
setFilterPatterns(array $patterns)
Set filter patterns.
+ Here is the call graph for this function:

◆ addFilterPattern()

ilDidacticTemplateBlockRoleAction::addFilterPattern ( ilDidacticTemplateFilterPattern  $pattern)

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

References $pattern.

Referenced by read().

37  : void
38  {
39  $this->pattern[] = $pattern;
40  }
+ Here is the caller graph for this function:

◆ apply()

ilDidacticTemplateBlockRoleAction::apply ( )

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

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

102  : bool
103  {
104  $source = $this->initSourceObject();
105  $roles = $this->filterRoles($source);
106 
107  // Create local policy for filtered roles
108  foreach ($roles as $role_id => $role) {
109  $this->blockRole($role_id, $source);
110  }
111 
112  return true;
113  }
$source
Definition: metadata.php:93
+ Here is the call graph for this function:

◆ blockRole()

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

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

References ilObject\getRefId(), and SYSTEM_ROLE_ID.

Referenced by apply().

115  : bool
116  {
117  // Set assign to 'y' only if it is a local role
118  $assign = $this->review->isAssignable($a_role_id, $source->getRefId()) ? 'y' : 'n';
119 
120  // Delete permissions
121  $this->admin->revokeSubtreePermissions($source->getRefId(), $a_role_id);
122 
123  // Delete template permissions
124  $this->admin->deleteSubtreeTemplates($source->getRefId(), $a_role_id);
125  if ($a_role_id !== SYSTEM_ROLE_ID) {
126  $this->admin->assignRoleToFolder(
127  $a_role_id,
128  $source->getRefId(),
129  $assign
130  );
131  }
132  return true;
133  }
const SYSTEM_ROLE_ID
Definition: constants.php:29
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilDidacticTemplateBlockRoleAction::delete ( )

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

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

90  : void
91  {
92  parent::delete();
93  $query = 'DELETE FROM didactic_tpl_abr ' .
94  'WHERE action_id = ' . $this->db->quote($this->getActionId(), 'integer');
95  $this->db->manipulate($query);
96 
97  foreach ($this->getFilterPattern() as $pattern) {
98  $pattern->delete();
99  }
100  }
$query
+ Here is the call graph for this function:

◆ deleteLocalPolicy()

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

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

References ilObject\_lookupTitle(), ilObject\getRefId(), ILIAS\Repository\logger(), and ilObjRole\MODE_UNPROTECTED_DELETE_LOCAL_POLICIES.

Referenced by revert().

148  : bool
149  {
150  // Create role folder if it does not exist
151  //$rolf = $rbacreview->getRoleFolderIdOfObject($source->getRefId());
152 
153  if ($this->review->getRoleFolderOfRole($a_role_id) === $source->getRefId()) {
154  $this->logger->debug('Ignoring local role: ' . ilObject::_lookupTitle($a_role_id));
155  return false;
156  }
157 
158  $this->admin->deleteLocalRole($a_role_id, $source->getRefId());
159 
160  // Change existing object
161  $role = new ilObjRole($a_role_id);
162  $role->changeExistingObjects(
163  $source->getRefId(),
165  ['all']
166  );
167  return true;
168  }
Class ilObjRole.
static _lookupTitle(int $obj_id)
const MODE_UNPROTECTED_DELETE_LOCAL_POLICIES
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFilterPattern()

ilDidacticTemplateBlockRoleAction::getFilterPattern ( )

Get filter patterns.

Returns
ilDidacticTemplateFilterPattern[]

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

References $pattern.

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

55  : array
56  {
57  return $this->pattern;
58  }
+ Here is the caller graph for this function:

◆ getFilterType()

ilDidacticTemplateBlockRoleAction::getFilterType ( )

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

References $filter_type.

Referenced by save(), and toXml().

+ Here is the caller graph for this function:

◆ getType()

ilDidacticTemplateBlockRoleAction::getType ( )

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

170  : int
171  {
172  return self::TYPE_BLOCK_ROLE;
173  }

◆ read()

ilDidacticTemplateBlockRoleAction::read ( )

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

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

213  : void
214  {
215  parent::read();
216  $query = 'SELECT * FROM didactic_tpl_abr ' .
217  'WHERE action_id = ' . $this->db->quote($this->getActionId(), ilDBConstants::T_INTEGER);
218  $res = $this->db->query($query);
219  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
220  $this->setFilterType((int) $row->filter_type);
221  }
222 
223  // Read filter
225  $this->getActionId(),
226  self::PATTERN_PARENT_TYPE
227  ) as $pattern) {
228  $this->addFilterPattern($pattern);
229  }
230  }
$res
Definition: ltiservices.php:69
addFilterPattern(ilDidacticTemplateFilterPattern $pattern)
$query
static lookupPatternsByParentId(int $a_parent_id, string $a_parent_type)
+ Here is the call graph for this function:

◆ revert()

ilDidacticTemplateBlockRoleAction::revert ( )

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

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

135  : bool
136  {
137  $source = $this->initSourceObject();
138  $roles = $this->filterRoles($source);
139 
140  // Create local policy for filtered roles
141  foreach ($roles as $role_id => $role) {
142  $this->deleteLocalPolicy($role_id, $source);
143  }
144 
145  return true;
146  }
$source
Definition: metadata.php:93
+ Here is the call graph for this function:

◆ save()

ilDidacticTemplateBlockRoleAction::save ( )

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

References $query, ilDidacticTemplateAction\getActionId(), getFilterPattern(), getFilterType(), and ilDBConstants\T_INTEGER.

70  : int
71  {
72  parent::save();
73  $query = 'INSERT INTO didactic_tpl_abr (action_id,filter_type) ' .
74  'VALUES( ' .
75  $this->db->quote($this->getActionId(), \ilDBConstants::T_INTEGER) . ', ' .
76  $this->db->quote($this->getFilterType(), \ilDBConstants::T_INTEGER) . ' ' .
77  ')';
78  $this->db->manipulate($query);
79 
80  foreach ($this->getFilterPattern() as $pattern) {
81  /* @var ilDidacticTemplateFilterPattern $pattern */
82  $pattern->setParentId($this->getActionId());
83  $pattern->setParentType(self::PATTERN_PARENT_TYPE);
84  $pattern->save();
85  }
86 
87  return $this->getActionId();
88  }
$query
+ Here is the call graph for this function:

◆ setFilterPatterns()

ilDidacticTemplateBlockRoleAction::setFilterPatterns ( array  $patterns)

Set filter patterns.

Parameters
ilDidacticTemplateFilterPattern[]$patterns

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

Referenced by __clone().

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

◆ setFilterType()

ilDidacticTemplateBlockRoleAction::setFilterType ( int  $a_type)

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

Referenced by read().

60  : void
61  {
62  $this->filter_type = $a_type;
63  }
+ Here is the caller graph for this function:

◆ toXml()

ilDidacticTemplateBlockRoleAction::toXml ( ilXmlWriter  $writer)

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

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

175  : void
176  {
177  $writer->xmlStartTag('blockRoleAction');
178 
179  switch ($this->getFilterType()) {
180  case self::FILTER_SOURCE_OBJ_ID:
181  $writer->xmlStartTag('roleFilter', ['source' => 'objId']);
182  break;
183 
184  case self::FILTER_PARENT_ROLES:
185  $writer->xmlStartTag('roleFilter', ['source' => 'parentRoles']);
186  break;
187 
188  case self::FILTER_SOURCE_TITLE:
189  default:
190  $writer->xmlStartTag('roleFilter', ['source' => 'title']);
191  break;
192 
193  }
194 
195  foreach ($this->getFilterPattern() as $pattern) {
196  $pattern->toXml($writer);
197  }
198  $writer->xmlEndTag('roleFilter');
199  $writer->xmlEndTag('blockRoleAction');
200  }
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
+ Here is the call graph for this function:

Field Documentation

◆ $filter_type

int ilDidacticTemplateBlockRoleAction::$filter_type = self::FILTER_SOURCE_TITLE
private

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

Referenced by getFilterType().

◆ $pattern

array ilDidacticTemplateBlockRoleAction::$pattern = []
private

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