From 46693bafab03a26933811d992e3550dd56067047 Mon Sep 17 00:00:00 2001
From: Tim Otten <totten@civicrm.org>
Date: Wed, 30 Oct 2013 17:11:10 -0700
Subject: [PATCH] CRM-13685 - "Manage Extensions" - Fix upgrade check

----------------------------------------
* CRM-13685: "Manage Extension" screen should use "<" to determine upgradeability
  http://issues.civicrm.org/jira/browse/CRM-13685
---
 CRM/Admin/Page/Extensions.php                | 5 +++++
 templates/CRM/Admin/Page/Extensions/Main.tpl | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/CRM/Admin/Page/Extensions.php b/CRM/Admin/Page/Extensions.php
index a6bc3528c0..d92c504e37 100644
--- a/CRM/Admin/Page/Extensions.php
+++ b/CRM/Admin/Page/Extensions.php
@@ -217,6 +217,11 @@ class CRM_Admin_Page_Extensions extends CRM_Core_Page_Basic {
           'key' => $row['key'],
         )
       );
+      if (isset($localExtensionRows[$info->key])) {
+        if (version_compare($localExtensionRows[$info->key]['version'], $info->version, '<')) {
+          $row['is_upgradeable'] = TRUE;
+        }
+      }
       $remoteExtensionRows[$row['id']] = $row;
     }
     $this->assign('remoteExtensionRows', $remoteExtensionRows);
diff --git a/templates/CRM/Admin/Page/Extensions/Main.tpl b/templates/CRM/Admin/Page/Extensions/Main.tpl
index dea6ea4dfe..d9c8a8331f 100644
--- a/templates/CRM/Admin/Page/Extensions/Main.tpl
+++ b/templates/CRM/Admin/Page/Extensions/Main.tpl
@@ -22,7 +22,7 @@ Depends: CRM/common/enableDisable.tpl and CRM/common/jsortable.tpl
         <tr id="row_{$row.id}" class="crm-extensions crm-extensions_{$row.id}{if $row.status eq 'disabled'} disabled{/if}{if $row.status eq 'installed-missing' or $row.status eq 'disabled-missing'} extension-missing{/if}{if $row.upgradable} extension-upgradable{elseif $row.status eq 'installed'} extension-installed{/if}">
           <td class="crm-extensions-label">
               <a class="collapsed" href="#"></a>&nbsp;<strong>{$row.label}</strong><br/>({$row.key})
-              {if $extAddNewEnabled && $remoteExtensionRows[$extKey] && $row.version != $remoteExtensionRows[$extKey].version}
+              {if $extAddNewEnabled && $remoteExtensionRows[$extKey] && $remoteExtensionRows[$extKey].is_upgradeable}
                 {capture assign='upgradeURL'}{crmURL p='civicrm/admin/extensions' q="action=update&id=$extKey&key=$extKey"}{/capture}
                 <div class="crm-extensions-upgrade">{ts 1=$upgradeURL}Version {$remoteExtensionRows[$extKey].version} is available. <a href="%1">Upgrade</a>{/ts}</div>
               {/if}
-- 
GitLab