Restructure Capa

This commit is contained in:
the-djmaze 2022-02-24 12:22:27 +01:00
parent 5990addfef
commit e7c7b8ed53
15 changed files with 74 additions and 140 deletions

View file

@ -1165,89 +1165,36 @@ class Actions
public function Capa(bool $bAdmin, ?Model\Account $oAccount = null): array
{
static $aResult;
if ($aResult && !$oAccount) {
return $aResult;
if (!$aResult) {
$oConfig = $this->oConfig;
$aResult = array(
'AutoLogout' => true,
'AdditionalAccounts' => (bool) $oConfig->Get('webmail', 'allow_additional_accounts', false),
'AttachmentThumbnails' => (bool) $oConfig->Get('interface', 'show_attachment_thumbnail', true),
'AttachmentsActions' => (bool) $oConfig->Get('capa', 'attachments_actions', false),
'Contacts' => (bool) $oConfig->Get('capa', 'contacts', true),
'DangerousActions' => (bool) $oConfig->Get('capa', 'dangerous_actions', true),
'GnuPG' => (bool) $oConfig->Get('security', 'openpgp', false) && \SnappyMail\PGP\GnuPG::isSupported(),
'Identities' => (bool) $oConfig->Get('webmail', 'allow_additional_identities', false),
'Kolab' => (bool) $oConfig->Get('labs', 'kolab_enabled', false),
'MessageActions' => (bool) $oConfig->Get('capa', 'message_actions', true),
'OpenPGP' => (bool) $oConfig->Get('security', 'openpgp', false),
'Prefetch' => (bool) $oConfig->Get('labs', 'allow_prefetch', false),
'Quota' => (bool) $oConfig->Get('capa', 'quota', true),
'Search' => (bool) $oConfig->Get('capa', 'search', true),
'SearchAdv' => (bool) $oConfig->Get('capa', 'search', true) && $oConfig->Get('capa', 'search_adv', true),
'Sieve' => false,
'Themes' => (bool) $oConfig->Get('webmail', 'allow_themes', false),
'UserBackground' => (bool) $oConfig->Get('webmail', 'allow_user_background', false)
);
}
$oConfig = $this->oConfig;
$aResult = array(
Enumerations\Capa::AUTOLOGOUT
);
if ($oConfig->Get('capa', 'dangerous_actions', true)) {
$aResult[] = Enumerations\Capa::DANGEROUS_ACTIONS;
}
if ($oConfig->Get('capa', 'quota', true)) {
$aResult[] = Enumerations\Capa::QUOTA;
}
if ($oConfig->Get('webmail', 'allow_additional_accounts', false)) {
$aResult[] = Enumerations\Capa::ADDITIONAL_ACCOUNTS;
}
if ($oConfig->Get('webmail', 'allow_additional_identities', false)) {
$aResult[] = Enumerations\Capa::IDENTITIES;
}
if ($oConfig->Get('webmail', 'allow_themes', false)) {
$aResult[] = Enumerations\Capa::THEMES;
}
if ($oConfig->Get('webmail', 'allow_user_background', false)) {
$aResult[] = Enumerations\Capa::USER_BACKGROUND;
}
if ($oConfig->Get('security', 'openpgp', false)) {
$aResult[] = Enumerations\Capa::OPEN_PGP;
if (\SnappyMail\PGP\GnuPG::isSupported()) {
$aResult[] = Enumerations\Capa::GNUPG;
}
}
if ($bAdmin || ($oAccount && $oAccount->Domain()->UseSieve())) {
$aResult[] = Enumerations\Capa::SIEVE;
}
if ($oConfig->Get('capa', 'attachments_actions', false)) {
$aResult[] = Enumerations\Capa::ATTACHMENTS_ACTIONS;
}
if ($oConfig->Get('capa', 'message_actions', true)) {
$aResult[] = Enumerations\Capa::MESSAGE_ACTIONS;
}
if ($oConfig->Get('capa', 'contacts', true)) {
$aResult[] = Enumerations\Capa::CONTACTS;
}
if ($oConfig->Get('capa', 'search', true)) {
$aResult[] = Enumerations\Capa::SEARCH;
if ($oConfig->Get('capa', 'search_adv', true)) {
$aResult[] = Enumerations\Capa::SEARCH_ADV;
}
}
if ($oConfig->Get('interface', 'show_attachment_thumbnail', true)) {
$aResult[] = Enumerations\Capa::ATTACHMENT_THUMBNAILS;
}
if ($oConfig->Get('labs', 'allow_prefetch', false)) {
$aResult[] = Enumerations\Capa::PREFETCH;
}
if ($oConfig->Get('labs', 'kolab_enabled', false)) {
$aResult[] = Enumerations\Capa::KOLAB;
}
$aResult['Sieve'] = $bAdmin || ($oAccount && $oAccount->Domain()->UseSieve());
return $aResult;
}
public function GetCapa(string $sName, ?Model\Account $oAccount = null): bool
{
return \in_array($sName, $this->Capa(false, $oAccount));
return !empty($this->Capa(false, $oAccount)[$sName]);
}
public function etag(string $sKey): string

View file

@ -4,23 +4,22 @@ namespace RainLoop\Enumerations;
class Capa
{
const GNUPG = 'GNUPG';
const OPEN_PGP = 'OPEN_PGP';
const PREFETCH = 'PREFETCH';
const THEMES = 'THEMES';
const USER_BACKGROUND = 'USER_BACKGROUND';
const SIEVE = 'SIEVE';
const ATTACHMENT_THUMBNAILS = 'ATTACHMENT_THUMBNAILS';
const ADDITIONAL_ACCOUNTS = 'ADDITIONAL_ACCOUNTS';
const IDENTITIES = 'IDENTITIES';
const CONTACTS = 'CONTACTS';
const SEARCH = 'SEARCH';
const SEARCH_ADV = 'SEARCH_ADV';
const QUOTA = 'QUOTA';
const TEMPLATES = 'TEMPLATES';
const MESSAGE_ACTIONS = 'MESSAGE_ACTIONS';
const ATTACHMENTS_ACTIONS = 'ATTACHMENTS_ACTIONS';
const DANGEROUS_ACTIONS = 'DANGEROUS_ACTIONS';
const AUTOLOGOUT = 'AUTOLOGOUT';
const KOLAB = 'KOLAB';
const GNUPG = 'GnuPG';
const OPEN_PGP = 'OpenPGP';
const PREFETCH = 'Prefetch';
const THEMES = 'Themes';
const USER_BACKGROUND = 'UserBackground';
const SIEVE = 'Sieve';
const ATTACHMENT_THUMBNAILS = 'AttachmentThumbnails';
const ADDITIONAL_ACCOUNTS = 'AdditionalAccounts';
const IDENTITIES = 'Identities';
const CONTACTS = 'Contacts';
const SEARCH = 'Search';
const SEARCH_ADV = 'SearchAdv';
const QUOTA = 'Quota';
const MESSAGE_ACTIONS = 'MessageActions';
const ATTACHMENTS_ACTIONS = 'AttachmentsActions';
const DANGEROUS_ACTIONS = 'DangerousActions';
const AUTOLOGOUT = 'AutoLogout';
const KOLAB = 'Kolab';
}

View file

@ -10,7 +10,7 @@
</div>
<br>
<br>
<div class="form-horizontal" data-bind="visible: capaUserBackground">
<div class="form-horizontal" data-bind="visible: background.enabled">
<div class="legend" data-i18n="SETTINGS_THEMES/LEGEND_THEMES_CUSTOM"></div>
<div class="control-group g-ui-user-select-none">
<div class="row" data-bind="visible: '' !== background.error()" style="margin-left: 0; margin-bottom: 10px;">