mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-06-27 00:36:44 +03:00
Bugfix: Nextcloud plugin wrong filename
This commit is contained in:
parent
99b84af7b5
commit
ee03abfd09
1 changed files with 0 additions and 0 deletions
74
plugins/nextcloud/NextcloudContactsSuggestions.php
Normal file
74
plugins/nextcloud/NextcloudContactsSuggestions.php
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
class NextcloudContactsSuggestions implements \RainLoop\Providers\Suggestions\ISuggestions
|
||||
{
|
||||
/**
|
||||
* @var \MailSo\Log\Logger
|
||||
*/
|
||||
private $oLogger = null;
|
||||
|
||||
public function Process(\RainLoop\Model\Account $oAccount, string $sQuery, int $iLimit = 20): array
|
||||
{
|
||||
try
|
||||
{
|
||||
$sQuery = \trim($sQuery);
|
||||
if ('' === $sQuery) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$cm = \OC::$server->getContactsManager();
|
||||
if (!$cm || !$cm->isEnabled()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$aSearchResult = $cm->search($sQuery, array('FN', 'NICKNAME', 'TITLE', 'EMAIL'));
|
||||
|
||||
//$this->oLogger->WriteDump($aSearchResult);
|
||||
|
||||
if (\is_array($aSearchResult) && 0 < \count($aSearchResult)) {
|
||||
$iInputLimit = $iLimit;
|
||||
$aResult = array();
|
||||
foreach ($aSearchResult as $aContact) {
|
||||
if (0 >= $iLimit) {
|
||||
break;
|
||||
}
|
||||
if (!empty($aContact['UID'])) {
|
||||
$sUid = $aContact['UID'];
|
||||
$mEmails = isset($aContact['EMAIL']) ? $aContact['EMAIL'] : '';
|
||||
|
||||
$sFullName = isset($aContact['FN']) ? \trim($aContact['FN']) : '';
|
||||
if (empty($sFullName) && isset($aContact['NICKNAME'])) {
|
||||
$sFullName = \trim($aContact['NICKNAME']);
|
||||
}
|
||||
|
||||
if (!\is_array($mEmails)) {
|
||||
$mEmails = array($mEmails);
|
||||
}
|
||||
|
||||
foreach ($mEmails as $sEmail) {
|
||||
$sHash = $sFullName.'|'.$sEmail;
|
||||
if (!isset($aResult[$sHash])) {
|
||||
$aResult[$sHash] = array($sEmail, $sFullName);
|
||||
--$iLimit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return \array_slice(\array_values($aResult), 0, $iInputLimit);
|
||||
}
|
||||
}
|
||||
catch (\Exception $oException)
|
||||
{
|
||||
if ($this->oLogger) {
|
||||
$this->oLogger->WriteException($oException);
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function SetLogger(\MailSo\Log\Logger $oLogger)
|
||||
{
|
||||
$this->oLogger = $oLogger;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue