ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilRoleXmlExport Class Reference

Xml export of roles and role templates. More...

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

Public Member Functions

 __construct ()
 Constructor. More...
 
 setRoles ($a_roles)
 Set roles Format is: array(role_id => array(role_folder_id)) More...
 
 getRoles ()
 Get roles. More...
 
 addRole ($a_role_id, $a_rolf_id)
 Add one role. More...
 
 setMode ($a_mode)
 
 getMode ()
 
 writeHeader ()
 Write xml header. More...
 
 write ()
 Write xml presentation of chosen roles. More...
 
- Public Member Functions inherited from ilXmlWriter
 __construct ($version="1.0", $outEnc="utf-8", $inEnc="utf-8")
 constructor More...
 
 _ilXmlWriter ()
 destructor public More...
 
 xmlSetDtdDef ($dtdDef)
 Sets dtd definition. More...
 
 xmlSetStSheet ($stSheet)
 Sets stylesheet. More...
 
 xmlSetGenCmt ($genCmt)
 Sets generated comment. More...
 
 xmlEncodeData ($data)
 Encodes text from input encoding into output encoding. More...
 
 xmlFormatData ($data)
 Indents text for better reading. More...
 
 xmlFormatElement ($array)
 Callback function for xmlFormatData; do not invoke directly. More...
 
 xmlHeader ()
 Writes xml header public. More...
 
 xmlStartTag ($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
 Writes a starttag. More...
 
 xmlEndTag ($tag)
 Writes an endtag. More...
 
 xmlComment ($comment)
 Writes a comment. More...
 
 xmlData ($data, $encode=true, $escape=true)
 Writes data. More...
 
 xmlElement ($tag, $attrs=null, $data=null, $encode=true, $escape=true)
 Writes a basic element (no children, just textual content) More...
 
 xmlDumpFile ($file, $format=true)
 Dumps xml document from memory into a file. More...
 
 xmlDumpMem ($format=true)
 Returns xml document from memory. More...
 
 appendXML ($a_str)
 append xml string to document More...
 
 xmlClear ()
 clears xmlStr public More...
 

Data Fields

const MODE_DTPL = 1
 
- Data Fields inherited from ilXmlWriter
 $xmlStr
 
 $version
 
 $outEnc
 
 $inEnc
 
 $dtdDef = ""
 
 $stSheet = ""
 
 $genCmt = "Generated by ILIAS XmlWriter"
 

Private Member Functions

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

Private Attributes

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

Additional Inherited Members

- Static Public Member Functions inherited from ilXmlWriter
static _xmlEscapeData ($data)
 Escapes reserved characters. More...
 

Detailed Description

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 12 of file class.ilRoleXmlExport.php.

Constructor & Destructor Documentation

◆ __construct()

ilRoleXmlExport::__construct ( )

Constructor.

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

References initRbacOperations().

27  {
28  parent::__construct();
29 
30  $this->initRbacOperations();
31  }
initRbacOperations()
Cache rbac operations.
+ Here is the call graph for this function:

Member Function Documentation

◆ addRole()

ilRoleXmlExport::addRole (   $a_role_id,
  $a_rolf_id 
)

Add one role.

Parameters
int$a_role_id
int$a_ref_idof source object

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

61  {
62  $this->roles[$a_role_id][] = $a_rolf_id;
63  }

◆ getMode()

ilRoleXmlExport::getMode ( )

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

References $mode.

Referenced by write().

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

◆ getRoles()

ilRoleXmlExport::getRoles ( )

Get roles.

Returns
array

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

References $roles.

Referenced by write().

51  {
52  return (array) $this->roles;
53  }
+ Here is the caller graph for this function:

◆ initRbacOperations()

ilRoleXmlExport::initRbacOperations ( )
private

Cache rbac operations.

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

References $DIC.

Referenced by __construct().

145  {
146  global $DIC;
147 
148  $rbacreview = $DIC['rbacreview'];
149 
150  foreach ($rbacreview->getOperations() as $operation) {
151  $this->operations[$operation['ops_id']] = $operation['operation'];
152  }
153  return true;
154  }
global $DIC
Definition: saml.php:7
+ Here is the caller graph for this function:

◆ setMode()

ilRoleXmlExport::setMode (   $a_mode)

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

66  {
67  $this->mode = $a_mode;
68  }

◆ setRoles()

ilRoleXmlExport::setRoles (   $a_roles)

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

Parameters
array$a_roles
Returns
void

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

42  {
43  $this->roles = (array) $a_roles;
44  }

◆ write()

ilRoleXmlExport::write ( )

Write xml presentation of chosen roles.

Returns
bool

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

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

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

◆ writeHeader()

ilRoleXmlExport::writeHeader ( )

Write xml header.

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

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

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

◆ writeRole()

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

Write xml presentation of one role.

Parameters
int$a_role_id
int$a_rolf

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

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

Referenced by write().

114  {
115  global $DIC;
116 
117  $rbacreview = $DIC['rbacreview'];
118 
119  $attributes = array(
120  'type' => ilObject::_lookupType($a_role_id),
121  'id' => 'il_' . IL_INST_ID . '_' . ilObject::_lookupType($a_role_id) . '_' . $a_role_id,
122  'protected' => ($GLOBALS['DIC']['rbacreview']->isProtected($a_rolf, $a_role_id) ? 1 : 0)
123  );
124 
125  $this->xmlStartTag('role', $attributes);
126 
127  $this->xmlElement('title', array(), ilObject::_lookupTitle($a_role_id));
128  $this->xmlElement('description', array(), ilObject::_lookupDescription($a_role_id));
129 
130  $this->xmlStartTag('operations');
131  foreach ($rbacreview->getAllOperationsOfRole($a_role_id, $a_rolf) as $obj_group => $operations) {
132  foreach ($operations as $ops_id) {
133  $this->xmlElement('operation', array('group' => $obj_group), trim($this->operations[$ops_id]));
134  }
135  }
136  $this->xmlEndTag('operations');
137  $this->xmlEndTag('role');
138  return true;
139  }
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
global $DIC
Definition: saml.php:7
static _lookupTitle($a_id)
lookup object title
xmlEndTag($tag)
Writes an endtag.
static _lookupDescription($a_id)
lookup object description
if(array_key_exists('yes', $_REQUEST)) $attributes
Definition: getconsent.php:85
static _lookupType($a_id, $a_reference=false)
lookup object type
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $mode

ilRoleXmlExport::$mode = 0
private

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

Referenced by getMode().

◆ $operations

ilRoleXmlExport::$operations = array()
private

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

Referenced by writeRole().

◆ $roles

ilRoleXmlExport::$roles = array()
private

Definition at line 17 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: