Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
reset_bulkmail_job.php
1 #!/usr/bin/php
2 <?php
29 // Check for environment/arguments
30 if (ini_get('memory_limit') != '-1') ini_set('memory_limit', -1);
31 error_reporting(E_ALL);
32 if ((php_sapi_name() != 'cli')) {
33  trigger_error("You can only run this script from the command line\n", E_USER_ERROR);
34 }
35 
36 $system_root = (isset($_SERVER['argv'][1])) ? $_SERVER['argv'][1] : '';
37 if (empty($system_root) || !is_dir($system_root)) {
38  trigger_error("You need to supply the path to the System Root as the first argument\n", E_USER_ERROR);
39 }
40 
41 $asset_id = (isset($_SERVER['argv'][2])) ? $_SERVER['argv'][2] : '';
42 if (empty($asset_id)) {
43  trigger_error("You need to supply the asset id of the bulkmail job as the second argument\n", E_USER_ERROR);
44 }
45 
46 require_once $system_root.'/core/include/init.inc';
47 
48 $root_user = $GLOBALS['SQ_SYSTEM']->am->getSystemAsset('root_user');
49 $GLOBALS['SQ_SYSTEM']->setCurrentUser($root_user);
50 
51 // Check for valid asset
52 $asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($asset_id);
53 if (is_null($asset) || (!($asset instanceof Bulkmail_Job))) {
54  trigger_error("You need to provide a valid bulkmail job to process\n", E_USER_ERROR);
55 }//end if
56 
57 // Process
58 $hh = $GLOBALS['SQ_SYSTEM']->getHipoHerder();
59 $vars = Array(
60  'assetid' => $asset_id,
61  'new_status' => SQ_STATUS_UNDER_CONSTRUCTION,
62  'dependants_only' => TRUE
63  );
64 if ($asset->status == SQ_STATUS_LIVE) {
65  $errors = $hh->freestyleHipo('hipo_job_edit_status', $vars);
66 }
67 
68 // Check for errors, and show if found
69 if (!empty($errors)) {
70  echo print_r($errors, TRUE);
71 }
72 
73 ?>