17 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
18 require_once SQ_CORE_PACKAGE_PATH.
'/system/triggers/trigger_action/trigger_action.inc';
55 public static function execute($settings, &$state)
57 if (empty($state[
'asset'])) {
59 if (empty($state[
'assetid'])) {
62 $state[
'asset'] = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($state[
'assetid']);
66 if (is_null($state[
'asset']))
return FALSE;
69 $assetid = $state[
'asset']->id;
70 $todo_assetids = $settings[
'selected_assets'];
71 if ($settings[
'use_current_asset']) {
72 $todo_assetids[] = $assetid;
75 $type_code = empty($settings[
'asset_types']) ?
'' : $settings[
'asset_types'];
77 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
80 'assetid' => $todo_assetids,
81 'level' => $settings[
'level'],
82 'type_codes' => $type_code,
85 $status_errors = $hh->freestyleHipo(
'hipo_job_clear_cache', $vars);
89 'assetid' => $assetid,
105 public static function getInterface($settings, $prefix, $write_access=FALSE)
108 $new_prefix = str_replace(
'[',
'_', $prefix);
109 $new_prefix = str_replace(
']',
'', $new_prefix);
112 $level_options = Array(
113 'single' => translate(
'selected_asset'),
114 'dependants' => translate(
'selected_asset_and_dependants'),
115 'children' => translate(
'selected_asset_and_children'),
119 $asset_types = $GLOBALS[
'SQ_SYSTEM']->am->getTypeList();
120 foreach ($asset_types as $type_code) {
121 $info = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($type_code);
122 if ($info[
'allowed_access'] !=
'system' && $info[
'instantiable']) {
123 $asset_types_options[$type_code] = $info[
'name'];
126 asort($asset_types_options);
127 $asset_types_options = array_reverse($asset_types_options, TRUE);
128 $asset_types_options[
''] =
'-- '.translate(
'all_asset_types').
' --';
129 $asset_types_options = array_reverse($asset_types_options, TRUE);
132 $settings[
'use_current_asset'] = isset($settings[
'use_current_asset']) ? $settings[
'use_current_asset'] : FALSE;
133 $settings[
'selected_assets'] = isset($settings[
'selected_assets']) ? $settings[
'selected_assets'] : Array();
134 $settings[
'level'] = isset($settings[
'level']) ? $settings[
'level'] :
'single';
135 $settings[
'asset_types'] = isset($settings[
'asset_types']) ? $settings[
'asset_types'] : Array();
136 if (empty($settings[
'asset_types'])) {
137 $settings[
'asset_types'] = Array(0 =>
'');
145 <td valign=
"top"><b><?php echo translate(
'trigger_clear_cache_current_asset'); ?></b></td>
146 <td valign=
"top" style=
"padding-bottom: 10px;"><?php
149 echo check_box($prefix.
'[use_current_asset]', 1, $settings[
'use_current_asset']);
150 echo translate(
'trigger_clear_cache_include_current_asset');
152 echo
' ';
153 echo ($settings[
'use_current_asset']) ? translate(
'yes') : translate(
'no');
162 <td valign=
"top"><b><?php echo translate(
'trigger_clear_cache_choose_asset'); ?></b></td>
163 <td valign=
"top" style=
"padding-bottom: 10px;"><?php
164 echo multiple_asset_finder($new_prefix.
'_select_assets', $settings[
'selected_assets']);
167 <td valign=
"top"><b><?php echo translate(
'trigger_clear_cache_choose_asset_selected'); ?></b></td>
168 <td valign=
"top" style=
"padding-bottom: 10px;"><?php
169 if (empty($settings[
'selected_assets'])) {
170 echo
' '.translate(
'no_asset_selected');
173 foreach ($settings[
'selected_assets'] as $selected_asset) {
175 echo get_asset_tag_line($selected_asset);
185 <td valign=
"top"><b><?php echo translate(
'level'); ?></b></td>
186 <td valign=
"top" style=
"padding-bottom: 10px;"><?php
189 echo combo_box($new_prefix.
'_level', $level_options, FALSE, $settings[
'level'], 0);
191 echo
' '.$level_options[$settings[
'level']];
200 <td valign=
"top"><b><?php echo translate(
'asset_types'); ?></b></td>
201 <td valign=
"top" style=
"padding-bottom: 10px;"><?php echo combo_box($new_prefix.
'_asset_types', $asset_types_options, TRUE, $settings[
'asset_types'], 8); ?></td>
205 <td valign=
"top"><b><?php echo translate(
'trigger_clear_cache_asset_types_selected'); ?></b></td>
206 <td valign=
"top" style=
"padding-bottom: 10px;"><?php
207 if (!empty($settings[
'asset_types'][0])) {
209 foreach ($settings[
'asset_types'] as $type_code) {
211 echo get_asset_type_icon($type_code);
212 echo $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($type_code,
'name');
217 echo
' '.translate(
'all_asset_types');
226 hidden_field($prefix.
'[prefix]', $new_prefix);
228 return ob_get_clean();
246 $new_prefix = $request_data[
'prefix'];
247 $settings[
'prefix'] = $new_prefix;
250 $settings[
'use_current_asset'] = array_get_index($request_data,
'use_current_asset', FALSE);
251 $settings[
'selected_assets'] = Array();
252 if (isset($_POST[$new_prefix.
'_select_assets']) && !empty($_POST[$new_prefix.
'_asset_types'])) {
253 foreach ($_POST[$new_prefix.
'_select_assets'] as $key => $array) {
255 if ($array[
'assetid'] != 0) {
256 $settings[
'selected_assets'][] = $array[
'assetid'];
262 $settings[
'level'] =
'single';
263 if (isset($_POST[$new_prefix.
'_level'])) {
264 $settings[
'level'] = $_POST[$new_prefix.
'_level'];
268 if (isset($_POST[$new_prefix.
'_asset_types']) && !empty($_POST[$new_prefix.
'_asset_types'][0])) {
269 $settings[
'asset_types'] = $_POST[$new_prefix.
'_asset_types'];
271 $settings[
'asset_types'] = Array();
288 public static function getLocks($settings, &$state)
290 return Array($state[
'assetid'] => Array(
'lookups'));