From 278355dc6dedd997577c515eac5bfa80adb8f9b8 Mon Sep 17 00:00:00 2001 From: Aleksey Lim Date: Sat, 01 Aug 2009 05:47:51 +0000 Subject: Process hulahop version to make SP identification precise on XO --- diff --git a/site/app/models/file.php b/site/app/models/file.php index 4a49f97..64b4e74 100644 --- a/site/app/models/file.php +++ b/site/app/models/file.php @@ -85,11 +85,13 @@ class File extends AppModel // Platform WHERE if necessary $platform = !empty($platform_id) ? " AND (File.platform_id = ".PLATFORM_ALL." OR File.platform_id = {$platform_id})" : ''; - if (preg_match('/OLPC\//', $_SERVER['HTTP_USER_AGENT'])) - $sp = 0.82; - else { - preg_match('/Sugar Labs\/([^\s]*)/', $_SERVER['HTTP_USER_AGENT'], $matches); - if (isset($matches[1])) + if (preg_match('/OLPC\/0\.([^-]*)-/', $_SERVER['HTTP_USER_AGENT'], $matches)) { + if (floatval($matches[1]) <= 4.6) + $sp = 0.82; + else + $sp = 0.84; + } else { + if (preg_match('/Sugar Labs\/([^\s]*)/', $_SERVER['HTTP_USER_AGENT'], $matches)) $sp = floatval($matches[1]); else $sp = 0.84; diff --git a/site/app/models/version.php b/site/app/models/version.php index 17f9c44..f836e38 100644 --- a/site/app/models/version.php +++ b/site/app/models/version.php @@ -137,11 +137,13 @@ class Version extends AppModel if (!is_array($status)) $status = array($status); $status_sql = implode(',',$status); - if (preg_match('/OLPC\//', $_SERVER['HTTP_USER_AGENT'])) - $sp = 0.82; - else { - preg_match('/Sugar Labs\/([^\s]*)/', $_SERVER['HTTP_USER_AGENT'], $matches); - if (isset($matches[1])) + if (preg_match('/OLPC\/0\.([^-]*)-/', $_SERVER['HTTP_USER_AGENT'], $matches)) { + if (floatval($matches[1]) <= 4.6) + $sp = 0.82; + else + $sp = 0.84; + } else { + if (preg_match('/Sugar Labs\/([^\s]*)/', $_SERVER['HTTP_USER_AGENT'], $matches)) $sp = floatval($matches[1]); else $sp = 0.84; diff --git a/site/app/webroot/js/amo2009/addons.js b/site/app/webroot/js/amo2009/addons.js index 4d71ad0..19a8ded 100644 --- a/site/app/webroot/js/amo2009/addons.js +++ b/site/app/webroot/js/amo2009/addons.js @@ -213,14 +213,16 @@ function initDownloadPopup(triggerID, popupID) * @param bool showVersionLink offer a link to the user which will remove the compatibility hint (and allow them to download the add-on) */ function addCompatibilityHints(addonID, versionID, fromVer, toVer, showVersionLink) { - var uapattern_olpc = /OLPC\//; + var uapattern_olpc = /OLPC\/0\.([^-]*)-/; var uamatch_olpc = uapattern_olpc.exec(navigator.userAgent); if (uamatch_olpc) { - var version = "0.82"; + if (vc.compareVersions(uamatch[1], "4.6") <= 0) + var version = "0.82"; + else + var version = "0.84"; } else { var uapattern = /Sugar Labs\/([^\s]*).*$/; - var ua = navigator.userAgent; - var uamatch = uapattern.exec(ua); + var uamatch = uapattern.exec(navigator.userAgent); if (!uamatch || uamatch.length < 2) { var version = "0.84"; } else { -- cgit v0.9.1