17 require_once SQ_SYSTEM_ROOT.
'/core/hipo/hipo_job.inc';
62 public static function paintConfig(&$o, $class, $write_access)
65 $o->openField(translate(
'trigger_execution_threshold'));
68 text_box($class.
'[SQ_HIPO_TRIGGER_BATCH_EVENTS_THRESHOLD]', SQ_HIPO_TRIGGER_BATCH_EVENTS_THRESHOLD, 0);
70 echo SQ_HIPO_TRIGGER_BATCH_EVENTS_THRESHOLD;
87 'SQ_HIPO_TRIGGER_BATCH_EVENTS_THRESHOLD' => Array(
'editable' => 1,
'default' => 0),
105 return parent::getCodeName().
'-u'.$GLOBALS[
'SQ_SYSTEM']->currentUserId().
'-a'.$this->_running_vars[
'codename_target'].
'-'.$this->_running_vars[
'codename_propagate'];
118 return translate(
'hipo_name_trigger_batch_events');
134 'name' => translate(
'hipo_processing_assets'),
135 'function_call' => Array(
136 'process_function' =>
'processAssets',
138 'running_mode' =>
'server',
140 'allow_cancel' =>
true,
161 if (SQ_HIPO_TRIGGER_BATCH_EVENTS_THRESHOLD == 0) {
165 if (empty($this->_running_vars[
'assets']))
return 0;
167 return (($this->_running_vars[
'total_steps'] / SQ_HIPO_TRIGGER_BATCH_EVENTS_THRESHOLD) * 100);
180 while (!empty($this->_running_vars[
'assets'])) {
181 if (!$this->
processAssets($this->_steps[0], get_class($this))) {
199 if (empty($this->_running_vars[
'assets']) || empty($this->_running_vars[
'events'])) {
200 trigger_localised_error(
'HIPO0002', E_USER_WARNING);
205 $this->_running_vars[
'total_steps'] = count($this->_running_vars[
'assets']) * count($this->_running_vars[
'events']);
206 $this->_running_vars[
'step_value'] = (int) (100 / $this->_running_vars[
'total_steps']);
208 if (empty($this->_running_vars[
'event_parameters'])) $this->_running_vars[
'event_parameters'] = NULL;
210 return parent::prepare();
226 if (empty($this->_running_vars[
'current_events'])) {
227 if (empty($this->_running_vars[
'assets'])) {
229 $step_data[
'complete'] =
true;
230 $step_data[
'percent_done'] = 100;
233 $this->_running_vars[
'current_events'] = $this->_running_vars[
'events'];
234 $this->_running_vars[
'current_assetid'] = array_pop($this->_running_vars[
'assets']);
237 $current_event = array_pop($this->_running_vars[
'current_events']);
238 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($this->_running_vars[
'current_assetid']);
239 $GLOBALS[
'SQ_SYSTEM']->broadcastTriggerEvent($current_event, $asset, $this->_running_vars[
'event_parameters']);
241 $step_data[
'message'] = translate(
'hipo_broadcast_event', $current_event, $this->_running_vars[
'current_assetid']);
242 $step_data[
'percent_done'] += $this->_running_vars[
'step_value'];
243 $step_data[
'complete'] =
false;