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

Commit

Permalink
fix(Felamimail/Sieve): show contact phone number in vacation template
Browse files Browse the repository at this point in the history
  • Loading branch information
ccheng-dev committed May 10, 2023
1 parent f2b3bc1 commit bf9c008
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
9 changes: 4 additions & 5 deletions tests/tine20/Felamimail/Frontend/JsonTest.php
Expand Up @@ -2036,11 +2036,10 @@ public function testGetVacationMessage()
$result = $this->_getVacationMessageWithTemplate();
$sclever = Tinebase_User::getInstance()->getFullUserByLoginName('sclever');
$pwulf = Tinebase_User::getInstance()->getFullUserByLoginName('pwulf');
$this->assertEquals("Ich bin vom 18.04.2012 bis zum 20.04.2012 im Urlaub. Bitte kontaktieren Sie<br /> Paul Wulf (" .
$pwulf->accountEmailAddress . ") oder Susan Clever (" .
$sclever->accountEmailAddress . ").<br /><br />I am on vacation until Apr 20, 2012. Please contact<br /> Paul Wulf (" .
$pwulf->accountEmailAddress . ") or Susan Clever (" .
$sclever->accountEmailAddress . ") instead.<br /><br />" .
$this->assertEquals("Ich bin vom 18.04.2012 bis zum 20.04.2012 im Urlaub. Bitte kontaktieren Sie" .
"<br /> Paul Wulf (pwulf@mail.test) +441273-3766-376 oder Susan Clever (sclever@mail.test) +441273-3766-373.<br />" .
"<br />I am on vacation until Apr 20, 2012. Please contact" .
"<br /> Paul Wulf (pwulf@mail.test) +441273-3766-376 or Susan Clever (sclever@mail.test) +441273-3766-373 instead.<br /><br />" .
Addressbook_Controller_Contact::getInstance()->getContactByUserId(Tinebase_Core::getUser()->getId())->n_fn . "<br />",
$result['message'],
);
Expand Down
4 changes: 2 additions & 2 deletions tests/tine20/Felamimail/files/vacation_template.tpl
@@ -1,7 +1,7 @@
Ich bin vom {startDate-de_DE} bis zum {endDate-de_DE} im Urlaub. Bitte kontaktieren Sie
{representation-n_fn-1} ({representation-email-1}) oder {representation-n_fn-2} ({representation-email-2}).
{representation-n_fn-1} ({representation-email-1}) {representation-tel_work-1} oder {representation-n_fn-2} ({representation-email-2}) {representation-tel_work-2}.

I am on vacation until {endDate-en_US}. Please contact
{representation-n_fn-1} ({representation-email-1}) or {representation-n_fn-2} ({representation-email-2}) instead.
{representation-n_fn-1} ({representation-email-1}) {representation-tel_work-1} or {representation-n_fn-2} ({representation-email-2}) {representation-tel_work-2} instead.

{owncontact-n_fn}
4 changes: 2 additions & 2 deletions tests/tine20/Felamimail/files/vacation_template_sig.tpl
@@ -1,8 +1,8 @@
Ich bin vom {startDate-de_DE} bis zum {endDate-de_DE} im Urlaub. Bitte kontaktieren Sie
{representation-n_fn-1} ({representation-email-1}) oder {representation-n_fn-2} ({representation-email-2}).
{representation-n_fn-1} ({representation-email-1}) {representation-tel_work-1} oder {representation-n_fn-2} ({representation-email-2}) {representation-tel_work-2}.

I am on vacation until {endDate-en_US}. Please contact
{representation-n_fn-1} ({representation-email-1}) or {representation-n_fn-2} ({representation-email-2}) instead.
{representation-n_fn-1} ({representation-email-1}) {representation-tel_work-1} or {representation-n_fn-2} ({representation-email-2}) {representation-tel_work-2} instead.

{owncontact-n_fn}

Expand Down
10 changes: 7 additions & 3 deletions tine20/Felamimail/Controller/Sieve.php
Expand Up @@ -703,17 +703,19 @@ protected function _doMessageSubstitutions(Felamimail_Model_Sieve_Vacation $vaca
'{representation-n_fn-2}',
'{representation-email-1}',
'{representation-email-2}',
'{representation-tel_work-1}',
'{representation-tel_work-2}',
'{owncontact-n_fn}',
'{signature}',
);

if (!isset($representativesArray[1])) {
$message = str_replace(" or {representation-n_fn-2} ({representation-email-2}) instead.", '', $message);
$message = str_replace(" oder {representation-n_fn-2} ({representation-email-2}).", '', $message);
$message = str_replace(" or {representation-n_fn-2} ({representation-email-2}) {representation-tel_work-2} instead.", '', $message);
$message = str_replace(" oder {representation-n_fn-2} ({representation-email-2}) {representation-tel_work-2}.", '', $message);
}

if (!isset($representativesArray[0])) {
$message = str_replace(" {representation-n_fn-1} ({representation-email-1})", '', $message);
$message = str_replace(" {representation-n_fn-1} ({representation-email-1}) {representation-tel_work-1}", '', $message);
}

if (!isset($representativesArray[0]) && !isset($representativesArray[1])) {
Expand All @@ -730,6 +732,8 @@ protected function _doMessageSubstitutions(Felamimail_Model_Sieve_Vacation $vaca
(isset($representativesArray[1])) ? $representativesArray[1]->n_fn : 'unknown person',
(isset($representativesArray[0])) ? $representativesArray[0]->email : 'unknown email',
(isset($representativesArray[1])) ? $representativesArray[1]->email : 'unknown email',
(isset($representativesArray[0])) ? $representativesArray[0]->tel_work : '',
(isset($representativesArray[1])) ? $representativesArray[1]->tel_work : '',
($ownContact) ? $ownContact->n_fn : '',
($vacation->signature) ? Felamimail_Model_Message::convertHTMLToPlainTextWithQuotes(
preg_replace("/\\r|\\n/", '', $vacation->signature)) : '',
Expand Down

0 comments on commit bf9c008

Please sign in to comment.