ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilSoapRoleObjectXMLWriter.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once "./Services/Xml/classes/class.ilXmlWriter.php";
6 
20 {
21  public $ilias;
22  public $xml;
23  public $roles;
24  public $role_type;
25  public $user_id = 0;
26 
34  public function __construct()
35  {
36  global $DIC;
37 
38  $ilias = $DIC['ilias'];
39  $ilUser = $DIC['ilUser'];
40 
41  parent::__construct();
42 
43  $this->ilias =&$ilias;
44  $this->user_id = $ilUser->getId();
45  }
46 
47 
48  public function setObjects(&$roles)
49  {
50  $this->roles = &$roles;
51  }
52 
53  public function setType($type)
54  {
55  $this->role_type = $type;
56  }
57 
58 
59  public function start()
60  {
61  global $DIC;
62 
63  $rbacreview = $DIC['rbacreview'];
64  if (!is_array($this->roles)) {
65  return false;
66  }
67 
68  $this->__buildHeader();
69 
70  include_once './Services/AccessControl/classes/class.ilObjRole.php';
71  include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
72 
73  foreach ($this->roles as $role) {
74  // if role type is not empty and does not match, then continue;
75  if (!empty($this->role_type) && strcasecmp($this->role_type, $role["role_type"]) != 0) {
76  continue;
77  }
78  if ($rbacreview->isRoleDeleted($role["obj_id"])) {
79  continue;
80  }
81 
82  $attrs = array( 'role_type' => ucwords($role["role_type"]),
83  'id' => "il_" . IL_INST_ID . "_role_" . $role["obj_id"]);
84 
85  // open tag
86  $this->xmlStartTag("Role", $attrs);
87 
88 
89  $this->xmlElement('Title', null, $role["title"]);
90  $this->xmlElement('Description', null, $role["description"]);
91  $this->xmlElement('Translation', null, ilObjRole::_getTranslation($role["title"]));
92 
93  if ($ref_id = ilUtil::__extractRefId($role["title"])) {
94  $ownerObj = IlObjectFactory::getInstanceByRefId($ref_id, false);
95 
96  if (is_object($ownerObj)) {
97  $attrs = array("obj_id" =>
98  "il_" . IL_INST_ID . "_" . $ownerObj->getType() . "_" . $ownerObj->getId(), "ref_id" => $ownerObj->getRefId(), "type" => $ownerObj->getType());
99  $this->xmlStartTag('AssignedObject', $attrs);
100  $this->xmlElement('Title', null, $ownerObj->getTitle());
101  $this->xmlElement('Description', null, $ownerObj->getDescription());
103  $this->xmlEndTag('AssignedObject', $attrs);
104  }
105  }
106 
107  $this->xmlEndTag("Role");
108  }
109 
110  $this->__buildFooter();
111 
112  return true;
113  }
114 
115  public function getXML()
116  {
117  return $this->xmlDumpMem(false);
118  }
119 
120 
121  public function __buildHeader()
122  {
123  $this->xmlSetDtdDef("<!DOCTYPE Roles PUBLIC \"-//ILIAS//DTD ILIAS Roles//EN\" \"" . ILIAS_HTTP_PATH . "/xml/ilias_role_object_3_10.dtd\">");
124  $this->xmlSetGenCmt("Roles information of ilias system");
125  $this->xmlHeader();
126 
127  $this->xmlStartTag('Roles');
128 
129  return true;
130  }
131 
132  public function __buildFooter()
133  {
134  $this->xmlEndTag('Roles');
135  }
136 }
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
xmlSetGenCmt($genCmt)
Sets generated comment.
xmlSetDtdDef($dtdDef)
Sets dtd definition.
$type
global $DIC
Definition: saml.php:7
xmlDumpMem($format=true)
Returns xml document from memory.
XML writer class.
xmlEndTag($tag)
Writes an endtag.
static __extractRefId($role_title)
extract ref id from role title, e.g.
static appendPathToObject($writer, $refid)
$ilUser
Definition: imgupload.php:18
redirection script todo: (a better solution should control the processing via a xml file) ...
xmlHeader()
Writes xml header public.
static _getTranslation($a_role_title)
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)