| 1 |
<?php |
<?php |
| 2 |
// $Id: node.module,v 1.1008 2008/12/31 12:02:22 dries Exp $ |
// $Id: node.module,v 1.1009 2009/01/04 19:56:51 dries Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 1476 |
} |
} |
| 1477 |
|
|
| 1478 |
/** |
/** |
| 1479 |
* Implementation of hook_user_delete(). |
* Implementation of hook_user_cancel(). |
| 1480 |
*/ |
*/ |
| 1481 |
function node_user_delete(&$edit, &$user) { |
function node_user_cancel(&$edit, &$account, $method) { |
| 1482 |
db_query('UPDATE {node} SET uid = 0 WHERE uid = %d', $user->uid); |
switch ($method) { |
| 1483 |
db_query('UPDATE {node_revision} SET uid = 0 WHERE uid = %d', $user->uid); |
case 'user_cancel_block_unpublish': |
| 1484 |
|
// Unpublish nodes (current revisions). |
| 1485 |
|
module_load_include('inc', 'node', 'node.admin'); |
| 1486 |
|
$nodes = db_select('node', 'n')->fields('n', array('nid'))->condition('uid', $account->uid)->execute()->fetchCol(); |
| 1487 |
|
node_mass_update($nodes, array('status' => 0)); |
| 1488 |
|
break; |
| 1489 |
|
|
| 1490 |
|
case 'user_cancel_reassign': |
| 1491 |
|
// Anonymize nodes (current revisions). |
| 1492 |
|
module_load_include('inc', 'node', 'node.admin'); |
| 1493 |
|
$nodes = db_select('node', 'n')->fields('n', array('nid'))->condition('uid', $account->uid)->execute()->fetchCol(); |
| 1494 |
|
node_mass_update($nodes, array('uid' => 0)); |
| 1495 |
|
// Anonymize old revisions. |
| 1496 |
|
db_update('node_revision')->fields(array('uid' => 0))->condition('uid', $account->uid)->execute(); |
| 1497 |
|
// Clean history. |
| 1498 |
|
db_delete('history')->condition('uid', $account->uid)->execute(); |
| 1499 |
|
break; |
| 1500 |
|
|
| 1501 |
|
case 'user_cancel_delete': |
| 1502 |
|
// Delete nodes (current revisions). |
| 1503 |
|
// @todo Introduce node_mass_delete() or make node_mass_update() more flexible. |
| 1504 |
|
$nodes = db_select('node', 'n')->fields('n', array('nid'))->condition('uid', $account->uid)->execute()->fetchCol(); |
| 1505 |
|
foreach ($nodes as $nid) { |
| 1506 |
|
node_delete($nid); |
| 1507 |
|
} |
| 1508 |
|
// Delete old revisions. |
| 1509 |
|
db_delete('node_revision')->condition('uid', $account->uid)->execute(); |
| 1510 |
|
// Clean history. |
| 1511 |
|
db_delete('history')->condition('uid', $account->uid)->execute(); |
| 1512 |
|
break; |
| 1513 |
|
} |
| 1514 |
} |
} |
| 1515 |
|
|
| 1516 |
/** |
/** |