Completed
Push — master ( 937117...931dfe )
by Michael
05:45 queued 02:42
created

onuninstall.php ➔ xoops_module_pre_uninstall_soapbox()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * uninstall.php - cleanup on module uninstall
4
 *
5
 * @author          XOOPS Module Development Team
6
 * @copyright       {@link http://xoops.org 2001-2016 XOOPS Project}
7
 * @license         {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
8
 * @link            http://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
18
function xoops_module_pre_uninstall_soapbox(XoopsModule $module)
0 ignored issues
show
Unused Code introduced by
The parameter $module is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
19
{
20
    // Do some synchronization
21
    return true;
22
}
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_soapbox(XoopsModule $module)
0 ignored issues
show
Unused Code introduced by
The parameter $module is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
32
{
33
    return true;
34
}
35
36
//=======================================================
37
38
// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
39
40
/**
41
 * @param XoopsModule $module
42
 *
43
 * @return bool
44
 */
45
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.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
46
{
47
    // global $xoopsDB,$xoopsConfig;
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
48
    //
49
    // nothing to do yet
50
    return true;
51
52
    //routine to delete a cache directory
53
    /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
39% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
54
     $cacheDir = XOOPS_ROOT_PATH . '/uploads/shoutbox';
55
    //Always check if a directory exists prior to creation
56
    if (!is_dir($cacheDir)) {
57
        return true;
58
    } else {
59
        return rmdirr($cacheDir); // see the function below
60
    }
61
     */
62
63
    //------------- example from user log --------------
64
    /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
65
     $logsetObj = UserlogSetting::getInstance();
66
67
    return $logsetObj->cleanCache(); // delete all settings caches
68
69
     */
70
}
71
72
/**
73
 * Delete a file, or a folder and its contents
74
 *
75
 * @author      Aidan Lister <[email protected]>
76
 * @param  string $dirname The directory to delete
77
 * @return bool   Returns true on success, false on failure
78
 */
79
80
function rmdirr($dirname)
81
{
82
    // Simple delete for a file
83
    if (is_file($dirname)) {
84
        return unlink($dirname);
85
    }
86
87
    // Loop through the folder
88
    $dir = dir($dirname);
89
    while (false !== $entry = $dir->read()) {
90
        // Skip pointers
91
        if ($entry === '.' || $entry === '..') {
92
            continue;
93
        }
94
95
        // Deep delete directories
96
        if (is_dir("$dirname/$entry")) {
97
            rmdirr("$dirname/$entry");
98
        } else {
99
            unlink("$dirname/$entry");
100
        }
101
    }
102
103
    // Clean up
104
    $dir->close();
105
106
    return rmdir($dirname);
107
}
108