dolibarr 21.0.0-alpha
ajax.php
Go to the documentation of this file.
1<?php
27if (!defined('NOTOKENRENEWAL')) {
28 define('NOTOKENRENEWAL', '1'); // Disables token renewal
29}
30if (!defined('NOREQUIREHTML')) {
31 define('NOREQUIREHTML', '1');
32}
33if (!defined('NOREQUIREAJAX')) {
34 define('NOREQUIREAJAX', '1');
35}
36if (!defined('NOREQUIRESOC')) {
37 define('NOREQUIRESOC', '1');
38}
39// You can get information if module "Agenda" has been enabled by reading the
40if (!defined('NOREQUIREMENU')) {
41 define('NOREQUIREMENU', '1');
42}
43if (!defined("NOLOGIN")) {
44 define("NOLOGIN", '1');
45}
46if (!defined('NOIPCHECK')) {
47 define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
48}
49if (!defined('NOBROWSERNOTIF')) {
50 define('NOBROWSERNOTIF', '1');
51}
52
53include_once '../../../main.inc.php'; // Load $user and permissions
54
55$action = GETPOST('action', 'aZ09');
56$id = GETPOSTINT('id');
57$email = GETPOST('email', 'custom', 0, FILTER_VALIDATE_EMAIL);
58
59
60if (!isModEnabled('ticket')) {
61 httponly_accessforbidden('Module Ticket not enabled');
62}
63
64// Option TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST must be set.
65// Warning: this option is not secured so has been disabled from setup.
66if (!getDolGlobalString('TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST')) {
67 httponly_accessforbidden('Option TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST of module ticket is not enabled');
68}
69
70
71/*
72 * Actions
73 */
74
75// None
76
77
78/*
79 * View
80 */
81
83
84if ($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.
85 $return = array(
86 'contacts' => array(),
87 'error' => '',
88 );
89
90 if (!empty($email)) {
91 require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
92
93 $ticket = new Ticket($db);
94 $arrayofcontacts = $ticket->searchContactByEmail($email);
95 if (is_array($arrayofcontacts)) {
96 $arrayofminimalcontacts = array();
97 foreach ($arrayofcontacts as $tmpval) {
98 $tmpresult = new stdClass();
99 $tmpresult->id = $tmpval->id;
100 $tmpresult->firstname = $tmpval->firstname;
101 $tmpresult->lastname = $tmpval->lastname;
102 $arrayofminimalcontacts[] = $tmpresult;
103 }
104
105 $return['contacts'] = $arrayofminimalcontacts;
106 } else {
107 $return['error'] = $ticket->errorsToString();
108 }
109 }
110
111 echo json_encode($return);
112 exit();
113}
$id
Definition account.php:39
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.