17 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
18 require_once SQ_CORE_PACKAGE_PATH.
'/system/triggers/trigger_action/trigger_action.inc';
58 public static function execute($settings, &$state)
61 if (empty($settings[
'status']))
return FALSE;
63 if (empty($state[
'asset'])) {
65 if (empty($state[
'assetid'])) {
68 $state[
'asset'] = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($state[
'assetid']);
73 if (!isset($settings[
'dependant_parents'])) {
74 $settings[
'dependant_parents'] = FALSE;
79 $target_assets = Array();
80 if ($settings[
'dependant_parents']) {
82 $target_assets = $GLOBALS[
'SQ_SYSTEM']->am->getDependantParents($state[
'asset']->
id,
'', TRUE, FALSE);
83 if (!empty($target_assets)) {
85 $target_assets = array_flip($target_assets);
86 foreach ($target_assets as $assetid => $null) {
87 $target_assets[$assetid] = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
92 if (empty($target_assets) || !$settings[
'dependant_parents']) {
93 $target_assets[$state[
'asset']->id] =& $state[
'asset'];
97 foreach ($target_assets as $target_assetid => $target_asset) {
100 if (is_null($target_asset))
return FALSE;
102 $old_status = $target_asset->status;
103 if ($old_status != $settings[
'status']) {
104 $available_statuses = $target_asset->getAvailableStatii();
106 if (!isset($available_statuses[$settings[
'status']])) {
111 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
113 'assetid' => $target_assetid,
114 'new_status' => $settings[
'status'],
116 $status_errors = $hh->freestyleHipo(
'hipo_job_edit_status', $vars);
118 if (!empty($status_errors))
return FALSE;
125 'assetid' => $state[
'asset']->
id,
126 'affected_assetids' => $target_assets,
127 'old_status' => $old_status,
128 'new_status' => $state[
'asset']->status,
144 public static function getInterface($settings, $prefix, $write_access=FALSE)
146 if (empty($settings[
'status'])) {
148 $selected_status = SQ_STATUS_UNDER_CONSTRUCTION;
150 $selected_status = $settings[
'status'];
155 if (!$write_access) {
156 $form_element_extras =
'disabled="disabled"';
158 $form_element_extras =
'';
162 combo_box($prefix.
'[status]', $status_list, FALSE, $selected_status, NULL, $form_element_extras);
163 $basic_part_1 = ob_get_contents();
167 $dependant_parents = array_get_index($settings,
'dependant_parents', FALSE);
169 check_box($prefix.
'[dependant_parents]', 1, $dependant_parents);
171 echo
'<img src="'.sq_web_path(
'lib').
'/web/images/'.($dependant_parents ?
'tick' :
'cross').
'.gif" alt="'.($dependant_parents ? translate(
'yes') : translate(
'no')).
'" /> ';
173 $basic_part_2 = ob_get_contents();
177 return translate(
'trigger_set_status', $basic_part_1, $basic_part_2);
196 $settings[
'dependant_parents'] = array_get_index($request_data,
'dependant_parents', FALSE);
199 $status = array_get_index($request_data,
'status', NULL);
200 if (is_null($status)) {
201 return 'Status has not been specified';
207 if (!isset($status_list[$status])) {
208 return 'Specified status is invalid';
210 $settings[
'status'] = $status;
226 foreach (get_constant_values(
'SQ_STATUS_') as $status_value) {
227 $status[$status_value] = get_status_description($status_value);