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
|
|
|
* userlog module |
13
|
|
|
* |
14
|
|
|
* @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ |
15
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
16
|
|
|
* @package userlog include |
17
|
|
|
* @since 1 |
18
|
|
|
* @author irmtfan ([email protected]) |
19
|
|
|
* @author The XOOPS Project <www.xoops.org> <www.xoops.ir> |
20
|
|
|
* @version $Id: module.php 1 2013-02-26 16:25:04Z irmtfan $ |
21
|
|
|
*/ |
22
|
|
|
defined("XOOPS_ROOT_PATH") or die("XOOPS root path not defined"); |
|
|
|
|
23
|
|
|
require_once dirname(__FILE__) . '/common.php'; |
24
|
|
|
function xoops_module_uninstall_userlog(&$module) |
|
|
|
|
25
|
|
|
{ |
26
|
|
|
$logsetObj = UserlogSetting::getInstance(); |
27
|
|
|
|
28
|
|
|
return $logsetObj->cleanCache(); // delete all settings caches |
29
|
|
|
} |
30
|
|
|
function xoops_module_update_userlog(&$module, $prev_version = null) |
|
|
|
|
31
|
|
|
{ |
32
|
|
|
if ($prev_version == round( $module->getInfo("version") * 100, 2 )) { |
33
|
|
|
$module->setErrors("You have the latest " . $module->getInfo("name") . " module (". $module->getInfo("dirname") . " version " . $module->getInfo("version") . ") and update is not necessary"); |
34
|
|
|
print_r($module->getErrors()); |
35
|
|
|
|
36
|
|
|
return true; |
37
|
|
|
} |
38
|
|
|
$ret = false; |
39
|
|
|
// first db update |
40
|
|
|
if ($prev_version == 100) { |
41
|
|
|
$ret = update_userlog_v100($module); |
42
|
|
|
} |
43
|
|
|
print_r($module->getErrors()); |
44
|
|
|
|
45
|
|
|
return $ret; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
// update database from v1 to 1.01 (Beta1 to RC1) |
49
|
|
|
// module_name VARCHAR(25) change to VARCHAR(50) |
50
|
|
|
function update_userlog_v100(&$module) |
|
|
|
|
51
|
|
|
{ |
52
|
|
|
$field = "module_name"; |
53
|
|
|
$Userlog = Userlog::getInstance(); |
54
|
|
|
$ret = $Userlog->getHandler('log')->showFields($field); |
55
|
|
|
preg_match_all('!\d+!', $ret[$field]["Type"], $nums); |
56
|
|
|
// only change if module_name Type was VARCHAR(25) |
57
|
|
|
if($nums[0][0] == 25) { |
58
|
|
|
$ret2 = $Userlog->getHandler('log')->changeField($field, "VARCHAR(50)"); |
59
|
|
|
} else { |
60
|
|
|
$ret2 = true; |
61
|
|
|
$module->setErrors("Your table field ({$field}) with size {$ret[$field]['Type']} dont need change."); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
return $ret2; |
65
|
|
|
} |
66
|
|
|
|
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.