ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 @global 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 @global 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 ()
 @global 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 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

Reimplemented from ilDidacticTemplateAction.

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

29 {
30 parent::__construct($action_id);
31 }

References ilDidacticTemplateAction\$action_id.

Member Function Documentation

◆ __clone()

ilDidacticTemplateBlockRoleAction::__clone ( )

clone method

Reimplemented from ilDidacticTemplateAction.

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

256 {
257 parent::__clone();
258
259 // Clone patterns
260 $cloned = array();
261 foreach ($this->getFilterPattern() as $pattern) {
262 $clones[] = clone $pattern;
263 }
264 $this->setFilterPatterns($clones);
265 }
setFilterPatterns(array $patterns)
Set filter patterns.

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

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

38 {
39 $this->pattern[] = $pattern;
40 }

References $pattern.

Referenced by read().

+ Here is the caller graph for this function:

◆ apply()

ilDidacticTemplateBlockRoleAction::apply ( )

Apply action.

Reimplemented from ilDidacticTemplateAction.

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

130 {
131 $source = $this->initSourceObject();
132 $roles = $this->filterRoles($source);
133
134 // Create local policy for filtered roles
135 foreach ($roles as $role_id => $role) {
136 $this->blockRole($role_id, $source);
137 }
138 return true;
139 }
$source
Definition: linkback.php:22
initSourceObject()
Init the source object.
filterRoles(ilObject $source)
Filter roles.

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

+ 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 146 of file class.ilDidacticTemplateBlockRoleAction.php.

147 {
148 global $rbacadmin, $rbacreview;
149
150 // Set assign to 'y' only if it is a local role
151 $assign = $rbacreview->isAssignable($a_role_id, $source->getRefId()) ? 'y' : 'n';
152
153 // Delete permissions
154 $rbacadmin->revokeSubtreePermissions($source->getRefId(), $a_role_id);
155
156 // Delete template permissions
157 $rbacadmin->deleteSubtreeTemplates($source->getRefId(), $a_role_id);
158
159 $rbacadmin->assignRoleToFolder(
160 $a_role_id,
161 $source->getRefId(),
162 $assign
163 );
164 return true;
165 }

References $source.

Referenced by apply().

+ Here is the caller graph for this function:

◆ delete()

ilDidacticTemplateBlockRoleAction::delete ( )

delete action filter @global ilDB $ilDB

Returns
bool

Reimplemented from ilDidacticTemplateAction.

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

108 {
109 global $ilDB;
110
111 parent::delete();
112
113 $query = 'DELETE FROM didactic_tpl_abr ' .
114 'WHERE action_id = ' . $ilDB->quote($this->getActionId(), 'integer');
115 $ilDB->manipulate($query);
116
117 foreach ($this->getFilterPattern() as $pattern) {
118 $pattern->delete();
119 }
120 return true;
121 }
$query
global $ilDB

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

+ 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 188 of file class.ilDidacticTemplateBlockRoleAction.php.

189 {
190 global $rbacreview, $rbacadmin;
191
192 // Create role folder if it does not exist
193 //$rolf = $rbacreview->getRoleFolderIdOfObject($source->getRefId());
194
195 if ($rbacreview->getRoleFolderOfRole($a_role_id) == $source->getRefId()) {
196 ilLoggerFactory::getLogger('otpl')->debug('Ignoring local role: ' . ilObject::_lookupTitle($a_role_id));
197 return false;
198 }
199
200 $rbacadmin->deleteLocalRole($a_role_id, $source->getRefId());
201
202 // Change existing object
203 include_once './Services/AccessControl/classes/class.ilObjRole.php';
204 $role = new ilObjRole($a_role_id);
205 $role->changeExistingObjects(
206 $source->getRefId(),
208 array('all')
209 );
210
211 return true;
212 }
static getLogger($a_component_id)
Get component logger.
Class ilObjRole.
const MODE_UNPROTECTED_DELETE_LOCAL_POLICIES
static _lookupTitle($a_id)
lookup object title

References $source, ilObject\_lookupTitle(), ilLoggerFactory\getLogger(), 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 pattern.

Returns
array

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

56 {
57 return $this->pattern;
58 }

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

Reimplemented from ilDidacticTemplateAction.

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

References ilDidacticTemplateAction\TYPE_BLOCK_ROLE.

◆ read()

ilDidacticTemplateBlockRoleAction::read ( )

read action data @global ilDB $ilDB

Returns
bool

Reimplemented from ilDidacticTemplateAction.

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

273 {
274 global $ilDB;
275
276 if (!parent::read()) {
277 return false;
278 }
279
280 $query = 'SELECT * FROM didactic_tpl_abr ' .
281 'WHERE action_id = ' . $ilDB->quote($this->getActionId());
282 $res = $ilDB->query($query);
283 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
284 $this->setFilterType($row->filter_type);
285 }
286
287 // Read filter
288 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateFilterPatternFactory.php';
289 foreach (ilDidacticTemplateFilterPatternFactory::lookupPatternsByParentId($this->getActionId(), self::PATTERN_PARENT_TYPE) as $pattern) {
290 $this->addFilterPattern($pattern);
291 }
292 }
addFilterPattern(ilDidacticTemplateFilterPattern $pattern)
Add filter.
static lookupPatternsByParentId($a_parent_id, $a_parent_type)
Get patterns by template id.
foreach($_POST as $key=> $value) $res

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

+ Here is the call graph for this function:

◆ revert()

ilDidacticTemplateBlockRoleAction::revert ( )

Revert action.

Reimplemented from ilDidacticTemplateAction.

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

171 {
172 $source = $this->initSourceObject();
173 $roles = $this->filterRoles($source);
174
175 // Create local policy for filtered roles
176 foreach ($roles as $role_id => $role) {
177 $this->deleteLocalPolicy($role_id, $source);
178 }
179 return true;
180 }
deleteLocalPolicy($a_role_id, $source)
Delete local policy.

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

+ Here is the call graph for this function:

◆ save()

ilDidacticTemplateBlockRoleAction::save ( )

Save action.

Reimplemented from ilDidacticTemplateAction.

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

82 {
83 global $ilDB;
84
85 parent::save();
86
87 $query = 'INSERT INTO didactic_tpl_abr (action_id,filter_type) ' .
88 'VALUES( ' .
89 $ilDB->quote($this->getActionId(), 'integer') . ', ' .
90 $ilDB->quote($this->getFilterType(), 'integer') . ' ' .
91 ')';
92 $ilDB->manipulate($query);
93
94 foreach ($this->getFilterPattern() as $pattern) {
95 /* @var ilDidacticTemplateFilterPattern $pattern */
96 $pattern->setParentId($this->getActionId());
97 $pattern->setParentType(self::PATTERN_PARENT_TYPE);
98 $pattern->save();
99 }
100 }

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

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

47 {
48 $this->pattern = $patterns;
49 }

Referenced by __clone().

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

65 {
66 $this->filter_type = $a_type;
67 }
$a_type
Definition: workflow.php:92

References $a_type.

Referenced by read().

+ Here is the caller graph for this function:

◆ toXml()

ilDidacticTemplateBlockRoleAction::toXml ( ilXmlWriter  $writer)

Export to xml.

Parameters
ilXmlWriter$writer
Returns
void

Reimplemented from ilDidacticTemplateAction.

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

230 {
231 $writer->xmlStartTag('blockRoleAction');
232
233 switch ($this->getFilterType()) {
235 $writer->xmlStartTag('roleFilter', array('source' => 'objId'));
236 break;
237
238 default:
240 $writer->xmlStartTag('roleFilter', array('source' => 'title'));
241 break;
242 }
243
244 foreach ($this->getFilterPattern() as $pattern) {
245 $pattern->toXml($writer);
246 }
247 $writer->xmlEndTag('roleFilter');
248 $writer->xmlEndTag('blockRoleAction');
249 return;
250 }
xmlEndTag($tag)
Writes an endtag.
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.

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

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

Referenced by toXml().

◆ FILTER_SOURCE_TITLE

const ilDidacticTemplateBlockRoleAction::FILTER_SOURCE_TITLE = 1

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

Referenced by toXml().

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