You are here

function template_preprocess_birthdays_block in Birthdays 6

Preprocess variables to format the birthdays block.

$variables contains the following data:

  • $uids
  • $amount
  • $block_type

File

./birthdays.module, line 388
The Birthdays module allows users to add their birthday to their profile. It lists birthdays on a seperate page and in different blocks. Users can receive an e-mail on their birthday automatically, and the administrator can receive daily reminders of…

Code

function template_preprocess_birthdays_block(&$variables) {
  global $_birthdays_field;

  //dsm($variables);
  $variables['no_birthdays'] = TRUE;
  $variables['show_starsigns'] = (bool) variable_get('birthdays_show_starsign', BIRTHDAYS_STARSIGN_OFF);
  if (!empty($variables['uids'])) {
    $row = 0;
    $variables['no_birthdays'] = FALSE;
    foreach ($variables['uids'] as $uid) {
      $account = user_load(array(
        'uid' => $uid,
      ));
      $birthdays[$row]['account'] = $account;
      $birthdays[$row]['username'] = theme('username', $account);

      // +1 when the birthday isn't today, because it shows the age the person will be on his/her birthday
      $account->age = $account->age + !($account->{$_birthdays_field->name}['day'] == format_date(time(), 'custom', 'j') && $account->{$_birthdays_field->name}['month'] == format_date(time(), 'custom', 'n'));
      $birthdays[$row]['age'] = _birthdays_show_age($account);
      $birthdays[$row]['show_age'] = isset($birthdays[$row]['age']);
      $birthdays[$row]['starsign'] = birthdays_get_starsign_image($account->birthdays_starsign, variable_get('birthdays_show_starsign', BIRTHDAYS_STARSIGN_OFF));
      $account->{$_birthdays_field->name}['year'] = NULL;

      // Don't show the year in blocks
      $birthdays[$row]['date'] = _birthdays_show_date($account->{$_birthdays_field->name}, $account);
      $row++;
    }
    $variables['birthdays'] = $birthdays;
  }
  $variables['more'] = '<div class="more-link">' . l(t('more'), 'birthdays', array(
    'attributes' => array(
      'title' => t('Show all birthdays.'),
    ),
  )) . '</div>';
}