ILIAS  release_8 Revision v8.24
ilDidacticTemplateLocalRoleAction Class Reference

represents a creation of local roles action More...

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

Public Member Functions

 __construct (int $a_action_id=0)
 
 getType ()
 Get type of template. More...
 
 setRoleTemplateId (int $a_role_template_id)
 
 getRoleTemplateId ()
 
 apply ()
 Apply action. More...
 
 revert ()
 Implement everthing that is necessary to revert a didactic template return bool. 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...
 
 toXml (ilXmlWriter $writer)
 
 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)
 

Private Attributes

int $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 FILTER_LOCAL_ROLES = 4
 
const PATTERN_PARENT_TYPE = 'action'
 
- Protected Member Functions inherited from ilDidacticTemplateAction
 initSourceObject ()
 
 filterRoles (ilObject $source)
 
- Protected Attributes inherited from ilDidacticTemplateAction
ilLogger $logger
 
ilDBInterface $db
 
ilRbacReview $review
 
ilRbacAdmin $admin
 

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 11 of file class.ilDidacticTemplateLocalRoleAction.php.

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateLocalRoleAction::__construct ( int  $a_action_id = 0)

Reimplemented from ilDidacticTemplateAction.

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

16 {
17 parent::__construct($a_action_id);
18 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ apply()

ilDidacticTemplateLocalRoleAction::apply ( )

Apply action.

Returns
bool

Reimplemented from ilDidacticTemplateAction.

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

35 : bool
36 {
37 $source = $this->initSourceObject();
38
39 $role = new ilObjRole();
40 $role->setTitle(ilObject::_lookupTitle($this->getRoleTemplateId()) . '_' . $this->getRefId());
41 $role->setDescription(ilObject::_lookupDescription($this->getRoleTemplateId()));
42 $role->create();
43 $this->admin->assignRoleToFolder($role->getId(), $source->getRefId(), "y");
44 $this->logger->info(
45 'Using rolt: ' .
46 $this->getRoleTemplateId() .
47 ' with title "' .
49 '". '
50 );
51
52 // Copy template permissions
53
54 $this->logger->debug(
55 'Copy role template permissions ' .
56 'tpl_id: ' . $this->getRoleTemplateId() . ' ' .
57 'parent: ' . ROLE_FOLDER_ID . ' ' .
58 'role_id: ' . $role->getId() . ' ' .
59 'role_parent: ' . $source->getRefId()
60 );
61
62 $this->admin->copyRoleTemplatePermissions(
63 $this->getRoleTemplateId(),
65 $source->getRefId(),
66 $role->getId(),
67 true
68 );
69 // Set permissions
70 $ops = $this->review->getOperationsOfRole($role->getId(), $source->getType(), $source->getRefId());
71 $this->admin->grantPermission($role->getId(), $ops, $source->getRefId());
72
73 return true;
74 }
Class ilObjRole.
static _lookupTitle(int $obj_id)
static _lookupDescription(int $obj_id)
const ROLE_FOLDER_ID
Definition: constants.php:34
$source
Definition: metadata.php:93

References $source, ilObject\_lookupDescription(), ilObject\_lookupTitle(), ilDidacticTemplateAction\getRefId(), getRoleTemplateId(), ilDidacticTemplateAction\initSourceObject(), ILIAS\Repository\logger(), and ROLE_FOLDER_ID.

+ Here is the call graph for this function:

◆ delete()

ilDidacticTemplateLocalRoleAction::delete ( )

Delete didactic template action Overwrite for filling additional db fields.

Reimplemented from ilDidacticTemplateAction.

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

100 : void
101 {
102 parent::delete();
103
104 $query = 'DELETE FROM didactic_tpl_alr ' .
105 'WHERE action_id = ' . $this->db->quote($this->getActionId(), 'integer');
106 $this->db->manipulate($query);
107 }
$query

References $query, and ilDidacticTemplateAction\getActionId().

+ Here is the call graph for this function:

◆ getRoleTemplateId()

ilDidacticTemplateLocalRoleAction::getRoleTemplateId ( )

Definition at line 30 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 type of template.

Returns
int $type

Reimplemented from ilDidacticTemplateAction.

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

20 : int
21 {
23 }

References ilDidacticTemplateAction\TYPE_LOCAL_ROLE.

◆ read()

ilDidacticTemplateLocalRoleAction::read ( )

Reimplemented from ilDidacticTemplateAction.

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

131 : void
132 {
133 parent::read();
134 $query = 'SELECT * FROM didactic_tpl_alr ' .
135 'WHERE action_id = ' . $this->db->quote($this->getActionId(), 'integer');
136 $res = $this->db->query($query);
137 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
138 $this->setRoleTemplateId((int) $row->role_template_id);
139 }
140 }
$res
Definition: ltiservices.php:69

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

+ Here is the call graph for this function:

◆ revert()

ilDidacticTemplateLocalRoleAction::revert ( )

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

Reimplemented from ilDidacticTemplateAction.

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

76 : bool
77 {
78 // @todo: revert could delete the generated local role. But on the other hand all users
79 // assigned to this local role would be deassigned. E.g. if course or group membership
80 // is handled by didactic templates, all members would get lost.
81 return false;
82 }

◆ save()

ilDidacticTemplateLocalRoleAction::save ( )

Write action to db Overwrite for filling additional db fields.

Returns
int

Reimplemented from ilDidacticTemplateAction.

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

84 : int
85 {
86 if (!parent::save()) {
87 return 0;
88 }
89
90 $query = 'INSERT INTO didactic_tpl_alr (action_id,role_template_id) ' .
91 'VALUES ( ' .
92 $this->db->quote($this->getActionId(), 'integer') . ', ' .
93 $this->db->quote($this->getRoleTemplateId(), 'integer') . ' ' .
94 ') ';
95 $res = $this->db->manipulate($query);
96
97 return $this->getActionId();
98 }

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

+ Here is the call graph for this function:

◆ setRoleTemplateId()

ilDidacticTemplateLocalRoleAction::setRoleTemplateId ( int  $a_role_template_id)

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

25 : void
26 {
27 $this->role_template_id = $a_role_template_id;
28 }

Referenced by read().

+ Here is the caller graph for this function:

◆ toXml()

ilDidacticTemplateLocalRoleAction::toXml ( ilXmlWriter  $writer)

Reimplemented from ilDidacticTemplateAction.

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

109 : void
110 {
111 $writer->xmlStartTag('localRoleAction');
112
113 $il_id = 'il_' . IL_INST_ID . '_' . ilObject::_lookupType($this->getRoleTemplateId()) . '_' . $this->getRoleTemplateId();
114
115 $writer->xmlStartTag(
116 'roleTemplate',
117 [
118 'id' => $il_id
119 ]
120 );
121
122 $exp = new ilRoleXmlExport();
123 $exp->setMode(ilRoleXmlExport::MODE_DTPL);
124 $exp->addRole($this->getRoleTemplateId(), ROLE_FOLDER_ID);
125 $exp->write();
126 $writer->appendXML($exp->xmlDumpMem(false));
127 $writer->xmlEndTag('roleTemplate');
128 $writer->xmlEndTag('localRoleAction');
129 }
static _lookupType(int $id, bool $reference=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlEndTag(string $tag)
Writes an endtag.
appendXML(string $a_str)
append xml string to document
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
const IL_INST_ID
Definition: constants.php:40

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

+ Here is the call graph for this function:

Field Documentation

◆ $role_template_id

int ilDidacticTemplateLocalRoleAction::$role_template_id = 0
private

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

Referenced by getRoleTemplateId().


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