Completed
Push — master ( 6452b0...d576ea )
by Michael
05:58 queued 03:02
created

include/install_function.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * News functions
4
 *
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
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
 * @copyright   {@link http://xoops.org/ XOOPS Project}
13
 * @license     GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
14
 * @author      Voltan
15
 * @package     News
16
 * @param $xoopsModule
17
 * @return bool
18
 */
19
20
function xoops_module_pre_install_news(&$xoopsModule)
21
{
22
    // Check if this XOOPS version is supported
23
    $minSupportedVersion = explode('.', '2.5.0');
24
    $currentVersion      = explode('.', substr(XOOPS_VERSION, 6));
25
26
    if ($currentVersion[0] > $minSupportedVersion[0]) {
27
        return true;
28
    } elseif ($currentVersion[0] == $minSupportedVersion[0]) {
29
        if ($currentVersion[1] > $minSupportedVersion[1]) {
30
            return true;
31
        } elseif ($currentVersion[1] == $minSupportedVersion[1]) {
32
            if ($currentVersion[2] > $minSupportedVersion[2]) {
33
                return true;
34
            } elseif ($currentVersion[2] == $minSupportedVersion[2]) {
35
                return true;
36
            }
37
        }
38
    }
39
40
    return false;
41
}
42
43
/**
44
 * @param $xoopsModule
45
 *
46
 * @return bool
47
 */
48
function xoops_module_install_news(&$xoopsModule)
49
{
50
    $module_id     = $xoopsModule->getVar('mid');
51
    $gpermHandler  = xoops_getHandler('groupperm');
52
    $configHandler = xoops_getHandler('config');
0 ignored issues
show
$configHandler is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
53
54
    /**
55
     * Default public category permission mask
56
     */
57
58
    // Access right
59
    $gpermHandler->addRight('news_approve', 1, XOOPS_GROUP_ADMIN, $module_id);
60
    $gpermHandler->addRight('news_submit', 1, XOOPS_GROUP_ADMIN, $module_id);
61
    $gpermHandler->addRight('news_view', 1, XOOPS_GROUP_ADMIN, $module_id);
62
63
    $gpermHandler->addRight('news_view', 1, XOOPS_GROUP_USERS, $module_id);
64
    $gpermHandler->addRight('news_view', 1, XOOPS_GROUP_ANONYMOUS, $module_id);
65
66
    $dir = XOOPS_ROOT_PATH . '/uploads/news';
67
    if (!is_dir($dir)) {
68
        mkdir($dir, 0777);
69
    }
70
    chmod($dir, 0777);
71
72
    $dir = XOOPS_ROOT_PATH . '/uploads/news/file';
73
    if (!is_dir($dir)) {
74
        mkdir($dir, 0777);
75
    }
76
    chmod($dir, 0777);
77
78
    $dir = XOOPS_ROOT_PATH . '/uploads/news/image';
79
    if (!is_dir($dir)) {
80
        mkdir($dir, 0777);
81
    }
82
    chmod($dir, 0777);
83
84
    // Copy index.html files on uploads folders
85
    $indexFile = XOOPS_ROOT_PATH . '/modules/news/include/index.html';
86
    copy($indexFile, XOOPS_ROOT_PATH . '/uploads/news/index.html');
87
    copy($indexFile, XOOPS_ROOT_PATH . '/uploads/news/file/index.html');
88
    copy($indexFile, XOOPS_ROOT_PATH . '/uploads/news/image/index.html');
89
90
    return true;
91
}
92