You are here

function birthdays_profile_alter in Birthdays 6

Same name and namespace in other branches
  1. 5 birthdays.module \birthdays_profile_alter()

Alter the way the birthday is shown. This is fired after every module has filled the profile.

File

./birthdays.module, line 696
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 birthdays_profile_alter(&$account) {
  global $_birthdays_field;

  // If the _birthdays_field hasn't been set yet, do not continue
  if (!isset($_birthdays_field)) {
    return;
  }

  // If the field existed, and is amongst the profile fields to be shown, it is save to continue
  if (isset($_birthdays_field) && array_key_exists($_birthdays_field->category, $account->content) && array_key_exists($_birthdays_field->name, $account->content[$_birthdays_field->category])) {

    // Do you have access to see birthdays?
    if (user_access('access birthdays')) {

      // Show starsign (will be hidden when needed)
      $starsign = '<span class="birthdays-starsign">' . birthdays_get_starsign_image($account->birthdays_starsign, variable_get('birthdays_show_starsign', BIRTHDAYS_STARSIGN_OFF)) . '</span>&nbsp;&nbsp;&nbsp;';

      // Show age (when allowed by user and administrator)
      if (variable_get('birthdays_hide_year', BIRTHDAYS_HIDE_YEAR_NO) == BIRTHDAYS_HIDE_YEAR_NO || variable_get('birthdays_hide_year', BIRTHDAYS_HIDE_YEAR_NO) == BIRTHDAYS_HIDE_YEAR_USER && $account->birthdays_user_hide_year != BIRTHDAYS_HIDE_YEAR_USER_YES) {
        $age = '&nbsp;&nbsp;&nbsp;<span class="birthdays-age">(' . $account->age . ')</span>';
      }

      // Alter the profile field setup by profile.module. Show medium format in stead of short format
      $account->content[$_birthdays_field->category][$_birthdays_field->name]['#value'] = $starsign . _birthdays_show_date($account->{$_birthdays_field->name}, $account, 'medium') . $age;
    }
    else {

      // No access? Remove from profile to show
      unset($account->content[$_birthdays_field->category][$_birthdays_field->name]);
    }
  }
}