mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-12-31 03:52:01 +08:00
Don't load Capa at login page and cleanup/speedup GetCapa
This commit is contained in:
parent
ad269597d6
commit
6df9aaae43
8 changed files with 34 additions and 31 deletions
|
@ -509,7 +509,7 @@ class Actions
|
|||
{
|
||||
if (null === $this->oAddressBookProvider) {
|
||||
$oDriver = null;
|
||||
if ($this->GetCapa(false, Enumerations\Capa::CONTACTS, $oAccount)) {
|
||||
if ($this->GetCapa(Enumerations\Capa::CONTACTS)) {
|
||||
if ($this->oConfig->Get('contacts', 'enable', false) || $bForceEnable) {
|
||||
$oDriver = $this->fabrica('address-book', $oAccount);
|
||||
}
|
||||
|
@ -643,7 +643,7 @@ class Actions
|
|||
$oConfig = $this->oConfig;
|
||||
|
||||
$aAttachmentsActions = array();
|
||||
if ($this->GetCapa(false, Enumerations\Capa::ATTACHMENTS_ACTIONS)) {
|
||||
if ($this->GetCapa(Enumerations\Capa::ATTACHMENTS_ACTIONS)) {
|
||||
if (\class_exists('PharData') || \class_exists('ZipArchive')) {
|
||||
$aAttachmentsActions[] = 'zip';
|
||||
}
|
||||
|
@ -784,7 +784,6 @@ class Actions
|
|||
$aResult['WeakPassword'] = \is_file($passfile);
|
||||
}
|
||||
|
||||
$aResult['Capa'] = $this->Capa(true);
|
||||
$aResult['LanguageAdmin'] = $this->ValidateLanguage($oConfig->Get('webmail', 'language_admin', 'en'), '', true);
|
||||
$aResult['UserLanguageAdmin'] = $this->ValidateLanguage($UserLanguageRaw, '', true, true);
|
||||
} else {
|
||||
|
@ -867,11 +866,11 @@ class Actions
|
|||
$aResult['AutoLogout'] = (int)$oSettings->GetConf('AutoLogout', $aResult['AutoLogout']);
|
||||
$aResult['Layout'] = (int)$oSettings->GetConf('Layout', $aResult['Layout']);
|
||||
|
||||
if (!$this->GetCapa(false, Enumerations\Capa::AUTOLOGOUT, $oAccount)) {
|
||||
if (!$this->GetCapa(Enumerations\Capa::AUTOLOGOUT)) {
|
||||
$aResult['AutoLogout'] = 0;
|
||||
}
|
||||
|
||||
if ($this->GetCapa(false, Enumerations\Capa::USER_BACKGROUND, $oAccount)) {
|
||||
if ($this->GetCapa(Enumerations\Capa::USER_BACKGROUND)) {
|
||||
$aResult['UserBackgroundName'] = (string)$oSettings->GetConf('UserBackgroundName', $aResult['UserBackgroundName']);
|
||||
$aResult['UserBackgroundHash'] = (string)$oSettings->GetConf('UserBackgroundHash', $aResult['UserBackgroundHash']);
|
||||
}
|
||||
|
@ -894,11 +893,10 @@ class Actions
|
|||
$aResult['AdditionalLoginError'] = $this->GetSpecLogoutCustomMgsWithDeletion();
|
||||
}
|
||||
}
|
||||
|
||||
$aResult['Capa'] = $this->Capa(false, $oAccount);
|
||||
}
|
||||
|
||||
if ($aResult['Auth']) {
|
||||
$aResult['Capa'] = $this->Capa($bAdmin, $oAccount);
|
||||
$aResult['PhpUploadSizes'] = array(
|
||||
'upload_max_filesize' => \ini_get('upload_max_filesize'),
|
||||
'post_max_size' => \ini_get('post_max_size')
|
||||
|
@ -1081,7 +1079,7 @@ class Actions
|
|||
{
|
||||
$oAccount = $this->getAccountFromToken();
|
||||
|
||||
if (!$this->GetCapa(false, Enumerations\Capa::USER_BACKGROUND, $oAccount)) {
|
||||
if (!$this->GetCapa(Enumerations\Capa::USER_BACKGROUND)) {
|
||||
return $this->FalseResponse(__FUNCTION__);
|
||||
}
|
||||
|
||||
|
@ -1160,9 +1158,16 @@ class Actions
|
|||
|
||||
public function Capa(bool $bAdmin, ?Model\Account $oAccount = null): array
|
||||
{
|
||||
static $aResult;
|
||||
if ($aResult && !$oAccount) {
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
$oConfig = $this->oConfig;
|
||||
|
||||
$aResult = array();
|
||||
$aResult = array(
|
||||
Enumerations\Capa::AUTOLOGOUT
|
||||
);
|
||||
|
||||
if ($oConfig->Get('capa', 'dangerous_actions', true)) {
|
||||
$aResult[] = Enumerations\Capa::DANGEROUS_ACTIONS;
|
||||
|
@ -1231,14 +1236,12 @@ class Actions
|
|||
$aResult[] = Enumerations\Capa::KOLAB;
|
||||
}
|
||||
|
||||
$aResult[] = Enumerations\Capa::AUTOLOGOUT;
|
||||
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
public function GetCapa(bool $bAdmin, string $sName, ?Model\Account $oAccount = null): bool
|
||||
public function GetCapa(string $sName, ?Model\Account $oAccount = null): bool
|
||||
{
|
||||
return \in_array($sName, $this->Capa($bAdmin, $oAccount));
|
||||
return \in_array($sName, $this->Capa(false, $oAccount));
|
||||
}
|
||||
|
||||
public function etag(string $sKey): string
|
||||
|
|
|
@ -36,7 +36,7 @@ trait Accounts
|
|||
|
||||
public function GetAccounts(MainAccount $oAccount): array
|
||||
{
|
||||
if ($this->GetCapa(false, Capa::ADDITIONAL_ACCOUNTS, $oAccount)) {
|
||||
if ($this->GetCapa(Capa::ADDITIONAL_ACCOUNTS)) {
|
||||
$sAccounts = $this->StorageProvider()->Get($oAccount,
|
||||
StorageType::CONFIG,
|
||||
'additionalaccounts'
|
||||
|
@ -76,7 +76,7 @@ trait Accounts
|
|||
{
|
||||
$oMainAccount = $this->getMainAccountFromToken();
|
||||
|
||||
if (!$this->GetCapa(false, Capa::ADDITIONAL_ACCOUNTS, $oMainAccount)) {
|
||||
if (!$this->GetCapa(Capa::ADDITIONAL_ACCOUNTS)) {
|
||||
return $this->FalseResponse(__FUNCTION__);
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ trait Accounts
|
|||
{
|
||||
$oMainAccount = $this->getMainAccountFromToken();
|
||||
|
||||
if (!$this->GetCapa(false, Capa::ADDITIONAL_ACCOUNTS, $oMainAccount)) {
|
||||
if (!$this->GetCapa(Capa::ADDITIONAL_ACCOUNTS)) {
|
||||
return $this->FalseResponse(__FUNCTION__);
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,7 @@ trait Accounts
|
|||
{
|
||||
$oAccount = $this->getAccountFromToken();
|
||||
|
||||
if (!$this->GetCapa(false, Capa::IDENTITIES, $oAccount)) {
|
||||
if (!$this->GetCapa(Capa::IDENTITIES)) {
|
||||
return $this->FalseResponse(__FUNCTION__);
|
||||
}
|
||||
|
||||
|
@ -254,7 +254,7 @@ trait Accounts
|
|||
public function GetIdentities(Account $oAccount): array
|
||||
{
|
||||
// A custom name for a single identity is also stored in this system
|
||||
$allowMultipleIdentities = $this->GetCapa(false, Capa::IDENTITIES, $oAccount);
|
||||
$allowMultipleIdentities = $this->GetCapa(Capa::IDENTITIES);
|
||||
|
||||
// Get all identities
|
||||
$identities = $this->IdentitiesProvider()->GetIdentities($oAccount, $allowMultipleIdentities);
|
||||
|
|
|
@ -18,7 +18,7 @@ trait Filters
|
|||
{
|
||||
$oAccount = $this->getAccountFromToken();
|
||||
|
||||
if (!$this->GetCapa(false, Capa::SIEVE, $oAccount))
|
||||
if (!$this->GetCapa(Capa::SIEVE, $oAccount))
|
||||
{
|
||||
return $this->FalseResponse(__FUNCTION__);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ trait Filters
|
|||
{
|
||||
$oAccount = $this->getAccountFromToken();
|
||||
|
||||
if (!$this->GetCapa(false, Capa::SIEVE, $oAccount)) {
|
||||
if (!$this->GetCapa(Capa::SIEVE, $oAccount)) {
|
||||
return $this->FalseResponse(__FUNCTION__);
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ trait Filters
|
|||
{
|
||||
$oAccount = $this->getAccountFromToken();
|
||||
|
||||
if (!$this->GetCapa(false, Capa::SIEVE, $oAccount)) {
|
||||
if (!$this->GetCapa(Capa::SIEVE, $oAccount)) {
|
||||
return $this->FalseResponse(__FUNCTION__);
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ trait Filters
|
|||
{
|
||||
$oAccount = $this->getAccountFromToken();
|
||||
|
||||
if (!$this->GetCapa(false, Capa::SIEVE, $oAccount)) {
|
||||
if (!$this->GetCapa(Capa::SIEVE, $oAccount)) {
|
||||
return $this->FalseResponse(__FUNCTION__);
|
||||
}
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ trait Folders
|
|||
$this->Plugins()->RunHook('filter.folders-complete', array($oAccount, $oFolderCollection));
|
||||
|
||||
$aQuota = null;
|
||||
if ($this->GetCapa(false, Capa::QUOTA, $this->getAccountFromToken())) {
|
||||
if ($this->GetCapa(Capa::QUOTA)) {
|
||||
try {
|
||||
// $aQuota = $this->MailClient()->Quota();
|
||||
$aQuota = $this->MailClient()->QuotaRoot();
|
||||
|
|
|
@ -210,7 +210,7 @@ trait Response
|
|||
$mResult['Html'] = $mResponse->Html();
|
||||
$mResult['Plain'] = $mResponse->Plain();
|
||||
|
||||
// $this->GetCapa(false, Capa::OPEN_PGP) || $this->GetCapa(false, Capa::GNUPG)
|
||||
// $this->GetCapa(Capa::OPEN_PGP) || $this->GetCapa(Capa::GNUPG)
|
||||
$mResult['isPgpEncrypted'] = $mResponse->isPgpEncrypted();
|
||||
$mResult['PgpSigned'] = $mResponse->PgpSigned();
|
||||
$mResult['PgpEncrypted'] = $mResponse->PgpEncrypted();
|
||||
|
@ -248,7 +248,7 @@ trait Response
|
|||
{
|
||||
$mResult = $mResponse->jsonSerialize();
|
||||
$mResult['Framed'] = $this->isFileHasFramedPreview($mResult['FileName']);
|
||||
$mResult['IsThumbnail'] = $this->GetCapa(false, Capa::ATTACHMENT_THUMBNAILS) && $this->isFileHasThumbnail($mResult['FileName']);
|
||||
$mResult['IsThumbnail'] = $this->GetCapa(Capa::ATTACHMENT_THUMBNAILS) && $this->isFileHasThumbnail($mResult['FileName']);
|
||||
$mResult['Download'] = Utils::EncodeKeyValuesQ(array(
|
||||
'V' => APP_VERSION,
|
||||
'Account' => $this->getAccountFromToken()->Hash(),
|
||||
|
|
|
@ -11,7 +11,7 @@ trait Themes
|
|||
$sTheme = $this->Config()->Get('webmail', 'theme', 'Default');
|
||||
if (!$bAdmin
|
||||
&& ($oAccount = $this->getAccountFromToken(false))
|
||||
&& $this->GetCapa(false, \RainLoop\Enumerations\Capa::THEMES, $oAccount)
|
||||
&& $this->GetCapa(\RainLoop\Enumerations\Capa::THEMES)
|
||||
&& ($oSettingsLocal = $this->SettingsProvider(true)->Load($oAccount))) {
|
||||
$sTheme = (string) $oSettingsLocal->GetConf('Theme', $sTheme);
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ trait User
|
|||
*/
|
||||
public function DoAttachmentsActions() : array
|
||||
{
|
||||
if (!$this->GetCapa(false, Capa::ATTACHMENTS_ACTIONS))
|
||||
if (!$this->GetCapa(Capa::ATTACHMENTS_ACTIONS))
|
||||
{
|
||||
return $this->FalseResponse(__FUNCTION__);
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ trait User
|
|||
$oSettings->SetConf('Language', $this->ValidateLanguage($oConfig->Get('webmail', 'language', 'en')));
|
||||
}
|
||||
|
||||
if ($this->GetCapa(false, Capa::THEMES, $oAccount))
|
||||
if ($this->GetCapa(Capa::THEMES))
|
||||
{
|
||||
$this->setSettingsFromParams($oSettingsLocal, 'Theme', 'string', function ($sTheme) use ($self) {
|
||||
return $self->ValidateTheme($sTheme);
|
||||
|
@ -367,7 +367,7 @@ trait User
|
|||
{
|
||||
$oAccount = $this->initMailClientConnection();
|
||||
|
||||
if (!$this->GetCapa(false, Capa::QUOTA, $oAccount))
|
||||
if (!$this->GetCapa(Capa::QUOTA))
|
||||
{
|
||||
return $this->DefaultResponse(__FUNCTION__, array(0, 0, 0, 0));
|
||||
}
|
||||
|
@ -463,7 +463,7 @@ trait User
|
|||
{
|
||||
$oAccount = $this->getAccountFromToken();
|
||||
|
||||
if (!$this->GetCapa(false, Capa::USER_BACKGROUND, $oAccount))
|
||||
if (!$this->GetCapa(Capa::USER_BACKGROUND))
|
||||
{
|
||||
return $this->FalseResponse(__FUNCTION__);
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ trait UserAuth
|
|||
{
|
||||
$this->Http()->ServerNoCache();
|
||||
$oMainAccount = $this->getMainAccountFromToken(false);
|
||||
if ($sEmail && $oMainAccount && $this->GetCapa(false, \RainLoop\Enumerations\Capa::ADDITIONAL_ACCOUNTS, $oMainAccount)) {
|
||||
if ($sEmail && $oMainAccount && $this->GetCapa(\RainLoop\Enumerations\Capa::ADDITIONAL_ACCOUNTS)) {
|
||||
$oAccount = null;
|
||||
if ($oMainAccount->Email() === $sEmail) {
|
||||
$this->SetAdditionalAuthToken($oAccount);
|
||||
|
|
Loading…
Reference in a new issue