Fixing indentation

This commit is contained in:
Floris Westerman 2020-11-10 11:52:21 +01:00
parent 1c63287243
commit 6919a6a34f
No known key found for this signature in database
GPG key ID: E2AED138B92702B0
8 changed files with 903 additions and 1234 deletions

2
.editorconfig Normal file
View file

@ -0,0 +1,2 @@
[*.php]
indent_style = tab

File diff suppressed because it is too large Load diff

View file

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

View file

@ -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'] : '';

View file

@ -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) {

View file

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

View file

@ -40,5 +40,8 @@ class TestIdentities implements IIdentities
return false; return false;
} }
public function Name() : string { return "Test"; } public function Name(): string
{
return "Test";
}
} }