Merge pull request #10162 from yashodha/CRM-20429
[civicrm-core.git] / CRM / Utils / VersionCheck.php
index 364c8466110ade56dfbfafc2d3f5caec1c63cb2c..6cd1507bd69c5a411f1040c69ff325c074128107 100644 (file)
@@ -287,6 +287,7 @@ class CRM_Utils_VersionCheck {
         'MySQL' => CRM_CORE_DAO::singleValueQuery('SELECT VERSION()'),
         'communityMessagesUrl' => Civi::settings()->get('communityMessagesUrl'),
       );
+      $this->getDomainStats();
       $this->getPayProcStats();
       $this->getEntityStats();
       $this->getExtensionStats();
@@ -339,6 +340,7 @@ class CRM_Utils_VersionCheck {
       'CRM_Member_DAO_MembershipBlock' => 'is_active = 1',
       'CRM_Pledge_DAO_Pledge' => 'is_test = 0',
       'CRM_Pledge_DAO_PledgeBlock' => NULL,
+      'CRM_Mailing_Event_DAO_Delivered' => NULL,
     );
     foreach ($tables as $daoName => $where) {
       $dao = new $daoName();
@@ -381,6 +383,36 @@ class CRM_Utils_VersionCheck {
     }
   }
 
+  /**
+   * Fetch stats about domain and add to 'stats' array.
+   */
+  private function getDomainStats() {
+    // Start with default value NULL, then check to see if there's a better
+    // value to be had.
+    $this->stats['domain_isoCode'] = NULL;
+    $params = array(
+      'id' => CRM_Core_Config::domainID(),
+    );
+    $domain_result = civicrm_api3('domain', 'getsingle', $params);
+    if (!empty($domain_result['contact_id'])) {
+      $address_params = array(
+        'contact_id' => $domain_result['contact_id'],
+        'is_primary' => 1,
+        'sequential' => 1,
+      );
+      $address_result = civicrm_api3('address', 'get', $address_params);
+      if ($address_result['count'] == 1 && !empty($address_result['values'][0]['country_id'])) {
+        $country_params = array(
+          'id' => $address_result['values'][0]['country_id'],
+        );
+        $country_result = civicrm_api3('country', 'getsingle', $country_params);
+        if (!empty($country_result['iso_code'])) {
+          $this->stats['domain_isoCode'] = $country_result['iso_code'];
+        }
+      }
+    }
+  }
+
   /**
    * Send the request to civicrm.org
    * Store results in the cache file