ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSoapRoleObjectXMLWriter.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  +-----------------------------------------------------------------------------+
5  | ILIAS open source |
6  +-----------------------------------------------------------------------------+
7  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
8  | |
9  | This program is free software; you can redistribute it and/or |
10  | modify it under the terms of the GNU General Public License |
11  | as published by the Free Software Foundation; either version 2 |
12  | of the License, or (at your option) any later version. |
13  | |
14  | This program is distributed in the hope that it will be useful, |
15  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
16  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17  | GNU General Public License for more details. |
18  | |
19  | You should have received a copy of the GNU General Public License |
20  | along with this program; if not, write to the Free Software |
21  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
22  +-----------------------------------------------------------------------------+
23 */
24 
38 include_once "./classes/class.ilXmlWriter.php";
39 
41 {
42  var $ilias;
43  var $xml;
44  var $roles;
46  var $user_id = 0;
47 
56  {
57  global $ilias,$ilUser;
58 
60 
61  $this->ilias =& $ilias;
62  $this->user_id = $ilUser->getId();
63  }
64 
65 
66  function setObjects(& $roles)
67  {
68  $this->roles = & $roles;
69  }
70 
71  function setType ($type)
72  {
73  $this->role_type = $type;
74  }
75 
76 
77  function start()
78  {
79  global $rbacreview;
80  if (!is_array($this->roles))
81  return false;
82 
83  $this->__buildHeader();
84 
85  include_once './Services/AccessControl/classes/class.ilObjRole.php';
86  include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
87 
88  foreach ($this->roles as $role)
89  {
90  // if role type is not empty and does not match, then continue;
91  if (!empty($this->role_type) && strcasecmp ($this->role_type, $role["role_type"]) != 0 )
92  {
93  continue;
94  }
95  if ($rbacreview->isRoleDeleted($role["obj_id"]))
96  {
97  continue;
98  }
99 
100  $attrs = array( 'role_type' => ucwords($role["role_type"]),
101  'id' => "il_".IL_INST_ID."_role_".$role["obj_id"]);
102 
103  // open tag
104  $this->xmlStartTag("Role", $attrs);
105 
106 
107  $this->xmlElement('Title',null, $role["title"]);
108  $this->xmlElement('Description',null, $role["description"]);
109  $this->xmlElement('Translation',null,ilObjRole::_getTranslation($role["title"]));
110 
111  if ($ref_id = ilUtil::__extractRefId($role["title"]))
112  {
113 
114  $ownerObj = IlObjectFactory::getInstanceByRefId($ref_id, false);
115 
116  if (is_object($ownerObj))
117  {
118  $attrs = array ("obj_id" =>
119  "il_".IL_INST_ID."_".$ownerObj->getType()."_".$ownerObj->getId(), "ref_id" => $ownerObj->getRefId(), "type" => $ownerObj->getType());
120  $this->xmlStartTag('AssignedObject', $attrs);
121  $this->xmlElement ('Title', null, $ownerObj->getTitle());
122  $this->xmlElement ('Description', null, $ownerObj->getDescription());
124  $this->xmlEndTag ('AssignedObject', $attrs);
125  }
126  }
127 
128  $this->xmlEndTag ("Role");
129 
130  }
131 
132  $this->__buildFooter();
133 
134  return true;
135  }
136 
137  function getXML()
138  {
139  return $this->xmlDumpMem(FALSE);
140  }
141 
142 
143  function __buildHeader()
144  {
145  $this->xmlSetDtdDef("<!DOCTYPE Roles PUBLIC \"-//ILIAS//DTD ILIAS Roles//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_role_object_3_10.dtd\">");
146  $this->xmlSetGenCmt("Roles information of ilias system");
147  $this->xmlHeader();
148 
149  $this->xmlStartTag('Roles');
150 
151  return true;
152  }
153 
154  function __buildFooter()
155  {
156  $this->xmlEndTag('Roles');
157  }
158 
159 
160 }
161 
162 
163 ?>