CRM-16173 - Allow define()s for CIVICRM_CXN_APPS_VERIFY and CIVICRM_CXN_APPS_URL
authorTim Otten <totten@civicrm.org>
Sat, 28 Mar 2015 23:48:08 +0000 (16:48 -0700)
committerTim Otten <totten@civicrm.org>
Tue, 14 Jul 2015 04:00:07 +0000 (21:00 -0700)
CRM/Cxn/BAO/Cxn.php
api/v3/CxnApp.php

index 26a57c70c98a1cfc47577eabd1b3545fe9b7647c..8d9e90c7b9e214088f68c35eb9183cfd989363bb 100644 (file)
@@ -134,8 +134,8 @@ class CRM_Cxn_BAO_Cxn extends CRM_Cxn_DAO_Cxn {
    *   TRUE if application metadata must be verified.
    */
   public static function isAppMetaVerified() {
-    if (defined('CIVICRM_CXN_VERIFY_APPMETA')) {
-      return CIVICRM_CXN_VERIFY_APPMETA;
+    if (defined('CIVICRM_CXN_APPS_VERIFY')) {
+      return CIVICRM_CXN_APPS_VERIFY;
     }
     elseif (!defined('CIVICRM_CXN_CA')) {
       return TRUE;
index 89d3a4d0684124aec621792d3d893c324104c52c..be10d3b82e3f1fd62c7e72151ca58c1f6ac2add7 100644 (file)
@@ -95,12 +95,18 @@ function _civicrm_api3_cxn_app_get_spec(&$spec) {
  */
 function civicrm_api3_cxn_app_get($params) {
   // FIXME: We should cache, but CRM_Utils_Cache and CRM_Core_BAO_Cache don't seem to support TTL...
-  list ($status, $blob) = CRM_Utils_HttpClient::singleton()->get(\Civi\Cxn\Rpc\Constants::OFFICIAL_APPMETAS_URL);
+
+  // You should not change CIVICRM_CXN_APPS_URL in production; this is for local development.
+  $url = defined('CIVICRM_CXN_APPS_URL') ? CIVICRM_CXN_APPS_URL : \Civi\Cxn\Rpc\Constants::OFFICIAL_APPMETAS_URL;
+
+  list ($status, $blob) = CRM_Utils_HttpClient::singleton()->get($url);
   if (CRM_Utils_HttpClient::STATUS_OK != $status) {
     throw new API_Exception("Failed to download application list.");
   }
+
   $agent = new \Civi\Cxn\Rpc\Agent(CRM_Cxn_BAO_Cxn::getCACert(), NULL, NULL);
   $message = $agent->decode(array(AppMetasMessage::NAME, GarbledMessage::NAME), $blob);
+
   if ($message instanceof AppMetasMessage) {
     return _civicrm_api3_basic_array_get('CxnApp', $params, $message->getData(), 'appId',
       array('appId', 'appUrl', 'desc', 'appCert', 'perm'));