Issues (525)

include/uninstall.php (1 issue)

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