ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilDidacticTemplateLocalRoleAction Class Reference

represents a creation of local roles action More...

+ Inheritance diagram for ilDidacticTemplateLocalRoleAction:
+ Collaboration diagram for ilDidacticTemplateLocalRoleAction:

Public Member Functions

 __construct ($a_action_id=0)
 Constructor. More...
 
 getType ()
 Get action type. More...
 
 setRoleTemplateId ($a_role_template_id)
 Set role template id. More...
 
 getRoleTemplateId ()
 get role template id More...
 
 apply ()
 Apply action. More...
 
 revert ()
 Revert action. More...
 
 save ()
 Create new action. More...
 
 delete ()
 Delete @global ilDB $ilDB. More...
 
 toXml (ilXmlWriter $writer)
 Write xml of template action. More...
 
 read ()
 Read db entry @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...
 

Private Attributes

 $role_template_id = 0
 

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 PATTERN_PARENT_TYPE = 'action'
 
- Protected Member Functions inherited from ilDidacticTemplateAction
 initSourceObject ()
 Init the source object. More...
 
 filterRoles (ilObject $source)
 Filter roles. More...
 

Detailed Description

represents a creation of local roles action

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

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

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateLocalRoleAction::__construct (   $a_action_id = 0)

Constructor.

Parameters
int$a_action_id

Reimplemented from ilDidacticTemplateAction.

Definition at line 20 of file class.ilDidacticTemplateLocalRoleAction.php.

21 {
22 parent::__construct($a_action_id);
23 }

Member Function Documentation

◆ apply()

ilDidacticTemplateLocalRoleAction::apply ( )

Apply action.

Reimplemented from ilDidacticTemplateAction.

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

56 {
57 global $rbacreview, $rbacadmin;
58
59 $source = $this->initSourceObject();
60
61 // Check if role folder already exists
62
63 // Create role
64
65 include_once './Services/AccessControl/classes/class.ilObjRole.php';
66 $role = new ilObjRole();
67 $role->setTitle(ilObject::_lookupTitle($this->getRoleTemplateId()) . '_' . $this->getRefId());
68 $role->setDescription(ilObject::_lookupDescription($this->getRoleTemplateId()));
69 $role->create();
70 $rbacadmin->assignRoleToFolder($role->getId(), $source->getRefId(), "y");
71
72 ilLoggerFactory::getLogger('otpl')->info('Using rolt: ' . $this->getRoleTemplateId() . ' with title "' . ilObject::_lookupTitle($this->getRoleTemplateId() . '". '));
73
74 // Copy template permissions
75
76 ilLoggerFactory::getLogger('otpl')->debug(
77 'Copy role template permissions ' .
78 'tpl_id: ' . $this->getRoleTemplateId() . ' ' .
79 'parent: ' . ROLE_FOLDER_ID . ' ' .
80 'role_id: ' . $role->getId() . ' ' .
81 'role_parent: ' . $source->getRefId()
82 );
83
84
85 $rbacadmin->copyRoleTemplatePermissions(
86 $this->getRoleTemplateId(),
87 ROLE_FOLDER_ID,
88 $source->getRefId(),
89 $role->getId(),
90 true
91 );
92
93 // Set permissions
94 $ops = $rbacreview->getOperationsOfRole($role->getId(), $source->getType(), $source->getRefId());
95 $rbacadmin->grantPermission($role->getId(), $ops, $source->getRefId());
96
97 return true;
98 }
$source
Definition: linkback.php:22
initSourceObject()
Init the source object.
getRefId()
Get ref id of target object.
static getLogger($a_component_id)
Get component logger.
Class ilObjRole.
static _lookupTitle($a_id)
lookup object title
static _lookupDescription($a_id)
lookup object description

References $source, ilObject\_lookupDescription(), ilObject\_lookupTitle(), ilLoggerFactory\getLogger(), ilDidacticTemplateAction\getRefId(), getRoleTemplateId(), and ilDidacticTemplateAction\initSourceObject().

+ Here is the call graph for this function:

◆ delete()

ilDidacticTemplateLocalRoleAction::delete ( )

Delete @global ilDB $ilDB.

Returns
bool

Reimplemented from ilDidacticTemplateAction.

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

135 {
136 global $ilDB;
137
138 parent::delete();
139
140 $query = 'DELETE FROM didactic_tpl_alr ' .
141 'WHERE action_id = ' . $ilDB->quote($this->getActionId(), 'integer');
142 $ilDB->manipulate($query);
143
144 return true;
145 }
$query
global $ilDB

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

+ Here is the call graph for this function:

◆ getRoleTemplateId()

ilDidacticTemplateLocalRoleAction::getRoleTemplateId ( )

get role template id

Returns
int

Definition at line 47 of file class.ilDidacticTemplateLocalRoleAction.php.

References $role_template_id.

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

+ Here is the caller graph for this function:

◆ getType()

ilDidacticTemplateLocalRoleAction::getType ( )

Get action type.

Returns
int

Reimplemented from ilDidacticTemplateAction.

Definition at line 29 of file class.ilDidacticTemplateLocalRoleAction.php.

References ilDidacticTemplateAction\TYPE_LOCAL_ROLE.

◆ read()

ilDidacticTemplateLocalRoleAction::read ( )

Read db entry @global ilDB $ilDB.

Returns
bool

Reimplemented from ilDidacticTemplateAction.

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

181 {
182 global $ilDB;
183
184 parent::read();
185
186 $query = 'SELECT * FROM didactic_tpl_alr ' .
187 'WHERE action_id = ' . $ilDB->quote($this->getActionId(), 'integer');
188 $res = $ilDB->query($query);
189 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
190 $this->setRoleTemplateId($row->role_template_id);
191 }
192 return true;
193 }
setRoleTemplateId($a_role_template_id)
Set role template id.
foreach($_POST as $key=> $value) $res

References $ilDB, $query, $res, $row, ilDBConstants\FETCHMODE_OBJECT, ilDidacticTemplateAction\getActionId(), and setRoleTemplateId().

+ Here is the call graph for this function:

◆ revert()

ilDidacticTemplateLocalRoleAction::revert ( )

Revert action.

Reimplemented from ilDidacticTemplateAction.

Definition at line 103 of file class.ilDidacticTemplateLocalRoleAction.php.

104 {
105 // @todo: revert could delete the generated local role. But on the other hand all users
106 // assigned to this local role would be deassigned. E.g. if course or group membership
107 // is handled by didactic templates, all members would get lost.
108 }

◆ save()

ilDidacticTemplateLocalRoleAction::save ( )

Create new action.

Reimplemented from ilDidacticTemplateAction.

Definition at line 113 of file class.ilDidacticTemplateLocalRoleAction.php.

114 {
115 global $ilDB;
116
117 parent::save();
118
119 $query = 'INSERT INTO didactic_tpl_alr (action_id,role_template_id) ' .
120 'VALUES ( ' .
121 $ilDB->quote($this->getActionId(), 'integer') . ', ' .
122 $ilDB->quote($this->getRoleTemplateId(), 'integer') . ' ' .
123 ') ';
124 $res = $ilDB->manipulate($query);
125
126 return true;
127 }

References $ilDB, $query, $res, ilDidacticTemplateAction\getActionId(), and getRoleTemplateId().

+ Here is the call graph for this function:

◆ setRoleTemplateId()

ilDidacticTemplateLocalRoleAction::setRoleTemplateId (   $a_role_template_id)

Set role template id.

Parameters
int$a_role_template_id

Definition at line 38 of file class.ilDidacticTemplateLocalRoleAction.php.

39 {
40 $this->role_template_id = $a_role_template_id;
41 }

Referenced by read().

+ Here is the caller graph for this function:

◆ toXml()

ilDidacticTemplateLocalRoleAction::toXml ( ilXmlWriter  $writer)

Write xml of template action.

Parameters
ilXmlWriter$writer

Reimplemented from ilDidacticTemplateAction.

Definition at line 151 of file class.ilDidacticTemplateLocalRoleAction.php.

152 {
153 $writer->xmlStartTag('localRoleAction');
154
155
156 $il_id = 'il_' . IL_INST_ID . '_' . ilObject::_lookupType($this->getRoleTemplateId()) . '_' . $this->getRoleTemplateId();
157
158 $writer->xmlStartTag(
159 'roleTemplate',
160 array(
161 'id' => $il_id
162 )
163 );
164
165 include_once './Services/AccessControl/classes/class.ilRoleXmlExport.php';
166 $exp = new ilRoleXmlExport();
167 $exp->setMode(ilRoleXmlExport::MODE_DTPL);
168 $exp->addRole($this->getRoleTemplateId(), ROLE_FOLDER_ID);
169 $exp->write();
170 $writer->appendXML($exp->xmlDumpMem(false));
171 $writer->xmlEndTag('roleTemplate');
172 $writer->xmlEndTag('localRoleAction');
173 }
static _lookupType($a_id, $a_reference=false)
lookup object type
Xml export of roles and role templates.
xmlEndTag($tag)
Writes an endtag.
appendXML($a_str)
append xml string to document
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.

References ilObject\_lookupType(), ilXmlWriter\appendXML(), getRoleTemplateId(), ilRoleXmlExport\MODE_DTPL, ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

+ Here is the call graph for this function:

Field Documentation

◆ $role_template_id

ilDidacticTemplateLocalRoleAction::$role_template_id = 0
private

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

Referenced by getRoleTemplateId().


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