From 044379d18fbfb7673e5a5992e9c5af7830e358a8 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Thu, 8 May 2008 18:57:58 +0000 Subject: added 'object' key to the XML-RPCS config allowing the passing of a class object for method calls that aren't part of the CI super object --- system/libraries/Xmlrpcs.php | 24 ++++++++++++++++++------ user_guide/libraries/xmlrpc.html | 11 +++++++---- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php index 1b2ffca05..7a4bc825e 100644 --- a/system/libraries/Xmlrpcs.php +++ b/system/libraries/Xmlrpcs.php @@ -41,7 +41,9 @@ class CI_Xmlrpcs extends CI_Xmlrpc var $system_methods = array(); // XML RPC Server methods var $controller_obj; - + var $object = FALSE; + + //------------------------------------- // Constructor, more or less //------------------------------------- @@ -74,6 +76,11 @@ class CI_Xmlrpcs extends CI_Xmlrpc { $this->debug = $config['debug']; } + + if (isset($config['object']) && is_object($config['object'])) + { + $this->object = $config['object']; + } } //------------------------------------- @@ -320,11 +327,16 @@ class CI_Xmlrpcs extends CI_Xmlrpc } else { - $CI =& get_instance(); - return $CI->$method_parts['1']($m); - //$class = new $method_parts['0']; - //return $class->$method_parts['1']($m); - //return call_user_func(array(&$method_parts['0'],$method_parts['1']), $m); + if ($this->object === FALSE) + { + $CI =& get_instance(); + return $CI->$method_parts['1']($m); + } + else + { + return $this->object->$method_parts['1']($m); + //return call_user_func(array(&$method_parts['0'],$method_parts['1']), $m); + } } } else diff --git a/user_guide/libraries/xmlrpc.html b/user_guide/libraries/xmlrpc.html index e77158c47..b7e98f653 100644 --- a/user_guide/libraries/xmlrpc.html +++ b/user_guide/libraries/xmlrpc.html @@ -180,8 +180,9 @@ class and method for processing.

$this->load->library('xmlrpc');
$this->load->library('xmlrpcs');

-$config['functions']['new_post']  = array('function' => 'My_blog.new_entry');
-$config['functions']['update_post'] = array('function' => 'My_blog.update_entry');
+$config['functions]['new_post'] = array('function' => 'My_blog.new_entry'),
+$config['functions]['update_post'] = array('function' => 'My_blog.update_entry');
+$config['object'] = $this;

$this->xmlrpcs->initialize($config);
$this->xmlrpcs->serve(); @@ -189,6 +190,9 @@ $this->xmlrpcs->serve();

The above example contains an array specifying two method requests that the Server allows. The allowed methods are on the left side of the array. When either of those are received, they will be mapped to the class and method on the right.

+

The 'object' key is a special key that you pass an instantiated class object with, which is necessary when the method you are mapping to is not + part of the CodeIgniter super object.

+

In other words, if an XML-RPC Client sends a request for the new_post method, your server will load the My_blog class and call the new_entry function. If the request is for the update_post method, your @@ -196,8 +200,7 @@ server will load the My_blog class and call the update_entryThe function names in the above example are arbitrary. You'll decide what they should be called on your server, or if you are using standardized APIs, like the Blogger or MetaWeblog API, you'll use their function names.

- - +

Processing Server Requests

When the XML-RPC Server receives a request and loads the class/method for processing, it will pass -- cgit v1.2.3-24-g4f1b