You are here

function user_badges_preprocess_author_pane in Author Pane 6.2

Same name and namespace in other branches
  1. 5 modules/user_badges.author-pane.inc \user_badges_preprocess_author_pane()
  2. 6 modules/user_badges.author-pane.inc \user_badges_preprocess_author_pane()
  3. 7.2 modules/user_badges.author-pane.inc \user_badges_preprocess_author_pane()

Implementation of hook_preprocess_author_pane().

File

modules/user_badges.author-pane.inc, line 11
Provides a preprocess function on behalf of the user badges module.

Code

function user_badges_preprocess_author_pane(&$variables) {

  // Check if this preprocess needs to be run given who's calling it.
  if (!author_pane_run_preprocess('user_badges', $variables['caller'])) {
    return;
  }
  $account_id = $variables['account']->uid;
  if ($account_id != 0) {

    // Implement static caching for cases where this Author Pane appears more
    // than once on a given page.
    static $cached_user_badges;
    if (isset($cached_user_badges[$account_id])) {
      $variables['user_badges'] = $cached_user_badges[$account_id];
    }
    else {
      if (isset($variables['account']->badges)) {
        $shtml = '';
        foreach ($variables['account']->badges as $obadge) {
          $shtml .= theme('user_badge', $obadge, $variables['account']);
        }
      }
      $variables['user_badges'] = $shtml;
      $cached_user_badges[$account_id] = $variables['user_badges'];
    }
  }
}