xoops_module_pre_uninstall_gbook()   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
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * uninstall.php - cleanup on module uninstall
6
 *
7
 * @author          XOOPS Module Development Team
8
 * @copyright       {@link https://xoops.org 2001-2016 XOOPS Project}
9
 * @license         {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
10
 * @link            https://xoops.org XOOPS
11
 */
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
20
use XoopsModules\Gbook;
21
22
/**
23
 * @param \XoopsModule $module
24
 * @return bool
25
 */
26
function xoops_module_pre_uninstall_gbook(\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

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