You are here

function acquia_agent_init in Acquia Connector 6.2

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

Implementation of hook_init().

File

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

Code

function acquia_agent_init() {

  // Auto-connect with Acquia Cloud credentials if there's not currently a
  // connection or credentials set.
  if (!acquia_agent_has_credentials() && !variable_get('acquia_subscription_data', FALSE) && variable_get('ah_network_key', FALSE) && variable_get('ah_network_identifier', FALSE)) {
    variable_set('acquia_identifier', variable_get('ah_network_identifier', FALSE));
    variable_set('acquia_key', variable_get('ah_network_key', FALSE));
    $activated = acquia_agent_check_subscription();
    if ($activated) {
      $text = t('Your site has been automatically connected to Acquia. <a href="!url">Change subscription</a>', array(
        '!url' => url('admin/settings/acquia-agent/setup'),
      ));
      drupal_set_message($text, 'status', FALSE);
    }
  }
  $hide_signup_messages = variable_get('acquia_agent_hide_signup_messages', 0);
  if (!$hide_signup_messages && arg(2) != 'acquia-agent' && empty($_POST) && user_access('administer site configuration') && !acquia_agent_has_credentials() && arg(0) !== 'filefield' && arg(1) != 'progress') {
    $text = 'Sign up for Acquia Cloud Free, a free Drupal sandbox to experiment with new features, test your code quality, and apply continuous integration best practices. Check out the <a href="!acquia-free">epic set of dev features and tools</a> that come with your free subscription.<br/>If you have an Acquia subscription, <a href="!settings">connect now</a>. Otherwise, you can turn this message off by disabling the Acquia Connector modules.';
    if (isset($_SERVER['AH_SITE_GROUP'])) {
      $text = '<a href="!settings">Connect your site to Acquia now</a>. <a href="!more">Learn more</a>.';
    }
    $message = t($text, array(
      '!acquia-free' => url('https://www.acquia.com/acquia-cloud-free'),
      '!settings' => url('admin/settings/acquia-agent/setup'),
    ));
    drupal_set_message($message, 'warning', FALSE);
  }

  // Disable caching and maintenance mode on the Connector status page.
  if (arg(0) == 'system' && arg(1) == 'acquia-connector-status') {

    // Preserve current values.
    $GLOBALS['conf']['acquia_cache'] = $GLOBALS['conf']['cache'];
    $GLOBALS['conf']['cache'] = FALSE;
    $GLOBALS['conf']['acquia_site_offline'] = $GLOBALS['conf']['site_offline'];
    $GLOBALS['conf']['site_offline'] = FALSE;
  }
}