17 require_once SQ_CORE_PACKAGE_PATH.
'/system/triggers/trigger_action/trigger_action.inc';
18 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
19 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
20 require_once SQ_SYSTEM_ROOT.
'/core/attributes/parameter_map/parameter_map.inc';
57 public static function execute($settings, &$state)
61 $value_map = array_get_index($settings,
'value_map', serialize(Array()));
63 $param_map_value = $param_map_attr->getParameterValue(
'design_id');
66 if (empty($settings[
'assetid']) && empty($param_map_value)) {
72 $assetid = is_null($param_map_value) ? $settings[
'assetid'] : $param_map_value;
74 if (!$GLOBALS[
'SQ_SYSTEM']->am->assetExists($assetid)) {
78 $design_type = array_get_index($settings,
'design_type',
'design::system');
79 $design_name = array_get_index($settings,
'design_name',
'::user_define');
82 if (empty($state[
'asset'])) {
84 if (empty($state[
'assetid'])) {
87 $state[
'asset'] = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($state[
'assetid']);
92 $am = $GLOBALS[
'SQ_SYSTEM']->am;
95 if ($design_type ==
'design::system') {
96 $design_final_name =
'design::system::frontend';
97 }
else if ($design_type ==
'design::user') {
98 $design_final_name =
'design::user::'.$design_name;
100 $design_final_name = $design_type;
104 $design_links = $am->getLinks($state[
'assetid'], SQ_LINK_NOTICE,
'design', FALSE,
'major', $design_final_name);
105 $link_already_created = FALSE;
107 if (!empty($design_links)) {
110 foreach ($design_links as $link) {
113 if ($link[
'minorid'] == $assetid && !$link_already_created) {
115 $link_already_created = TRUE;
117 if (!$am->deleteAssetLink($link[
'linkid'])) {
128 if (!$link_already_created) {
129 $design = $am->getAsset($assetid);
130 $link_create_status = $am->createAssetLink($state[
'asset'], $design, SQ_LINK_NOTICE, $design_final_name);
132 if (!$link_create_status) {
139 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
140 $vars = Array(
'assetids' => Array($state[
'asset']->
id));
141 $hh->freestyleHipo(
'hipo_job_update_lookups', $vars);
143 'assetid' => $state[
'asset']->
id,
144 'designid' => $assetid,
145 'code' =>
'system::frontend',
161 public static function getInterface($settings, $prefix, $write_access=FALSE)
164 if (empty($settings[
'assetid'])) {
166 $selected_assetid =
'0';
168 $selected_assetid = $settings[
'assetid'];
171 $design_type = array_get_index($settings,
'design_type',
'');
172 $design_name = array_get_index($settings,
'design_name',
'');
175 if ($selected_assetid && !$GLOBALS[
'SQ_SYSTEM']->am->assetExists($selected_assetid)) {
176 $selected_assetid = 0;
179 if (!$write_access) {
180 $form_element_extras =
'disabled="disabled"';
182 $form_element_extras =
'';
185 $design_types = Array (
186 'design::system::frontend' =>
'Frontend Design',
187 'design::system::login' =>
'Login Design',
188 'design::user' =>
'User Defined Design',
193 $disabled = ($design_type ==
'design::user') ?
'' :
'disabled="disabled"';
194 $extra =
'onChange="if(this.value == \'design::user\') { document.getElementById(\''.$prefix.
'[design_name]'.
'\').disabled=\
'\';}
195 else { document.getElementById(\
''.$prefix.
'[design_name]'.
'\').disabled=\
'disabled\'; }"';
198 asset_finder($prefix.
'[assetid]', $selected_assetid, Array(
'design' =>
'D'));
200 echo translate(
'trigger_set_design_select_design_type');
201 combo_box($prefix.
'[design_type]', $design_types, FALSE, $design_type, 0, $extra);
203 echo translate(
'trigger_set_design_set_user_design_name');
204 text_box($prefix.
'[design_name]', $design_name,
'',
'', FALSE, $disabled);
206 if ($selected_assetid) {
207 $selected_assetname = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($selected_assetid), Array(), TRUE,
'name');
208 text_box($prefix.
'[assetid]', $selected_assetname[$selected_assetid].
' (#'.$selected_assetid.
')',
'',
'', FALSE, $form_element_extras);
210 text_box($prefix.
'[assetid]',
'',
'',
'', FALSE, $form_element_extras);
216 $new_prefix = str_replace(array(
'[',
']'),
'_', $prefix);
217 hidden_field($prefix.
'[new_prefix]', $new_prefix);
218 $param_map_value = array_get_index($settings,
'value_map', serialize(Array()));
220 $param_map_attr->setParameter(
'design_id',
'Design ID');
221 echo $param_map_attr->paint($new_prefix.
'_parameter_map');
224 $basic_part_1 = ob_get_contents();
227 return translate(
'trigger_set_design_basic', $basic_part_1);
247 $settings[
'assetid'] = $request_data[
'assetid'][
'assetid'];
248 $settings[
'design_type'] = $request_data[
'design_type'];
249 if (!empty($request_data[
'design_name'])) {
250 $settings[
'design_name'] = $request_data[
'design_name'];
254 $new_prefix = str_replace(array(
'[',
']'),
'_', array_get_index($request_data,
'new_prefix',
''));
257 $param_map_attr->process($new_prefix.
'_parameter_map');
258 $settings[
'value_map'] = $param_map_attr->value;
261 $value_map = unserialize($settings[
'value_map']);
263 if (empty($settings[
'assetid']) && empty($value_map)) {
264 return 'Design Asset id is not specified';
280 public static function getLocks($settings, &$state)
283 $state[
'assetid'] => Array(