Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
cron_job_regenerate_report.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/system/cron/cron_job/cron_job.inc';
19 
34 {
35 
36 
43  function __construct($assetid=0)
44  {
45  parent::__construct($assetid);
46 
47  }//end constructor
48 
49 
59  protected function _getName($short_name=FALSE)
60  {
61  $id = $this->attr('asset');
62  if ($GLOBALS['SQ_SYSTEM']->am->assetExists($id)) {
63  $asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($id);
64  $name = $asset->name;
65  }
66  return "Regenerate \"$name\" [#$asset->id]";
67 
68  }//end _getName()
69 
70 
84  protected function _exec(&$msg)
85  {
86  $this->setAttrValue('running', TRUE);
87  $this->saveAttributes();
88  $hh = $GLOBALS['SQ_SYSTEM']->getHipoHerder();
89 
90  $assetid = $this->attr('asset');
91  $asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($assetid);
92  $user = $this->getRunningUser();
93 
94  // pass who/when info to the hipo var
95  $vars = Array(
96  'userid' => $user->id,
97  'generated_date' => date('F j, Y, g:i a'),
98  'assetid' => $assetid,
99  'asset' => $asset,
100  'type_code' => $asset->type(),
101  'complete' => FALSE,
102  );
103 
104  // doing freestyle hipo because we cant queue hipo without browser refresh
105  $status_errors = $hh->freestyleHipo('hipo_job_generate_report', $vars);
106  return SQ_CRON_JOB_COMPLETED;
107 
108  }//end _exec()
109 
110 
117  public function run()
118  {
119  $res = parent::run();
120  if ($res & SQ_CRON_JOB_COMPLETED) {
121  if ($GLOBALS['SQ_SYSTEM']->am->acquireLock($this->id, 'all')) {
122  $this->setAttrValue('running', FALSE);
123  $this->saveAttributes();
124  $GLOBALS['SQ_SYSTEM']->am->releaseLock($this->id, 'all');
125  }
126  }
127 
128  return $res;
129 
130  }//end run()
131 
132 
133 }//end class
134 
135 ?>