1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace XoopsModules\Countdown\Common; |
6
|
|
|
|
7
|
|
|
/* |
8
|
|
|
You may not change or alter any portion of this comment or credits |
9
|
|
|
of supporting developers from this source code or any supporting source code |
10
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
11
|
|
|
|
12
|
|
|
This program is distributed in the hope that it will be useful, |
13
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Module: Countdown |
19
|
|
|
* |
20
|
|
|
* @category Module |
21
|
|
|
* @package countdown |
22
|
|
|
* @author XOOPS Development Team <https://xoops.org> |
23
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
24
|
|
|
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
25
|
|
|
* @link https://xoops.org/ |
26
|
|
|
* @since 1.0.0 |
27
|
|
|
*/ |
28
|
|
|
trait VersionChecks |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* |
32
|
|
|
* Verifies XOOPS version meets minimum requirements for this module |
33
|
|
|
* @static |
34
|
|
|
* @param \XoopsModule $module |
35
|
|
|
* |
36
|
|
|
* @param null|string $requiredVer |
37
|
|
|
* @return bool true if meets requirements, false if not |
38
|
|
|
*/ |
39
|
|
|
public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null) |
40
|
|
|
{ |
41
|
|
|
$moduleDirName = basename(dirname(dirname(__DIR__))); |
42
|
|
|
$moduleDirNameUpper = strtoupper($moduleDirName); |
43
|
|
|
if (null === $module) { |
44
|
|
|
$module = \XoopsModule::getByDirname($moduleDirName); |
45
|
|
|
} |
46
|
|
|
xoops_loadLanguage('admin', $moduleDirName); |
47
|
|
|
|
48
|
|
|
//check for minimum XOOPS version |
49
|
|
|
$currentVer = substr(XOOPS_VERSION, 6); // get the numeric part of string |
50
|
|
|
if (null === $requiredVer) { |
51
|
|
|
$requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string |
|
|
|
|
52
|
|
|
} |
53
|
|
|
$success = true; |
54
|
|
|
|
55
|
|
|
if (version_compare($currentVer, $requiredVer, '<')) { |
56
|
|
|
$success = false; |
57
|
|
|
$module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer)); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
return $success; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* |
65
|
|
|
* Verifies PHP version meets minimum requirements for this module |
66
|
|
|
* @static |
67
|
|
|
* @param \XoopsModule $module |
68
|
|
|
* |
69
|
|
|
* @return bool true if meets requirements, false if not |
70
|
|
|
*/ |
71
|
|
|
public static function checkVerPhp(\XoopsModule $module) |
72
|
|
|
{ |
73
|
|
|
$moduleDirName = basename(dirname(dirname(__DIR__))); |
74
|
|
|
$moduleDirNameUpper = strtoupper($moduleDirName); |
75
|
|
|
xoops_loadLanguage('admin', $module->dirname()); |
|
|
|
|
76
|
|
|
// check for minimum PHP version |
77
|
|
|
$success = true; |
78
|
|
|
$verNum = PHP_VERSION; |
79
|
|
|
$reqVer = $module->getInfo('min_php'); |
80
|
|
|
if (false !== $reqVer && '' !== $reqVer) { |
81
|
|
|
if (version_compare($verNum, $reqVer, '<')) { |
|
|
|
|
82
|
|
|
$module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum)); |
|
|
|
|
83
|
|
|
$success = false; |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
return $success; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|