ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilnetucateResponse.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24
25require_once("./Services/Xml/classes/class.ilSaxParser.php");
26
36{
41 function ilnetucateResponse($a_str)
42 {
43 $xml_str = $this->validateInput($a_str);
44
45 parent::ilSaxParser($xml_str);
46
47 $this->startParsing();
48 }
49
50 function validateInput($a_str)
51 {
52 $response = split("\r\n\r\n",$a_str);
53
54 $header = $response[0];
55 $response_data = $response[1];
56
57 if (strpos($response_data,"<?xml") === false)
58 {
59 echo "netucateResponse::validateInput() : No valid response data!<br/>";
60 var_dump($header,$response_data);
61 exit;
62 }
63
64 return chop($response_data);
65 }
66
67 function isError()
68 {
69 if ($this->data['response']['status'] == "error" or $this->data['response']['status'] == "")
70 {
71 return true;
72 }
73
74 return false;
75 }
76
77 function getErrorMsg()
78 {
79 if ($this->data['response']['status'] == "error" or $this->data['response']['status'] == "")
80 {
81 return trim($this->data['result']['cdata']);
82 }
83 }
84
85 function getResultMsg()
86 {
87 return trim($this->data['result']['cdata']);
88 }
89
90 function getFirstID()
91 {
92 reset($this->data['id']);
93 return current($this->data['id']);
94 }
95
96
102 function setHandlers($a_xml_parser)
103 {
104 xml_set_object($a_xml_parser,$this);
105 xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
106 xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
107 }
108
112 function startParsing()
113 {
114 $xml_parser = $this->createParser();
115 $this->setOptions($xml_parser);
116 $this->setHandlers($xml_parser);
117 $this->parse($xml_parser,$this->xml_file);
118 $this->freeParser($xml_parser);
119 return true;
120 }
121
127 function parse($a_xml_parser,$a_xml_str)
128 {
129 $parseOk = xml_parse($a_xml_parser,$a_xml_str,true);
130
131 if (!$parseOk && (xml_get_error_code($a_xml_parser) != XML_ERROR_NONE))
132 {
133 $this->ilias->raiseError("XML Parse Error: ".xml_error_string(xml_get_error_code($a_xml_parser)),$this->ilias->error_obj->FATAL);
134 }
135 }
136
137
141 function handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
142 {
143 global $ilErr;
144
145 switch($a_name)
146 {
147 case "netucate.API.Response":
148 $this->data['response']['failureCount'] = $a_attribs['failureCount'];
149 $this->data['response']['operationTotal'] = $a_attribs['operationTotal'];
150 $this->data['response']['status'] = $a_attribs['status'];
151 $this->data['response']['successCount'] = $a_attribs['successCount'];
152 break;
153
154 case "netucate.Result":
155 $this->data['result']['code'] = $a_attribs['code'];
156 $this->data['result']['id'] = $a_attribs['id'];
157 $this->data['result']['name'] = $a_attribs['name'];
158 $this->data['result']['request'] = $a_attribs['request'];
159 break;
160
161 case "netucate.ElementID":
162 $this->data['element']['type'] = $a_attribs['type'];
163 break;
164
165 case "netucate.URL":
166 break;
167
168 case "netucate.ID":
169 break;
170
171 case "netucate.Class.List":
172 case "netucate.User.List":
173 break;
174
175 case "netucate.Class":
176 $this->data['classes'][$a_attribs['classid']] = array (
177 'name' => $a_attribs['name'],
178 'instructoruserid' => $a_attribs['instructoruserid'],
179 'bandwidth' => $a_attribs['bandwidth'],
180 'appsharebandwidth' => $a_attribs['appsharebandwidth'],
181 'description' => $a_attribs['description'],
182 'password' => $a_attribs['password'],
183 'message' => $a_attribs['message'],
184 'floorpolicy' => $a_attribs['floorpolicy'],
185 'conferencetypeid' => $a_attribs['conferencetypeid'],
186 'videobandwidth' => $a_attribs['videobandwidth'],
187 'videoframerate' => $a_attribs['videoframerate'],
188 'enablepush' => $a_attribs['enablepush'],
189 'issecure' => $a_attribs['issecure'],
190 'alwaysopen' => $a_attribs['alwaysopen'],
191 'akclassvalue1' => $a_attribs['akclassvalue1'],
192 'akclassvalue2' => $a_attribs['akclassvalue2']
193 );
194 break;
195
196 case "netucate.User":
197 $this->data['users'][$a_attribs['userid']] = array (
198 'fullname' => $a_attribs['fullname'],
199 'authority' => $a_attribs['authority'],
200 'email' => $a_attribs['email'],
201 'homepage' => $a_attribs['homepage'],
202 'contactinfo' => $a_attribs['contactinfo'],
203 'comment' => $a_attribs['comments'],
204 'phonenumber' => $a_attribs['phonenumber'],
205 'akuservalue1' => $a_attribs['akuservalue1'],
206 'akuservalue2' => $a_attribs['akuservalue2'],
207 );
208 break;
209 }
210 }
211
212
213 function handlerEndTag($a_xml_parser, $a_name)
214 {
215 switch($a_name)
216 {
217 case "netucate.API.Response":
218 $this->data['response']['cdata'] = $this->cdata;
219 break;
220
221 case "netucate.Result":
222 $this->data['result']['cdata'] = $this->cdata;
223 break;
224
225 case "netucate.ElementID":
226 //$this->data['element']['cdata'] = $this->cdata;
227 break;
228
229 case "netucate.URL":
230 $this->data['url']['cdata'] = trim($this->cdata);
231 break;
232
233 case "netucate.ID":
234 $this->data['id'][trim($this->cdata)] = trim($this->cdata);
235 break;
236
237 case "netucate.Class.List":
238 case "netucate.Class":
239 case "netucate.User.List":
240 case "netucate.User":
241 break;
242 }
243
244 $this->cdata = '';
245 }
246
250 function handlerCharacterData($a_xml_parser, $a_data)
251 {
252 if(!empty($a_data))
253 {
254 $this->cdata .= $a_data;
255 }
256 }
257
258}
259?>
Base class for sax-based expat parsing extended classes need to overwrite the method setHandlers and ...
freeParser($a_xml_parser)
free xml parser handle
createParser()
create parser
setOptions($a_xml_parser)
set parser options
process reponse from Centra Server (c) Sascha Hofmann, 2004
ilnetucateResponse($a_str)
Constructor @access public.
handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element
startParsing()
start the parser
handlerEndTag($a_xml_parser, $a_name)
parse($a_xml_parser, $a_xml_str)
parse xml file
setHandlers($a_xml_parser)
set event handler should be overwritten by inherited class @access private
handlerCharacterData($a_xml_parser, $a_data)
handler for character data
exit
Definition: login.php:54
redirection script todo: (a better solution should control the processing via a xml file)