Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
cron_job_clear_matrix_cache.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/system/cron/cron_job/cron_job.inc';
19 
32 {
33 
34 
41  function __construct($assetid=0)
42  {
43  parent::__construct($assetid);
44 
45  }//end constructor
46 
47 
57  protected function _getName($short_name=FALSE)
58  {
59  // the ownerid must be set at the creation of this cron job
60  return 'Clear Matrix Cache Cron Job #'.$this->attr('ownerid');
61 
62  }//end _getName()
63 
64 
76  protected function _exec(&$msg)
77  {
78  // based on the options in the tool interface and settings in the global prefs
79  $assetid = Array($this->attr('ownerid'));
80  $vars = Array(
81  'assetid' => $assetid,
82  'level' => $this->attr('level'),
83  'type_codes' => $this->attr('type_codes'),
84  'delete_all' => 'no',
85  'repopulate' => $this->attr('repopulate'),
86  );
87 
88  $hh = $GLOBALS['SQ_SYSTEM']->getHipoHerder();
89  $status_errors = $hh->freestyleHipo('hipo_job_clear_cache', $vars);
90  if (empty($status_errors)) {
91  $asset = $GLOBALS['SQ_SYSTEM']->am->getAsset(isset($assetid[0]) ? $assetid[0] : NULL);
92  $GLOBALS['SQ_SYSTEM']->am->forgetAsset($asset);
93 
94  if ($this->attr('type') == 'one_off') {
95  // all OK, and we can be removed because we have done our one off task
96  return SQ_CRON_JOB_COMPLETED | SQ_CRON_JOB_REMOVE;
97  } else if ($this->attr('type') == 'repeating') {
98  // repeating time interval job, do not remove
99  return SQ_CRON_JOB_COMPLETED;
100  }
101  } else {
102  // process failed
103  trigger_localised_error('CRON0057', E_USER_WARNING);
104  }
105 
106  // we can be removed because the error is beyound our control
107  return SQ_CRON_JOB_ERROR | SQ_CRON_JOB_REMOVE;
108 
109  }//end _exec()
110 
111 
119  public static function getActiveJobs()
120  {
121  $cm = $GLOBALS['SQ_SYSTEM']->am->getSystemAsset('cron_manager');
122  return $cm->getJobs('cron_job_clear_matrix_cache');
123 
124  }//end getActiveJobs()
125 
126 
127 }//end class
128 
129 ?>