17 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
18 require_once SQ_CORE_PACKAGE_PATH.
'/system/triggers/trigger_action/trigger_action.inc';
54 public static function execute($settings, &$state)
58 if (empty($settings[
'path']) && empty($settings[
'remove_all']))
return FALSE;
60 if (empty($state[
'asset'])) {
62 if (empty($state[
'assetid'])) {
65 $state[
'asset'] = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($state[
'assetid']);
69 if (is_null($state[
'asset']))
return FALSE;
72 $web_path = self::replaceKeywordsInWebPath($settings[
'path'], $state[
'asset']);
73 $valid_paths = make_valid_web_paths(Array($web_path));
74 $web_path = array_shift($valid_paths);
79 $web_paths_old = $web_paths_new = $state[
'asset']->getWebPaths();
81 foreach ($web_paths_new as $key => $path){
82 if($path === $web_path){
83 unset ($web_paths_new[$key]);
88 if (!empty($settings[
'remove_all'])) {
89 $web_paths_new = Array();
94 if ($web_paths_new !== $web_paths_old) {
101 if(!empty($settings[
'update_children'])){
102 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
103 $vars = Array(
'assetids' => Array($state[
'asset']->
id));
104 $lookup_errors = $hh->freestyleHipo(
'hipo_job_update_lookups', $vars);
105 if (!empty($lookup_errors)) {
111 'assetid' => $state[
'asset']->
id
132 replace_global_keywords($web_path);
135 $keywords = retrieve_keywords_replacements($web_path);
136 $replacements = Array();
137 foreach ($keywords as $keyword) {
140 replace_keywords($web_path, $replacements);
157 public static function getInterface($settings, $prefix, $write_access=FALSE)
161 $web_path = array_get_index($settings,
'path',
'');
162 echo translate(
'remove_web_path').
' ';
164 text_box($prefix.
'[path]', $web_path, 40);
166 echo
'<b>'.$web_path.
'</b>';
169 echo
'<div class="sq-backend-section-note">'.translate(
'trigger_remove_web_path_note').
'</div>';
170 check_box($prefix.
'[remove_all]',
'1', array_get_index($settings,
'remove_all',
'0'),
'', ($write_access ?
'' :
'disabled="disabled"'));
171 echo
'<label for='.$prefix.
'[remove_all]'.
'>'.translate(
'trigger_remove_web_path_remove_all').
'.</label>';
173 check_box($prefix.
'[update_children]',
'1', array_get_index($settings,
'update_children',
'0'),
'', ($write_access ?
'' :
'disabled="disabled"'));
174 echo
'<label for='.$prefix.
'[update_children]'.
'>'.translate(
'trigger_remove_web_path_update_children').
'.</label>';
175 return ob_get_clean();
193 $web_path = array_get_index($request_data,
'path',
'');
194 $web_path = trim($web_path);
195 $remove_all = array_get_index($request_data,
'remove_all',
'');
196 $update_children = array_get_index($request_data,
'update_children',
'');
198 if ($web_path ==
'' && $remove_all ==
'') {
199 return translate(
'web_path_not_specified');
201 $settings[
'path'] = $web_path;
202 $settings[
'remove_all'] = $remove_all;
203 $settings[
'update_children'] = $update_children;
219 public static function getLocks($settings, &$state)
221 return Array($state[
'assetid'] => Array(
'lookups'));