|
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
|
|
|
|
|
26
|
|
|
require __DIR__ . '/header.php'; |
|
27
|
|
|
|
|
28
|
|
|
// Template Index |
|
29
|
|
|
$templateMain = 'wgevents_admin_permission.tpl'; |
|
30
|
|
|
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('permission.php')); |
|
31
|
|
|
|
|
32
|
|
|
$op = Request::getCmd('op', 'global'); |
|
33
|
|
|
|
|
34
|
|
|
// Get Form |
|
35
|
|
|
require_once \XOOPS_ROOT_PATH . '/class/xoopsform/grouppermform.php'; |
|
36
|
|
|
\xoops_load('XoopsFormLoader'); |
|
37
|
|
|
$formTitle = \_AM_WGEVENTS_PERMISSIONS_GLOBAL; |
|
38
|
|
|
$permName = 'wgevents_ac'; |
|
39
|
|
|
$permDesc = \_AM_WGEVENTS_PERMISSIONS_DESC; |
|
40
|
|
|
$permDesc .= \_AM_WGEVENTS_PERMISSIONS_GLOBAL_DESC; |
|
41
|
|
|
$permDesc .= \_AM_WGEVENTS_PERMISSIONS_EVENTS_APPROVE_DESC; |
|
42
|
|
|
$permDesc .= \_AM_WGEVENTS_PERMISSIONS_EVENTS_APPROVE_AUTO_DESC; |
|
43
|
|
|
$permDesc .= \_AM_WGEVENTS_PERMISSIONS_EVENTS_SUBMIT_DESC; |
|
44
|
|
|
$permDesc .= \_AM_WGEVENTS_PERMISSIONS_REGISTRATIONS_AUTOVERIF_DESC; |
|
45
|
|
|
$permDesc .= \_AM_WGEVENTS_PERMISSIONS_REGISTRATIONS_SUBMIT_DESC; |
|
46
|
|
|
|
|
47
|
|
|
$globalPerms = [ |
|
48
|
|
|
Constants::PERM_GLOBAL_APPROVE => \_AM_WGEVENTS_PERMISSIONS_GLOBAL_APPROVE, |
|
49
|
|
|
Constants::PERM_GLOBAL_SUBMIT => \_AM_WGEVENTS_PERMISSIONS_GLOBAL_SUBMIT, |
|
50
|
|
|
Constants::PERM_GLOBAL_VIEW => \_AM_WGEVENTS_PERMISSIONS_GLOBAL_VIEW, |
|
51
|
|
|
Constants::PERM_EVENTS_APPROVE => \_AM_WGEVENTS_PERMISSIONS_EVENTS_APPROVE, |
|
52
|
|
|
Constants::PERM_EVENTS_APPROVE_AUTO => \_AM_WGEVENTS_PERMISSIONS_EVENTS_APPROVE_AUTO, |
|
53
|
|
|
Constants::PERM_EVENTS_SUBMIT => \_AM_WGEVENTS_PERMISSIONS_EVENTS_SUBMIT, |
|
54
|
|
|
Constants::PERM_EVENTS_VIEW => \_AM_WGEVENTS_PERMISSIONS_EVENTS_VIEW, |
|
55
|
|
|
Constants::PERM_REGISTRATIONS_AUTOVERIF => \_AM_WGEVENTS_PERMISSIONS_REGISTRATIONS_AUTOVERIF, |
|
56
|
|
|
Constants::PERM_REGISTRATIONS_SUBMIT => \_AM_WGEVENTS_PERMISSIONS_REGISTRATIONS_SUBMIT, |
|
57
|
|
|
]; |
|
58
|
|
|
|
|
59
|
|
|
$moduleId = $xoopsModule->getVar('mid'); |
|
60
|
|
|
$permForm = new \XoopsGroupPermForm($formTitle, $moduleId, $permName, $permDesc, 'admin/permission.php'); |
|
61
|
|
|
$permFound = false; |
|
62
|
|
|
if ('global' === $op) { |
|
63
|
|
|
foreach ($globalPerms as $gPermId => $gPermName) { |
|
64
|
|
|
$permForm->addItem($gPermId, $gPermName); |
|
65
|
|
|
} |
|
66
|
|
|
$infos = |
|
67
|
|
|
$GLOBALS['xoopsTpl']->assign('form', $permForm->render()); |
|
68
|
|
|
$permFound = true; |
|
69
|
|
|
} |
|
70
|
|
|
unset($permForm); |
|
71
|
|
|
if (true !== $permFound) { |
|
72
|
|
|
\redirect_header('permission.php', 3, \_AM_WGEVENTS_NO_PERMISSIONS_SET); |
|
73
|
|
|
exit(); |
|
74
|
|
|
} |
|
75
|
|
|
require __DIR__ . '/footer.php'; |
|
76
|
|
|
|
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: