onuninstall.php ➔ xoops_module_pre_uninstall_xxxx()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 5
rs 10
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
12
/**
13
 * Prepares system prior to attempting to uninstall module
14
 * @param XoopsModule $module {@link XoopsModule}
15
 *
16
 * @return bool true if ready to uninstall, false if not
17
 */
18
19
function xoops_module_pre_uninstall_xxxx(\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...
20
{
21
    // Do some synchronization
22
    return true;
23
}
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_xxxx(\XoopsModule $module)
33
{
34
//    return true;
35
36
    $moduleDirName = basename(dirname(__DIR__));
37
    $xsitemapHelper      = \Xmf\Module\Helper::getHelper($moduleDirName);
38
39
    /** @var XXXXXXUtility $utilityClass */
40
    $utilityClass     = ucfirst($moduleDirName) . 'Utility';
41
    if (!class_exists($utilityClass)) {
42
        xoops_load('utility', $moduleDirName);
43
    }
44
45
    $success = true;
46
    $xsitemapHelper->loadLanguage('admin');
47
48
49
    //------------------------------------------------------------------
50
    // Remove uploads folder (and all subfolders) if they exist
51
    //------------------------------------------------------------------
52
53
    $old_directories = [$GLOBALS['xoops']->path("uploads/{$moduleDirName}")];
54
    foreach ($old_directories as $old_dir) {
55
        $dirInfo = new \SplFileInfo($old_dir);
56
        if ($dirInfo->isDir()) {
57
            // The directory exists so delete it
58
            if (false === $utilityClass::rrmdir($old_dir)) {
59
                $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $old_dir));
0 ignored issues
show
Bug introduced by
The variable $moduleDirNameUpper does not exist. Did you mean $module?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
60
                $success = false;
61
            }
62
        }
63
        unset($dirInfo);
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(_AM_XXXXX_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