18 require_once SQ_CORE_PACKAGE_PATH.
'/page/page_edit_fns.inc';
48 $delivery_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_NOTICE,
'', FALSE,
'major',
'delivery_method');
49 $delivery_asset_ids = Array();
50 foreach ($delivery_links as $one_link) {
51 $delivery_asset_ids[$one_link[
'minorid']] = $one_link[
'minor_type_code'];
54 if ($asset->writeAccess(
'links')) {
55 multiple_asset_finder($prefix.
'_delivery_methods', array_keys($delivery_asset_ids), Array(
'ecommerce_delivery_method'=>
'D'));
57 $infos = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(array_keys($delivery_asset_ids));
59 <table
class=
"sq-backend-table">
61 <th
class=
"sq-backend-table-header"><?php echo translate(
'asset') ?></th>
62 <th
class=
"sq-backend-table-header"><?php echo translate(
'type') ?></th>
65 foreach ($infos as $assetid => $info) {
68 <td
class=
"sq-backend-table-cell"><?php echo get_asset_tag_line($assetid) ?></td>
69 <td
class=
"sq-backend-table-cell"><?php echo ucwords(str_replace(
'_',
' ', $info[
'type_code'])) ?></td>
94 if (!isset($_POST[$prefix.
'_delivery_methods'])) {
97 $new_delivery_methods = $_POST[$prefix.
'_delivery_methods'];
98 foreach ($new_delivery_methods as $new_delivery_method) {
99 $new_delivery_method_ids[] = $new_delivery_method[
'assetid'];
103 $delivery_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_NOTICE,
'', FALSE,
'major',
'delivery_method');
105 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
106 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
110 foreach ($delivery_links as $delivery_link) {
111 if (!in_array($delivery_link[
'minorid'], $new_delivery_method_ids)) {
112 if (!$GLOBALS[
'SQ_SYSTEM']->am->deleteAssetLink($delivery_link[
'linkid'])) {
119 foreach ($new_delivery_methods as $index => $node) {
121 foreach ($delivery_links as $delivery_link) {
122 if ($delivery_link[
'minorid'] == $node[
'assetid']) {
127 if ($node[
'assetid'] != 0) {
128 $new_node = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($node[
'assetid']);
129 if (!$asset->createLink($new_node, SQ_LINK_NOTICE,
'delivery_method')) {
131 trigger_localised_error(
'CMS0016', E_USER_WARNING, $new_node->name, $new_node->id);
138 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
140 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
143 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
162 <table
class=
"sq-backend-table">
164 <th><?php echo translate(
'edit_format') ?></th>
165 <th><?php echo translate(
'note') ?></th>
169 $link_to_folder = $GLOBALS[
'SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_TYPE_2,
'folder');
170 $links_to_bodycopies = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($link_to_folder[
'minorid'], SQ_LINK_TYPE_2,
'bodycopy');
172 $contexts = $asset->_getAvailableContexts();
174 if (!empty($links_to_bodycopies)) {
175 foreach ($links_to_bodycopies as $link) {
176 $info = Array($link[
'minorid'] =>
'contents');
177 $href = $GLOBALS[
'SQ_SYSTEM']->am->getAssetBackendHref($info);
180 <td
class=
"sq-backend-table-cell">
181 <?php echo get_asset_tag_line($link[
'minorid'],
'contents') ?>
183 <td
class=
"sq-backend-table-cell">
185 switch ($link[
'value']) {
187 echo translate(
'ecom_checkout_checkout_context_desc');
190 echo translate(
'ecom_checkout_confirmation_context_desc');
193 echo translate(
'ecom_checkout_failure_context_desc');
196 echo translate(
'ecom_checkout_receipt_context_desc');
224 $current_value = $asset->attr(
'flat_charge_assetid');
226 if ($asset->writeAccess(
'links')) {
227 $flat_charges = !empty($current_value) ? $current_value : Array();
228 multiple_asset_finder($prefix.
'_flat_charge', $flat_charges, Array(
'product' =>
'D'));
230 for ($i=0; $i<count($current_value); $i++) {
231 echo get_asset_tag_line($current_value[$i]).
'<br />';
251 if (!isset($_POST[$prefix.
'_flat_charge'])) {
255 $flat_charge_values = $_POST[$prefix.
'_flat_charge'];
256 $new_charge_values = Array();
257 foreach ($flat_charge_values as $value) {
258 if (($value[
'assetid'] != 0) && (!in_array($value[
'assetid'], $new_charge_values))) {
259 $new_charge_values[] = $value[
'assetid'];
262 $asset->setAttrValue(
'flat_charge_assetid', $new_charge_values);
280 $selected_country_values = $asset->attr(
'taxable_countries');
281 $name = $prefix.
'_taxable_countries';
300 $name =
'taxable_countries';
319 global $standards_lists_countries;
320 require_once SQ_FUDGE_PATH.
'/standards_lists/countries.inc';
322 $standards_lists_countries = array_merge(Array(
'blank'=>
''), $standards_lists_countries);
325 echo combo_box($name, $standards_lists_countries, $multiple ? TRUE : FALSE, $selected, $size);
328 $countries_string =
'';
329 for ($i=0; $i<count($selected); $i++) {
330 foreach ($standards_lists_countries as $code => $country) {
331 if ($selected[$i] === $code) {
332 if (empty($countries_string)) {
333 $countries_string = $country;
335 $countries_string .=
', '.$country;
341 echo $countries_string;
359 if ($asset->writeAccess(
'attributes')) {
360 $post = isset($_POST[$prefix.
'_'.$name]) ? $_POST[$prefix.
'_'.$name] : Array();
361 if ($asset->setAttrValue($name, $post)) {
451 $selector_type = $asset->attr(
'quantity_selector');
452 $metadata_source_name =
'quantity_field';
453 $attribute_source_name =
'quantity_attribute';
456 $selector_type = $asset->attr(
'item_weight_selector');
457 $metadata_source_name =
'item_weight_metadata_source';
458 $attribute_source_name =
'item_weight_attribute_source';
461 $prefix = $asset->getPrefix();
462 $wa = $asset->writeAccess(
'attributes');
463 switch ($selector_type) {
466 echo asset_finder($prefix.
'_'.$metadata_source_name, $asset->attr($metadata_source_name), Array(
'metadata_field_text' =>
'I'));
468 $field = $asset->attr($metadata_source_name);
469 if (!empty($field)) {
470 echo get_asset_tag_line($asset->attr($metadata_source_name));
477 echo text_box($prefix.
'_'.$attribute_source_name, $asset->attr($attribute_source_name));
479 echo $asset->attr($attribute_source_name);
500 $metadata_source_name =
'quantity_field';
501 $attribute_source_name =
'quantity_attribute';
504 $metadata_source_name =
'item_weight_metadata_source';
505 $attribute_source_name =
'item_weight_attribute_source';
508 $prefix = $asset->getPrefix();
509 if ($asset->writeAccess(
'attributes')) {
510 if (isset($_POST[$prefix.
'_'.$metadata_source_name][
'assetid'])) {
511 if ($asset->setAttrValue($metadata_source_name, $_POST[$prefix.
'_'.$metadata_source_name][
'assetid'])) {
516 }
else if (isset($_POST[$prefix.
'_'.$attribute_source_name])) {
517 if ($asset->setAttrValue($attribute_source_name, $_POST[$prefix.
'_'.$attribute_source_name])) {
542 global $standards_lists_countries;
543 require_once SQ_FUDGE_PATH.
'/standards_lists/countries.inc';
545 $standards_lists_countries = array_merge(Array(
'blank'=>
''), $standards_lists_countries);
547 $wa = $asset->writeAccess(
'attributes');
548 $delivery_weight_fees = $asset->attr(
'delivery_weight_fee_mapping');
549 if ($wa && empty($delivery_weight_fees)) {
550 $delivery_weight_fees = Array(0);
555 <script type=
"text/javascript">
557 function prependLastTable(moreButton)
559 var lastTable = moreButton.parentNode;
560 while (lastTable.tagName !=
'TABLE') {
561 lastTable = lastTable.parentNode;
565 var lastSibling = lastTable.previousSibling;
566 var lastTableButtonCell = moreButton.parentNode;
569 var validLocation = moreButton.parentNode;
570 while (validLocation.className !=
'sq-backend-data') {
571 validLocation = validLocation.parentNode;
574 var clone = lastTable.cloneNode(
true);
576 validLocation.insertBefore(clone, lastTable.nextSibling);
579 lastTableButtonCell.appendChild(moreButton);
582 moreButton.parentNode.removeChild(moreButton);
585 incrementTableFieldNames(clone);
590 function incrementTableFieldNames(element)
593 var elementChildren = element.childNodes[i];
594 var tagName = element.tagName;
596 if ((tagName ==
'INPUT') || (tagName ==
'SELECT')) {
598 var currentKey = element.name.match(/\[(\d+)\]/);
599 var newKey = parseInt(currentKey[1]) + 1;
600 element.name = element.name.replace(/\[(\d+)\]/,
'[' + newKey +
']');
603 while (elementChildren) {
604 incrementTableFieldNames(elementChildren);
606 elementChildren = element.childNodes[i];
610 function resetLastTableFields(element, findTable)
614 var element = element.parentNode;
615 while (element.tagName !=
'TABLE') {
616 element = element.parentNode;
621 var elementChildren = element.childNodes[i];
622 var tagName = element.tagName;
624 if (tagName ==
'INPUT') {
626 if (element.type !=
'button') {
630 }
else if (tagName ==
'SELECT') {
631 element.selectedIndex = 0;
635 while (elementChildren) {
636 resetLastTableFields(elementChildren,
false);
638 elementChildren = element.childNodes[i];
643 foreach ($delivery_weight_fees as $key => $data) {
645 <table width=
"200px">
647 <td colspan=
"3" width=
"100%" valign=
"top">
649 $name = $prefix.
'_country_delivery_weight_country['.$key.
']';
657 $name = $prefix.
'_country_delivery_weight_price['.$key.
']';
658 echo translate(
'price').
':';
664 echo text_box($prefix.
'_country_delivery_weight_price['.$key.
']', $data[
'price'], 10);
673 $clear_button_name = $prefix.
'_country_delivery_weight_clear_button['.$key.
']';
674 $more_button_name = $prefix.
'_country_delivery_weight_more_button['.$key.
']';
675 echo normal_button($clear_button_name, translate(
'clear'),
'resetLastTableFields(this, true)');
677 if ($key === count($delivery_weight_fees)-1) {
678 echo normal_button($more_button_name, translate(
'more').
'...',
'var table = prependLastTable(this); resetLastTableFields(table, false)');
705 if ($asset->writeAccess(
'attributes')) {
706 $countries_form_name = $prefix.
'_country_delivery_weight_country';
707 $price_form_name = $prefix.
'_country_delivery_weight_price';
708 if (isset($_POST[$countries_form_name])) {
709 $delivery_weight_fees = Array();
710 foreach ($_POST[$countries_form_name] as $key => $codes) {
711 if (empty($codes[0]) || empty($_POST[$price_form_name][$key])) {
714 $delivery_weight_fees[$key] = Array(
715 'countries' => $codes,
716 'price' => (
float) $_POST[$price_form_name][$key],
719 $asset->setAttrValue(
'delivery_weight_fee_mapping', $delivery_weight_fees);
740 $selected_country_values = $asset->attr(
'international_delivery_fee_exempt_countries');
741 $name = $prefix.
'_international_delivery_fee_exempt_countries';
760 $name =
'international_delivery_fee_exempt_countries';
778 $wa = $asset->writeAccess(
'attributes');
779 $conditions = $asset->attr(
'conditional_delivery_fees');
780 if ($wa && empty($conditions)) {
782 $conditions = Array(0);
784 foreach ($conditions as $key => $data) {
786 <table width=
"500px">
788 <td width=
"50%" rowspan=
"6" valign=
"top">
790 $name = $prefix.
'_conditional_fee_countries['.$key.
']';
797 $name = $prefix.
'_conditional_fee_comparison_price['.$key.
']';
800 <?php echo translate(
'ecom_checkout_comparison_price').
':'; ?>
805 echo text_box($name, $data[
'comparison_price'], 5);
807 echo $data[
'comparison_price'];
814 $name = $prefix.
'_conditional_fee_operator['.$key.
']';
823 <?php echo translate(
'ecom_checkout_operator').
':'; ?>
828 echo combo_box($name, $operators, FALSE, $data[
'operator']);
830 echo $data[
'operator'];
837 $name = $prefix.
'_conditional_fee_additional_cost['.$key.
']';
840 <?php echo translate(
'ecom_checkout_additional_cost').
':'; ?>
845 echo text_box($name, $data[
'additional_cost'], 5);
847 echo $data[
'additional_cost'];
854 $name = $prefix.
'_conditional_fee_remove_fees['.$key.
']';
857 <?php echo translate(
'ecom_checkout_remove_fees').
':'; ?>
862 echo check_box($name,
'1', $data[
'remove_fees']);
864 if ($data[
'remove_fees']) {
865 echo translate(
'yes');
867 echo translate(
'no');
879 $clear_button_name = $prefix.
'_conditional_fee_clear_button['.$key.
']';
880 $more_button_name = $prefix.
'_conditional_fee_more_button['.$key.
']';
881 echo normal_button($clear_button_name, translate(
'clear'),
'resetLastTableFields(this, true)');
883 if ($key === count($conditions)-1) {
884 echo normal_button($more_button_name, translate(
'more').
'...',
'var table = prependLastTable(this); resetLastTableFields(table, false)');
913 if ($asset->writeAccess(
'attributes')) {
914 $countries_form_name = $prefix.
'_conditional_fee_countries';
915 $comparison_price_form_name = $prefix.
'_conditional_fee_comparison_price';
916 $operator_form_name = $prefix.
'_conditional_fee_operator';
917 $additional_cost_form_name = $prefix.
'_conditional_fee_additional_cost';
918 $remove_fees_form_name = $prefix.
'_conditional_fee_remove_fees';
919 if (isset($_POST[$countries_form_name])) {
920 $conditions = Array();
921 foreach ($_POST[$countries_form_name] as $key => $codes) {
922 if (empty($codes[0]) || empty($_POST[$comparison_price_form_name][$key]) || empty($_POST[$operator_form_name][$key])) {
925 $conditions[$key] = Array(
926 'countries' => $codes,
927 'comparison_price' => (
float) $_POST[$comparison_price_form_name][$key],
928 'operator' => $_POST[$operator_form_name][$key],
929 'additional_cost' => (
float) $_POST[$additional_cost_form_name][$key],
932 if (isset($_POST[$remove_fees_form_name][$key])) {
933 $conditions[$key][
'remove_fees'] = TRUE;
935 $conditions[$key][
'remove_fees'] = FALSE;
938 $asset->setAttrValue(
'conditional_delivery_fees', $conditions);
959 $wa = $asset->writeAccess(
'attributes');
960 $customise_receipt = $asset->attr(
'customise_receipt');
963 '1' => translate(
'yes'),
964 '0' => translate(
'no'),
966 echo combo_box($prefix.
'_customise_receipt', $contents, FALSE, $customise_receipt);
968 echo $customise_receipt ? translate(
'yes') : translate(
'no');
988 $wa = $asset->writeAccess(
'attributes');
990 if (isset($_POST[$prefix.
'_customise_receipt'])) {
991 $asset->setAttrValue(
'customise_receipt', (
bool) $_POST[$prefix.
'_customise_receipt']);
1013 $write_access = $asset->writeAccess(
'attributes');
1014 $actions = $asset->attr(
'actions');
1017 if ($write_access) {
1018 $selected_action = array_get_index($_REQUEST, $prefix.
'_new_selected_action', NULL);
1019 if (!is_numeric($selected_action)) {
1020 $selected_action = array_get_index($_POST, $prefix.
'_selected_action', NULL);
1023 $selected_action = NULL;
1028 hidden_field($prefix.
'_new_selected_action',
'');
1030 if (!empty($actions)) {
1031 ?><table
class=
"sq-backend-table">
1033 <col width=
"60" align=
"center" />
1036 <col width=
"60" align=
"center" />
1037 <col width=
"60" align=
"center" />
1040 <th><p>Edit</p></th>
1041 <th><p>Action Name / Type</p></th>
1042 <th><p>Summary</p></th>
1043 <th><p>Valid ?</p></th>
1044 <th><p>Active ?</p></th>
1045 <th><p>Delete ?</p></th>
1046 </thead><tbody><?php
1048 foreach ($actions as $key => $action) {
1049 $is_selected_action = (!is_null($selected_action) && ((string)$selected_action === (
string)$key));
1051 if ($is_selected_action) {
1052 echo
' class="alt"';
1055 $action_type = $action[
'type_code'];
1056 $settings = $action[
'settings'];
1057 $type_name = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($action_type,
'name');
1059 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($action_type);
1061 if ($write_access && !$is_selected_action) {
1062 ?><td
class=
"sq-backend-table-cell"><p><a href=
"#" onclick=
"document.getElementById('<?php echo $prefix ?>_new_selected_action').value = <?php echo $key ?>; document.main_form.submit(); return false;"><img src=
"<?php echo sq_web_path('lib'); ?>/web/images/icons/edit_mode.png" width=
"15" height=
"15" border=
"0" /></a></p></td><?php
1064 ?><td
class=
"sq-backend-table-cell"> </td><?php
1066 ?><td
class=
"sq-backend-table-cell"><p><strong><?php echo $action[
'name'] ?></strong><br/>(<?php echo $type_name ?>)</p></td><?php
1067 ?><td
class=
"sq-backend-table-cell"><?php echo call_user_func(Array($action_type,
'paintSummary'), $asset, $settings, $o, $prefix) ?></td><?php
1068 ?><td
class=
"sq-backend-table-cell"><p><img src=
"<?php echo sq_web_path('lib'); ?>/web/images/<?php echo call_user_func(Array($action_type, 'isValid'), $asset, $settings) ? 'tick' : 'cross' ?>.gif" width=
"15" height=
"15" border=
"0" /></p></td><?php
1069 if ($write_access) {
1070 ?><td
class=
"sq-backend-table-cell"><p><?php check_box($prefix.
'_rules[active]['.$key.
']',
'1', $action[
'active']) ?></p></td><?php
1071 ?><td
class=
"sq-backend-table-cell"><p><?php check_box($prefix.
'_rules[delete]['.$key.
']',
'1', FALSE) ?></p></td><?php
1073 ?><td
class=
"sq-backend-table-cell"><p><img src=
"<?php echo sq_web_path('lib'); ?>/web/images/<?php echo $action['active'] ? 'tick' : 'cross' ?>.gif" width=
"15" height=
"15" border=
"0" /></p></td><?php
1074 ?><td
class=
"sq-backend-table-cell"> </td><?php
1078 ?></tbody></table><?php
1080 ?><p>There are no actions currently defined
for this form.</p><?php
1084 $o->
sectionNote(
'Only actions that are <strong>valid</strong> and <strong>active</strong> will be executed when the checkout is completed. An action can be activated or deactivated with the <strong>Active ?</strong> check box.');
1086 return $write_access;
1102 $write_access = $asset->writeAccess(
'attributes');
1107 $edit_action = array_get_index($_REQUEST, $prefix.
'_new_selected_action', NULL);
1108 if (!empty($edit_action)) {
1109 return $write_access;
1112 if ($write_access) {
1113 $actions = $asset->attr(
'actions');
1115 $rule_changes = array_get_index($_POST, $prefix.
'_rules', Array());
1117 if(!empty($actions)) {
1118 foreach ($actions as $key => $action) {
1119 if (!isset($rule_changes[
'active'][$key])) {
1120 $rule_changes[
'active'][$key] = Array();
1124 if (!isset($rule_changes[
'active'])) {
1125 $rule_changes[
'active'] = Array();
1129 if (!isset($rule_changes[
'delete'])) {
1130 $rule_changes[
'delete'] = Array();
1133 foreach ($rule_changes[
'active'] as $key => $value) {
1134 $actions[$key][
'active'] = (boolean)$value;
1136 foreach ($rule_changes[
'delete'] as $key => $value) {
1137 unset($actions[$key]);
1140 $asset->setAttrValue(
'actions', $actions);
1141 if (!$asset->saveAttributes())
return FALSE;
1144 return $write_access;
1160 $write_access = $asset->writeAccess(
'attributes');
1162 $types = $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants(
'checkout_action');
1163 $names = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($types,
'name');
1166 if ($write_access) {
1168 check_box($prefix.
'_new',
'1', FALSE,
'this.form.'.$prefix.
'_new_type.disabled = !this.checked; return true;');
1169 ?><label
for=
"<?php echo $prefix ?>_new">Create a
new action of type:</label> <?php
1170 $names = Array(
'' =>
'Select action type...') + $names;
1171 combo_box($prefix.
'_new_type', $names, FALSE,
'', 0,
'disabled="disabled"');
1174 ?><p>This screen must be locked before you can create a
new action.</p><?php
1180 $o->
sectionNote(
'If you create a new action, the new action will be displayed immediately for you to edit. If you already have an action open to edit, the changes to that action will be saved when you commit before the new action is created.');
1182 return $write_access;
1198 $write_access = $asset->writeAccess(
'attributes');
1200 if ($write_access) {
1202 $new_action = (int)array_get_index($_POST, $prefix.
'_new',
'0');
1208 $action_type = array_get_index($_POST, $prefix.
'_new_type',
'');
1209 if (!empty($action_type)) {
1210 if ($GLOBALS[
'SQ_SYSTEM']->am->installed($action_type)) {
1212 $type_parents = $GLOBALS[
'SQ_SYSTEM']->am->getTypeAncestors($action_type);
1213 if (in_array(
'checkout_action', $type_parents)) {
1215 $type_name = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($action_type,
'name');
1216 $actions = $asset->attr(
'actions');
1218 if (!empty($actions)) {
1219 $new_key = max(array_keys($actions)) + 1;
1224 $actions[$new_key] = Array(
1226 'type_code' => $action_type,
1230 $asset->setAttrValue(
'actions', $actions);
1233 $_POST[$prefix.
'_new_selected_action'] = $new_key;
1235 if (!$asset->saveAttributes())
return FALSE;
1237 trigger_error(
'Cannot create new action; asset type "'.$action_type.
'" is not a checkout action', E_USER_WARNING);
1241 trigger_error(
'Cannot create new action; "'.$action_type.
'" is not a valid asset type', E_USER_WARNING);
1249 return $write_access;
1265 $write_access = $asset->writeAccess(
'attributes');
1266 $selected_action = array_get_index($_REQUEST, $prefix.
'_new_selected_action', NULL);
1267 if (!is_numeric($selected_action)) {
1268 $selected_action = array_get_index($_POST, $prefix.
'_selected_action', NULL);
1271 if ($write_access) {
1272 if (!is_null($selected_action)) {
1273 $actions = $asset->attr(
'actions');
1277 if (!isset($actions[$selected_action])) {
1279 ?><p>No action is currently selected
for editing. To edit an action, please select from the
"Existing Actions" list above.</p><?php
1284 $action = $actions[$selected_action];
1286 $type_name = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($action[
'type_code'],
'name');
1290 text_box($prefix.
'_selected_name', $action[
'name'], 30);
1291 $o->
note(
'An optional name to identify this particular action. If cleared, the action\'s type ("'.$type_name.
'" in this case) will be used, numerically indexed if necessary.');
1296 hidden_field($prefix.
'_selected_action', $selected_action);
1297 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($action[
'type_code']);
1298 call_user_func(Array($action[
'type_code'],
'paintInlineInterface'), $asset, $action[
'settings'], $o, $prefix);
1304 ?><p>No action is currently selected
for editing. To edit an action, please select from the
"Existing Actions" list above.</p><?php
1310 ?><p>This screen must be locked before you can edit an action.</p><?php
1314 return $write_access;
1332 $asset_types = $GLOBALS[
'SQ_SYSTEM']->am->getAssetTypes(TRUE);
1334 $all_types = Array();
1335 foreach ($asset_types as $type_code => $info) {
1336 $all_types[$type_code] = $info[
'name'];
1337 $type_anc = $GLOBALS[
'SQ_SYSTEM']->am->getTypeAncestors($type_code);
1339 foreach ($type_anc as $anc_type_code) {
1340 if ($anc_type_code ==
'asset')
continue;
1342 if (!in_array($anc_type_code, array_keys($all_types))) {
1343 $all_types[$anc_type_code] = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($anc_type_code,
'name');
1347 $all_types = array_unique($all_types);
1349 $all_types[
'asset'] =
'-- '.translate(
'sch_all_asset_types').
' --';
1350 $all_types[
''] =
'';
1351 $all_types = array_reverse($all_types);
1353 combo_box($field_name, $all_types, FALSE, $selected_type_code);
1355 submit_button($field_name.
'_go', translate(
'go'),
'main_form.submit()');
1370 $write_access = $asset->writeAccess(
'attributes');
1371 $actions = $asset->attr(
'actions');
1376 $edit_action = array_get_index($_REQUEST, $prefix.
'_new_selected_action', NULL);
1377 if (is_numeric($edit_action)) {
1383 $selected_action = array_get_index($_POST, $prefix.
'_selected_action', NULL);
1384 if (!isset($actions[$selected_action])) {
1388 if ($write_access) {
1389 if (!is_null($selected_action)) {
1390 $new_name = array_get_index($_POST, $prefix.
'_selected_name', NULL);
1391 $action = $actions[$selected_action];
1393 $new_name = array_get_index($_POST, $prefix.
'_selected_name', NULL);
1394 if ($new_name != $action[
'name']) {
1395 if (empty($new_name)) {
1396 $new_name = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($action[
'type_code'],
'name');
1401 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($action[
'type_code']);
1402 $settings = $action[
'settings'];
1406 $result = call_user_func_array(Array($action[
'type_code'],
'processInlineInterface'), Array($asset, &$settings, $o, $prefix));
1408 $actions[$selected_action][
'settings'] = $settings;
1409 $asset->setAttrValue(
'actions', $actions);
1410 if (!$asset->saveAttributes())
return FALSE;
1417 return ($result && $write_access);
1436 $actions = $asset->attr(
'actions');
1444 foreach ($actions as $action) {
1445 if ($action[
'name'] == $name) {
1450 $name = $base_name.
' '.$i;