0002284: add reply-to setting to email account
authorPhilipp Schüle <p.schuele@metaways.de>
Mon, 27 Feb 2017 16:55:31 +0000 (17:55 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Mon, 6 Mar 2017 07:55:51 +0000 (08:55 +0100)
!usermanual

https://forge.tine20.org/view.php?id=2284

Change-Id: Ic9e6ef0406b8c3253791b16d4302ba8158825738
Reviewed-on: http://gerrit.tine20.com/customers/4276
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Felamimail/Frontend/JsonTest.php
tine20/Felamimail/Controller/Account.php
tine20/Felamimail/Controller/Message/Send.php
tine20/Felamimail/Model/Account.php
tine20/Felamimail/Setup/Update/Release9.php
tine20/Felamimail/Setup/setup.xml
tine20/Felamimail/js/AccountEditDialog.js
tine20/Felamimail/js/Model.js

index 3d39a85..90b1448 100644 (file)
@@ -1878,4 +1878,22 @@ IbVx8ZTO7dJRKrg72aFmWTf0uNla7vicAhpiLWobyNYcZbIjrAGDfg==
             : 5;
         $this->assertEquals($supportedFlags, $regData['supportedFlags']['totalcount']);
     }
+
+    /**
+     * @see 0002284: add reply-to setting to email account
+     */
+    public function testReplyToSetting()
+    {
+        $this->_account->reply_to = 'noreply@tine20.org';
+        $this->_json->saveAccount($this->_account->toArray());
+
+        $this->_foldersToClear[] = 'INBOX';
+        $messageToSend = $this->_getMessageData();
+        $this->_json->saveMessage($messageToSend);
+        $message = $this->_searchForMessageBySubject($messageToSend['subject']);
+
+        $complete = $this->_json->getMessage($message['id']);
+        $this->assertTrue(isset($complete['headers']['reply-to']), print_r($complete, true));
+        $this->assertEquals('"Tine 2.0 Admin Account" <noreply@tine20.org>', $complete['headers']['reply-to']);
+    }
 }
index 3522687..ee09bc9 100644 (file)
@@ -317,6 +317,7 @@ class Felamimail_Controller_Account extends Tinebase_Controller_Record_Abstract
             'display_format',
             'compose_format',
             'preserve_format',
+            'reply_to',
             'has_children_support',
             'delimiter',
             'ns_personal',
index 7455f52..1b65304 100644 (file)
@@ -425,9 +425,7 @@ class Felamimail_Controller_Message_Send extends Felamimail_Controller_Message
     {
         $_mail->clearFrom();
         
-        $from = (isset($_account->from) && ! empty($_account->from)) 
-            ? $_account->from 
-            : Tinebase_Core::getUser()->accountFullName;
+        $from = $this->_getSenderName($_account);
         
         $email = ($_message !== NULL && ! empty($_message->from_email)) ? $_message->from_email : $_account->email;
         
@@ -435,6 +433,13 @@ class Felamimail_Controller_Message_Send extends Felamimail_Controller_Message
         
         $_mail->setFrom($email, $from);
     }
+
+    protected function _getSenderName($account)
+    {
+        return (isset($_account->from) && ! empty($_account->from))
+            ? $_account->from
+            : Tinebase_Core::getUser()->accountFullName;
+    }
     
     /**
      * set mail recipients
@@ -518,6 +523,11 @@ class Felamimail_Controller_Message_Send extends Felamimail_Controller_Message
         if (isset($_account->organization) && ! empty($_account->organization)) {
             $_mail->addHeader('Organization', $_account->organization);
         }
+
+        // add reply-to
+        if (! empty($_account->reply_to)) {
+            $_mail->setReplyTo($_account->reply_to, $this->_getSenderName($_account));
+        }
         
         // set message-id (we could use Zend_Mail::createMessageId() here)
         if ($_mail->getMessageId() === NULL) {
index 6c95747..2e47081 100644 (file)
@@ -96,6 +96,7 @@ class Felamimail_Model_Account extends Tinebase_EmailUser_Model_Account
             Zend_Filter_Input::DEFAULT_VALUE => 1,
             array('InArray', array(0,1)),
         ),
+        'reply_to'              => array(Zend_Filter_Input::ALLOW_EMPTY => true),
     // namespaces
         'ns_personal'           => array(Zend_Filter_Input::ALLOW_EMPTY => true),
         'ns_other'              => array(Zend_Filter_Input::ALLOW_EMPTY => true),
index fad5e77..42b2cea 100644 (file)
@@ -69,4 +69,26 @@ class Felamimail_Setup_Update_Release9 extends Setup_Update_Abstract
         $this->setApplicationVersion('Felamimail', '9.3');
         $this->setTableVersion('felamimail_account', '22');
     }
+
+
+    /**
+     * update to 9.4
+     *
+     * @see 0002284: add reply-to setting to email account
+     */
+    public function update_3()
+    {
+        if ($this->getTableVersion('felamimail_account') < 23) {
+            $declaration = new Setup_Backend_Schema_Field_Xml('
+            <field>
+                    <name>reply_to</name>
+                    <type>text</type>
+                    <length>255</length>
+            </field>');
+            $this->_backend->addCol('felamimail_account', $declaration, 19);
+            $this->setTableVersion('felamimail_account', 23);
+        }
+
+        $this->setApplicationVersion('Felamimail', '9.4');
+    }
 }
index 966c0af..cead2ec 100644 (file)
@@ -1,13 +1,13 @@
 <?xml version="1.0" encoding="utf-8"?>
 <application>
     <name>Felamimail</name>
-    <version>9.3</version>
+    <version>9.4</version>
     <order>30</order>
     <status>enabled</status>
     <tables>
         <table>
             <name>felamimail_account</name>
-            <version>22</version>
+            <version>23</version>
             <declaration>
                 <field>
                     <name>id</name>
                     <default>false</default>
                 </field>
                 <field>
+                    <name>reply_to</name>
+                    <type>text</type>
+                    <length>255</length>
+                </field>
+                <field>
                     <name>ns_personal</name>
                     <type>text</type>
                     <length>255</length>
index 770f0a3..7dcfbcc 100644 (file)
@@ -67,6 +67,7 @@ Tine.Felamimail.AccountEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
                     case 'display_format':
                     case 'compose_format':
                     case 'preserve_format':
+                    case 'reply_to':
                         break;
                     default:
                         item.setDisabled(true);
@@ -359,6 +360,10 @@ Tine.Felamimail.AccountEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
                         [0, this.app.i18n._('No')],
                         [1,  this.app.i18n._('Yes')]
                     ]
+                }, {
+                    fieldLabel: this.app.i18n._('Reply-To Email'),
+                    name: 'reply_to',
+                    vtype: 'email'
                 }]]
             }]
         };
index 07cd03f..6057c19 100644 (file)
@@ -380,6 +380,7 @@ Tine.Felamimail.Model.Account = Tine.Tinebase.data.Record.create(Tine.Tinebase.M
     { name: 'display_format' },
     { name: 'compose_format' },
     { name: 'preserve_format' },
+    { name: 'reply_to' },
     { name: 'ns_personal' },
     { name: 'ns_other' },
     { name: 'ns_shared' },