phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] api/interface class.interface_xmlrpc.php, 1.1.2.3, 1


From: Dan Kuykendall <address@hidden>
Subject: [Phpgroupware-cvs] api/interface class.interface_xmlrpc.php, 1.1.2.3, 1.1.2.4
Date: Sun, 02 Nov 2003 00:47:27 +0000

Update of /cvsroot/phpgroupware/api/interface
In directory subversions:/tmp/cvs-serv14439/api/interface

Modified Files:
      Tag: proposal-branch
        class.interface_xmlrpc.php 
Log Message:
added proper introspection support

Index: class.interface_xmlrpc.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/interface/Attic/class.interface_xmlrpc.php,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -d -r1.1.2.3 -r1.1.2.4
*** class.interface_xmlrpc.php  1 Nov 2003 19:01:01 -0000       1.1.2.3
--- class.interface_xmlrpc.php  2 Nov 2003 00:47:25 -0000       1.1.2.4
***************
*** 64,87 ****
                {
                        $GLOBALS['phpgw']->finish(False);
!                       $error_result = "<?xml version=\"1.0\"?>\n";
!                       $error_result .= "<methodResponse>\n";
!                       $error_result .= "      <fault>\n";
!                       $error_result .= "              <value>\n";
!                       $error_result .= "                      <struct>\n";
!                       $error_result .= "                              
<member>\n";
!                       $error_result .= "                                      
<name>faultCode</name>\n";
!                       $error_result .= "                                      
<value><int>1</int></value>\n";
!                       $error_result .= "                              
</member>\n";
!                       $error_result .= "                              
<member>\n";
!                       $error_result .= "                                      
<name>faultString</name>\n";
!                       $error_result .= "                                      
<value><string>Please login.</string></value>\n";
!                       $error_result .= "                              
</member>\n";
!                       $error_result .= "                      </struct>\n";
!                       $error_result .= "              </value>\n";
!                       $error_result .= "      </fault>\n";
!                       $error_result .= "</methodResponse>\n";
!                       
!                       $this->output($error_result);
!                       exit;
                }
  
--- 64,68 ----
                {
                        $GLOBALS['phpgw']->finish(False);
!                       $this->xmlrpc_fault('1', 'Please login.');
                }
  
***************
*** 106,129 ****
                                $msg = 'Username and/or password missing.';
                        }
!                       $error_result = "<?xml version=\"1.0\"?>\n";
!                       $error_result .= "<methodResponse>\n";
!                       $error_result .= "      <fault>\n";
!                       $error_result .= "              <value>\n";
!                       $error_result .= "                      <struct>\n";
!                       $error_result .= "                              
<member>\n";
!                       $error_result .= "                                      
<name>faultCode</name>\n";
!                       $error_result .= "                                      
<value><int>$code</int></value>\n";
!                       $error_result .= "                              
</member>\n";
!                       $error_result .= "                              
<member>\n";
!                       $error_result .= "                                      
<name>faultString</name>\n";
!                       $error_result .= "                                      
<value><string>$msg</string></value>\n";
!                       $error_result .= "                              
</member>\n";
!                       $error_result .= "                      </struct>\n";
!                       $error_result .= "              </value>\n";
!                       $error_result .= "      </fault>\n";
!                       $error_result .= "</methodResponse>\n";
!                       
!                       $this->output($error_result);
!                       exit;
                }
  
--- 87,91 ----
                                $msg = 'Username and/or password missing.';
                        }
!                       $this->xmlrpc_fault($code, $msg);
                }
  
***************
*** 134,157 ****
                function access_denied($methodname, $inputs = '')
                {
!                       $error_result = "<?xml version=\"1.0\"?>\n";
!                       $error_result .= "<methodResponse>\n";
!                       $error_result .= "      <fault>\n";
!                       $error_result .= "              <value>\n";
!                       $error_result .= "                      <struct>\n";
!                       $error_result .= "                              
<member>\n";
!                       $error_result .= "                                      
<name>faultCode</name>\n";
!                       $error_result .= "                                      
<value><int>99</int></value>\n";
!                       $error_result .= "                              
</member>\n";
!                       $error_result .= "                              
<member>\n";
!                       $error_result .= "                                      
<name>faultString</name>\n";
!                       $error_result .= "                                      
<value><string>Access denied to $methodname</string></value>\n";
!                       $error_result .= "                              
</member>\n";
!                       $error_result .= "                      </struct>\n";
!                       $error_result .= "              </value>\n";
!                       $error_result .= "      </fault>\n";
!                       $error_result .= "</methodResponse>\n";
!                       
!                       $this->output($error_result);
!                       exit;
                }
                
--- 96,100 ----
                function access_denied($methodname, $inputs = '')
                {
!                       $this->xmlrpc_fault('99', 'Access denied to 
'.$methodname);
                }
                
***************
*** 172,179 ****
                        $api_data = xml2var($xml_result);
  
!                       if($this->methodName == 'system.listMethods')
                        {
!                               $this->get_method_list($api_data);
!                               return;
                        }
                        
--- 115,129 ----
                        $api_data = xml2var($xml_result);
  
!                       switch ($this->methodName)
                        {
!                               case 'system.listMethods':
!                                       $this->system_listMethods();
!                                       return;
!                               case 'system.methodSignature':
!                                       $this->system_methodSignature();
!                                       return;
!                               case 'system.methodHelp':
!                                       $this->system_methodHelp();
!                                       return;                                 
                        }
                        
***************
*** 228,231 ****
--- 178,190 ----
                function parse()
                {
+ $GLOBALS['HTTP_RAW_POST_DATA'] = '<?xml version="1.0"?>
+ <methodCall>
+ <methodName>system.methodHelp</methodName>
+ <params>
+ <param>
+ <value><string>api.base.login</string></value>
+ </param>
+ </params>
+ </methodCall>';
                        if(!isset($GLOBALS['HTTP_RAW_POST_DATA']))
                        {
***************
*** 233,237 ****
                                exit;
                        }
!                               
                        if(!strstr($GLOBALS['HTTP_RAW_POST_DATA'], '<?xml'))
                        {
--- 192,196 ----
                                exit;
                        }
! 
                        if(!strstr($GLOBALS['HTTP_RAW_POST_DATA'], '<?xml'))
                        {
***************
*** 266,291 ****
                        {
                                $GLOBALS['phpgw']->finish(False);
!                               $error_result = "<?xml version=\"1.0\"?>\n";
!                               $error_result .= "<methodResponse>\n";
!                               $error_result .= "      <fault>\n";
!                               $error_result .= "              <value>\n";
!                               $error_result .= "                      
<struct>\n";
!                               $error_result .= "                              
<member>\n";
!                               $error_result .= "                              
        <name>faultCode</name>\n";
!                               $error_result .= "                              
        <value><int>1</int></value>\n";
!                               $error_result .= "                              
</member>\n";
!                               $error_result .= "                              
<member>\n";
!                               $error_result .= "                              
        <name>faultString</name>\n";
!                               $error_result .= "                              
        <value><string>Invalid xmlrpc packet. methodName 
missing.</string></value>\n";
!                               $error_result .= "                              
</member>\n";
!                               $error_result .= "                      
</struct>\n";
!                               $error_result .= "              </value>\n";
!                               $error_result .= "      </fault>\n";
!                               $error_result .= "</methodResponse>\n";
!                               exit;
                        }
  
                        $this->methodName = 
$this->xml_vals[$this->xml_index['methodName'][0]]['value'];
- 
                        switch ($this->methodName)
                        {
--- 225,232 ----
                        {
                                $GLOBALS['phpgw']->finish(False);
!                               $this->xmlrpc_fault('1', 'Invalid xmlrpc 
packet. methodName missing.');
                        }
  
                        $this->methodName = 
$this->xml_vals[$this->xml_index['methodName'][0]]['value'];
                        switch ($this->methodName)
                        {
***************
*** 293,296 ****
--- 234,243 ----
                                        unset($this->op);
                                        break;
+                               case 'system.methodSignature':
+                                       unset($this->op);
+                                       break;
+                               case 'system.methodHelp':
+                                       unset($this->op);
+                                       break;
                                case 'system.logout':
                                        $this->op = 'api.base.logout';
***************
*** 556,560 ****
                }
  
!               function get_method_list($api_data)
                {
                        $GLOBALS['phpgw']->load_docs();
--- 503,507 ----
                }
  
!               function system_listMethods()
                {
                        $GLOBALS['phpgw']->load_docs();
***************
*** 584,625 ****
                        {
                                /* I dont think this follows the standard, but 
I need to find some good examples of how it SHOULD look. Dan */
!                               $result = "<?xml version=\"1.0\" 
?>\n<introspection version=\"1.0\">\n<methodList>\n<struct>\n";
                                foreach($allow_methods as 
$methodname=>$methodname_data)
                                {
                                        if($methodname_data['type'] == 'public')
                                        {
!                                               $result .= "<member>\n";
!                                               $result .= 
"<name>$methodname</name>\n";
!                                               $result .= 
"<purpose>".$methodname_data['abstract']."</purpose>\n";
!                                               
if(is_array($methodname_data['params']))
!                                               {
!                                                       //$result .= 
"<struct>\n<member>\n";
!                                                       $result .= "<params>\n";
!                                                       
foreach($methodname_data['params'] as $paramname=>$paramname_data)
!                                                       {
!                                                               $result .= 
"<param>\n";
!                                                               $result .= 
"<name>$paramname</name>\n";
!                                                               $result .= 
"<type>".$paramname_data['type']."</type>\n";
!                                                               $result .= 
"<description>".$paramname_data['desc']."</description>\n";
!                                                               
if($paramname_data['default'] == '##REQUIRD##' | $paramname_data['default'] == 
'required')
!                                                               {
!                                                                       $result 
.= "<optional>false</optional>\n";
!                                                               }
!                                                               else
!                                                               {
!                                                                       $result 
.= "<optional>true</optional>\n";
!                                                               }
!                                                               $result .= 
"</param>\n";
!                                                       }
!                                                       $result .= 
"</params>\n";
!                                                       //$result .= 
"</struct>\n</member>\n";
!                                               }
!                                               $result .= "</member>\n";
                                        }
                                }
!                               $result .= 
"</struct>\n</methodList>\n</introspection>";
                        }
                        $this->output($result);
                        exit;
                }
        }
--- 531,654 ----
                        {
                                /* I dont think this follows the standard, but 
I need to find some good examples of how it SHOULD look. Dan */
!                               $result = "<?xml version=\"1.0\" 
?>\n<methodResponse>\n<params>\n<param>\n<value>\n<array>\n<data>\n";
                                foreach($allow_methods as 
$methodname=>$methodname_data)
                                {
                                        if($methodname_data['type'] == 'public')
                                        {
!                                               $result .= 
"<value><string>$methodname</string></value>\n";
                                        }
                                }
!                               $result .= 
"</data>\n</array>\n</value>\n</param>\n</params>\n</methodResponse>";
                        }
                        $this->output($result);
                        exit;
                }
+ 
+               function system_methodSignature()
+               {
+                       
if(isset($this->xml_vals[$this->xml_index['string'][0]]['value']))
+                       {
+                               $methodname = 
$this->xml_vals[$this->xml_index['string'][0]]['value'];
+                       }
+                       
elseif(isset($this->xml_vals[$this->xml_index['value'][0]]['value']))
+                       {
+                               $methodname = 
$this->xml_vals[$this->xml_index['value'][0]]['value'];
+                       }
+                       else
+                       {
+                               $this->xmlrpc_fault('1', 'Invalid request. 
methodName missing.');
+                       }
+ 
+                       $GLOBALS['phpgw']->load_docs();
+                       list($app,$class,$func) = explode('.',$methodname);
+ 
+                       
if(isset($GLOBALS['docs']['classes'][$app.'_'.$class]['functions'][$func]) && 
$GLOBALS['phpgw']->acl->check($methodname, 1))
+                       {
+                               $result = "<?xml 
version=\"1.0\"?>\n<methodResponse>\n";
+                               
if(is_array($GLOBALS['docs']['classes'][$app.'_'.$class]['functions'][$func]['params']))
+                               {
+                                       $result .= 
"<params>\n<param>\n<value><array>\n<data>\n<value><array>\n<data>\n";
+                                       
foreach($GLOBALS['docs']['classes'][$app.'_'.$class]['functions'][$func]['params']
 as $paramname=>$paramname_data)
+                                       {
+                                               $result .= 
"<value><string>".$paramname_data['type']."</string></value>\n";
+                                       }
+                                       $result .= 
"</data>\n</array></value>\n</data>\n</array></value>\n</param>\n</params>\n";
+                               }
+                               $result .= "</methodResponse>\n";
+                               $this->output($result);
+                               exit;
+                       }
+                       
elseif(isset($GLOBALS['docs']['classes'][$app.'_'.$class]['functions'][$func]) 
&& !$GLOBALS['phpgw']->acl->check($methodname, 1))
+                       {
+                               $this->xmlrpc_fault('1', 'Access Denied. Your 
account does not have rights to this function.');
+                       }
+                       
elseif(!isset($GLOBALS['docs']['classes'][$app.'_'.$class]['functions'][$func]))
+                       {
+                               $this->xmlrpc_fault('1', 'No such method 
exists.');
+                       }
+               }
+ 
+               function system_methodHelp()
+               {
+                       
if(isset($this->xml_vals[$this->xml_index['string'][0]]['value']))
+                       {
+                               $methodname = 
$this->xml_vals[$this->xml_index['string'][0]]['value'];
+                       }
+                       
elseif(isset($this->xml_vals[$this->xml_index['value'][0]]['value']))
+                       {
+                               $methodname = 
$this->xml_vals[$this->xml_index['value'][0]]['value'];
+                       }
+                       else
+                       {
+                               $this->xmlrpc_fault('1', 'Invalid request. 
methodName missing.');
+                       }
+ 
+                       $GLOBALS['phpgw']->load_docs();
+                       list($app,$class,$func) = explode('.',$methodname);
+ 
+                       
if(isset($GLOBALS['docs']['classes'][$app.'_'.$class]['functions'][$func]) && 
$GLOBALS['phpgw']->acl->check($methodname, 1))
+                       {
+                               $result = "<?xml 
version=\"1.0\"?>\n<methodResponse>\n";
+                               
if(isset($GLOBALS['docs']['classes'][$app.'_'.$class]['functions'][$func]['abstract']))
+                               {
+                                       $result .= "<params>\n<param>\n";
+                                       $result .= 
"<value><string>".$GLOBALS['docs']['classes'][$app.'_'.$class]['functions'][$func]['abstract']."</string></value>\n";
+                                       $result .= "</param>\n</params>\n";
+                               }
+                               $result .= "</methodResponse>\n";
+                               $this->output($result);
+                               exit;
+                       }
+                       
elseif(isset($GLOBALS['docs']['classes'][$app.'_'.$class]['functions'][$func]) 
&& !$GLOBALS['phpgw']->acl->check($methodname, 1))
+                       {
+                               $this->xmlrpc_fault('1', 'Access Denied. Your 
account does not have rights to this function.');
+                       }
+                       
elseif(!isset($GLOBALS['docs']['classes'][$app.'_'.$class]['functions'][$func]))
+                       {
+                               $this->xmlrpc_fault('1', 'No such method 
exists.');
+                       }
+               }
+               
+               function xmlrpc_fault($code, $text)
+               {
+                       $error_result = "<?xml version=\"1.0\"?>\n";
+                       $error_result .= "<methodResponse>\n";
+                       $error_result .= "      <fault>\n";
+                       $error_result .= "              <value>\n";
+                       $error_result .= "                      <struct>\n";
+                       $error_result .= "                              
<member>\n";
+                       $error_result .= "                                      
<name>faultCode</name>\n";
+                       $error_result .= "                                      
<value><int>$code</int></value>\n";
+                       $error_result .= "                              
</member>\n";
+                       $error_result .= "                              
<member>\n";
+                       $error_result .= "                                      
<name>faultString</name>\n";
+                       $error_result .= "                                      
<value><string>$text</string></value>\n";
+                       $error_result .= "                              
</member>\n";
+                       $error_result .= "                      </struct>\n";
+                       $error_result .= "              </value>\n";
+                       $error_result .= "      </fault>\n";
+                       $error_result .= "</methodResponse>\n";
+                       $this->output($error_result);
+                       exit;
+               }       
        }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]