xoops_module_uninstall_cssholmes()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 46
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

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

19
function xoops_module_pre_uninstall_cssholmes(/** @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...
20
{
21
    // Do some synchronization
22
    return true;
23
}
24
25
/**
26
 * Performs tasks required during uninstallation of the module
27
 * @param \XoopsModule $module {@link XoopsModule}
28
 *
29
 * @return bool true if uninstallation successful, false if not
30
 */
31
function xoops_module_uninstall_cssholmes(\XoopsModule $module)
32
{
33
    //    return true;
34
35
    $moduleDirName      = basename(dirname(__DIR__));
36
    $moduleDirNameUpper = mb_strtoupper($moduleDirName);
37
    /** @var \XoopsModules\Cssholmes\Helper $helper */
38
    $helper = \XoopsModules\Cssholmes\Helper::getInstance();
39
40
    /** @var Cssholmes\Utility $utility */
41
    $utility = new Cssholmes\Utility();
42
43
    $success = true;
44
    $helper->loadLanguage('admin');
45
46
    //------------------------------------------------------------------
47
    // Remove uploads folder (and all subfolders) if they exist
48
    //------------------------------------------------------------------
49
50
    $old_directories = [$GLOBALS['xoops']->path("uploads/{$moduleDirName}")];
51
    foreach ($old_directories as $old_dir) {
52
        $dirInfo = new \SplFileInfo($old_dir);
53
        if ($dirInfo->isDir()) {
54
            // The directory exists so delete it
55
            if (false === $utility::rrmdir($old_dir)) {
56
                $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $old_dir));
57
                $success = false;
58
            }
59
        }
60
        unset($dirInfo);
61
    }
62
    /*
63
    //------------ START ----------------
64
    //------------------------------------------------------------------
65
    // Remove xsitemap.xml from XOOPS root folder if it exists
66
    //------------------------------------------------------------------
67
    $xmlfile = $GLOBALS['xoops']->path('xsitemap.xml');
68
    if (is_file($xmlfile)) {
69
        if (false === ($delOk = unlink($xmlfile))) {
70
            $module->setErrors(sprintf(_AM_CSSHOLMES_ERROR_BAD_REMOVE, $xmlfile));
71
        }
72
    }
73
//    return $success && $delOk; // use this if you're using this routine
74
*/
75
76
    return $success;
77
    //------------ END  ----------------
78
}
79