xoops_module_pre_uninstall_xhelp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php declare(strict_types=1);
2
3
/**
4
 * uninstall.php - cleanup on module uninstall
5
 *
6
 * @author          XOOPS Module Development Team
7
 * @copyright       {@link https://xoops.org 2001-2016 XOOPS Project}
8
 * @license         {@link https://www.fsf.org/copyleft/gpl.html GNU public license}
9
 * @link            https://xoops.org XOOPS
10
 */
11
12
use XoopsModules\Xhelp;
13
14
/**
15
 * Prepares system prior to attempting to uninstall module
16
 * @param \XoopsModule $module {@link XoopsModule}
17
 *
18
 * @return bool true if ready to uninstall, false if not
19
 */
20
function xoops_module_pre_uninstall_xhelp(\XoopsModule $module): bool
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

20
function xoops_module_pre_uninstall_xhelp(/** @scrutinizer ignore-unused */ \XoopsModule $module): bool

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...
21
{
22
    // Do some synchronization
23
    return true;
24
}
25
26
/**
27
 * Performs tasks required during uninstallation of the module
28
 * @param \XoopsModule $module {@link XoopsModule}
29
 *
30
 * @return bool true if uninstallation successful, false if not
31
 */
32
function xoops_module_uninstall_xhelp(\XoopsModule $module): bool
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

32
function xoops_module_uninstall_xhelp(/** @scrutinizer ignore-unused */ \XoopsModule $module): bool

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...
33
{
34
    require_once \dirname(__DIR__) . '/preloads/autoloader.php';
35
    $moduleDirName      = \basename(\dirname(__DIR__));
36
    $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
0 ignored issues
show
Unused Code introduced by
The assignment to $moduleDirNameUpper is dead and can be removed.
Loading history...
37
38
    $helper  = Xhelp\Helper::getInstance();
39
    $utility = new Xhelp\Utility();
0 ignored issues
show
Unused Code introduced by
The assignment to $utility is dead and can be removed.
Loading history...
40
    //    $configurator = new Xhelp\Common\Configurator();
41
42
    // Load language files
43
    $helper->loadLanguage('admin');
44
    $helper->loadLanguage('common');
45
    $success = true;
46
47
    //------------------------------------------------------------------
48
    // Remove uploads folder (and all subfolders) if they exist
49
    //------------------------------------------------------------------
50
    /*
51
        $old_directories = [$GLOBALS['xoops']->path("uploads/{$moduleDirName}")];
52
        foreach ($old_directories as $old_dir) {
53
            $dirInfo = new \SplFileInfo($old_dir);
54
            if ($dirInfo->isDir()) {
55
                // The directory exists so delete it
56
                if (false === $utility::rrmdir($old_dir)) {
57
                    $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $old_dir));
58
                    $success = false;
59
                }
60
            }
61
            unset($dirInfo);
62
        }
63
        */
64
65
    /*
66
    //------------ START ----------------
67
    //------------------------------------------------------------------
68
    // Remove xsitemap.xml from XOOPS root folder if it exists
69
    //------------------------------------------------------------------
70
    $xmlfile = $GLOBALS['xoops']->path('xsitemap.xml');
71
    if (is_file($xmlfile)) {
72
        if (false === ($delOk = unlink($xmlfile))) {
73
            $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_REMOVE'), $xmlfile));
74
        }
75
    }
76
//    return $success && $delOk; // use this if you're using this routine
77
*/
78
79
    return $success;
80
    //------------ END  ----------------
81
}
82