• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

ilinc/classes/class.ilnetucateResponse.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00025 require_once("./classes/class.ilSaxParser.php");
00026 
00035 class ilnetucateResponse extends ilSaxParser
00036 {
00041         function ilnetucateResponse($a_str)
00042         {
00043                 $xml_str = $this->validateInput($a_str);
00044 
00045                 parent::ilSaxParser($xml_str);
00046                                 
00047                 $this->startParsing();
00048         }
00049         
00050         function validateInput($a_str)
00051         {
00052                 $response = split("\r\n\r\n",$a_str);
00053         
00054                 $header = $response[0];
00055                 $response_data = $response[1];
00056                 
00057                 if (strpos($response_data,"<?xml") === false)
00058                 {
00059                         echo "netucateResponse::validateInput() : No valid response data!<br/>";
00060                         var_dump($header,$response_data);
00061                         exit;
00062                 }
00063         
00064         return chop($response_data);
00065         }
00066         
00067         function isError()
00068         {
00069                 if ($this->data['response']['status'] == "error" or $this->data['response']['status'] == "")
00070                 {
00071                         return true;
00072                 }
00073                 
00074                 return false;
00075         }
00076         
00077         function getErrorMsg()
00078         {
00079                 if ($this->data['response']['status'] == "error" or $this->data['response']['status'] == "")
00080                 {
00081                         return trim($this->data['result']['cdata']);
00082                 }
00083         }
00084         
00085         function getResultMsg()
00086         {
00087                 return trim($this->data['result']['cdata']);
00088         }
00089         
00090         function getFirstID()
00091         {
00092                 reset($this->data['id']);
00093                 return current($this->data['id']);
00094         }
00095                 
00096 
00102         function setHandlers($a_xml_parser)
00103         {
00104                 xml_set_object($a_xml_parser,$this);
00105                 xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
00106                 xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
00107         }
00108 
00112         function startParsing()
00113         {
00114                 $xml_parser = $this->createParser();
00115                 $this->setOptions($xml_parser);
00116                 $this->setHandlers($xml_parser);
00117                 $this->parse($xml_parser,$this->xml_file);
00118                 $this->freeParser($xml_parser);
00119                 return true;
00120         }
00121         
00127         function parse($a_xml_parser,$a_xml_str)
00128         {
00129                 $parseOk = xml_parse($a_xml_parser,$a_xml_str,true);
00130 
00131                 if (!$parseOk && (xml_get_error_code($a_xml_parser) != XML_ERROR_NONE))
00132                 {
00133                                 $this->ilias->raiseError("XML Parse Error: ".xml_error_string(xml_get_error_code($a_xml_parser)),$this->ilias->error_obj->FATAL);
00134                 }
00135         }
00136 
00137 
00141         function handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
00142         {
00143                 global $ilErr;
00144 
00145                 switch($a_name)
00146                 {
00147                         case "netucate.API.Response":
00148                                 $this->data['response']['failureCount'] = $a_attribs['failureCount'];
00149                                 $this->data['response']['operationTotal'] = $a_attribs['operationTotal'];
00150                                 $this->data['response']['status'] = $a_attribs['status'];
00151                                 $this->data['response']['successCount'] = $a_attribs['successCount'];
00152                                 break;
00153 
00154                         case "netucate.Result":
00155                                 $this->data['result']['code'] = $a_attribs['code'];
00156                                 $this->data['result']['id'] = $a_attribs['id'];
00157                                 $this->data['result']['name'] = $a_attribs['name'];
00158                                 $this->data['result']['request'] = $a_attribs['request'];
00159                                 break;
00160 
00161                         case "netucate.ElementID":
00162                                 $this->data['element']['type'] = $a_attribs['type'];
00163                                 break;
00164 
00165                         case "netucate.URL":
00166                                 break;
00167 
00168                         case "netucate.ID":
00169                                 break;
00170                                 
00171                         case "netucate.Class.List":
00172                         case "netucate.User.List":
00173                                 break;
00174                                 
00175                         case "netucate.Class":
00176                                 $this->data['classes'][$a_attribs['classid']] = array (
00177                                                                                                                                                 'name' => $a_attribs['name'],
00178                                                                                                                                                 'instructoruserid' => $a_attribs['instructoruserid'],
00179                                                                                                                                                 'bandwidth' => $a_attribs['bandwidth'],
00180                                                                                                                                                 'appsharebandwidth' => $a_attribs['appsharebandwidth'],
00181                                                                                                                                                 'description' => $a_attribs['description'],
00182                                                                                                                                                 'password' => $a_attribs['password'],
00183                                                                                                                                                 'message' => $a_attribs['message'],
00184                                                                                                                                                 'floorpolicy' => $a_attribs['floorpolicy'],
00185                                                                                                                                                 'conferencetypeid' => $a_attribs['conferencetypeid'],
00186                                                                                                                                                 'videobandwidth' => $a_attribs['videobandwidth'],
00187                                                                                                                                                 'videoframerate' => $a_attribs['videoframerate'],
00188                                                                                                                                                 'enablepush' => $a_attribs['enablepush'],
00189                                                                                                                                                 'issecure' => $a_attribs['issecure'],
00190                                                                                                                                                 'alwaysopen' => $a_attribs['alwaysopen'],
00191                                                                                                                                                 'akclassvalue1' => $a_attribs['akclassvalue1'],
00192                                                                                                                                                 'akclassvalue2' => $a_attribs['akclassvalue2']
00193                                                                                                                                                 );
00194                                 break;
00195                                 
00196                         case "netucate.User":
00197                                 $this->data['users'][$a_attribs['userid']] = array (
00198                                                                                                                                                 'fullname' => $a_attribs['fullname'],
00199                                                                                                                                                 'authority' => $a_attribs['authority'],
00200                                                                                                                                                 'email' => $a_attribs['email'],
00201                                                                                                                                                 'homepage' => $a_attribs['homepage'],
00202                                                                                                                                                 'contactinfo' => $a_attribs['contactinfo'],
00203                                                                                                                                                 'comment' => $a_attribs['comments'],
00204                                                                                                                                                 'phonenumber' => $a_attribs['phonenumber'],
00205                                                                                                                                                 'akuservalue1' => $a_attribs['akuservalue1'],
00206                                                                                                                                                 'akuservalue2' => $a_attribs['akuservalue2'],
00207                                                                                                                                                 );
00208                                 break;
00209                 }
00210         }
00211 
00212 
00213         function handlerEndTag($a_xml_parser, $a_name)
00214         {
00215                 switch($a_name)
00216                 {
00217                         case "netucate.API.Response":
00218                                 $this->data['response']['cdata'] = $this->cdata;
00219                                 break;
00220 
00221                         case "netucate.Result":
00222                                 $this->data['result']['cdata'] = $this->cdata;
00223                                 break;
00224 
00225                         case "netucate.ElementID":
00226                                 //$this->data['element']['cdata'] = $this->cdata;
00227                                 break;
00228 
00229                         case "netucate.URL":
00230                                 $this->data['url']['cdata'] = trim($this->cdata);
00231                                 break;
00232 
00233                         case "netucate.ID":
00234                                 $this->data['id'][trim($this->cdata)] = trim($this->cdata);
00235                                 break;
00236                                 
00237                         case "netucate.Class.List":
00238                         case "netucate.Class":
00239                         case "netucate.User.List":
00240                         case "netucate.User":
00241                                 break;
00242                 }
00243                 
00244                 $this->cdata = '';
00245         }
00246         
00250         function handlerCharacterData($a_xml_parser, $a_data)
00251         {
00252                 if(!empty($a_data))
00253                 {
00254                         $this->cdata .= $a_data;
00255                 }
00256         }
00257         
00258 }
00259 ?>

Generated on Fri Dec 13 2013 17:56:49 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1