diff options
author | Nils Adermann <naderman@naderman.de> | 2011-07-16 22:22:35 -0400 |
---|---|---|
committer | Nils Adermann <naderman@naderman.de> | 2011-07-16 22:22:35 -0400 |
commit | 6923069e0e1a1c7f525545c5d796beb40920b2d1 (patch) | |
tree | a00b462c3bbbfa10b00796b029e8e63dac738b5f /phpBB/includes | |
parent | aa0c3a0f455f40990d5c05802ccfd75dac2fd049 (diff) | |
parent | 82fa4eff7ebcc10b808de9dacb7520ad0d2e1df1 (diff) | |
download | forums-6923069e0e1a1c7f525545c5d796beb40920b2d1.tar forums-6923069e0e1a1c7f525545c5d796beb40920b2d1.tar.gz forums-6923069e0e1a1c7f525545c5d796beb40920b2d1.tar.bz2 forums-6923069e0e1a1c7f525545c5d796beb40920b2d1.tar.xz forums-6923069e0e1a1c7f525545c5d796beb40920b2d1.zip |
Merge branch 'develop-olympus' into develop
* develop-olympus:
[ticket/10263] Call phpbb_version_compare() from includes/acp/acp_main.php
[ticket/10263] Call phpbb_version_compare() from includes/acp/acp_update.php
[ticket/10263] Adding unit tests for phpbb_version_compare().
[ticket/10263] Add wrapper for version_compare() that allows the use of A and B
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/acp/acp_main.php | 5 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_update.php | 7 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 28 |
3 files changed, 31 insertions, 9 deletions
diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index ac375838fd..40a186b21d 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -415,11 +415,8 @@ class acp_main { $latest_version_info = explode("\n", $latest_version_info); - $latest_version = str_replace('rc', 'RC', strtolower(trim($latest_version_info[0]))); - $current_version = str_replace('rc', 'RC', strtolower($config['version'])); - $template->assign_vars(array( - 'S_VERSION_UP_TO_DATE' => version_compare($current_version, $latest_version, '<') ? false : true, + 'S_VERSION_UP_TO_DATE' => phpbb_version_compare(trim($latest_version_info[0]), $config['version'], '<='), )); } diff --git a/phpBB/includes/acp/acp_update.php b/phpBB/includes/acp/acp_update.php index 41fb0884b7..f0365e8e66 100644 --- a/phpBB/includes/acp/acp_update.php +++ b/phpBB/includes/acp/acp_update.php @@ -69,12 +69,9 @@ class acp_update $current_version = (!empty($version_update_from)) ? $version_update_from : $config['version']; - $up_to_date_automatic = (version_compare(str_replace('rc', 'RC', strtolower($current_version)), str_replace('rc', 'RC', strtolower($latest_version)), '<')) ? false : true; - $up_to_date = (version_compare(str_replace('rc', 'RC', strtolower($config['version'])), str_replace('rc', 'RC', strtolower($latest_version)), '<')) ? false : true; - $template->assign_vars(array( - 'S_UP_TO_DATE' => $up_to_date, - 'S_UP_TO_DATE_AUTO' => $up_to_date_automatic, + 'S_UP_TO_DATE' => phpbb_version_compare($latest_version, $config['version'], '<='), + 'S_UP_TO_DATE_AUTO' => phpbb_version_compare($latest_version, $current_version, '<='), 'S_VERSION_CHECK' => true, 'U_ACTION' => $this->u_action, 'U_VERSIONCHECK_FORCE' => append_sid($this->u_action . '&versioncheck_force=1'), diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 6bc5c6e0f4..aa07ca269e 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -549,6 +549,34 @@ function phpbb_email_hash($email) } /** +* Wrapper for version_compare() that allows using uppercase A and B +* for alpha and beta releases. +* +* See http://www.php.net/manual/en/function.version-compare.php +* +* @param string $version1 First version number +* @param string $version2 Second version number +* @param string $operator Comparison operator (optional) +* +* @return mixed Integer (-1, 0, 1) if comparison operator is specified. +* Boolean (true, false) otherwise. +*/ +function phpbb_version_compare($version1, $version2, $operator = null) +{ + $version1 = strtolower($version1); + $version2 = strtolower($version2); + + if (is_null($operator)) + { + return version_compare($version1, $version2); + } + else + { + return version_compare($version1, $version2, $operator); + } +} + +/** * Global function for chmodding directories and files for internal use * * This function determines owner and group whom the file belongs to and user and group of PHP and then set safest possible file permissions. |