Skip to content

Commit

Permalink
Merge branch 'pu/ccheng/velo_2226_revert' into 'main'
Browse files Browse the repository at this point in the history
revert(Felamimail/js): support sieve forwarding

See merge request tine20/tine20!6472
  • Loading branch information
pschuele committed Feb 6, 2025
2 parents 95235f6 + bf92602 commit 035ac94
Show file tree
Hide file tree
Showing 19 changed files with 41 additions and 476 deletions.
14 changes: 0 additions & 14 deletions tests/tine20/Admin/Frontend/Json/EmailAccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '[email protected]',
'id' => Tinebase_Record_Abstract::generateUID(),
], [
'account_id' => $account->getId(),
'email' => '[email protected]',
'id' => Tinebase_Record_Abstract::generateUID(),
]
]);

$this->_json->saveEmailAccount($account->toArray());
$script = $this->_json->getSieveScript($account->getId());
$this->assertStringContainsString('currentdate', $script);
$this->assertStringContainsString('[email protected]', $script);
$this->assertStringContainsString('[email protected]', $script);


$account->sieve_rules = $this->_getSieveRuleData();
$this->_json->saveEmailAccount($account->toArray());
Expand Down
19 changes: 0 additions & 19 deletions tests/tine20/Felamimail/Sieve/Backend/ScriptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
'[email protected]',
'[email protected]',
];
$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('[email protected]', $sieveScript);
$this->assertStringContainsString('[email protected]', $sieveScript);
}

public function testInvalidRule()
{
$script = new Felamimail_Sieve_Backend_Script();
Expand Down
1 change: 0 additions & 1 deletion tests/tine20/Tinebase/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions tine20/Admin/js/user/EditDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -851,6 +851,8 @@ Tine.Admin.UserEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
}])
}, config)
);

return this.forwardsGrid;
},

initPasswordConfirmWindow: function() {
Expand Down
2 changes: 1 addition & 1 deletion tine20/Felamimail/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
12 changes: 6 additions & 6 deletions tine20/Felamimail/Controller/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,6 @@ protected function _beforeUpdateSystemAccount($_record, $_oldRecord)
'sieve_custom',
'sieve_vacation',
'sieve_rules',
'sieve_forwardings',
'sent_folder',
'trash_folder',
'drafts_folder',
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 1 addition & 11 deletions tine20/Felamimail/Controller/Sieve.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
41 changes: 0 additions & 41 deletions tine20/Felamimail/Controller/Sieve/Forward.php

This file was deleted.

1 change: 0 additions & 1 deletion tine20/Felamimail/Frontend/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 *******************************/
Expand Down
20 changes: 0 additions & 20 deletions tine20/Felamimail/Model/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
80 changes: 0 additions & 80 deletions tine20/Felamimail/Model/Sieve/Forward.php

This file was deleted.

3 changes: 0 additions & 3 deletions tine20/Felamimail/Model/Sieve/ScriptPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tine20/Felamimail/Setup/Update/17.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 => [
Expand All @@ -45,6 +46,7 @@ class Felamimail_Setup_Update_17 extends Setup_Update_Abstract
self::FUNCTION_CONST => 'update004',
],
],

];

public function update000()
Expand Down
20 changes: 16 additions & 4 deletions tine20/Felamimail/Setup/Update/18.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ 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 => [
self::RELEASE018_UPDATE001 => [
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 => [
Expand All @@ -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);
}
}
4 changes: 2 additions & 2 deletions tine20/Felamimail/Setup/setup.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<application>
<name>Felamimail</name>
<version>18.1</version>
<version>18.2</version>
<order>30</order>
<status>enabled</status>
<tables>
<table>
<name>felamimail_account</name>
<version>30</version>
<version>31</version>
<declaration>
<field>
<name>id</name>
Expand Down
Loading

0 comments on commit 035ac94

Please sign in to comment.