|
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: Tag |
|
15
|
|
|
* |
|
16
|
|
|
* @category Module |
|
17
|
|
|
* @package tag |
|
18
|
|
|
* @author XOOPS Module Development Team |
|
19
|
|
|
* @author Mamba |
|
20
|
|
|
* @author Herve Thouzard |
|
21
|
|
|
* @copyright {@link http://xoops.org 2001-2016 XOOPS Project} |
|
22
|
|
|
* @coypright Herve Thouzard |
|
23
|
|
|
* @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
|
24
|
|
|
* @link http://xoops.org XOOPS |
|
25
|
|
|
* @since 2.00 |
|
26
|
|
|
*/ |
|
27
|
|
|
|
|
28
|
|
|
if ((!defined('XOOPS_ROOT_PATH')) || !($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->IsAdmin()) { |
|
|
|
|
|
|
29
|
|
|
exit('Restricted access' . PHP_EOL); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @param string $tablename |
|
34
|
|
|
* |
|
35
|
|
|
* @return bool |
|
36
|
|
|
*/ |
|
37
|
|
|
function tableExists($tablename) |
|
|
|
|
|
|
38
|
|
|
{ |
|
39
|
|
|
$result = $GLOBALS['xoopsDB']->queryF("SHOW TABLES LIKE '$tablename'"); |
|
40
|
|
|
return ($GLOBALS['xoopsDB']->getRowsNum($result) > 0) ? true : false; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* |
|
45
|
|
|
* Prepares system prior to attempting to install module |
|
46
|
|
|
* @param XoopsModule $module {@link XoopsModule} |
|
47
|
|
|
* |
|
48
|
|
|
* @return bool true if ready to install, false if not |
|
49
|
|
|
*/ |
|
50
|
|
|
function xoops_module_pre_update_tag(XoopsModule $module) |
|
|
|
|
|
|
51
|
|
|
{ |
|
52
|
|
|
|
|
53
|
|
|
if (!class_exists('TagUtilities')) { |
|
54
|
|
|
xoops_load('utilities', 'tag'); |
|
55
|
|
|
} |
|
56
|
|
|
//check for minimum XOOPS version |
|
57
|
|
|
if (!TagUtilities::checkXoopsVer($module)) { |
|
58
|
|
|
return false; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
// check for minimum PHP version |
|
62
|
|
|
if (!TagUtilities::checkPHPVer($module)) { |
|
63
|
|
|
return false; |
|
64
|
|
|
} |
|
65
|
|
|
return true; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* |
|
70
|
|
|
* Performs tasks required during update of the module |
|
71
|
|
|
* @param XoopsModule $module {@link XoopsModule} |
|
72
|
|
|
* @param null $prev_version |
|
73
|
|
|
* |
|
74
|
|
|
* @return bool true if update successful, false if not |
|
75
|
|
|
*/ |
|
76
|
|
|
|
|
77
|
|
View Code Duplication |
function xoops_module_update_tag(XoopsModule $module, $prev_version = null) |
|
|
|
|
|
|
78
|
|
|
{ |
|
79
|
|
|
//load_functions("config"); |
|
80
|
|
|
//mod_clearConfg($module->getVar("dirname", "n")); |
|
|
|
|
|
|
81
|
|
|
|
|
82
|
|
|
if ($prev_version <= 150) { |
|
83
|
|
|
$GLOBALS['xoopsDB']->queryFromFile($GLOBALS['xoops']->path('/modules/' . $module->getVar('dirname') . '/sql/mysql.150.sql')); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/* Do some synchronization */ |
|
87
|
|
|
include_once $GLOBALS['xoops']->path('/modules/' . $module->getVar('dirname') . '/include/functions.recon.php'); |
|
88
|
|
|
tag_synchronization(); |
|
89
|
|
|
|
|
90
|
|
|
return true; |
|
91
|
|
|
} |
|
92
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.