dolibarr 21.0.0-beta
ajax.php
Go to the documentation of this file.
1<?php
28if (!defined('NOTOKENRENEWAL')) {
29 define('NOTOKENRENEWAL', '1'); // Disables token renewal
30}
31if (!defined('NOREQUIREHTML')) {
32 define('NOREQUIREHTML', '1');
33}
34if (!defined('NOREQUIREAJAX')) {
35 define('NOREQUIREAJAX', '1');
36}
37if (!defined('NOREQUIRESOC')) {
38 define('NOREQUIRESOC', '1');
39}
40// You can get information if module "Agenda" has been enabled by reading the
41if (!defined('NOREQUIREMENU')) {
42 define('NOREQUIREMENU', '1');
43}
44if (!defined("NOLOGIN")) {
45 define("NOLOGIN", '1');
46}
47if (!defined('NOIPCHECK')) {
48 define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
49}
50if (!defined('NOBROWSERNOTIF')) {
51 define('NOBROWSERNOTIF', '1');
52}
53
54include_once '../../../main.inc.php'; // Load $user and permissions
55
60$action = GETPOST('action', 'aZ09');
61$id = GETPOSTINT('id');
62$email = GETPOST('email', 'custom', 0, FILTER_VALIDATE_EMAIL);
63
64
65if (!isModEnabled('ticket')) {
66 httponly_accessforbidden('Module Ticket not enabled');
67}
68
69// Option TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST must be set.
70// Warning: this option is not secured so has been disabled from setup.
71if (!getDolGlobalString('TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST')) {
72 httponly_accessforbidden('Option TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST of module ticket is not enabled');
73}
74
75
76/*
77 * Actions
78 */
79
80// None
81
82
83/*
84 * View
85 */
86
88
89if ($action == 'getContacts') { // Test on permission not required here. Access is allowed only if TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST is on and option has been disabled because not secured.
90 $return = array(
91 'contacts' => array(),
92 'error' => '',
93 );
94
95 if (!empty($email)) {
96 require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
97
98 $ticket = new Ticket($db);
99 $arrayofcontacts = $ticket->searchContactByEmail($email);
100 if (is_array($arrayofcontacts)) {
101 $arrayofminimalcontacts = array();
102 foreach ($arrayofcontacts as $tmpval) {
103 $tmpresult = new stdClass();
104 $tmpresult->id = $tmpval->id;
105 $tmpresult->firstname = $tmpval->firstname;
106 $tmpresult->lastname = $tmpval->lastname;
107 $arrayofminimalcontacts[] = $tmpresult;
108 }
109
110 $return['contacts'] = $arrayofminimalcontacts;
111 } else {
112 $return['error'] = $ticket->errorsToString();
113 }
114 }
115
116 echo json_encode($return);
117 exit();
118}
$id
Definition account.php:48
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
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.