ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilRoleXmlExport Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilRoleXmlExport:
+ Collaboration diagram for ilRoleXmlExport:

Public Member Functions

 __construct ()
 
 setRoles (array $a_roles)
 Set roles Format is: array(role_id => array(role_folder_id)) More...
 
 getRoles ()
 
 addRole (int $a_role_id, int $a_rolf_id)
 
 setMode (int $a_mode)
 
 getMode ()
 
 writeHeader ()
 Write xml header. More...
 
 write ()
 Write xml presentation of chosen roles. More...
 
- Public Member Functions inherited from ilXmlWriter
 __construct (string $version="1.0", string $outEnc="utf-8", string $inEnc="utf-8")
 
 xmlSetDtdDef (string $dtdDef)
 Sets dtd definition. More...
 
 xmlSetGenCmt (string $genCmt)
 Sets generated comment. More...
 
 xmlFormatData (string $data)
 Indents text for better reading. More...
 
 xmlHeader ()
 Writes xml header. More...
 
 xmlStartTag (string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
 Writes a starttag. More...
 
 xmlEndTag (string $tag)
 Writes an endtag. More...
 
 xmlData (string $data, bool $encode=true, bool $escape=true)
 Writes data. More...
 
 xmlElement (string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
 Writes a basic element (no children, just textual content) More...
 
 xmlDumpFile (string $file, bool $format=true)
 Dumps xml document from memory into a file. More...
 
 xmlDumpMem (bool $format=true)
 Returns xml document from memory. More...
 
 appendXML (string $a_str)
 append xml string to document More...
 
 xmlClear ()
 clears xmlStr More...
 

Data Fields

const MODE_DTPL = 1
 

Protected Attributes

ilRbacReview $rbacreview
 

Private Member Functions

 writeRole (int $a_role_id, int $a_rolf)
 Write xml presentation of one role. More...
 
 initRbacOperations ()
 Cache rbac operations. More...
 

Private Attributes

array $roles = array()
 
array $operations = array()
 
int $mode = 0
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Xml export of roles and role templates

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

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

Constructor & Destructor Documentation

◆ __construct()

ilRoleXmlExport::__construct ( )

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

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), and initRbacOperations().

36  {
37  global $DIC;
38 
39  $this->rbacreview = $DIC->rbac()->review();
40 
42  $this->initRbacOperations();
43  }
global $DIC
Definition: feed.php:28
initRbacOperations()
Cache rbac operations.
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ addRole()

ilRoleXmlExport::addRole ( int  $a_role_id,
int  $a_rolf_id 
)

Definition at line 59 of file class.ilRoleXmlExport.php.

59  : void
60  {
61  $this->roles[$a_role_id][] = $a_rolf_id;
62  }

◆ getMode()

ilRoleXmlExport::getMode ( )

Definition at line 69 of file class.ilRoleXmlExport.php.

References $mode.

Referenced by write().

69  : int
70  {
71  return $this->mode;
72  }
+ Here is the caller graph for this function:

◆ getRoles()

ilRoleXmlExport::getRoles ( )

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

References $roles.

Referenced by write().

54  : array
55  {
56  return $this->roles;
57  }
+ Here is the caller graph for this function:

◆ initRbacOperations()

ilRoleXmlExport::initRbacOperations ( )
private

Cache rbac operations.

Definition at line 135 of file class.ilRoleXmlExport.php.

Referenced by __construct().

135  : void
136  {
137  foreach ($this->rbacreview->getOperations() as $operation) {
138  $this->operations[$operation['ops_id']] = $operation['operation'];
139  }
140  }
+ Here is the caller graph for this function:

◆ setMode()

ilRoleXmlExport::setMode ( int  $a_mode)

Definition at line 64 of file class.ilRoleXmlExport.php.

64  : void
65  {
66  $this->mode = $a_mode;
67  }

◆ setRoles()

ilRoleXmlExport::setRoles ( array  $a_roles)

Set roles Format is: array(role_id => array(role_folder_id))

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

49  : void
50  {
51  $this->roles = $a_roles;
52  }

◆ write()

ilRoleXmlExport::write ( )

Write xml presentation of chosen roles.

Definition at line 87 of file class.ilRoleXmlExport.php.

References getMode(), getRoles(), writeRole(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

87  : void
88  {
89  if ($this->getMode() != self::MODE_DTPL) {
90  $this->xmlStartTag('roles');
91  }
92 
93  foreach ($this->getRoles() as $role_id => $role_folder_ids) {
94  foreach ((array) $role_folder_ids as $rolf) {
95  $this->writeRole($role_id, $rolf);
96  }
97  }
98 
99  if ($this->getMode() != self::MODE_DTPL) {
100  $this->xmlEndTag('roles');
101  }
102  }
xmlEndTag(string $tag)
Writes an endtag.
writeRole(int $a_role_id, int $a_rolf)
Write xml presentation of one role.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
+ Here is the call graph for this function:

◆ writeHeader()

ilRoleXmlExport::writeHeader ( )

Write xml header.

Definition at line 77 of file class.ilRoleXmlExport.php.

References ilXmlWriter\xmlHeader(), ilXmlWriter\xmlSetDtdDef(), and ilXmlWriter\xmlSetGenCmt().

77  : void
78  {
79  $this->xmlSetDtdDef("<!DOCTYPE Roles PUBLIC \"-//ILIAS//DTD ILIAS Roles//EN\" \"" . ILIAS_HTTP_PATH . "/xml/ilias_role_definition_4_2.dtd\">");
80  $this->xmlSetGenCmt("Role Definition");
81  $this->xmlHeader();
82  }
xmlSetGenCmt(string $genCmt)
Sets generated comment.
xmlSetDtdDef(string $dtdDef)
Sets dtd definition.
xmlHeader()
Writes xml header.
+ Here is the call graph for this function:

◆ writeRole()

ilRoleXmlExport::writeRole ( int  $a_role_id,
int  $a_rolf 
)
private

Write xml presentation of one role.

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

References $attributes, $GLOBALS, $operations, ilObject\_lookupDescription(), ilObject\_lookupTitle(), ilObject\_lookupType(), IL_INST_ID, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by write().

107  : void
108  {
109  $attributes = array(
110  'type' => ilObject::_lookupType($a_role_id),
111  'id' => 'il_' . IL_INST_ID . '_' . ilObject::_lookupType($a_role_id) . '_' . $a_role_id,
112  'protected' => ($GLOBALS['DIC']['rbacreview']->isProtected($a_rolf, $a_role_id) ? 1 : 0)
113  );
114 
115  $this->xmlStartTag('role', $attributes);
116 
117  $this->xmlElement('title', array(), ilObject::_lookupTitle($a_role_id));
118  $this->xmlElement('description', array(), ilObject::_lookupDescription($a_role_id));
119 
120  $this->xmlStartTag('operations');
121  foreach ($this->rbacreview->getAllOperationsOfRole($a_role_id, $a_rolf) as $obj_group => $operations) {
122  foreach ($operations as $ops_id) {
123  if (isset($this->operations[$ops_id])) {
124  $this->xmlElement('operation', array('group' => $obj_group), trim($this->operations[$ops_id]));
125  }
126  }
127  }
128  $this->xmlEndTag('operations');
129  $this->xmlEndTag('role');
130  }
$attributes
Definition: metadata.php:248
const IL_INST_ID
Definition: constants.php:40
xmlEndTag(string $tag)
Writes an endtag.
static _lookupTitle(int $obj_id)
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
static _lookupDescription(int $obj_id)
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $mode

int ilRoleXmlExport::$mode = 0
private

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

Referenced by getMode().

◆ $operations

array ilRoleXmlExport::$operations = array()
private

Definition at line 30 of file class.ilRoleXmlExport.php.

Referenced by writeRole().

◆ $rbacreview

ilRbacReview ilRoleXmlExport::$rbacreview
protected

Definition at line 33 of file class.ilRoleXmlExport.php.

◆ $roles

array ilRoleXmlExport::$roles = array()
private

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

Referenced by getRoles().

◆ MODE_DTPL

const ilRoleXmlExport::MODE_DTPL = 1

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