Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
status_change.php
1 <?php
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);
20 }
21 
22 $available_status_codes = Array(1,2,4,8,16,32,64,128,256);
23 
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";
27  exit();
28 }
29 
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";
32  exit();
33 }
34 
35 define('SQ_SYSTEM_ROOT', $SYSTEM_ROOT);
36 require_once $SYSTEM_ROOT.'/core/include/init.inc';
37 
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";
41  exit();
42 }
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";
46  exit();
47 }
48 $CHILDREN = (isset($_SERVER['argv'][4]) && $_SERVER['argv'][4] == 'y') ? FALSE : TRUE;
49 
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);
53 
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);
58 echo 'FINISHED';
59 if (!empty($errors)) {
60  echo "... But with errors!\n";
61  foreach ($errors as $error) {
62  echo "\t".
63  $line = array_get_index($error, 'message', '');
64  if (!empty($line)) {
65  echo "\t".$line."\n";
66  }//end if
67  }//end foreach
68 } else {
69  echo "\n";
70 }//end if
71 
72 $GLOBALS['SQ_SYSTEM']->restoreRunLevel();
73 ?>