mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-25 18:19:22 +03:00
Code refactoring
This commit is contained in:
parent
58d8e92902
commit
1de1ecc9c4
4 changed files with 220 additions and 127 deletions
|
|
@ -1757,6 +1757,64 @@ class Actions
|
|||
return $aIdentities;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Account $oAccount
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetIdentitiesNew($oAccount)
|
||||
{
|
||||
$aIdentities = array();
|
||||
if ($oAccount)
|
||||
{
|
||||
$oAccountIdentity = \RainLoop\Identity::NewInstance('', $oAccount->Email());
|
||||
|
||||
$aSubIdentities = array();
|
||||
$oSettings = $this->SettingsProvider()->Load($oAccount);
|
||||
if ($oSettings)
|
||||
{
|
||||
$sData = $oSettings->GetConf('Identities', '');
|
||||
if ('' !== $sData && '[' === \substr($sData, 0, 1))
|
||||
{
|
||||
$aSubIdentities = @\json_decode($sData, true);
|
||||
$aSubIdentities = \is_array($aSubIdentities) ? $aSubIdentities : array();
|
||||
}
|
||||
}
|
||||
|
||||
if (0 < \count($aSubIdentities))
|
||||
{
|
||||
foreach ($aSubIdentities as $aItem)
|
||||
{
|
||||
if (isset($aItem['Id'], $aItem['Email']))
|
||||
{
|
||||
if (0 < \strlen($aItem['Id']))
|
||||
{
|
||||
$oItem = \RainLoop\Identity::NewInstance($aItem['Id'], $aItem['Email']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$oItem = $oAccountIdentity;
|
||||
}
|
||||
|
||||
$oItem->SetName(isset($aItem['Name']) ? $aItem['Name'] : '');
|
||||
$oItem->SetReplyTo(isset($aItem['ReplyTo']) ? $aItem['ReplyTo'] : '');
|
||||
$oItem->SetBcc(isset($aItem['Bcc']) ? $aItem['Bcc'] : '');
|
||||
$oItem->SetSignature(isset($aItem['Signature']) ? $aItem['Signature'] : '');
|
||||
|
||||
if ('' !== $oItem->Id())
|
||||
{
|
||||
\array_push($aIdentities, $oItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
\array_unshift($aIdentities, $oAccountIdentity);
|
||||
}
|
||||
|
||||
return $aIdentities;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Account $oAccount
|
||||
* @param array $aAccounts = array()
|
||||
|
|
@ -2024,6 +2082,33 @@ class Actions
|
|||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @throws \MailSo\Base\Exceptions\Exception
|
||||
*/
|
||||
public function DoAccountsAndIdentitiesNew()
|
||||
{
|
||||
$oAccount = $this->getAccountFromToken();
|
||||
|
||||
$mAccounts = false;
|
||||
if ($this->Config()->Get('webmail', 'allow_additional_accounts', true))
|
||||
{
|
||||
$mAccounts = $this->GetAccounts($oAccount);
|
||||
$mAccounts = \array_keys($mAccounts);
|
||||
|
||||
foreach ($mAccounts as $iIndex => $sName)
|
||||
{
|
||||
$mAccounts[$iIndex] = \MailSo\Base\Utils::IdnToUtf8($sName);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->DefaultResponse(__FUNCTION__, array(
|
||||
'Accounts' => $mAccounts,
|
||||
'Identities' => $this->GetIdentitiesNew($oAccount)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Account $oAccount
|
||||
*/
|
||||
|
|
@ -6381,7 +6466,7 @@ class Actions
|
|||
\header('Content-Type: '.$sContentTypeOut);
|
||||
\header('Content-Disposition: '.($bDownload ? 'attachment' : 'inline').'; '.
|
||||
\trim(\MailSo\Base\Utils::EncodeHeaderUtf8AttributeValue('filename', $sFileNameOut)), true);
|
||||
|
||||
|
||||
\header('Accept-Ranges: none', true);
|
||||
\header('Content-Transfer-Encoding: binary');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue