From: x2000habouzit Date: Sun, 23 Jul 2006 11:50:01 +0000 (+0000) Subject: merge xmlrpc stuff, and put it in classes/ X-Git-Tag: xorg/0.9.11~324 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=27cb2301e3ba633ca355d1b5b5815d28ff8d84e8;p=platal.git merge xmlrpc stuff, and put it in classes/ git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@581 839d8a87-29fc-0310-9880-83ba4fa771e5 --- diff --git a/include/platal/xmlrpc-server.inc.php b/classes/XmlrpcClient.php similarity index 55% rename from include/platal/xmlrpc-server.inc.php rename to classes/XmlrpcClient.php index 23b12d5..101fa74 100644 --- a/include/platal/xmlrpc-server.inc.php +++ b/classes/XmlrpcClient.php @@ -1,5 +1,4 @@ echo('x')."\n"; + * print $client->add(1, 3)."\n"; + */ + +class XmlrpcClient +{ + var $url; + var $urlparts; + + function XmlrpcClient($url) + { + $this->url = $url; + $this->urlparts = parse_url($this->url); + foreach (array('scheme', 'host', 'user', 'pass', 'path', 'query', 'fragment') as $part) { + if (!isset($this->urlparts[$part])) { + $this->urlparts[$part] = null; + } + } + } + + function __call($function, $arguments, &$return) + { + $requestprms['host'] = $this->urlparts['host']; + $requestprms['port'] = $this->urlparts['port']; + $requestprms['uri'] = $this->urlparts['path']; + $requestprms['user'] = $this->urlparts['user']; + $requestprms['pass'] = $this->urlparts['pass']; + $requestprms['method'] = $function; + $requestprms['args'] = $arguments; + $requestprms['timeout'] = 0; + $requestprms['secure'] = 0; + + $result = xu_rpc_http_concise($requestprms); + if (is_array($result) && isset($result['faultCode'])) { + print('Error in xmlrpc call \''.$function.'\''."\n"); + print(' code : '.$result['faultCode']."\n"); + print(' message: '.$result['faultString']."\n"); + return false; + } + $return = $result; + return true; + } + +} + +overload('XmlrpcClient'); + +// vim:set et sw=4 sts=4 sws=4: ?> diff --git a/htdocs/admin/lists.php b/htdocs/admin/lists.php index 1674404..07d84fc 100644 --- a/htdocs/admin/lists.php +++ b/htdocs/admin/lists.php @@ -22,8 +22,7 @@ require_once("xorg.inc.php"); new_admin_page('admin/lists.tpl'); $page->assign('xorg_title','Polytechnique.org - Administration - Mailing lists'); -require_once('platal/xmlrpc-client.inc.php'); -require_once('lists.inc.php'); +require_once 'lists.inc.php'; $client =& lists_xmlrpc(S::v('uid'), S::v('password')); $listes = $client->get_all_lists(); diff --git a/include/lists.inc.php b/include/lists.inc.php index d86b3f3..15f0d67 100644 --- a/include/lists.inc.php +++ b/include/lists.inc.php @@ -21,7 +21,7 @@ // {{{ import class definitions -require_once 'platal/xmlrpc-client.inc.php'; +require_once dirname(__FILE__).'/../classes/XmlrpcClient.php'; // }}} // {{{ function lists_xmlrpc @@ -32,7 +32,7 @@ function &lists_xmlrpc($uid, $pass, $fqdn=null) $dom = is_null($fqdn) ? $globals->mail->domain : $fqdn; $url = "http://$uid:$pass@{$globals->lists->rpchost}:{$globals->lists->rpcport}/$dom"; - $client = new xmlrpc_client($url); + $client = new XmlrpcClient($url); return $client; } diff --git a/include/platal/xmlrpc-client.inc.php b/include/platal/xmlrpc-client.inc.php deleted file mode 100644 index fe1bec7..0000000 --- a/include/platal/xmlrpc-client.inc.php +++ /dev/null @@ -1,77 +0,0 @@ -echo('x')."\n"; - * print $client->add(1, 3)."\n"; - */ - -class xmlrpc_client -{ - var $url; - var $urlparts; - - function xmlrpc_client($url) - { - $this->url = $url; - $this->urlparts = parse_url($this->url); - foreach (array('scheme', 'host', 'user', 'pass', 'path', 'query', 'fragment') as $part) { - if (!isset($this->urlparts[$part])) { - $this->urlparts[$part] = null; - } - } - } - - function __call($function, $arguments, &$return) - { - $requestprms['host'] = $this->urlparts['host']; - $requestprms['port'] = $this->urlparts['port']; - $requestprms['uri'] = $this->urlparts['path']; - $requestprms['user'] = $this->urlparts['user']; - $requestprms['pass'] = $this->urlparts['pass']; - $requestprms['method'] = $function; - $requestprms['args'] = $arguments; - $requestprms['timeout'] = 0; - $requestprms['secure'] = 0; - - $result = xu_rpc_http_concise($requestprms); - if (is_array($result) && isset($result['faultCode'])) { - print('Error in xmlrpc call \''.$function.'\''."\n"); - print(' code : '.$result['faultCode']."\n"); - print(' message: '.$result['faultString']."\n"); - return false; - } - $return = $result; - return true; - } - -} - -overload('xmlrpc_client'); - -// vim:set et sw=4 sts=4 sws=4: -?> diff --git a/include/validations/listes.inc.php b/include/validations/listes.inc.php index fe06410..e74eb02 100644 --- a/include/validations/listes.inc.php +++ b/include/validations/listes.inc.php @@ -85,8 +85,7 @@ class ListeReq extends Validate function commit() { - require_once('platal/xmlrpc-client.inc.php'); - require_once('lists.inc.php'); + require_once 'lists.inc.php'; $client =& lists_xmlrpc(S::v('uid'), S::v('password')); $ret = $client->create_list($this->liste, $this->desc, diff --git a/include/webservices/manageurs.client.inc.php b/include/webservices/manageurs.client.inc.php index a5f47b8..9b0ecf7 100644 --- a/include/webservices/manageurs.client.inc.php +++ b/include/webservices/manageurs.client.inc.php @@ -1,34 +1,34 @@ array(0 => array('adr1' => 'test AX', 'city' => 'Trou perdu'))); - - $client = new xmlrpc_client($url); - - global $globals; - if($array = $client->get_annuaire_infos($globals->webservice->pass, $id_assoce, $adresse)){ - - if( is_string($array) ){ - $erreur = xmlrpc_decode($array); - echo $erreur['erreurstring']."\n"; - return $erreur['erreur']; - } - else{ - manageurs_encrypt_init($id_assoce); - $reply = manageurs_decrypt_array($array); - manageurs_encrypt_close(); - return $reply; + // return array('adresse' => array(0 => array('adr1' => 'test AX', 'city' => 'Trou perdu'))); + + $client = new XmlrpcClient($url); + + global $globals; + if($array = $client->get_annuaire_infos($globals->webservice->pass, $id_assoce, $adresse)){ + + if( is_string($array) ){ + $erreur = xmlrpc_decode($array); + echo $erreur['erreurstring']."\n"; + return $erreur['erreur']; + } + else{ + manageurs_encrypt_init($id_assoce); + $reply = manageurs_decrypt_array($array); + manageurs_encrypt_close(); + return $reply; + } } - } - else return false; + else return false; } ?> diff --git a/modules/auth.php b/modules/auth.php index afdf1c8..e3571c0 100644 --- a/modules/auth.php +++ b/modules/auth.php @@ -48,7 +48,6 @@ class AuthModule extends PLModule { global $globals; - require_once 'platal/xmlrpc-client.inc.php'; require_once 'lists.inc.php'; $cle = $globals->core->econfiance; diff --git a/modules/xnetlists.php b/modules/xnetlists.php index a534a5b..1201fbf 100644 --- a/modules/xnetlists.php +++ b/modules/xnetlists.php @@ -146,7 +146,6 @@ class XnetListsModule extends ListsModule return; } - require_once 'platal/xmlrpc-client.inc.php'; require_once 'lists.inc.php'; $ret = $this->client->create_list( $liste, Post::get('desc'), Post::get('advertise'),