18 require_once SQ_PACKAGES_PATH.
'/web_services/api/soap_api/soap_api.inc';
43 parent::__construct($assetid);
59 'RemoveDesign' =>
'1',
60 'GetDesignFromURL' =>
'1',
61 'ApplyAssetPaintLayout' =>
'1',
62 'RemoveAssetPaintLayout'=>
'1',
87 $request_info = (Array) $request;
88 $new_designid = array_get_index($request_info,
'DesignID',
'');
89 $assetid = array_get_index($request_info,
'AssetID',
'');
90 $design_type = array_get_index($request_info,
'DesignType',
'');
91 $user_defined_design_name = array_get_index($request_info,
'UserDefinedDesignName',
'');
93 $design_name = self::getDesignNameFromType($design_type);
94 if (empty($design_name))
throw new SoapFault(
'Server',
'The Design Type is invalid. Operation Aborted.');
97 $design_changed = FALSE;
99 if (!empty($assetid) && !empty($new_designid)) {
100 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
101 $design = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($new_designid);
103 if (!($design instanceof
Design)) {
104 throw new SoapFault(
'Server',
'The DesignID Provided Does Not Belong To A Design Asset');
107 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
108 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
110 $update_design_cascade = FALSE;
111 if ($design_name == (
'design::user::'.$user_defined_design_name)) {
113 if (empty($user_defined_design_name)) {
114 throw new SoapFault(
'Server',
'User Defined Design Name is either empty or not valid.');
116 if ($GLOBALS[
'SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE,
'design', FALSE, $user_defined_design_name)) {
117 throw new SoapFault(
'Server',
'Design Name '.$user_defined_design_name.
' is already in use');
118 trigger_localised_error(
'SYS0134', E_USER_WARNING, $user_defined_design_name);
123 if (in_array($design_type, Array(
'OverrideUserDefined',
'UserDefined'))) {
124 $design_name = $design_name.$user_defined_design_name;
127 $old_design_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE,
'design', FALSE, $design_name);
128 $old_designid = (empty($old_design_link)) ? 0 : $old_design_link[
'minorid'];
132 if ($new_designid != $old_designid) {
135 if (!$asset->deleteLink($old_design_link[
'linkid'])) {
136 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
143 $design = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($new_designid);
144 if (is_null($design)) {
145 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
150 if (!$asset->createLink($design, SQ_LINK_NOTICE, $design_name)) {
151 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
156 $update_design_cascade = TRUE;
158 throw new SoapFault(
'Server',
'The Design Has Already Been Applied To The Asset. Operation Aborted.');
160 $designs_changed = TRUE;
163 if ($designs_changed) {
164 if ($update_design_cascade == TRUE) {
165 $assets_affected_lookups[] = $asset->id;
168 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
171 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
172 $update_lookup_result = $asset->updateLookups();
174 if (!$update_lookup_result) {
175 throw new SoapFault(
'Server',
'Update Lookups For Asset Failed. Try Running Update Lookups Again Another Time');
179 'ApplyDesignResult' => $designs_changed,
183 throw new SoapFault(
'Server',
'Asset ID is not valid. Please provide a valid Asset ID');
197 private static function getDesignNameFromType($design_type)
200 switch ($design_type) {
201 case 'OverrideFrontend':
202 $design_name =
'override::design::system::frontend';
204 case 'OverrideLogin':
205 $design_name =
'override::design::system::login';
207 case 'OverrideUserDefined':
208 $design_name =
'override::design::user::';
211 $design_name =
'design::system::frontend';
214 $design_name =
'design::system::login';
217 $design_name =
'design::user::';
246 $request_info = (Array) $request;
247 $design_id = array_get_index($request_info,
'DesignID',
'');
248 $assetid = array_get_index($request_info,
'AssetID',
'');
249 $design_type = array_get_index($request_info,
'DesignType',
'');
250 $user_defined_design_name = array_get_index($request_info,
'UserDefinedDesignName',
'');
253 if (!empty($assetid) && !empty($design_id)) {
254 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
255 $design = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($design_id);
257 $design_name = self::getDesignNameFromType($design_type);
260 if (!($design instanceof
Design)) {
261 throw new SoapFault(
'Server',
'The DesignID Provided Does Not Belong To A Design Asset');
264 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
265 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
268 if (in_array($design_type, Array(
'OverrideUserDefined',
'UserDefined'))) {
269 $design_name = $design_name.$user_defined_design_name;
272 $old_design_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE,
'design', FALSE, $design_name);
273 $old_designid = (empty($old_design_link)) ? 0 : $old_design_link[
'minorid'];
275 if ($old_designid && $old_designid == $design_id) {
276 if (!$asset->deleteLink($old_design_link[
'linkid'])) {
277 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
282 throw new SoapFault(
'Server',
'No Such Design Found For Asset');
286 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
289 $update_lookup_result = $asset->updateLookups();
291 if (!$update_lookup_result) {
292 throw new SoapFault(
'Server',
'Update Lookups For Asset Failed. Try Running Update Lookups Again Another Time');
296 'RemoveDesignResult' => $designs_ok,
300 throw new SoapFault(
'Server',
'Asset ID is not valid. Please provide a valid Asset ID');
323 $request_info = (Array) $request;
324 $url = array_get_index($request_info,
'URL',
'');
325 $design_type = array_get_index($request_info,
'DesignType',
'');
326 $user_defined_design_name = array_get_index($request_info,
'UserDefinedDesignName',
'');
329 $url = str_replace(
'http://' ,
'', $url);
330 $url = str_replace(
'https://',
'', $url);
332 $design_name = self::getDesignNameFromType($design_type);
334 if (in_array($design_type, Array(
'OverrideUserDefined',
'UserDefined'))) {
335 $design_name = $design_name.$user_defined_design_name;
338 if (empty($design_name)) {
339 $design_name =
'design::system::frontend';
342 $designs = $GLOBALS[
'SQ_SYSTEM']->am->getDesignFromURL($url, $design_name);
343 $design_result = Array (
344 'DesignID' => $designs[
'designid'],
345 'TypeCode' => $designs[
'type_code'],
349 'GetDesignFromURLResult' => $design_result,
372 $request_info = (Array) $request;
373 $paint_layout_id = array_get_index($request_info,
'PaintLayoutID',
'');
374 $assetid = array_get_index($request_info,
'AssetID',
'');
375 $paint_layout_type = array_get_index($request_info,
'PaintLayoutType',
'');
377 if (!empty($assetid)) {
378 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
379 if (empty($paint_layout_id)) {
380 throw new SoapFault(
'Server',
'The PaintLayoutID provided is invalid');
383 $result = self::changePaintLayout($asset, $paint_layout_id, $paint_layout_type);
386 'ApplyAssetPaintLayoutResult' => $result,
390 throw new SoapFault(
'Server',
'The AssetID supplied is either empty or not valid');
413 $request_info = (Array) $request;
414 $paint_layout_id = array_get_index($request_info,
'PaintLayoutID',
'');
415 $assetid = array_get_index($request_info,
'AssetID',
'');
416 $paint_layout_type = array_get_index($request_info,
'PaintLayoutType',
'');
418 if (!empty($assetid)) {
419 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
421 $paint_layout_end_name =
'::system::frontend';
422 $value_name = $paint_layout_type ==
'Frontend' ?
'paint_layout' :
'override::paint_layout';
423 $paint_layout_name = $value_name.$paint_layout_end_name;
424 $existing_layout_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE,
'paint_layout_page', TRUE, $paint_layout_name);
425 if (empty($existing_layout_link) || ($existing_layout_link[
'minorid'] != $paint_layout_id)) {
426 throw new SoapFault(
'Server',
'The Asset Does Not Have A PaintLayout Applied With The Provided PaintLayoutID');
429 $paint_layout_end_name =
'::system::frontend';
430 $value_name = $paint_layout_type ==
'Frontend' ?
'paint_layout' :
'override::paint_layout';
431 $paint_layout_name = $value_name.$paint_layout_end_name;
434 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
435 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
436 $GLOBALS[
'SQ_SYSTEM']->am->acquireLock($asset->id,
'all');
438 $layouts_changed = FALSE;
443 $existing_layout_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE,
'paint_layout_page', TRUE, $paint_layout_name);
446 if ($existing_layout_link) {
447 if (!$asset->deleteLink($existing_layout_link[
'linkid'])) {
449 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
453 $layouts_changed = TRUE;
458 if (!$new_values = $asset->deleteLookupValue($paint_layout_name, $existing_layout_link[
'minorid'])) {
460 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
467 if ($layouts_changed) {
468 if (!$asset->updateLookups()) {
469 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
470 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
478 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($asset->id,
'all');
479 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
480 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
483 'RemoveAssetPaintLayoutResult' => $result,
486 throw new SoapFault(
'Server',
'The AssetID supplied is either empty or not valid');
501 private static function changePaintLayout($asset, $paint_layout_id, $paint_layout_type)
503 $paint_layout = NULL;
505 if ($paint_layout_id != 0) {
506 $paint_layout = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($paint_layout_id);
508 throw new SoapFault(
'Server',
'The PaintLayoutID Provided Does Not Belong To A Paint Layout Page Asset');
512 $paint_layout_end_name =
'::system::frontend';
513 $value_name = $paint_layout_type ==
'Frontend' ?
'paint_layout' :
'override::paint_layout';
514 $paint_layout_name = $value_name.$paint_layout_end_name;
516 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
517 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
518 $GLOBALS[
'SQ_SYSTEM']->am->acquireLock($asset->id,
'all');
520 $lookup_values = $asset->getLookupValues(FALSE);
521 $existing_layout_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE,
'paint_layout_page', TRUE, $paint_layout_name);
522 $layouts_changed = FALSE;
526 'paint_layout' => Array (
529 'override::paint_layout' => Array (
535 $create_new = $delete_existing = FALSE;
536 if (empty($existing_layout_link)) {
539 }
else if ($existing_layout_link[
'minorid'] !== $paint_layout_id) {
540 $delete_existing = TRUE;
544 if ($delete_existing) {
545 if ($existing_layout_link) {
546 if (!$asset->deleteLink($existing_layout_link[
'linkid'])) {
547 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
551 $layouts_changed = TRUE;
556 if (!$new_values = $asset->deleteLookupValue($paint_layout_name, $existing_layout_link[
'minorid'])) {
557 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
561 $lookup_values = $new_values;
569 if (is_null($paint_layout)) {
570 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
572 }
else if (!$asset->createLink($paint_layout, SQ_LINK_NOTICE, $paint_layout_name)) {
573 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
577 $layouts_changed = TRUE;
582 if (empty($paint_layout_id)) {
583 if (isset($lookup_values[
'asset'][$paint_layout_name])) {
584 unset($lookup_values[
'asset'][$paint_layout_name]);
588 $layouts_changed = TRUE;
590 if (!isset($lookup_values[
'asset'])) {
591 $lookup_values[
'asset'] = Array();
593 $lookup_values[
'asset'][$value_name] = Array(
'value' => $paint_layout_id);
596 if (!$asset->setLookupValues($lookup_values)) {
597 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
598 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
603 if ($layouts_changed) {
604 if (!$asset->updateLookups()) {
605 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
606 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
612 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
613 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
614 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($asset->id,
'all');
629 $obj_optional = self::getArgType(
'AssetObject', 0, 1);
630 $design_link_summary = self::getArgType(
'DesignLinkSummary', 0, 1);
632 $complex_types = Array (
633 'ApplyDesign' => Array (
634 'ApplyDesign' => Array (
635 'DesignID' => self::$string_non_optional,
636 'AssetID' => self::$string_non_optional,
637 'DesignType' => self::$string_non_optional,
638 'UserDefinedDesignName' => self::$string_optional,
640 'ApplyDesignResponse' => Array (
641 'ApplyDesignResult' => self::$boolean_optional,
644 'RemoveDesign' => Array (
645 'RemoveDesign' => Array (
646 'DesignID' => self::$string_non_optional,
647 'AssetID' => self::$string_non_optional,
648 'DesignType' => self::$string_optional,
649 'UserDefinedDesignName' => self::$string_optional,
651 'RemoveDesignResponse' => Array (
652 'RemoveDesignResult' => self::$boolean_optional,
655 'GetDesignFromURL' => Array (
656 'GetDesignFromURL' => Array (
657 'URL' => self::$string_non_optional,
658 'DesignType' => self::$string_optional,
659 'UserDefinedDesignName' => self::$string_optional,
661 'GetDesignFromURLResponse' => Array (
662 'GetDesignFromURLResult' => $design_link_summary,
665 'ApplyAssetPaintLayout' => Array (
666 'ApplyAssetPaintLayout' => Array (
667 'PaintLayoutID' => self::$string_non_optional,
668 'AssetID' => self::$string_optional,
669 'PaintLayoutType' => self::$string_non_optional,
672 'ApplyAssetPaintLayoutResponse' => Array (
673 'ApplyAssetPaintLayoutResult' => self::$boolean_optional,
676 'RemoveAssetPaintLayout' => Array (
677 'RemoveAssetPaintLayout' => Array (
678 'PaintLayoutID' => self::$string_non_optional,
679 'AssetID' => self::$string_optional,
680 'PaintLayoutType' => self::$string_non_optional,
683 'RemoveAssetPaintLayoutResponse' => Array (
684 'RemoveAssetPaintLayoutResult' => self::$boolean_optional,
688 'ApplyURLPaintLayout' => Array (
689 'ApplyURLPaintLayout' => Array (
693 'ApplyURLPaintLayoutResponse' => Array (
694 'ApplyURLPaintLayoutResult' => self::$boolean_optional,
699 $complex_types_available = parent::getComplexElements($complex_types);
701 return $complex_types_available;
714 $complex_types = Array (
715 'GetDesignFromURL' => Array (
716 'DesignLinkSummary' => Array (
717 'DesignID' => self::$string_non_optional,
718 'TypeCode' => self::$string_optional,
723 $complex_types_available = parent::getComplexElements($complex_types);
725 return $complex_types_available;
738 $design_type = Array (
739 'restriction_base' =>
'string',
740 'enumeration' => Array (
741 'Frontend',
'OverrideFrontend',
'Login',
'OverrideLogin',
'UserDefined',
'OverrideUserDefined',
745 $simple_restricted_types = Array (
746 'ApplyDesign' => Array (
747 'DesignType' => $design_type,
749 'RemoveDesign' => Array (
750 'DesignType' => $design_type,
752 'GetDesignFromURL' => Array (
753 'DesignType' => $design_type,
757 $simple_restricted_types_available = parent::getSimpleRestrictedTypes($simple_restricted_types);
759 return $simple_restricted_types_available;