xoops_module_pre_uninstall_songlist()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
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 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\Songlist;
13
use XoopsModules\Songlist\Helper;
14
15
/**
16
 * Prepares system prior to attempting to uninstall module
17
 * @param \XoopsModule $module {@link XoopsModule}
18
 *
19
 * @return bool true if ready to uninstall, false if not
20
 */
21
function xoops_module_pre_uninstall_songlist(\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

21
function xoops_module_pre_uninstall_songlist(/** @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...
22
{
23
    // Do some synchronization
24
    return true;
25
}
26
27
/**
28
 * Performs tasks required during uninstallation of the module
29
 * @param \XoopsModule $module {@link XoopsModule}
30
 *
31
 * @return bool true if uninstallation successful, false if not
32
 */
33
function xoops_module_uninstall_songlist(\XoopsModule $module): bool
34
{
35
    $moduleDirName      = \basename(\dirname(__DIR__));
36
    $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
37
    $helper             = Helper::getInstance();
38
39
    $success = true;
40
    $helper->loadLanguage('admin');
41
42
    // Rename uploads folder to BAK and add date to name
43
    $uploadDirectory = $GLOBALS['xoops']->path("uploads/$moduleDirName");
44
    $dirInfo = new \SplFileInfo($uploadDirectory);
45
    if ($dirInfo->isDir()) {
46
        // The directory exists so rename it
47
        $date = date('Y-m-d');
48
        if (!rename($uploadDirectory, $uploadDirectory . "_bak_$date")) {
49
            $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR_FOLDER_RENAME_FAILED'), $uploadDirectory));
50
            $success = false;
51
        }
52
    }
53
    unset($dirInfo);
54
    /*
55
    //------------ START ----------------
56
    //------------------------------------------------------------------
57
    // Remove xsitemap.xml from XOOPS root folder if it exists
58
    //------------------------------------------------------------------
59
    $xmlfile = $GLOBALS['xoops']->path('xsitemap.xml');
60
    if (is_file($xmlfile)) {
61
        if (false === ($delOk = unlink($xmlfile))) {
62
            $module->setErrors(sprintf(_AM_XXXXX_ERROR_BAD_REMOVE, $xmlfile));
63
        }
64
    }
65
//    return $success && $delOk; // use this if you're using this routine
66
*/
67
68
    return $success;
69
    //------------ END  ----------------
70
}
71