Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
fix(Admin/EmailAccount): disable sieve tabs if no dovecot_master_user…
Browse files Browse the repository at this point in the history
…s table
  • Loading branch information
ccheng-dev committed Jul 21, 2021
1 parent 7557a37 commit 24c7d20
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
8 changes: 4 additions & 4 deletions tine20/Admin/Controller/EmailAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@ public function update(Tinebase_Record_Interface $_record, $_additionalArguments
$currentAccount = $this->get($_record->getId(), null, true, $_updateDeleted);

$raii = false;
if ($this->_sieveBackendSupportsMasterPassword($_record)) {
if ($this->sieveBackendSupportsMasterPassword($_record)) {
$raii = $this->prepareAccountForSieveAdminAccess($_record->getId());
}

$this->_inspectBeforeUpdate($_record, $currentAccount);
$account = $this->_backend->update($_record);
$this->_inspectAfterUpdate($account, $_record, $currentAccount);

if ($raii && $this->_sieveBackendSupportsMasterPassword($_record)) {
if ($raii && $this->sieveBackendSupportsMasterPassword($_record)) {
$this->removeSieveAdminAccess();
unset($raii);
}
Expand All @@ -170,9 +170,9 @@ public function update(Tinebase_Record_Interface $_record, $_additionalArguments
* @param $account
* @return bool
*/
protected function _sieveBackendSupportsMasterPassword($account)
public function sieveBackendSupportsMasterPassword($account = null)
{
if (! in_array($account->type, [
if ($account && ! in_array($account->type, [
Felamimail_Model_Account::TYPE_SYSTEM,
Felamimail_Model_Account::TYPE_SHARED,
Felamimail_Model_Account::TYPE_USER_INTERNAL,
Expand Down
7 changes: 7 additions & 0 deletions tine20/Admin/Frontend/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class Admin_Frontend_Json extends Tinebase_Frontend_Json_Abstract
*/
protected $_manageSAM = false;

/**
* @var bool
*/
protected $_hasMasterSieveAccess;

/**
* constructs Admin_Frontend_Json
*/
Expand All @@ -35,6 +40,7 @@ public function __construct()
if (isset(Tinebase_Core::getConfig()->samba)) {
$this->_manageSAM = Tinebase_Core::getConfig()->samba->get('manageSAM', false);
}
$this->_hasMasterSieveAccess = Admin_Controller_EmailAccount::getInstance()->sieveBackendSupportsMasterPassword();
}

/**
Expand All @@ -49,6 +55,7 @@ public function getRegistryData()

$registryData = array(
'manageSAM' => $this->_manageSAM,
'masterSieveAccess' => $this->_hasMasterSieveAccess,
'defaultPrimaryGroup' => Tinebase_Group::getInstance()->getDefaultGroup()->toArray(),
'defaultInternalAddressbook' => (
isset($appConfigDefaults[Admin_Model_Config::DEFAULTINTERNALADDRESSBOOK])
Expand Down
18 changes: 13 additions & 5 deletions tine20/Felamimail/js/AccountEditDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,7 @@ Tine.Felamimail.AccountEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
this.grantsGrid.setValue(this.record.get('grants'));
}

if (this.isSystemAccount()) {
this.loadVacationRecord();
this.loadRuleRecord();
}

this.disableSieveTabs();
this.disableFormFields();
},

Expand Down Expand Up @@ -213,6 +209,18 @@ Tine.Felamimail.AccountEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
);
}
},

disableSieveTabs() {
if (this.asAdminModule && !Tine.Admin.registry.get('masterSieveAccess')) {
this.vacationPanel.setDisabled(true);
this.rulesGridPanel.setDisabled(true);
} else {
if (this.isSystemAccount()) {
this.loadVacationRecord();
this.loadRuleRecord();
}
}
},

isSystemAccount: function() {
return this.record.get('type') === 'system' || this.record.get('type') === 'shared' || this.record.get('type') === 'userInternal' || this.record.get('type') === 'adblist';
Expand Down

0 comments on commit 24c7d20

Please sign in to comment.