|
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\ { |
|
25
|
|
|
Constants, |
|
26
|
|
|
Common, |
|
27
|
|
|
Utility |
|
28
|
|
|
}; |
|
29
|
|
|
|
|
30
|
|
|
require __DIR__ . '/header.php'; |
|
31
|
|
|
// Get all request values |
|
32
|
|
|
$op = Request::getCmd('op', 'list'); |
|
33
|
|
|
$regId = Request::getInt('id'); |
|
34
|
|
|
$evId = Request::getInt('evid'); |
|
35
|
|
|
$start = Request::getInt('start'); |
|
36
|
|
|
$limit = Request::getInt('limit', $helper->getConfig('adminpager')); |
|
37
|
|
|
$GLOBALS['xoopsTpl']->assign('start', $start); |
|
38
|
|
|
$GLOBALS['xoopsTpl']->assign('limit', $limit); |
|
39
|
|
|
|
|
40
|
|
|
$moduleDirName = \basename(\dirname(__DIR__)); |
|
41
|
|
|
|
|
42
|
|
|
$GLOBALS['xoopsTpl']->assign('mod_url', XOOPS_URL . '/modules/' . $moduleDirName); |
|
43
|
|
|
|
|
44
|
|
|
switch ($op) { |
|
45
|
|
|
case 'list': |
|
46
|
|
|
default: |
|
47
|
|
|
// Define Stylesheet |
|
48
|
|
|
$GLOBALS['xoTheme']->addStylesheet($style, null); |
|
49
|
|
|
$templateMain = 'wgevents_admin_registrationhist.tpl'; |
|
50
|
|
|
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('registrationhist.php')); |
|
51
|
|
|
if ($evId > 0) { |
|
52
|
|
|
$crRegistrationhist = new \CriteriaCompo(); |
|
53
|
|
|
$crRegistrationhist->add(new \Criteria('evid', $evId)); |
|
54
|
|
|
$registrationhistCount = $registrationhistHandler->getCount($crRegistrationhist); |
|
55
|
|
|
$GLOBALS['xoopsTpl']->assign('registrationhistCount', $registrationhistCount); |
|
56
|
|
|
$GLOBALS['xoopsTpl']->assign('wgevents_url', \WGEVENTS_URL); |
|
57
|
|
|
$GLOBALS['xoopsTpl']->assign('wgevents_upload_url', \WGEVENTS_UPLOAD_URL); |
|
58
|
|
|
// Table view registrationhists |
|
59
|
|
|
if ($registrationhistCount > 0) { |
|
60
|
|
|
$crRegistrationhist->setSort('id'); |
|
61
|
|
|
$crRegistrationhist->setOrder('DESC'); |
|
62
|
|
|
$registrationhistAll = $registrationhistHandler->getAll($crRegistrationhist); |
|
63
|
|
|
foreach (\array_keys($registrationhistAll) as $i) { |
|
64
|
|
|
$registrationhist = $registrationhistAll[$i]->getValuesRegistrationhists(); |
|
65
|
|
|
$GLOBALS['xoopsTpl']->append('registrationhists_list', $registrationhist); |
|
66
|
|
|
unset($registrationhist); |
|
67
|
|
|
} |
|
68
|
|
|
} else { |
|
69
|
|
|
$GLOBALS['xoopsTpl']->assign('error', \_AM_WGEVENTS_THEREARENT_REGISTRATIONHISTS); |
|
70
|
|
|
} |
|
71
|
|
|
} else { |
|
72
|
|
|
$GLOBALS['xoopsTpl']->assign('eventsHeader', \sprintf(_AM_WGEVENTS_LIST_EVENTS_LAST, $limit)); |
|
73
|
|
|
$eventCount = $eventHandler->getCountEvents(); |
|
74
|
|
|
$GLOBALS['xoopsTpl']->append('eventCount', $eventCount); |
|
75
|
|
|
// Table view events |
|
76
|
|
|
if ($eventCount > 0) { |
|
77
|
|
|
$eventAll = $eventHandler->getAllEvents(); |
|
78
|
|
|
foreach (\array_keys($eventAll) as $i) { |
|
79
|
|
|
$event = $eventAll[$i]->getValuesEvents(); |
|
80
|
|
|
$crRegistrationhist = new \CriteriaCompo(); |
|
81
|
|
|
$crRegistrationhist->add(new \Criteria('evid', $i)); |
|
82
|
|
|
$registrationhistCount = $registrationhistHandler->getCount($crRegistrationhist); |
|
83
|
|
|
$event['registrationhists'] = $registrationhistCount; |
|
84
|
|
|
$GLOBALS['xoopsTpl']->append('events_list', $event); |
|
85
|
|
|
unset($event); |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
break; |
|
90
|
|
|
/* |
|
91
|
|
|
case 'delete': |
|
92
|
|
|
$templateMain = 'wgevents_admin_registrationhist.tpl'; |
|
93
|
|
|
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('registrationhist.php')); |
|
94
|
|
|
$registrationhistObj = $registrationhistHandler->get($regId); |
|
95
|
|
|
$regEvid = $registrationhistObj->getVar('evid'); |
|
96
|
|
|
if (isset($_REQUEST['ok']) && 1 === (int)$_REQUEST['ok']) { |
|
97
|
|
|
if (!$GLOBALS['xoopsSecurity']->check()) { |
|
98
|
|
|
\redirect_header('registrationhist.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
|
99
|
|
|
} |
|
100
|
|
|
if ($registrationhistHandler->delete($registrationhistObj)) { |
|
101
|
|
|
//delete existing answers |
|
102
|
|
|
$answerHandler->cleanupAnswers($regEvid, $regId); |
|
103
|
|
|
\redirect_header('registrationhist.php', 3, \_MA_WGEVENTS_FORM_DELETE_OK); |
|
104
|
|
|
} else { |
|
105
|
|
|
$GLOBALS['xoopsTpl']->assign('error', $registrationhistObj->getHtmlErrors()); |
|
106
|
|
|
} |
|
107
|
|
|
} else { |
|
108
|
|
|
$customConfirm = new Common\Confirm( |
|
109
|
|
|
['ok' => 1, 'id' => $regId, 'start' => $start, 'limit' => $limit, 'op' => 'delete'], |
|
110
|
|
|
$_SERVER['REQUEST_URI'], |
|
111
|
|
|
\sprintf(\_MA_WGEVENTS_FORM_SURE_DELETE, $registrationhistObj->getVar('evid'))); |
|
112
|
|
|
$form = $customConfirm->getFormConfirm(); |
|
113
|
|
|
$GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
114
|
|
|
} |
|
115
|
|
|
break; |
|
116
|
|
|
*/ |
|
117
|
|
|
} |
|
118
|
|
|
require __DIR__ . '/footer.php'; |
|
119
|
|
|
|
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: