forked from extern/egroupware
allow limited search for contact to merge
This commit is contained in:
parent
46c8c6e318
commit
d02ca8ecb5
@ -4,6 +4,13 @@
|
||||
*
|
||||
* Usage: curl --user $username[:$passwd] -L https://domain.com/egroupware/addressbook/merge.php?path=/templates/addressbook/document.txt&ids=123
|
||||
*
|
||||
* Supported GET parameters:
|
||||
* - path: full VFS path of document to merge
|
||||
* - ids: one or more id(s): ids[]=123&ids[]=456
|
||||
* - search: search criteria or array with field specific criteria, eg. search[account_id]=123
|
||||
* - limit: max. number of search results to return, default 1
|
||||
* - order: default last modified first
|
||||
*
|
||||
* For Apache FCGI you need the following rewrite rule:
|
||||
*
|
||||
* RewriteEngine on
|
||||
@ -35,7 +42,43 @@ require_once($egw_dir.'/phpgwapi/inc/class.egw_digest_auth.inc.php');
|
||||
include($egw_dir.'/header.inc.php');
|
||||
|
||||
$merge = new addressbook_merge();
|
||||
if (($err = $merge->download($_REQUEST['path'], $_REQUEST['ids'])))
|
||||
|
||||
if (!isset($_REQUEST['ids']) && isset($_REQUEST['search']))
|
||||
{
|
||||
if (is_array($_REQUEST['search']))
|
||||
{
|
||||
$criteria = array();
|
||||
foreach($_REQUEST['search'] as $name => $value)
|
||||
{
|
||||
if (isset($merge->contacts->contact_fields[$name]))
|
||||
{
|
||||
$criteria[$name] = $value;
|
||||
}
|
||||
}
|
||||
$wildcard = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$criteria = $_REQUEST['search'];
|
||||
$wildcard = '*';
|
||||
}
|
||||
$order_by = 'contact_modified DESC';
|
||||
if (isset($_REQUEST['order']) && preg_match('/^[a-z0-9_, ]+$/', $_REQUEST['order']))
|
||||
{
|
||||
$order_by = $_REQUEST['order'];
|
||||
}
|
||||
$ids = array();
|
||||
foreach($merge->contacts->search($criteria, true, $order_by, '', $wildcard, true, 'AND',
|
||||
array(0, isset($_REQUEST['limit']) && $_REQUEST['limit'] > 1 ? (int)$_REQUEST['limit'] : 1)) as $row)
|
||||
{
|
||||
$ids[] = $row['id'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$ids = (array)$_REQUEST['ids'];
|
||||
}
|
||||
if (($err = $merge->download($_REQUEST['path'], $ids)))
|
||||
{
|
||||
header("HTTP/1.1 500 $err");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user