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