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
|
|
|
$ansId = Request::getInt('id'); |
31
|
|
|
$evId = Request::getInt('evid'); |
32
|
|
|
$start = Request::getInt('start'); |
33
|
|
|
$limit = Request::getInt('limit', $helper->getConfig('adminpager')); |
34
|
|
|
$GLOBALS['xoopsTpl']->assign('start', $start); |
35
|
|
|
$GLOBALS['xoopsTpl']->assign('limit', $limit); |
36
|
|
|
|
37
|
|
|
$moduleDirName = \basename(\dirname(__DIR__)); |
38
|
|
|
|
39
|
|
|
$GLOBALS['xoopsTpl']->assign('mod_url', XOOPS_URL . '/modules/' . $moduleDirName); |
40
|
|
|
|
41
|
|
|
switch ($op) { |
42
|
|
|
case 'list': |
43
|
|
|
default: |
44
|
|
|
// Define Stylesheet |
45
|
|
|
$GLOBALS['xoTheme']->addStylesheet($style, null); |
46
|
|
|
$templateMain = 'wgevents_admin_answerhist.tpl'; |
47
|
|
|
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('answerhists.php')); |
48
|
|
|
if ($evId > 0) { |
49
|
|
|
// get all questions for this event |
50
|
|
|
$questionsArr = $questionHandler->getQuestionsByEvent($evId); |
51
|
|
|
//get answers |
52
|
|
|
$crAnswerhists = new \CriteriaCompo(); |
53
|
|
|
$crAnswerhists->add(new \Criteria('evid', $evId)); |
54
|
|
|
$answerhistCount = $answerhistHandler->getCount($crAnswerhists); |
55
|
|
|
$GLOBALS['xoopsTpl']->assign('answerhistCount', $answerhistCount); |
56
|
|
|
$GLOBALS['xoopsTpl']->assign('wgevents_url', \WGEVENTS_URL); |
57
|
|
|
$GLOBALS['xoopsTpl']->assign('wgevents_upload_url', \WGEVENTS_UPLOAD_URL); |
58
|
|
|
// Table view answerhistss |
59
|
|
|
if ($answerhistCount > 0) { |
60
|
|
|
$answerhistsAll = $answerhistHandler->getAll($crAnswerhists); |
61
|
|
|
foreach (\array_keys($answerhistsAll) as $i) { |
62
|
|
|
$answerhists = $answerhistsAll[$i]->getValuesAnswerhists($questionsArr); |
63
|
|
|
$registrationObj = $registrationHandler->get($answerhists['regid']); |
64
|
|
|
$regname = 'deleted registration'; |
65
|
|
|
if (is_object($registrationObj)) { |
66
|
|
|
$regname = $registrationObj->getVar('firstname') . ' ' . $registrationObj->getVar('lastname'); |
67
|
|
|
} |
68
|
|
|
$answerhists['regname'] = $regname; |
69
|
|
|
$GLOBALS['xoopsTpl']->append('answerhists_list', $answerhists); |
70
|
|
|
unset($answerhists); |
71
|
|
|
} |
72
|
|
|
} else { |
73
|
|
|
$GLOBALS['xoopsTpl']->assign('error', \_AM_WGEVENTS_THEREARENT_ANSWERHISTS); |
74
|
|
|
} |
75
|
|
|
} else { |
76
|
|
|
$GLOBALS['xoopsTpl']->assign('eventsHeader', \sprintf(_AM_WGEVENTS_LIST_EVENTS_LAST, $limit)); |
77
|
|
|
$eventCount = $eventHandler->getCountEvents(); |
78
|
|
|
$GLOBALS['xoopsTpl']->append('eventCount', $eventCount); |
79
|
|
|
// Table view events |
80
|
|
|
if ($eventCount > 0) { |
81
|
|
|
$eventAll = $eventHandler->getAllEvents(); |
82
|
|
|
foreach (\array_keys($eventAll) as $i) { |
83
|
|
|
$event = $eventAll[$i]->getValuesEvents(); |
84
|
|
|
$crAnswerhists = new \CriteriaCompo(); |
85
|
|
|
$crAnswerhists->add(new \Criteria('evid', $i)); |
86
|
|
|
$answerhistCount = $answerhistHandler->getCount($crAnswerhists); |
87
|
|
|
$event['answerhists'] = $answerhistCount; |
88
|
|
|
$GLOBALS['xoopsTpl']->append('events_list', $event); |
89
|
|
|
unset($event); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
break; |
94
|
|
|
/* |
95
|
|
|
case 'delete': |
96
|
|
|
$templateMain = 'wgevents_admin_answer.tpl'; |
97
|
|
|
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('answer.php')); |
98
|
|
|
$answerObj = $answerHandler->get($ansId); |
99
|
|
|
$ansEvid = $answerObj->getVar('evid'); |
100
|
|
|
if (isset($_REQUEST['ok']) && 1 === (int)$_REQUEST['ok']) { |
101
|
|
|
if (!$GLOBALS['xoopsSecurity']->check()) { |
102
|
|
|
\redirect_header('answer.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
103
|
|
|
} |
104
|
|
|
if ($answerHandler->delete($answerObj)) { |
105
|
|
|
\redirect_header('answer.php', 3, \_MA_WGEVENTS_FORM_DELETE_OK); |
106
|
|
|
} else { |
107
|
|
|
$GLOBALS['xoopsTpl']->assign('error', $answerObj->getHtmlErrors()); |
108
|
|
|
} |
109
|
|
|
} else { |
110
|
|
|
$customConfirm = new Common\Confirm( |
111
|
|
|
['ok' => 1, 'id' => $ansId, 'start' => $start, 'limit' => $limit, 'op' => 'delete'], |
112
|
|
|
$_SERVER['REQUEST_URI'], |
113
|
|
|
\sprintf(\_MA_WGEVENTS_FORM_SURE_DELETE, $answerObj->getVar('evid'))); |
114
|
|
|
$form = $customConfirm->getFormConfirm(); |
115
|
|
|
$GLOBALS['xoopsTpl']->assign('form', $form->render()); |
116
|
|
|
} |
117
|
|
|
break; |
118
|
|
|
*/ |
119
|
|
|
} |
120
|
|
|
require __DIR__ . '/footer.php'; |
121
|
|
|
|
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are 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.php
However, as
OtherDir/Foo.php
does 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: