1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits of |
4
|
|
|
supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit |
6
|
|
|
authors. |
7
|
|
|
|
8
|
|
|
This program is distributed in the hope that it will be useful, but |
9
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of |
10
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Module: xForms |
15
|
|
|
* |
16
|
|
|
* @package \XoopsModules\Smallworld |
17
|
|
|
* @author Richard Griffith <[email protected]> |
18
|
|
|
* @author trabis <[email protected]> |
19
|
|
|
* @author XOOPS Module Development Team |
20
|
|
|
* @copyright Copyright (c) 2001-2020 {@link https://xoops.org XOOPS Project} |
21
|
|
|
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU Public License |
22
|
|
|
* @link https://github.com/XoopsModules25x/smallworld |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
use XoopsModules\Smallworld; |
26
|
|
|
use XoopsModules\Smallworld\Helper; |
27
|
|
|
use XoopsModules\Smallworld\Utility; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @internal {Make sure you PROTECT THIS FILE} |
31
|
|
|
*/ |
32
|
|
|
if ((!defined('XOOPS_ROOT_PATH')) |
33
|
|
|
|| !($GLOBALS['xoopsUser'] instanceof \XoopsUser) |
|
|
|
|
34
|
|
|
|| !($GLOBALS['xoopsUser']->isAdmin())) { |
35
|
|
|
exit('Restricted access' . PHP_EOL); |
36
|
|
|
} |
37
|
|
|
/** |
38
|
|
|
* Prepares system prior to attempting to update module |
39
|
|
|
* |
40
|
|
|
* @param \XoopsModule $module {@link \XoopsModule} |
41
|
|
|
* @return bool true if ready to install, false if not |
42
|
|
|
*/ |
43
|
|
|
function xoops_module_pre_update_smallworld(\XoopsModule $module) |
44
|
|
|
{ |
45
|
|
|
/** |
46
|
|
|
* @var Smallworld\Helper $helper |
47
|
|
|
* @var Smallworld\Utility $utility |
48
|
|
|
*/ |
49
|
|
|
$helper = Smallworld\Helper::getInstance(); |
50
|
|
|
$utility = new Smallworld\Utility(); |
51
|
|
|
$xoopsSuccess = $utility::checkVerXoops($module); |
52
|
|
|
$phpSuccess = $utility::checkVerPhp($module); |
53
|
|
|
|
54
|
|
|
return $xoopsSuccess && $phpSuccess; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Update Smallworld module |
59
|
|
|
* |
60
|
|
|
* @param \XoopsModule $module |
61
|
|
|
* @return bool true on succeess, false on failure |
62
|
|
|
*/ |
63
|
|
|
function xoops_module_update_smallworld(\XoopsModule $module) |
64
|
|
|
{ |
65
|
|
|
$tables = new \Xmf\Database\Tables(); |
66
|
|
|
|
67
|
|
|
$cTable = 'config'; |
68
|
|
|
$criteria = new \Criteria('conf_name', 'smallworldprivorpub', '='); |
69
|
|
|
if ($success = $tables->useTable($cTable)) { |
70
|
|
|
$success = $tables->update($cTable, ['conf_value' => 1], $criteria); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
$msgTable = 'smallworld_messages'; |
74
|
|
|
$column = 'message'; |
75
|
|
View Code Duplication |
if ($successA = $tables->useTable($msgTable)) { // if this returns false, there is no table |
76
|
|
|
$attributes = $tables->getColumnAttributes($msgTable, $column); |
77
|
|
|
if (false === mb_strpos($attributes, ' TEXT')) { // assumes it's already been updated if TEXT found |
78
|
|
|
$successA = $tables->alterColumn($msgTable, $column, ' TEXT '); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
$comTable = 'smallworld_comments'; |
83
|
|
|
$column = 'comment'; |
84
|
|
View Code Duplication |
if ($successB = $tables->useTable($comTable)) { // if this returns false, there is no table |
85
|
|
|
$attributes = $tables->getColumnAttributes($comTable, $column); |
86
|
|
|
if (false === mb_strpos($attributes, ' TEXT')) { // assumes it's already been updated if 'TEXT' not found |
87
|
|
|
$successB = $tables->alterColumn($comTable, $column, ' TEXT '); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
// now create smallworld_settings table if it doesn't exist |
92
|
|
|
$sTable = 'smallworld_settings'; |
93
|
|
|
if (false === ($successC = $tables->useTable($sTable))) { // if this returns true then the table exists already |
94
|
|
|
// Table does not exist -> create |
95
|
|
|
$successC = $tables->addTable($sTable); |
96
|
|
|
$successC = $successC && ($tables->setTableOptions($sTable, 'ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1')); |
97
|
|
|
$successC = $successC && ($tables->addColumn($sTable, 'id', 'INT(11) NOT NULL AUTO_INCREMENT')); |
98
|
|
|
$successC = $successC && ($tables->addColumn($sTable, 'userid', 'INT(11) NOT NULL')); |
99
|
|
|
$successC = $successC && ($tables->addColumn($sTable, 'value', 'TEXT')); |
100
|
|
|
$successC = $successC && ($tables->addPrimaryKey($sTable, 'id')); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
$successD = $tables->executeQueue(); // change the tables |
104
|
|
|
|
105
|
|
|
// setup the criteria to update the avatar fields |
106
|
|
|
$criteria = new \CriteriaCompo(); |
107
|
|
|
$criteria->add(new \Criteria('userimage', 'blank.gif', '=')); |
108
|
|
|
$criteria->add(new \Criteria('userimage', '\.(jpe?g|gif|png|bmp)', 'NOT REGEXP'), 'OR'); |
109
|
|
|
|
110
|
|
|
// update the admin avatar |
111
|
|
|
$aTable = 'smallworld_admin'; |
112
|
|
|
if ($successE = $tables->useTable($aTable)) { |
113
|
|
|
$successE = $tables->update($aTable, ['userimage' => ''], $criteria); |
114
|
|
|
} |
115
|
|
|
// update user table avatar |
116
|
|
|
$uTable = 'smallworld_user'; |
117
|
|
|
if ($successF = $tables->useTable($uTable)) { |
118
|
|
|
$successF = $tables->update($uTable, ['userimage' => ''], $criteria); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
return $success && $successA && $successB && $successC && $successD && $successE && $successF; |
122
|
|
|
} |
123
|
|
|
|
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.