"fix for fmails live search to include accounts, if they are stored in a different repository"

This commit is contained in:
Ralf Becker 2007-11-11 06:45:07 +00:00
parent df4b5575fd
commit fbb7d5c052

View File

@ -24,7 +24,6 @@
if (!is_object($GLOBALS['egw']->contacts)) {
$GLOBALS['egw']->contacts =& CreateObject('phpgwapi.contacts');
}
if (method_exists($GLOBALS['egw']->contacts,'search')) {
// 1.3+
$contacts = $GLOBALS['egw']->contacts->search(array(
@ -32,6 +31,28 @@
'email' => $_searchString,
'email_home' => $_searchString,
),array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,20));
// additionally search the accounts, if the contact storage is not the account storage
if ($GLOBALS['egw_info']['server']['account_repository'] == 'ldap' &&
$GLOBALS['egw_info']['server']['contact_repository'] == 'sql')
{
$accounts = $GLOBALS['egw']->contacts->search(array(
'n_fn' => $_searchString,
'email' => $_searchString,
'email_home' => $_searchString,
),array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,20),array('owner' => 0));
if ($contacts && $accounts)
{
$contacts = array_merge($contacts,$accounts);
usort($contacts,create_function('$a,$b','return strcasecmp($a["n_fn"],$b["n_fn"]);'));
}
elseif($accounts)
{
$contacts =& $accounts;
}
unset($accounts);
}
} else {
// < 1.3
$contacts = $GLOBALS['egw']->contacts->read(0,20,array(