[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 08/12: Task #0002125: type , missed phoneTo f
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 08/12: Task #0002125: type , missed phoneTo for mobile , phone and faxTo, several emails separated by a comma |
Date: |
Sat, 17 Sep 2022 08:40:57 -0400 (EDT) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 68d41b82ca0538a1060f8a315fbd690cd2eb7491
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Wed Sep 14 19:38:08 2022 +0200
Task #0002125: type , missed phoneTo for mobile , phone and faxTo, several
emails separated by a comma
---
include/lib/ac_common.php | 32 +++++++++++++++++++++++++++++---
include/template/contact-summary.php | 8 +++-----
unit-test/include/lib/ac_commonTest.php | 20 +++++++++++++++++++-
3 files changed, 51 insertions(+), 9 deletions(-)
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('<a href="mailto:%s">%s</a>',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('<a href="mailto:%s">%s</a> ',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('<a href="fax:%s">%s</a>',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","");
?>
</td>
<td>
- <?=$contact['contact_mobile']?>
+ <?=phoneTo($contact['contact_mobile'])?>
</td>
<td>
<?php
@@ -82,12 +82,10 @@ $from=$http->request("ac","string","");
?>
</td>
<td>
- <?php if (!empty($contact['contact_phone'])):?>
- <a
href="tel:<?=$contact['contact_phone']?>"><?=$contact['contact_phone']?></a>
- <?php endif;?>
+ <?=phoneTo($contact['contact_phone'])?>
</td>
<td>
- <?=$contact['contact_phone']?>
+ <?=FaxTo($contact['contact_fax'])?>
</td>
</tr>
<?php endforeach;?>
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('<a
href="mailto:%s">%s</a>',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('<a
href="mailto:%s">%s</a>',h("test@noalyss.be"),h("test@noalyss.be"));
+ $expect.=sprintf('<a
href="mailto:%s">%s</a>',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('<a href="fax:%s">%s</a>',h(123),h(123));
+ $expect=preg_replace('/\s+/','',$expect);
+
$this->assertEquals(strtoupper($expect),strtoupper(preg_replace("/\s+/",'',faxTo('123'))),);
}
}
- [Noalyss-commit] [noalyss] branch master updated (da636cf6e -> f1d3862e1), Dany De Bontridder, 2022/09/17
- [Noalyss-commit] [noalyss] 07/12: Improve test, Dany De Bontridder, 2022/09/17
- [Noalyss-commit] [noalyss] 04/12: Task #0002125: Contact , devrait être refait sur le modèle de Fiche->résumé, Dany De Bontridder, 2022/09/17
- [Noalyss-commit] [noalyss] 08/12: Task #0002125: type , missed phoneTo for mobile , phone and faxTo, several emails separated by a comma,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 01/12: Fix Bug : accounting history was not shown when dble clicked, Dany De Bontridder, 2022/09/17
- [Noalyss-commit] [noalyss] 06/12: SQL If nothing is loaded return false, otherwise true, Dany De Bontridder, 2022/09/17
- [Noalyss-commit] [noalyss] 02/12: New #0002193: Possibilité d'ajouter directement une note aux opérations Cosmetic : change icon for enlarging operation label, Dany De Bontridder, 2022/09/17
- [Noalyss-commit] [noalyss] 09/12: Improve PHPUNIT, Dany De Bontridder, 2022/09/17
- [Noalyss-commit] [noalyss] 11/12: New #2195 0002195: Création catégorie : ordre des attributs, Dany De Bontridder, 2022/09/17
- [Noalyss-commit] [noalyss] 03/12: Improve autoloader, Dany De Bontridder, 2022/09/17
- [Noalyss-commit] [noalyss] 05/12: New function mailto and tel, Dany De Bontridder, 2022/09/17
- [Noalyss-commit] [noalyss] 12/12: Improve #0002196: Comptes Alphanumériques calculés trop longs, Dany De Bontridder, 2022/09/17
- [Noalyss-commit] [noalyss] 10/12: Add function linkTo for URL, Dany De Bontridder, 2022/09/17