You are here

function node_user_cancel in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/node/node.module \node_user_cancel()

Implements hook_user_cancel().

File

core/modules/node/node.module, line 686
The core module that allows content to be submitted to the site.

Code

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

      // Unpublish nodes (current revisions).
      $nids = \Drupal::entityQuery('node')
        ->condition('uid', $account
        ->id())
        ->execute();
      module_load_include('inc', 'node', 'node.admin');
      node_mass_update($nids, array(
        'status' => 0,
      ), NULL, TRUE);
      break;
    case 'user_cancel_reassign':

      // Anonymize all of the nodes for this old account.
      module_load_include('inc', 'node', 'node.admin');
      $vids = \Drupal::entityManager()
        ->getStorage('node')
        ->userRevisionIds($account);
      node_mass_update($vids, array(
        'uid' => 0,
        'revision_uid' => 0,
      ), NULL, TRUE, TRUE);
      break;
  }
}