You are here

function notifications_account_update_subscriptions_submit in Notifications 7

Mass update user subscriptions

File

notifications_account/notifications_account.pages.inc, line 260
User pages for Notifications

Code

function notifications_account_update_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_subscription} 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_subscription} 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;
  }
}