mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-09-20 07:35:55 +08:00
Fixing indentation
This commit is contained in:
parent
1c63287243
commit
6919a6a34f
2
.editorconfig
Normal file
2
.editorconfig
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[*.php]
|
||||||
|
indent_style = tab
|
File diff suppressed because it is too large
Load diff
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
namespace RainLoop\Actions;
|
namespace RainLoop\Actions;
|
||||||
|
|
||||||
use \RainLoop\Enumerations\Capa;
|
use RainLoop\Enumerations\Capa;
|
||||||
use \RainLoop\Exceptions\ClientException;
|
use RainLoop\Exceptions\ClientException;
|
||||||
use \RainLoop\Model\Account;
|
use RainLoop\Model\Account;
|
||||||
use \RainLoop\Model\Identity;
|
use RainLoop\Model\Identity;
|
||||||
use \RainLoop\Notifications;
|
use RainLoop\Notifications;
|
||||||
use RainLoop\Providers\Storage\Enumerations\StorageType;
|
use RainLoop\Providers\Storage\Enumerations\StorageType;
|
||||||
use function trim;
|
use function trim;
|
||||||
|
|
||||||
|
@ -20,8 +20,7 @@ trait Accounts
|
||||||
{
|
{
|
||||||
$oAccount = $this->getAccountFromToken();
|
$oAccount = $this->getAccountFromToken();
|
||||||
|
|
||||||
if (!$this->GetCapa(false, false, Capa::ADDITIONAL_ACCOUNTS, $oAccount))
|
if (!$this->GetCapa(false, false, Capa::ADDITIONAL_ACCOUNTS, $oAccount)) {
|
||||||
{
|
|
||||||
return $this->FalseResponse(__FUNCTION__);
|
return $this->FalseResponse(__FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,12 +33,9 @@ trait Accounts
|
||||||
$bNew = '1' === (string)$this->GetActionParam('New', '1');
|
$bNew = '1' === (string)$this->GetActionParam('New', '1');
|
||||||
|
|
||||||
$sEmail = \MailSo\Base\Utils::IdnToAscii($sEmail, true);
|
$sEmail = \MailSo\Base\Utils::IdnToAscii($sEmail, true);
|
||||||
if ($bNew && ($oAccount->Email() === $sEmail || $sParentEmail === $sEmail || isset($aAccounts[$sEmail])))
|
if ($bNew && ($oAccount->Email() === $sEmail || $sParentEmail === $sEmail || isset($aAccounts[$sEmail]))) {
|
||||||
{
|
|
||||||
throw new ClientException(Notifications::AccountAlreadyExists);
|
throw new ClientException(Notifications::AccountAlreadyExists);
|
||||||
}
|
} else if (!$bNew && !isset($aAccounts[$sEmail])) {
|
||||||
else if (!$bNew && !isset($aAccounts[$sEmail]))
|
|
||||||
{
|
|
||||||
throw new ClientException(Notifications::AccountDoesNotExist);
|
throw new ClientException(Notifications::AccountDoesNotExist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,8 +43,7 @@ trait Accounts
|
||||||
$oNewAccount->SetParentEmail($sParentEmail);
|
$oNewAccount->SetParentEmail($sParentEmail);
|
||||||
|
|
||||||
$aAccounts[$oNewAccount->Email()] = $oNewAccount->GetAuthToken();
|
$aAccounts[$oNewAccount->Email()] = $oNewAccount->GetAuthToken();
|
||||||
if (!$oAccount->IsAdditionalAccount())
|
if (!$oAccount->IsAdditionalAccount()) {
|
||||||
{
|
|
||||||
$aAccounts[$oAccount->Email()] = $oAccount->GetAuthToken();
|
$aAccounts[$oAccount->Email()] = $oAccount->GetAuthToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,8 +58,7 @@ trait Accounts
|
||||||
{
|
{
|
||||||
$oAccount = $this->getAccountFromToken();
|
$oAccount = $this->getAccountFromToken();
|
||||||
|
|
||||||
if (!$this->GetCapa(false, false, Capa::ADDITIONAL_ACCOUNTS, $oAccount))
|
if (!$this->GetCapa(false, false, Capa::ADDITIONAL_ACCOUNTS, $oAccount)) {
|
||||||
{
|
|
||||||
return $this->FalseResponse(__FUNCTION__);
|
return $this->FalseResponse(__FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,16 +68,13 @@ trait Accounts
|
||||||
|
|
||||||
$aAccounts = $this->GetAccounts($oAccount);
|
$aAccounts = $this->GetAccounts($oAccount);
|
||||||
|
|
||||||
if (0 < \strlen($sEmailToDelete) && $sEmailToDelete !== $sParentEmail && isset($aAccounts[$sEmailToDelete]))
|
if (0 < \strlen($sEmailToDelete) && $sEmailToDelete !== $sParentEmail && isset($aAccounts[$sEmailToDelete])) {
|
||||||
{
|
|
||||||
unset($aAccounts[$sEmailToDelete]);
|
unset($aAccounts[$sEmailToDelete]);
|
||||||
|
|
||||||
$oAccountToChange = null;
|
$oAccountToChange = null;
|
||||||
if ($oAccount->Email() === $sEmailToDelete && !empty($aAccounts[$sParentEmail]))
|
if ($oAccount->Email() === $sEmailToDelete && !empty($aAccounts[$sParentEmail])) {
|
||||||
{
|
|
||||||
$oAccountToChange = $this->GetAccountFromCustomToken($aAccounts[$sParentEmail], false, false);
|
$oAccountToChange = $this->GetAccountFromCustomToken($aAccounts[$sParentEmail], false, false);
|
||||||
if ($oAccountToChange)
|
if ($oAccountToChange) {
|
||||||
{
|
|
||||||
$this->AuthToken($oAccountToChange);
|
$this->AuthToken($oAccountToChange);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,8 +94,7 @@ trait Accounts
|
||||||
$oAccount = $this->getAccountFromToken();
|
$oAccount = $this->getAccountFromToken();
|
||||||
|
|
||||||
$oIdentity = new \RainLoop\Model\Identity();
|
$oIdentity = new \RainLoop\Model\Identity();
|
||||||
if (!$oIdentity->FromJSON($this->GetActionParams(), true))
|
if (!$oIdentity->FromJSON($this->GetActionParams(), true)) {
|
||||||
{
|
|
||||||
throw new ClientException(Notifications::InvalidInputArgument);
|
throw new ClientException(Notifications::InvalidInputArgument);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,14 +109,12 @@ trait Accounts
|
||||||
{
|
{
|
||||||
$oAccount = $this->getAccountFromToken();
|
$oAccount = $this->getAccountFromToken();
|
||||||
|
|
||||||
if (!$this->GetCapa(false, false, Capa::IDENTITIES, $oAccount))
|
if (!$this->GetCapa(false, false, Capa::IDENTITIES, $oAccount)) {
|
||||||
{
|
|
||||||
return $this->FalseResponse(__FUNCTION__);
|
return $this->FalseResponse(__FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sId = trim($this->GetActionParam('IdToDelete', ''));
|
$sId = trim($this->GetActionParam('IdToDelete', ''));
|
||||||
if (empty($sId))
|
if (empty($sId)) {
|
||||||
{
|
|
||||||
throw new ClientException(Notifications::UnknownError);
|
throw new ClientException(Notifications::UnknownError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,8 +132,7 @@ trait Accounts
|
||||||
$aAccounts = $this->GetActionParam('Accounts', null);
|
$aAccounts = $this->GetActionParam('Accounts', null);
|
||||||
$aIdentities = $this->GetActionParam('Identities', null);
|
$aIdentities = $this->GetActionParam('Identities', null);
|
||||||
|
|
||||||
if (!\is_array($aAccounts) && !\is_array($aIdentities))
|
if (!\is_array($aAccounts) && !\is_array($aIdentities)) {
|
||||||
{
|
|
||||||
return $this->FalseResponse(__FUNCTION__);
|
return $this->FalseResponse(__FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,13 +154,11 @@ trait Accounts
|
||||||
|
|
||||||
$mAccounts = false;
|
$mAccounts = false;
|
||||||
|
|
||||||
if ($this->GetCapa(false, false, Capa::ADDITIONAL_ACCOUNTS, $oAccount))
|
if ($this->GetCapa(false, false, Capa::ADDITIONAL_ACCOUNTS, $oAccount)) {
|
||||||
{
|
|
||||||
$mAccounts = $this->GetAccounts($oAccount);
|
$mAccounts = $this->GetAccounts($oAccount);
|
||||||
$mAccounts = \array_keys($mAccounts);
|
$mAccounts = \array_keys($mAccounts);
|
||||||
|
|
||||||
foreach ($mAccounts as $iIndex => $sName)
|
foreach ($mAccounts as $iIndex => $sName) {
|
||||||
{
|
|
||||||
$mAccounts[$iIndex] = \MailSo\Base\Utils::IdnToUtf8($sName);
|
$mAccounts[$iIndex] = \MailSo\Base\Utils::IdnToUtf8($sName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,8 +133,7 @@ class Identity implements JsonSerializable
|
||||||
|
|
||||||
public function FromJSON(array $aData, bool $bAjax = false): bool
|
public function FromJSON(array $aData, bool $bAjax = false): bool
|
||||||
{
|
{
|
||||||
if (!empty($aData['Email']))
|
if (!empty($aData['Email'])) {
|
||||||
{
|
|
||||||
$this->sId = !empty($aData['Id']) ? $aData['Id'] : '';
|
$this->sId = !empty($aData['Id']) ? $aData['Id'] : '';
|
||||||
$this->sEmail = $bAjax ? Utils::IdnToAscii($aData['Email'], true) : $aData['Email'];
|
$this->sEmail = $bAjax ? Utils::IdnToAscii($aData['Email'], true) : $aData['Email'];
|
||||||
$this->sName = isset($aData['Name']) ? $aData['Name'] : '';
|
$this->sName = isset($aData['Name']) ? $aData['Name'] : '';
|
||||||
|
|
|
@ -32,7 +32,8 @@ class Identities extends AbstractProvider
|
||||||
* @param bool $allowMultipleIdentities
|
* @param bool $allowMultipleIdentities
|
||||||
* @return Identity[]
|
* @return Identity[]
|
||||||
*/
|
*/
|
||||||
public function GetIdentities(Account $account, bool $allowMultipleIdentities) : array {
|
public function GetIdentities(Account $account, bool $allowMultipleIdentities): array
|
||||||
|
{
|
||||||
// Find all identities stored in the system
|
// Find all identities stored in the system
|
||||||
$identities = $this->MergeIdentitiesPerDriver($this->GetIdentiesPerDriver($account));
|
$identities = $this->MergeIdentitiesPerDriver($this->GetIdentiesPerDriver($account));
|
||||||
|
|
||||||
|
@ -49,7 +50,8 @@ class Identities extends AbstractProvider
|
||||||
return $allowMultipleIdentities ? $identities : [$primaryIdentity];
|
return $allowMultipleIdentities ? $identities : [$primaryIdentity];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function UpdateIdentity(Account $account, Identity $identity) {
|
public function UpdateIdentity(Account $account, Identity $identity)
|
||||||
|
{
|
||||||
// Find all identities in the system
|
// Find all identities in the system
|
||||||
$identities = &$this->GetIdentiesPerDriver($account);
|
$identities = &$this->GetIdentiesPerDriver($account);
|
||||||
|
|
||||||
|
@ -80,7 +82,8 @@ class Identities extends AbstractProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function DeleteIdentity(Account $account, string $identityId) {
|
public function DeleteIdentity(Account $account, string $identityId)
|
||||||
|
{
|
||||||
// On deletion, we remove the identity from all drivers if they are writeable.
|
// On deletion, we remove the identity from all drivers if they are writeable.
|
||||||
$identities = &$this->GetIdentiesPerDriver($account);
|
$identities = &$this->GetIdentiesPerDriver($account);
|
||||||
|
|
||||||
|
@ -100,7 +103,8 @@ class Identities extends AbstractProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function &GetIdentiesPerDriver(Account $account) : array {
|
private function &GetIdentiesPerDriver(Account $account): array
|
||||||
|
{
|
||||||
if (isset($this->identitiesPerDriverPerAccount[$account->Email()]))
|
if (isset($this->identitiesPerDriverPerAccount[$account->Email()]))
|
||||||
return $this->identitiesPerDriverPerAccount[$account->Email()];
|
return $this->identitiesPerDriverPerAccount[$account->Email()];
|
||||||
|
|
||||||
|
@ -120,7 +124,8 @@ class Identities extends AbstractProvider
|
||||||
* @param Identity[][] $identitiesPerDriver
|
* @param Identity[][] $identitiesPerDriver
|
||||||
* @return Identity[]
|
* @return Identity[]
|
||||||
*/
|
*/
|
||||||
private function MergeIdentitiesPerDriver(array $identitiesPerDriver) : array {
|
private function MergeIdentitiesPerDriver(array $identitiesPerDriver): array
|
||||||
|
{
|
||||||
// Merge logic for the identities
|
// Merge logic for the identities
|
||||||
$identities = [];
|
$identities = [];
|
||||||
foreach ($this->drivers as $driver) {
|
foreach ($this->drivers as $driver) {
|
||||||
|
|
|
@ -50,7 +50,9 @@ class FileIdentities implements IIdentities
|
||||||
*/
|
*/
|
||||||
public function SetIdentities(Account $account, array $identities)
|
public function SetIdentities(Account $account, array $identities)
|
||||||
{
|
{
|
||||||
$jsons = array_map(function($identity) { return $identity->ToSimpleJSON(); }, $identities);
|
$jsons = array_map(function ($identity) {
|
||||||
|
return $identity->ToSimpleJSON();
|
||||||
|
}, $identities);
|
||||||
$this->localStorageProvider->Put($account, Storage\Enumerations\StorageType::CONFIG, 'identities', json_encode($jsons));
|
$this->localStorageProvider->Put($account, Storage\Enumerations\StorageType::CONFIG, 'identities', json_encode($jsons));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,5 +40,8 @@ class TestIdentities implements IIdentities
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Name() : string { return "Test"; }
|
public function Name(): string
|
||||||
|
{
|
||||||
|
return "Test";
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue