You are here

function acquia_agent_check_subscription in Acquia Connector 7

Same name and namespace in other branches
  1. 6.2 acquia_agent/acquia_agent.module \acquia_agent_check_subscription()
  2. 6 acquia_agent/acquia_agent.module \acquia_agent_check_subscription()
  3. 7.3 acquia_agent/acquia_agent.module \acquia_agent_check_subscription()
  4. 7.2 acquia_agent/acquia_agent.module \acquia_agent_check_subscription()

Get subscription status from the Acquia Network, and store the result.

This check also sends a heartbeat to the Acquia Network unless $params['no_heartbeat'] == 1.

8 calls to acquia_agent_check_subscription()
acquia_agent_cron in acquia_agent/acquia_agent.module
Implementation of hook_cron().
acquia_agent_manual_status in acquia_agent/acquia_agent.module
Substituted menu callback for 'admin/reports/updates/check'.
acquia_agent_refresh_status in acquia_agent/acquia_agent.module
Menu callback for 'admin/config/system/acquia-agent/refresh-status'.
acquia_agent_set_submit in acquia_agent/acquia_agent.pages.inc
Save acquia_agent_settings form submissions.
acquia_agent_subscription_is_active in acquia_agent/acquia_agent.module
Helper function to check if the site has an active subscription.

... See full list

File

acquia_agent/acquia_agent.module, line 116
Acquia Agent securely sends information to Acquia Network.

Code

function acquia_agent_check_subscription($params = array()) {

  // Default return value is FALSE.
  $subscription = FALSE;
  if (!acquia_agent_has_credentials()) {

    // If there is not an identifier or key, delete any old subscription data.
    variable_del('acquia_subscription_data');
  }
  else {

    // There is an identifier and key, so attempt communication.
    // Include version number information.
    acquia_agent_load_versions();
    if (IS_ACQUIA_DRUPAL) {
      $params['version'] = ACQUIA_DRUPAL_VERSION;
      $params['series'] = ACQUIA_DRUPAL_SERIES;
      $params['branch'] = ACQUIA_DRUPAL_BRANCH;
      $params['revision'] = ACQUIA_DRUPAL_REVISION;
    }

    // Include Acquia Search module version number.
    if (module_exists('acquia_search')) {
      foreach (array(
        'acquia_search',
        'apachesolr',
      ) as $name) {
        $info = system_get_info('module', $name);

        // Send the version, or at least the core compatibility as a fallback.
        $params['search_version'][$name] = isset($info['version']) ? (string) $info['version'] : (string) $info['core'];
      }
    }
    $data = acquia_agent_call('acquia.agent.subscription', $params);
    $subscription['timestamp'] = REQUEST_TIME;
    if ($errno = xmlrpc_errno()) {
      switch ($errno) {
        case SUBSCRIPTION_NOT_FOUND:
        case SUBSCRIPTION_EXPIRED:
          variable_del('acquia_subscription_data');
          break;
      }
    }
    elseif (acquia_agent_valid_response($data)) {
      $subscription += $data['result']['body'];
      variable_set('acquia_subscription_data', $subscription);
    }
    else {
      watchdog('acquia agent', 'HMAC validation error: <pre>@data</pre>', array(
        '@data' => print_r($data, TRUE),
      ), WATCHDOG_ERROR);
    }
  }
  module_invoke_all('acquia_subscription_status', acquia_agent_subscription_is_active());
  return $subscription;
}