dolibarr  16.0.5
ajax.php
Go to the documentation of this file.
1 <?php
24 if (!defined('NOTOKENRENEWAL')) {
25  define('NOTOKENRENEWAL', '1'); // Disables token renewal
26 }
27 if (!defined('NOREQUIREHTML')) {
28  define('NOREQUIREHTML', '1');
29 }
30 if (!defined('NOREQUIREAJAX')) {
31  define('NOREQUIREAJAX', '1');
32 }
33 if (!defined('NOREQUIRESOC')) {
34  define('NOREQUIRESOC', '1');
35 }
36 if (!defined('NOCSRFCHECK')) {
37  define('NOCSRFCHECK', '1');
38 }
39 // Do not check anti CSRF attack test
40 if (!defined('NOREQUIREMENU')) {
41  define('NOREQUIREMENU', '1');
42 }
43 // If there is no need to load and show top and left menu
44 if (!defined("NOLOGIN")) {
45  define("NOLOGIN", '1');
46 }
47 if (!defined('NOIPCHECK')) {
48  define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
49 }
50 if (!defined('NOBROWSERNOTIF')) {
51  define('NOBROWSERNOTIF', '1');
52 }
53 
54 include_once '../../../main.inc.php'; // Load $user and permissions
55 
56 $action = GETPOST('action', 'aZ09');
57 $id = GETPOST('id', 'int');
58 $email = GETPOST('email', 'custom', 0, FILTER_VALIDATE_EMAIL);
59 
60 
61 if (!isModEnabled('ticket')) {
62  accessforbidden('', 0, 0, 1);
63 }
64 
65 if (empty($conf->global->TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST)) {
66  accessforbidden('', 0, 0, 1);
67 }
68 
69 
70 /*
71  * View
72  */
73 
74 top_httphead();
75 
76 if ($action == 'getContacts') {
77  $return = array(
78  'contacts' => array(),
79  'error' => '',
80  );
81 
82  if (!empty($email)) {
83  require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
84 
85  $ticket = new Ticket($db);
86  $contacts = $ticket->searchContactByEmail($email);
87  if (is_array($contacts)) {
88  $return['contacts'] = $contacts;
89  } else {
90  $return['error'] = $ticket->errorsToString();
91  }
92  }
93 
94  echo json_encode($return);
95  exit();
96 }
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
top_httphead
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
Definition: main.inc.php:1407
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
Ticket
Class to generate the form for creating a new ticket.
Definition: html.formticket.class.php:31
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933