You are here

function notifications_subscription_delete in Notifications 6.4

Delete subscription and clean up related data, included the static cache

It also removes pending notifications related to that subscription

Parameters

$sid: Subscription object or sid or array of sids of subscription/s to delete

9 calls to notifications_subscription_delete()
notifications_custom_account_update in notifications_custom/notifications_custom.module
Update custom subscriptions for user account
notifications_delete_subscription in ./notifications.module
Obsoleted (kept for backwards compatibility so some modules don't need to be updated)
notifications_delete_subscriptions in ./notifications.module
Delete multiple subscriptions and clean up related data (pending notifications, fields).
notifications_form_unsubscribe_confirm_submit in ./notifications.pages.inc
Process unsubscribe form submission
notifications_multiple_delete_confirm_submit in ./notifications.manage.inc
Submit multiple delete from

... See full list

File

./notifications.module, line 779
Notifications module

Code

function notifications_subscription_delete($sid) {
  $sid = is_object($sid) ? $sid->sid : $sid;
  $cache =& messaging_static('notifications_load_subscription');
  if (is_array($sid)) {
    $where = 'sid IN (' . db_placeholders($sid) . ')';
    if ($cache) {
      $cache = array_diff_key($cache, array_flip($sid));
    }
  }
  else {
    $where = "sid = %d";
    $cache[$sid] = NULL;
  }
  foreach (array(
    'notifications',
    'notifications_fields',
  ) as $table) {
    db_query("DELETE FROM {" . $table . "} WHERE " . $where, $sid);
  }

  // Delete queued notifications for this subscription
  notifications_queue()
    ->queue_delete(array(
    'sid' => $sid,
  ));
}