2001-07-08 15:54:40 +02:00
|
|
|
<?php
|
|
|
|
/**************************************************************************\
|
|
|
|
* phpGroupWare - addressbook *
|
|
|
|
* http://www.phpgroupware.org *
|
|
|
|
* Written by Miles Lott <milosch@phpgroupware.org> *
|
|
|
|
* -------------------------------------------- *
|
|
|
|
* This program is free software; you can redistribute it and/or modify it *
|
|
|
|
* under the terms of the GNU General Public License as published by the *
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your *
|
|
|
|
* option) any later version. *
|
|
|
|
\**************************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
class boaddressbook
|
|
|
|
{
|
|
|
|
var $public_functions = array(
|
|
|
|
'read_entries' => True,
|
|
|
|
'read_entry' => True,
|
|
|
|
'read_last_entry' => True,
|
|
|
|
'add_entry' => True,
|
|
|
|
'add_vcard' => True,
|
|
|
|
'add_email' => True,
|
2003-10-24 21:05:05 +02:00
|
|
|
'update_entry' => True,
|
|
|
|
'delete_entry' => True,
|
2001-07-08 15:54:40 +02:00
|
|
|
);
|
2001-08-09 02:19:28 +02:00
|
|
|
|
2003-08-28 16:16:30 +02:00
|
|
|
var $xml_functions = array();
|
|
|
|
var $xmlrpc_methods = array();
|
2001-08-04 16:12:32 +02:00
|
|
|
var $soap_functions = array(
|
|
|
|
'read_entries' => array(
|
2001-08-27 11:51:32 +02:00
|
|
|
'in' => array('int','int','struct','string','int'),
|
|
|
|
'out' => array('array')
|
2001-08-04 16:12:32 +02:00
|
|
|
),
|
|
|
|
'read_entry' => array(
|
2001-08-27 11:51:32 +02:00
|
|
|
'in' => array('int','struct'),
|
|
|
|
'out' => array('array')
|
2001-08-04 16:12:32 +02:00
|
|
|
),
|
|
|
|
'read_last_entry' => array(
|
2001-08-27 11:51:32 +02:00
|
|
|
'in' => array('struct'),
|
|
|
|
'out' => array('array')
|
2001-08-04 16:12:32 +02:00
|
|
|
),
|
|
|
|
'add_entry' => array(
|
2001-08-27 11:51:32 +02:00
|
|
|
'in' => array('int','struct'),
|
2001-08-04 16:12:32 +02:00
|
|
|
'out' => array()
|
|
|
|
),
|
|
|
|
'update_entry' => array(
|
2001-08-27 11:51:32 +02:00
|
|
|
'in' => array('int','struct'),
|
2001-08-04 16:12:32 +02:00
|
|
|
'out' => array()
|
|
|
|
)
|
|
|
|
);
|
2001-07-08 15:54:40 +02:00
|
|
|
|
|
|
|
var $debug = False;
|
|
|
|
|
|
|
|
var $so;
|
|
|
|
var $start;
|
2003-08-28 16:16:30 +02:00
|
|
|
var $limit;
|
2001-07-08 15:54:40 +02:00
|
|
|
var $query;
|
|
|
|
var $sort;
|
|
|
|
var $order;
|
|
|
|
var $filter;
|
|
|
|
var $cat_id;
|
2001-07-12 03:01:11 +02:00
|
|
|
var $total;
|
2003-10-24 21:05:05 +02:00
|
|
|
var $contact_cache = array();
|
2001-07-08 15:54:40 +02:00
|
|
|
|
|
|
|
var $use_session = False;
|
|
|
|
|
|
|
|
function boaddressbook($session=False)
|
|
|
|
{
|
|
|
|
$this->so = CreateObject('addressbook.soaddressbook');
|
2003-10-24 21:05:05 +02:00
|
|
|
$this->grants = &$this->so->grants;
|
2001-07-08 15:54:40 +02:00
|
|
|
|
|
|
|
if($session)
|
|
|
|
{
|
|
|
|
$this->read_sessiondata();
|
|
|
|
$this->use_session = True;
|
|
|
|
}
|
2003-10-24 21:05:05 +02:00
|
|
|
/* _debug_array($_POST); */
|
2003-08-28 16:16:30 +02:00
|
|
|
/* Might change this to '' at the end---> */
|
2003-10-24 21:05:05 +02:00
|
|
|
$_start = get_var('start',array('POST','GET'));
|
|
|
|
$_query = get_var('query',array('POST','GET'));
|
|
|
|
$_sort = get_var('sort',array('POST','GET'));
|
|
|
|
$_order = get_var('order',array('POST','GET'));
|
|
|
|
$_filter = get_var('filter',array('POST','GET'));
|
|
|
|
$_cat_id = get_var('cat_id',array('POST','GET'));
|
|
|
|
$_fcat_id = get_var('fcat_id',array('POST','GET'));
|
2003-08-28 16:16:30 +02:00
|
|
|
|
|
|
|
if(!empty($_start) || ($_start == '0') || ($_start == 0))
|
|
|
|
{
|
|
|
|
if($this->debug) { echo '<br>overriding $start: "' . $this->start . '" now "' . $_start . '"'; }
|
|
|
|
$this->start = $_start;
|
|
|
|
}
|
|
|
|
if($_limit)
|
|
|
|
{
|
|
|
|
$this->limit = $_limit;
|
|
|
|
}
|
|
|
|
if((empty($_query) && !empty($this->query)) || !empty($_query))
|
|
|
|
{
|
|
|
|
$this->query = $_query;
|
|
|
|
}
|
|
|
|
|
2003-10-24 21:05:05 +02:00
|
|
|
if(isset($_POST['fcat_id']) || isset($_POST['fcat_id']))
|
2003-08-28 16:16:30 +02:00
|
|
|
{
|
|
|
|
$this->cat_id = $_fcat_id;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->cat_id = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(isset($_sort) && !empty($_sort))
|
|
|
|
{
|
|
|
|
if($this->debug) { echo '<br>overriding $sort: "' . $this->sort . '" now "' . $_sort . '"'; }
|
|
|
|
$this->sort = $_sort;
|
|
|
|
}
|
2001-12-23 18:28:14 +01:00
|
|
|
|
2003-08-28 16:16:30 +02:00
|
|
|
if(isset($_order) && !empty($_order))
|
2002-01-17 04:52:56 +01:00
|
|
|
{
|
2003-08-28 16:16:30 +02:00
|
|
|
if($this->debug) { echo '<br>overriding $order: "' . $this->order . '" now "' . $_order . '"'; }
|
|
|
|
$this->order = $_order;
|
2002-01-17 04:52:56 +01:00
|
|
|
}
|
2003-08-28 16:16:30 +02:00
|
|
|
|
|
|
|
if(isset($_filter) && !empty($_filter))
|
|
|
|
{
|
|
|
|
if($this->debug) { echo '<br>overriding $filter: "' . $this->filter . '" now "' . $_filter . '"'; }
|
|
|
|
$this->filter = $_filter;
|
|
|
|
}
|
|
|
|
|
|
|
|
if($this->debug) { $this->_debug_sqsof(); }
|
|
|
|
|
|
|
|
$this->xmlrpc_methods[] = array(
|
|
|
|
'name' => 'read_entries',
|
|
|
|
'description' => 'Get list of addressbook items'
|
|
|
|
);
|
2001-12-23 18:28:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function _debug_sqsof()
|
|
|
|
{
|
|
|
|
$data = array(
|
|
|
|
'start' => $this->start,
|
2003-08-28 16:16:30 +02:00
|
|
|
'limit' => $this->limit,
|
2001-12-23 18:28:14 +01:00
|
|
|
'query' => $this->query,
|
|
|
|
'sort' => $this->sort,
|
|
|
|
'order' => $this->order,
|
|
|
|
'filter' => $this->filter,
|
2003-08-28 16:16:30 +02:00
|
|
|
'cat_id' => $this->cat_id
|
2001-12-23 18:28:14 +01:00
|
|
|
);
|
|
|
|
echo '<br>BO:';
|
|
|
|
_debug_array($data);
|
2001-08-20 18:30:02 +02:00
|
|
|
}
|
2001-08-09 02:19:28 +02:00
|
|
|
|
2001-08-20 18:30:02 +02:00
|
|
|
function list_methods($_type='xmlrpc')
|
|
|
|
{
|
2001-08-27 11:51:32 +02:00
|
|
|
/*
|
|
|
|
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.
|
|
|
|
*/
|
2003-08-28 16:16:30 +02:00
|
|
|
if (is_array($_type))
|
2001-08-27 11:51:32 +02:00
|
|
|
{
|
|
|
|
$_type = $_type['type'] ? $_type['type'] : $_type[0];
|
|
|
|
}
|
2001-08-20 18:30:02 +02:00
|
|
|
switch($_type)
|
|
|
|
{
|
|
|
|
case 'xmlrpc':
|
|
|
|
$xml_functions = array(
|
2001-10-22 23:18:57 +02:00
|
|
|
'read' => array(
|
2001-08-20 18:30:02 +02:00
|
|
|
'function' => 'read_entry',
|
|
|
|
'signature' => array(array(xmlrpcStruct,xmlrpcStruct)),
|
|
|
|
'docstring' => lang('Read a single entry by passing the id and fieldlist.')
|
|
|
|
),
|
2001-10-22 23:18:57 +02:00
|
|
|
'add' => array(
|
2001-08-20 18:30:02 +02:00
|
|
|
'function' => 'add_entry',
|
|
|
|
'signature' => array(array(xmlrpcStruct,xmlrpcStruct)),
|
|
|
|
'docstring' => lang('Add a single entry by passing the fields.')
|
|
|
|
),
|
2001-10-22 23:18:57 +02:00
|
|
|
'save' => array(
|
2001-08-20 18:30:02 +02:00
|
|
|
'function' => 'update_entry',
|
|
|
|
'signature' => array(array(xmlrpcStruct,xmlrpcStruct)),
|
|
|
|
'docstring' => lang('Update a single entry by passing the fields.')
|
|
|
|
),
|
2001-10-22 23:18:57 +02:00
|
|
|
'delete' => array(
|
2001-08-20 18:30:02 +02:00
|
|
|
'function' => 'delete_entry',
|
|
|
|
'signature' => array(array(xmlrpcInt,xmlrpcInt)),
|
|
|
|
'docstring' => lang('Delete a single entry by passing the id.')
|
|
|
|
),
|
2001-10-22 23:18:57 +02:00
|
|
|
'read_list' => array(
|
2001-08-20 18:30:02 +02:00
|
|
|
'function' => 'read_entries',
|
|
|
|
'signature' => array(array(xmlrpcStruct,xmlrpcStruct)),
|
|
|
|
'docstring' => lang('Read a list of entries.')
|
2001-08-27 11:51:32 +02:00
|
|
|
),
|
|
|
|
'list_methods' => array(
|
|
|
|
'function' => 'list_methods',
|
|
|
|
'signature' => array(array(xmlrpcStruct,xmlrpcString)),
|
|
|
|
'docstring' => lang('Read this list of methods.')
|
2001-08-20 18:30:02 +02:00
|
|
|
)
|
|
|
|
);
|
|
|
|
return $xml_functions;
|
|
|
|
break;
|
|
|
|
case 'soap':
|
|
|
|
return $this->soap_functions;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return array();
|
|
|
|
break;
|
|
|
|
}
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2001-07-12 06:09:12 +02:00
|
|
|
function save_sessiondata($data)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2003-08-28 16:16:30 +02:00
|
|
|
if ($this->use_session)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2003-08-28 16:16:30 +02:00
|
|
|
if($this->debug) { echo '<br>Save:'; _debug_array($data); }
|
2001-08-27 11:51:32 +02:00
|
|
|
$GLOBALS['phpgw']->session->appsession('session_data','addressbook',$data);
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function read_sessiondata()
|
|
|
|
{
|
2001-08-27 11:51:32 +02:00
|
|
|
$data = $GLOBALS['phpgw']->session->appsession('session_data','addressbook');
|
2003-08-28 16:16:30 +02:00
|
|
|
if($this->debug) { echo '<br>Read:'; _debug_array($data); }
|
2001-07-08 15:54:40 +02:00
|
|
|
|
|
|
|
$this->start = $data['start'];
|
2003-08-28 16:16:30 +02:00
|
|
|
$this->limit = $data['limit'];
|
2001-07-08 15:54:40 +02:00
|
|
|
$this->query = $data['query'];
|
|
|
|
$this->sort = $data['sort'];
|
|
|
|
$this->order = $data['order'];
|
|
|
|
$this->filter = $data['filter'];
|
|
|
|
$this->cat_id = $data['cat_id'];
|
2001-12-23 18:28:14 +01:00
|
|
|
if($this->debug) { echo '<br>read_sessiondata();'; $this->_debug_sqsof(); }
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function strip_html($dirty = '')
|
|
|
|
{
|
2003-08-28 16:16:30 +02:00
|
|
|
if ($dirty == '')
|
2001-08-04 16:12:32 +02:00
|
|
|
{
|
|
|
|
$dirty = array();
|
|
|
|
}
|
2001-07-08 15:54:40 +02:00
|
|
|
for($i=0;$i<count($dirty);$i++)
|
|
|
|
{
|
2003-08-28 16:16:30 +02:00
|
|
|
if(gettype($dirty[$i]) == 'array')
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2003-08-28 16:16:30 +02:00
|
|
|
while (list($name,$value) = @each($dirty[$i]))
|
2001-08-04 16:12:32 +02:00
|
|
|
{
|
2001-08-27 11:51:32 +02:00
|
|
|
$cleaned[$i][$name] = $GLOBALS['phpgw']->strip_html($dirty[$i][$name]);
|
2001-08-04 16:12:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-27 11:51:32 +02:00
|
|
|
$cleaned[$i] == $GLOBALS['phpgw']->strip_html($dirty[$i]);
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $cleaned;
|
|
|
|
}
|
|
|
|
|
2001-08-09 02:19:28 +02:00
|
|
|
function read_entries($data)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2001-08-23 08:57:37 +02:00
|
|
|
$entries = $this->so->read_entries($data);
|
2001-07-12 03:01:11 +02:00
|
|
|
$this->total = $this->so->contacts->total_records;
|
2003-08-28 16:16:30 +02:00
|
|
|
if($this->debug) { echo '<br>Total records="' . $this->total . '"'; }
|
|
|
|
return (is_array($entries) ? $this->strip_html($entries) : array());
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2001-08-09 02:19:28 +02:00
|
|
|
function read_entry($data)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2003-10-24 21:05:05 +02:00
|
|
|
if ($this->check_perms($data,PHPGW_ACL_DELETE))
|
|
|
|
{
|
|
|
|
$entry = $this->so->read_entry($data['id'],$data['fields']);
|
|
|
|
return $this->strip_html($entry);
|
|
|
|
}
|
|
|
|
return array(0 => array('No access' => 'No access'));
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function read_last_entry($fields)
|
|
|
|
{
|
2003-10-24 21:05:05 +02:00
|
|
|
if ($this->check_perms($fields,PHPGW_ACL_DELETE))
|
|
|
|
{
|
|
|
|
$entry = $this->so->read_last_entry($fields);
|
|
|
|
return $this->strip_html($entry);
|
|
|
|
}
|
|
|
|
return array(0 => array('No access' => 'No access'));
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function add_vcard()
|
|
|
|
{
|
2003-08-28 16:16:30 +02:00
|
|
|
global $uploadedfile;
|
2001-07-08 15:54:40 +02:00
|
|
|
|
|
|
|
if($uploadedfile == 'none' || $uploadedfile == '')
|
|
|
|
{
|
2001-08-27 11:51:32 +02:00
|
|
|
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uivcard.in&action=GetFile'));
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-27 11:51:32 +02:00
|
|
|
$uploaddir = $GLOBALS['phpgw_info']['server']['temp_dir'] . SEP;
|
2001-07-08 15:54:40 +02:00
|
|
|
|
|
|
|
srand((double)microtime()*1000000);
|
|
|
|
$random_number = rand(100000000,999999999);
|
|
|
|
$newfilename = md5("$uploadedfile, $uploadedfile_name, "
|
|
|
|
. time() . getenv("REMOTE_ADDR") . $random_number );
|
|
|
|
|
|
|
|
copy($uploadedfile, $uploaddir . $newfilename);
|
|
|
|
$ftp = fopen($uploaddir . $newfilename . '.info','w');
|
|
|
|
fputs($ftp,"$uploadedfile_type\n$uploadedfile_name\n");
|
|
|
|
fclose($ftp);
|
|
|
|
|
|
|
|
$filename = $uploaddir . $newfilename;
|
|
|
|
|
|
|
|
$vcard = CreateObject('phpgwapi.vcard');
|
|
|
|
$entry = $vcard->in_file($filename);
|
|
|
|
/* _debug_array($entry);exit; */
|
2001-08-27 11:51:32 +02:00
|
|
|
$entry['owner'] = $GLOBALS['phpgw_info']['user']['account_id'];
|
2001-08-04 16:12:32 +02:00
|
|
|
$entry['access'] = 'private';
|
|
|
|
$entry['tid'] = 'n';
|
|
|
|
/* _debug_array($entry);exit; */
|
|
|
|
$this->so->add_entry($entry);
|
2001-07-08 15:54:40 +02:00
|
|
|
$ab_id = $this->get_lastid();
|
|
|
|
|
|
|
|
/* Delete the temp file. */
|
|
|
|
unlink($filename);
|
|
|
|
unlink($filename . '.info');
|
2001-08-27 11:51:32 +02:00
|
|
|
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.view&ab_id=' . $ab_id));
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function add_email()
|
|
|
|
{
|
2003-08-28 16:16:30 +02:00
|
|
|
global $name,$referer;
|
2001-07-08 15:54:40 +02:00
|
|
|
|
|
|
|
$named = explode(' ', $name);
|
2003-08-28 16:16:30 +02:00
|
|
|
for ($i=count($named);$i>=0;$i--) { $names[$i] = $named[$i]; }
|
|
|
|
if ($names[2])
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
|
|
|
$fields['n_given'] = $names[0];
|
|
|
|
$fields['n_middle'] = $names[1];
|
|
|
|
$fields['n_family'] = $names[2];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$fields['n_given'] = $names[0];
|
|
|
|
$fields['n_family'] = $names[1];
|
|
|
|
}
|
|
|
|
$fields['email'] = $add_email;
|
|
|
|
$referer = urlencode($referer);
|
|
|
|
|
2001-08-27 11:51:32 +02:00
|
|
|
$this->so->add_entry($GLOBALS['phpgw_info']['user']['account_id'],$fields,'private','','n');
|
2001-07-08 15:54:40 +02:00
|
|
|
$ab_id = $this->get_lastid();
|
|
|
|
|
|
|
|
Header('Location: '
|
2001-08-27 11:51:32 +02:00
|
|
|
. $GLOBALS['phpgw']->link('/index.php',"menuaction=addressbook.uiaddressbook.view&ab_id=$ab_id&referer=$referer"));
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2001-08-04 16:12:32 +02:00
|
|
|
function add_entry($fields)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2003-10-24 21:05:05 +02:00
|
|
|
// setting some defaults, if not set eg. via xmlrpc
|
|
|
|
$fields['tid'] = trim($fields['tid']);
|
|
|
|
if(empty($fields['tid']))
|
|
|
|
{
|
|
|
|
$fields['tid'] = 'n';
|
|
|
|
}
|
|
|
|
if(!@$fields['owner'])
|
|
|
|
{
|
|
|
|
$fields['owner'] = $GLOBALS['phpgw_info']['user']['account_id'];
|
|
|
|
}
|
|
|
|
if(empty($fields['access']))
|
|
|
|
{
|
|
|
|
$fields['access'] = 'public';
|
|
|
|
}
|
2001-08-04 16:12:32 +02:00
|
|
|
return $this->so->add_entry($fields);
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function get_lastid()
|
|
|
|
{
|
|
|
|
return $this->so->get_lastid();
|
|
|
|
}
|
|
|
|
|
2001-08-04 16:12:32 +02:00
|
|
|
function update_entry($fields)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2003-10-24 21:05:05 +02:00
|
|
|
if ($this->check_perms($fields,PHPGW_ACL_EDIT))
|
|
|
|
{
|
|
|
|
return $this->so->update_entry($fields);
|
|
|
|
}
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
|
|
|
function delete_entry($addr)
|
|
|
|
{
|
2003-10-24 22:42:00 +02:00
|
|
|
if (!is_array($addr))
|
|
|
|
{
|
|
|
|
$id = intval($addr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (is_numeric($addr[0])) // xmlrpc liefert array($id)
|
|
|
|
{
|
|
|
|
$id = intval($addr[0]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$id = isset($addr['id']) ? $addr['id'] : $addr['ab_id'];
|
|
|
|
}
|
|
|
|
}
|
2003-10-24 21:05:05 +02:00
|
|
|
|
|
|
|
if ($this->check_perms($id,PHPGW_ACL_DELETE))
|
|
|
|
{
|
|
|
|
return $this->so->delete_entry($id);
|
|
|
|
}
|
|
|
|
return False;
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2001-07-12 06:09:12 +02:00
|
|
|
|
2003-10-24 21:05:05 +02:00
|
|
|
/*!
|
|
|
|
@function check_perms
|
|
|
|
@abstract checks if user has the necessary rights on the given address or address-id
|
|
|
|
@syntax check_perms($addr,$rights)
|
|
|
|
@param $addr mixed address-record with id and owner or addr-id
|
|
|
|
@param $rights integer PHPGW_ACL_{READ|EDIT|ADD|DELETE}
|
|
|
|
@return True if the user has the requested rights, else False
|
|
|
|
*/
|
|
|
|
function check_perms($addr,$rights)
|
2001-07-12 06:09:12 +02:00
|
|
|
{
|
2003-10-24 21:05:05 +02:00
|
|
|
$id = !is_array($addr) ? $addr : (isset($addr['id']) ? $addr['id'] : $addr['ab_id']);
|
|
|
|
|
|
|
|
if (!is_array($addr) || !isset($addr['owner']))
|
|
|
|
{
|
|
|
|
$a = $this->so->read_entry($id,array('owner'));
|
|
|
|
$owner = $a[0]['owner'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$owner = $addr['owner'];
|
|
|
|
}
|
|
|
|
//echo "<p>boaddressbook::check_perms(id='$id',rights=$rights): grant[owner='$owner']='".$this->grants[$owner]."' => ".(($this->grants[$owner] & 4) ? 'True':'False')."</p>\n";
|
2003-10-24 22:42:00 +02:00
|
|
|
return $owner && !!($this->grants[$owner] & $rights);
|
2001-07-12 06:09:12 +02:00
|
|
|
}
|
2001-07-13 11:03:31 +02:00
|
|
|
|
|
|
|
function save_preferences($prefs,$other,$qfields,$fcat_id)
|
|
|
|
{
|
2001-08-27 11:51:32 +02:00
|
|
|
$GLOBALS['phpgw']->preferences->read_repository();
|
2003-08-28 16:16:30 +02:00
|
|
|
if (is_array($prefs))
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
2001-08-04 16:12:32 +02:00
|
|
|
/* _debug_array($prefs);exit; */
|
2003-08-28 16:16:30 +02:00
|
|
|
while (list($pref,$x) = each($qfields))
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
|
|
|
/* echo '<br>checking: ' . $pref . '=' . $prefs[$pref]; */
|
2003-08-28 16:16:30 +02:00
|
|
|
if ($prefs[$pref] == 'on')
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
2001-08-27 11:51:32 +02:00
|
|
|
$GLOBALS['phpgw']->preferences->add('addressbook',$pref,'addressbook_on');
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-27 11:51:32 +02:00
|
|
|
$GLOBALS['phpgw']->preferences->delete('addressbook',$pref);
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(is_array($other))
|
|
|
|
{
|
2001-08-27 11:51:32 +02:00
|
|
|
$GLOBALS['phpgw']->preferences->delete('addressbook','mainscreen_showbirthdays');
|
2003-08-28 16:16:30 +02:00
|
|
|
if ($other['mainscreen_showbirthdays'])
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
2001-10-21 12:51:32 +02:00
|
|
|
$GLOBALS['phpgw']->preferences->add('addressbook','mainscreen_showbirthdays',True);
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
|
|
|
|
2001-08-27 11:51:32 +02:00
|
|
|
$GLOBALS['phpgw']->preferences->delete('addressbook','default_filter');
|
2003-08-28 16:16:30 +02:00
|
|
|
if ($other['default_filter'])
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
2003-07-01 22:24:00 +02:00
|
|
|
$GLOBALS['phpgw']->preferences->add('addressbook','default_filter',$other['default_filter']);
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
|
|
|
|
2001-08-27 11:51:32 +02:00
|
|
|
$GLOBALS['phpgw']->preferences->delete('addressbook','autosave_category');
|
2003-08-28 16:16:30 +02:00
|
|
|
if ($other['autosave_category'])
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
2001-08-27 11:51:32 +02:00
|
|
|
$GLOBALS['phpgw']->preferences->add('addressbook','autosave_category',True);
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-08-28 16:16:30 +02:00
|
|
|
$GLOBALS['phpgw']->preferences->delete('addressbook','default_category');
|
|
|
|
$GLOBALS['phpgw']->preferences->add('addressbook','default_category',$fcat_id);
|
2001-07-13 11:03:31 +02:00
|
|
|
|
2001-08-27 11:51:32 +02:00
|
|
|
$GLOBALS['phpgw']->preferences->save_repository(True);
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
?>
|