mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 04:29:21 +03:00
Contacts suggestions example plugin
This commit is contained in:
parent
86d763420d
commit
436e54891e
9 changed files with 106 additions and 16 deletions
|
|
@ -305,11 +305,9 @@ class Actions
|
|||
$mResult = array();
|
||||
}
|
||||
|
||||
// \RainLoop\Providers\Suggestions\ISuggestions
|
||||
// $mResult[] = new \RainLoop\Providers\Suggestions\TestSuggestions();
|
||||
|
||||
if (\is_array($mResult) && \RainLoop\Utils::IsOwnCloud())
|
||||
{
|
||||
// \RainLoop\Providers\Suggestions\ISuggestions
|
||||
$mResult[] = new \RainLoop\Providers\Suggestions\OwnCloudSuggestions();
|
||||
}
|
||||
|
||||
|
|
@ -7011,8 +7009,10 @@ class Actions
|
|||
$aResult = \array_merge($aResult, $aSuggestionsProviderResult);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$aResult = \RainLoop\Utils::RemoveSuggestionsdDuplicates($aResult);
|
||||
if ($iLimit < \count($aResult))
|
||||
{
|
||||
$aResult = \array_slice($aResult, 0, $iLimit);
|
||||
|
|
@ -7020,6 +7020,7 @@ class Actions
|
|||
|
||||
$this->Plugins()->RunHook('ajax.suggestions-post', array(&$aResult, $sQuery, $oAccount, $iLimit));
|
||||
|
||||
$aResult = \RainLoop\Utils::RemoveSuggestionsdDuplicates($aResult);
|
||||
if ($iLimit < \count($aResult))
|
||||
{
|
||||
$aResult = \array_slice($aResult, 0, $iLimit);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class Suggestions extends \RainLoop\Providers\AbstractProvider
|
|||
*/
|
||||
public function Process($oAccount, $sQuery, $iLimit = 20)
|
||||
{
|
||||
$aResult = array();
|
||||
|
||||
$aSuggestions = array();
|
||||
if ($oAccount instanceof \RainLoop\Model\Account &&
|
||||
$this->IsActive() && \is_array($this->aDrivers) && 0 < \strlen($sQuery))
|
||||
|
|
@ -54,16 +54,7 @@ class Suggestions extends \RainLoop\Providers\AbstractProvider
|
|||
}
|
||||
}
|
||||
|
||||
$aCache = array();
|
||||
foreach ($aSuggestions as $aItem) // remove duplicates
|
||||
{
|
||||
$sLine = \implode('~~', $aItem);
|
||||
if (!isset($aCache[$sLine]))
|
||||
{
|
||||
$aCache[$sLine] = true;
|
||||
$aResult[] = $aItem;
|
||||
}
|
||||
}
|
||||
$aResult = \RainLoop\Utils::RemoveSuggestionsdDuplicates($aSuggestions);
|
||||
|
||||
if ($iLimit < \count($aResult))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -608,6 +608,32 @@ class Utils
|
|||
return self::WebVersionPath().'static/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $aSuggestions
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function RemoveSuggestionsdDuplicates($aSuggestions)
|
||||
{
|
||||
$aResult = array();
|
||||
|
||||
if (is_array($aSuggestions))
|
||||
{
|
||||
$aCache = array();
|
||||
foreach ($aSuggestions as $aItem)
|
||||
{
|
||||
$sLine = \implode('~~', $aItem);
|
||||
if (!isset($aCache[$sLine]))
|
||||
{
|
||||
$aCache[$sLine] = true;
|
||||
$aResult[] = $aItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sFileName
|
||||
* @param bool $bProcessSections = false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue