Deprecate most Domain methods

This commit is contained in:
the-djmaze 2024-03-10 23:58:18 +01:00
parent ea4cda6a91
commit 1e55f86f51
12 changed files with 80 additions and 69 deletions

View file

@ -66,8 +66,8 @@ class ChangePasswordDriverLDAP
'{email:domain}' => $sDomain, '{email:domain}' => $sDomain,
'{login}' => $oAccount->IncLogin(), '{login}' => $oAccount->IncLogin(),
'{imap:login}' => $oAccount->IncLogin(), '{imap:login}' => $oAccount->IncLogin(),
'{imap:host}' => $oAccount->Domain()->IncHost(), '{imap:host}' => $oAccount->Domain()->ImapSettings()->host,
'{imap:port}' => $oAccount->Domain()->IncPort(), '{imap:port}' => $oAccount->Domain()->ImapSettings()->port,
'{gecos}' => \function_exists('posix_getpwnam') ? \posix_getpwnam($oAccount->IncLogin()) : '' '{gecos}' => \function_exists('posix_getpwnam') ? \posix_getpwnam($oAccount->IncLogin()) : ''
)); ));

View file

@ -6,8 +6,8 @@ class ChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
{ {
const const
NAME = 'Change Password', NAME = 'Change Password',
VERSION = '2.19', VERSION = '2.20',
RELEASE = '2023-04-11', RELEASE = '2024-03-10',
REQUIRED = '2.23.0', REQUIRED = '2.23.0',
CATEGORY = 'Security', CATEGORY = 'Security',
DESCRIPTION = 'Extension to allow users to change their passwords'; DESCRIPTION = 'Extension to allow users to change their passwords';

View file

@ -102,8 +102,8 @@ class LdapContactsSuggestions implements \RainLoop\Providers\Suggestions\ISugges
'{email:domain}' => $sDomain, '{email:domain}' => $sDomain,
'{login}' => $oAccount->IncLogin(), '{login}' => $oAccount->IncLogin(),
'{imap:login}' => $oAccount->IncLogin(), '{imap:login}' => $oAccount->IncLogin(),
'{imap:host}' => $oAccount->Domain()->IncHost(), '{imap:host}' => $oAccount->Domain()->ImapSettings()->host,
'{imap:port}' => $oAccount->Domain()->IncPort() '{imap:port}' => $oAccount->Domain()->ImapSettings()->port
)); ));
$aObjectClasses = empty($this->sObjectClasses) ? array() : \explode(',', $this->sObjectClasses); $aObjectClasses = empty($this->sObjectClasses) ? array() : \explode(',', $this->sObjectClasses);

View file

@ -4,8 +4,8 @@ class LdapContactsSuggestionsPlugin extends \RainLoop\Plugins\AbstractPlugin
{ {
const const
NAME = 'Contacts suggestions (LDAP)', NAME = 'Contacts suggestions (LDAP)',
VERSION = '2.13', VERSION = '2.14',
RELEASE = '2023-10-01', RELEASE = '2024-03-10',
REQUIRED = '2.23.0', REQUIRED = '2.23.0',
CATEGORY = 'Contacts', CATEGORY = 'Contacts',
DESCRIPTION = 'Get contacts suggestions from LDAP.'; DESCRIPTION = 'Get contacts suggestions from LDAP.';

View file

@ -70,7 +70,7 @@ class LdapMailAccounts
$username = $sEmail; $username = $sEmail;
$oActions = \RainLoop\Api::Actions(); $oActions = \RainLoop\Api::Actions();
$oDomain = $oActions->DomainProvider()->Load(\MailSo\Base\Utils::GetDomainFromEmail($sEmail), true); $oDomain = $oActions->DomainProvider()->Load(\MailSo\Base\Utils::GetDomainFromEmail($sEmail), true);
if ($oDomain->IncShortLogin()){ if ($oDomain->ImapSettings()->shortLogin){
$username = @ldap_escape($this->RemoveEventualDomainPart($sEmail), "", LDAP_ESCAPE_FILTER); $username = @ldap_escape($this->RemoveEventualDomainPart($sEmail), "", LDAP_ESCAPE_FILTER);
} }
@ -101,7 +101,7 @@ class LdapMailAccounts
if (count($mailAddressResults) < 1) { if (count($mailAddressResults) < 1) {
$this->logger->Write("Could not find user $username in LDAP! Overwriting of main mail address not possible.", \LOG_NOTICE, self::LOG_KEY); $this->logger->Write("Could not find user $username in LDAP! Overwriting of main mail address not possible.", \LOG_NOTICE, self::LOG_KEY);
return false; return false;
} }
foreach($mailAddressResults as $mailAddressResult) foreach($mailAddressResults as $mailAddressResult)
{ {

View file

@ -12,10 +12,10 @@ class LdapMailAccountsPlugin extends AbstractPlugin
{ {
const const
NAME = 'LDAP Mail Accounts', NAME = 'LDAP Mail Accounts',
VERSION = '2.0.0', VERSION = '2.1.0',
AUTHOR = 'cm-schl', AUTHOR = 'cm-schl',
URL = 'https://github.com/cm-sch', URL = 'https://github.com/cm-sch',
RELEASE = '2023-03-14', RELEASE = '2024-03-10',
REQUIRED = '2.25.4', REQUIRED = '2.25.4',
CATEGORY = 'Accounts', CATEGORY = 'Accounts',
DESCRIPTION = 'Add additional mail accounts the SnappyMail user has access to by a LDAP query. Basing on the work of FWest98 (https://github.com/FWest98).'; DESCRIPTION = 'Add additional mail accounts the SnappyMail user has access to by a LDAP query. Basing on the work of FWest98 (https://github.com/FWest98).';
@ -44,10 +44,10 @@ class LdapMailAccountsPlugin extends AbstractPlugin
*/ */
public function overwriteMainAccountEmail(&$sEmail, &$sLogin) public function overwriteMainAccountEmail(&$sEmail, &$sLogin)
{ {
$this->Manager()->Actions()->Logger()->Write("Login DATA: login: $sLogin email: $sEmail", \LOG_WARNING, "LDAP MAIL ACCOUNTS PLUGIN"); $this->Manager()->Actions()->Logger()->Write("Login DATA: login: $sLogin email: $sEmail", \LOG_WARNING, "LDAP MAIL ACCOUNTS PLUGIN");
// Set up config // Set up config
$config = LdapMailAccountsConfig::MakeConfig($this->Config()); $config = LdapMailAccountsConfig::MakeConfig($this->Config());
if ($config->bool_overwrite_mail_address_main_account) if ($config->bool_overwrite_mail_address_main_account)
{ {
@ -55,7 +55,7 @@ $this->Manager()->Actions()->Logger()->Write("Login DATA: login: $sLogin email:
$oldapMailAccounts->overwriteEmail($sEmail, $sLogin); $oldapMailAccounts->overwriteEmail($sEmail, $sLogin);
} }
$this->Manager()->Actions()->Logger()->Write("Login DATA: login: $sLogin email: $sEmail", \LOG_WARNING, "LDAP MAIL ACCOUNTS PLUGIN"); $this->Manager()->Actions()->Logger()->Write("Login DATA: login: $sLogin email: $sEmail", \LOG_WARNING, "LDAP MAIL ACCOUNTS PLUGIN");
} }
// Function gets called by RainLoop/Actions/User.php // Function gets called by RainLoop/Actions/User.php
@ -90,7 +90,7 @@ $this->Manager()->Actions()->Logger()->Write("Login DATA: login: $sLogin email:
\nThe value found inside ldap will overwrite the mail address of the SnappyMail main account (the account the user logged in at SnappyMail) \nThe value found inside ldap will overwrite the mail address of the SnappyMail main account (the account the user logged in at SnappyMail)
\nThe mail address used at login will still be used to login to the servers.") \nThe mail address used at login will still be used to login to the servers.")
->SetDefaultValue("mail"), ->SetDefaultValue("mail"),
]); ]);
return [ return [
\RainLoop\Plugins\Property::NewInstance(LdapMailAccountsConfig::CONFIG_SERVER) \RainLoop\Plugins\Property::NewInstance(LdapMailAccountsConfig::CONFIG_SERVER)
@ -172,7 +172,7 @@ $this->Manager()->Actions()->Logger()->Write("Login DATA: login: $sLogin email:
->SetDefaultValue("displayName"), ->SetDefaultValue("displayName"),
$groupOverwriteMainAccount $groupOverwriteMainAccount
]; ];
} }
} }

View file

@ -7,8 +7,8 @@ class SmtpUseFromAdrAccountPlugin extends \RainLoop\Plugins\AbstractPlugin
NAME = 'Use From-Address-Account for smtp', NAME = 'Use From-Address-Account for smtp',
AUTHOR = 'attike', AUTHOR = 'attike',
URL = 'https://github.com/attike', URL = 'https://github.com/attike',
VERSION = '1.0', VERSION = '1.1',
RELEASE = '2023-12-06', RELEASE = '2024-03-10',
REQUIRED = '2.23.0', REQUIRED = '2.23.0',
CATEGORY = 'Filters', CATEGORY = 'Filters',
DESCRIPTION = 'Set smpt-config and -credentials based on selected from-address-account'; DESCRIPTION = 'Set smpt-config and -credentials based on selected from-address-account';
@ -34,8 +34,8 @@ class SmtpUseFromAdrAccountPlugin extends \RainLoop\Plugins\AbstractPlugin
if (\strlen($sWhiteList) && \RainLoop\Plugins\Helper::ValidateWildcardValues($sFrom, $sWhiteList, $sFoundValue) && $sFrom != $oAccount->Email()) { if (\strlen($sWhiteList) && \RainLoop\Plugins\Helper::ValidateWildcardValues($sFrom, $sWhiteList, $sFoundValue) && $sFrom != $oAccount->Email()) {
\SnappyMail\LOG::info(get_class($this) ,'From address different from account recognized: '. $oAccount->Email().' -> '.$sFrom . '(~ '.$sFoundValue.')'); \SnappyMail\LOG::info(get_class($this) ,'From address different from account recognized: '. $oAccount->Email().' -> '.$sFrom . '(~ '.$sFoundValue.')');
$oMainAccount; $oMainAccount;
$oFromAccount; $oFromAccount;
if ( $oAccount instanceof \RainLoop\Model\MainAccount ) { if ($oAccount instanceof \RainLoop\Model\MainAccount ) {
$oMainAccount=$oAccount; $oMainAccount=$oAccount;
} else { } else {
$oMainAccount=$this->Manager()->Actions()->getMainAccountFromToken(); $oMainAccount=$this->Manager()->Actions()->getMainAccountFromToken();
@ -44,21 +44,21 @@ class SmtpUseFromAdrAccountPlugin extends \RainLoop\Plugins\AbstractPlugin
return; return;
} }
} }
$aAccounts=$this->Manager()->Actions()->getAccounts($oMainAccount); $aAccounts = $this->Manager()->Actions()->getAccounts($oMainAccount);
foreach ($aAccounts as &$value) { foreach ($aAccounts as &$value) {
$oValue=\RainLoop\Model\AdditionalAccount::NewInstanceFromTokenArray($this->Manager()->Actions(), $value); $oValue=\RainLoop\Model\AdditionalAccount::NewInstanceFromTokenArray($this->Manager()->Actions(), $value);
if ($oValue->Email()==$sFrom) { if ($oValue->Email()==$sFrom) {
$oFromAccount = $oValue; $oFromAccount = $oValue;
break; break;
} }
} }
if (is_null($oFromAccount)){ if (is_null($oFromAccount)){
\SnappyMail\LOG::info(get_class($this),'No Account found for '. $sFrom); \SnappyMail\LOG::info(get_class($this),'No Account found for '. $sFrom);
if ($this->Config()->Get('plugin', 'throw_notfound_exception', true)) { if ($this->Config()->Get('plugin', 'throw_notfound_exception', true)) {
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AccountDoesNotExist); throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AccountDoesNotExist);
} }
return; return;
} }
$this->aFromAccount[$oAccount->Email()]=$oFromAccount; $this->aFromAccount[$oAccount->Email()]=$oFromAccount;
} }
} }
@ -71,10 +71,10 @@ class SmtpUseFromAdrAccountPlugin extends \RainLoop\Plugins\AbstractPlugin
{ {
if ( isset($this->aFromAccount[$oAccount->Email()]) ) { if ( isset($this->aFromAccount[$oAccount->Email()]) ) {
$oFromAccount = $this->aFromAccount[$oAccount->Email()]; $oFromAccount = $this->aFromAccount[$oAccount->Email()];
$oSettings->host = $oFromAccount->Domain()->OutHost(); $oSettings->host = $oFromAccount->Domain()->SmtpSettings()->host;
$oSettings->port = (int) $oFromAccount->Domain()->OutPort(); $oSettings->port = (int) $oFromAccount->Domain()->SmtpSettings()->port;
$oSettings->type = $oFromAccount->Domain()-> SmtpSettings()->type; $oSettings->type = $oFromAccount->Domain()->SmtpSettings()->type;
\SnappyMail\LOG::info(get_class($this),'Smtp config rewrite: '. $oFromAccount->Domain()->OutHost()); \SnappyMail\LOG::info(get_class($this),'Smtp config rewrite: '. $oSettings->host);
} }
} }
@ -88,9 +88,9 @@ class SmtpUseFromAdrAccountPlugin extends \RainLoop\Plugins\AbstractPlugin
if ( isset($this->aFromAccount[$oAccount->Email()]) ) { if ( isset($this->aFromAccount[$oAccount->Email()]) ) {
$oFromAccount = $this->aFromAccount[$oAccount->Email()]; $oFromAccount = $this->aFromAccount[$oAccount->Email()];
unset($this->aFromAccount[$oAccount->Email()]); unset($this->aFromAccount[$oAccount->Email()]);
$oSettings->Login = $oFromAccount-> OutLogin(); $oSettings->Login = $oFromAccount->OutLogin();
$oSettings->useAuth = $oFromAccount->Domain()-> SmtpSettings()->useAuth; $oSettings->useAuth = $oFromAccount->Domain()->SmtpSettings()->useAuth;
$oSettings->Password = $oFromAccount->IncPassword(); $oSettings->Password = $oFromAccount->IncPassword();
\SnappyMail\LOG::info(get_class($this),'user/pwd rewrite: '. $oFromAccount->Email()); \SnappyMail\LOG::info(get_class($this),'user/pwd rewrite: '. $oFromAccount->Email());
} }
} }
@ -106,10 +106,9 @@ class SmtpUseFromAdrAccountPlugin extends \RainLoop\Plugins\AbstractPlugin
->SetDescription('space as delimiter, wildcard supported.') ->SetDescription('space as delimiter, wildcard supported.')
->SetDefaultValue('user@example.com *@example2.com'), ->SetDefaultValue('user@example.com *@example2.com'),
\RainLoop\Plugins\Property::NewInstance('throw_notfound_exception')->SetLabel('Throw Exception, if from-adr is not found as account') \RainLoop\Plugins\Property::NewInstance('throw_notfound_exception')->SetLabel('Throw Exception, if from-adr is not found as account')
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL) ->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL)
->SetDescription('it is not possible to send eMails in this case, regardless of whether the smtp-server would do it') ->SetDescription('it is not possible to send eMails in this case, regardless of whether the smtp-server would do it')
->SetDefaultValue(true), ->SetDefaultValue(true)
); );
} }

View file

@ -269,13 +269,14 @@ class Actions
} }
if ($oAccount) { if ($oAccount) {
$oDomain = $oAccount->Domain();
$sLine = \str_replace('{imap:login}', $oAccount->IncLogin(), $sLine); $sLine = \str_replace('{imap:login}', $oAccount->IncLogin(), $sLine);
$sLine = \str_replace('{imap:host}', $oAccount->Domain()->IncHost(), $sLine); $sLine = \str_replace('{imap:host}', $oDomain->ImapSettings()->host, $sLine);
$sLine = \str_replace('{imap:port}', $oAccount->Domain()->IncPort(), $sLine); $sLine = \str_replace('{imap:port}', $oDomain->ImapSettings()->port, $sLine);
$sLine = \str_replace('{smtp:login}', $oAccount->OutLogin(), $sLine); $sLine = \str_replace('{smtp:login}', $oAccount->OutLogin(), $sLine);
$sLine = \str_replace('{smtp:host}', $oAccount->Domain()->OutHost(), $sLine); $sLine = \str_replace('{smtp:host}', $oDomain->SmtpSettings()->host, $sLine);
$sLine = \str_replace('{smtp:port}', $oAccount->Domain()->OutPort(), $sLine); $sLine = \str_replace('{smtp:port}', $oDomain->SmtpSettings()->port, $sLine);
} }
$aClear['/\{imap:([^}]*)\}/i'] = 'imap'; $aClear['/\{imap:([^}]*)\}/i'] = 'imap';
@ -899,7 +900,7 @@ class Actions
'Kolab' => false, // See Kolab plugin 'Kolab' => false, // See Kolab plugin
); );
} }
$aResult[Capa::SIEVE] = $bAdmin || ($oAccount && $oAccount->Domain()->UseSieve()); $aResult[Capa::SIEVE] = $bAdmin || ($oAccount && $oAccount->Domain()->SieveSettings()->enabled);
return $aResult; return $aResult;
} }

View file

@ -137,7 +137,7 @@ trait AdminDomains
$sImapErrorDesc = $oException->getMessage(); $sImapErrorDesc = $oException->getMessage();
} }
if ($oDomain->OutUsePhpMail()) { if ($oDomain->SmtpSettings()->usePhpMail) {
$mSmtpResult = \MailSo\Base\Utils::FunctionCallable('mail'); $mSmtpResult = \MailSo\Base\Utils::FunctionCallable('mail');
if (!$mSmtpResult) { if (!$mSmtpResult) {
$sSmtpErrorDesc = 'PHP: mail() function is undefined'; $sSmtpErrorDesc = 'PHP: mail() function is undefined';
@ -179,7 +179,7 @@ trait AdminDomains
} }
} }
if ($oDomain->UseSieve()) { if ($oDomain->SieveSettings()->enabled) {
try try
{ {
$oSieveClient = new \MailSo\Sieve\SieveClient(); $oSieveClient = new \MailSo\Sieve\SieveClient();

View file

@ -964,7 +964,7 @@ trait Messages
{ {
$oMessage->SetFrom(new \MailSo\Mime\Email( $oMessage->SetFrom(new \MailSo\Mime\Email(
$oIdentity->Email(), $oIdentity->Name())); $oIdentity->Email(), $oIdentity->Name()));
if ($oAccount->Domain()->OutSetSender()) { if ($oAccount->Domain()->SmtpSettings()->setSender) {
$oMessage->SetSender(\MailSo\Mime\Email::Parse($oAccount->Email())); $oMessage->SetSender(\MailSo\Mime\Email::Parse($oAccount->Email()));
} }
} }

View file

@ -39,7 +39,7 @@ abstract class Account implements \JsonSerializable
public function IncLogin() : string public function IncLogin() : string
{ {
return $this->oDomain->IncShortLogin() return $this->oDomain->ImapSettings()->shortLogin
? \MailSo\Base\Utils::GetAccountNameFromEmail($this->sLogin) ? \MailSo\Base\Utils::GetAccountNameFromEmail($this->sLogin)
: $this->sLogin; : $this->sLogin;
} }
@ -52,7 +52,9 @@ abstract class Account implements \JsonSerializable
public function OutLogin() : string public function OutLogin() : string
{ {
$sSmtpLogin = $this->sSmtpLogin ?: $this->sLogin; $sSmtpLogin = $this->sSmtpLogin ?: $this->sLogin;
return $this->oDomain->OutShortLogin() ? \MailSo\Base\Utils::GetAccountNameFromEmail($sSmtpLogin) : $sSmtpLogin; return $this->oDomain->SmtpSettings()->shortLogin
? \MailSo\Base\Utils::GetAccountNameFromEmail($sSmtpLogin)
: $sSmtpLogin;
} }
public function Domain() : Domain public function Domain() : Domain

View file

@ -61,51 +61,60 @@ class Domain implements \JsonSerializable
return $this->Name; return $this->Name;
} }
/**
* @deprecated
*/
public function IncHost() : string public function IncHost() : string
{ {
\trigger_error('Deprecated function called.', \E_USER_DEPRECATED);
return $this->IMAP->host; return $this->IMAP->host;
} }
/**
* @deprecated
*/
public function IncPort() : int public function IncPort() : int
{ {
\trigger_error('Deprecated function called.', \E_USER_DEPRECATED);
return $this->IMAP->port; return $this->IMAP->port;
} }
/**
* @deprecated
*/
public function IncShortLogin() : bool public function IncShortLogin() : bool
{ {
\trigger_error('Deprecated function called.', \E_USER_DEPRECATED);
return $this->IMAP->shortLogin; return $this->IMAP->shortLogin;
} }
/**
* @deprecated
*/
public function UseSieve() : bool public function UseSieve() : bool
{ {
\trigger_error('Deprecated function called.', \E_USER_DEPRECATED);
return $this->Sieve->enabled; return $this->Sieve->enabled;
} }
/**
* @deprecated
*/
public function OutHost() : string public function OutHost() : string
{ {
\trigger_error('Deprecated function called.', \E_USER_DEPRECATED);
return $this->SMTP->host; return $this->SMTP->host;
} }
/**
* @deprecated
*/
public function OutPort() : int public function OutPort() : int
{ {
\trigger_error('Deprecated function called.', \E_USER_DEPRECATED);
return $this->SMTP->port; return $this->SMTP->port;
} }
public function OutShortLogin() : bool
{
return $this->SMTP->shortLogin;
}
public function OutSetSender() : bool
{
return $this->SMTP->setSender;
}
public function OutUsePhpMail() : bool
{
return $this->SMTP->usePhpMail;
}
public function SetAliasName(string $sAliasName) : void public function SetAliasName(string $sAliasName) : void
{ {
$this->aliasName = $sAliasName; $this->aliasName = $sAliasName;