Add in function io map function, listmethods() and rework so class to create

the contacts object in the constructor
This commit is contained in:
Miles Lott 2001-08-20 16:30:02 +00:00
parent eac74fee75
commit ca0ed1f136
2 changed files with 49 additions and 35 deletions

View File

@ -112,20 +112,49 @@
if(isset($order)) { $this->order = $order; }
if(isset($filter)) { $this->filter = $filter; }
if(isset($fcat_id)) { $this->cat_id = $fcat_id; }
}
/* Preliminary xml function exposure */
$this->xml_functions = array(
function list_methods($_type='xmlrpc')
{
switch($_type)
{
case 'xmlrpc':
$xml_functions = array(
'read_entry' => array(
'function' => 'read_entry',
'signature' => array(array($xmlrpcStruct)),
'signature' => array(array(xmlrpcStruct,xmlrpcStruct)),
'docstring' => lang('Read a single entry by passing the id and fieldlist.')
),
'add_entry' => array(
'function' => 'add_entry',
'signature' => array(array(xmlrpcStruct,xmlrpcStruct)),
'docstring' => lang('Add a single entry by passing the fields.')
),
'update_entry' => array(
'function' => 'update_entry',
'signature' => array(array(xmlrpcStruct,xmlrpcStruct)),
'docstring' => lang('Update a single entry by passing the fields.')
),
'delete_entry' => array(
'function' => 'delete_entry',
'signature' => array(array(xmlrpcInt,xmlrpcInt)),
'docstring' => lang('Delete a single entry by passing the id.')
),
'read_entries' => array(
'function' => 'read_entries',
'signature' => array(array($xmlrpcStruct)),
'signature' => array(array(xmlrpcStruct,xmlrpcStruct)),
'docstring' => lang('Read a list of entries.')
)
);
return $xml_functions;
break;
case 'soap':
return $this->soap_functions;
break;
default:
return array();
break;
}
}
function save_sessiondata($data)

View File

@ -46,27 +46,17 @@
$this->rights = $rights;
$this->grants = $grants;
$this->owner = $owner;
}
function makeobj()
{
if (!is_object($this->contacts))
{
$this->contacts = CreateObject('phpgwapi.contacts');
}
return;
}
function read_entries($start,$offset,$qcols,$query,$qfilter,$sort,$order)
{
$this->makeobj();
$readrights = $this->rights & PHPGW_ACL_READ;
return $this->contacts->read($start,$offset,$qcols,$query,$qfilter,$sort,$order,$readrights);
}
function read_entry($id,$fields)
{
$this->makeobj();
if ($this->rights & PHPGW_ACL_READ)
{
return $this->contacts->read_single_entry($id,$fields);
@ -80,21 +70,19 @@
function read_last_entry($fields)
{
$this->makeobj();
if ($this->rights & PHPGW_ACL_READ)
{
return $this->contacts->read_last_entry($fields);
}
else
{
$rtrn = array('No access' => 'No access');
$rtrn = array(0 => array('No access' => 'No access'));
return $rtrn;
}
}
function add_entry($fields)
{
$this->makeobj();
$fields['tid'] = trim($fields['tid']);
if(empty($fields['tid']))
{
@ -109,15 +97,13 @@
function get_lastid()
{
$this->makeobj();
$entry = $this->contacts->read_last_entry();
$ab_id = $entry[0]['id'];
return $ab_id;
$id = $entry[0]['id'];
return $id;
}
function update_entry($fields)
{
$this->makeobj();
if ($this->rights & PHPGW_ACL_EDIT)
{
$this->contacts->update($fields['ab_id'],$fields['owner'],$fields,$fields['access'],$fields['cat_id']);
@ -127,7 +113,6 @@
function delete_entry($data)
{
$this->makeobj();
if ($this->rights & PHPGW_ACL_DELETE)
{
$this->contacts->delete($data['id']);