dolibarr  17.0.4
ajax.php
Go to the documentation of this file.
1 <?php
27 if (!defined('NOTOKENRENEWAL')) {
28  define('NOTOKENRENEWAL', '1'); // Disables token renewal
29 }
30 if (!defined('NOREQUIREHTML')) {
31  define('NOREQUIREHTML', '1');
32 }
33 if (!defined('NOREQUIREAJAX')) {
34  define('NOREQUIREAJAX', '1');
35 }
36 if (!defined('NOREQUIRESOC')) {
37  define('NOREQUIRESOC', '1');
38 }
39 // You can get information if module "Agenda" has been enabled by reading the
40 if (!defined('NOREQUIREMENU')) {
41  define('NOREQUIREMENU', '1');
42 }
43 if (!defined("NOLOGIN")) {
44  define("NOLOGIN", '1');
45 }
46 if (!defined('NOIPCHECK')) {
47  define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
48 }
49 if (!defined('NOBROWSERNOTIF')) {
50  define('NOBROWSERNOTIF', '1');
51 }
52 
53 include_once '../../../main.inc.php'; // Load $user and permissions
54 
55 $action = GETPOST('action', 'aZ09');
56 $id = GETPOST('id', 'int');
57 $email = GETPOST('email', 'custom', 0, FILTER_VALIDATE_EMAIL);
58 
59 
60 if (!isModEnabled('ticket')) {
61  httponly_accessforbidden('Module Ticket not enabled');
62 }
63 
64 if (empty($conf->global->TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST)) {
65  httponly_accessforbidden('Option TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST of module ticket is not enabled');
66 }
67 
68 
69 /*
70  * View
71  */
72 
73 top_httphead();
74 
75 if ($action == 'getContacts') {
76  $return = array(
77  'contacts' => array(),
78  'error' => '',
79  );
80 
81  if (!empty($email)) {
82  require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
83 
84  $ticket = new Ticket($db);
85  $arrayofcontacts = $ticket->searchContactByEmail($email);
86  if (is_array($arrayofcontacts)) {
87  $arrayofminimalcontacts = array();
88  foreach ($arrayofcontacts as $tmpval) {
89  $tmpresult = new stdClass();
90  $tmpresult->id = $tmpval->id;
91  $tmpresult->firstname = $tmpval->firstname;
92  $tmpresult->lastname = $tmpval->lastname;
93  $arrayofminimalcontacts[] = $tmpresult;
94  }
95 
96  $return['contacts'] = $arrayofminimalcontacts;
97  } else {
98  $return['error'] = $ticket->errorsToString();
99  }
100  }
101 
102  echo json_encode($return);
103  exit();
104 }
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
isModEnabled($module)
Is Dolibarr module enabled.
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
Definition: main.inc.php:1440
Class to generate the form for creating a new ticket.
httponly_accessforbidden($message=1, $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.