15 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
16 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
51 public static function execute($settings, &$state)
54 if (!isset($settings[
'index_page']))
return FALSE;
55 if ($settings[
'index_page'] ==
'')
return FALSE;
57 $selected_asset_id = array_get_index($settings,
'index_page', 0);
59 if (empty($state[
'asset'])) {
61 if (empty($state[
'assetid'])) {
64 $state[
'asset'] = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($state[
'assetid']);
67 if (is_null($state[
'asset']))
return FALSE;
69 $link_value =
'index';
70 $field_name = $state[
'asset']->getPrefix().
'_'.str_replace(
' ',
'_', strtolower($link_value));
72 $link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($state[
'asset']->
id, SQ_LINK_NOTICE,
'', FALSE, $link_value);
75 if (!empty($link) && $link[
'minorid'] == $selected_asset_id) {
79 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
80 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
85 $success = (bool) $asset->deleteLink($link[
'linkid']);
88 if ($success && !empty($selected_asset_id)) {
89 $selected_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($selected_asset_id);
90 if (!is_null($selected_asset)) {
91 $success = (bool) $state[
'asset']->
createLink($selected_asset, SQ_LINK_NOTICE, $link_value);
97 $GLOBALS[
'SQ_SYSTEM']->doTransaction($success ?
'COMMIT' :
'ROLLBACK');
98 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
101 'assetid' => $state[
'asset']->
id,
102 'index_page' => $settings[
'index_page'],
118 public static function getInterface($settings, $prefix, $write_access=FALSE)
121 if (empty($settings[
'index_page'])) {
123 $selected_assetid =
'0';
125 $selected_assetid = $settings[
'index_page'];
129 if ($selected_assetid && !$GLOBALS[
'SQ_SYSTEM']->am->assetExists($selected_assetid)) {
130 $selected_assetid = 0;
133 if (!$write_access) {
134 $form_element_extras =
'disabled="disabled"';
136 $form_element_extras =
'';
141 asset_finder($prefix.
'[index_page]', $selected_assetid, Array(
'page_standard' =>
'P'));
142 echo translate(
'trigger_set_index_page_select');
145 if ($selected_assetid) {
146 $selected_assetname = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($selected_assetid), Array(), TRUE,
'name');
147 text_box($prefix.
'[index_page]', $selected_assetname[$selected_assetid].
' (#'.$selected_assetid.
')',
'',
'', FALSE, $form_element_extras);
149 text_box($prefix.
'[index_page]',
'',
'',
'', FALSE, $form_element_extras);
153 $basic_part_1 = ob_get_contents();
156 return translate(
'trigger_set_index_page_basic', $basic_part_1);
176 if (empty($request_data[
'index_page'][
'assetid'])) {
177 return 'Index page is not specified';
181 $settings[
'index_page'] = $request_data[
'index_page'][
'assetid'];
197 public static function getLocks($settings, &$state)
201 $state[
'assetid'] => Array(
'all'),