You are here

function acquia_lift_requirements in Acquia Lift Connector 7.2

Same name and namespace in other branches
  1. 8.4 acquia_lift.install \acquia_lift_requirements()
  2. 8 acquia_lift.install \acquia_lift_requirements()
  3. 8.3 acquia_lift.install \acquia_lift_requirements()
  4. 7 acquia_lift.install \acquia_lift_requirements()

Implements hook_requirements().

File

./acquia_lift.install, line 90
Acquia Lift - Installation file.

Code

function acquia_lift_requirements($phase) {
  $requirements = array();
  if ($phase == 'runtime') {

    // Required JavaScript libraries.
    $libraries = array(
      'underscore',
      'backbone',
      'modernizr',
      'chosen',
      'qtip',
      'd3',
      'rickshaw',
    );
    foreach ($libraries as $lib) {
      $requirements['acquia_lift_' . $lib] = array(
        'title' => t('Acquia Lift: @library', array(
          '@library' => $lib,
        )),
        'value' => t('The @library library is not present', array(
          '@library' => $lib,
        )),
        'severity' => REQUIREMENT_ERROR,
      );
      if (function_exists('libraries_detect')) {
        if (($library = libraries_detect($lib)) && !empty($library['installed'])) {
          $requirements['acquia_lift_' . $lib]['value'] = $library['version'];
          $requirements['acquia_lift_' . $lib]['severity'] = REQUIREMENT_OK;
        }
        elseif (!empty($library['error'])) {
          $requirements['acquia_lift_' . $lib]['value'] = $library['error message'];
        }
      }
    }
    $subscription = acquia_agent_settings('acquia_subscription_data');
    $is_active = FALSE;
    if (isset($subscription['heartbeat_data']['acquia_lift']['status']) && $subscription['heartbeat_data']['acquia_lift']['status']) {
      $is_active = TRUE;
    }
    if ($is_active) {
      $requirements['acquia_lift_status'] = array(
        'title' => t('Acquia Lift Subscription status'),
        'severity' => REQUIREMENT_OK,
        'value' => t('Active'),
        'description' => t('You can manually refresh the subscription status in the Acquia Subscription status section on this page.'),
      );
    }
    else {
      $requirements['acquia_lift_status'] = array(
        'title' => t('Acquia Lift Subscription status'),
        'severity' => REQUIREMENT_WARNING,
        'value' => t('Inactive'),
        'description' => t('Your subscription is expired or you are using an invalid identifier and key pair. You can check the subscription identifier and the subscription key at the <a href="@settings">Acquia Lift settings</a> page.', array(
          '@settings' => url('admin/config/content/personalize/acquia_lift'),
        )),
      );
    }
  }

  // Update the cached version whenever we may be updating the module.
  if ($phase == 'runtime' || $phase == 'update') {
    _acquia_lift_set_version();
  }
  return $requirements;
}