Exemplo n.º 1
0
 /**
  *
  * @param \RainLoop\Model\Account $oAccount        	
  * @param string $sQuery        	
  * @param int $iLimit
  *        	= 20
  *        	
  * @return array
  */
 public function Process($oAccount, $sQuery, $iLimit = 20)
 {
     $sQuery = \trim($sQuery);
     if ('' === $sQuery || !$oAccount) {
         return array();
     }
     $aResult = $this->ldapSearch($oAccount, $sQuery, $iLimit);
     $aResult = \RainLoop\Utils::RemoveSuggestionDuplicates($aResult);
     if ($iLimit < \count($aResult)) {
         $aResult = \array_slice($aResult, 0, $iLimit);
     }
     return $aResult;
 }
Exemplo n.º 2
0
 /**
  * @param \RainLoop\Model\Account $oAccount
  * @param string $sQuery
  * @param int $iLimit = 20
  *
  * @return array
  */
 public function Process($oAccount, $sQuery, $iLimit = 20)
 {
     $aSuggestions = array();
     if ($oAccount instanceof \RainLoop\Model\Account && $this->IsActive() && \is_array($this->aDrivers) && 0 < \strlen($sQuery)) {
         foreach ($this->aDrivers as $oDriver) {
             $aSubs = null;
             if ($oDriver) {
                 $aSubs = $oDriver->Process($oAccount, $sQuery, $iLimit);
                 if (\is_array($aSubs) && 0 < \count($aSubs)) {
                     $aSuggestions = \array_merge($aSuggestions, $aSubs);
                 }
             }
         }
     }
     $aResult = \RainLoop\Utils::RemoveSuggestionDuplicates($aSuggestions);
     if ($iLimit < \count($aResult)) {
         $aResult = \array_slice($aResult, 0, $iLimit);
     }
     return $aResult;
 }
Exemplo n.º 3
0
 /**
  * @return array
  */
 public function DoSuggestions()
 {
     $oAccount = $this->getAccountFromToken();
     $sQuery = \trim($this->GetActionParam('Query', ''));
     $iLimit = (int) $this->Config()->Get('contacts', 'suggestions_limit', 20);
     $aResult = array();
     $this->Plugins()->RunHook('ajax.suggestions-input-parameters', array(&$sQuery, &$iLimit, $oAccount));
     $iLimit = (int) $iLimit;
     if (5 > $iLimit) {
         $iLimit = 5;
     }
     $this->Plugins()->RunHook('ajax.suggestions-pre', array(&$aResult, $sQuery, $oAccount, $iLimit));
     if ($iLimit > \count($aResult) && 0 < \strlen($sQuery)) {
         try {
             // Address Book
             $oAddressBookProvider = $this->AddressBookProvider($oAccount);
             if ($oAddressBookProvider && $oAddressBookProvider->IsActive()) {
                 $aSuggestions = $oAddressBookProvider->GetSuggestions($oAccount->ParentEmailHelper(), $sQuery, $iLimit);
                 if (0 === \count($aResult)) {
                     $aResult = $aSuggestions;
                 } else {
                     $aResult = \array_merge($aResult, $aSuggestions);
                 }
             }
         } catch (\Exception $oException) {
             $this->Logger()->WriteException($oException);
         }
     }
     if ($iLimit > \count($aResult) && 0 < \strlen($sQuery)) {
         $oSuggestionsProvider = $this->SuggestionsProvider();
         if ($oSuggestionsProvider && $oSuggestionsProvider->IsActive()) {
             $aSuggestionsProviderResult = $oSuggestionsProvider->Process($oAccount, $sQuery, $iLimit);
             if (\is_array($aSuggestionsProviderResult) && 0 < \count($aSuggestionsProviderResult)) {
                 $aResult = \array_merge($aResult, $aSuggestionsProviderResult);
             }
         }
     }
     $aResult = \RainLoop\Utils::RemoveSuggestionDuplicates($aResult);
     if ($iLimit < \count($aResult)) {
         $aResult = \array_slice($aResult, 0, $iLimit);
     }
     $this->Plugins()->RunHook('ajax.suggestions-post', array(&$aResult, $sQuery, $oAccount, $iLimit));
     $aResult = \RainLoop\Utils::RemoveSuggestionDuplicates($aResult);
     if ($iLimit < \count($aResult)) {
         $aResult = \array_slice($aResult, 0, $iLimit);
     }
     return $this->DefaultResponse(__FUNCTION__, $aResult);
 }
 /**
  * @param \RainLoop\Model\Account $oAccount
  * @param string $sQuery
  * @param int $iLimit = 20
  *
  * @return array
  */
 public function Process($oAccount, $sQuery, $iLimit = 20)
 {
     $sQuery = \trim($sQuery);
     if (2 > \strlen($sQuery)) {
         return array();
     } else {
         if (!$oAccount || !\RainLoop\Plugins\Helper::ValidateWildcardValues($oAccount->Email(), $this->sAllowedEmails)) {
             return array();
         }
     }
     $aResult = $this->ldapSearch($oAccount, $sQuery);
     $aResult = \RainLoop\Utils::RemoveSuggestionDuplicates($aResult);
     if ($iLimit < \count($aResult)) {
         $aResult = \array_slice($aResult, 0, $iLimit);
     }
     return $aResult;
 }