You are here

function user_delete_node_cancel in User Delete 6.2

Mimics hook_user_cancel() for node module.

1 call to user_delete_node_cancel()
user_delete_user_cancel in ./user_delete.module
Implements hook_user_cancel();

File

./user_delete.module, line 564
Provide account cancellation methods and API to provide the same functionalty as Drupal 7 for cancelling accounts.

Code

function user_delete_node_cancel($edit, $account, $method) {
  switch ($method) {
    case 'user_cancel_block_unpublish':

      // Unpublish nodes (current revisions).
      $result = db_query("SELECT nid FROM {node} WHERE uid = %d", $account->uid);
      $nodes = array();
      while ($nid = db_result($result)) {
        $nodes[] = $nid;
      }
      user_delete_node_mass_update($nodes, array(
        'status' => 0,
      ));
      break;
    case 'user_cancel_reassign':

      // Anonymize nodes (current revisions).
      $result = db_query("SELECT nid FROM {node} WHERE uid = %d", $account->uid);
      $nodes = array();
      while ($nid = db_result($result)) {
        $nodes[] = $nid;
      }
      user_delete_node_mass_update($nodes, array(
        'uid' => 0,
      ));

      // Anonymize old revisions.
      db_query("UPDATE {node_revisions} SET uid = 0 WHERE uid = %d", $account->uid);

      // Anonymize history
      db_query("UPDATE {history} SET uid = 0 WHERE uid = %d", $account->uid);
      break;
    case 'user_cancel_delete':

      // Anonymize nodes (current revisions).
      $result = db_query("SELECT nid FROM {node} WHERE uid = %d", $account->uid);
      $nodes = array();
      while ($nid = db_result($result)) {
        $nodes[] = $nid;
      }
      user_delete_node_mass_delete($nodes);
      break;
  }
}