Passed
Push — master ( 882d2a...8f67b7 )
by Michael
03:09
created

GroupPermForm::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 5
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php namespace XoopsModules\Newbb;
2
3
use XoopsModules\Newbb;
4
5
/**
6
 * Class GroupPermForm
7
 * @package XoopsModules\Newbb
8
 */
9
class GroupPermForm extends \XoopsGroupPermForm
0 ignored issues
show
Bug introduced by
The type XoopsGroupPermForm was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
{
11
    /**
12
     * @param        $title
13
     * @param        $modid
14
     * @param        $permname
15
     * @param        $permdesc
16
     * @param string $url
17
     */
18
19
    public function __construct($title, $modid, $permname, $permdesc, $url = '')
20
    {
21
        parent::__construct($title, $modid, $permname, $permdesc, $url);
22
    }
23
24
    /**
25
     * @param        $title
26
     * @param        $modid
27
     * @param        $permname
28
     * @param        $permdesc
29
     * @param string $url
30
     */
31
32
    /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
33
    public function newbb_XoopsGroupPermForm($title, $modid, $permname, $permdesc, $url = "")
34
    {
35
//        $this->XoopsGroupPermForm($title, $modid, $permname, $permdesc, $url);
36
        self::__construct($title, $modid, $permname, $permdesc, $url);
37
    }
38
*/
39
    /**
40
     * @return string
41
     */
42
    public function render()
43
    {
44
        // load all child ids for javascript codes
45
        foreach (array_keys($this->_itemTree) as $item_id) {
46
            $this->_itemTree[$item_id]['allchild'] = [];
0 ignored issues
show
Bug Best Practice introduced by
The property _itemTree does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
47
            $this->_loadAllChildItemIds($item_id, $this->_itemTree[$item_id]['allchild']);
48
        }
49
        /** @var \XoopsGroupPermHandler $gpermHandler */
50
        $gpermHandler = xoops_getHandler('groupperm');
0 ignored issues
show
Bug introduced by
The function xoops_getHandler was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

50
        $gpermHandler = /** @scrutinizer ignore-call */ xoops_getHandler('groupperm');
Loading history...
51
        /** @var \XoopsMemberHandler $memberHandler */
52
        $memberHandler = xoops_getHandler('member');
53
        $glist         = $memberHandler->getGroupList();
54
        foreach (array_keys($glist) as $i) {
55
            // get selected item id(s) for each group
56
            $selected = $gpermHandler->getItemIds($this->_permName, $i, $this->_modid);
57
            $ele      = new Newbb\GroupFormCheckBox($glist[$i], 'perms[' . $this->_permName . ']', $i, $selected);
58
            $ele->setOptionTree($this->_itemTree);
59
            $this->addElement($ele);
60
            unset($ele);
61
        }
62
        $tray = new \XoopsFormElementTray('');
0 ignored issues
show
Bug introduced by
The type XoopsFormElementTray was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
63
        $tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Newbb\_SUBMIT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The type XoopsFormButton was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
64
        $tray->addElement(new \XoopsFormButton('', 'reset', _CANCEL, 'reset'));
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Newbb\_CANCEL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
65
        $this->addElement($tray);
66
        $ret      = '<br><strong>' . $this->getTitle() . '</strong><br>' . $this->_permDesc . '<br>';
67
        $ret      .= "<form name='" . $this->getName() . "' id='" . $this->getName() . "' action='" . $this->getAction() . "' method='" . $this->getMethod() . "'" . $this->getExtra() . ">\n<table width='100%' class='outer' cellspacing='1' valign='top'>\n";
68
        $elements = $this->getElements();
69
        $hidden   = '';
70
        foreach (array_keys($elements) as $i) {
71
            if (!is_object($elements[$i])) {
72
                $ret .= $elements[$i];
73
            } elseif (!$elements[$i]->isHidden()) {
74
                $ret .= "<tr valign='top' align='left'><td class='head'>" . $elements[$i]->getCaption();
75
                if ('' !== $elements[$i]->getDescription()) {
76
                    $ret .= '<br><br><span style="font-weight: normal;">' . $elements[$i]->getDescription() . '</span>';
77
                }
78
                $ret .= "</td>\n<td class='even' style='text-align:center;'>\n" . $elements[$i]->render() . "\n</td></tr>\n";
79
            } else {
80
                $hidden .= $elements[$i]->render();
81
            }
82
        }
83
        $ret .= "</table>$hidden</form>";
84
        $ret .= $this->renderValidationJS(true);
85
86
        return $ret;
87
    }
88
}
89