mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-09 06:28:28 +03:00
Imporve ownClud Suggestion driver
This commit is contained in:
parent
99cdd1f43f
commit
dee86572e4
1 changed files with 27 additions and 5 deletions
|
|
@ -24,14 +24,31 @@ class OwnCloudSuggestions implements \RainLoop\Providers\Suggestions\ISuggestion
|
|||
|
||||
try
|
||||
{
|
||||
if ('' === $sQuery || !$oAccount || !\RainLoop\Utils::IsOwnCloudLoggedIn() ||
|
||||
!\class_exists('OCP\Contacts') || !\OCP\Contacts::isEnabled()
|
||||
)
|
||||
if ('' === $sQuery || !$oAccount || !\RainLoop\Utils::IsOwnCloudLoggedIn())
|
||||
{
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
$aParams = array('FN', 'NICKNAME', 'TITLE', 'EMAIL');
|
||||
if (\class_exists('OC') && isset(\OC::$server) && \method_exists(\OC::$server, 'getContactsManager'))
|
||||
{
|
||||
$cm = \OC::$server->getContactsManager();
|
||||
if (!$cm && !$cm->isEnabled())
|
||||
{
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
$aSearchResult = $cm->search($sQuery, $aParams);
|
||||
}
|
||||
else if (\class_exists('OCP\Contacts') && \OCP\Contacts::isEnabled())
|
||||
{
|
||||
$aSearchResult = \OCP\Contacts::search($sQuery, $aParams);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
$aSearchResult = \OCP\Contacts::search($sQuery, array('FN', 'EMAIL'));
|
||||
//$this->oLogger->WriteDump($aSearchResult);
|
||||
|
||||
$aHashes = array();
|
||||
|
|
@ -47,9 +64,14 @@ class OwnCloudSuggestions implements \RainLoop\Providers\Suggestions\ISuggestion
|
|||
$sUid = empty($aContact['UID']) ? '' : $aContact['UID'];
|
||||
if (!empty($sUid))
|
||||
{
|
||||
$sFullName = isset($aContact['FN']) ? \trim($aContact['FN']) : '';
|
||||
$mEmails = isset($aContact['EMAIL']) ? $aContact['EMAIL'] : '';
|
||||
|
||||
$sFullName = isset($aContact['FN']) ? \trim($aContact['FN']) : '';
|
||||
if (empty($sFullName))
|
||||
{
|
||||
$sFullName = isset($aContact['NICKNAME']) ? \trim($aContact['NICKNAME']) : '';
|
||||
}
|
||||
|
||||
if (!\is_array($mEmails))
|
||||
{
|
||||
$mEmails = array($mEmails);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue