You are here

function date_repeat_merge in Date 6

Same name and namespace in other branches
  1. 8 date_repeat/date_repeat_form.inc \date_repeat_merge()
  2. 5.2 date_repeat/date_repeat_form.inc \date_repeat_merge()
  3. 6.2 date_repeat/date_repeat_form.inc \date_repeat_merge()
  4. 7.3 date_repeat/date_repeat_form.inc \date_repeat_merge()
  5. 7 date_repeat/date_repeat_form.inc \date_repeat_merge()
  6. 7.2 date_repeat/date_repeat_form.inc \date_repeat_merge()

Regroup values back into a consistant array, no matter what state it is in.

3 calls to date_repeat_merge()
date_repeat_rrule_validate in date_repeat/date_repeat_form.inc
Build a RRULE out of the form values.
_date_repeat_rrule_process in date_repeat/date_repeat_form.inc
Generate the repeat setting form.
_date_repeat_widget_validate in date/date_repeat.inc
Validation for date repeat form element.

File

date_repeat/date_repeat_form.inc, line 197
Code to add a date repeat selection form to a date field and create an iCal RRULE from the chosen selections.

Code

function date_repeat_merge($form_values) {
  if (empty($form_values) || !is_array($form_values)) {
    return $form_values;
  }
  if (array_key_exists('advanced', $form_values) || array_key_exists('exceptions', $form_values)) {
    $form_values = array_merge($form_values, (array) $form_values['advanced'], (array) $form_values['exceptions']);
    unset($form_values['advanced']);
    unset($form_values['exceptions']);
    unset($form_values['help']);
  }
  unset($form_values['BYDAY']['']);
  unset($form_values['BYMONTH']['']);
  unset($form_values['BYMONTHDAY']['']);
  if (is_array($form_values['UNTIL']['datetime']) && array_key_exists('date', $form_values['UNTIL']['datetime'])) {
    $form_values['UNTIL']['datetime'] = $form_values['UNTIL']['datetime']['date'];
  }
  if (isset($form_values['EXDATE']) && is_array($form_values['EXDATE'])) {
    foreach ($form_values['EXDATE'] as $delta => $value) {
      if (is_array($value['datetime']) && array_key_exists('date', $value['datetime'])) {
        $form_values['EXDATE'][$delta]['datetime'] = $value['datetime']['date'];
      }
    }
  }
  return $form_values;
}