function quickbar_init in Quickbar 6
Same name and namespace in other branches
- 7.2 quickbar.module \quickbar_init()
- 7 quickbar.module \quickbar_init()
Implementation of hook_init().
File
- ./
quickbar.module, line 6
Code
function quickbar_init() {
// Make sure quickbar should be used.
if (quickbar_is_enabled()) {
// Declare initial variables.
global $user;
// Need a serialized array for default value.
$roles = unserialize(variable_get('quickbar_role_weights', ''));
if (is_array($roles)) {
// Sort roles
asort($roles);
// Loop through the roles looking for a role that matches the current users
// role and also has a menu associated with it.
foreach ($roles as $rid => $weight) {
if (!empty($user->roles[$rid]) && ($menu = variable_get('quickbar_' . $rid, 0))) {
$path = drupal_get_path('module', 'quickbar');
drupal_add_js($path . '/js/quickbar.js');
drupal_add_css($path . '/theme/quickbar.css');
$iconsets = module_invoke_all('quickbar_iconset_info');
$iconset = variable_get('quickbar_iconset_' . $rid, 'quickbar');
// Add the iconset
drupal_add_css($iconsets[$iconset]['css']);
break;
}
}
}
}
}