You are here

function birthdays_form_user in Birthdays 6

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

Adds user options to the profile form which are saved in {users}.data and are loaded during a user_load().

Return value

fields for the form

1 call to birthdays_form_user()
birthdays_user in ./birthdays.module
Implementation of hook_user().

File

./birthdays.module, line 735
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_form_user($edit, $account, $category, $register = FALSE) {
  global $_birthdays_field;
  drupal_add_css(drupal_get_path('module', 'birthdays') . '/birthdays.css', 'module');

  // If the called category is the category of the form field
  if ($category == $_birthdays_field->category || $_birthdays_field->register && $register || module_exists('onepageprofile') && $category == 'account') {

    // If the hiding of the year is a user option: show the option
    if (variable_get('birthdays_hide_year', BIRTHDAYS_HIDE_YEAR_NO) == BIRTHDAYS_HIDE_YEAR_USER) {
      $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,
        '#description' => t("Do not show your age and your year of birth."),
        '#return_value' => BIRTHDAYS_HIDE_YEAR_USER_YES,
        '#weight' => 1,
        '#prefix' => '<div class="birthdays-container">',
        '#suffix' => '</div>',
      );
    }

    // If the birthday user mail is optionally, show the option
    if (variable_get('birthdays_send_user', BIRTHDAYS_USER_MAIL_NO) == BIRTHDAYS_USER_MAIL_USER) {
      $form[$_birthdays_field->category][$_birthdays_field->name]['birthdays_user_send_mail'] = array(
        '#type' => 'checkbox',
        '#title' => t("Do not send birthday mail"),
        '#default_value' => (int) $account->birthdays_user_send_mail,
        '#description' => t("Do not send me an e-mail or e-card when it's my birthday."),
        '#return_value' => BIRTHDAYS_USER_MAIL_USER_NO,
        '#weight' => 2,
        '#prefix' => '<div class="birthdays-container">',
        '#suffix' => '</div>',
      );
    }
  }
  return $form;
}