xoops_module_uninstall_xoopsmembers()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 42
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 15
c 0
b 0
f 0
nc 3
nop 1
dl 0
loc 42
rs 9.7666
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\Xoopsmembers;
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_xoopsmembers(\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

20
function xoops_module_pre_uninstall_xoopsmembers(/** @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...
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_xoopsmembers(\XoopsModule $module)
33
{
34
    //    return true;
35
36
    $moduleDirName      = \basename(\dirname(__DIR__));
37
    $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
38
    /** @var Xoopsmembers\Helper $helper */
39
    $helper = Xoopsmembers\Helper::getInstance();
40
41
    /** @var Xoopsmembers\Utility $utility */
42
    $utility = new Xoopsmembers\Utility();
0 ignored issues
show
Unused Code introduced by
The assignment to $utility is dead and can be removed.
Loading history...
43
44
    $success = true;
45
    $helper->loadLanguage('admin');
46
47
    // Rename uploads folder to BAK and add date to name
48
    $uploadDirectory = $GLOBALS['xoops']->path("uploads/$moduleDirName");
49
    $dirInfo = new \SplFileInfo($uploadDirectory);
50
    if ($dirInfo->isDir()) {
51
        // The directory exists so rename it
52
        $date = date('Y-m-d');
53
        if (!rename($uploadDirectory, $uploadDirectory . "_bak_$date")) {
54
            $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $uploadDirectory));
55
            $success = false;
56
        }
57
    }
58
    unset($dirInfo);
59
    /*
60
    //------------ START ----------------
61
    //------------------------------------------------------------------
62
    // Remove xsitemap.xml from XOOPS root folder if it exists
63
    //------------------------------------------------------------------
64
    $xmlfile = $GLOBALS['xoops']->path('xsitemap.xml');
65
    if (is_file($xmlfile)) {
66
        if (false === ($delOk = unlink($xmlfile))) {
67
            $module->setErrors(sprintf(_AM_XOOPSMEMBERS_ERROR_BAD_REMOVE, $xmlfile));
68
        }
69
    }
70
//    return $success && $delOk; // use this if you're using this routine
71
*/
72
73
    return $success;
74
    //------------ END  ----------------
75
}
76