You are here

function oa_notifications_form_submit in Open Atrium Notifications 7.2

Submit handler for node edit form to save notification values Only executes on node ADD form (new nodes)

_state

Parameters

$form:

1 string reference to 'oa_notifications_form_submit'
oa_notifications_form_node_form_alter in ./oa_notifications.module
Implements hook_form_node_form_alter().

File

./oa_notifications.module, line 822

Code

function oa_notifications_form_submit($form, &$form_state) {
  if (empty($form[OA_NOTIFY_FORM]['skip_notify']['#access'])) {

    // skip notifications if notify checkbox is not accessible
    oa_notification_skip(TRUE);
    $form_state['values'][OA_NOTIFY_FORM]['skip_notify'] = TRUE;
  }
  elseif (isset($form_state['values'][OA_NOTIFY_FORM]['skip_notify'])) {
    oa_notification_skip($form_state['values'][OA_NOTIFY_FORM]['skip_notify']);
  }
  $node = $form_state['node'];
  if (empty($node->nid)) {

    // Only save from form data if on node/add page (nid is undefined)
    // Otherwise data is already saved in DB via ajax.
    $notifications = $form_state['storage']['notification_data'];
    oa_notifications_process_add($notifications, $form_state);
    oa_notifications_process_remove($notifications, $form_state);
    $node->notification_data = $notifications;
  }
}