You are here

function _subscriptions_user_settings_form_submit in Subscriptions 2.0.x

Same name and namespace in other branches
  1. 7 subscriptions.admin.inc \_subscriptions_user_settings_form_submit()

User settings subform submit handler.

_state

Parameters

array $form:

1 string reference to '_subscriptions_user_settings_form_submit'
subscriptions_user_settings_form in ./subscriptions.admin.old.php
Returns the form definition for the settings part of the overview page.

File

./subscriptions.admin.old.php, line 802
Subscriptions module (load-on-demand admin functions).

Code

function _subscriptions_user_settings_form_submit(array $form, array &$form_state) {
  $uid = subscriptions_arg(1, 'uid');
  if (isset($form_state['values']['reset']) && $form_state['values']['op'] == $form_state['values']['reset']) {
    if ($uid > 0) {
      db_update('subscriptions_user')
        ->fields(array(
        'digest' => -1,
        'secure_links' => -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,
      ))
        ->condition('uid', $uid)
        ->execute();
      drupal_set_message(t('The site defaults were restored.'));
    }
  }
  elseif ($form_state['values']['op'] == $form_state['values']['save_settings']) {
    if (subscriptions_arg(0) != 'user') {
      $uid = -DRUPAL_AUTHENTICATED_RID;
      if (variable_get('subscriptions_hide_overview_page', 0) != $form_state['values']['hide_overview_page']) {
        variable_set('subscriptions_hide_overview_page', $form_state['values']['hide_overview_page']);
        menu_rebuild();
      }
    }
    $send_interval_visible = 1 - $form_state['values']['send_interval_visible'];
    $send_updates_visible = 1 - $form_state['values']['send_updates_visible'];
    $send_comments_visible = 1 - $form_state['values']['send_comments_visible'];
    db_update('subscriptions_user')
      ->fields(array(
      'digest' => $form_state['values']['digest'],
      'secure_links' => isset($form_state['values']['secure_links']) ? $form_state['values']['secure_links'] : 0,
      'send_interval' => $uid > 0 && $send_interval_visible == -2 ? -1 : $form_state['values']['send_interval'],
      'send_updates' => $uid > 0 && $send_updates_visible == -2 ? -1 : $form_state['values']['send_updates'],
      'send_comments' => $uid > 0 && $send_comments_visible == -2 ? -1 : $form_state['values']['send_comments'],
      'send_interval_visible' => $send_interval_visible,
      'send_updates_visible' => $send_updates_visible,
      'send_comments_visible' => $send_comments_visible,
      'autosub_on_post' => $form_state['values']['autosub_post'],
      'autosub_on_update' => $form_state['values']['autosub_update'],
      'autosub_on_comment' => $form_state['values']['autosub_comment'],
      'send_self' => $form_state['values']['sendself'],
    ))
      ->condition('uid', $uid)
      ->execute();
    drupal_set_message(t('The changes have been saved.'));
  }
}