ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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, and array.

Referenced by write().

51  {
52  return (array) $this->roles;
53  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ initRbacOperations()

ilRoleXmlExport::initRbacOperations ( )
private

Cache rbac operations.

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

Referenced by __construct().

150  {
151  global $rbacreview;
152 
153  foreach($rbacreview->getOperations() as $operation)
154  {
155  $this->operations[$operation['ops_id']] = $operation['operation'];
156  }
157  return true;
158  }
+ 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.

References array.

42  {
43  $this->roles = (array) $a_roles;
44  }
Create styles array
The data for the language used.

◆ write()

ilRoleXmlExport::write ( )

Write xml presentation of chosen roles.

Returns
bool

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

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

92  {
93 
94  if($this->getMode() != self::MODE_DTPL)
95  {
96  $this->xmlStartTag('roles');
97  }
98 
99  foreach($this->getRoles() as $role_id => $role_folder_ids)
100  {
101  foreach((array) $role_folder_ids as $rolf)
102  {
103  $this->writeRole($role_id, $rolf);
104  }
105  }
106 
107  if($this->getMode() != self::MODE_DTPL)
108  {
109  $this->xmlEndTag('roles');
110  }
111  }
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.
Create styles array
The data for the language used.
+ 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 118 of file class.ilRoleXmlExport.php.

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

Referenced by write().

119  {
120  global $rbacreview;
121 
122  $attributes = array(
123  'type' => ilObject::_lookupType($a_role_id),
124  'id' => 'il_'.IL_INST_ID.'_'.ilObject::_lookupType($a_role_id).'_'.$a_role_id,
125  'protected' => ($GLOBALS['rbacreview']->isProtected($a_rolf,$a_role_id) ? 1 : 0)
126  );
127 
128  $this->xmlStartTag('role',$attributes);
129 
130  $this->xmlElement('title',array(),ilObject::_lookupTitle($a_role_id));
131  $this->xmlElement('description', array(), ilObject::_lookupDescription($a_role_id));
132 
133  $this->xmlStartTag('operations');
134  foreach($rbacreview->getAllOperationsOfRole($a_role_id, $a_rolf) as $obj_group => $operations)
135  {
136  foreach($operations as $ops_id)
137  {
138  $this->xmlElement('operation', array('group' => $obj_group), trim($this->operations[$ops_id]));
139  }
140  }
141  $this->xmlEndTag('operations');
142  $this->xmlEndTag('role');
143  return true;
144  }
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)
static _lookupTitle($a_id)
lookup object title
xmlEndTag($tag)
Writes an endtag.
static _lookupDescription($a_id)
lookup object description
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
+ 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: