xoops_module_pre_uninstall_lexikon()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 1
b 0
f 0
1
<?php
2
3
/*
4
 You may not change or alter any portion of this comment or credits
5
 of supporting developers from this source code or any supporting source code
6
 which is considered copyrighted (c) material of the original comment or credit authors.
7
8
 This program is distributed in the hope that it will be useful,
9
 but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
*/
12
13
/**
14
 * Module: lexikon
15
 *
16
 * @category        Module
17
 * @package         lexikon
18
 * @author          XOOPS Development Team <https://xoops.org>
19
 * @copyright       {@link https://xoops.org/ XOOPS Project}
20
 * @license         GPL 2.0 or later
21
 * @link            https://xoops.org/
22
 * @since           1.0.0
23
 */
24
25
use XoopsModules\Lexikon\{
26
    Helper,
27
    Utility
28
};
29
/** @var Helper $helper */
30
/** @var Utility $utility */
31
32
/**
33
 * Prepares system prior to attempting to uninstall module
34
 * @param \XoopsModule $module {@link XoopsModule}
35
 *
36
 * @return bool true if ready to uninstall, false if not
37
 */
38
function xoops_module_pre_uninstall_lexikon(\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

38
function xoops_module_pre_uninstall_lexikon(/** @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...
39
{
40
    // Do some synchronization if needed
41
    return true;
42
}
43
44
/**
45
 * Performs tasks required during uninstallation of the module
46
 * @param \XoopsModule $module {@link XoopsModule}
47
 *
48
 * @return bool true if uninstallation successful, false if not
49
 */
50
function xoops_module_uninstall_lexikon(\XoopsModule $module)
51
{
52
    require \dirname(__DIR__) . '/preloads/autoloader.php';
53
    $moduleDirName      = \basename(\dirname(__DIR__));
54
    $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
0 ignored issues
show
Unused Code introduced by
The assignment to $moduleDirNameUpper is dead and can be removed.
Loading history...
55
56
    $helper  = Helper::getInstance();
57
    $utility = new Utility();
0 ignored issues
show
Unused Code introduced by
The assignment to $utility is dead and can be removed.
Loading history...
58
    //    $configurator = new Lexikon\Common\Configurator();
59
60
    // Load language files
61
    $helper->loadLanguage('admin');
62
    $helper->loadLanguage('common');
63
    $success = true;
64
65
    //------------------------------------------------------------------
66
    // Remove uploads folder (and all subfolders) if they exist
67
    //------------------------------------------------------------------
68
    /*
69
        $old_directories = [$GLOBALS['xoops']->path("uploads/{$moduleDirName}")];
70
        foreach ($old_directories as $old_dir) {
71
            $dirInfo = new \SplFileInfo($old_dir);
72
            if ($dirInfo->isDir()) {
73
                // The directory exists so delete it
74
                if (false === $utility::rrmdir($old_dir)) {
75
                    $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $old_dir));
76
                    $success = false;
77
                }
78
            }
79
            unset($dirInfo);
80
        }
81
        */
82
83
    /*
84
    //------------ START ----------------
85
    //------------------------------------------------------------------
86
    // Remove xsitemap.xml from XOOPS root folder if it exists
87
    //------------------------------------------------------------------
88
    $xmlfile = $GLOBALS['xoops']->path('xsitemap.xml');
89
    if (is_file($xmlfile)) {
90
        if (false === ($delOk = unlink($xmlfile))) {
91
            $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_REMOVE'), $xmlfile));
92
        }
93
    }
94
//    return $success && $delOk; // use this if you're using this routine
95
*/
96
97
    return $success;
98
    //------------ END  ----------------
99
}
100