1
|
|
|
<?php declare(strict_types=1); |
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.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
15
|
|
|
* @author XOOPS Development Team |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
use XoopsModules\Moduleinstaller; |
19
|
|
|
use XoopsModules\Moduleinstaller\Utility; |
20
|
|
|
|
21
|
|
|
//require_once __DIR__ . '/setup.php'; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Prepares system prior to attempting to install module |
25
|
|
|
* @param \XoopsModule $module {@link XoopsModule} |
26
|
|
|
* |
27
|
|
|
* @return bool true if ready to install, false if not |
28
|
|
|
*/ |
29
|
|
|
function xoops_module_pre_install_moduleinstaller(\XoopsModule $module) |
30
|
|
|
{ |
31
|
|
|
require_once \dirname(__DIR__) . '/preloads/autoloader.php'; |
32
|
|
|
$utility = new Utility(); |
33
|
|
|
$xoopsSuccess = $utility::checkVerXoops($module); |
34
|
|
|
$phpSuccess = $utility::checkVerPhp($module); |
35
|
|
|
|
36
|
|
|
if ($xoopsSuccess && $phpSuccess) { |
37
|
|
|
$moduleTables = &$module->getInfo('tables'); |
38
|
|
|
foreach ($moduleTables as $table) { |
39
|
|
|
$GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';'); |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
return $xoopsSuccess && $phpSuccess; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Performs tasks required during installation of the module |
48
|
|
|
* @param \XoopsModule $module {@link XoopsModule} |
49
|
|
|
* |
50
|
|
|
* @return bool true if installation successful, false if not |
51
|
|
|
*/ |
52
|
|
|
function xoops_module_install_moduleinstaller(\XoopsModule $module) |
|
|
|
|
53
|
|
|
{ |
54
|
|
|
require_once \dirname(__DIR__, 3) . '/mainfile.php'; |
55
|
|
|
|
56
|
|
|
$moduleDirName = \basename(\dirname(__DIR__)); |
57
|
|
|
|
58
|
|
|
$helper = Moduleinstaller\Helper::getInstance(); |
59
|
|
|
$utility = new Utility(); |
60
|
|
|
$configurator = new Moduleinstaller\Common\Configurator(); |
61
|
|
|
// Load language files |
62
|
|
|
$helper->loadLanguage('admin'); |
63
|
|
|
$helper->loadLanguage('modinfo'); |
64
|
|
|
|
65
|
|
|
// default Permission Settings ---------------------- |
66
|
|
|
global $xoopsModule; |
67
|
|
|
$moduleId = $xoopsModule->getVar('mid'); |
68
|
|
|
// $moduleId2 = $helper->getModule()->mid(); |
69
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
70
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
71
|
|
|
// access rights ------------------------------------------ |
72
|
|
|
$grouppermHandler->addRight($moduleDirName . '_approve', 1, (int)XOOPS_GROUP_ADMIN, $moduleId); |
73
|
|
|
$grouppermHandler->addRight($moduleDirName . '_submit', 1, (int)XOOPS_GROUP_ADMIN, $moduleId); |
74
|
|
|
$grouppermHandler->addRight($moduleDirName . '_view', 1, (int)XOOPS_GROUP_ADMIN, $moduleId); |
75
|
|
|
$grouppermHandler->addRight($moduleDirName . '_view', 1, (int)XOOPS_GROUP_USERS, $moduleId); |
76
|
|
|
$grouppermHandler->addRight($moduleDirName . '_view', 1, (int)XOOPS_GROUP_ANONYMOUS, $moduleId); |
77
|
|
|
|
78
|
|
|
// --- CREATE FOLDERS --------------- |
79
|
|
|
if (count($configurator->uploadFolders) > 0) { |
80
|
|
|
// foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
81
|
|
|
foreach (array_keys($configurator->uploadFolders) as $i) { |
82
|
|
|
$utility::createFolder($configurator->uploadFolders[$i]); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
// --- COPY blank.png FILES --------------- |
87
|
|
|
if (count($configurator->copyBlankFiles) > 0) { |
88
|
|
|
$file = \dirname(__DIR__) . '/assets/images/blank.png'; |
89
|
|
|
foreach (array_keys($configurator->copyBlankFiles) as $i) { |
90
|
|
|
$dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
91
|
|
|
$utility::copyFile($file, $dest); |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
//delete .html entries from the tpl table |
95
|
|
|
$sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $xoopsModule->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'"; |
96
|
|
|
$GLOBALS['xoopsDB']->queryF($sql); |
97
|
|
|
|
98
|
|
|
return true; |
99
|
|
|
} |
100
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.