You are here

function subscriptions_ui_node_form_submit in Subscriptions 2.0.x

Same name and namespace in other branches
  1. 5.2 subscriptions_ui.module \subscriptions_ui_node_form_submit()
  2. 6 subscriptions_ui.module \subscriptions_ui_node_form_submit()
  3. 7 subscriptions_ui.module \subscriptions_ui_node_form_submit()

Node subscriptions node subform submit handler.

_state

Parameters

array $form:

File

subscriptions_ui/subscriptions_ui.module, line 390
Provides a user interface for Subscriptions.

Code

function subscriptions_ui_node_form_submit(array $form, array &$form_state) {
  $recipient_uid = $form_state['values']['account']->uid;
  $default_send_intervals = $form_state['values']['send_intervals'];
  foreach ($form_state['values']['subscriptions'] as $index => $value) {
    $params = $form_state['values']['params'][$index];
    $args = [
      $params['module'],
      $params['field'],
      $params['value'],
      $params['author_uid'],
      $recipient_uid,
    ];
    if ($value) {
      $args[] = $default_send_intervals[$index];
      $args[] = !empty($form_state['values']['updates'][$index]);
      $args[] = !empty($form_state['values']['comments'][$index]);
      call_user_func_array('subscriptions_write_subscription', $args);
    }
    else {
      subscriptions_delete($args['4'], $args['0'], $args['1'], $args['2'], $args['3']);
    }
  }
  $form_state['redirect'] = str_replace('/subscribe', '', current_path());
}