1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* You may not change or alter any portion of this comment or credits |
7
|
|
|
* of supporting developers from this source code or any supporting source code |
8
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
9
|
|
|
* |
10
|
|
|
* This program is distributed in the hope that it will be useful, |
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
17
|
|
|
* @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
18
|
|
|
* @author XOOPS Development Team |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
use XoopsModules\Rssfit; |
22
|
|
|
use XoopsModules\Rssfit\Utility; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Prepares system prior to attempting to install module |
26
|
|
|
* |
27
|
|
|
* @return bool true if ready to install, false if not |
28
|
|
|
*/ |
29
|
|
|
function xoops_module_pre_install_rssfit(\XoopsModule $module): bool |
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
|
|
|
* |
49
|
|
|
* @return bool true if installation successful, false if not |
50
|
|
|
*/ |
51
|
|
|
function xoops_module_install_rssfit(\XoopsModule $module): bool |
|
|
|
|
52
|
|
|
{ |
53
|
|
|
require_once \dirname(__DIR__) . '/preloads/autoloader.php'; |
54
|
|
|
require_once \dirname(__DIR__, 3) . '/mainfile.php'; |
55
|
|
|
|
56
|
|
|
$moduleDirName = \basename(\dirname(__DIR__)); |
57
|
|
|
|
58
|
|
|
$helper = Rssfit\Helper::getInstance(); |
59
|
|
|
$configurator = new Rssfit\Common\Configurator(); |
60
|
|
|
$utility = new Utility(); |
61
|
|
|
|
62
|
|
|
// Load language files |
63
|
|
|
$helper->loadLanguage('admin'); |
64
|
|
|
$helper->loadLanguage('modinfo'); |
65
|
|
|
|
66
|
|
|
// default Permission Settings ---------------------- |
67
|
|
|
global $xoopsModule; |
68
|
|
|
$moduleId = $xoopsModule->getVar('mid'); |
69
|
|
|
// $moduleId2 = $helper->getModule()->mid(); |
70
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
71
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
72
|
|
|
// access rights ------------------------------------------ |
73
|
|
|
$grouppermHandler->addRight($moduleDirName . '_approve', 1, (int)XOOPS_GROUP_ADMIN, $moduleId); |
74
|
|
|
$grouppermHandler->addRight($moduleDirName . '_submit', 1, (int)XOOPS_GROUP_ADMIN, $moduleId); |
75
|
|
|
$grouppermHandler->addRight($moduleDirName . '_view', 1, (int)XOOPS_GROUP_ADMIN, $moduleId); |
76
|
|
|
$grouppermHandler->addRight($moduleDirName . '_view', 1, (int)XOOPS_GROUP_USERS, $moduleId); |
77
|
|
|
$grouppermHandler->addRight($moduleDirName . '_view', 1, (int)XOOPS_GROUP_ANONYMOUS, $moduleId); |
78
|
|
|
|
79
|
|
|
// --- CREATE FOLDERS --------------- |
80
|
|
|
if (count($configurator->uploadFolders) > 0) { |
81
|
|
|
// foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
82
|
|
|
foreach (array_keys($configurator->uploadFolders) as $i) { |
83
|
|
|
$utility::createFolder($configurator->uploadFolders[$i]); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
// --- COPY blank.png FILES --------------- |
88
|
|
|
if (count($configurator->copyBlankFiles) > 0) { |
89
|
|
|
$file = \dirname(__DIR__) . '/assets/images/blank.png'; |
90
|
|
|
foreach (array_keys($configurator->copyBlankFiles) as $i) { |
91
|
|
|
$dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
92
|
|
|
$utility::copyFile($file, $dest); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
//delete .html entries from the tpl table |
96
|
|
|
$sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $xoopsModule->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'"; |
97
|
|
|
$GLOBALS['xoopsDB']->queryF($sql); |
98
|
|
|
|
99
|
|
|
return true; |
100
|
|
|
} |
101
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.