| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <?php
- /* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
- * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
- * Copyright (C) 2007-2020 Laurent Destailleur <eldy@users.sourceforge.net>
- * Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
- /**
- * \file htdocs/projet/ajax/projects.php
- * \brief File to return Ajax response on product list request
- */
- if (!defined('NOTOKENRENEWAL')) {
- define('NOTOKENRENEWAL', 1); // Disables token renewal
- }
- if (!defined('NOREQUIREMENU')) {
- define('NOREQUIREMENU', '1');
- }
- if (!defined('NOREQUIREHTML')) {
- define('NOREQUIREHTML', '1');
- }
- if (!defined('NOREQUIREAJAX')) {
- define('NOREQUIREAJAX', '1');
- }
- if (!defined('NOREQUIRESOC')) {
- define('NOREQUIRESOC', '1');
- }
- if (!defined('NOCSRFCHECK')) {
- define('NOCSRFCHECK', '1');
- }
- if (empty($_GET['keysearch']) && !defined('NOREQUIREHTML')) {
- define('NOREQUIREHTML', '1');
- }
- require '../../../main.inc.php';
- dol_include_once('/documentfollower/class/documentfollowerprocess.class.php');
- dol_include_once('/documentfollower/class/dfprocessajaxhandler.class.php');
- /*
- * View
- */
- dol_syslog("Call ajax custom/documentfollower/ajax/dfprocess.php");
- top_httphead('application/json');
- $ref = GETPOST('ref', 'aZ09');
- $id = GETPOST('id', 'aZ09');
- $operation = GETPOST('type', 'int');
- $level = GETPOST('level', 'int');
- $description = GETPOST('description', 'aZ09');
- // missing parameters
- if (empty($id) || empty($ref)) {
- http_response_code(400);
- return;
- }
- // object by ref
- $object = new DocumentFollowerProcess($db);
- if ($object->fetch(null, $ref) < 1) {
- http_response_code(404);
- return;
- }
- // encoded ID not equals with the parameter ID
- if (hash('sha512', $object->id) !== $id) {
- http_response_code(500);
- return;
- }
- $ajaxResult = [];
- try {
- if (empty($level)) {
- $level = null;
- }
- (new DfProcessAjaxHandler($object, $operation, $level, $description))->process();
- $ajaxResult = [
- 'success' => [
- 'message' => 'Sikeres mentés'
- ]
- ];
- } catch (\Exception $e) {
- $ajaxResult['error'] = [
- 'message' => 'Hiba történt a feldolgozás során'
- ];
- }
- $db->close();
- echo json_encode($ajaxResult);
|