function quickbar_help_preprocess_quickbar in Quickbar 7.2
Implements hook_preprocess_quickbar().
File
- modules/
quickbar_help/ quickbar_help.module, line 152
Code
function quickbar_help_preprocess_quickbar(&$vars) {
// Declare initial variables.
global $user;
$set_class = 'not-active';
$current_path = drupal_get_path_alias();
// Since any path can be the front page, we need to check for it specifically
if (drupal_is_front_page()) {
$current_path = '/';
}
// Need a serialized array for default value.
$roles = 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.
$menus = variable_get('quickbar_role_menus', array());
foreach ($roles as $rid => $weight) {
if (!empty($user->roles[$rid]) && $menus[$rid]) {
$result = db_query("SELECT path FROM {quickbar_help} WHERE path = :path AND rid = :rid", array(
':path' => $current_path,
':rid' => $rid,
))
->fetchField();
if ($result) {
$set_class = 'active';
break;
}
}
}
}
$vars['tree'][0]['help']['help-icon'] = array();
$vars['tree_0']['help'] = theme('links', array(
'links' => $vars['tree'][0]['help'],
'attributes' => array(
'class' => "links clearfix {$set_class}",
'id' => 'quickbar-help',
),
));
}