[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] api/interface/class.interface_xmlrpc.php, 1.1.2.15
From: |
nomail |
Subject: |
[Phpgroupware-cvs] api/interface/class.interface_xmlrpc.php, 1.1.2.15 |
Date: |
Wed, 16 Jun 2004 18:04:57 +0200 |
Update of /api/interface
Modified Files:
Branch: proposal-branch
class.interface_xmlrpc.php
date: 2004/06/16 16:04:57; author: dcech; state: Exp; lines: +39 -49
Log Message:
modularised the response generation code a little
=====================================================================
Index: api/interface/class.interface_xmlrpc.php
diff -u api/interface/class.interface_xmlrpc.php:1.1.2.14
api/interface/class.interface_xmlrpc.php:1.1.2.15
--- api/interface/class.interface_xmlrpc.php:1.1.2.14 Wed Jun 16 15:37:35 2004
+++ api/interface/class.interface_xmlrpc.php Wed Jun 16 16:04:57 2004
@@ -141,45 +141,7 @@
}
}
- /* Constructing the XML doc */
- $response_packet = "<?xml version=\"1.0\"?>\n";
- $response_packet .= "<methodResponse>\n";
-
- if(!empty($this->method_result))
- {
- $response_packet .= $this->indent."<params>\n";
-
- if(!is_array($this->method_result))
- {
- $response_packet .=
str_repeat($this->indent,2)."<param>\n";
- $response_packet .=
$this->add_vars($this->method_result,3);
- $response_packet .=
str_repeat($this->indent,2)."</param>\n";
- }
- else
- {
-
if(array_key_exists(0,$this->method_result))
- {
- $num =
count($this->method_result);
- for ($i=0; $i < $num; $i++)
- {
- $response_packet .=
str_repeat($this->indent,2)."<param>\n";
- $response_packet .=
$this->add_vars($this->method_result[$i],3);
- $response_packet .=
str_repeat($this->indent,2)."</param>\n";
- }
- }
- else
- {
- $response_packet .=
str_repeat($this->indent,2)."<param>\n";
- $response_packet .=
$this->add_vars($this->method_result,3);
- $response_packet .=
str_repeat($this->indent,2)."</param>\n";
- }
- }
- $response_packet .= $this->indent."</params>\n";
- }
-
- $response_packet .= '</methodResponse>';
-
- return $this->output($response_packet);
+ return
$this->output($this->response($this->method_result));
}
function parse()
@@ -425,6 +387,38 @@
break;
}
}
+
+ function response($result = NOTSET)
+ {
+ $response = "<?xml version=\"1.0\"?>\n";
+ $response .= "<methodResponse>\n";
+
+ if(!empty($result) && $result !== NOTSET)
+ {
+ $response .= $this->indent."<params>\n";
+
+ if(is_array($result) &&
array_key_exists(0,$result))
+ {
+ foreach ($result as $val)
+ {
+ $response .=
str_repeat($this->indent,2)."<param>\n";
+ $response .=
$this->add_vars($val,3);
+ $response .=
str_repeat($this->indent,2)."</param>\n";
+ }
+ }
+ else
+ {
+ $response .=
str_repeat($this->indent,2)."<param>\n";
+ $response .= $this->add_vars($result,3);
+ $response .=
str_repeat($this->indent,2)."</param>\n";
+ }
+
+ $response .= $this->indent."</params>\n";
+ }
+
+ $response .= '</methodResponse>';
+ return $response;
+ }
function add_vars($params,$level = 0)
{
@@ -591,23 +585,19 @@
if(isset($GLOBALS['docs'][$app]['classes'][$app.'_'.$class]['functions'][$func])
&& $GLOBALS['phpgw']->acl->check($methodname, 1))
{
- $result = "<?xml
version=\"1.0\"?>\n<methodResponse>\n";
if(isset($GLOBALS['docs'][$app]['classes'][$app.'_'.$class]['functions'][$func]['abstract']))
{
- $result .= "<params>\n<param>\n";
- $result .=
"<value><string>".$GLOBALS['docs'][$app]['classes'][$app.'_'.$class]['functions'][$func]['abstract']."</string></value>\n";
- $result .= "</param>\n</params>\n";
+ return
$this->output($this->response($GLOBALS['docs'][$app]['classes'][$app.'_'.$class]['functions'][$func]['abstract']));
}
- $result .= "</methodResponse>\n";
- return $this->output($result);
+ return $this->output($this->response());
}
elseif(isset($GLOBALS['docs'][$app]['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.');
+ $this->xmlrpc_fault(1, 'Access Denied. Your
account does not have rights to this function.');
}
elseif(!isset($GLOBALS['docs'][$app]['classes'][$app.'_'.$class]['functions'][$func]))
{
- $this->xmlrpc_fault('1', 'No such method
exists.');
+ $this->xmlrpc_fault(1, 'No such method
exists.');
}
}
@@ -626,5 +616,5 @@
$error_result .= "</methodResponse>\n";
echo $this->output($error_result);
exit;
- }
+ }
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] api/interface/class.interface_xmlrpc.php, 1.1.2.15,
nomail <=