You are here

function fancy_login_init in Fancy Login 6

Same name and namespace in other branches
  1. 6.2 fancy_login.module \fancy_login_init()

Implementation of hook_init() Loads the javascript on all pages except user/* when the user is not logged in

File

./fancy_login.module, line 7

Code

function fancy_login_init() {
  if (user_is_anonymous()) {
    $path = drupal_get_path('module', 'fancy_login');
    $login_path = drupal_get_path_alias('user/login');
    $fl_settings = array(
      'screenFadeColor' => variable_get('screen_fade_color', 'white'),
      'screenFadeZIndex' => variable_get('screen_fade_z_index', '10'),
      'loginBoxHeight' => variable_get('login_box_height', 'auto'),
      'loginBoxWidth' => variable_get('login_box_width', '175px'),
      'loginBoxBackgroundColor' => variable_get('login_box_background_color', 'white'),
      'loginBoxTextColor' => variable_get('login_box_text_color', 'black'),
      'loginBoxBorderColor' => variable_get('login_box_border_color', 'black'),
      'loginBoxBorderWidth' => variable_get('login_box_border_width', '3px'),
      'loginBoxBorderStyle' => variable_get('login_box_border_style', 'solid'),
      'loginPath' => $login_path,
      'dimFadeSpeed' => (int) variable_get('fancy_login_dim_fade_speed', 500),
      'boxFadeSpeed' => (int) variable_get('fancy_login_box_fade_speed', 1000),
      'hideObjects' => variable_get('fancy_login_hide_objects', 0),
    );
    if (variable_get('fancy_login_no_redirect', 0)) {
      $fl_settings['destination'] = variable_get('clean_url', 0) ? '?' : '&';
      $fl_settings['destination'] .= 'destination=' . $_GET['q'];
    }
    if (variable_get('fancy_login_https', FALSE)) {
      global $base_root;
      $fl_settings['httpsRoot'] = preg_replace('/http:\\/\\//', 'https://', $base_root);
    }
    $fl_settings['requestDestination'] = variable_get('clean_url', 0) ? '?' : '&';
    $fl_settings['requestDestination'] .= 'destination=' . $_GET['q'];
    drupal_add_js(array(
      'fancyLogin' => $fl_settings,
    ), 'setting');
    drupal_add_js($path . '/scripts/fancy_login.js');
    drupal_add_css($path . '/css/fancy_login.css');
  }
}