You are here

function user_badges_preprocess_author_pane in Author Pane 7.2

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

Implements hook_preprocess_author_pane().

File

modules/user_badges.author-pane.inc, line 10
This file 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;
  }

  // Anonymous users has no user badges.
  if ($variables['account']->uid != 0) {

    // Only display the badges according badge limit
    if (isset($variables['account']->badges)) {
      $variables['user_badges'] = '';

      // Loop through and add only the badges that are within the limit,
      // $variables['account']->badges, stores the badges within the limit
      foreach ($variables['account']->badges as $badge) {
        $variables['user_badges'] .= theme('user_badge', array(
          'badge' => $badge,
        ));
      }
    }
  }
}