function node_authlink_batch_delete in Node authorize link 7
Same name and namespace in other branches
- 8 node_authlink.module \node_authlink_batch_delete()
Callback: Delete authkeys for all nodes in node type.
1 string reference to 'node_authlink_batch_delete'
- node_authlink_form_node_type_form_alter in ./
node_authlink.module - Implements hook_form_node_type_form_alter().
File
- ./
node_authlink.module, line 116 - Provides functionality for the node_authlink module.
Code
function node_authlink_batch_delete(&$form, &$form_state) {
// NIDs of nodes that are in this node type.
$query = db_select('node', 'n');
$query
->leftJoin('node_authlink_nodes', 'a', 'n.nid = a.nid');
$query
->fields('n', array(
'nid',
))
->condition('type', $form_state['values']['type'])
->isNotNull('authkey');
$nids = $query
->execute()
->fetchCol();
// Delete keys.
$count = db_delete('node_authlink_nodes')
->condition('nid', $nids, 'IN')
->execute();
foreach ($nids as $nid) {
if (module_exists('entitycache')) {
cache_clear_all($nid, 'cache_entity_node');
}
}
drupal_set_message(t('%num authkeys has been deleted.', array(
'%num' => $count,
)));
}