xoops_module_uninstall_xfguestbook()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
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 3
rs 10
c 1
b 0
f 0
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
/**
12
 * Prepares system prior to attempting to uninstall module
13
 * @param \XoopsModule $module {@link \XoopsModule}
14
 *
15
 * @return bool true if ready to uninstall, false if not
16
 */
17
function xoops_module_pre_uninstall_xfguestbook(\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

17
function xoops_module_pre_uninstall_xfguestbook(/** @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...
18
{
19
    // Do some synchronization
20
    return true;
21
}
22
23
/**
24
 * Performs tasks required during uninstallation of the module
25
 * @param \XoopsModule $module {@link \XoopsModule}
26
 *
27
 * @return bool true if uninstallation successful, false if not
28
 */
29
function xoops_module_uninstall_xfguestbook(\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

29
function xoops_module_uninstall_xfguestbook(/** @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...
30
{
31
    return true;
32
}
33
34
//=======================================================
35
36
/**
37
 * @param \XoopsModule $module
38
 *
39
 * @return bool
40
 */
41
function xoops_module_uninstall_XXXX(\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

41
function xoops_module_uninstall_XXXX(/** @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...
42
{
43
    // global $xoopsDB,$xoopsConfig;
44
    //
45
    // nothing to do yet
46
    return true;
47
    //routine to delete a cache directory
48
    /*
49
     $cacheDir = XOOPS_ROOT_PATH . '/uploads/shoutbox';
50
    //Always check if a directory exists prior to creation
51
    if (!is_dir($cacheDir)) {
52
        return true;
53
    } else {
54
        return rmdirr($cacheDir); // see the function below
55
    }
56
     */
57
58
    //------------- example from user log --------------
59
    /*
60
     $logsetObj = UserlogSetting::getInstance();
61
62
    return $logsetObj->cleanCache(); // delete all settings caches
63
64
     */
65
}
66
67
/**
68
 * Delete a file, or a folder and its contents
69
 *
70
 * @param string $dirname The directory to delete
71
 * @return bool   Returns true on success, false on failure
72
 * @author      Aidan Lister <[email protected]>
73
 */
74
function rmdirr($dirname)
75
{
76
    // Simple delete for a file
77
    if (is_file($dirname)) {
78
        return unlink($dirname);
79
    }
80
81
    // Loop through the folder
82
    $dir = dir($dirname);
83
    while (false !== $entry = $dir->read()) {
84
        // Skip pointers
85
        if ('.' === $entry || '..' === $entry) {
86
            continue;
87
        }
88
89
        // Deep delete directories
90
        if (is_dir("$dirname/$entry")) {
91
            rmdirr("$dirname/$entry");
92
        } else {
93
            unlink("$dirname/$entry");
94
        }
95
    }
96
97
    // Clean up
98
    $dir->close();
99
100
    return rmdir($dirname);
101
}
102