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