$ruleData[0]['enabled'] = 0;
$this->_sieveTestHelper($ruleData);
}
-
+
+ /**
+ * @see 0006222: Keep a copy from mails forwarded to another emailaddress
+ */
+ public function testSetForwardRuleWithCopy()
+ {
+ $ruleData = array(array(
+ 'id' => 1,
+ 'action_type' => Felamimail_Sieve_Rule_Action::REDIRECT,
+ 'action_argument' => array(
+ 'emails' => 'someaccount@example.org',
+ 'copy' => 1,
+ ),
+ 'conjunction' => 'allof',
+ 'conditions' => array(array(
+ 'test' => Felamimail_Sieve_Rule_Condition::TEST_ADDRESS,
+ 'comperator' => Felamimail_Sieve_Rule_Condition::COMPERATOR_CONTAINS,
+ 'header' => 'From',
+ 'key' => 'info@example.org',
+ )),
+ 'enabled' => 1,
+ ));
+
+ $this->_sieveTestHelper($ruleData);
+ }
+
+ /**
+ * @see 0006222: Keep a copy from mails forwarded to another emailaddress
+ */
+ public function testSetForwardRuleWithoutCopy()
+ {
+ $ruleData = array(array(
+ 'id' => 1,
+ 'action_type' => Felamimail_Sieve_Rule_Action::REDIRECT,
+ 'action_argument' => array(
+ 'emails' => 'someaccount@example.org',
+ 'copy' => 0,
+ ),
+ 'conjunction' => 'allof',
+ 'conditions' => array(array(
+ 'test' => Felamimail_Sieve_Rule_Condition::TEST_ADDRESS,
+ 'comperator' => Felamimail_Sieve_Rule_Condition::COMPERATOR_CONTAINS,
+ 'header' => 'From',
+ 'key' => 'info@example.org',
+ )),
+ 'enabled' => 1,
+ ));
+
+ $this->_sieveTestHelper($ruleData);
+ }
+
/**
* testGetVacationTemplates
*
if (! empty($this->_rules)) {
$require[] = '"fileinto"';
$require[] = '"reject"';
+ $require[] = '"copy"';
foreach ($this->_rules as $rule) {
if ($rule->hasRegexCondition()) {
$this->_rules = array();
foreach ($ruleRecords as $ruleRecord) {
$ruleRecord->conditions = Zend_Json::decode($ruleRecord->conditions);
+ if (Tinebase_Helper::is_json($ruleRecord->action_argument)) {
+ $ruleRecord->action_argument = Zend_Json::decode($ruleRecord->action_argument);
+ }
+
$this->_rules[] = $ruleRecord->getFSR();
}
}
$ruleRecord->setFromFSR($rule);
$ruleRecord->account_id = $this->_accountId;
$ruleRecord->conditions = Zend_Json::encode($ruleRecord->conditions);
+ if (is_array($ruleRecord->action_argument)) {
+ $ruleRecord->action_argument = Zend_Json::encode($ruleRecord->action_argument);
+ }
$this->_rulesBackend->create($ruleRecord);
}
* @subpackage Sieve
* @license http://www.gnu.org/licenses/agpl.html AGPL Version 3
* @author Lars Kneschke <l.kneschke@metaways.de>
- * @copyright Copyright (c) 2010 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright Copyright (c) 2010-2016 Metaways Infosystems GmbH (http://www.metaways.de)
*
*/
case self::DISCARD:
return " $this->_type;";
break;
-
+
+ case self::REDIRECT:
+ if (is_array($this->_argument)) {
+ if (isset($this->_argument['copy']) && $this->_argument['copy'] == 1) {
+ $argument = $this->_quoteString($this->_argument['emails']);
+ return " $this->_type :copy $argument;";
+ } else {
+ $argument = $this->_quoteString($this->_argument['emails']);
+ return " $this->_type $argument;";
+ }
+
+ break;
+ }
+
default:
$argument = $this->_quoteString($this->_argument);
return " $this->_type $argument;";
if (this.record.get('action_type') == type) {
var field = this.getForm().findField('action_argument_' + type);
if (field !== null) {
- field.setValue(this.record.get('action_argument'));
+ switch (type) {
+ case 'redirect':
+ var data = this.record.get('action_argument'),
+ checkbox = this.getForm().findField('action_argument_redirect_copy');
+ field.setValue(data.emails);
+ checkbox.setValue(data.copy);
+ break;
+ default:
+ field.setValue(this.record.get('action_argument'));
+ }
}
}
}
Tine.Felamimail.sieve.RuleEditDialog.superclass.onRecordUpdate.call(this);
this.record.set('conditions', this.getConditions());
-
- var argumentField = this.getForm().findField('action_argument_' + this.actionTypeCombo.getValue()),
+
+ var argumentFieldName = 'action_argument_' + this.actionTypeCombo.getValue();
+ argumentField = this.getForm().findField(argumentFieldName),
argumentValue = (argumentField !== null) ? argumentField.getValue() : '';
+
+ // add additional action arguments
+ if (argumentFieldName === 'action_argument_redirect') {
+ argumentValue = {
+ emails: argumentValue,
+ copy: this.getForm().findField('action_argument_redirect_copy').getValue()
+ };
+ }
+
this.record.set('action_argument', argumentValue);
},
emptyText: 'test@example.org',
width: 200,
hideLabel: true
+ }, {
+ name: 'action_argument_redirect_copy',
+ xtype: 'checkbox',
+ fieldLabel: this.app.i18n._('Keep a copy')
}]
}, {
id: this.idPrefix + 'reject',
*/
actionRenderer: function(type, metadata, record) {
var types = Tine.Felamimail.sieve.RuleEditDialog.getActionTypes(this.app),
- result = type;
-
+ result = type,
+ action_argument = record.get('action_argument');
+
for (i=0; i < types.length; i++) {
if (types[i][0] == type) {
result = types[i][1];
}
}
- if (record.get('action_argument') && record.get('action_argument') != '') {
- result += ' ' + record.get('action_argument');
+ if (action_argument && action_argument != '') {
+ result += Ext.isObject(action_argument)
+ ? ': ' + action_argument.emails + (action_argument.copy ? ' (' + this.app.i18n._('Keep a copy') + ')' : '')
+ : action_argument;
}
return Ext.util.Format.htmlEncode(result);