mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-11 08:24:50 +03:00
Make #879 optional
This commit is contained in:
parent
dc6674af4a
commit
82a1f4d781
2 changed files with 19 additions and 4 deletions
|
|
@ -7,6 +7,13 @@ class NextcloudContactsSuggestions implements \RainLoop\Providers\Suggestions\IS
|
|||
*/
|
||||
private $oLogger = null;
|
||||
|
||||
private bool $ignoreSystemAddressbook;
|
||||
|
||||
function __construct(bool $ignoreSystemAddressbook = true)
|
||||
{
|
||||
$this->ignoreSystemAddressbook = $ignoreSystemAddressbook;
|
||||
}
|
||||
|
||||
public function Process(\RainLoop\Model\Account $oAccount, string $sQuery, int $iLimit = 20): array
|
||||
{
|
||||
try
|
||||
|
|
@ -22,11 +29,14 @@ class NextcloudContactsSuggestions implements \RainLoop\Providers\Suggestions\IS
|
|||
}
|
||||
|
||||
// Unregister system addressbook so as to return only contacts in user's addressbooks
|
||||
foreach($cm->getUserAddressBooks() as $addressBook) {
|
||||
if($addressBook->isSystemAddressBook()) {
|
||||
$cm->unregisterAddressBook($addressBook);
|
||||
if ($this->ignoreSystemAddressbook) {
|
||||
foreach($cm->getUserAddressBooks() as $addressBook) {
|
||||
if($addressBook->isSystemAddressBook()) {
|
||||
$cm->unregisterAddressBook($addressBook);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$aSearchResult = $cm->search($sQuery, array('FN', 'NICKNAME', 'TITLE', 'EMAIL'));
|
||||
|
||||
//$this->oLogger->WriteDump($aSearchResult);
|
||||
|
|
|
|||
|
|
@ -202,7 +202,9 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
$mResult = array();
|
||||
}
|
||||
include_once __DIR__ . '/NextcloudContactsSuggestions.php';
|
||||
$mResult[] = new NextcloudContactsSuggestions();
|
||||
$mResult[] = new NextcloudContactsSuggestions(
|
||||
$this->Config()->Get('plugin', 'ignoreSystemAddressbook', true)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -213,6 +215,9 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
\RainLoop\Plugins\Property::NewInstance('suggestions')->SetLabel('Suggestions')
|
||||
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL)
|
||||
->SetDefaultValue(true),
|
||||
\RainLoop\Plugins\Property::NewInstance('ignoreSystemAddressbook')->SetLabel('Ignore system addressbook')
|
||||
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL)
|
||||
->SetDefaultValue(true),
|
||||
\RainLoop\Plugins\Property::NewInstance('calendar')->SetLabel('Enable "Put ICS in calendar"')
|
||||
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL)
|
||||
->SetDefaultValue(false)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue