Passed
Push — master ( e12440...7742f2 )
by Michael
02:31
created

xoops_module_pre_uninstall_chess()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
3
/*
4
 You may not change or alter any portion of this comment or credits
5
 of supporting developers from this source code or any supporting source code
6
 which is considered copyrighted (c) material of the original comment or credit authors.
7
8
 This program is distributed in the hope that it will be useful,
9
 but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
*/
12
13
/**
14
 * uninstall.php - cleanup on module uninstall
15
 *
16
 * @author          XOOPS Module Development Team
17
 * @copyright       {@link https://xoops.org 2001-2016 XOOPS Project}
18
 * @license         {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
19
 * @link            https://xoops.org XOOPS
20
 */
21
22
use XoopsModules\Chess;
23
24
/**
25
 * Prepares system prior to attempting to uninstall module
26
 * @param XoopsModule $module {@link XoopsModule}
27
 *
28
 * @return bool true if ready to uninstall, false if not
29
 */
30
function xoops_module_pre_uninstall_chess(\XoopsModule $module)
0 ignored issues
show
Unused Code introduced by
The parameter $module is not used and could be removed. ( Ignorable by Annotation )

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

30
function xoops_module_pre_uninstall_chess(/** @scrutinizer ignore-unused */ \XoopsModule $module)

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

Loading history...
31
{
32
    // Do some synchronization if needed
33
34
    return true;
35
}
36
37
/**
38
 * Performs tasks required during uninstallation of the module
39
 * @param XoopsModule $module {@link XoopsModule}
40
 *
41
 * @return bool true if uninstallation successful, false if not
42
 */
43
function xoops_module_uninstall_chess(\XoopsModule $module)
44
{
45
    require __DIR__ . '/common.php';
46
47
    $moduleDirName = basename(dirname(__DIR__));
48
49
    $moduleDirNameUpper = mb_strtoupper($moduleDirName);
50
51
    $helper = Chess\Helper::getInstance();
52
53
    $utility = new Chess\Utility();
54
    //    $configurator = new Chess\Common\Configurator();
55
56
    // Load language files
57
58
    $helper->loadLanguage('admin');
59
60
    $helper->loadLanguage('common');
61
62
    $success = true;
63
64
    //------------------------------------------------------------------
65
66
    // Remove uploads folder (and all subfolders) if they exist
67
68
    //------------------------------------------------------------------
69
70
    $old_directories = [$GLOBALS['xoops']->path("uploads/{$moduleDirName}")];
71
72
    foreach ($old_directories as $old_dir) {
73
        $dirInfo = new SplFileInfo($old_dir);
74
75
        if ($dirInfo->isDir()) {
76
            // The directory exists so delete it
77
78
            if (false === $utility::rrmdir($old_dir)) {
79
                $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $old_dir));
80
81
                $success = false;
82
            }
83
        }
84
85
        unset($dirInfo);
86
    }
87
88
    /*
89
    //------------ START ----------------
90
    //------------------------------------------------------------------
91
    // Remove xsitemap.xml from XOOPS root folder if it exists
92
    //------------------------------------------------------------------
93
    $xmlfile = $GLOBALS['xoops']->path('xsitemap.xml');
94
    if (is_file($xmlfile)) {
95
        if (false === ($delOk = unlink($xmlfile))) {
96
            $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_REMOVE'), $xmlfile));
97
        }
98
    }
99
//    return $success && $delOk; // use this if you're using this routine
100
*/
101
102
    return $success;
103
    //------------ END  ----------------
104
}
105