--- birthdays/birthdays.module 2010-03-16 11:27:07.414006484 +0100 +++ birthdays-patch2/birthdays.module 2010-03-16 11:51:34.235005933 +0100 @@ -712,7 +712,7 @@ function birthdays_profile_alter(&$accou '   '; // 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)) { + 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_field->name}['birthdays_user_hide_year'] != BIRTHDAYS_HIDE_YEAR_USER_YES)) { $age = '   ('. $account->age .')'; } @@ -744,7 +744,7 @@ function birthdays_form_user($edit, $acc $form[$_birthdays_field->category][$_birthdays_field->name]['birthdays_user_hide_year'] = array( '#type' => 'checkbox', '#title' => t("Hide age and birth year"), - '#default_value' => (int) $account->birthdays_user_hide_year, + '#default_value' => (int) $account->{$_birthdays_field->name}['birthdays_user_hide_year'], '#description' => t("Do not show your age and your year of birth."), '#return_value' => BIRTHDAYS_HIDE_YEAR_USER_YES, '#weight' => 1, @@ -964,6 +964,8 @@ function _birthdays_get_age($date) { * age */ function _birthdays_calculate_age($day, $month, $year) { + global $_birthdays_field; + if ($year && $month && $day) { // age = (current year - birthyear) - 1 (when the birthday hasn't arrived yet). return format_date(time(), 'custom', 'Y') - $year - (format_date(time(), 'custom', 'nd') < $month . str_pad($day, 2, 0, STR_PAD_LEFT)); @@ -982,8 +984,10 @@ function _birthdays_calculate_age($day, * @return int */ function _birthdays_show_age($account) { + global $_birthdays_field; + $age = NULL; - if (isset($account->age) && (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))) { + if (isset($account->age) && (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_field->name}['birthdays_user_hide_year'] != BIRTHDAYS_HIDE_YEAR_USER_YES))) { $age = $account->age; } return $age; @@ -1010,7 +1014,9 @@ function _birthdays_show_date($date, $ac * Format date, optionally hide year */ function _birthdays_show_date_2($day, $month, $year, $account, $type = 'small') { + global $_birthdays_field; $output = ''; + // Determine format type switch ($type) { case 'medium': @@ -1025,7 +1031,7 @@ function _birthdays_show_date_2($day, $m //$format = substr($format, 0, -6); // If admin or user decide to hide the age&year: hide year - if ($year && ( variable_get('birthdays_hide_year', BIRTHDAYS_HIDE_YEAR_NO) == BIRTHDAYS_HIDE_YEAR_YES || (variable_get('birthdays_hide_year', BIRTHDAYS_HIDE_YEAR_NO) == BIRTHDAYS_HIDE_YEAR_USER && $account->birthdays_user_hide_year == BIRTHDAYS_HIDE_YEAR_YES))) { + if ($year && ( variable_get('birthdays_hide_year', BIRTHDAYS_HIDE_YEAR_NO) == BIRTHDAYS_HIDE_YEAR_YES || (variable_get('birthdays_hide_year', BIRTHDAYS_HIDE_YEAR_NO) == BIRTHDAYS_HIDE_YEAR_USER && $account->{$_birthdays_field->name}['birthdays_user_hide_year'] == BIRTHDAYS_HIDE_YEAR_YES))) { $year = NULL; }