Extensions use \MailSo\Log\Inherit

This commit is contained in:
the-djmaze 2024-03-31 21:02:05 +02:00
parent c4acb26758
commit a424c6a52a
5 changed files with 13 additions and 38 deletions

View file

@ -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(

View file

@ -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
*/

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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
}