25 error_reporting(E_ALL);
26 if ((php_sapi_name() !=
'cli')) trigger_error(
"You can only run this script from the command line\n", E_USER_ERROR);
28 if (empty($argv[1])) {
29 echo
"Supply some assetid's to move to the trash.\n";
30 echo
"This only moves the assets to the trash, to really delete them, you still need to use the purge_trash.php script.\n\n";
31 echo
"Usage: " . __FILE__ .
" id1 id2 id3\n";
35 require dirname(__FILE__) .
'/../../core/include/init.inc';
38 $root_user = &$GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'root_user');
40 if (!$GLOBALS[
'SQ_SYSTEM']->setCurrentUser($root_user)) {
41 echo
"Failed login in as root user\n";
45 $trash_folder = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'trash_folder');
47 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
53 # argv[0] is the script name so take one off to see how many assets we're going to delete.
54 $asset_count = count($argv) - 1;
55 echo
"Going to delete $asset_count assets .. \n";
56 for ($i = 1; $i <= $asset_count; $i++) {
58 echo
"Have deleted $i / $asset_count assets so far .. \r";
62 $link = $am->getLink($assetid, NULL,
'', TRUE, NULL,
'minor');
64 $bad_ids[] = $assetid;
67 $am->moveLink($link[
'linkid'], $trash_folder->id, $link[
'link_type'], 0);
70 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
72 echo
"\nTrashing complete.\n";
73 if (!empty($bad_ids)) {
74 echo
"I was unable to delete the following assetids:\n";
75 echo str_repeat(
'-', 5) .
"\n";
76 echo implode($bad_ids,
"\n") .
"\n";
77 echo str_repeat(
'-', 5) .
"\n";
80 echo
"Please run purge_trash now to really delete them.\n";