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
|
|
|
if ((!defined('XOOPS_ROOT_PATH')) || !($GLOBALS['xoopsUser'] instanceof \XoopsUser) |
|
|
|
|
21
|
|
|
|| !$GLOBALS['xoopsUser']->IsAdmin() |
22
|
|
|
) { |
23
|
|
|
exit('Restricted access' . PHP_EOL); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @param string $tablename |
28
|
|
|
* |
29
|
|
|
* @return bool |
30
|
|
|
*/ |
31
|
|
|
function tableExists($tablename) |
32
|
|
|
{ |
33
|
|
|
$result = $GLOBALS['xoopsDB']->queryF("SHOW TABLES LIKE '$tablename'"); |
34
|
|
|
|
35
|
|
|
return ($GLOBALS['xoopsDB']->getRowsNum($result) > 0) ? true : false; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* |
40
|
|
|
* Prepares system prior to attempting to install module |
41
|
|
|
* @param XoopsModule $module {@link XoopsModule} |
42
|
|
|
* |
43
|
|
|
* @return bool true if ready to install, false if not |
44
|
|
|
*/ |
45
|
|
|
function xoops_module_pre_update_planet(\XoopsModule $module) |
46
|
|
|
{ |
47
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
|
|
|
|
48
|
|
|
/** @var Planet\Helper $helper */ |
49
|
|
|
/** @var Planet\Utility $utility */ |
50
|
|
|
$helper = Planet\Helper::getInstance(); |
|
|
|
|
51
|
|
|
$utility = new Planet\Utility(); |
52
|
|
|
|
53
|
|
|
$xoopsSuccess = $utility::checkVerXoops($module); |
54
|
|
|
$phpSuccess = $utility::checkVerPhp($module); |
55
|
|
|
return $xoopsSuccess && $phpSuccess; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* |
60
|
|
|
* Performs tasks required during update of the module |
61
|
|
|
* @param XoopsModule $module {@link XoopsModule} |
62
|
|
|
* @param null $previousVersion |
63
|
|
|
* |
64
|
|
|
* @return bool true if update successful, false if not |
65
|
|
|
*/ |
66
|
|
|
|
67
|
|
|
function xoops_module_update_planet(\XoopsModule $module, $previousVersion = null) |
68
|
|
|
{ |
69
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
70
|
|
|
$capsDirName = strtoupper($moduleDirName); |
|
|
|
|
71
|
|
|
|
72
|
|
|
/** @var Planet\Helper $helper */ |
73
|
|
|
/** @var Planet\Utility $utility */ |
74
|
|
|
/** @var Planet\Configurator $configurator */ |
75
|
|
|
$helper = Planet\Helper::getInstance(); |
|
|
|
|
76
|
|
|
$utility = new Planet\Utility(); |
|
|
|
|
77
|
|
|
$configurator = new Planet\Configurator(); |
78
|
|
|
|
79
|
|
|
if ($previousVersion < 240) { |
80
|
|
|
|
81
|
|
|
//rename column EXAMPLE |
82
|
|
|
$tables = new Tables(); |
83
|
|
|
$table = 'planetx_categories'; |
84
|
|
|
$column = 'ordre'; |
85
|
|
|
$newName = 'order'; |
86
|
|
|
$attributes = "INT(5) NOT NULL DEFAULT '0'"; |
87
|
|
|
if ($tables->useTable($table)) { |
88
|
|
|
$tables->alterColumn($table, $column, $attributes, $newName); |
89
|
|
|
if (!$tables->executeQueue()) { |
90
|
|
|
echo '<br>' . _AM_XXXXX_UPGRADEFAILED0 . ' ' . $migrate->getLastError(); |
|
|
|
|
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
//delete old HTML templates |
95
|
|
|
if (count($configurator->templateFolders) > 0) { |
96
|
|
|
foreach ($configurator->templateFolders as $folder) { |
97
|
|
|
$templateFolder = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $folder); |
98
|
|
|
if (is_dir($templateFolder)) { |
99
|
|
|
$templateList = array_diff(scandir($templateFolder, SCANDIR_SORT_NONE), ['..', '.']); |
100
|
|
|
foreach ($templateList as $k => $v) { |
101
|
|
|
$fileInfo = new \SplFileInfo($templateFolder . $v); |
102
|
|
|
if ('html' === $fileInfo->getExtension() && 'index.html' !== $fileInfo->getFilename()) { |
103
|
|
|
if (file_exists($templateFolder . $v)) { |
104
|
|
|
unlink($templateFolder . $v); |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
// --- DELETE OLD FILES --------------- |
113
|
|
|
if (count($configurator->oldFiles) > 0) { |
114
|
|
|
// foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
115
|
|
|
foreach (array_keys($configurator->oldFiles) as $i) { |
116
|
|
|
$tempFile = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator->oldFiles[$i]); |
117
|
|
|
if (is_file($tempFile)) { |
118
|
|
|
unlink($tempFile); |
119
|
|
|
} |
120
|
|
|
} |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
// --- DELETE OLD FOLDERS --------------- |
124
|
|
|
xoops_load('XoopsFile'); |
125
|
|
|
if (count($configurator->oldFolders) > 0) { |
126
|
|
|
// foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
127
|
|
|
foreach (array_keys($configurator->oldFolders) as $i) { |
128
|
|
|
$tempFolder = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator->oldFolders[$i]); |
129
|
|
|
/* @var $folderHandler XoopsObjectHandler */ |
130
|
|
|
$folderHandler = XoopsFile::getHandler('folder', $tempFolder); |
131
|
|
|
$folderHandler->delete($tempFolder); |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
// --- CREATE FOLDERS --------------- |
136
|
|
View Code Duplication |
if (count($configurator->uploadFolders) > 0) { |
|
|
|
|
137
|
|
|
// foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
138
|
|
|
foreach (array_keys($configurator->uploadFolders) as $i) { |
139
|
|
|
$utilityClass::createFolder($configurator->uploadFolders[$i]); |
|
|
|
|
140
|
|
|
} |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
// --- COPY blank.png FILES --------------- |
144
|
|
View Code Duplication |
if (count($configurator->copyBlankFiles) > 0) { |
|
|
|
|
145
|
|
|
$file = __DIR__ . '/../assets/images/blank.png'; |
146
|
|
|
foreach (array_keys($configurator->copyBlankFiles) as $i) { |
147
|
|
|
$dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
148
|
|
|
$utilityClass::copyFile($file, $dest); |
|
|
|
|
149
|
|
|
} |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
//delete .html entries from the tpl table |
153
|
|
|
$sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . '\' AND `tpl_file` LIKE \'%.html%\''; |
154
|
|
|
$GLOBALS['xoopsDB']->queryF($sql); |
155
|
|
|
|
156
|
|
|
/** @var XoopsGroupPermHandler $gpermHandler */ |
157
|
|
|
$gpermHandler = xoops_getHandler('groupperm'); |
158
|
|
|
return $gpermHandler->deleteByModule($module->getVar('mid'), 'item_read'); |
159
|
|
|
} |
160
|
|
|
return true; |
161
|
|
|
} |
162
|
|
|
|
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.