ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilDidacticTemplateBlockRoleAction Class Reference

Description of ilDidacticTemplateBlockRoleAction. 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

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateBlockRoleAction::__construct ( int  $action_id = 0)

Definition at line 17 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 186 of file class.ilDidacticTemplateBlockRoleAction.php.

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

187  {
188  parent::__clone();
189 
190  $clones = [];
191  foreach ($this->getFilterPattern() as $pattern) {
192  $clones[] = clone $pattern;
193  }
194  $this->setFilterPatterns($clones);
195  }
setFilterPatterns(array $patterns)
Set filter patterns.
+ Here is the call graph for this function:

◆ addFilterPattern()

ilDidacticTemplateBlockRoleAction::addFilterPattern ( ilDidacticTemplateFilterPattern  $pattern)

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

References $pattern.

Referenced by read().

22  : void
23  {
24  $this->pattern[] = $pattern;
25  }
+ Here is the caller graph for this function:

◆ apply()

ilDidacticTemplateBlockRoleAction::apply ( )

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

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

87  : bool
88  {
89  $source = $this->initSourceObject();
90  $roles = $this->filterRoles($source);
91 
92  // Create local policy for filtered roles
93  foreach ($roles as $role_id => $role) {
94  $this->blockRole($role_id, $source);
95  }
96 
97  return true;
98  }
+ Here is the call graph for this function:

◆ blockRole()

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

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

References ilObject\getRefId().

Referenced by apply().

100  : bool
101  {
102  // Set assign to 'y' only if it is a local role
103  $assign = $this->review->isAssignable($a_role_id, $source->getRefId()) ? 'y' : 'n';
104 
105  // Delete permissions
106  $this->admin->revokeSubtreePermissions($source->getRefId(), $a_role_id);
107 
108  // Delete template permissions
109  $this->admin->deleteSubtreeTemplates($source->getRefId(), $a_role_id);
110 
111  $this->admin->assignRoleToFolder(
112  $a_role_id,
113  $source->getRefId(),
114  $assign
115  );
116 
117  return true;
118  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilDidacticTemplateBlockRoleAction::delete ( )

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

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

75  : void
76  {
77  parent::delete();
78  $query = 'DELETE FROM didactic_tpl_abr ' .
79  'WHERE action_id = ' . $this->db->quote($this->getActionId(), 'integer');
80  $this->db->manipulate($query);
81 
82  foreach ($this->getFilterPattern() as $pattern) {
83  $pattern->delete();
84  }
85  }
+ Here is the call graph for this function:

◆ deleteLocalPolicy()

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

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

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

Referenced by revert().

133  : bool
134  {
135  // Create role folder if it does not exist
136  //$rolf = $rbacreview->getRoleFolderIdOfObject($source->getRefId());
137 
138  if ($this->review->getRoleFolderOfRole($a_role_id) === $source->getRefId()) {
139  $this->logger->debug('Ignoring local role: ' . ilObject::_lookupTitle($a_role_id));
140  return false;
141  }
142 
143  $this->admin->deleteLocalRole($a_role_id, $source->getRefId());
144 
145  // Change existing object
146  $role = new ilObjRole($a_role_id);
147  $role->changeExistingObjects(
148  $source->getRefId(),
150  ['all']
151  );
152  return true;
153  }
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 40 of file class.ilDidacticTemplateBlockRoleAction.php.

References $pattern.

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

40  : array
41  {
42  return $this->pattern;
43  }
+ Here is the caller graph for this function:

◆ getFilterType()

ilDidacticTemplateBlockRoleAction::getFilterType ( )

Definition at line 50 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 155 of file class.ilDidacticTemplateBlockRoleAction.php.

155  : int
156  {
157  return self::TYPE_BLOCK_ROLE;
158  }

◆ read()

ilDidacticTemplateBlockRoleAction::read ( )

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

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

197  : void
198  {
199  parent::read();
200  $query = 'SELECT * FROM didactic_tpl_abr ' .
201  'WHERE action_id = ' . $this->db->quote($this->getActionId(), ilDBConstants::T_INTEGER);
202  $res = $this->db->query($query);
203  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
204  $this->setFilterType((int) $row->filter_type);
205  }
206 
207  // Read filter
209  $this->getActionId(),
210  self::PATTERN_PARENT_TYPE
211  ) as $pattern) {
212  $this->addFilterPattern($pattern);
213  }
214  }
$res
Definition: ltiservices.php:69
addFilterPattern(ilDidacticTemplateFilterPattern $pattern)
static lookupPatternsByParentId(int $a_parent_id, string $a_parent_type)
+ Here is the call graph for this function:

◆ revert()

ilDidacticTemplateBlockRoleAction::revert ( )

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

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

120  : bool
121  {
122  $source = $this->initSourceObject();
123  $roles = $this->filterRoles($source);
124 
125  // Create local policy for filtered roles
126  foreach ($roles as $role_id => $role) {
127  $this->deleteLocalPolicy($role_id, $source);
128  }
129 
130  return true;
131  }
+ Here is the call graph for this function:

◆ save()

ilDidacticTemplateBlockRoleAction::save ( )

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

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

55  : int
56  {
57  parent::save();
58  $query = 'INSERT INTO didactic_tpl_abr (action_id,filter_type) ' .
59  'VALUES( ' .
60  $this->db->quote($this->getActionId(), \ilDBConstants::T_INTEGER) . ', ' .
61  $this->db->quote($this->getFilterType(), \ilDBConstants::T_INTEGER) . ' ' .
62  ')';
63  $this->db->manipulate($query);
64 
65  foreach ($this->getFilterPattern() as $pattern) {
66  /* @var ilDidacticTemplateFilterPattern $pattern */
67  $pattern->setParentId($this->getActionId());
68  $pattern->setParentType(self::PATTERN_PARENT_TYPE);
69  $pattern->save();
70  }
71 
72  return $this->getActionId();
73  }
+ Here is the call graph for this function:

◆ setFilterPatterns()

ilDidacticTemplateBlockRoleAction::setFilterPatterns ( array  $patterns)

Set filter patterns.

Parameters
ilDidacticTemplateFilterPattern[]$patterns

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

Referenced by __clone().

31  : void
32  {
33  $this->pattern = $patterns;
34  }
+ Here is the caller graph for this function:

◆ setFilterType()

ilDidacticTemplateBlockRoleAction::setFilterType ( int  $a_type)

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

Referenced by read().

45  : void
46  {
47  $this->filter_type = $a_type;
48  }
+ Here is the caller graph for this function:

◆ toXml()

ilDidacticTemplateBlockRoleAction::toXml ( ilXmlWriter  $writer)

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

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

160  : void
161  {
162  $writer->xmlStartTag('blockRoleAction');
163 
164  switch ($this->getFilterType()) {
165  case self::FILTER_SOURCE_OBJ_ID:
166  $writer->xmlStartTag('roleFilter', ['source' => 'objId']);
167  break;
168 
169  case self::FILTER_PARENT_ROLES:
170  $writer->xmlStartTag('roleFilter', ['source' => 'parentRoles']);
171  break;
172 
173  case self::FILTER_SOURCE_TITLE:
174  default:
175  $writer->xmlStartTag('roleFilter', ['source' => 'title']);
176  break;
177  }
178 
179  foreach ($this->getFilterPattern() as $pattern) {
180  $pattern->toXml($writer);
181  }
182  $writer->xmlEndTag('roleFilter');
183  $writer->xmlEndTag('blockRoleAction');
184  }
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 15 of file class.ilDidacticTemplateBlockRoleAction.php.

Referenced by getFilterType().

◆ $pattern

array ilDidacticTemplateBlockRoleAction::$pattern = []
private

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