ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 31 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 200 of file class.ilDidacticTemplateBlockRoleAction.php.

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

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

◆ addFilterPattern()

ilDidacticTemplateBlockRoleAction::addFilterPattern ( ilDidacticTemplateFilterPattern  $pattern)

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

References $pattern.

Referenced by read().

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

◆ apply()

ilDidacticTemplateBlockRoleAction::apply ( )

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

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

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

◆ blockRole()

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

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

References ilObject\getRefId().

Referenced by apply().

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

◆ delete()

ilDidacticTemplateBlockRoleAction::delete ( )

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

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

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

◆ deleteLocalPolicy()

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

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

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

Referenced by revert().

147  : bool
148  {
149  // Create role folder if it does not exist
150  //$rolf = $rbacreview->getRoleFolderIdOfObject($source->getRefId());
151 
152  if ($this->review->getRoleFolderOfRole($a_role_id) === $source->getRefId()) {
153  $this->logger->debug('Ignoring local role: ' . ilObject::_lookupTitle($a_role_id));
154  return false;
155  }
156 
157  $this->admin->deleteLocalRole($a_role_id, $source->getRefId());
158 
159  // Change existing object
160  $role = new ilObjRole($a_role_id);
161  $role->changeExistingObjects(
162  $source->getRefId(),
164  ['all']
165  );
166  return true;
167  }
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 54 of file class.ilDidacticTemplateBlockRoleAction.php.

References $pattern.

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

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

◆ getFilterType()

ilDidacticTemplateBlockRoleAction::getFilterType ( )

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

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

◆ read()

ilDidacticTemplateBlockRoleAction::read ( )

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

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

211  : void
212  {
213  parent::read();
214  $query = 'SELECT * FROM didactic_tpl_abr ' .
215  'WHERE action_id = ' . $this->db->quote($this->getActionId(), ilDBConstants::T_INTEGER);
216  $res = $this->db->query($query);
217  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
218  $this->setFilterType((int) $row->filter_type);
219  }
220 
221  // Read filter
223  $this->getActionId(),
224  self::PATTERN_PARENT_TYPE
225  ) as $pattern) {
226  $this->addFilterPattern($pattern);
227  }
228  }
$res
Definition: ltiservices.php:66
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 134 of file class.ilDidacticTemplateBlockRoleAction.php.

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

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

◆ save()

ilDidacticTemplateBlockRoleAction::save ( )

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

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

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

◆ setFilterPatterns()

ilDidacticTemplateBlockRoleAction::setFilterPatterns ( array  $patterns)

Set filter patterns.

Parameters
ilDidacticTemplateFilterPattern[]$patterns

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

Referenced by __clone().

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

◆ setFilterType()

ilDidacticTemplateBlockRoleAction::setFilterType ( int  $a_type)

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

Referenced by read().

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

◆ toXml()

ilDidacticTemplateBlockRoleAction::toXml ( ilXmlWriter  $writer)

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

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

174  : void
175  {
176  $writer->xmlStartTag('blockRoleAction');
177 
178  switch ($this->getFilterType()) {
179  case self::FILTER_SOURCE_OBJ_ID:
180  $writer->xmlStartTag('roleFilter', ['source' => 'objId']);
181  break;
182 
183  case self::FILTER_PARENT_ROLES:
184  $writer->xmlStartTag('roleFilter', ['source' => 'parentRoles']);
185  break;
186 
187  case self::FILTER_SOURCE_TITLE:
188  default:
189  $writer->xmlStartTag('roleFilter', ['source' => 'title']);
190  break;
191  }
192 
193  foreach ($this->getFilterPattern() as $pattern) {
194  $pattern->toXml($writer);
195  }
196  $writer->xmlEndTag('roleFilter');
197  $writer->xmlEndTag('blockRoleAction');
198  }
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 29 of file class.ilDidacticTemplateBlockRoleAction.php.

Referenced by getFilterType().

◆ $pattern

array ilDidacticTemplateBlockRoleAction::$pattern = []
private

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