Skip to content

Commit

Permalink
Improve Capa handling
Browse files Browse the repository at this point in the history
  • Loading branch information
the-djmaze committed Feb 26, 2024
1 parent 6e1aae3 commit 118587d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
34 changes: 18 additions & 16 deletions snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace RainLoop;

use RainLoop\Enumerations\Capa;

class Actions
{
use Actions\Admin;
Expand Down Expand Up @@ -471,7 +473,7 @@ public function AddressBookProvider(?Model\Account $oAccount = null): Providers\
$oDriver = null;
try {
// if ($this->oConfig->Get('contacts', 'enable', false)) {
if ($this->GetCapa(Enumerations\Capa::CONTACTS)) {
if ($this->GetCapa(Capa::CONTACTS)) {
$oDriver = $this->fabrica('address-book', $oAccount);
}
if ($oAccount && $oDriver) {
Expand Down Expand Up @@ -712,7 +714,7 @@ public function AppData(bool $bAdmin): array
]);

$aAttachmentsActions = array();
if ($this->GetCapa(Enumerations\Capa::ATTACHMENTS_ACTIONS)) {
if ($this->GetCapa(Capa::ATTACHMENTS_ACTIONS)) {
if (\class_exists('PharData') || \class_exists('ZipArchive')) {
$aAttachmentsActions[] = 'zip';
}
Expand Down Expand Up @@ -809,7 +811,7 @@ public function AppData(bool $bAdmin): array
$aResult['fontSerif'] = $oSettings->GetConf('fontSerif', '');
$aResult['fontMono'] = $oSettings->GetConf('fontMono', '');

if ($this->GetCapa(Enumerations\Capa::USER_BACKGROUND)) {
if ($this->GetCapa(Capa::USER_BACKGROUND)) {
$aResult['userBackgroundName'] = (string)$oSettings->GetConf('UserBackgroundName', '');
$aResult['userBackgroundHash'] = (string)$oSettings->GetConf('UserBackgroundHash', '');
}
Expand Down Expand Up @@ -971,26 +973,26 @@ public function Capa(bool $bAdmin, ?Model\Account $oAccount = null): array
if (!$aResult) {
$oConfig = $this->oConfig;
$aResult = array(
'AdditionalAccounts' => (bool) $oConfig->Get('webmail', 'allow_additional_accounts', false),
'AttachmentThumbnails' => (bool) $oConfig->Get('interface', 'show_attachment_thumbnail', true)
Capa::ADDITIONAL_ACCOUNTS => (bool) $oConfig->Get('webmail', 'allow_additional_accounts', false),
Capa::ATTACHMENT_THUMBNAILS => (bool) $oConfig->Get('interface', 'show_attachment_thumbnail', true)
&& ($bAdmin
|| \extension_loaded('gd')
|| \extension_loaded('gmagick')
|| \extension_loaded('imagick')
),
'AttachmentsActions' => (bool) $oConfig->Get('capa', 'attachments_actions', false),
'Contacts' => (bool) $oConfig->Get('contacts', 'enable', false),
'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' => false, // See Kolab plugin
'OpenPGP' => (bool) $oConfig->Get('security', 'openpgp', false),
'Sieve' => false,
'Themes' => (bool) $oConfig->Get('webmail', 'allow_themes', false),
'UserBackground' => (bool) $oConfig->Get('webmail', 'allow_user_background', false)
Capa::ATTACHMENTS_ACTIONS => (bool) $oConfig->Get('capa', 'attachments_actions', false),
Capa::CONTACTS => (bool) $oConfig->Get('contacts', 'enable', false),
Capa::DANGEROUS_ACTIONS => (bool) $oConfig->Get('capa', 'dangerous_actions', true),
Capa::GNUPG => (bool) $oConfig->Get('security', 'openpgp', false) && \SnappyMail\PGP\GnuPG::isSupported(),
Capa::IDENTITIES => (bool) $oConfig->Get('webmail', 'allow_additional_identities', false),
Capa::OPENPGP => (bool) $oConfig->Get('security', 'openpgp', false),
Capa::SIEVE => false,
Capa::THEMES => (bool) $oConfig->Get('webmail', 'allow_themes', false),
Capa::USER_BACKGROUND => (bool) $oConfig->Get('webmail', 'allow_user_background', false),
'Kolab' => false, // See Kolab plugin
);
}
$aResult['Sieve'] = $bAdmin || ($oAccount && $oAccount->Domain()->UseSieve());
$aResult[Capa::SIEVE] = $bAdmin || ($oAccount && $oAccount->Domain()->UseSieve());
return $aResult;
}

Expand Down
14 changes: 7 additions & 7 deletions snappymail/v/0.0.0/app/libraries/RainLoop/Enumerations/Capa.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

abstract class Capa
{
const ADDITIONAL_ACCOUNTS = 'AdditionalAccounts';
const ATTACHMENTS_ACTIONS = 'AttachmentsActions';
const ATTACHMENT_THUMBNAILS = 'AttachmentThumbnails';
const CONTACTS = 'Contacts';
const DANGEROUS_ACTIONS = 'DangerousActions';
const GNUPG = 'GnuPG';
const IDENTITIES = 'Identities';
const OPENPGP = 'OpenPGP';
const SIEVE = 'Sieve';
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 ATTACHMENTS_ACTIONS = 'AttachmentsActions';
const DANGEROUS_ACTIONS = 'DangerousActions';
}

0 comments on commit 118587d

Please sign in to comment.