|
1
|
|
|
<?php |
|
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
|
|
|
* Module: Pedigree |
|
14
|
|
|
* |
|
15
|
|
|
* @package XoopsModules\Pedigree |
|
16
|
|
|
* @copyright 2011-2019 XOOPS Project (https://xoops.org) |
|
17
|
|
|
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
|
18
|
|
|
* @author XOOPS Module Dev Team (https://xoops.org) |
|
19
|
|
|
* @todo Refactor this code - it currently doesn't work as intended |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
use Xmf\Module\Admin; |
|
23
|
|
|
use Xmf\Request; |
|
|
|
|
|
|
24
|
|
|
use XoopsModules\Pedigree\{ |
|
25
|
|
|
Constants, |
|
26
|
|
|
Helper |
|
27
|
|
|
}; |
|
28
|
|
|
/** @var Helper $helper */ |
|
29
|
|
|
/** @var Admin $adminObject */ |
|
30
|
|
|
|
|
31
|
|
|
require_once __DIR__ . '/admin_header.php'; |
|
32
|
|
|
//xoops_cp_header(); |
|
33
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopsform/grouppermform.php'; |
|
34
|
|
|
//require_once XOOPS_ROOT_PATH."/class/xoopsform/FormHiddenToken.php"; |
|
35
|
|
|
|
|
36
|
|
|
if (!empty($_POST['submit'])) { |
|
37
|
|
|
$helper->redirect('admin/permissions.php', Constants::REDIRECT_DELAY_SHORT, _MP_GPERMUPDATED); |
|
|
|
|
|
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
$adminObject->displayNavigation(basename(__FILE__)); |
|
41
|
|
|
|
|
42
|
|
|
$permission = Request::getInt('permission', 1, 'POST'); |
|
43
|
|
|
$selected = ['', '', '']; |
|
44
|
|
|
$selected[$permission - 1] = ' selected'; |
|
45
|
|
|
|
|
46
|
|
|
echo ' |
|
47
|
|
|
<form method="post" name="fselperm" action="' . $helper->url('admin/permissions.php') . '"> |
|
48
|
|
|
<table border=0> |
|
49
|
|
|
<tr> |
|
50
|
|
|
<td> |
|
51
|
|
|
<select name="permission" onChange="document.fselperm.submit()"> |
|
52
|
|
|
<option value="1"' . $selected[0] . '>' . _AM_PEDIGREE_PERMISSIONS_ACCESS . '</option> |
|
53
|
|
|
<option value="2"' . $selected[1] . '>' . _AM_PEDIGREE_PERMISSIONS_SUBMIT . '</option> |
|
54
|
|
|
<option value="3"' . $selected[2] . '>' . _AM_PEDIGREE_PERMISSIONS_VIEW . '</option> |
|
55
|
|
|
</select> |
|
56
|
|
|
</td> |
|
57
|
|
|
</tr> |
|
58
|
|
|
</table> |
|
59
|
|
|
</form>'; |
|
60
|
|
|
|
|
61
|
|
|
//$module_id = $xoopsModule->getVar('mid'); |
|
62
|
|
|
$module_id = $helper->getModule()->getVar('mid'); |
|
63
|
|
|
|
|
64
|
|
|
switch ($permission) { |
|
65
|
|
|
case 1: |
|
66
|
|
|
$formTitle = _AM_PEDIGREE_PERMISSIONS_ACCESS; |
|
67
|
|
|
$permName = 'pedigree_access'; |
|
68
|
|
|
$permDesc = ''; |
|
69
|
|
|
break; |
|
70
|
|
|
case 2: |
|
71
|
|
|
$formTitle = _AM_PEDIGREE_PERMISSIONS_SUBMIT; |
|
72
|
|
|
$permName = 'pedigree_submit'; |
|
73
|
|
|
$permDesc = ''; |
|
74
|
|
|
break; |
|
75
|
|
|
case 3: |
|
76
|
|
|
$formTitle = _AM_PEDIGREE_PERMISSIONS_VIEW; |
|
77
|
|
|
$permName = 'pedigree_view'; |
|
78
|
|
|
$permDesc = ''; |
|
79
|
|
|
break; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
$permform = new \XoopsGroupPermForm($formTitle, $module_id, $permName, $permDesc, 'admin/permissions.php'); |
|
83
|
|
|
// $xdir_catHandler= xoops_getModuleHandler('xdirectory_xdir_cat', $xoopsModule->getVar("dirname")); |
|
84
|
|
|
$criteria = new \CriteriaCompo(); |
|
85
|
|
|
$criteria->setSort('title'); |
|
86
|
|
|
$criteria->setOrder('ASC'); |
|
87
|
|
|
// $xdir_cat_arr = $xdir_catHandler->getObjects($criteria); |
|
88
|
|
|
|
|
89
|
|
|
//foreach (array_keys($xdir_cat_arr) as $xdir_cat_id => $xdir_cat) |
|
90
|
|
|
foreach (array_keys($xdir_cat_arr) as $i) { |
|
91
|
|
|
//$permform->addItem($xdir_cat_id, $xdir_cat["xdir_cat_title"], $xdir_cat["xdir_cat_pid"]); |
|
92
|
|
|
$permform->addItem($xdir_cat_arr[$i]->getVar('cid'), $xdir_cat_arr[$i]->getVar('title')); |
|
93
|
|
|
} |
|
94
|
|
|
echo $permform->render(); |
|
95
|
|
|
echo "<br><br><br><br>\n"; |
|
96
|
|
|
unset($permform); |
|
97
|
|
|
|
|
98
|
|
|
require_once __DIR__ . '/admin_footer.php'; |
|
99
|
|
|
|
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: