ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 ilDB $ilDB. More...
 
 toXml (ilXmlWriter $writer)
 Write xml of template action. More...
 
 read ()
 Read db entry 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 ()
 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 FILTER_LOCAL_ROLES = 4
 
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

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.

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

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

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

◆ delete()

ilDidacticTemplateLocalRoleAction::delete ( )

Delete ilDB $ilDB.

Returns
bool

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

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

140  {
141  global $DIC;
142 
143  $ilDB = $DIC['ilDB'];
144 
145  parent::delete();
146 
147  $query = 'DELETE FROM didactic_tpl_alr ' .
148  'WHERE action_id = ' . $ilDB->quote($this->getActionId(), 'integer');
149  $ilDB->manipulate($query);
150 
151  return true;
152  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ 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

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

30  {
31  return self::TYPE_LOCAL_ROLE;
32  }

◆ read()

ilDidacticTemplateLocalRoleAction::read ( )

Read db entry ilDB $ilDB.

Returns
bool

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

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

188  {
189  global $DIC;
190 
191  $ilDB = $DIC['ilDB'];
192 
193  parent::read();
194 
195  $query = 'SELECT * FROM didactic_tpl_alr ' .
196  'WHERE action_id = ' . $ilDB->quote($this->getActionId(), 'integer');
197  $res = $ilDB->query($query);
198  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
199  $this->setRoleTemplateId($row->role_template_id);
200  }
201  return true;
202  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
setRoleTemplateId($a_role_template_id)
Set role template id.
global $ilDB
+ Here is the call graph for this function:

◆ revert()

ilDidacticTemplateLocalRoleAction::revert ( )

Revert action.

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

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

◆ save()

ilDidacticTemplateLocalRoleAction::save ( )

Create new action.

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

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

117  {
118  global $DIC;
119 
120  $ilDB = $DIC['ilDB'];
121 
122  parent::save();
123 
124  $query = 'INSERT INTO didactic_tpl_alr (action_id,role_template_id) ' .
125  'VALUES ( ' .
126  $ilDB->quote($this->getActionId(), 'integer') . ', ' .
127  $ilDB->quote($this->getRoleTemplateId(), 'integer') . ' ' .
128  ') ';
129  $res = $ilDB->manipulate($query);
130 
131  return true;
132  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ 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.

Referenced by read().

39  {
40  $this->role_template_id = $a_role_template_id;
41  }
+ Here is the caller graph for this function:

◆ toXml()

ilDidacticTemplateLocalRoleAction::toXml ( ilXmlWriter  $writer)

Write xml of template action.

Parameters
ilXmlWriter$writer

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

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

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