You are here

function notifications_update_user_subscriptions_submit in Notifications 6.4

Same name and namespace in other branches
  1. 6.2 notifications.pages.inc \notifications_update_user_subscriptions_submit()
  2. 6.3 notifications.pages.inc \notifications_update_user_subscriptions_submit()

Mass update user subscriptions

File

./notifications.pages.inc, line 565
User pages for Notifications

Code

function notifications_update_user_subscriptions_submit($form, $form_state) {
  $account = $form_state['values']['account'];
  switch ($form_state['values']['operation']) {
    case 'enable':

      // Enable also blocked subscriptions just in case there are some
      db_query('UPDATE {notifications} SET status = %d WHERE uid = %d', Notifications_Subscription::STATUS_ACTIVE, $account->uid);
      drupal_set_message(t('All your subscriptions have been enabled.'));
      break;
    case 'disable':
      db_query('UPDATE {notifications} SET status = %d WHERE status = %d AND uid = %d', Notifications_Subscription::STATUS_INACTIVE, Notifications_Subscription::STATUS_ACTIVE, $account->uid);
      notifications_queue()
        ->queue_clean(array(
        'uid' => $account->uid,
      ));
      drupal_set_message(t('All your subscriptions have been disabled.'));
      break;
  }
}