diff --git a/tests/tine20/Admin/Frontend/Json/EmailAccountTest.php b/tests/tine20/Admin/Frontend/Json/EmailAccountTest.php index e6f11ef32d1..305a42f8732 100644 --- a/tests/tine20/Admin/Frontend/Json/EmailAccountTest.php +++ b/tests/tine20/Admin/Frontend/Json/EmailAccountTest.php @@ -442,24 +442,10 @@ public function testSaveEmailAccountWithSieveScript() $account->sieve_rules = []; $account->sieve_vacation = $vacationData; - $account->sieve_forwardings = new Tinebase_Record_RecordSet(Felamimail_Model_Sieve_Forward::class, [ - [ - 'account_id' => $account->getId(), - 'email' => 'test1@mail.test', - 'id' => Tinebase_Record_Abstract::generateUID(), - ], [ - 'account_id' => $account->getId(), - 'email' => 'test2@mail.test', - 'id' => Tinebase_Record_Abstract::generateUID(), - ] - ]); $this->_json->saveEmailAccount($account->toArray()); $script = $this->_json->getSieveScript($account->getId()); $this->assertStringContainsString('currentdate', $script); - $this->assertStringContainsString('test1@mail.test', $script); - $this->assertStringContainsString('test2@mail.test', $script); - $account->sieve_rules = $this->_getSieveRuleData(); $this->_json->saveEmailAccount($account->toArray()); diff --git a/tests/tine20/Felamimail/Sieve/Backend/ScriptTest.php b/tests/tine20/Felamimail/Sieve/Backend/ScriptTest.php index 481fb7943ef..871d59fbc7f 100644 --- a/tests/tine20/Felamimail/Sieve/Backend/ScriptTest.php +++ b/tests/tine20/Felamimail/Sieve/Backend/ScriptTest.php @@ -138,25 +138,6 @@ public function testAutoReplyAction() $this->assertStringContainsString('Felamimail_Sieve_Rule', $sieveScript); } - - public function testForwarding() - { - $script = new Felamimail_Sieve_Backend_Script(); - $forward = new Felamimail_Sieve_Forward(); - - $testEmails = [ - 'test1@mail.test', - 'test2@mail.test', - ]; - $forward->setAddresses($testEmails); - $script->setForward($forward); - $sieveScript = $script->getSieve(); - $this->assertStringContainsString('require ["envelope", "copy", "reject", "editheader", "variables"]', $sieveScript, - 'editheader extension is required in script: ' . $sieveScript); - $this->assertStringContainsString('test1@mail.test', $sieveScript); - $this->assertStringContainsString('test2@mail.test', $sieveScript); - } - public function testInvalidRule() { $script = new Felamimail_Sieve_Backend_Script(); diff --git a/tests/tine20/Tinebase/ApplicationTest.php b/tests/tine20/Tinebase/ApplicationTest.php index 9a092796772..c7c8216098a 100644 --- a/tests/tine20/Tinebase/ApplicationTest.php +++ b/tests/tine20/Tinebase/ApplicationTest.php @@ -355,7 +355,6 @@ public function testGetModelsOfAllApplications() Felamimail_Model_MessageFileSuggestion::class, Felamimail_Model_MessagePipeConfig::class, Felamimail_Model_PreparedMessagePart::class, - Felamimail_Model_Sieve_Forward::class, Felamimail_Model_Sieve_Rule::class, Felamimail_Model_Sieve_ScriptPart::class, Felamimail_Model_Sieve_Vacation::class, diff --git a/tine20/Admin/js/user/EditDialog.js b/tine20/Admin/js/user/EditDialog.js index e6b5359b741..4082b9dabc0 100644 --- a/tine20/Admin/js/user/EditDialog.js +++ b/tine20/Admin/js/user/EditDialog.js @@ -714,7 +714,7 @@ Tine.Admin.UserEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, { } this.initAliasesGrid(); - this.forwardsGrid = this.initForwardsGrid(); + this.initForwardsGrid(); return [ [this.aliasesGrid, this.forwardsGrid], @@ -822,7 +822,7 @@ Tine.Admin.UserEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, { let record = this.record ?? additionConfig.record; const config = _.assign(this.getCommonConfig(), additionConfig); - return new Tine.widgets.grid.QuickaddGridPanel( + this.forwardsGrid = new Tine.widgets.grid.QuickaddGridPanel( Ext.apply({ onNewentry: function(value) { if (value.email === record.get('accountEmailAddress') || aliasesStore.find('email', value.email) !== -1) { @@ -851,6 +851,8 @@ Tine.Admin.UserEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, { }]) }, config) ); + + return this.forwardsGrid; }, initPasswordConfirmWindow: function() { diff --git a/tine20/Felamimail/Config.php b/tine20/Felamimail/Config.php index c3972d9341a..1005dd5fd93 100644 --- a/tine20/Felamimail/Config.php +++ b/tine20/Felamimail/Config.php @@ -338,7 +338,7 @@ class Felamimail_Config extends Tinebase_Config_Abstract self::DESCRIPTION => 'Move notifications to a subfolder via sieve', //_('Move notifications to a subfolder via sieve') self::TYPE => self::TYPE_BOOL, - self::DEFAULT_STR => true, + self::DEFAULT_STR => false, ], self::FEATURE_AUTOSAVE_DRAFTS => [ self::LABEL => 'Auto-Save Drafts', diff --git a/tine20/Felamimail/Controller/Account.php b/tine20/Felamimail/Controller/Account.php index b19c0732902..3de5ecddad4 100644 --- a/tine20/Felamimail/Controller/Account.php +++ b/tine20/Felamimail/Controller/Account.php @@ -1042,7 +1042,6 @@ protected function _beforeUpdateSystemAccount($_record, $_oldRecord) 'sieve_custom', 'sieve_vacation', 'sieve_rules', - 'sieve_forwardings', 'sent_folder', 'trash_folder', 'drafts_folder', @@ -1310,11 +1309,12 @@ protected function _afterUpdateSetSieve($updatedRecord, $record, $currentRecord) ) { Felamimail_Controller_Sieve::getInstance()->updateAutoMoveNotificationScript($updatedRecord); } - $sieveRecord = is_array($record->sieve_vacation) ? new Felamimail_Model_Sieve_Vacation($record->sieve_vacation, TRUE) : null; - $ruleRecords = is_array($record->sieve_rules) ? new Tinebase_Record_RecordSet(Felamimail_Model_Sieve_Rule::class, array_values($record->sieve_rules)) : null; - $forwardRecords = $record->sieve_forwardings; - if ($sieveRecord || $ruleRecords || $forwardRecords) { - $script = Felamimail_Controller_Sieve::getInstance()->setSieveScript($updatedRecord, $sieveRecord, $ruleRecords, $forwardRecords); + + if (is_array($record->sieve_vacation) && is_array($record->sieve_rules)) { + $sieveRecord = new Felamimail_Model_Sieve_Vacation($record->sieve_vacation, TRUE); + $ruleRecords = new Tinebase_Record_RecordSet(Felamimail_Model_Sieve_Rule::class, array_values($record->sieve_rules)); + + $script = Felamimail_Controller_Sieve::getInstance()->setSieveScript($updatedRecord, $sieveRecord, $ruleRecords); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug( __METHOD__ . '::' . __LINE__ . ' Updated sieve script : ' . $script); diff --git a/tine20/Felamimail/Controller/Sieve.php b/tine20/Felamimail/Controller/Sieve.php index 82f4fd8b751..04182f1e260 100644 --- a/tine20/Felamimail/Controller/Sieve.php +++ b/tine20/Felamimail/Controller/Sieve.php @@ -536,11 +536,7 @@ public function getRules($_accountId) * @throws Felamimail_Exception_SievePutScriptFail * @throws Tinebase_Exception_AccessDenied */ - public function setSieveScript($_accountId, - Felamimail_Model_Sieve_Vacation $_vacation = null, - Tinebase_Record_RecordSet $_rules = null, - Tinebase_Record_RecordSet $_forwards = null - ) + public function setSieveScript($_accountId, Felamimail_Model_Sieve_Vacation $_vacation = null, Tinebase_Record_RecordSet $_rules = null) { $account = $_accountId instanceof Felamimail_Model_Account ? $_accountId @@ -551,12 +547,6 @@ public function setSieveScript($_accountId, $script = $this->getSieveScript($account); - if ($_forwards && count($_forwards) > 0) { - $forward = new Felamimail_Sieve_Forward(); - $forward->setAddresses($_forwards->email); - $script->setForward($forward); - } - if ($_vacation) { $this->_addVacationUserData($_vacation, $account); $this->_checkCapabilities($_vacation); diff --git a/tine20/Felamimail/Controller/Sieve/Forward.php b/tine20/Felamimail/Controller/Sieve/Forward.php deleted file mode 100644 index add61730940..00000000000 --- a/tine20/Felamimail/Controller/Sieve/Forward.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @copyright Copyright (c) 2024 Metaways Infosystems GmbH (http://www.metaways.de) - * - */ - -/** - * Forward controller for Felamimail sieve - * - * @package Felamimail - * @subpackage Controller - */ -class Felamimail_Controller_Sieve_Forward extends Tinebase_Controller_Record_Abstract -{ - use Tinebase_Controller_SingletonTrait; - - /** - * the constructor - * - */ - protected function __construct() - { - $this->_applicationName = Felamimail_Config::APP_NAME; - $this->_modelName = Felamimail_Model_Sieve_Forward::class; - $this->_doRightChecks = false; - $this->_purgeRecords = true; - $this->_doContainerACLChecks = false; - - $this->_backend = new Tinebase_Backend_Sql([ - 'modelName' => $this->_modelName, - 'tableName' => 'felamimail_sieve_forward', - 'modlogActive' => true - ]); - } -} diff --git a/tine20/Felamimail/Frontend/Json.php b/tine20/Felamimail/Frontend/Json.php index 793612a74a5..df340310375 100644 --- a/tine20/Felamimail/Frontend/Json.php +++ b/tine20/Felamimail/Frontend/Json.php @@ -23,7 +23,6 @@ class Felamimail_Frontend_Json extends Tinebase_Frontend_Json_Abstract protected $_configuredModels = [ 'Account', 'Signature', - Felamimail_Model_Sieve_Forward::MODEL_NAME_PART, ]; /***************************** folder funcs *******************************/ diff --git a/tine20/Felamimail/Model/Account.php b/tine20/Felamimail/Model/Account.php index b9c7494a8b6..46fdf228b17 100644 --- a/tine20/Felamimail/Model/Account.php +++ b/tine20/Felamimail/Model/Account.php @@ -31,7 +31,6 @@ * @property string $sieve_notification_move * @property string $sieve_notification_move_folder * @property string $sieve_hostname - * @property string $sieve_forwardings * @property string $migration_approved * @property string $message_sent_copy_behavior * @property Tinebase_Record_Abstract $contact_id @@ -520,25 +519,6 @@ class Felamimail_Model_Account extends Tinebase_EmailUser_Model_Account Zend_Filter_Input::ALLOW_EMPTY => true, ], ], - 'sieve_forwardings' => [ - self::LABEL => 'Sieve forwarding email addresses', // _('Sieve forwarding email addresses') - self::TYPE => self::TYPE_RECORDS, - self::VALIDATORS => [ - Zend_Filter_Input::ALLOW_EMPTY => true, - ], - self::OMIT_MOD_LOG => true, - self::SYSTEM => true, - self::NULLABLE => true, - self::DEFAULT_VAL => null, - self::CONFIG => [ - self::APP_NAME => 'Felamimail', - self::MODEL_NAME => Felamimail_Model_Sieve_Forward::MODEL_NAME_PART, - self::REF_ID_FIELD => 'account_id', - self::RECORD_CLASS_NAME => Felamimail_Model_Sieve_Forward::class, - self::CONTROLLER_CLASS_NAME => Felamimail_Controller_Sieve_Forward::class, - self::DEPENDENT_RECORDS => true, - ], - ], 'sieve_hostname' => [ self::TYPE => self::TYPE_STRING, self::LENGTH => 255, diff --git a/tine20/Felamimail/Model/Sieve/Forward.php b/tine20/Felamimail/Model/Sieve/Forward.php deleted file mode 100644 index 12c1c4d4876..00000000000 --- a/tine20/Felamimail/Model/Sieve/Forward.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @copyright Copyright (c) 2024 Metaways Infosystems GmbH (http://www.metaways.de) - * - */ - -/** - * class to hold Forward data - * - * @package Felamimail - */ -class Felamimail_Model_Sieve_Forward extends Tinebase_Record_NewAbstract -{ - public const FLD_ACCOUNT_ID = 'account_id'; - public const FLD_EMAIL = 'email'; - - public const MODEL_NAME_PART = 'Sieve_Forward'; - public const TABLE_NAME = 'felamimail_sieve_forward'; - - /** - * holds the configuration object (must be declared in the concrete class) - * - * @var Tinebase_ModelConfiguration - */ - protected static $_configurationObject = null; - - /** - * Holds the model configuration (must be assigned in the concrete class) - * - * @var array - */ - protected static $_modelConfiguration = [ - self::VERSION => 1, - self::MODLOG_ACTIVE => true, - self::APP_NAME => Felamimail_Config::APP_NAME, - self::MODEL_NAME => self::MODEL_NAME_PART, - - self::TABLE => [ - self::NAME => self::TABLE_NAME, - self::INDEXES => [ - self::FLD_ACCOUNT_ID => [ - self::COLUMNS => [self::FLD_ACCOUNT_ID] - ] - ] - ], - - self::FIELDS => [ - self::FLD_ACCOUNT_ID => [ - self::TYPE => self::TYPE_STRING, - self::LENGTH => 255, - self::NULLABLE => true, - ], - self::FLD_EMAIL => [ - self::TYPE => self::TYPE_STRING, - self::LENGTH => 255, - self::DISABLED => true, - self::VALIDATORS => [ - Zend_Filter_Input::ALLOW_EMPTY => false, - Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_REQUIRED, - ], - ], - ], - ]; - - /** - * set from sieve forward object - * - * @param Felamimail_Sieve_Forward $fsf - */ - public function setFromFSF(Felamimail_Sieve_Forward $fsf) - { - $data = $fsf->toArray(); - $this->setFromArray($data); - } -} diff --git a/tine20/Felamimail/Model/Sieve/ScriptPart.php b/tine20/Felamimail/Model/Sieve/ScriptPart.php index ae7fb0cc80a..c8ff011cf78 100644 --- a/tine20/Felamimail/Model/Sieve/ScriptPart.php +++ b/tine20/Felamimail/Model/Sieve/ScriptPart.php @@ -37,9 +37,6 @@ class Felamimail_Model_Sieve_ScriptPart extends Tinebase_Record_Abstract /** @var string */ const TYPE_CUSTOM = 'custom'; - - /** @var string */ - const TYPE_FORWARD = 'forward'; /** * key in $_validators/$_properties array for the field which diff --git a/tine20/Felamimail/Setup/Update/17.php b/tine20/Felamimail/Setup/Update/17.php index a883b532524..6ec1689ad38 100644 --- a/tine20/Felamimail/Setup/Update/17.php +++ b/tine20/Felamimail/Setup/Update/17.php @@ -20,6 +20,7 @@ class Felamimail_Setup_Update_17 extends Setup_Update_Abstract const RELEASE017_UPDATE003 = __CLASS__ . '::update003'; const RELEASE017_UPDATE004 = __CLASS__ . '::update004'; + static protected $_allUpdates = [ self::PRIO_NORMAL_APP_STRUCTURE => [ self::RELEASE017_UPDATE001 => [ @@ -45,6 +46,7 @@ class Felamimail_Setup_Update_17 extends Setup_Update_Abstract self::FUNCTION_CONST => 'update004', ], ], + ]; public function update000() diff --git a/tine20/Felamimail/Setup/Update/18.php b/tine20/Felamimail/Setup/Update/18.php index ad258ad210f..ad0b321070c 100644 --- a/tine20/Felamimail/Setup/Update/18.php +++ b/tine20/Felamimail/Setup/Update/18.php @@ -15,6 +15,7 @@ class Felamimail_Setup_Update_18 extends Setup_Update_Abstract { protected const RELEASE018_UPDATE000 = __CLASS__ . '::update000'; protected const RELEASE018_UPDATE001 = __CLASS__ . '::update001'; + protected const RELEASE018_UPDATE002 = __CLASS__ . '::update002'; static protected $_allUpdates = [ self::PRIO_NORMAL_APP_STRUCTURE => [ @@ -22,6 +23,10 @@ class Felamimail_Setup_Update_18 extends Setup_Update_Abstract self::CLASS_CONST => self::class, self::FUNCTION_CONST => 'update001', ], + self::RELEASE018_UPDATE002 => [ + self::CLASS_CONST => self::class, + self::FUNCTION_CONST => 'update002', + ], ], self::PRIO_NORMAL_APP_UPDATE => [ self::RELEASE018_UPDATE000 => [ @@ -38,10 +43,17 @@ public function update000(): void public function update001(): void { - Setup_SchemaTool::updateSchema([ - Felamimail_Model_Sieve_Forward::class, - ]); - $this->addApplicationUpdate(Felamimail_Config::APP_NAME, '18.1', self::RELEASE018_UPDATE001); } + + public function update002(): void + { + Tinebase_TransactionManager::getInstance()->rollBack(); + + if ($this->getTableVersion('felamimail_account') < 31) { + $this->setTableVersion('felamimail_account', 31); + } + + $this->addApplicationUpdate(Felamimail_Config::APP_NAME, '18.2', self::RELEASE018_UPDATE002); + } } diff --git a/tine20/Felamimail/Setup/setup.xml b/tine20/Felamimail/Setup/setup.xml index 9b4e34cf77b..8c6e9a5ea67 100644 --- a/tine20/Felamimail/Setup/setup.xml +++ b/tine20/Felamimail/Setup/setup.xml @@ -1,13 +1,13 @@ Felamimail - 18.1 + 18.2 30 enabled felamimail_account - 30 + 31 id diff --git a/tine20/Felamimail/Sieve/Backend/Abstract.php b/tine20/Felamimail/Sieve/Backend/Abstract.php index daa62397da2..71d09a99fde 100644 --- a/tine20/Felamimail/Sieve/Backend/Abstract.php +++ b/tine20/Felamimail/Sieve/Backend/Abstract.php @@ -17,13 +17,6 @@ */ abstract class Felamimail_Sieve_Backend_Abstract { - /** - * the forward object - * - * @var Felamimail_Sieve_Forward - */ - protected $_forward = NULL; - /** * array of Sieve rules(Felamimail_Sieve_Rule) * @@ -51,16 +44,6 @@ abstract class Felamimail_Sieve_Backend_Abstract * @var string */ protected $_generatorString = "#Generated by Felamimail_Sieve\r\n"; - - /** - * return array of Felamimail_Sieve_Rule - * - * @return Felamimail_Sieve_Forward|null - */ - public function getForward() - { - return $this->_forward; - } /** * return array of Felamimail_Sieve_Rule @@ -133,10 +116,9 @@ public function getSieve() $rules = $this->_getRulesString(); $vacation = $this->_getVacationString(); $scriptParts = $this->_getScriptPartsString(); - $forwardings = $this->_getForwardString(); - $header = (!empty($forwardings) || !empty($rules) || !empty($vacation) || !empty($scriptParts) ) ? $this->_getHeaderString() : ''; + $header = (!empty($rules) || !empty($vacation) || !empty($scriptParts)) ? $this->_getHeaderString() : ''; - $sieve = $header . "\r\n\r\n" . $forwardings . $rules . $vacation . $scriptParts . "\r\n\r\n"; + $sieve = $header . "\r\n\r\n" . $rules . $vacation . $scriptParts . "\r\n\r\n"; return $sieve; } @@ -205,20 +187,6 @@ protected function _getRequirements() return $require; } - /** - * @return string - */ - protected function _getForwardString() - { - if ($this->_forward) { - $forward = $this->_forward->__toString(); - } else { - $forward = ''; - } - - return $forward; - } - /** * @return string */ @@ -273,16 +241,6 @@ protected function _getVacationString() return $vacation; } - /** - * set vacation - * - * @param Felamimail_Sieve_Forward $forward - */ - public function setForward(Felamimail_Sieve_Forward $forward) - { - $this->_forward = $forward; - } - /** * set vacation * @@ -311,6 +269,5 @@ public function getDataFromScript(Felamimail_Sieve_Backend_Abstract $_scriptToCo $this->_vacation = $_scriptToCopyFrom->getVacation(); $this->_rules = $_scriptToCopyFrom->getRules(); $this->_scriptParts = $_scriptToCopyFrom->getScriptParts(); - $this->_forward = $_scriptToCopyFrom->getForward(); } } diff --git a/tine20/Felamimail/Sieve/Backend/Sql.php b/tine20/Felamimail/Sieve/Backend/Sql.php index aeecbc3a93d..a472f527c21 100644 --- a/tine20/Felamimail/Sieve/Backend/Sql.php +++ b/tine20/Felamimail/Sieve/Backend/Sql.php @@ -19,13 +19,6 @@ */ class Felamimail_Sieve_Backend_Sql extends Felamimail_Sieve_Backend_Abstract { - /** - * forward backend - * - * @var Tinebase_Backend_Sql - */ - protected $_forwardBackend = NULL; - /** * rules backend * @@ -63,11 +56,6 @@ class Felamimail_Sieve_Backend_Sql extends Felamimail_Sieve_Backend_Abstract */ public function __construct($_accountId, $_readData = TRUE) { - $this->_forwardBackend = new Tinebase_Backend_Sql(array( - 'modelName' => 'Felamimail_Model_Sieve_Forward', - 'tableName' => 'felamimail_sieve_forward', - )); - $this->_rulesBackend = new Tinebase_Backend_Sql(array( 'modelName' => 'Felamimail_Model_Sieve_Rule', 'tableName' => 'felamimail_sieve_rule', @@ -104,35 +92,11 @@ public function readScriptData() $this->_getRules(); $this->_getVacation(); $this->_getScriptParts(); - $this->_getForwardings(); if (count($this->_rules) === 0 && $this->_vacation === NULL && $this->_scriptParts->count() === 0) { throw new Tinebase_Exception_NotFound('No sieve data found in database for this account.'); } } - - /** - * get vacation - */ - protected function _getForwardings() - { - try { - $filter = Tinebase_Model_Filter_FilterGroup::getFilterForModel(Felamimail_Model_Sieve_Forward::class, [ - ['field' => 'account_id', 'operator' => 'equals', 'value' => $this->_accountId] - ]); - $forwardRecords = $this->_forwardBackend->search($filter); - - if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ - . ' Got forward from DB: ' . print_r($forwardRecords->toArray(), TRUE)); - if ($forwardRecords->count() > 0) { - $forward = new Felamimail_Sieve_Forward(); - $forward->setAddresses($forwardRecords->email); - $this->_forward = $forward; - } - } catch (Tinebase_Exception_NotFound $tenf) { - // do nothing - } - } protected function _getScriptParts() { @@ -198,38 +162,8 @@ public function save() $this->_saveRules(); $this->_saveVacation(); $this->_saveScriptParts(); - //$this->_saveForwardings(); } - - /** - * persist forwarding data in db - */ - protected function _saveForwardings() - { - $this->_forwardBackend->deleteByProperty($this->_accountId, 'account_id'); - - if (empty($this->_forward)) { - return; - } - - $forwardData = $this->_forward->toArray(); - foreach ($forwardData['addresses'] as $email) { - $forwardRecord = new Felamimail_Model_Sieve_Forward(); - $forwardRecord->account_id = $this->_accountId; - $forwardRecord->email = $email; - - if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ - . ' Saving forward in DB: ' . print_r($forwardRecord->toArray(), TRUE)); - - try { - $this->_forwardBackend->create($forwardRecord); - } catch (Tinebase_Exception_NotFound $tenf) { - Tinebase_Exception::log($tenf); - } - } - } - /** * persist script parts data in db * diff --git a/tine20/Felamimail/Sieve/Forward.php b/tine20/Felamimail/Sieve/Forward.php deleted file mode 100644 index b45f35c61f0..00000000000 --- a/tine20/Felamimail/Sieve/Forward.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @copyright Copyright (c) 2024 Metaways Infosystems GmbH (http://www.metaways.de) - * - */ - -/** - * class to manage script generation for sieve forwardings - * - * @package Felamimail - * @subpackage Sieve - */ -class Felamimail_Sieve_Forward -{ - /** - * email addresses - * - * @var array - */ - protected array $_addresses = []; - - public function __toString() - { - if (count($this->_addresses) === 0) { - if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . - __LINE__ . 'reply to option is null , skip resoling reply-to header'); - return ''; - } - $result = 'require ["envelope", "copy", "reject", "editheader", "variables"];' . PHP_EOL; - $this->_addReplyTo($result); - $this->_addForwarding($result); - - return $result; - } - - /** - * @param string $result - * @return void - */ - protected function _addForwarding(string &$result): void - { - foreach ($this->_addresses as $email) { - if (! preg_match(Tinebase_Mail::EMAIL_ADDRESS_REGEXP, $email)) { - if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) Tinebase_Core::getLogger()->notice( - __METHOD__ . '::' . __LINE__ . ' Email address invalid: ' . $email); - continue; - } - $result .= 'redirect "' . $email . '";' . PHP_EOL; - } - } - - /** - * @param string $result - * @return void - */ - protected function _addReplyTo(string &$result): void - { - $result .= 'if address :matches "from" "*" { - addheader "Reply-To" "${1}"; -}'; - // Add "FW:" as a prefix to the subject - $result .= 'if header :matches "subject" "*" { - set "original_subject" "${1}"; - deleteheader "Subject"; - addheader "Subject" "FW: ${original_subject}"; -}'; - - $result .= PHP_EOL . PHP_EOL; - } - - /** - * add addresses - * - * @param array $addresses the addresses - * @return Felamimail_Sieve_Forward - */ - public function setAddresses($addresses) - { - $this->_addresses = $addresses; - - return $this; - } - - /** - * return values as array - * - * @return array - */ - public function toArray() - { - return [ - 'addresses' => $this->_addresses, - ]; - } -} diff --git a/tine20/Felamimail/js/AccountEditDialog.js b/tine20/Felamimail/js/AccountEditDialog.js index 84e71187cff..172ca90e235 100644 --- a/tine20/Felamimail/js/AccountEditDialog.js +++ b/tine20/Felamimail/js/AccountEditDialog.js @@ -338,10 +338,7 @@ Tine.Felamimail.AccountEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, { this.rulesGridPanel = new Tine.Felamimail.sieve.RulesGridPanel({ title: this.app.i18n._('Filter Rules'), account: this.record ? this.record : null, - recordProxy: this.asAdminModule ? new Tine.Felamimail.RulesBackend({ - appName: 'Admin', - modelName: 'SieveRule' - }) : Tine.Felamimail.rulesBackend, + recordProxy: this.ruleRecordProxy, initialLoadAfterRender: false, disabled: !this.isSystemAccount() }); @@ -362,60 +359,18 @@ Tine.Felamimail.AccountEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, { this.saveInAdbFields = []; this.emailImapUser = []; this.aliasesGrid = []; - this.smtpForwardsGrid = []; - this.sieveForwardsGrid = []; + this.forwardsGrid = []; const additionConfig = { scope: this, record: this.record, - columnWidth: 0.5, }; if (this.asAdminModule) { this.saveInAdbFields = Tine.Admin.UserEditDialog.prototype.getSaveInAddessbookFields(this, this.record.get('type') === 'system'); this.emailImapUser = this.record.data?.email_imap_user || []; this.aliasesGrid = Tine.Admin.UserEditDialog.prototype.initAliasesGrid(additionConfig); - this.smtpForwardsGrid = Tine.Admin.UserEditDialog.prototype.initForwardsGrid(additionConfig); - const app = Tine.Tinebase.appMgr.get('Admin'); - this.sieveForwardsGrid = new Tine.widgets.grid.QuickaddGridPanel( - Ext.apply({ - autoExpandColumn: 'email', - quickaddMandatory: 'email', - useBBar: true, - frame: false, - height: 200, - recordClass: Tine.Felamimail.Model.Sieve_Forward, - store: new Ext.data.JsonStore({ - fields: ['id', 'email'], - id: 'id' - }), - onNewentry: function(value) { - if (value.email === this.record.get('accountEmailAddress')) { - Ext.MessageBox.show({ - buttons: Ext.Msg.OK, - icon: Ext.MessageBox.WARNING, - title: app.i18n._('Forwarding to self'), - msg: app.i18n._('You are not allowed to set a forwarding e-mail address that is identical to the users primary e-mail or one of his aliases.') - }); - return false; - } else { - Tine.widgets.grid.QuickaddGridPanel.prototype.onNewentry.call(this, value); - } - }, - cm: new Ext.grid.ColumnModel([{ - id: 'email', - header: app.i18n.gettext('E-mail Forward'), - width: 300, - hideable: false, - sortable: true, - quickaddField: new Ext.form.TextField({ - emptyText: app.i18n.gettext('Add a forwarding address...'), - vtype: 'email' - }), - editor: new Ext.form.TextField({allowBlank: false}) - }]) - }, additionConfig)) - ; + this.forwardsGrid = Tine.Admin.UserEditDialog.prototype.initForwardsGrid(additionConfig); const adb = Tine.Tinebase.appMgr.get('Addressbook'); if (Tine.Tinebase.registry.get('manageImapEmailUser') && Tine.Tinebase.registry.get('manageSmtpEmailUser') @@ -774,7 +729,7 @@ Tine.Felamimail.AccountEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, { this.testConnection('SMTP', true, true); }, disabled: true - })], [this.aliasesGrid, this.smtpForwardsGrid] + })], [this.aliasesGrid, this.forwardsGrid] ] }, { title: this.app.i18n._('Sieve'), @@ -817,7 +772,6 @@ Tine.Felamimail.AccountEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, { this.setDisabled(me.isSystemAccount()); } }], [ - this.sieveForwardsGrid, this.sieveNotifyGrid ], [{ fieldLabel: this.app.i18n._('Auto-move notifications'), @@ -1252,9 +1206,6 @@ Tine.Felamimail.AccountEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, { // load sieve notification emails const data = this.record.data.sieve_notification_email.split(','); this.sieveNotifyGrid.setStoreFromArray(data.map((e) => {return {'email': e}})); - if (this.asAdminModule) { - this.sieveForwardsGrid.store.loadData( this.record.data.sieve_forwardings ?? ''); - } }, /** @@ -1281,7 +1232,7 @@ Tine.Felamimail.AccountEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, { this.aliasesGrid.setStoreFromArray(this.record.data.email_smtp_user.emailAliases); } if (this.record.data?.email_smtp_user?.emailForwards) { - this.smtpForwardsGrid.setStoreFromArray(this.record.data.email_smtp_user.emailForwards); + this.forwardsGrid.setStoreFromArray(this.record.data.email_smtp_user.emailForwards); } } }, @@ -1291,13 +1242,13 @@ Tine.Felamimail.AccountEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, { if (this.asAdminModule && Tine.Tinebase.registry.get('manageSmtpEmailUser')) { // forcing blur of quickadd grids this.aliasesGrid.doBlur(); - this.smtpForwardsGrid.doBlur(); + this.forwardsGrid.doBlur(); if (this.record.data?.email_smtp_user?.emailAliases) { this.record.data.email_smtp_user.emailAliases = this.aliasesGrid.getFromStoreAsArray(); } if (this.record.data?.email_smtp_user?.emailForwards) { - this.record.data.email_smtp_user.emailForwards = this.smtpForwardsGrid.getFromStoreAsArray(); + this.record.data.email_smtp_user.emailForwards = this.forwardsGrid.getFromStoreAsArray(); } Tine.log.debug('Tine.Felamimail.AccountEditDialog::onRecordUpdate() -> setting aliases and forwards in e-mail record'); Tine.log.debug(this.record); @@ -1345,9 +1296,6 @@ Tine.Felamimail.AccountEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, { this.record.set('sieve_rules', rules); this.record.set('sieve_vacation', this.vacationRecord); - if (this.asAdminModule) { - this.record.set('sieve_forwardings', this.sieveForwardsGrid.getFromStoreAsArray()); - } // update sieve notification emails const notifyEmails = this.sieveNotifyGrid.getFromStoreAsArray();