Issues (143)

include/oninstall.php (2 issues)

1
<?php
2
/*
3
 * You may not change or alter any portion of this comment or credits
4
 * of supporting developers from this source code or any supporting source code
5
 * which is considered copyrighted (c) material of the original comment or credit authors.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
/**
13
 * @copyright    XOOPS Project https://xoops.org/
14
 * @license      GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
15
 * @package
16
 * @since
17
 * @author       XOOPS Development Team
18
 */
19
20
use XoopsModules\Xdonations;
21
22
//require_once __DIR__ . '/setup.php';
23
24
/**
25
 *
26
 * Prepares system prior to attempting to install module
27
 * @param XoopsModule $module {@link XoopsModule}
28
 *
29
 * @return bool true if ready to install, false if not
30
 */
31
function xoops_module_pre_install_xdonations(\XoopsModule $module)
32
{
33
    require_once dirname(__DIR__) . '/preloads/autoloader.php';
34
    /** @var Xdonations\Utility $utility */
35
    $utility = new \XoopsModules\Xdonations\Utility();
36
    $xoopsSuccess = $utility::checkVerXoops($module);
37
    $phpSuccess   = $utility::checkVerPhp($module);
38
39
    if (false !== $xoopsSuccess && false !==  $phpSuccess) {
40
        $moduleTables =& $module->getInfo('tables');
41
        foreach ($moduleTables as $table) {
42
            $GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';');
43
        }
44
    }
45
46
    return $xoopsSuccess && $phpSuccess;
47
}
48
49
/**
50
 *
51
 * Performs tasks required during installation of the module
52
 * @param XoopsModule $module {@link XoopsModule}
53
 *
54
 * @return bool true if installation successful, false if not
55
 */
56
function xoops_module_install_xdonations(\XoopsModule $module)
0 ignored issues
show
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

56
function xoops_module_install_xdonations(/** @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...
57
{
58
    require_once   dirname(dirname(dirname(__DIR__))) . '/mainfile.php';
59
    require_once   dirname(__DIR__) . '/include/config.php';
60
61
    $moduleDirName = basename(dirname(__DIR__));
62
    /** @var Xdonations\Helper $helper */
63
    $helper       = Xdonations\Helper::getInstance();
64
    $utility      = new Xdonations\Utility();
65
    $configurator = new Xdonations\Common\Configurator();
66
    // Load language files
67
    $helper->loadLanguage('admin');
68
    $helper->loadLanguage('modinfo');
69
70
    // default Permission Settings ----------------------
71
    global $xoopsModule;
72
    $moduleId     = $xoopsModule->getVar('mid');
73
    $moduleId2    = $helper->getModule()->mid();
0 ignored issues
show
The assignment to $moduleId2 is dead and can be removed.
Loading history...
74
    $grouppermHandler = xoops_getHandler('groupperm');
75
    // access rights ------------------------------------------
76
    $grouppermHandler->addRight($moduleDirName . '_approve', 1, XOOPS_GROUP_ADMIN, $moduleId);
77
    $grouppermHandler->addRight($moduleDirName . '_submit', 1, XOOPS_GROUP_ADMIN, $moduleId);
78
    $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ADMIN, $moduleId);
79
    $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_USERS, $moduleId);
80
    $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ANONYMOUS, $moduleId);
81
82
    //  ---  CREATE FOLDERS ---------------
83
    if (count($configurator->uploadFolders) > 0) {
84
        //    foreach (array_keys($GLOBALS['uploadFolders']) as $i) {
85
        foreach (array_keys($configurator->uploadFolders) as $i) {
86
            $utility::createFolder($configurator->uploadFolders[$i]);
87
        }
88
    }
89
90
    //  ---  COPY blank.png FILES ---------------
91
    if (count($configurator->copyBlankFiles) > 0) {
92
        $file =  dirname(__DIR__) . '/assets/images/blank.png';
93
        foreach (array_keys($configurator->copyBlankFiles) as $i) {
94
            $dest = $configurator->copyBlankFiles[$i] . '/blank.png';
95
            $utility::copyFile($file, $dest);
96
        }
97
    }
98
    //delete .html entries from the tpl table
99
    $sql = 'DELETE FROM ' . $xoopsDB->prefix('tplfile') . " WHERE `tpl_module` = '" . $xoopsModule->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'";
100
    $xoopsDB->queryF($sql);
101
102
    return true;
103
}
104