mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-09-20 07:35:55 +08:00
Extensions use \MailSo\Log\Inherit
This commit is contained in:
parent
c4acb26758
commit
a424c6a52a
|
@ -4,6 +4,8 @@ namespace Plugins\Example;
|
|||
|
||||
class ContactSuggestions implements \RainLoop\Providers\Suggestions\ISuggestions
|
||||
{
|
||||
// use \MailSo\Log\Inherit;
|
||||
|
||||
public function Process(\RainLoop\Model\Account $oAccount, string $sQuery, int $iLimit = 20) : array
|
||||
{
|
||||
return array(
|
||||
|
|
|
@ -11,6 +11,8 @@ use MailSo\Mime\Message as MimeMessage;
|
|||
|
||||
class ExamplePlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||
{
|
||||
// use \MailSo\Log\Inherit;
|
||||
|
||||
const
|
||||
NAME = 'Example',
|
||||
AUTHOR = 'SnappyMail',
|
||||
|
@ -453,7 +455,6 @@ class ExamplePlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
$this->Manager()->ReadLang(string $sLang, array &$aLang) : self
|
||||
$this->Manager()->IsEnabled() : bool
|
||||
$this->Manager()->Count() : int
|
||||
$this->Manager()->SetLogger(\MailSo\Log\Logger $oLogger) : self
|
||||
$this->Manager()->WriteLog(string $sDesc, int $iType = \LOG_INFO) : void
|
||||
$this->Manager()->WriteException(string $sDesc, int $iType = \LOG_INFO) : void
|
||||
*/
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
getEmailAddressDomain<?php
|
||||
<?php
|
||||
|
||||
class LdapContactsSuggestions implements \RainLoop\Providers\Suggestions\ISuggestions
|
||||
{
|
||||
use \MailSo\Log\Inherit;
|
||||
|
||||
private string $sLdapUri = 'ldap://localhost:389';
|
||||
|
||||
private bool $bUseStartTLS = true;
|
||||
|
@ -20,11 +22,6 @@ class LdapContactsSuggestions implements \RainLoop\Providers\Suggestions\ISugges
|
|||
|
||||
private string $sEmailAttributes = 'mailAddress,mail,mailAlternateAddress,mailAlias';
|
||||
|
||||
/**
|
||||
* @var \MailSo\Log\Logger
|
||||
*/
|
||||
private $oLogger = null;
|
||||
|
||||
private string $sAllowedEmails = '*';
|
||||
|
||||
/**
|
||||
|
@ -75,7 +72,7 @@ class LdapContactsSuggestions implements \RainLoop\Providers\Suggestions\ISugges
|
|||
$aResult = array();
|
||||
$oCon = @\ldap_connect($this->sLdapUri);
|
||||
if ($oCon) {
|
||||
$this->oLogger->Write('ldap_connect: connected', \LOG_INFO, 'LDAP');
|
||||
$this->logWrite('ldap_connect: connected', \LOG_INFO, 'LDAP');
|
||||
|
||||
@\ldap_set_option($oCon, LDAP_OPT_PROTOCOL_VERSION, 3);
|
||||
|
||||
|
@ -142,7 +139,7 @@ class LdapContactsSuggestions implements \RainLoop\Providers\Suggestions\ISugges
|
|||
$sFilter .= (1 < count($aItems) ? '(|' : '').$sSubFilter.(1 < count($aItems) ? ')' : '');
|
||||
$sFilter .= ')';
|
||||
|
||||
$this->oLogger->Write('ldap_search: start: '.$sBaseDn.' / '.$sFilter, \LOG_INFO, 'LDAP');
|
||||
$this->logWrite('ldap_search: start: '.$sBaseDn.' / '.$sFilter, \LOG_INFO, 'LDAP');
|
||||
$oS = @\ldap_search($oCon, $sBaseDn, $sFilter, $aItems, 0, 30, 30);
|
||||
if ($oS) {
|
||||
$aEntries = @\ldap_get_entries($oCon, $oS);
|
||||
|
@ -245,23 +242,7 @@ class LdapContactsSuggestions implements \RainLoop\Providers\Suggestions\ISugges
|
|||
if ($this->oLogger) {
|
||||
$sError = $oCon ? @\ldap_error($oCon) : '';
|
||||
$iErrno = $oCon ? @\ldap_errno($oCon) : 0;
|
||||
|
||||
$this->oLogger->Write($sCmd.' error: '.$sError.' ('.$iErrno.')',
|
||||
\LOG_WARNING, 'LDAP');
|
||||
$this->logWrite($sCmd.' error: '.$sError.' ('.$iErrno.')', \LOG_WARNING, 'LDAP');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \MailSo\Log\Logger $oLogger
|
||||
*
|
||||
* @return \LdapContactsSuggestions
|
||||
*/
|
||||
public function SetLogger($oLogger)
|
||||
{
|
||||
if ($oLogger instanceof \MailSo\Log\Logger) {
|
||||
$this->oLogger = $oLogger;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,7 @@
|
|||
|
||||
class NextcloudContactsSuggestions implements \RainLoop\Providers\Suggestions\ISuggestions
|
||||
{
|
||||
/**
|
||||
* @var \MailSo\Log\Logger
|
||||
*/
|
||||
private $oLogger = null;
|
||||
use \MailSo\Log\Inherit;
|
||||
|
||||
private bool $ignoreSystemAddressbook;
|
||||
|
||||
|
@ -75,16 +72,9 @@ class NextcloudContactsSuggestions implements \RainLoop\Providers\Suggestions\IS
|
|||
}
|
||||
catch (\Exception $oException)
|
||||
{
|
||||
if ($this->oLogger) {
|
||||
$this->oLogger->WriteException($oException);
|
||||
}
|
||||
$this->logException($oException);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function SetLogger(\MailSo\Log\Logger $oLogger)
|
||||
{
|
||||
$this->oLogger = $oLogger;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace RainLoop\Providers\Suggestions;
|
|||
|
||||
interface ISuggestions
|
||||
{
|
||||
// use \MailSo\Log\Inherit;
|
||||
public function Process(\RainLoop\Model\Account $oAccount, string $sQuery, int $iLimit = 20) : array;
|
||||
// public function SetLogger(\MailSo\Log\Logger $oLogger) : void
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue