xoops_module_uninstall_rssfit()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 44
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

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

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