function notifications_delete_subscriptions in Notifications 6.2
Same name and namespace in other branches
- 5 notifications.module \notifications_delete_subscriptions()
- 6.4 notifications.module \notifications_delete_subscriptions()
- 6 notifications.module \notifications_delete_subscriptions()
- 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 $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
7 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_form_unsubscribe_confirm_submit in ./
notifications.pages.inc - Process form submission
- notifications_page_unsubscribe in ./
notifications.pages.inc - Menu callback for unsubscribe page
File
- ./
notifications.module, line 824 - Notifications module
Code
function notifications_delete_subscriptions($params, $conditions = array(), $limit = FALSE) {
// Build query conditions using the query builder
$query = notifications_subscriptions_query_build($params, $conditions, $limit);
$query['select'][] = 'n.sid';
list($sql, $args) = notifications_query_sql($query);
// Query notifications that meet these conditions and build an array
$result = db_query($sql, $args);
$delete = array();
while ($n = db_fetch_object($result)) {
$delete[] = $n->sid;
}
// This is the actual deletion. We've fetched the values from the db so this needs no escaping.
if ($delete) {
$placeholders = db_placeholders($delete);
foreach (array(
'notifications_fields',
'notifications_queue',
'notifications',
) as $table) {
db_query('DELETE FROM {' . $table . '} WHERE sid IN (' . $placeholders . ')', $delete);
}
}
}