Passed
Push — master ( ba995b...aecde2 )
by Michael
32s queued 12s
created

admin/permissions.php (2 issues)

Labels
Severity
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 (http://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\Request;
23
use XoopsModules\Pedigree;
24
25
require_once __DIR__ . '/admin_header.php';
26
27
//xoops_cp_header();
28
require_once XOOPS_ROOT_PATH . '/class/xoopsform/grouppermform.php';
29
//require_once XOOPS_ROOT_PATH."/class/xoopsform/FormHiddenToken.php";
30
31
if (!empty($_POST['submit'])) {
32
    $helper->redirect('admin/permissions.php', 1, _MP_GPERMUPDATED);
33
}
34
35
/** @var \Xmf\Module\Admin $adminObject */
36
echo $adminObject->displayNavigation(basename(__FILE__));
0 ignored issues
show
Are you sure the usage of $adminObject->displayNav...ion(basename(__FILE__)) targeting Xmf\Module\Admin::displayNavigation() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Are you sure $adminObject->displayNav...ion(basename(__FILE__)) of type void can be used in echo? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

36
echo /** @scrutinizer ignore-type */ $adminObject->displayNavigation(basename(__FILE__));
Loading history...
37
38
$permission = Request::getInt('permission', 1, 'POST');
39
$selected = ['', '', ''];
40
$selected[$permission - 1] = ' selected';
41
42
echo '
43
<form method="post" name="fselperm" action="' . $helper->url('admin/permissions.php') . '">
44
    <table border=0>
45
        <tr>
46
            <td>
47
                <select name="permission" onChange="document.fselperm.submit()">
48
                    <option value="1"' . $selected[0] . '>' . _AM_PEDIGREE_PERMISSIONS_ACCESS . '</option>
49
                    <option value="2"' . $selected[1] . '>' . _AM_PEDIGREE_PERMISSIONS_SUBMIT . '</option>
50
                    <option value="3"' . $selected[2] . '>' . _AM_PEDIGREE_PERMISSIONS_VIEW . '</option>
51
                </select>
52
            </td>
53
        </tr>
54
    </table>
55
</form>';
56
57
$module_id = $xoopsModule->getVar('mid');
58
59
switch ($permission) {
60
    case 1:
61
        $formTitle = _AM_PEDIGREE_PERMISSIONS_ACCESS;
62
        $permName  = 'xdirectory_access';
63
        $permDesc  = '';
64
        break;
65
    case 2:
66
        $formTitle = _AM_PEDIGREE_PERMISSIONS_SUBMIT;
67
        $permName  = 'xdirectory_submit';
68
        $permDesc  = '';
69
        break;
70
    case 3:
71
        $formTitle = _AM_PEDIGREE_PERMISSIONS_VIEW;
72
        $permName  = 'xdirectory_view';
73
        $permDesc  = '';
74
        break;
75
}
76
77
$permform = new \XoopsGroupPermForm($formTitle, $module_id, $permName, $permDesc, 'admin/permissions.php');
78
//    $xdir_catHandler= xoops_getModuleHandler('xdirectory_xdir_cat', $xoopsModule->getVar("dirname"));
79
$criteria = new \CriteriaCompo();
80
$criteria->setSort('title');
81
$criteria->setOrder('ASC');
82
//    $xdir_cat_arr = $xdir_catHandler->getObjects($criteria);
83
84
//foreach (array_keys($xdir_cat_arr) as $xdir_cat_id => $xdir_cat)
85
foreach (array_keys($xdir_cat_arr) as $i) {
86
    //$permform->addItem($xdir_cat_id, $xdir_cat["xdir_cat_title"], $xdir_cat["xdir_cat_pid"]);
87
    $permform->addItem($xdir_cat_arr[$i]->getVar('cid'), $xdir_cat_arr[$i]->getVar('title'));
88
}
89
echo $permform->render();
90
echo "<br><br><br><br>\n";
91
unset($permform);
92
93
require_once __DIR__ . '/admin_footer.php';
94