Skip to content

Commit 85609c4

Browse files
committed
fix(targetticket,targethange,targetproblem): add missing file
1 parent 7872379 commit 85609c4

File tree

2 files changed

+1688
-0
lines changed

2 files changed

+1688
-0
lines changed

ajax/target_actor.php

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
/**
3+
* ---------------------------------------------------------------------
4+
* Formcreator is a plugin which allows creation of custom forms of
5+
* easy access.
6+
* ---------------------------------------------------------------------
7+
* LICENSE
8+
*
9+
* This file is part of Formcreator.
10+
*
11+
* Formcreator is free software; you can redistribute it and/or modify
12+
* it under the terms of the GNU General Public License as published by
13+
* the Free Software Foundation; either version 2 of the License, or
14+
* (at your option) any later version.
15+
*
16+
* Formcreator is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU General Public License
22+
* along with Formcreator. If not, see <http://www.gnu.org/licenses/>.
23+
* ---------------------------------------------------------------------
24+
* @copyright Copyright © 2011 - 2021 Teclib'
25+
* @license http://www.gnu.org/licenses/gpl.txt GPLv3+
26+
* @link https://github.com/pluginsGLPI/formcreator/
27+
* @link https://pluginsglpi.github.io/formcreator/
28+
* @link http://plugins.glpi-project.org/#/plugin/formcreator
29+
* ---------------------------------------------------------------------
30+
*/
31+
32+
include ('../../../inc/includes.php');
33+
34+
// Check if plugin is activated...
35+
if (!(new Plugin())->isActivated('formcreator')) {
36+
http_response_code(404);
37+
exit();
38+
}
39+
40+
if (!isset($_POST['action'])) {
41+
http_response_code(400);
42+
die();
43+
}
44+
45+
46+
switch ($_POST['action']) {
47+
case 'add':
48+
$id = (int) $_POST['id'];
49+
$actor_value = $_POST['actor_value_' . $_POST['actor_type']] ?? 0;
50+
$target_actor = new PluginFormcreatorTarget_Actor();
51+
if ($target_actor->add($_POST) === false) {
52+
http_response_code(500);
53+
Session::addMessageAfterRedirect(__('Failed to add the actor', 'formcreator'), false, ERROR, true);
54+
}
55+
break;
56+
57+
case 'delete':
58+
$target_actor = new PluginFormcreatorTarget_Actor();
59+
$success = $target_actor->delete([
60+
'id' => (int) $_POST['id']
61+
]);
62+
if (!$success) {
63+
http_response_code(400);
64+
Session::addMessageAfterRedirect(__('Failed to delete the actor', 'formcreator'), false, ERROR, true);
65+
}
66+
break;
67+
}

0 commit comments

Comments
 (0)