Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/zend/Zend/XmlRpc/Server/System.php
Go to the documentation of this file.
00001 <?php
00032 class Zend_XmlRpc_Server_System
00033 {
00037     protected $_server;
00038 
00045     public function __construct(Zend_XmlRpc_Server $server)
00046     {
00047         $this->_server = $server;
00048     }
00049 
00057     public function listMethods()
00058     {
00059         $table = $this->_server->getDispatchTable()->getMethods();
00060         return array_keys($table);
00061     }
00062 
00069     public function methodHelp($method)
00070     {
00071         $table = $this->_server->getDispatchTable();
00072         if (!$table->hasMethod($method)) {
00073             require_once 'Zend/XmlRpc/Server/Exception.php';
00074             throw new Zend_XmlRpc_Server_Exception('Method "' . $method . '" does not exist', 640);
00075         }
00076 
00077         return $table->getMethod($method)->getMethodHelp();
00078     }
00079 
00086     public function methodSignature($method)
00087     {
00088         $table = $this->_server->getDispatchTable();
00089         if (!$table->hasMethod($method)) {
00090             require_once 'Zend/XmlRpc/Server/Exception.php';
00091             throw new Zend_XmlRpc_Server_Exception('Method "' . $method . '" does not exist', 640);
00092         }
00093         $method = $table->getMethod($method)->toArray();
00094         return $method['prototypes'];
00095     }
00096 
00114     public function multicall($methods)
00115     {
00116         $responses = array();
00117         foreach ($methods as $method) {
00118             $fault = false;
00119             if (!is_array($method)) {
00120                 $fault = $this->_server->fault('system.multicall expects each method to be a struct', 601);
00121             } elseif (!isset($method['methodName'])) {
00122                 $fault = $this->_server->fault('Missing methodName: ' . var_export($methods, 1), 602);
00123             } elseif (!isset($method['params'])) {
00124                 $fault = $this->_server->fault('Missing params', 603);
00125             } elseif (!is_array($method['params'])) {
00126                 $fault = $this->_server->fault('Params must be an array', 604);
00127             } else {
00128                 if ('system.multicall' == $method['methodName']) {
00129                     // don't allow recursive calls to multicall
00130                     $fault = $this->_server->fault('Recursive system.multicall forbidden', 605);
00131                 }
00132             }
00133 
00134             if (!$fault) {
00135                 try {
00136                     $request = new Zend_XmlRpc_Request();
00137                     $request->setMethod($method['methodName']);
00138                     $request->setParams($method['params']);
00139                     $response = $this->_server->handle($request);
00140                     if ($response instanceof Zend_XmlRpc_Fault
00141                         || $response->isFault()
00142                     ) {
00143                         $fault = $response;
00144                     } else {
00145                         $responses[] = $response->getReturnValue();
00146                     }
00147                 } catch (Exception $e) {
00148                     $fault = $this->_server->fault($e);
00149                 }
00150             }
00151 
00152             if ($fault) {
00153                 $responses[] = array(
00154                     'faultCode'   => $fault->getCode(),
00155                     'faultString' => $fault->getMessage()
00156                 );
00157             }
00158         }
00159 
00160         return $responses;
00161     }
00162 }
 All Data Structures Namespaces Files Functions Variables Enumerations