You are here

function quickbar_help_page_build in Quickbar 7.2

Implements hook_page_build().

File

modules/quickbar_help/quickbar_help.module, line 194

Code

function quickbar_help_page_build(&$page) {

  // Declare initial variables.
  global $user;

  // Need a serialized array for default value.
  $roles = variable_get('quickbar_role_weights', '');
  $path = drupal_get_path_alias();
  if (drupal_is_front_page()) {
    $path = '/';
  }
  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]) {
        $item = db_query("SELECT text, format FROM {quickbar_help}\n                         WHERE path = :path\n                         AND rid = :rid", array(
          ':path' => $path,
          ':rid' => $rid,
        ))
          ->fetchAssoc();
        if ($item['text']) {
          $page['page_bottom']['quickbar_help'] = array(
            '#type' => 'markup',
            '#markup' => "<div id='quickbar-help-box'><span class='close-button'></span>" . check_markup($item['text'], $item['format']) . '</div>',
          );
        }
      }
    }
  }
}