From 04a024570c99432b09a8245bfd88505769447d0e Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 16 Sep 2021 13:19:43 +0200 Subject: [PATCH] update fetchKnowledge and html.formticket --- htdocs/core/ajax/fetchKnowledgeRecord.php | 50 ++++++++++++++++++--- htdocs/core/class/html.formticket.class.php | 4 +- 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/htdocs/core/ajax/fetchKnowledgeRecord.php b/htdocs/core/ajax/fetchKnowledgeRecord.php index a1f8ae6a1e9..00294d1b3c9 100644 --- a/htdocs/core/ajax/fetchKnowledgeRecord.php +++ b/htdocs/core/ajax/fetchKnowledgeRecord.php @@ -22,9 +22,6 @@ if (!defined('NOTOKENRENEWAL')) { define('NOTOKENRENEWAL', '1'); // Disables token renewal } -if (!defined('NOREQUIREMENU')) { - define('NOREQUIREMENU', '1'); -} if (!defined('NOREQUIREHTML')) { define('NOREQUIREHTML', '1'); } @@ -34,13 +31,30 @@ if (!defined('NOREQUIREAJAX')) { if (!defined('NOREQUIRESOC')) { define('NOREQUIRESOC', '1'); } - +if (!defined('NOCSRFCHECK')) { + define('NOCSRFCHECK', '1'); +} +// Do not check anti CSRF attack test +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', '1'); +} +// If there is no need to load and show top and left menu +if (!defined("NOLOGIN")) { + define("NOLOGIN", '1'); +} +if (!defined('NOIPCHECK')) { + define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +} +if (!defined('NOBROWSERNOTIF')) { + define('NOBROWSERNOTIF', '1'); +} include '../../main.inc.php'; $action = GETPOST('action', 'aZ09'); $idticketgroup = GETPOST('idticketgroup', 'aZ09'); $idticketgroup = GETPOST('idticketgroup', 'aZ09'); $lang = GETPOST('lang', 'aZ09'); +$popupurl = GETPOST('popupurl', 'bool'); /* * Actions @@ -69,7 +83,33 @@ if ($action == "getKnowledgeRecord") { $response = array(); while ($i < $num) { $obj = $db->fetch_object($resql); - $response[] = array('title'=>$obj->question,'ref'=>$obj->url,'answer'=>$obj->answer,'url'=>$obj->url); + if ($popupurl == "false") { + $url = "url. "\" target=\"_blank\">".$obj->url.""; + $response[] = array('title'=>$obj->question,'ref'=>$obj->url,'answer'=>$obj->answer,'url'=>$url); + } else { + $name = $obj->ref; + $buttonstring = $obj->url; + $url = $obj->url; + $urltoprint = ''.$buttonstring.''; + $urltoprint .= ''; + $urltoprint .= ''; + $response[] = array('title'=>$obj->question,'ref'=>$obj->url,'answer'=>$obj->answer,'url'=>$urltoprint); + } $i++; } } else { diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 496778525d1..a4774898018 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -258,7 +258,7 @@ class FormTicket if (idgroupticket != "") { $.ajax({ url: \''.DOL_URL_ROOT.'/core/ajax/fetchKnowledgeRecord.php\', - data: { action: \'getKnowledgeRecord\', idticketgroup: idgroupticket, token: \''.newToken().'\', lang:\''.$langs->defaultlang.'\'}, + data: { action: \'getKnowledgeRecord\', idticketgroup: idgroupticket, token: \''.newToken().'\', lang:\''.$langs->defaultlang.'\', popupurl:false}, type: \'GET\', success: function(response) { var urllist = \'\'; @@ -266,7 +266,7 @@ class FormTicket response = JSON.parse(response) for (key in response) { console.log(response[key]) - urllist += "
  • " + response[key].title + ": " + \'"+response[key].url+"
  • "; + urllist += "
  • " + response[key].title + ": " +response[key].url+"
  • "; } if (urllist != "") { console.log(urllist)