You are here

function admin_init in Admin 6

Same name and namespace in other branches
  1. 6.2 admin.module \admin_init()

Implementation of hook_init().

File

./admin.module, line 6

Code

function admin_init() {

  // Don't do anything if the user has no access.
  if (!user_access('admin menu') && !user_access('admin inline')) {
    return;
  }
  $path = drupal_get_path('module', 'admin');
  drupal_add_js($path . '/toolbar/admin_toolbar.js');
  drupal_add_css($path . '/toolbar/admin_toolbar.css');
  if (arg(0) == 'admin') {

    // Set the active menu
    menu_set_active_menu_name('admin');

    // Conditionally include admin functions (form alters, etc.)
    module_load_include('inc', 'admin', 'admin.admin');
  }
  $admin_theme = variable_get('admin_theme', 'slate');

  // Initialize the slate theme. Bypass the theme system entirely so we can load our own theme into place.
  if ($admin_theme == 'slate' || empty($admin_theme)) {
    if (variable_get('node_admin_theme', 0) && (strpos($_GET['q'], 'node/add') === 0 || strpos($_GET['q'], 'admin/content/add') === 0 || arg(0) == 'node' && arg(2) == 'edit')) {
      _admin_init_theme();
    }
    else {
      if (arg(0) == 'admin') {
        if (strpos($_GET['q'], 'admin/build/block') === 0) {
          if (in_array(arg(3), array(
            'configure',
            'delete',
            'add',
          ), TRUE)) {
            _admin_init_theme();
          }
        }
        else {
          _admin_init_theme();
        }
      }
    }
  }
  else {
    if (function_exists('admin_theme_init') && $GLOBALS['custom_theme'] == 'slate') {
      _admin_init_theme();
    }
  }
}