1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
You may not change or alter any portion of this comment or credits |
5
|
|
|
of supporting developers from this source code or any supporting source code |
6
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
7
|
|
|
|
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
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Module: lexikon |
15
|
|
|
* |
16
|
|
|
* @category Module |
17
|
|
|
* @package lexikon |
18
|
|
|
* @author XOOPS Development Team <https://xoops.org> |
19
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
20
|
|
|
* @license GPL 2.0 or later |
21
|
|
|
* @link https://xoops.org/ |
22
|
|
|
* @since 1.0.0 |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
use XoopsModules\Lexikon\{ |
26
|
|
|
Common\Configurator, |
27
|
|
|
Helper, |
28
|
|
|
Utility |
29
|
|
|
}; |
30
|
|
|
/** @var Helper $helper */ |
31
|
|
|
/** @var Utility $utility */ |
32
|
|
|
/** @var Configurator $configurator */ |
33
|
|
|
|
34
|
|
|
require \dirname(__DIR__) . '/preloads/autoloader.php'; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Prepares system prior to attempting to install module |
38
|
|
|
* @param \XoopsModule $module {@link XoopsModule} |
39
|
|
|
* |
40
|
|
|
* @return bool true if ready to install, false if not |
41
|
|
|
*/ |
42
|
|
|
function xoops_module_pre_install_lexikon(\XoopsModule $module) |
43
|
|
|
{ |
44
|
|
|
$utility = new Utility(); |
45
|
|
|
|
46
|
|
|
//check for minimum XOOPS version |
47
|
|
|
$xoopsSuccess = $utility::checkVerXoops($module); |
48
|
|
|
|
49
|
|
|
// check for minimum PHP version |
50
|
|
|
$phpSuccess = $utility::checkVerPhp($module); |
51
|
|
|
|
52
|
|
|
if (false !== $xoopsSuccess && false !== $phpSuccess) { |
53
|
|
|
$moduleTables = &$module->getInfo('tables'); |
54
|
|
|
foreach ($moduleTables as $table) { |
55
|
|
|
$GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';'); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
return $xoopsSuccess && $phpSuccess; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Performs tasks required during installation of the module |
64
|
|
|
* @param \XoopsModule $module {@link XoopsModule} |
65
|
|
|
* |
66
|
|
|
* @return bool true if installation successful, false if not |
67
|
|
|
*/ |
68
|
|
|
function xoops_module_install_lexikon(\XoopsModule $module) |
69
|
|
|
{ |
70
|
|
|
$moduleDirName = \basename(\dirname(__DIR__)); |
71
|
|
|
|
72
|
|
|
$helper = Helper::getInstance(); |
73
|
|
|
$utility = new Utility(); |
74
|
|
|
$configurator = new Configurator(); |
75
|
|
|
|
76
|
|
|
// Load language files |
77
|
|
|
$helper->loadLanguage('admin'); |
78
|
|
|
$helper->loadLanguage('modinfo'); |
79
|
|
|
|
80
|
|
|
// default Permission Settings ---------------------- |
81
|
|
|
$moduleId = $module->getVar('mid'); |
82
|
|
|
|
83
|
|
|
//$moduleName = $module->getVar('name'); |
84
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
85
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
86
|
|
|
// access rights ------------------------------------------ |
87
|
|
|
$grouppermHandler->addRight($moduleDirName . '_approve', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
|
|
|
88
|
|
|
$grouppermHandler->addRight($moduleDirName . '_submit', 1, XOOPS_GROUP_ADMIN, $moduleId); |
89
|
|
|
$grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ADMIN, $moduleId); |
90
|
|
|
$grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_USERS, $moduleId); |
91
|
|
|
$grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ANONYMOUS, $moduleId); |
92
|
|
|
|
93
|
|
|
// --- CREATE FOLDERS --------------- |
94
|
|
|
if (count($configurator->uploadFolders) > 0) { |
95
|
|
|
// foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
96
|
|
|
foreach (array_keys($configurator->uploadFolders) as $i) { |
97
|
|
|
$utility::createFolder($configurator->uploadFolders[$i]); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
// --- COPY blank.png FILES --------------- |
101
|
|
|
if (count($configurator->copyBlankFiles) > 0) { |
102
|
|
|
$file = \dirname(__DIR__) . '/assets/images/blank.png'; |
103
|
|
|
foreach (array_keys($configurator->copyBlankFiles) as $i) { |
104
|
|
|
$dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
105
|
|
|
$utility::copyFile($file, $dest); |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
// --- COPY test folder files --------------- |
110
|
|
|
if (count($configurator->copyTestFolders) > 0) { |
111
|
|
|
// $file = \dirname(__DIR__) . '/testdata/images/'; |
112
|
|
|
foreach (array_keys($configurator->copyTestFolders) as $i) { |
113
|
|
|
$src = $configurator->copyTestFolders[$i][0]; |
114
|
|
|
$dest = $configurator->copyTestFolders[$i][1]; |
115
|
|
|
$utility::rcopy($src, $dest); |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
//delete .html entries from the tpl table |
120
|
|
|
$sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'"; |
121
|
|
|
$GLOBALS['xoopsDB']->queryF($sql); |
122
|
|
|
|
123
|
|
|
return true; |
124
|
|
|
} |
125
|
|
|
|