function olark_add_js in Olark Chat 6
Builds and inserts the correct Olark Javascript into the page.
1 call to olark_add_js()
- olark_init in ./
olark.module - Implements hook_init().
File
- ./
olark.module, line 187 - Integrates Olark Chat in a Drupal site.
Code
function olark_add_js() {
static $added;
if (!isset($added)) {
global $user;
$path = drupal_get_path('module', 'olark');
drupal_add_js($path . '/olark.js', 'module', 'header', TRUE);
$setting = array(
'olark' => array(),
);
// If the user is logged in, let's get some pertinent information and
// pass it along as well.
if ($user->uid) {
$setting['olark']['uid'] = $user->uid;
$setting['olark']['name'] = $user->name;
//$setting['olark']['mail'] = t('email !mail', array('!mail' => $user->mail));
$setting['olark']['mail'] = $user->mail;
$setting['olark']['roles'] = t('roles !roles', array(
'!roles' => implode(', ', $user->roles),
));
$setting['olark']['userpage'] = url('user/' . $user->uid, array(
'absolute' => TRUE,
));
$setting['olark']['loggedinas'] = t('logged in as !link', array(
'!link' => l($user->name, 'user/' . $user->uid, array(
'absolute' => TRUE,
)),
));
}
$setting['olark']['disable_ios'] = variable_get('olark_ios', '');
$setting['olark']['enabled'] = variable_get('olark_enable', 1);
drupal_add_js($setting, 'setting');
$added = TRUE;
}
}