You are here

function notifications_delete_subscriptions in Notifications 6.4

Same name and namespace in other branches
  1. 5 notifications.module \notifications_delete_subscriptions()
  2. 6 notifications.module \notifications_delete_subscriptions()
  3. 6.2 notifications.module \notifications_delete_subscriptions()
  4. 6.3 notifications.module \notifications_delete_subscriptions()

Delete multiple subscriptions and clean up related data (pending notifications, fields).

Warning: If !$limit, it will delete also subscriptions with more conditions than the fields passed.

Parameters

array $params: Array of multiple conditions in the notifications table to delete subscriptions

array $field_conditions: Array of multiple conditions in the notifications_fields table to delete subscriptions

$limit: Whether to limit the result to subscriptions with exactly that condition fields

Return value

int Number of deleted subscriptions

9 calls to notifications_delete_subscriptions()
NotificationsBasicTests::testNotificationsBasicAPI in tests/notifications_api.test
Play with creating, retrieving, deleting a pair subscriptions
notifications_content_nodeapi in notifications_content/notifications_content.module
Implementation of hook_nodeapi()
notifications_content_node_type in notifications_content/notifications_content.module
Implementation of hook node_type
notifications_custom_delete in notifications_custom/notifications_custom.module
Delete custom subscription and optionally all instances of it
notifications_delete_destination in ./notifications.module
Shorthand function for deleting everything related to a destination

... See full list

File

./notifications.module, line 815
Notifications module

Code

function notifications_delete_subscriptions($params, $field_conditions = array(), $limit = FALSE) {
  notifications_include('query.inc');

  // For exact condition fields we add one more main condition.
  if ($limit) {
    $params += array(
      'conditions' => count($field_conditions),
    );
  }

  // This will get partially loaded objects, only with sid field
  $query['select'][] = 's.sid';
  $subscriptions = notifications_query_subscriptions($params, $field_conditions, $query, FALSE);

  // This is the actual deletion, pass the array of sids
  if ($subscriptions) {
    notifications_subscription_delete(array_keys($subscriptions));
  }
  return $subscriptions ? count($subscriptions) : 0;
}