|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
// |
|
3
|
|
|
// ------------------------------------------------------------------------ // |
|
4
|
|
|
// XOOPS - PHP Content Management System // |
|
5
|
|
|
// Copyright (c) 2000-2020 XOOPS.org // |
|
6
|
|
|
// <https://xoops.org> // |
|
7
|
|
|
// ------------------------------------------------------------------------ // |
|
8
|
|
|
// This program is free software; you can redistribute it and/or modify // |
|
9
|
|
|
// it under the terms of the GNU General Public License as published by // |
|
10
|
|
|
// the Free Software Foundation; either version 2 of the License, or // |
|
11
|
|
|
// (at your option) any later version. // |
|
12
|
|
|
// // |
|
13
|
|
|
// You may not change or alter any portion of this comment or credits // |
|
14
|
|
|
// of supporting developers from this source code or any supporting // |
|
15
|
|
|
// source code which is considered copyrighted (c) material of the // |
|
16
|
|
|
// original comment or credit authors. // |
|
17
|
|
|
// // |
|
18
|
|
|
// This program is distributed in the hope that it will be useful, // |
|
19
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
20
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
21
|
|
|
// GNU General Public License for more details. // |
|
22
|
|
|
// // |
|
23
|
|
|
// You should have received a copy of the GNU General Public License // |
|
24
|
|
|
// along with this program; if not, write to the Free Software // |
|
25
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
|
26
|
|
|
// ------------------------------------------------------------------------ // |
|
27
|
|
|
|
|
28
|
|
|
use Xmf\Module\Admin; |
|
29
|
|
|
use Xmf\Request; |
|
|
|
|
|
|
30
|
|
|
use XoopsModules\News; |
|
31
|
|
|
|
|
32
|
|
|
require \dirname(__DIR__, 3) . '/include/cp_header.php'; |
|
33
|
|
|
// require_once XOOPS_ROOT_PATH . '/modules/news/class/xoopstopic.php'; |
|
34
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
|
35
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopsform/grouppermform.php'; |
|
36
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/news/admin/functions.php'; |
|
37
|
|
|
require_once __DIR__ . '/admin_header.php'; |
|
38
|
|
|
xoops_cp_header(); |
|
39
|
|
|
$adminObject = Admin::getInstance(); |
|
40
|
|
|
$adminObject->displayNavigation(basename(__FILE__)); |
|
41
|
|
|
|
|
42
|
|
|
echo '<br><br><br>'; |
|
43
|
|
|
$permtoset = Request::getInt('permtoset', 1, 'POST'); |
|
44
|
|
|
$selected = ['', '', '']; |
|
45
|
|
|
$selected[$permtoset - 1] = ' selected'; |
|
46
|
|
|
echo "<form method='post' name='fselperm' action='groupperms.php'><select name='permtoset' onChange='document.fselperm.submit()'><option value='1'" |
|
47
|
|
|
. $selected[0] |
|
48
|
|
|
. '>' |
|
49
|
|
|
. _AM_APPROVEFORM |
|
50
|
|
|
. "</option><option value='2'" |
|
51
|
|
|
. $selected[1] |
|
52
|
|
|
. '>' |
|
53
|
|
|
. _AM_SUBMITFORM |
|
54
|
|
|
. "</option><option value='3'" |
|
55
|
|
|
. $selected[2] |
|
56
|
|
|
. '>' |
|
57
|
|
|
. _AM_VIEWFORM |
|
58
|
|
|
. "</option></select> <input type='submit' name='go'></form>"; |
|
59
|
|
|
$module_id = $xoopsModule->getVar('mid'); |
|
60
|
|
|
|
|
61
|
|
|
switch ($permtoset) { |
|
62
|
|
|
case 1: |
|
63
|
|
|
$title_of_form = _AM_APPROVEFORM; |
|
64
|
|
|
$perm_name = 'news_approve'; |
|
65
|
|
|
$perm_desc = _AM_APPROVEFORM_DESC; |
|
66
|
|
|
break; |
|
67
|
|
|
case 2: |
|
68
|
|
|
$title_of_form = _AM_SUBMITFORM; |
|
69
|
|
|
$perm_name = 'news_submit'; |
|
70
|
|
|
$perm_desc = _AM_SUBMITFORM_DESC; |
|
71
|
|
|
break; |
|
72
|
|
|
case 3: |
|
73
|
|
|
$title_of_form = _AM_VIEWFORM; |
|
74
|
|
|
$perm_name = 'news_view'; |
|
75
|
|
|
$perm_desc = _AM_VIEWFORM_DESC; |
|
76
|
|
|
break; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
$permform = new \XoopsGroupPermForm($title_of_form, $module_id, $perm_name, $perm_desc, 'admin/groupperms.php'); |
|
80
|
|
|
$xt = new \XoopsModules\News\XoopsTopic($xoopsDB->prefix('news_topics')); |
|
81
|
|
|
$alltopics = $xt->getTopicsList(); |
|
82
|
|
|
|
|
83
|
|
|
if ($alltopics) { |
|
84
|
|
|
foreach ($alltopics as $topic_id => $topic) { |
|
85
|
|
|
$permform->addItem($topic_id, $topic['title'], $topic['pid']); |
|
86
|
|
|
} |
|
87
|
|
|
echo $permform->render(); |
|
88
|
|
|
echo "<br><br><br><br>\n"; |
|
89
|
|
|
unset($permform); |
|
90
|
|
|
} else { |
|
91
|
|
|
redirect_header('index.php?op=topicsmanager', 5, _NW_NEWS_NO_TOPICS, false); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
require_once __DIR__ . '/admin_footer.php'; |
|
95
|
|
|
|
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: