diff --git a/include/lib/ac_common.php b/include/lib/ac_common.php
index 5bd7d8f28..2398f8fcd 100644
--- a/include/lib/ac_common.php
+++ b/include/lib/ac_common.php
@@ -1637,12 +1637,38 @@ function phoneTo($p_tel) {
/**
* @brief compose a HTML string with email
- * @param $p_email
+ * @param string $p_email email or emails separated by a comma
* @return false|string returns false if email not valide
*/
function mailTo($p_email) {
- if ( filter_var($p_email,FILTER_VALIDATE_EMAIL) ) {
- $r=sprintf('%s',h($p_email),h($p_email));
+ if (empty($p_email )) return "";
+ $nComma=preg_match("/,/",$p_email);
+ if ( $nComma > 0) {
+ $aEmail=explode(",",$p_email);
+ } else {
+ $aEmail[0]=$p_email;
+ }
+ $r="";
+ foreach ($aEmail as $email) {
+ if ( filter_var(trim($email),FILTER_VALIDATE_EMAIL) ) {
+ $r.=sprintf('%s ',h($email),h($email));
+ } else {
+ $r.=sprintf("%s",h($email));
+
+ }
+
+ }
+ return $r;
+}
+
+/**
+ * @brief compose a HTML string with fax
+ * @param string $p_fax fax number
+ * @return false|string returns false if $p_fax is empty
+ */
+function FaxTo($p_tel) {
+ if (!empty($p_tel)) {
+ $r=sprintf('%s',h($p_tel),h($p_tel));
return $r;
}
return false;
diff --git a/include/template/contact-summary.php b/include/template/contact-summary.php
index d13a34695..b4ebb3fa6 100644
--- a/include/template/contact-summary.php
+++ b/include/template/contact-summary.php
@@ -68,7 +68,7 @@ $from=$http->request("ac","string","");
?>
- =$contact['contact_mobile']?>
+ =phoneTo($contact['contact_mobile'])?>
|
request("ac","string","");
?>
|
-
- =$contact['contact_phone']?>
-
+ =phoneTo($contact['contact_phone'])?>
|
- =$contact['contact_phone']?>
+ =FaxTo($contact['contact_fax'])?>
|
diff --git a/unit-test/include/lib/ac_commonTest.php b/unit-test/include/lib/ac_commonTest.php
index 4cbcee8b4..510395b17 100644
--- a/unit-test/include/lib/ac_commonTest.php
+++ b/unit-test/include/lib/ac_commonTest.php
@@ -393,7 +393,25 @@ class Ac_CommonTest extends TestCase
$expect=sprintf('%s',h("test@noalyss.be"),h("test@noalyss.be"));
$expect=preg_replace('/\s+/','',$expect);
$this->assertEquals(strtoupper($expect),strtoupper(preg_replace("/\s+/",'',mailTo('test@noalyss.be'))),);
- $this->assertFalse(mailTo('test@noalyss.@be'),"Send email to invalidate email");
+ $this->assertEquals('test@noalyss.@be',mailTo('test@noalyss.@be'),"Send email to invalidate email");
+ $expect=sprintf('%s',h("test@noalyss.be"),h("test@noalyss.be"));
+ $expect.=sprintf('%s',h("test2@noalyss.be"),h("test2@noalyss.be"));
+ $expect=preg_replace('/\s+/','',$expect);
+ $this->assertEquals($expect,
+ preg_replace('/\s+/','',mailTo('test@noalyss.be,test2@noalyss.be'))
+ ,"Send email to invalidate email");
+
+ }
+ /**
+ * @testdox Test the FAX tag
+ * @return void
+ */
+ function testFaxTo()
+ {
+ $this->assertFalse(faxTo(""),"Invalide phone");
+ $expect=sprintf('%s',h(123),h(123));
+ $expect=preg_replace('/\s+/','',$expect);
+ $this->assertEquals(strtoupper($expect),strtoupper(preg_replace("/\s+/",'',faxTo('123'))),);
}
}