You are here

function _ed_classified_delete in Classified Ads 5

Same name and namespace in other branches
  1. 5.2 ed_classified_delete.inc \_ed_classified_delete()
  2. 6.2 ed_classified_delete.inc \_ed_classified_delete()
  3. 7.2 ed_classified_delete.inc \_ed_classified_delete()

Reimplement the node_delete code, because the code in node_delete performs an access check for node deletion rights This can be made more efficient, if needed.

1 call to _ed_classified_delete()
_ed_classified_purge_ad in ./ed_classified_delete.inc
"purge" an expired ad (This will delete a classified ad that has been 'expired' and is older than the threshold)

File

./ed_classified_delete.inc, line 91
Node deletion facilities. Michael Curry, Exodus Development, Inc. exodusdev@gmail.com for more information, please visit http://exodusdev.com Copyright (c) 2006, 2007 Exodus Development, Inc. All Rights Reserved. Licensed under the terms of the GNU…

Code

function _ed_classified_delete($nid) {
  $node = node_load($nid);

  // sanity check: only delete if:
  // Node found, nid != 0, node is unpublished (stats == 0) and it is truly a classified ad.
  if ($node && $node->nid != 0 && 0 == $node->status && _ed_classified_node_is_classified($node)) {
    db_query('DELETE FROM {node} WHERE nid = %d', $node->nid);
    db_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid);

    // Call the node-specific callback (if any):
    node_invoke($node, 'delete');
    node_invoke_nodeapi($node, 'delete');

    // Remove this node from the search index if needed.
    if (function_exists('search_wipe')) {
      search_wipe($node->nid, 'node');
    }
  }
}