From 5ffb31ea7e8820d58dfeffeb294f5d16775c213a Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sat, 20 Mar 2021 15:04:58 +0100 Subject: [PATCH] =?UTF-8?q?Task=20#1907:=20Gestion=20:=20=C3=A9v=C3=A9neme?= =?UTF-8?q?nt=20ajout=20de=20lien=20hyperlnk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/lib/ac_common.php | 12 ++++++++++++ include/template/detail-action.php | 17 +++++++++++------ unit-test/include/lib/ac_common.php | 20 +++++++++++++++++++- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/include/lib/ac_common.php b/include/lib/ac_common.php index 6c9a2d369..8f96a815f 100644 --- a/include/lib/ac_common.php +++ b/include/lib/ac_common.php @@ -1558,4 +1558,16 @@ function rebuild_access_code($pan_code) $sep=($s_result != "" )?"/":""; } return $s_result; +} + +/*** + * Transform a http link into a clickable link + */ +function add_http_link($text) +{ + + $ret=preg_replace("!http[s]{0,1}://[[:graph:]*]*!",'\0',$text); + + return $ret; + } \ No newline at end of file diff --git a/include/template/detail-action.php b/include/template/detail-action.php index 99d70b320..f3769b8a9 100644 --- a/include/template/detail-action.php +++ b/include/template/detail-action.php @@ -1,5 +1,6 @@ '; - echo h($acomment[0]['agc_comment']); + $comment_http= h($acomment[0]['agc_comment']); + $comment_http=add_http_link($comment_http); + echo $comment_http; echo ''; } } else { @@ -305,6 +307,7 @@ function small(p_id_textarea){ echo $description->input(); } + //---------------------------------- Comment ----------------------------------------------------------------------- if ( Document_Option::can_add_comment($ag_id) && @@ -364,7 +367,7 @@ function small(p_id_textarea){ $comment= h($m_desc.' '.$acomment[$c]['agc_id'].'('.$acomment[$c]['tech_user']." ". $acomment[$c]['str_agc_date'].')').$js. '
 '.
-                                " ".h($acomment[$c]['agc_comment']).'
' + " ".add_http_link(h($acomment[$c]['agc_comment'])).'' ; } @@ -373,7 +376,7 @@ function small(p_id_textarea){ $comment=h($m_desc.' '.$acomment[$c]['agc_id'].'('.$acomment[$c]['tech_user']." ". $acomment[$c]['str_agc_date'].')'). '
 '.
-                                    " ".h($acomment[$c]['agc_comment']).'
' + " ".add_http_link(h($acomment[$c]['agc_comment'])).'' ; @@ -394,6 +397,7 @@ function small(p_id_textarea){ } } + @@ -488,6 +492,7 @@ for ($i=0;$i - + Document créé le ag_timestamp ?> par ag_owner?> @@ -571,4 +576,4 @@ Document créé le ag_timestamp ?> par ag_ow $('related_action_div').hide(); $('dependant_action_div').show(); } ; - \ No newline at end of file + diff --git a/unit-test/include/lib/ac_common.php b/unit-test/include/lib/ac_common.php index b2bc19e4e..750fe4f77 100644 --- a/unit-test/include/lib/ac_common.php +++ b/unit-test/include/lib/ac_common.php @@ -167,5 +167,23 @@ class Ac_CommonTest extends TestCase $this->assertEquals( $result, trim(sql_filter_per($g_connection, 98, 99, "p_id", "j_tech_per"))); } - + /*** + * @covers add_http_link + */ + function testAdd_Http_link() + { + $text="A link on http://demo.noalyss.eu is ok"; + $result=add_http_link($text); + $this->assertEquals('A link on http://demo.noalyss.eu is ok',$result); + + $text="A link on https://demo.noalyss.eu/do.php?gDossier=33&ac=COMPTA/MENUFIN is ok"; + $result=add_http_link($text); + $this->assertEquals('A link on https://demo.noalyss.eu/do.php?gDossier=33&ac=COMPTA/MENUFIN is ok',$result); + + + + $text = "The chain is not going to change htps:/demo.noalyss.eu/do.php?gDossier=33&ac=COMPTA/MENUFIN"; + $this->assertEquals($text,$text); + + } }