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