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