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,
'{login}' => $oAccount->IncLogin(),
'{imap:login}' => $oAccount->IncLogin(),
'{imap:host}' => $oAccount->Domain()->IncHost(),
'{imap:port}' => $oAccount->Domain()->IncPort(),
'{imap:host}' => $oAccount->Domain()->ImapSettings()->host,
'{imap:port}' => $oAccount->Domain()->ImapSettings()->port,
'{gecos}' => \function_exists('posix_getpwnam') ? \posix_getpwnam($oAccount->IncLogin()) : ''
));

View file

@ -6,8 +6,8 @@ class ChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
{
const
NAME = 'Change Password',
VERSION = '2.19',
RELEASE = '2023-04-11',
VERSION = '2.20',
RELEASE = '2024-03-10',
REQUIRED = '2.23.0',
CATEGORY = 'Security',
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,
'{login}' => $oAccount->IncLogin(),
'{imap:login}' => $oAccount->IncLogin(),
'{imap:host}' => $oAccount->Domain()->IncHost(),
'{imap:port}' => $oAccount->Domain()->IncPort()
'{imap:host}' => $oAccount->Domain()->ImapSettings()->host,
'{imap:port}' => $oAccount->Domain()->ImapSettings()->port
));
$aObjectClasses = empty($this->sObjectClasses) ? array() : \explode(',', $this->sObjectClasses);

View file

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

View file

@ -70,7 +70,7 @@ class LdapMailAccounts
$username = $sEmail;
$oActions = \RainLoop\Api::Actions();
$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);
}
@ -101,7 +101,7 @@ class LdapMailAccounts
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);
return false;
}
}
foreach($mailAddressResults as $mailAddressResult)
{

View file

@ -12,10 +12,10 @@ class LdapMailAccountsPlugin extends AbstractPlugin
{
const
NAME = 'LDAP Mail Accounts',
VERSION = '2.0.0',
VERSION = '2.1.0',
AUTHOR = 'cm-schl',
URL = 'https://github.com/cm-sch',
RELEASE = '2023-03-14',
RELEASE = '2024-03-10',
REQUIRED = '2.25.4',
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).';
@ -44,10 +44,10 @@ class LdapMailAccountsPlugin extends AbstractPlugin
*/
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
$config = LdapMailAccountsConfig::MakeConfig($this->Config());
// Set up config
$config = LdapMailAccountsConfig::MakeConfig($this->Config());
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);
}
$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
@ -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 mail address used at login will still be used to login to the servers.")
->SetDefaultValue("mail"),
]);
]);
return [
\RainLoop\Plugins\Property::NewInstance(LdapMailAccountsConfig::CONFIG_SERVER)
@ -172,7 +172,7 @@ $this->Manager()->Actions()->Logger()->Write("Login DATA: login: $sLogin email:
->SetDefaultValue("displayName"),
$groupOverwriteMainAccount
];
}
}

View file

@ -7,8 +7,8 @@ class SmtpUseFromAdrAccountPlugin extends \RainLoop\Plugins\AbstractPlugin
NAME = 'Use From-Address-Account for smtp',
AUTHOR = 'attike',
URL = 'https://github.com/attike',
VERSION = '1.0',
RELEASE = '2023-12-06',
VERSION = '1.1',
RELEASE = '2024-03-10',
REQUIRED = '2.23.0',
CATEGORY = 'Filters',
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()) {
\SnappyMail\LOG::info(get_class($this) ,'From address different from account recognized: '. $oAccount->Email().' -> '.$sFrom . '(~ '.$sFoundValue.')');
$oMainAccount;
$oFromAccount;
if ( $oAccount instanceof \RainLoop\Model\MainAccount ) {
$oFromAccount;
if ($oAccount instanceof \RainLoop\Model\MainAccount ) {
$oMainAccount=$oAccount;
} else {
$oMainAccount=$this->Manager()->Actions()->getMainAccountFromToken();
@ -44,21 +44,21 @@ class SmtpUseFromAdrAccountPlugin extends \RainLoop\Plugins\AbstractPlugin
return;
}
}
$aAccounts=$this->Manager()->Actions()->getAccounts($oMainAccount);
foreach ($aAccounts as &$value) {
$oValue=\RainLoop\Model\AdditionalAccount::NewInstanceFromTokenArray($this->Manager()->Actions(), $value);
if ($oValue->Email()==$sFrom) {
$oFromAccount = $oValue;
break;
}
}
if (is_null($oFromAccount)){
$aAccounts = $this->Manager()->Actions()->getAccounts($oMainAccount);
foreach ($aAccounts as &$value) {
$oValue=\RainLoop\Model\AdditionalAccount::NewInstanceFromTokenArray($this->Manager()->Actions(), $value);
if ($oValue->Email()==$sFrom) {
$oFromAccount = $oValue;
break;
}
}
if (is_null($oFromAccount)){
\SnappyMail\LOG::info(get_class($this),'No Account found for '. $sFrom);
if ($this->Config()->Get('plugin', 'throw_notfound_exception', true)) {
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AccountDoesNotExist);
}
return;
}
return;
}
$this->aFromAccount[$oAccount->Email()]=$oFromAccount;
}
}
@ -71,10 +71,10 @@ class SmtpUseFromAdrAccountPlugin extends \RainLoop\Plugins\AbstractPlugin
{
if ( isset($this->aFromAccount[$oAccount->Email()]) ) {
$oFromAccount = $this->aFromAccount[$oAccount->Email()];
$oSettings->host = $oFromAccount->Domain()->OutHost();
$oSettings->port = (int) $oFromAccount->Domain()->OutPort();
$oSettings->type = $oFromAccount->Domain()-> SmtpSettings()->type;
\SnappyMail\LOG::info(get_class($this),'Smtp config rewrite: '. $oFromAccount->Domain()->OutHost());
$oSettings->host = $oFromAccount->Domain()->SmtpSettings()->host;
$oSettings->port = (int) $oFromAccount->Domain()->SmtpSettings()->port;
$oSettings->type = $oFromAccount->Domain()->SmtpSettings()->type;
\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()]) ) {
$oFromAccount = $this->aFromAccount[$oAccount->Email()];
unset($this->aFromAccount[$oAccount->Email()]);
$oSettings->Login = $oFromAccount-> OutLogin();
$oSettings->useAuth = $oFromAccount->Domain()-> SmtpSettings()->useAuth;
$oSettings->Password = $oFromAccount->IncPassword();
$oSettings->Login = $oFromAccount->OutLogin();
$oSettings->useAuth = $oFromAccount->Domain()->SmtpSettings()->useAuth;
$oSettings->Password = $oFromAccount->IncPassword();
\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.')
->SetDefaultValue('user@example.com *@example2.com'),
\RainLoop\Plugins\Property::NewInstance('throw_notfound_exception')->SetLabel('Throw Exception, if from-adr is not found as account')
->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')
->SetDefaultValue(true),
->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')
->SetDefaultValue(true)
);
}

View file

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

View file

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

View file

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

View file

@ -39,7 +39,7 @@ abstract class Account implements \JsonSerializable
public function IncLogin() : string
{
return $this->oDomain->IncShortLogin()
return $this->oDomain->ImapSettings()->shortLogin
? \MailSo\Base\Utils::GetAccountNameFromEmail($this->sLogin)
: $this->sLogin;
}
@ -52,7 +52,9 @@ abstract class Account implements \JsonSerializable
public function OutLogin() : string
{
$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

View file

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