1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits |
4
|
|
|
of supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @copyright 2019-2021 XOOPS Project (https://xoops.org) |
14
|
|
|
* @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
15
|
|
|
* @author Richard Griffith <[email protected]> |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
use Xmf\Module\Admin; |
19
|
|
|
use Xmf\Module\Helper; |
20
|
|
|
use Xmf\Module\Helper\Permission; |
21
|
|
|
use Xmf\Request; |
|
|
|
|
22
|
|
|
|
23
|
|
|
require_once __DIR__ . '/admin_header.php'; |
24
|
|
|
|
25
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
26
|
|
|
|
27
|
|
|
$moduleAdmin = Admin::getInstance(); |
28
|
|
|
$moduleAdmin->displayNavigation('permissions.php'); |
29
|
|
|
|
30
|
|
|
$helper = Helper::getHelper('xwhoops'); |
31
|
|
|
$permHelper = new Permission(); |
32
|
|
|
if ($permHelper) { |
|
|
|
|
33
|
|
|
// this is the name and item we are going to work with |
34
|
|
|
$permissionName = 'use_xwhoops'; |
35
|
|
|
$permissionItemId = 0; |
36
|
|
|
|
37
|
|
|
// if this is a post operation get our variables |
38
|
|
|
if ('POST' === Request::getMethod()) { |
39
|
|
|
if (!$GLOBALS['xoopsSecurity']->check()) { |
40
|
|
|
redirect_header(XOOPS_URL . '/', 3, $GLOBALS['xoopsSecurity']->getErrors()); |
41
|
|
|
} |
42
|
|
|
$name = $permHelper->defaultFieldName($permissionName, $permissionItemId); |
43
|
|
|
$groups = Request::getVar($name, [], 'POST'); |
44
|
|
|
$permHelper->savePermissionForItem($permissionName, $permissionItemId, $groups); |
|
|
|
|
45
|
|
|
xoops_result(_MA_XWHOOPS_FORM_PROCESSED, _MA_XWHOOPS_PERMISSION_FORM); |
46
|
|
|
} |
47
|
|
|
$form = new XoopsThemeForm(_MA_XWHOOPS_PERMISSION_FORM, 'form', '', 'POST', true); |
48
|
|
|
$permElement = $permHelper->getGroupSelectFormForItem( |
49
|
|
|
$permissionName, |
50
|
|
|
$permissionItemId, |
51
|
|
|
_MA_XWHOOPS_PERMISSION_GROUPS, |
52
|
|
|
null, |
53
|
|
|
true |
54
|
|
|
); |
55
|
|
|
|
56
|
|
|
$form->addElement($permElement); |
57
|
|
|
$form->addElement(new XoopsFormButton('', 'submit', _MA_XWHOOPS_FORM_SUBMIT, 'submit')); |
58
|
|
|
|
59
|
|
|
echo $form->render(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
require_once __DIR__ . '/admin_footer.php'; |
63
|
|
|
|
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: