ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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 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 ilDB $ilDB More...
 
- Public Member Functions inherited from ilDidacticTemplateAction
 __construct ($action_id=0)
 Constructor. 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 ()
 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 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 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

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

References ilDidacticTemplateAction\$action_id.

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

Member Function Documentation

◆ __clone()

ilDidacticTemplateBlockRoleAction::__clone ( )

clone method

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

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

274  {
275  parent::__clone();
276 
277  // Clone patterns
278  $cloned = array();
279  foreach($this->getFilterPattern() as $pattern)
280  {
281  $clones[] = clone $pattern;
282  }
283  $this->setFilterPatterns($clones);
284  }
setFilterPatterns(Array $patterns)
Set filter patterns.
+ Here is the call graph for this function:

◆ addFilterPattern()

ilDidacticTemplateBlockRoleAction::addFilterPattern ( ilDidacticTemplateFilterPattern  $pattern)

Add filter.

Parameters
ilDidacticTemplateFilterPatter$pattern

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

References $pattern.

Referenced by read().

+ Here is the caller graph for this function:

◆ apply()

ilDidacticTemplateBlockRoleAction::apply ( )

Apply action.

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

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

131  {
132  $source = $this->initSourceObject();
133  $roles = $this->filterRoles($source);
134 
135  // Create local policy for filtered roles
136  foreach($roles as $role_id => $role)
137  {
138  $this->blockRole($role_id, $source);
139  }
140  return true;
141  }
filterRoles(ilObject $source)
Filter roles.
initSourceObject()
Init the source object.
+ 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 148 of file class.ilDidacticTemplateBlockRoleAction.php.

Referenced by apply().

149  {
150  global $rbacadmin, $rbacreview;
151 
152  // Create role folder if it does not exist
153  $rolf = $rbacreview->getRoleFolderIdOfObject($source->getRefId());
154  if(!$rolf)
155  {
156  $rolf_obj = $source->createRoleFolder();
157  $rolf = $rolf_obj->getRefId();
158  }
159 
160  // Set assign to 'y' only if it is a local role
161  $assign = $rbacreview->isAssignable($a_role_id, $rolf) ? 'y' : 'n';
162 
163  // Delete permissions
164  $rbacadmin->revokeSubtreePermissions($source->getRefId(), $a_role_id);
165 
166  // Delete template permissions
167  $rbacadmin->deleteSubtreeTemplates($source->getRefId(), $a_role_id);
168 
169  $rbacadmin->assignRoleToFolder(
170  $a_role_id,
171  $rolf,
172  $assign
173  );
174  return true;
175  }
+ Here is the caller graph for this function:

◆ delete()

ilDidacticTemplateBlockRoleAction::delete ( )

delete action filter ilDB $ilDB

Returns
bool

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

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

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  {
119  $pattern->delete();
120  }
121  return true;
122  }
+ 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 199 of file class.ilDidacticTemplateBlockRoleAction.php.

References $GLOBALS, ilObject\_lookupTitle(), and ilObjRole\MODE_UNPROTECTED_DELETE_LOCAL_POLICIES.

Referenced by revert().

200  {
201  global $rbacreview, $rbacadmin;
202 
203  // Create role folder if it does not exist
204  $rolf = $rbacreview->getRoleFolderIdOfObject($source->getRefId());
205  if(!$rolf)
206  {
207  return false;
208  }
209 
210  if($rbacreview->getRoleFolderOfRole($a_role_id) == $rolf)
211  {
212  $GLOBALS['ilLog']->write(__METHOD__.': Ignoring local role: '.ilObject::_lookupTitle($a_role_id));
213  return false;
214  }
215 
216  $rbacadmin->deleteLocalRole($a_role_id, $rolf);
217 
218  // Change existing object
219  include_once './Services/AccessControl/classes/class.ilObjRole.php';
220  $role = new ilObjRole($a_role_id);
221  $role->changeExistingObjects(
222  $source->getRefId(),
224  array('all')
225  );
226 
227  return true;
228  }
Class ilObjRole.
static _lookupTitle($a_id)
lookup object title
$GLOBALS['ct_recipient']
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 pattern.

Returns
array

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

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 72 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

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

236  {
237  return self::TYPE_BLOCK_ROLE;
238  }

◆ read()

ilDidacticTemplateBlockRoleAction::read ( )

read action data ilDB $ilDB

Returns
bool

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

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

292  {
293  global $ilDB;
294 
295  if(!parent::read())
296  {
297  return false;
298  }
299 
300  $query = 'SELECT * FROM didactic_tpl_abr '.
301  'WHERE action_id = '.$ilDB->quote($this->getActionId());
302  $res = $ilDB->query($query);
303  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
304  {
305  $this->setFilterType($row->filter_type);
306  }
307 
308  // Read filter
309  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateFilterPatternFactory.php';
310  foreach(ilDidacticTemplateFilterPatternFactory::lookupPatternsByParentId($this->getActionId(),self::PATTERN_PARENT_TYPE) as $pattern)
311  {
312  $this->addFilterPattern($pattern);
313  }
314  }
static lookupPatternsByParentId($a_parent_id, $a_parent_type)
Get patterns by template id.
addFilterPattern(ilDidacticTemplateFilterPattern $pattern)
Add filter.
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the call graph for this function:

◆ revert()

ilDidacticTemplateBlockRoleAction::revert ( )

Revert action.

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

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

181  {
182  $source = $this->initSourceObject();
183  $roles = $this->filterRoles($source);
184 
185  // Create local policy for filtered roles
186  foreach($roles as $role_id => $role)
187  {
188  $this->deleteLocalPolicy($role_id, $source);
189  }
190  return true;
191  }
deleteLocalPolicy($a_role_id, $source)
Delete local policy.
filterRoles(ilObject $source)
Filter roles.
initSourceObject()
Init the source object.
+ Here is the call graph for this function:

◆ save()

ilDidacticTemplateBlockRoleAction::save ( )

Save action.

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

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

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

◆ setFilterPatterns()

ilDidacticTemplateBlockRoleAction::setFilterPatterns ( Array  $patterns)

Set filter patterns.

Parameters
array$patterns

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

Referenced by __clone().

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

◆ setFilterType()

ilDidacticTemplateBlockRoleAction::setFilterType (   $a_type)

Set filter type.

Parameters
int$a_type

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

Referenced by read().

64  {
65  $this->filter_type = $a_type;
66  }
+ Here is the caller graph for this function:

◆ toXml()

ilDidacticTemplateBlockRoleAction::toXml ( ilXmlWriter  $writer)

Export to xml.

Parameters
ilXmlWriter$writer
Returns
void

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

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

246  {
247  $writer->xmlStartTag('blockRoleAction');
248 
249  switch($this->getFilterType())
250  {
251  case self::FILTER_SOURCE_OBJ_ID:
252  $writer->xmlStartTag('roleFilter',array('source' => 'objId'));
253  break;
254 
255  default:
256  case self::FILTER_SOURCE_TITLE:
257  $writer->xmlStartTag('roleFilter',array('source' => 'title'));
258  break;
259  }
260 
261  foreach($this->getFilterPattern() as $pattern)
262  {
263  $pattern->toXml($writer);
264  }
265  $writer->xmlEndTag('roleFilter');
266  $writer->xmlEndTag('blockRoleAction');
267  return;
268  }
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
xmlEndTag($tag)
Writes an endtag.
+ Here is the call graph for this function:

Field Documentation

◆ $filter_type

ilDidacticTemplateBlockRoleAction::$filter_type = self::FILTER_SOURCE_TITLE
private

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

Referenced by getFilterType().

◆ $pattern

ilDidacticTemplateBlockRoleAction::$pattern = array()
private

◆ FILTER_SOURCE_OBJ_ID

const ilDidacticTemplateBlockRoleAction::FILTER_SOURCE_OBJ_ID = 2

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

◆ FILTER_SOURCE_TITLE

const ilDidacticTemplateBlockRoleAction::FILTER_SOURCE_TITLE = 1

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

◆ PATTERN_PARENT_TYPE

const ilDidacticTemplateBlockRoleAction::PATTERN_PARENT_TYPE = 'action'

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


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