dolibarr  16.0.5
fetchKnowledgeRecord.php
Go to the documentation of this file.
1 <?php
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <https://www.gnu.org/licenses/>.
15  */
16 
22 if (!defined('NOTOKENRENEWAL')) {
23  define('NOTOKENRENEWAL', '1'); // Disables token renewal
24 }
25 if (!defined('NOREQUIREHTML')) {
26  define('NOREQUIREHTML', '1');
27 }
28 if (!defined('NOREQUIREAJAX')) {
29  define('NOREQUIREAJAX', '1');
30 }
31 if (!defined('NOREQUIRESOC')) {
32  define('NOREQUIRESOC', '1');
33 }
34 if (!defined('NOCSRFCHECK')) {
35  define('NOCSRFCHECK', '1');
36 }
37 // Do not check anti CSRF attack test
38 if (!defined('NOREQUIREMENU')) {
39  define('NOREQUIREMENU', '1');
40 }
41 // If there is no need to load and show top and left menu
42 if (!defined("NOLOGIN")) {
43  define("NOLOGIN", '1');
44 }
45 if (!defined('NOIPCHECK')) {
46  define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
47 }
48 if (!defined('NOBROWSERNOTIF')) {
49  define('NOBROWSERNOTIF', '1');
50 }
51 include '../../main.inc.php';
52 
53 $action = GETPOST('action', 'aZ09');
54 $idticketgroup = GETPOST('idticketgroup', 'aZ09');
55 $idticketgroup = GETPOST('idticketgroup', 'aZ09');
56 $lang = GETPOST('lang', 'aZ09');
57 
58 /*
59  * Actions
60  */
61 
62 // None
63 
64 
65 /*
66  * View
67  */
68 
69 if ($action == "getKnowledgeRecord") {
70  $response = '';
71  $sql = "SELECT kr.rowid, kr.ref, kr.question, kr.answer,kr.url,ctc.code";
72  $sql .= " FROM ".MAIN_DB_PREFIX."knowledgemanagement_knowledgerecord as kr ";
73  $sql .= " JOIN ".MAIN_DB_PREFIX."c_ticket_category as ctc ON ctc.rowid = kr.fk_c_ticket_category";
74  $sql .= " WHERE ctc.code = '".$db->escape($idticketgroup)."'";
75  $sql .= " AND ctc.active = 1 AND ctc.public = 1 AND (kr.lang = '".$db->escape($lang)."' OR kr.lang = 0 OR kr.lang IS NULL)";
76  $sql .= " AND kr.status = 1 AND (kr.answer IS NOT NULL AND kr.answer <> '')";
77  $resql = $db->query($sql);
78  if ($resql) {
79  $num = $db->num_rows($resql);
80  $i = 0;
81  $response = array();
82  while ($i < $num) {
83  $obj = $db->fetch_object($resql);
84  $response[] = array('title'=>$obj->question,'ref'=>$obj->ref,'answer'=>dol_escape_htmltag(preg_replace('/\\r|\\r\\n|\\n/', "", $obj->answer)),'url'=>$obj->url);
85  $i++;
86  }
87  } else {
88  dol_print_error($db);
89  }
90  $response =json_encode($response);
91  echo $response;
92 }
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
Definition: functions.lib.php:1468
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742