ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilDidacticTemplateLocalPolicyAction Class Reference

Description of class. More...

+ Inheritance diagram for ilDidacticTemplateLocalPolicyAction:
+ Collaboration diagram for ilDidacticTemplateLocalPolicyAction:

Public Member Functions

 __construct ($action_id=0)
 Constructor.
 addFilterPattern (ilDidacticTemplateFilterPattern $pattern)
 Add filter.
 setFilterPatterns (Array $patterns)
 Set filter patterns.
 getFilterPattern ()
 Get filter pattern.
 setFilterType ($a_type)
 Set filter type.
 getFilterType ()
 Get filter type.
 setRoleTemplateType ($a_tpl_type)
 Set Role template type.
 getRoleTemplateType ()
 Get role template type.
 setRoleTemplateId ($a_id)
 Set role template id.
 getRoleTemplateId ()
 Get role template id.
 save ()
 Save action.
 delete ()
 delete action filter ilDB $ilDB
 apply ()
 Apply action.
 revert ()
 Revert action.
 getType ()
 Get action type.
 toXml (ilXmlWriter $writer)
 Export to xml.
 __clone ()
 clone method
 read ()
 ilDB $ilDB
- Public Member Functions inherited from ilDidacticTemplateAction
 getActionId ()
 Get action id.
 setActionId ($a_action_id)
 Set action id.
 setType ($a_type_id)
 Set type id.
 setTemplateId ($a_id)
 Set template id.
 getTemplateId ()
 Get template id.
 setRefId ($a_ref_id)
 Set ref id of target object.
 getRefId ()
 Get ref id of target object.

Data Fields

const TPL_ACTION_OVERWRITE = 1
const TPL_ACTION_INTERSECT = 2
const TPL_ACTION_ADD = 3
const TPL_ACTION_SUBTRACT = 4
const TPL_ACTION_UNION = 5
- 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

 createLocalPolicy (ilObject $source, $role)
 Create local policy.
 revertLocalPolicy (ilObject $source, $role)
- Protected Member Functions inherited from ilDidacticTemplateAction
 initSourceObject ()
 Init the source object.
 filterRoles (ilObject $source)
 Filter roles.

Private Attributes

 $pattern = array()
 $filter_type = self::FILTER_SOURCE_TITLE
 $role_template_type = self::TPL_ACTION_OVERWRITE
 $role_template_id = 0

Detailed Description

Description of class.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 12 of file class.ilDidacticTemplateLocalPolicyAction.php.

Constructor & Destructor Documentation

ilDidacticTemplateLocalPolicyAction::__construct (   $action_id = 0)

Constructor.

Parameters
int$action_id

Reimplemented from ilDidacticTemplateAction.

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

References ilDidacticTemplateAction\$action_id.

Member Function Documentation

ilDidacticTemplateLocalPolicyAction::__clone ( )

clone method

Reimplemented from ilDidacticTemplateAction.

Definition at line 330 of file class.ilDidacticTemplateLocalPolicyAction.php.

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

{
// Clone patterns
$cloned = array();
foreach($this->getFilterPattern() as $pattern)
{
$clones[] = clone $pattern;
}
$this->setFilterPatterns($clones);
}

+ Here is the call graph for this function:

ilDidacticTemplateLocalPolicyAction::addFilterPattern ( ilDidacticTemplateFilterPattern  $pattern)

Add filter.

Parameters
ilDidacticTemplateFilterPatter$pattern

Definition at line 40 of file class.ilDidacticTemplateLocalPolicyAction.php.

References $pattern.

Referenced by read().

{
$this->pattern[] = $pattern;
}

+ Here is the caller graph for this function:

ilDidacticTemplateLocalPolicyAction::apply ( )

Apply action.

Reimplemented from ilDidacticTemplateAction.

Definition at line 171 of file class.ilDidacticTemplateLocalPolicyAction.php.

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

{
global $rbacreview;
$source = $this->initSourceObject();
// Create a role folder for the new local policies
$roles = $this->filterRoles($source);
// Create role folder if there is any local role left
$rolf = $rbacreview->getRoleFolderIdOfObject($source->getRefId());
if(count($roles) and !$rolf)
{
$rolf = $source->createRoleFolder();
$rolf = $rolf->getRefId();
}
// Create local policy for filtered roles
foreach($roles as $role_id => $role)
{
// No local policies for protected roles of higher context
if($role['protected'] and $role['parent'] != $rolf)
{
continue;
}
$this->createLocalPolicy($source,$role);
}
return true;
}

+ Here is the call graph for this function:

ilDidacticTemplateLocalPolicyAction::createLocalPolicy ( ilObject  $source,
  $role 
)
protected

Create local policy.

Parameters
ilObject$source
array$role
Returns
bool

Definition at line 377 of file class.ilDidacticTemplateLocalPolicyAction.php.

References $GLOBALS, ilObject\getRefId(), getRoleTemplateId(), getRoleTemplateType(), ilObjRole\MODE_PROTECTED_DELETE_LOCAL_POLICIES, and ilObjRole\MODE_UNPROTECTED_DELETE_LOCAL_POLICIES.

Referenced by apply().

{
global $rbacreview, $rbacadmin;
$GLOBALS['ilLog']->write(__METHOD__.': Using role: '.print_r($role,true));
$role_folder_id = $rbacreview->getRoleFolderIdOfObject($source->getRefId());
$GLOBALS['ilLog']->write(__METHOD__.': Role folder id: '.$role_folder_id);
// Add local policy
if(!$rbacreview->isRoleAssignedToFolder($role['obj_id'],$role_folder_id))
{
$rbacadmin->assignRoleToFolder($role['obj_id'],$role_folder_id,'n');
}
switch($this->getRoleTemplateType())
{
case self::TPL_ACTION_UNION:
$GLOBALS['ilLog']->write(__METHOD__.': Using ilRbacAdmin::copyRolePermissionUnion()');
$rbacadmin->copyRolePermissionUnion(
$role['obj_id'],
$role['parent'],
ROLE_FOLDER_ID,
$role['obj_id'],
$role_folder_id
);
break;
case self::TPL_ACTION_OVERWRITE:
$GLOBALS['ilLog']->write(__METHOD__.': Using ilRbacAdmin::copyRoleTemplatePermissions()');
$rbacadmin->copyRoleTemplatePermissions(
ROLE_FOLDER_ID,
$role_folder_id,
$role['obj_id'],
true
);
break;
case self::TPL_ACTION_INTERSECT:
$GLOBALS['ilLog']->write(__METHOD__.': Using ilRbacAdmin::copyRolePermissionIntersection()');
$rbacadmin->copyRolePermissionIntersection(
$role['obj_id'],
$role['parent'],
ROLE_FOLDER_ID,
$role_folder_id,
$role['obj_id']
);
break;
}
// Change existing object
include_once './Services/AccessControl/classes/class.ilObjRole.php';
$role_obj = new ilObjRole($role['obj_id']);
$role_obj->changeExistingObjects(
$source->getRefId(),
array('all')
);
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilDidacticTemplateLocalPolicyAction::delete ( )

delete action filter ilDB $ilDB

Returns
bool

Reimplemented from ilDidacticTemplateAction.

Definition at line 148 of file class.ilDidacticTemplateLocalPolicyAction.php.

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

{
global $ilDB;
$query = 'DELETE FROM didactic_tpl_alp '.
'WHERE action_id = '.$ilDB->quote($this->getActionId(),'integer');
$ilDB->manipulate($query);
foreach($this->getFilterPattern() as $pattern)
{
$pattern->delete();
}
return true;
}

+ Here is the call graph for this function:

ilDidacticTemplateLocalPolicyAction::getFilterPattern ( )

Get filter pattern.

Returns
array

Definition at line 58 of file class.ilDidacticTemplateLocalPolicyAction.php.

References $pattern.

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

{
}

+ Here is the caller graph for this function:

ilDidacticTemplateLocalPolicyAction::getFilterType ( )

Get filter type.

Returns
int

Definition at line 76 of file class.ilDidacticTemplateLocalPolicyAction.php.

References $filter_type.

Referenced by save(), and toXml().

{
}

+ Here is the caller graph for this function:

ilDidacticTemplateLocalPolicyAction::getRoleTemplateId ( )

Get role template id.

Returns
int

Definition at line 111 of file class.ilDidacticTemplateLocalPolicyAction.php.

References $role_template_id.

Referenced by createLocalPolicy(), save(), and toXml().

+ Here is the caller graph for this function:

ilDidacticTemplateLocalPolicyAction::getRoleTemplateType ( )

Get role template type.

Definition at line 93 of file class.ilDidacticTemplateLocalPolicyAction.php.

References $role_template_type.

Referenced by createLocalPolicy(), save(), and toXml().

+ Here is the caller graph for this function:

ilDidacticTemplateLocalPolicyAction::getType ( )

Get action type.

Returns
int

Reimplemented from ilDidacticTemplateAction.

Definition at line 249 of file class.ilDidacticTemplateLocalPolicyAction.php.

References ilDidacticTemplateAction\TYPE_LOCAL_POLICY.

ilDidacticTemplateLocalPolicyAction::read ( )

ilDB $ilDB

Reimplemented from ilDidacticTemplateAction.

Definition at line 343 of file class.ilDidacticTemplateLocalPolicyAction.php.

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

{
global $ilDB;
if(!parent::read())
{
return false;
}
$query = 'SELECT * FROM didactic_tpl_alp '.
'WHERE action_id = '.$ilDB->quote($this->getActionId());
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->setFilterType($row->filter_type);
$this->setRoleTemplateType($row->template_type);
$this->setRoleTemplateId($row->template_id);
}
// Read filter
include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateFilterPatternFactory.php';
{
$this->addFilterPattern($pattern);
}
}

+ Here is the call graph for this function:

ilDidacticTemplateLocalPolicyAction::revert ( )

Revert action.

ilRbacReview

Reimplemented from ilDidacticTemplateAction.

Definition at line 206 of file class.ilDidacticTemplateLocalPolicyAction.php.

References ilDidacticTemplateAction\filterRoles(), ilDidacticTemplateAction\initSourceObject(), ilObjRole\MODE_PROTECTED_DELETE_LOCAL_POLICIES, ilObjRole\MODE_UNPROTECTED_DELETE_LOCAL_POLICIES, and revertLocalPolicy().

{
global $rbacreview,$rbacadmin,$tree;
$source = $this->initSourceObject();
$rolf = $rbacreview->getRoleFolderIdOfObject($source->getRefId());
$roles = $this->filterRoles($source);
// Delete local policy for filtered roles
foreach($roles as $role_id => $role)
{
// Do not delete local roles of auto genrated roles
if(!$rbacreview->isGlobalRole($role['obj_id']) and
$rbacreview->isAssignable($role['obj_id'],$role['parent']) and
$rbacreview->isSystemGeneratedRole($role['obj_id']))
{
$this->revertLocalPolicy($source, $role);
}
else
{
// delete local role and change exiting objects
$rbacadmin->deleteLocalRole($role_id,$rolf);
// Change existing object
include_once './Services/AccessControl/classes/class.ilObjRole.php';
$role_obj = new ilObjRole($role_id);
$role_obj->changeExistingObjects(
$source->getRefId(),
$role['protected'] ?
array('all')
);
}
}
return true;
}

+ Here is the call graph for this function:

ilDidacticTemplateLocalPolicyAction::revertLocalPolicy ( ilObject  $source,
  $role 
)
protected

Definition at line 448 of file class.ilDidacticTemplateLocalPolicyAction.php.

References $GLOBALS, $query, $res, $row, DB_FETCHMODE_OBJECT, ilObject\getRefId(), ilObjRole\MODE_PROTECTED_DELETE_LOCAL_POLICIES, and ilObjRole\MODE_UNPROTECTED_DELETE_LOCAL_POLICIES.

Referenced by revert().

{
global $rbacadmin, $rbacreview, $ilDB;
$GLOBALS['ilLog']->write(__METHOD__.': Reverting policy for role: '.print_r($role,true));
// Local policies can only be reverted for auto generated roles. Otherwise the
// original role settings are unknown
if(substr($role['title'],0,3) != 'il_')
{
$GLOBALS['ilLog']->write(__METHOD__.': Cannot revert local policy for role '. $role['title']);
return false;
}
$role_folder_id = $rbacreview->getRoleFolderIdOfObject($source->getRefId());
// No role folder found
if(!$role_folder_id)
{
return false;
}
$exploded_title = explode('_',$role['title']);
$rolt_title = $exploded_title[0].'_'.$exploded_title[1].'_'.$exploded_title[2];
// Lookup role template
$query = 'SELECT obj_id FROM object_data '.
'WHERE title = '.$ilDB->quote($rolt_title,'text').' '.
'AND type = '.$ilDB->quote('rolt','text');
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$rolt_id = $row->obj_id;
}
// No template found
if(!$rolt_id)
{
return false;
}
$rbacadmin->copyRoleTemplatePermissions(
$rolt_id,
ROLE_FOLDER_ID,
$role_folder_id,
$role['obj_id'],
true
);
// Change existing object
include_once './Services/AccessControl/classes/class.ilObjRole.php';
$role_obj = new ilObjRole($role['obj_id']);
$role_obj->changeExistingObjects(
$source->getRefId(),
array('all')
);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilDidacticTemplateLocalPolicyAction::save ( )

Save action.

Reimplemented from ilDidacticTemplateAction.

Definition at line 119 of file class.ilDidacticTemplateLocalPolicyAction.php.

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

{
global $ilDB;
$query = 'INSERT INTO didactic_tpl_alp (action_id,filter_type,template_type,template_id) '.
'VALUES( '.
$ilDB->quote($this->getActionId(),'integer').', '.
$ilDB->quote($this->getFilterType(),'integer').', '.
$ilDB->quote($this->getRoleTemplateType(),'integer').', '.
$ilDB->quote($this->getRoleTemplateId(),'integer').' '.
')';
$ilDB->manipulate($query);
foreach($this->getFilterPattern() as $pattern)
{
/* @var ilDidacticTemplateFilterPattern $pattern */
$pattern->setParentId($this->getActionId());
$pattern->setParentType(self::PATTERN_PARENT_TYPE);
$pattern->save();
}
}

+ Here is the call graph for this function:

ilDidacticTemplateLocalPolicyAction::setFilterPatterns ( Array  $patterns)

Set filter patterns.

Parameters
array$patterns

Definition at line 49 of file class.ilDidacticTemplateLocalPolicyAction.php.

Referenced by __clone().

{
$this->pattern = $patterns;
}

+ Here is the caller graph for this function:

ilDidacticTemplateLocalPolicyAction::setFilterType (   $a_type)

Set filter type.

Parameters
int$a_type

Definition at line 67 of file class.ilDidacticTemplateLocalPolicyAction.php.

Referenced by read().

{
$this->filter_type = $a_type;
}

+ Here is the caller graph for this function:

ilDidacticTemplateLocalPolicyAction::setRoleTemplateId (   $a_id)

Set role template id.

Parameters
int$a_id

Definition at line 102 of file class.ilDidacticTemplateLocalPolicyAction.php.

Referenced by read().

{
$this->role_template_id = $a_id;
}

+ Here is the caller graph for this function:

ilDidacticTemplateLocalPolicyAction::setRoleTemplateType (   $a_tpl_type)

Set Role template type.

Parameters
int$a_tpl_type

Definition at line 85 of file class.ilDidacticTemplateLocalPolicyAction.php.

Referenced by read().

{
$this->role_template_type = $a_tpl_type;
}

+ Here is the caller graph for this function:

ilDidacticTemplateLocalPolicyAction::toXml ( ilXmlWriter  $writer)

Export to xml.

Parameters
ilXmlWriter$writer
Returns
void

Reimplemented from ilDidacticTemplateAction.

Definition at line 259 of file class.ilDidacticTemplateLocalPolicyAction.php.

References $pattern, ilObject\_lookupType(), ilXmlWriter\appendXML(), getFilterPattern(), getFilterType(), getRoleTemplateId(), getRoleTemplateType(), ilRoleXmlExport\MODE_DTPL, ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

{
$writer->xmlStartTag('localPolicyAction');
switch($this->getFilterType())
{
case self::FILTER_SOURCE_TITLE:
$writer->xmlStartTag('roleFilter',array('source' => 'title'));
break;
case self::FILTER_SOURCE_OBJ_ID:
$writer->xmlStartTag('roleFilter',array('source' => 'objId'));
break;
}
foreach($this->getFilterPattern() as $pattern)
{
$pattern->toXml($writer);
}
$writer->xmlEndTag('roleFilter');
$il_role_id = 'il_'.IL_INST_ID.'_'.ilObject::_lookupType($this->getRoleTemplateId()).'_'.$this->getRoleTemplateId();
switch($this->getRoleTemplateType())
{
case self::TPL_ACTION_OVERWRITE:
$writer->xmlStartTag(
'localPolicyTemplate',
array(
'type' => 'overwrite',
'id' => $il_role_id
)
);
break;
case self::TPL_ACTION_INTERSECT:
$writer->xmlStartTag(
'localPolicyTemplate',
array(
'type' => 'intersect',
'id' => $il_role_id
)
);
break;
case self::TPL_ACTION_UNION:
$writer->xmlStartTag(
'localPolicyTemplate',
array(
'type' => 'union',
'id' => $il_role_id
)
);
break;
}
include_once './Services/AccessControl/classes/class.ilRoleXmlExport.php';
$exp = new ilRoleXmlExport();
$exp->addRole($this->getRoleTemplateId(), ROLE_FOLDER_ID);
$exp->write();
$writer->appendXML($exp->xmlDumpMem(FALSE));
$writer->xmlEndTag('localPolicyTemplate');
$writer->xmlEndTag('localPolicyAction');
return void;
}

+ Here is the call graph for this function:

Field Documentation

ilDidacticTemplateLocalPolicyAction::$filter_type = self::FILTER_SOURCE_TITLE
private

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

Referenced by getFilterType().

ilDidacticTemplateLocalPolicyAction::$pattern = array()
private
ilDidacticTemplateLocalPolicyAction::$role_template_id = 0
private

Definition at line 24 of file class.ilDidacticTemplateLocalPolicyAction.php.

Referenced by getRoleTemplateId().

ilDidacticTemplateLocalPolicyAction::$role_template_type = self::TPL_ACTION_OVERWRITE
private

Definition at line 23 of file class.ilDidacticTemplateLocalPolicyAction.php.

Referenced by getRoleTemplateType().

const ilDidacticTemplateLocalPolicyAction::TPL_ACTION_ADD = 3
const ilDidacticTemplateLocalPolicyAction::TPL_ACTION_INTERSECT = 2
const ilDidacticTemplateLocalPolicyAction::TPL_ACTION_OVERWRITE = 1
const ilDidacticTemplateLocalPolicyAction::TPL_ACTION_SUBTRACT = 4
const ilDidacticTemplateLocalPolicyAction::TPL_ACTION_UNION = 5

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