Completed
Push — master ( 89db23...db7223 )
by Michael
02:46
created

oninstall.php ➔ xoops_module_pre_install_gbook()   B

Complexity

Conditions 5
Paths 8

Size

Total Lines 24
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 13
c 1
b 0
f 0
nc 8
nop 1
dl 0
loc 24
rs 8.5125
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
 * @copyright    XOOPS Project http://xoops.org/
14
 * @license      GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
15
 * @author     XOOPS Development Team
16
 */
17
18
19
/**
20
 *
21
 * Prepares system prior to attempting to install module
22
 * @param XoopsModule $module {@link XoopsModule}
23
 *
24
 * @return bool true if ready to install, false if not
25
 */
26
function xoops_module_pre_install_gbook(XoopsModule $module)
0 ignored issues
show
Coding Style introduced by
xoops_module_pre_install_gbook uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
27
{
28
    $moduleDirName = basename(dirname(__DIR__));
29
    $className = ucfirst($moduleDirName) . 'Utilities';
30
    if (!class_exists($className)) {
31
        xoops_load('utilities', $moduleDirName);
32
    }
33
    //check for minimum XOOPS version
34
    if (!$className::checkXoopsVer($module)) {
35
        return false;
36
    }
37
38
    // check for minimum PHP version
39
    if (!$className::checkPhpVer($module)) {
40
        return false;
41
    }
42
43
    $mod_tables =& $module->getInfo('tables');
44
    foreach ($mod_tables as $table) {
45
        $GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';');
46
    }
47
48
    return true;
49
}
50
51
/**
52
 *
53
 * Performs tasks required during installation of the module
54
 * @param XoopsModule $module {@link XoopsModule}
55
 *
56
 * @return bool true if installation successful, false if not
57
 */
58
function xoops_module_install_gbook(XoopsModule $module)
0 ignored issues
show
Unused Code introduced by
The parameter $module is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
59
{
60
    return true;
61
}
62