|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* You may not change or alter any portion of this comment or credits |
|
5
|
|
|
* of supporting developers from this source code or any supporting source code |
|
6
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
7
|
|
|
* |
|
8
|
|
|
* This program is distributed in the hope that it will be useful, |
|
9
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
|
15
|
|
|
* @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
|
16
|
|
|
* @author Brian Wahoff <[email protected]> |
|
17
|
|
|
* @author Eric Juden <[email protected]> |
|
18
|
|
|
* @author XOOPS Development Team |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
use Xmf\Request; |
|
22
|
|
|
use XoopsModules\Xhelp; |
|
23
|
|
|
|
|
24
|
|
|
/** @var Xhelp\Helper $helper */ |
|
25
|
|
|
|
|
26
|
|
|
require_once __DIR__ . '/header.php'; |
|
27
|
|
|
require_once XHELP_INCLUDE_PATH . '/events.php'; |
|
28
|
|
|
//require_once XHELP_BASE_PATH . '/functions.php'; |
|
29
|
|
|
|
|
30
|
|
|
global $xoopsUser, $xoopsDB, $xoopsConfig, $xoopsModuleConfig, $xoopsModule; |
|
31
|
|
|
|
|
32
|
|
|
$eventService = Xhelp\EventService::getInstance(); |
|
33
|
|
|
|
|
34
|
|
|
$xhelp_id = 0; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @todo move these into ticket.php and profile.php respectivly |
|
38
|
|
|
*/ |
|
39
|
|
|
if ($xoopsUser) { |
|
40
|
|
|
$uid = $xoopsUser->getVar('uid'); |
|
41
|
|
|
|
|
42
|
|
|
if (Request::hasVar('delete_ticket', 'POST')) { |
|
43
|
|
|
$ticketHandler = Xhelp\Helper::getInstance() |
|
44
|
|
|
->getHandler('Ticket'); |
|
45
|
|
|
if (Request::hasVar('ticketid', 'POST')) { |
|
46
|
|
|
$xhelp_id = $_POST['ticketid']; |
|
47
|
|
|
} |
|
48
|
|
|
$ticketInfo = $ticketHandler->get($xhelp_id); // Retrieve ticket information |
|
49
|
|
|
if ($ticketHandler->delete($ticketInfo)) { |
|
|
|
|
|
|
50
|
|
|
$message = _XHELP_MESSAGE_DELETE_TICKET; |
|
51
|
|
|
$eventService->trigger('delete_ticket', [&$ticketInfo]); |
|
52
|
|
|
} else { |
|
53
|
|
|
$message = _XHELP_MESSAGE_DELETE_TICKET_ERROR; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
$helper->redirect('index.php', 3, $message); |
|
57
|
|
|
} elseif (Request::hasVar('delete_responseTpl', 'POST')) { |
|
58
|
|
|
//Should only the owner of a template be able to delete it? |
|
59
|
|
|
$responseTemplatesHandler = Xhelp\Helper::getInstance() |
|
60
|
|
|
->getHandler('ResponseTemplates'); |
|
61
|
|
|
$displayTpl = $responseTemplatesHandler->get($_POST['tplID']); |
|
62
|
|
|
if ($xoopsUser->getVar('uid') != $displayTpl->getVar('uid')) { |
|
63
|
|
|
$message = _NOPERM; |
|
64
|
|
|
} else { |
|
65
|
|
|
if ($responseTemplatesHandler->delete($displayTpl)) { |
|
66
|
|
|
$message = _XHELP_MESSAGE_DELETE_RESPONSE_TPL; |
|
67
|
|
|
$eventService->trigger('delete_responseTpl', [$displayTpl]); |
|
68
|
|
|
} else { |
|
69
|
|
|
$message = _XHELP_MESSAGE_DELETE_RESPONSE_TPL_ERROR; |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
$helper->redirect('profile.php', 3, $message); |
|
73
|
|
|
} |
|
74
|
|
|
} else { // If not a user |
|
75
|
|
|
redirect_header(XOOPS_URL . '/user.php', 3); |
|
76
|
|
|
} |
|
77
|
|
|
|