You are here

function signup_node_admin_summary_form_submit in Signup 7

Same name and namespace in other branches
  1. 5.2 signup.module \signup_node_admin_summary_form_submit()
  2. 6.2 includes/node_admin_summary.inc \signup_node_admin_summary_form_submit()
  3. 6 includes/node_admin_summary.inc \signup_node_admin_summary_form_submit()

@todo Please document this function.

See also

http://drupal.org/node/1354

1 call to signup_node_admin_summary_form_submit()
signup_admin_form_submit in includes/admin.signup_administration.inc
Form submission handler for signup_admin_form().
1 string reference to 'signup_node_admin_summary_form_submit'
signup_node_admin_summary_form in includes/node_admin_summary.inc
@todo Please document this function.

File

includes/node_admin_summary.inc, line 61
Code related to the signup administration tab on each node.

Code

function signup_node_admin_summary_form_submit($form, &$form_state) {
  $nid = $form_state['values']['nid'];
  $node = node_load($nid);
  $limit_status = 0;
  if (isset($form_state['values']['limit']) && $form_state['values']['limit'] != $node->signup_close_signup_limit) {

    // TODO Please review the conversion of this statement to the D7 database API syntax.

    /* db_query("UPDATE {signup} SET close_signup_limit = %d WHERE nid = %d", $form_state['values']['limit'], $nid) */
    db_update('signup')
      ->fields(array(
      'close_signup_limit' => $form_state['values']['limit'],
    ))
      ->condition('nid', $nid)
      ->execute();
    $node->signup_close_signup_limit = $form_state['values']['limit'];
    $limit_status = _signup_check_limit($node, 'limit');
  }

  // Only consider the form's status value if the signup limit didn't
  // touch the status already.
  if (!$limit_status && isset($form_state['values']['status']) && $form_state['values']['status'] != $node->signup_status) {
    if ($form_state['values']['status']) {
      signup_open_signup($nid);
      drupal_set_message(t('Signups opened for !title.', array(
        '!title' => l($node->title, "node/{$node->nid}"),
      )));
    }
    else {
      signup_close_signup($nid);
      drupal_set_message(t('Signups closed for !title.', array(
        '!title' => l($node->title, "node/{$node->nid}"),
      )));
    }
  }
}