You are here

function login_shadowbox_init in Shadowbox 7.4

Implementation of hook_init()

File

login_shadowbox/login_shadowbox.module, line 6

Code

function login_shadowbox_init() {
  $enable = variable_get('login_shadowbox_enabled', FALSE) && variable_get('shadowbox_enabled', TRUE);
  $path = drupal_get_path('module', 'login_shadowbox');
  if ($enable && arg(0) != 'admin') {
    drupal_add_js($path . '/scripts/login_shadowbox_check.js');
  }
  if (user_is_anonymous() && $enable) {
    $login_path = drupal_get_path_alias('user/login');
    $register_path = drupal_get_path_alias('user/register');
    $password_path = drupal_get_path_alias('user/password');
    $login_content = url(drupal_get_path_alias('user/login/shadowbox'));
    $register_content = url(drupal_get_path_alias('user/register/shadowbox'));
    $password_content = url(drupal_get_path_alias('user/password/shadowbox'));

    // Shadowbox login settings
    $shadowbox_login_settings = array(
      'login_path' => $login_path,
      'register_path' => $register_path,
      'password_path' => $password_path,
      'login_content' => $login_content,
      'register_content' => $register_content,
      'password_content' => $password_content,
      'login_width' => variable_get('login_shadowbox_width', 500),
      'register_width' => variable_get('login_shadowbox_register_width', 500),
      'password_width' => variable_get('login_shadowbox_password_width', 500),
      'login_height' => variable_get('login_shadowbox_height', 380),
      'register_height' => variable_get('login_shadowbox_register_height', 440),
      'password_height' => variable_get('login_shadowbox_password_height', 240),
      'modal' => variable_get('login_shadowbox_modal', TRUE),
    );

    // We have to be sure shadowbox is loaded in case it is not
    drupal_add_library('shadowbox', 'shadowbox');

    // Adding the neccessary javascript and css files needed by shadowbox login
    drupal_add_js(array(
      'shadowboxLogin' => $shadowbox_login_settings,
    ), 'setting');
    drupal_add_js($path . '/scripts/login_shadowbox.js');
    $css_path = variable_get('login_shadowbox_css', $path . '/css/login_shadowbox.css');
    drupal_add_css($css_path, array(
      'group' => 'CSS_DEFAULT',
    ));
  }
}