You are here

function zopim_page_alter in Zopim Live Chat 7

Implementation of hook_page_alter().

@global object $user full user object for current user

Parameters

$page: nested array of renderable elements that make up the page.

File

./zopim.module, line 73

Code

function zopim_page_alter(&$page) {
  global $user;
  $id = variable_get('zopim_account', '');

  // 1. Check if the Zopim account number has a value.
  // 2. Add JS based on visibility value.
  // 3. Check if we should add the JS for the currently active user's role.
  if (!empty($id) && _zopim_visibility_pages() && _zopim_visibility_user_test($user)) {
    $script = <<<EOS
document.write(unescape("%3Cscript src='" + document.location.protocol + "//zopim.com/?{<span class="php-variable">$id</span>}' charset='utf-8' type='text/javascript'%3E%3C/script%3E"));
EOS;
    drupal_add_js($script, array(
      'type' => 'inline',
      'scope' => 'footer',
      'group' => JS_THEME,
    ));
  }
}