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 | * wgEvents module for xoops |
||
15 | * |
||
16 | * @copyright 2021 XOOPS Project (https://xoops.org) |
||
17 | * @license GPL 2.0 or later |
||
18 | * @package wgevents |
||
19 | * @author Goffy - Wedega - Email:[email protected] - Website:https://xoops.wedega.com |
||
20 | */ |
||
21 | |||
22 | use Xmf\Request; |
||
23 | use XoopsModules\Wgevents; |
||
24 | use XoopsModules\Wgevents\Constants; |
||
25 | use XoopsModules\Wgevents\Common; |
||
26 | |||
27 | require __DIR__ . '/header.php'; |
||
28 | // Get all request values |
||
29 | $op = Request::getCmd('op', 'list'); |
||
30 | $logId = Request::getInt('id'); |
||
31 | $start = Request::getInt('start'); |
||
32 | $limit = Request::getInt('limit', $helper->getConfig('adminpager')); |
||
33 | $GLOBALS['xoopsTpl']->assign('start', $start); |
||
34 | $GLOBALS['xoopsTpl']->assign('limit', $limit); |
||
35 | |||
36 | $moduleDirName = \basename(\dirname(__DIR__)); |
||
37 | |||
38 | $GLOBALS['xoopsTpl']->assign('mod_url', XOOPS_URL . '/modules/' . $moduleDirName); |
||
39 | |||
40 | switch ($op) { |
||
41 | case 'list': |
||
42 | default: |
||
43 | // Define Stylesheet |
||
44 | $GLOBALS['xoTheme']->addStylesheet($style, null); |
||
45 | $templateMain = 'wgevents_admin_log.tpl'; |
||
46 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('log.php')); |
||
47 | $adminObject->addItemButton(\_AM_WGEVENTS_DELETE_LOGS, 'log.php?op=deleteall', 'delete'); |
||
48 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||
49 | $logCount = $logHandler->getCountLogs(); |
||
50 | $logAll = $logHandler->getAllLogs(); |
||
51 | $GLOBALS['xoopsTpl']->assign('logCount', $logCount); |
||
52 | $GLOBALS['xoopsTpl']->assign('wgevents_url', \WGEVENTS_URL); |
||
53 | $GLOBALS['xoopsTpl']->assign('wgevents_upload_url', \WGEVENTS_UPLOAD_URL); |
||
54 | // Table view logs |
||
55 | if ($logCount > 0) { |
||
56 | foreach (\array_keys($logAll) as $i) { |
||
57 | $log = $logAll[$i]->getValuesLogs(); |
||
58 | $GLOBALS['xoopsTpl']->append('logs_list', $log); |
||
59 | unset($log); |
||
60 | } |
||
61 | } else { |
||
62 | $GLOBALS['xoopsTpl']->assign('error', \_AM_WGEVENTS_THEREARENT_LOGS); |
||
63 | } |
||
64 | break; |
||
65 | case 'save': |
||
66 | // Security Check |
||
67 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
68 | \redirect_header('log.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
69 | } |
||
70 | if ($logId > 0) { |
||
71 | $logObj = $logHandler->get($logId); |
||
72 | } else { |
||
73 | $logObj = $logHandler->create(); |
||
74 | } |
||
75 | // Set Vars |
||
76 | $logObj->setVar('text', Request::getString('text')); |
||
77 | $logDatecreatedObj = \DateTime::createFromFormat(\_SHORTDATESTRING, Request::getString('datecreated')); |
||
78 | $logObj->setVar('datecreated', $logDatecreatedObj->getTimestamp()); |
||
79 | $logObj->setVar('submitter', Request::getInt('submitter')); |
||
80 | // Insert Data |
||
81 | if ($logHandler->insert($logObj)) { |
||
82 | \redirect_header('log.php?op=list&start=' . $start . '&limit=' . $limit, 2, \_AM_WGEVENTS_FORM_OK); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
83 | } |
||
84 | // Get Form |
||
85 | $GLOBALS['xoopsTpl']->assign('error', $logObj->getHtmlErrors()); |
||
86 | $form = $logObj->getForm(); |
||
87 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
88 | break; |
||
89 | case 'edit': |
||
90 | $templateMain = 'wgevents_admin_log.tpl'; |
||
91 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('log.php')); |
||
92 | $adminObject->addItemButton(\_AM_WGEVENTS_ADD_LOG, 'log.php?op=new'); |
||
93 | $adminObject->addItemButton(\_AM_WGEVENTS_LIST_LOGS, 'log.php', 'list'); |
||
94 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||
95 | // Get Form |
||
96 | $logObj = $logHandler->get($logId); |
||
97 | $logObj->start = $start; |
||
98 | $logObj->limit = $limit; |
||
99 | $form = $logObj->getForm(); |
||
100 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
101 | break; |
||
102 | case 'delete': |
||
103 | $templateMain = 'wgevents_admin_log.tpl'; |
||
104 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('log.php')); |
||
105 | $logObj = $logHandler->get($logId); |
||
106 | $logText = $logObj->getVar('text'); |
||
107 | if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) { |
||
108 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
109 | \redirect_header('log.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
||
110 | } |
||
111 | if ($logHandler->delete($logObj)) { |
||
112 | \redirect_header('log.php', 3, \_AM_WGEVENTS_FORM_DELETE_OK); |
||
0 ignored issues
–
show
|
|||
113 | } else { |
||
114 | $GLOBALS['xoopsTpl']->assign('error', $logObj->getHtmlErrors()); |
||
115 | } |
||
116 | } else { |
||
117 | $customConfirm = new Common\Confirm( |
||
118 | ['ok' => 1, 'id' => $logId, 'start' => $start, 'limit' => $limit, 'op' => 'delete'], |
||
119 | $_SERVER['REQUEST_URI'], |
||
120 | \sprintf(\_AM_WGEVENTS_FORM_SURE_DELETE, $logObj->getVar('text'))); |
||
0 ignored issues
–
show
|
|||
121 | $form = $customConfirm->getFormConfirm(); |
||
122 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
123 | } |
||
124 | break; |
||
125 | case 'deleteall': |
||
126 | $templateMain = 'wgevents_admin_log.tpl'; |
||
127 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('log.php')); |
||
128 | if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) { |
||
129 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
130 | \redirect_header('log.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
||
131 | } |
||
132 | $logHandler->deleteAll(); |
||
133 | \redirect_header('log.php', 3, \_MA_WGEVENTS_FORM_DELETE_OK); |
||
134 | } else { |
||
135 | $customConfirm = new Common\Confirm( |
||
136 | ['ok' => 1, 'op' => 'deleteall'], |
||
137 | $_SERVER['REQUEST_URI'], |
||
138 | \sprintf(\_AM_WGEVENTS_FORM_SURE_DELETE_ALL, 'Table Log')); |
||
139 | $form = $customConfirm->getFormConfirm(); |
||
140 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
141 | } |
||
142 | break; |
||
143 | } |
||
144 | require __DIR__ . '/footer.php'; |
||
145 |