mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-13 17:00:45 +01:00
Adding parts of new app registry system. Initial calls allow get_appby[id/name] and find_new_app. More to follow.
This commit is contained in:
parent
e9fd4b08b4
commit
220e0a5c62
335
phpgwapi/inc/class.app_registry.inc.php
Executable file
335
phpgwapi/inc/class.app_registry.inc.php
Executable file
@ -0,0 +1,335 @@
|
|||||||
|
<?php
|
||||||
|
/**************************************************************************\
|
||||||
|
* phpGroupWare API - App(lication) Registry Manager Class *
|
||||||
|
* This file written by Mark Peters <skeeter@phpgroupware.org> *
|
||||||
|
* Copyright (C) 2001 Mark Peters *
|
||||||
|
* -------------------------------------------------------------------------*
|
||||||
|
* This library is part of the phpGroupWare API *
|
||||||
|
* http://www.phpgroupware.org/api *
|
||||||
|
* ------------------------------------------------------------------------ *
|
||||||
|
* This library is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2.1 of the License, *
|
||||||
|
* or any later version. *
|
||||||
|
* This library is distributed in the hope that it will be useful, but *
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
|
* See the GNU Lesser General Public License for more details. *
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License *
|
||||||
|
* along with this library; if not, write to the Free Software Foundation, *
|
||||||
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
|
||||||
|
\**************************************************************************/
|
||||||
|
|
||||||
|
/* $Id$ */
|
||||||
|
/*!
|
||||||
|
@class app_registry
|
||||||
|
@abstract functions for managing and installing apps via XML-RPC/SOAP
|
||||||
|
@discussion Author: skeeter
|
||||||
|
*/
|
||||||
|
class app_registry
|
||||||
|
{
|
||||||
|
var $public_functions = array(
|
||||||
|
'list_methods' => True,
|
||||||
|
'request_appbyid' => True,
|
||||||
|
'request_appbyname' => True,
|
||||||
|
'request_newer_applist' => True,
|
||||||
|
'get_appbyid' => True,
|
||||||
|
'get_appbyname' => True,
|
||||||
|
'find_new_app' => True
|
||||||
|
);
|
||||||
|
|
||||||
|
var $soap_functions = array();
|
||||||
|
|
||||||
|
var $db;
|
||||||
|
var $is;
|
||||||
|
var $client;
|
||||||
|
var $server;
|
||||||
|
|
||||||
|
// var $target_page = '/cvsdemo/xmlrpc.php';
|
||||||
|
// var $target_site = 'www.phpgroupware.org';
|
||||||
|
var $target_page = '/phpgroupware/xmlrpc.php';
|
||||||
|
var $target_site = 'devel';
|
||||||
|
var $target_port = 80;
|
||||||
|
|
||||||
|
function app_registry($param='')
|
||||||
|
{
|
||||||
|
$this->db = $GLOBALS['phpgw']->db;
|
||||||
|
|
||||||
|
if(is_array($param))
|
||||||
|
{
|
||||||
|
// This is the interserver communicator
|
||||||
|
$this->is = CreateObject('phpgwapi.interserver',$param['server']);
|
||||||
|
$this->is->sessionid = $param['sessionid'];
|
||||||
|
$this->is->kp3 = $param['kp3'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// create the app_registry services client
|
||||||
|
$this->client = CreateObject('phpgwapi.xmlrpc_client',$this->target_page,$this->target_site,$this->target_port);
|
||||||
|
$this->client->debug = False;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function list_methods($_type='xmlrpc')
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
This handles introspection or discovery by the logged in client,
|
||||||
|
in which case the input might be an array. The server always calls
|
||||||
|
this function to fill the server dispatch map using a string.
|
||||||
|
*/
|
||||||
|
if (is_array($_type))
|
||||||
|
{
|
||||||
|
$_type = $_type['type'];
|
||||||
|
}
|
||||||
|
switch($_type)
|
||||||
|
{
|
||||||
|
case 'xmlrpc':
|
||||||
|
$xml_functions = Array(
|
||||||
|
'list_methods' => Array(
|
||||||
|
'function' => 'list_methods',
|
||||||
|
'signature' => Array(
|
||||||
|
Array(
|
||||||
|
xmlrpcStruct,
|
||||||
|
xmlrpcString
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'docstring' => lang('Read this list of methods.')
|
||||||
|
),
|
||||||
|
'get_appbyid' => Array(
|
||||||
|
'function' => 'get_appbyid',
|
||||||
|
'signature' => Array(
|
||||||
|
Array(
|
||||||
|
xmlrpcStruct,
|
||||||
|
xmlrpcString
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'docstring' => lang('Read a single app by id.')
|
||||||
|
),
|
||||||
|
'get_appbyname' => Array(
|
||||||
|
'function' => 'get_appbyname',
|
||||||
|
'signature' => Array(
|
||||||
|
Array(
|
||||||
|
xmlrpcStruct,
|
||||||
|
xmlrpcString
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'docstring' => lang('Read a single app by name.')
|
||||||
|
),
|
||||||
|
'find_new_app' => Array(
|
||||||
|
'function' => 'find_new_app',
|
||||||
|
'signature' => Array(
|
||||||
|
Array(
|
||||||
|
xmlrpcStruct,
|
||||||
|
xmlrpcStruct
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'docstring' => lang('compare an array of apps/versions against the repository and return new/updated list of apps.')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return $xml_functions;
|
||||||
|
break;
|
||||||
|
case 'soap':
|
||||||
|
return $this->soap_functions;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return array();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function request($method, $args)
|
||||||
|
{
|
||||||
|
$msg = CreateObject('phpgwapi.xmlrpcmsg',$method,$args);
|
||||||
|
$resp = $this->client->send($msg);
|
||||||
|
if (!$resp)
|
||||||
|
{
|
||||||
|
echo '<p>IO error: '.$this->client->errstr.'</p>';
|
||||||
|
$GLOBALS['phpgw']->common->phpgw_exit();
|
||||||
|
}
|
||||||
|
if ($resp->faultCode())
|
||||||
|
{
|
||||||
|
echo '<p>There was an error: '.$resp->faultCode().' '.$resp->faultString().'</p>';
|
||||||
|
$GLOBALS['phpgw']->common->phpgw_exit();
|
||||||
|
}
|
||||||
|
return xmlrpc_decode($resp->value());
|
||||||
|
}
|
||||||
|
|
||||||
|
function request_appbyid($appid)
|
||||||
|
{
|
||||||
|
if(is_object($this->is))
|
||||||
|
{
|
||||||
|
return $this->is->send('system.get_appbyid',$appid,$this->is->server['server_url']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return $this->request('phpgwapi.app_registry.get_appbyid',$appid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function request_appbyname($app_name)
|
||||||
|
{
|
||||||
|
if(is_object($this->is))
|
||||||
|
{
|
||||||
|
return $this->is->send('system.get_appbyname',$app_name,$this->is->server['server_url']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return $this->request('phpgwapi.app_registry.get_appbyname',$app_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function request_newer_applist($dummy='')
|
||||||
|
{
|
||||||
|
$this->db->query('SELECT * FROM phpgw_applications',__LINE__,__FILE__);
|
||||||
|
while($this->db->next_record())
|
||||||
|
{
|
||||||
|
$app_list[$this->db->f('app_id')] = Array(
|
||||||
|
'id' => $this->db->f('app_id'),
|
||||||
|
'version' => $this->db->f('app_version')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(is_object($this->is))
|
||||||
|
{
|
||||||
|
return $this->is->send('system.find_new_app',$app_list,$this->is->server['server_url']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return $this->request('phpgwapi.app_registry.find_new_app',$app_list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_result()
|
||||||
|
{
|
||||||
|
switch($this->db->num_rows())
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
$app[] = CreateObject('phpgwapi.xmlrpcval',CreateObject('phpgwapi.xmlrpcval',False,'boolean'),'boolean');
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
$this->db->next_record();
|
||||||
|
$app[] = CreateObject('phpgwapi.xmlrpcval',
|
||||||
|
Array(
|
||||||
|
'id' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_id'),'int'),
|
||||||
|
'name' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_name'),'string'),
|
||||||
|
'title' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_title'),'string'),
|
||||||
|
'version' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_version'),'string'),
|
||||||
|
'tables' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_tables'),'string')
|
||||||
|
),
|
||||||
|
'struct'
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
while($this->db->next_record())
|
||||||
|
{
|
||||||
|
$app[] = CreateObject('phpgwapi.xmlrpcval',
|
||||||
|
Array(
|
||||||
|
'id' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_id'),'int'),
|
||||||
|
'name' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_name'),'string'),
|
||||||
|
'title' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_title'),'string'),
|
||||||
|
'version' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_version'),'string'),
|
||||||
|
'tables' => CreateObject('phpgwapi.xmlrpcval',$this->db->f('app_tables'),'string')
|
||||||
|
),
|
||||||
|
'struct'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval',$app, 'struct'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// function get_result()
|
||||||
|
// {
|
||||||
|
// switch($this->db->num_rows())
|
||||||
|
// {
|
||||||
|
// case 0:
|
||||||
|
// $app = False;
|
||||||
|
// break;
|
||||||
|
// case 1:
|
||||||
|
// $this->db->next_record();
|
||||||
|
// $app = Array(
|
||||||
|
// 'id' => $this->db->f('app_id'),
|
||||||
|
// 'name' => $this->db->f('app_name'),
|
||||||
|
// 'title' => $this->db->f('app_title'),
|
||||||
|
// 'version' => $this->db->f('app_version'),
|
||||||
|
// 'tables' => $this->db->f('app_tables')
|
||||||
|
// );
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// while($this->db->next_record())
|
||||||
|
// {
|
||||||
|
// $app[] = Array(
|
||||||
|
// 'id' => $this->db->f('app_id'),
|
||||||
|
// 'name' => $this->db->f('app_name'),
|
||||||
|
// 'title' => $this->db->f('app_title'),
|
||||||
|
// 'version' => $this->db->f('app_version'),
|
||||||
|
// 'tables' => $this->db->f('app_tables')
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// return $app;
|
||||||
|
// }
|
||||||
|
|
||||||
|
function get_appbyid($app_id)
|
||||||
|
{
|
||||||
|
$this->db->query('SELECT * FROM phpgw_applications WHERE app_id='.$app_id,__LINE__,__FILE__);
|
||||||
|
return $this->get_result();
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_appbyname($app_name)
|
||||||
|
{
|
||||||
|
$this->db->query("SELECT * FROM phpgw_applications WHERE app_name='".$app_name."'",__LINE__,__FILE__);
|
||||||
|
return $this->get_result();
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_allapps()
|
||||||
|
{
|
||||||
|
$this->db->query('SELECT * FROM phpgw_applications',__LINE__,__FILE__);
|
||||||
|
return $this->get_result();
|
||||||
|
}
|
||||||
|
|
||||||
|
function find_new_app($apps)
|
||||||
|
{
|
||||||
|
$this->db->query('SELECT * FROM phpgw_applications',__LINE__,__FILE__);
|
||||||
|
while($this->db->next_record())
|
||||||
|
{
|
||||||
|
$app[$this->db->f('app_id')] = Array(
|
||||||
|
'id' => $this->db->f('app_id'),
|
||||||
|
'name' => $this->db->f('app_name'),
|
||||||
|
'title' => $this->db->f('app_title'),
|
||||||
|
'version' => $this->db->f('app_version'),
|
||||||
|
'tables' => $this->db->f('app_tables')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@reset($apps);
|
||||||
|
while($apps && list($id,$application) = each($apps))
|
||||||
|
{
|
||||||
|
if($app[$id])
|
||||||
|
{
|
||||||
|
if($app[$id]->version == $application->version)
|
||||||
|
{
|
||||||
|
unset($app[$id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@reset($app);
|
||||||
|
while($app && list($id,$application) = each($app))
|
||||||
|
{
|
||||||
|
$updated_app[$id] = CreateObject('phpgwapi.xmlrpcval',
|
||||||
|
Array(
|
||||||
|
'id' => CreateObject('phpgwapi.xmlrpcval',$id,'int'),
|
||||||
|
'name' => CreateObject('phpgwapi.xmlrpcval',$application->name,'string'),
|
||||||
|
'title' => CreateObject('phpgwapi.xmlrpcval',$application->title,'string'),
|
||||||
|
'version' => CreateObject('phpgwapi.xmlrpcval',$application->version,'string'),
|
||||||
|
'tables' => CreateObject('phpgwapi.xmlrpcval',$application->tables,'string')
|
||||||
|
),
|
||||||
|
'struct'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval',$updated_app, 'struct'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -35,7 +35,10 @@
|
|||||||
{
|
{
|
||||||
$data = $service[2];
|
$data = $service[2];
|
||||||
$function = $service[1];
|
$function = $service[1];
|
||||||
$service = $service[0];
|
$temp_service = $service[0];
|
||||||
|
settype($service,'string');
|
||||||
|
$service = $temp_service;
|
||||||
|
unset($temp_service);
|
||||||
}
|
}
|
||||||
switch ($service)
|
switch ($service)
|
||||||
{
|
{
|
||||||
@ -45,6 +48,9 @@
|
|||||||
case 'todo':
|
case 'todo':
|
||||||
$this = CreateObject('phpgwapi.service_' . $service);
|
$this = CreateObject('phpgwapi.service_' . $service);
|
||||||
break;
|
break;
|
||||||
|
case 'app_registry':
|
||||||
|
$this = CreateObject('phpgwapi.'.$service);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$this = CreateObject($service);
|
$this = CreateObject($service);
|
||||||
break;
|
break;
|
||||||
|
@ -25,7 +25,8 @@
|
|||||||
var $payload;
|
var $payload;
|
||||||
var $methodname;
|
var $methodname;
|
||||||
var $params = array();
|
var $params = array();
|
||||||
var $debug = 0;
|
// var $debug = True;
|
||||||
|
var $debug = False;
|
||||||
|
|
||||||
function xmlrpcmsg($meth, $pars=0)
|
function xmlrpcmsg($meth, $pars=0)
|
||||||
{
|
{
|
||||||
@ -198,6 +199,7 @@
|
|||||||
xml_error_string(xml_get_error_code($parser)),
|
xml_error_string(xml_get_error_code($parser)),
|
||||||
xml_get_current_line_number($parser));
|
xml_get_current_line_number($parser));
|
||||||
}
|
}
|
||||||
|
// echo $errstr;
|
||||||
error_log($errstr);
|
error_log($errstr);
|
||||||
$r = CreateObject('phpgwapi.xmlrpcresp', '', $GLOBALS['xmlrpcerr']['invalid_return'],$GLOBALS['xmlrpcstr']['invalid_return']);
|
$r = CreateObject('phpgwapi.xmlrpcresp', '', $GLOBALS['xmlrpcerr']['invalid_return'],$GLOBALS['xmlrpcstr']['invalid_return']);
|
||||||
xml_parser_free($parser);
|
xml_parser_free($parser);
|
||||||
|
@ -685,6 +685,30 @@
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$GLOBALS['_xmlrpcs_get_appbyname_sig'] = array(array(xmlrpcStruct,xmlrpcString));
|
||||||
|
$GLOBALS['_xmlrpcs_get_appbyname_doc'] = 'Returns an array of information for the requested application name';
|
||||||
|
function _xmlrpcs_get_appbyname($server,$m)
|
||||||
|
{
|
||||||
|
$app = $m->getParam(0);
|
||||||
|
return ExecMethod('phpgwapi.app_registry.get_appbyname',$app->scalarval());
|
||||||
|
}
|
||||||
|
|
||||||
|
$GLOBALS['_xmlrpcs_get_appbyid_sig'] = array(array(xmlrpcStruct,xmlrpcString));
|
||||||
|
$GLOBALS['_xmlrpcs_get_appbyid_doc'] = 'Returns an array of information for the requested application ID';
|
||||||
|
function _xmlrpcs_get_appbyid($server,$m)
|
||||||
|
{
|
||||||
|
$app = $m->getParam(0);
|
||||||
|
return ExecMethod('phpgwapi.app_registry.get_appbyid',$app->scalarval());
|
||||||
|
}
|
||||||
|
|
||||||
|
$GLOBALS['_xmlrpcs_find_new_app_sig'] = array(array(xmlrpcStruct,xmlrpcStruct));
|
||||||
|
$GLOBALS['_xmlrpcs_find_new_app_doc'] = 'Returns an array of information for the requested application ID';
|
||||||
|
function _xmlrpcs_find_new_app($server,$m)
|
||||||
|
{
|
||||||
|
$app = $m->getParam(0);
|
||||||
|
return ExecMethod('phpgwapi.app_registry.find_new_app',$app->scalarval());
|
||||||
|
}
|
||||||
|
|
||||||
$GLOBALS['_xmlrpcs_login_sig'] = array(array(xmlrpcStruct,xmlrpcStruct));
|
$GLOBALS['_xmlrpcs_login_sig'] = array(array(xmlrpcStruct,xmlrpcStruct));
|
||||||
$GLOBALS['_xmlrpcs_login_doc'] = 'phpGroupWare client or server login via XML-RPC';
|
$GLOBALS['_xmlrpcs_login_doc'] = 'phpGroupWare client or server login via XML-RPC';
|
||||||
function _xmlrpcs_login($server,$m)
|
function _xmlrpcs_login($server,$m)
|
||||||
@ -782,6 +806,21 @@
|
|||||||
'docstring' => $GLOBALS['_xmlrpcs_listApps_doc']
|
'docstring' => $GLOBALS['_xmlrpcs_listApps_doc']
|
||||||
),
|
),
|
||||||
*/
|
*/
|
||||||
|
'system.get_appbyname' => array(
|
||||||
|
'function' => '_xmlrpcs_get_appbyname',
|
||||||
|
'signature' => $GLOBALS['_xmlrpcs_get_appbyname_sig'],
|
||||||
|
'docstring' => $GLOBALS['_xmlrpcs_get_appbyname_doc']
|
||||||
|
),
|
||||||
|
'system.get_appbyid' => array(
|
||||||
|
'function' => '_xmlrpcs_get_appbyid',
|
||||||
|
'signature' => $GLOBALS['_xmlrpcs_get_appbyid_sig'],
|
||||||
|
'docstring' => $GLOBALS['_xmlrpcs_get_appbyid_doc']
|
||||||
|
),
|
||||||
|
'system.find_new_app' => array(
|
||||||
|
'function' => '_xmlrpcs_find_new_app',
|
||||||
|
'signature' => $GLOBALS['_xmlrpcs_find_new_app_sig'],
|
||||||
|
'docstring' => $GLOBALS['_xmlrpcs_find_new_app_doc']
|
||||||
|
),
|
||||||
'system.login' => array(
|
'system.login' => array(
|
||||||
'function' => '_xmlrpcs_login',
|
'function' => '_xmlrpcs_login',
|
||||||
'signature' => $GLOBALS['_xmlrpcs_login_sig'],
|
'signature' => $GLOBALS['_xmlrpcs_login_sig'],
|
||||||
|
Loading…
Reference in New Issue
Block a user