SHARE
TWEET

Untitled

a guest Jun 19th, 2017 43 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env php
  2. <?php
  3. include_once('autoload.php');
  4. ini_set("memory_limit", "-1");
  5. ini_set("date.timezone", "Europe/London");
  6.  
  7. $cli =& eZCLI::instance();
  8. $script =& eZScript::instance();
  9.  
  10. $script->startup();
  11.  
  12. $script->initialize();
  13.  
  14. $userCreatorId = eZINI::instance()->variable("UserSettings", "UserCreatorID");
  15. $user = eZUser::fetch($userCreatorId);
  16. eZUser::setCurrentlyLoggedInUser($user, $userCreatorId);
  17.  
  18. $users = eZContentObjectTreeNode::fetch(5);
  19.  
  20. print "Retrieved users node.".PHP_EOL;
  21. $batchedUsersToDelete = array_chunk(array_map(function($node) {
  22.     return $node->attribute('main_node_id');
  23. }, $users->subTree(array(
  24.     'ClassFilterType' => 'include',
  25.     'ClassFilterArray' => array(52)
  26. ))), 50);
  27.  
  28. print "Batched users.".PHP_EOL;
  29. $totalBatches = count($batchedUsersToDelete);
  30. foreach ($batchedUsersToDelete as $index => $batch) {
  31.     $index++; // Make human-readable.
  32.     print "Processing {$index}/{$totalBatches}".PHP_EOL;
  33.     eZContentObjectTreeNode::removeSubtrees($batch, false);
  34. }
  35.  
  36. $script->shutdown();
  37. ?>
RAW Paste Data
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top