|
1
|
|
|
<?php namespace XoopsModules\Xfguestbook\Common; |
|
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
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
15
|
|
|
* @license http://www.fsf.org/copyleft/gpl.html GNU public license |
|
16
|
|
|
* @author mamba <[email protected]> |
|
17
|
|
|
*/ |
|
18
|
|
|
trait VersionChecks |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* |
|
22
|
|
|
* Verifies XOOPS version meets minimum requirements for this module |
|
23
|
|
|
* @static |
|
24
|
|
|
* @param \XoopsModule $module |
|
25
|
|
|
* |
|
26
|
|
|
* @param null|string $requiredVer |
|
27
|
|
|
* @return bool true if meets requirements, false if not |
|
28
|
|
|
*/ |
|
29
|
|
|
public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null) |
|
30
|
|
|
{ |
|
31
|
|
|
$moduleDirName = basename(dirname(dirname(__DIR__))); |
|
32
|
|
|
if (null === $module) { |
|
33
|
|
|
$module = \XoopsModule::getByDirname($moduleDirName); |
|
34
|
|
|
} |
|
35
|
|
|
xoops_loadLanguage('admin', $moduleDirName); |
|
36
|
|
|
|
|
37
|
|
|
//check for minimum XOOPS version |
|
38
|
|
|
$currentVer = substr(XOOPS_VERSION, 6); // get the numeric part of string |
|
39
|
|
|
if (null === $requiredVer) { |
|
40
|
|
|
$requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string |
|
|
|
|
|
|
41
|
|
|
} |
|
42
|
|
|
$success = true; |
|
43
|
|
|
|
|
44
|
|
|
if (version_compare($currentVer, $requiredVer, '<')) { |
|
45
|
|
|
$success = false; |
|
46
|
|
|
$module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer)); |
|
|
|
|
|
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
return $success; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* |
|
54
|
|
|
* Verifies PHP version meets minimum requirements for this module |
|
55
|
|
|
* @static |
|
56
|
|
|
* @param \XoopsModule $module |
|
57
|
|
|
* |
|
58
|
|
|
* @return bool true if meets requirements, false if not |
|
59
|
|
|
*/ |
|
60
|
|
|
public static function checkVerPhp(\XoopsModule $module) |
|
61
|
|
|
{ |
|
62
|
|
|
xoops_loadLanguage('admin', $module->dirname()); |
|
|
|
|
|
|
63
|
|
|
// check for minimum PHP version |
|
64
|
|
|
$success = true; |
|
65
|
|
|
$verNum = PHP_VERSION; |
|
66
|
|
|
$reqVer = $module->getInfo('min_php'); |
|
67
|
|
|
if (false !== $reqVer && '' !== $reqVer) { |
|
68
|
|
|
if (version_compare($verNum, $reqVer, '<')) { |
|
|
|
|
|
|
69
|
|
|
$module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum)); |
|
|
|
|
|
|
70
|
|
|
$success = false; |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
return $success; |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|