ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 ()
 Write action to db Overwrite for filling additional db fields. More...
 
 delete ()
 Delete didactic template action Overwrite for filling additional db fields. More...
 
 apply ()
 Apply action. More...
 
 revert ()
 Implement everthing that is necessary to revert a didactic template return bool. More...
 
 getType ()
 Get type of template. More...
 
 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)

Reimplemented from ilDidacticTemplateAction.

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

32 {
34 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ Here is the call graph for this function:

Member Function Documentation

◆ __clone()

ilDidacticTemplateBlockRoleAction::__clone ( )

Reimplemented from ilDidacticTemplateAction.

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

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.

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

+ Here is the call graph for this function:

◆ addFilterPattern()

ilDidacticTemplateBlockRoleAction::addFilterPattern ( ilDidacticTemplateFilterPattern  $pattern)

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

36 : void
37 {
38 $this->pattern[] = $pattern;
39 }

References $pattern.

Referenced by read().

+ Here is the caller graph for this function:

◆ apply()

ilDidacticTemplateBlockRoleAction::apply ( )

Apply action.

Returns
bool

Reimplemented from ilDidacticTemplateAction.

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

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 }

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

+ 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.

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 }

References ilObject\getRefId().

Referenced by apply().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilDidacticTemplateBlockRoleAction::delete ( )

Delete didactic template action Overwrite for filling additional db fields.

Reimplemented from ilDidacticTemplateAction.

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

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 }

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

+ 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.

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.
const MODE_UNPROTECTED_DELETE_LOCAL_POLICIES
static _lookupTitle(int $obj_id)

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

Referenced by revert().

+ 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.

54 : array
55 {
56 return $this->pattern;
57 }

References $pattern.

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

+ 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 ( )

Get type of template.

Returns
int $type

Reimplemented from ilDidacticTemplateAction.

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

169 : int
170 {
172 }

References ilDidacticTemplateAction\TYPE_BLOCK_ROLE.

◆ read()

ilDidacticTemplateBlockRoleAction::read ( )

Reimplemented from ilDidacticTemplateAction.

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

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 }
addFilterPattern(ilDidacticTemplateFilterPattern $pattern)
static lookupPatternsByParentId(int $a_parent_id, string $a_parent_type)
$res
Definition: ltiservices.php:69

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

+ Here is the call graph for this function:

◆ revert()

ilDidacticTemplateBlockRoleAction::revert ( )

Implement everthing that is necessary to revert a didactic template return bool.

Reimplemented from ilDidacticTemplateAction.

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

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 }

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

+ Here is the call graph for this function:

◆ save()

ilDidacticTemplateBlockRoleAction::save ( )

Write action to db Overwrite for filling additional db fields.

Returns
int

Reimplemented from ilDidacticTemplateAction.

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

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 }

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

+ 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.

45 : void
46 {
47 $this->pattern = $patterns;
48 }

Referenced by __clone().

+ Here is the caller graph for this function:

◆ setFilterType()

ilDidacticTemplateBlockRoleAction::setFilterType ( int  $a_type)

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

59 : void
60 {
61 $this->filter_type = $a_type;
62 }

Referenced by read().

+ Here is the caller graph for this function:

◆ toXml()

ilDidacticTemplateBlockRoleAction::toXml ( ilXmlWriter  $writer)

Reimplemented from ilDidacticTemplateAction.

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

174 : void
175 {
176 $writer->xmlStartTag('blockRoleAction');
177
178 switch ($this->getFilterType()) {
180 $writer->xmlStartTag('roleFilter', ['source' => 'objId']);
181 break;
182
184 $writer->xmlStartTag('roleFilter', ['source' => 'parentRoles']);
185 break;
186
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.

References $pattern, ilDidacticTemplateAction\FILTER_PARENT_ROLES, ilDidacticTemplateAction\FILTER_SOURCE_OBJ_ID, ilDidacticTemplateAction\FILTER_SOURCE_TITLE, getFilterPattern(), getFilterType(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

+ 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: