Completed
Push — master ( 266444...2ebe1b )
by Michael
01:31
created

admin/admin_header.php (3 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
 * Contact module
14
 *
15
 * @copyright   XOOPS Project (https://xoops.org)
16
 * @license     http://www.fsf.org/copyleft/gpl.html GNU public license
17
 * @author      Kazumi Ono (aka Onokazu)
18
 * @author      Trabis <[email protected]>
19
 * @author      Hossein Azizabadi (AKA Voltan)
20
 */
21
22
require_once __DIR__ . '/../../../include/cp_header.php';
23
require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
24
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
25
global $xoopsModule;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
26
27
$moduleDirName = $GLOBALS['xoopsModule']->getVar('dirname');
28
29
if (false !== ($moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName))) {
0 ignored issues
show
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
30
} else {
31
    $moduleHelper = Xmf\Module\Helper::getHelper('system');
32
}
33
/** @var Xmf\Module\Admin $adminObject */
34
$adminObject = Xmf\Module\Admin::getInstance();
35
36
$myts = MyTextSanitizer::getInstance();
37
38
if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof XoopsTpl)) {
0 ignored issues
show
The class XoopsTpl does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
39
    require_once $GLOBALS['xoops']->path('class/template.php');
40
    $xoopsTpl = new XoopsTpl();
41
}
42
43
$pathIcon16      = Xmf\Module\Admin::iconUrl('', 16);
44
$pathIcon32      = Xmf\Module\Admin::iconUrl('', 32);
45
$pathModIcon32 = $moduleHelper->getConfig('modicons32');
46
47
// Local icons path
48
$xoopsTpl->assign('pathModIcon16', $pathIcon16);
49
$xoopsTpl->assign('pathModIcon32', $pathIcon32);
50
51
// Load language files
52
$moduleHelper->loadLanguage('admin');
53
$moduleHelper->loadLanguage('modinfo');
54
$moduleHelper->loadLanguage('main');
55
56
57
// Contact Handler
58
/** @var ContactContactHandler $contactHandler*/
59
$contactHandler = xoops_getModuleHandler('contact', $moduleDirName);
60