16 if (ini_get(
'memory_limit') !=
'-1') ini_set(
'memory_limit',
'-1');
17 error_reporting(E_ALL);
18 if ((php_sapi_name() !=
'cli')) {
19 trigger_error(
"You can only run this script from the command line\n", E_USER_ERROR);
22 $available_status_codes = Array(1,2,4,8,16,32,64,128,256);
24 $SYSTEM_ROOT = (isset($_SERVER[
'argv'][1])) ? $_SERVER[
'argv'][1] :
'';
25 if (empty($SYSTEM_ROOT)) {
26 echo
"ERROR: You need to supply the path to the System Root as the first argument\n";
30 if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT.
'/core/include/init.inc')) {
31 echo
"ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n";
35 define(
'SQ_SYSTEM_ROOT', $SYSTEM_ROOT);
36 require_once $SYSTEM_ROOT.
'/core/include/init.inc';
38 $ROOT_NODE = (isset($_SERVER[
'argv'][2])) ? $_SERVER[
'argv'][2] :
'';
39 if (empty($ROOT_NODE)) {
40 echo
"You need to supply a root node as the second argument\n";
43 $STATUS = (isset($_SERVER[
'argv'][3])) ? $_SERVER[
'argv'][3] :
'';
44 if (empty($STATUS) || !in_array($STATUS, $available_status_codes)) {
45 echo
"You need to supply a status code as the third argument\n";
48 $CHILDREN = (isset($_SERVER[
'argv'][4]) && $_SERVER[
'argv'][4] ==
'y') ? FALSE : TRUE;
50 $root_user =& $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'root_user');
51 $GLOBALS[
'SQ_SYSTEM']->setCurrentUser($root_user);
52 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
54 echo
'START STATUS CHANGE'.
"\n";
55 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
56 $vars = Array(
'assetid' => $ROOT_NODE,
'new_status' => $STATUS,
'dependants_only' => $CHILDREN);
57 $errors = $hh->freestyleHipo(
'hipo_job_edit_status', $vars);
59 if (!empty($errors)) {
60 echo
"... But with errors!\n";
61 foreach ($errors as $error) {
63 $line = array_get_index($error,
'message',
'');
72 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();