1
|
|
|
<?php
|
2
|
|
|
|
3
|
|
|
declare(strict_types=1);
|
4
|
|
|
|
5
|
|
|
/*
|
6
|
|
|
You may not change or alter any portion of this comment or credits
|
7
|
|
|
of supporting developers from this source code or any supporting source code
|
8
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors.
|
9
|
|
|
|
10
|
|
|
This program is distributed in the hope that it will be useful,
|
11
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
13
|
|
|
*/
|
14
|
|
|
|
15
|
|
|
/**
|
16
|
|
|
* wgFileManager module for xoops
|
17
|
|
|
*
|
18
|
|
|
* @copyright 2021 XOOPS Project (https://xoops.org)
|
19
|
|
|
* @license GPL 2.0 or later
|
20
|
|
|
* @package wgfilemanager
|
21
|
|
|
* @author Goffy - Wedega - Email:[email protected] - Website:https://xoops.wedega.com
|
22
|
|
|
*/
|
23
|
|
|
|
24
|
|
|
use Xmf\Request;
|
|
|
|
|
25
|
|
|
use XoopsModules\Wgfilemanager;
|
26
|
|
|
use XoopsModules\Wgfilemanager\Constants;
|
27
|
|
|
|
28
|
|
|
require __DIR__ . '/header.php';
|
29
|
|
|
|
30
|
|
|
// Template Index
|
31
|
|
|
$templateMain = 'wgfilemanager_admin_permissions.tpl';
|
32
|
|
|
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('permissions.php'));
|
33
|
|
|
|
34
|
|
|
$op = Request::getCmd('op', 'global');
|
35
|
|
|
$permDir = 'directory' === $helper->getConfig('permission_type');
|
36
|
|
|
// Get Form
|
37
|
|
|
require_once \XOOPS_ROOT_PATH . '/class/xoopsform/grouppermform.php';
|
38
|
|
|
\xoops_load('XoopsFormLoader');
|
39
|
|
|
$permTableForm = new \XoopsSimpleForm('', 'fselperm', 'permissions.php', 'post');
|
40
|
|
|
$formSelect = new \XoopsFormSelect('', 'op', $op);
|
41
|
|
|
$formSelect->setExtra('onchange="document.fselperm.submit()"');
|
42
|
|
|
$formSelect->addOption('global', \_MA_WGFILEMANAGER_PERM_GLOBAL);
|
43
|
|
|
if ($permDir) {
|
44
|
|
|
//$formSelect->addOption('approve_directory', \_MA_WGFILEMANAGER_PERM_APPROVE . ' ' . _MA_WGFILEMANAGER_DIRECTORY);
|
45
|
|
|
$formSelect->addOption('submit_directory', \_MA_WGFILEMANAGER_PERM_DIR_SUBMIT);
|
46
|
|
|
$formSelect->addOption('view_directory', \_MA_WGFILEMANAGER_PERM_DIR_VIEW);
|
47
|
|
|
$formSelect->addOption('upload_directory', \_MA_WGFILEMANAGER_PERM_FILE_UPLOAD_TO_DIR);
|
48
|
|
|
$formSelect->addOption('download_directory', \_MA_WGFILEMANAGER_PERM_FILE_DOWNLOAD_FROM_DIR);
|
49
|
|
|
}
|
50
|
|
|
$permTableForm->addElement($formSelect);
|
51
|
|
|
$permTableForm->display();
|
52
|
|
|
switch ($op) {
|
53
|
|
|
case 'global':
|
54
|
|
|
default:
|
55
|
|
|
$formTitle = \_MA_WGFILEMANAGER_PERM_GLOBAL;
|
56
|
|
|
$permName = 'wgfilemanager_global';
|
57
|
|
|
$permDesc = \_MA_WGFILEMANAGER_PERM_GLOBAL_DESC;
|
58
|
|
|
$globalPerms = [Constants::PERM_GLOBAL_SUBMIT => \_MA_WGFILEMANAGER_PERM_GLOBAL_SUBMIT,
|
59
|
|
|
Constants::PERM_GLOBAL_VIEW => \_MA_WGFILEMANAGER_PERM_GLOBAL_VIEW,
|
60
|
|
|
Constants::PERM_GLOBAL_DOWNLOAD => \_MA_WGFILEMANAGER_PERM_GLOBAL_DOWNLOAD];
|
61
|
|
|
break;
|
62
|
|
|
/*case 'approve_directory':
|
63
|
|
|
$formTitle = \_MA_WGFILEMANAGER_PERM_APPROVE;
|
64
|
|
|
$permName = 'wgfilemanager_approve_directory';
|
65
|
|
|
$permDesc = \_MA_WGFILEMANAGER_PERM_APPROVE_DESC . ' ' . _MA_WGFILEMANAGER_DIRECTORY;
|
66
|
|
|
$handler = $helper->getHandler('directory');
|
67
|
|
|
break;*/
|
68
|
|
|
case 'submit_directory':
|
69
|
|
|
$formTitle = \_MA_WGFILEMANAGER_PERM_DIR_SUBMIT;
|
70
|
|
|
$permName = 'wgfilemanager_submit_directory';
|
71
|
|
|
$permDesc = \_MA_WGFILEMANAGER_PERM_DIR_SUBMIT_DESC;
|
72
|
|
|
$handler = $helper->getHandler('directory');
|
73
|
|
|
break;
|
74
|
|
|
case 'view_directory':
|
75
|
|
|
$formTitle = \_MA_WGFILEMANAGER_PERM_DIR_VIEW;
|
76
|
|
|
$permName = 'wgfilemanager_view_directory';
|
77
|
|
|
$permDesc = \_MA_WGFILEMANAGER_PERM_DIR_VIEW_DESC;
|
78
|
|
|
$handler = $helper->getHandler('directory');
|
79
|
|
|
break;
|
80
|
|
|
case 'upload_directory':
|
81
|
|
|
$formTitle = \_MA_WGFILEMANAGER_PERM_FILE_UPLOAD_TO_DIR;
|
82
|
|
|
$permName = 'wgfilemanager_upload_directory';
|
83
|
|
|
$permDesc = \_MA_WGFILEMANAGER_PERM_FILE_UPLOAD_TO_DIR_DESC;
|
84
|
|
|
$handler = $helper->getHandler('directory');
|
85
|
|
|
break;
|
86
|
|
|
case 'download_directory':
|
87
|
|
|
$formTitle = \_MA_WGFILEMANAGER_PERM_FILE_DOWNLOAD_FROM_DIR;
|
88
|
|
|
$permName = 'wgfilemanager_download_directory';
|
89
|
|
|
$permDesc = \_MA_WGFILEMANAGER_PERM_FILE_DOWNLOAD_FROM_DIR_DESC;
|
90
|
|
|
$handler = $helper->getHandler('directory');
|
91
|
|
|
break;
|
92
|
|
|
}
|
93
|
|
|
$moduleId = $xoopsModule->getVar('mid');
|
94
|
|
|
$permform = new \XoopsGroupPermForm($formTitle, $moduleId, $permName, $permDesc, 'admin/permissions.php');
|
95
|
|
|
$permFound = false;
|
96
|
|
|
if ($op === 'global') {
|
97
|
|
|
foreach ($globalPerms as $gPermId => $gPermName) {
|
98
|
|
|
$permform->addItem($gPermId, $gPermName);
|
99
|
|
|
}
|
100
|
|
|
$GLOBALS['xoopsTpl']->assign('form', $permform->render());
|
101
|
|
|
$permFound = true;
|
102
|
|
|
}
|
103
|
|
|
if ('approve_directory' === $op || 'submit_directory' === $op || 'view_directory' === $op || 'upload_directory' === $op || 'download_directory' === $op) {
|
104
|
|
|
$directoryCount = $directoryHandler->getCountDirectory();
|
105
|
|
|
if ($directoryCount > 0) {
|
106
|
|
|
$directoryAll = $directoryHandler->getAllDirectory(0, 'name');
|
107
|
|
|
foreach (\array_keys($directoryAll) as $i) {
|
108
|
|
|
$permform->addItem($directoryAll[$i]->getVar('id'), $directoryAll[$i]->getVar('name'));
|
109
|
|
|
}
|
110
|
|
|
$GLOBALS['xoopsTpl']->assign('form', $permform->render());
|
111
|
|
|
}
|
112
|
|
|
$permFound = true;
|
113
|
|
|
}
|
114
|
|
|
unset($permform);
|
115
|
|
|
if (true !== $permFound) {
|
116
|
|
|
\redirect_header('permissions.php', 3, \_MA_WGFILEMANAGER_NO_PERMISSIONS_SET);
|
117
|
|
|
exit();
|
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: