You are here

function birthdays_sync_form in Birthdays 6

Same name in this branch
  1. 6 birthdays.admin.inc \birthdays_sync_form()
  2. 6 birthdays.sync.inc \birthdays_sync_form()
Same name and namespace in other branches
  1. 5 birthdays.module \birthdays_sync_form()

Creates the synchronization form.

1 string reference to 'birthdays_sync_form'
birthdays_menu in ./birthdays.module
Implementation of hook_menu().

File

./birthdays.sync.inc, line 19
Because the Birthdays module uses 2 tables for the birthdays, they have to be kept in sync with each other. Normally that will be no problem, but in some cases there is the need to manually synchronize the two tables. These cases are for example:

Code

function birthdays_sync_form() {
  global $_birthdays_field;

  // We can't synchronize if the field hasn't been set yet.
  if (!isset($_birthdays_field)) {
    drupal_set_message(t('No date field has been selected as birthdays field. Please visit the <a href="@birthdays-settings">birthdays settings page</a>.', array(
      '@birthdays-settings' => url('admin/settings/birthdays'),
    )), 'warning');
    return array();
  }
  $form['profile_fieldset'] = array(
    '#type' => 'fieldset',
  );
  $form['profile_fieldset']['description'] = array(
    '#type' => 'item',
    '#title' => t('Profile to Birthdays'),
    '#value' => t("Fill the Birthdays module's table with data from the Profile module's table. This is needed when you install the Birthdays module, but already collected birthdays with the Profile module (e.g. for age verification, to show in the profile or after uninstalling the Birthdays module)."),
  );
  $form['profile_fieldset']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Copy Profile data to Birthdays module'),
    '#submit' => array(
      'birthdays_sync_profiles_to_birthdays',
    ),
  );
  $form['birthdays_fieldset'] = array(
    '#type' => 'fieldset',
  );
  $form['birthdays_fieldset']['description'] = array(
    '#type' => 'item',
    '#title' => t('Birthdays to Profile'),
    '#value' => t("Fill the Profile module's table with data from the Birthdays module's table. You can use this if you completely reinstalled the Profile module while leaving the Birthdays module alone, or to copy the old data collected by a version of the Birthdays module which didn't use the Profile module (pre-5.x)."),
  );
  $form['birthdays_fieldset']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Copy Birthdays data to Profile module'),
    '#submit' => array(
      'birthdays_sync_birthdays_to_profiles',
    ),
  );
  return $form;
}