You are here

function subscriptions_user_settings_form_submit in Subscriptions 5.2

Same name and namespace in other branches
  1. 6 subscriptions.admin.inc \subscriptions_user_settings_form_submit()

User settings subform submit handler.

File

./subscriptions.admin.inc, line 521

Code

function subscriptions_user_settings_form_submit($form_id, $form_values) {
  if (isset($form_values['reset']) && $form_values['op'] == $form_values['reset']) {
    if (($uid = arg(1)) > 0) {
      db_query("UPDATE {subscriptions_user} SET digest = -1, send_interval = -1, send_updates = -1, send_comments = -1, send_interval_visible = -1, send_updates_visible = -1, send_comments_visible = -1, autosub_on_post = -1, autosub_on_update = -1, autosub_on_comment = -1, send_self = -1 WHERE uid = %d", $uid);
      drupal_set_message(t('The site defaults were restored.'));
    }
  }
  elseif (isset($form_values['save']) && $form_values['op'] == $form_values['save']) {
    if (arg(0) == 'user') {
      $uid = arg(1);
    }
    else {
      $uid = -DRUPAL_AUTHENTICATED_RID;
    }
    $send_interval_visible = 1 - $form_values['send_interval_visible'];
    $send_updates_visible = 1 - $form_values['send_updates_visible'];
    $send_comments_visible = 1 - $form_values['send_comments_visible'];
    db_query("\n      UPDATE {subscriptions_user}\n      SET digest = %d, send_interval = %d, send_updates = %d, send_comments = %d,\n          send_interval_visible = %d, send_updates_visible = %d, send_comments_visible = %d,\n          autosub_on_post = %d, autosub_on_update = %d, autosub_on_comment = %d,\n          send_self = %d\n      WHERE uid = %d", $form_values['digest'], $uid > 0 && $send_interval_visible == -2 ? -1 : $form_values['send_interval'], $uid > 0 && $send_updates_visible == -2 ? -1 : $form_values['send_updates'], $uid > 0 && $send_comments_visible == -2 ? -1 : $form_values['send_comments'], $send_interval_visible, $send_updates_visible, $send_comments_visible, $form_values['autosub_post'], $form_values['autosub_update'], $form_values['autosub_comment'], $form_values['sendself'], $uid);
    drupal_set_message(t('The changes have been saved.'));
  }
}