diff --git a/docs/upgrades/upgrade_4.4.1-4.5.0.sql b/docs/upgrades/upgrade_4.4.1-4.5.0.sql index a22574b26..0be72765f 100644 --- a/docs/upgrades/upgrade_4.4.1-4.5.0.sql +++ b/docs/upgrades/upgrade_4.4.1-4.5.0.sql @@ -58,6 +58,14 @@ insert into international values (60,'Product',1,'Template'); alter table Product add column productTemplateId int not null default 1; insert into international values (61,'Product',1,'Product Template'); create table Product_template (productTemplateId int not null primary key, name varchar(255), template text); +INSERT INTO Product_template VALUES (1,'Default','\r\n\r\n\r\n \r\n \r\n\r\n
^Product_Description;

\r\n Price: ^Product_Price;
\r\n Product Number: ^Product_Number;

\r\n ^Product_Brochure;
\r\n ^Product_Manual;
\r\n ^Product_Warranty;
\r\n

\r\n ^Product_Thumbnail1;

\r\n ^Product_Thumbnail2;

\r\n ^Product_Thumbnail3;

\r\n

\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n
Features
^Product_Features;

Benefits
^Product_Benefits;

Specifications
^Product_Specifications;

Accessories
^Product_Accessories;

Related Products
^Product_Related;
\r\n\r\n'); +INSERT INTO Product_template VALUES (2,'Benefits Showcase','\r\n\r\n^Product_Image1;\r\n\r\n\r\n \r\n \r\n\r\n
^Product_Description;

\r\n Benefits
\r\n^Product_Benefits;\r\n

\r\n^Product_Thumbnail2;

\r\nSpecifications
\r\n^Product_Specifications;

\r\nOptions
\r\n^Product_Accessories;

\r\nOther Products
\r\n^Product_Related;

\r\n

\r\n\r\n'); +INSERT INTO Product_template VALUES (3,'Three Columns','\r\n^Product_Description;

\r\n\r\n\r\n\r\n \r\n \r\n \r\n\r\n
^Product_Thumbnail1;^Product_Thumbnail2;^Product_Thumbnail3;
\r\n\r\n\r\n \r\n \r\n \r\n\r\n
\r\nFeatures
^Product_Features;

\r\nBenefits
^Product_Benefits;

\r\n

\r\nSpecifications
^Product_Specifications;

\r\nAccessories
^Product_Accessories;

\r\nRelated Products
^Product_Related;

\r\n

\r\n Price: ^Product_Price;
\r\n Product Number: ^Product_Number;

\r\n ^Product_Brochure;
\r\n ^Product_Manual;
\r\n ^Product_Warranty;
\r\n

\r\n\r\n'); +INSERT INTO Product_template VALUES (4,'Left Column Collateral','\r\n\r\n\r\n
\r\n
\r\n^Product_Brochure;
\r\n^Product_Manual;
\r\n^Product_Warranty;
\r\n
\r\n
\r\n^Product_Thumbnail1;

\r\n^Product_Thumbnail2;

\r\n^Product_Thumbnail3;

\r\n

\r\n
\r\n^Product_Description;

\r\nSpecs:
\r\n^Product_Specifications;

\r\nFeatures:
\r\n^Product_Features;

\r\nOptions:
\r\n^Product_Accessories;

\r\n

'); + + + + diff --git a/lib/WebGUI/Wobject.pm b/lib/WebGUI/Wobject.pm index 5cc8b65ae..d5cbf5a62 100644 --- a/lib/WebGUI/Wobject.pm +++ b/lib/WebGUI/Wobject.pm @@ -73,6 +73,47 @@ sub _getNextSequenceNumber { #------------------------------------------------------------------- +=head2 confirm ( message, yesURL, [ , noURL, vitalComparison ] ) + +=item message + + A string containing the message to prompt the user for this action. + +=item yesURL + + A URL to the web method to execute if the user confirms the action. + +=item noURL + + A URL to the web method to execute if the user denies the action. + Defaults back to the current page. + +=item vitalComparison + + A comparison expression to be used when checking whether the action + should be allowed to continue. Typically this is used when the + action is a delete of some sort. + +=cut + +sub confirm { + my ($output, $noURL); + if ($_[4]) { + return WebGUI::Privilege::vitalComponent(); + } elsif (WebGUI::Privilege::canEditPage()) { + $noURL = $_[3] || WebGUI::URL::page(); + $output = '

'.WebGUI::International::get(42).'

'; + $output .= $_[1].'

'; + $output .= '

'.WebGUI::International::get(44).''; + $output .= '   '.WebGUI::International::get(45).'
'; + return $output; + } else { + return WebGUI::Privilege::insufficient(); + } +} + +#------------------------------------------------------------------- + =head2 description ( ) Returns this instance's description if it exists. @@ -211,6 +252,92 @@ sub inDateRange { #------------------------------------------------------------------- +=head2 moveCollateralDown ( tableName, idName, id ) + + Moves a collateral data item down one position. This assumes that the + collateral data table has a column called "wobjectId" that identifies + the wobject, and a column called "sequenceNumber" that determines + the position of the data item. + +=item tableName + + A string indicating the table that contains the collateral data. + +=item idName + + A string indicating the name of the column that uniquely identifies + this collateral data item. + +=item id + + An integer that uniquely identifies this collateral data item. + +=cut + +### NOTE: There is a redundant use of wobjectId in some of these statements on purpose to support +### two different types of collateral data. + +sub moveCollateralDown { + my ($id, $seq); + if (WebGUI::Privilege::canEditPage()) { + ($seq) = WebGUI::SQL->quickArray("select sequenceNumber from $_[1] where $_[2]=$_[3] and wobjectId=".$_[0]->get("wobjectId")); + ($id) = WebGUI::SQL->quickArray("select $_[2] from $_[1] where wobjectId=".$_[0]->get("wobjectId") + ." and sequenceNumber=$seq+1 group by wobjectId"); + if ($id ne "") { + WebGUI::SQL->write("update $_[1] set sequenceNumber=sequenceNumber+1 where $_[2]=$_[3] and wobjectId=".$_[0]->get("wobjectId")); + WebGUI::SQL->write("update $_[1] set sequenceNumber=sequenceNumber-1 where $_[2]=$id and wobjectId=".$_[0]->get("wobjectId")); + } + return ""; + } else { + return WebGUI::Privilege::insufficient(); + } +} + +#------------------------------------------------------------------- + +=head2 moveCollateralUp ( tableName, idName, id ) + + Moves a collateral data item up one position. This assumes that the + collateral data table has a column called "wobjectId" that identifies + the wobject, and a column called "sequenceNumber" that determines + the position of the data item. + +=item tableName + + A string indicating the table that contains the collateral data. + +=item idName + + A string indicating the name of the column that uniquely identifies + this collateral data item. + +=item id + + An integer that uniquely identifies this collateral data item. + +=cut + +### NOTE: There is a redundant use of wobjectId in some of these statements on purpose to support +### two different types of collateral data. + +sub moveCollateralUp { + my ($id, $seq); + if (WebGUI::Privilege::canEditPage()) { + ($seq) = WebGUI::SQL->quickArray("select sequenceNumber from $_[1] where $_[2]=$_[3] and wobjectId=".$_[0]->get("wobjectId")); + ($id) = WebGUI::SQL->quickArray("select $_[2] from $_[1] where wobjectId=".$_[0]->get("wobjectId") + ." and sequenceNumber=$seq-1 group by wobjectId"); + if ($id ne "") { + WebGUI::SQL->write("update $_[1] set sequenceNumber=sequenceNumber-1 where $_[2]=$_[3] and wobjectId=".$_[0]->get("wobjectId")); + WebGUI::SQL->write("update $_[1] set sequenceNumber=sequenceNumber+1 where $_[2]=$id and wobjectId=".$_[0]->get("wobjectId")); + } + return ""; + } else { + return WebGUI::Privilege::insufficient(); + } +} + +#------------------------------------------------------------------- + =head2 new ( hashRef ) Constructor. @@ -590,4 +717,21 @@ sub www_paste { } } +#------------------------------------------------------------------- + +=head2 www_view ( ) + + The default display mechanism for any wobject. This web method MUST + be overridden. + +=cut + +sub www_view { + my ($output); + $output = $_[0]->displayTitle; + $output .= $_[0]->description; + $output = $_[0]->processMacros($output); + return $output; +} + 1; diff --git a/lib/WebGUI/Wobject/Product.pm b/lib/WebGUI/Wobject/Product.pm index 2883bb3fe..3cea571e1 100644 --- a/lib/WebGUI/Wobject/Product.pm +++ b/lib/WebGUI/Wobject/Product.pm @@ -307,18 +307,10 @@ sub www_copyTemplate { #------------------------------------------------------------------- sub www_deleteAccessory { - my ($output); - if (WebGUI::Privilege::canEditPage()) { - $output = '

'.WebGUI::International::get(42).'

'; - $output .= WebGUI::International::get(2,$namespace).'

'; - $output .= '

'.WebGUI::International::get(44).''; - $output .= '   '.WebGUI::International::get(45).'
'; - return $output; - } else { - return WebGUI::Privilege::insufficient(); - } + $_[0]->confirm( + WebGUI::International::get(2,$namespace), + WebGUI::URL::page('func=deleteAccessoryConfirm&wid='.$_[0]->get("wobjectId").'&aid='.$session{form}{aid}) + ); } #------------------------------------------------------------------- @@ -335,18 +327,10 @@ sub www_deleteAccessoryConfirm { #------------------------------------------------------------------- sub www_deleteBenefit { - my ($output); - if (WebGUI::Privilege::canEditPage()) { - $output = '

'.WebGUI::International::get(42).'

'; - $output .= WebGUI::International::get(48,$namespace).'

'; - $output .= '

'.WebGUI::International::get(44).''; - $output .= '   '.WebGUI::International::get(45).'
'; - return $output; - } else { - return WebGUI::Privilege::insufficient(); - } + $_[0]->confirm( + WebGUI::International::get(48,$namespace), + WebGUI::URL::page('func=deleteBenefitConfirm&wid='.$_[0]->get("wobjectId").'&bid='.$session{form}{bid}) + ); } #------------------------------------------------------------------- @@ -362,18 +346,10 @@ sub www_deleteBenefitConfirm { #------------------------------------------------------------------- sub www_deleteFeature { - my ($output); - if (WebGUI::Privilege::canEditPage()) { - $output = '

'.WebGUI::International::get(42).'

'; - $output .= WebGUI::International::get(3,$namespace).'

'; - $output .= '

'.WebGUI::International::get(44).''; - $output .= '   '.WebGUI::International::get(45).'
'; - return $output; - } else { - return WebGUI::Privilege::insufficient(); - } + $_[0]->confirm( + WebGUI::International::get(3,$namespace), + WebGUI::URL::page('func=deleteFeatureConfirm&wid='.$_[0]->get("wobjectId").'&fid='.$session{form}{fid}) + ); } #------------------------------------------------------------------- @@ -389,25 +365,18 @@ sub www_deleteFeatureConfirm { #------------------------------------------------------------------- sub www_deleteFile { - my ($output); - if (WebGUI::Privilege::canEditPage()) { - $output = '

'.WebGUI::International::get(42).'

'; - $output .= WebGUI::International::get(12,$namespace).'

'; - $output .= '

'.WebGUI::International::get(44).''; - $output .= '   '.WebGUI::International::get(45).'
'; - return $output; - } else { - return WebGUI::Privilege::insufficient(); - } + $_[0]->confirm( + WebGUI::International::get(12,$namespace), + WebGUI::URL::page('func=deleteFileConfirm&wid='.$_[0]->get("wobjectId").'&file='.$session{form}{file}), + WebGUI::URL::page('func=edit&wid='.$_[0]->get("wobjectId")) + ); } #------------------------------------------------------------------- sub www_deleteFileConfirm { if (WebGUI::Privilege::canEditPage()) { $_[0]->set({$session{form}{file}=>''}); - return ""; + return $_[0]->www_edit(); } else { return WebGUI::Privilege::insufficient(); } @@ -415,18 +384,10 @@ sub www_deleteFileConfirm { #------------------------------------------------------------------- sub www_deleteRelated { - my ($output); - if (WebGUI::Privilege::canEditPage()) { - $output = '

'.WebGUI::International::get(42).'

'; - $output .= WebGUI::International::get(4,$namespace).'

'; - $output .= '

'.WebGUI::International::get(44).''; - $output .= '   '.WebGUI::International::get(45).'
'; - return $output; - } else { - return WebGUI::Privilege::insufficient(); - } + $_[0]->confirm( + WebGUI::International::get(4,$namespace), + WebGUI::URL::page('func=deleteRelatedConfirm&wid='.$_[0]->get("wobjectId").'&rid='.$session{form}{rid}) + ); } #------------------------------------------------------------------- @@ -443,18 +404,10 @@ sub www_deleteRelatedConfirm { #------------------------------------------------------------------- sub www_deleteSpecification { - my ($output); - if (WebGUI::Privilege::canEditPage()) { - $output = '

'.WebGUI::International::get(42).'

'; - $output .= WebGUI::International::get(5,$namespace).'

'; - $output .= '

'.WebGUI::International::get(44).''; - $output .= '   '.WebGUI::International::get(45).'
'; - return $output; - } else { - return WebGUI::Privilege::insufficient(); - } + $_[0]->confirm( + WebGUI::International::get(5,$namespace), + WebGUI::URL::page('func=deleteSpecificationConfirm&wid='.$_[0]->get("wobjectId").'&sid='.$session{form}{sid}) + ); } #------------------------------------------------------------------- @@ -470,20 +423,12 @@ sub www_deleteSpecificationConfirm { #------------------------------------------------------------------- sub www_deleteTemplate { - my ($output); - if ($session{form}{tid} < 1000) { - return WebGUI::Privilege::vitalComponent(); - } elsif (WebGUI::Privilege::canEditPage()) { - $output = '

'.WebGUI::International::get(42).'

'; - $output .= WebGUI::International::get(57,$namespace).'

'; - $output .= '

'.WebGUI::International::get(44).''; - $output .= '   '.WebGUI::International::get(45).'
'; - return $output; - } else { - return WebGUI::Privilege::insufficient(); - } + $_[0]->confirm( + WebGUI::International::get(57,$namespace), + WebGUI::URL::page('func=deleteTemplateConfirm&wid='.$_[0]->get("wobjectId").'&tid='.$session{form}{tid}), + '', + ($session{form}{tid} < 1000) + ); } #------------------------------------------------------------------- @@ -732,7 +677,7 @@ sub www_editTemplate { tie %data, 'Tie::CPHash'; if (WebGUI::Privilege::canEditPage()) { %data = WebGUI::SQL->quickHash("select * from Product_template where productTemplateId='$session{form}{tid}'"); - $output = helpIcon(3,$namespace); + $output = helpIcon(7,$namespace); $output .= '

'.WebGUI::International::get(58,$namespace).'

'; $f = WebGUI::HTMLForm->new; $f->hidden("wid",$_[0]->get("wobjectId")); @@ -767,207 +712,63 @@ sub www_editTemplateSave { #------------------------------------------------------------------- sub www_moveAccessoryDown { - my ($id, $seq); - if (WebGUI::Privilege::canEditPage()) { - ($seq) = WebGUI::SQL->quickArray("select sequenceNumber from Product_accessory - where accessoryWobjectId=$session{form}{aid} and wobjectId=".$_[0]->get("wobjectId")); - ($id) = WebGUI::SQL->quickArray("select accessoryWobjectId from Product_accessory - where wobjectId=".$_[0]->get("wobjectId")." and sequenceNumber=$seq+1 group by wobjectId"); - if ($id ne "") { - WebGUI::SQL->write("update Product_accessory set sequenceNumber=sequenceNumber+1 - where accessoryWobjectId=$session{form}{aid} and wobjectId=".$_[0]->get("wobjectId")); - WebGUI::SQL->write("update Product_accessory set sequenceNumber=sequenceNumber-1 - where accessoryWobjectId=$id and wobjectId=".$_[0]->get("wobjectId")); - } - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } + $_[0]->moveCollateralDown("Product_related","accessoryWobjectId",$session{form}{aid}); } #------------------------------------------------------------------- sub www_moveAccessoryUp { - my ($id, $seq); - if (WebGUI::Privilege::canEditPage()) { - ($seq) = WebGUI::SQL->quickArray("select sequenceNumber from Product_accessory - where accessoryWobjectId=$session{form}{aid} and wobjectId=".$_[0]->get("wobjectId")); - ($id) = WebGUI::SQL->quickArray("select accessoryWobjectId from Product_accessory - where wobjectId=".$_[0]->get("wobjectId")." and sequenceNumber=$seq-1 group by wobjectId"); - if ($id ne "") { - WebGUI::SQL->write("update Product_accessory set sequenceNumber=sequenceNumber-1 - where accessoryWobjectId=$session{form}{aid} and wobjectId=".$_[0]->get("wobjectId")); - WebGUI::SQL->write("update Product_accessory set sequenceNumber=sequenceNumber+1 - where accessoryWobjectId=$id and wobjectId=".$_[0]->get("wobjectId")); - } - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } + $_[0]->moveCollateralUp("Product_accessory","accessoryWobjectId",$session{form}{aid}); } #------------------------------------------------------------------- sub www_moveBenefitDown { - my ($id, $seq); - if (WebGUI::Privilege::canEditPage()) { - ($seq) = WebGUI::SQL->quickArray("select sequenceNumber from Product_benefit - where productBenefitId=$session{form}{bid}"); - ($id) = WebGUI::SQL->quickArray("select productBenefitId from Product_benefit - where wobjectId=".$_[0]->get("wobjectId")." and sequenceNumber=$seq+1 group by wobjectId"); - if ($id ne "") { - WebGUI::SQL->write("update Product_benefit set sequenceNumber=sequenceNumber+1 - where productBenefitId=$session{form}{bid}"); - WebGUI::SQL->write("update Product_benefit set sequenceNumber=sequenceNumber-1 where productBenefitId=$id"); - } - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } + $_[0]->moveCollateralDown("Product_benefit","productBenefitId",$session{form}{bid}); } #------------------------------------------------------------------- sub www_moveBenefitUp { - my ($id, $seq); - if (WebGUI::Privilege::canEditPage()) { - ($seq) = WebGUI::SQL->quickArray("select sequenceNumber from Product_benefit - where productBenefitId=$session{form}{bid}"); - ($id) = WebGUI::SQL->quickArray("select productBenefitId from Product_benefit - where wobjectId=".$_[0]->get("wobjectId")." and sequenceNumber=$seq-1 group by wobjectId"); - if ($id ne "") { - WebGUI::SQL->write("update Product_benefit set sequenceNumber=sequenceNumber-1 - where productBenefitId=$session{form}{bid}"); - WebGUI::SQL->write("update Product_benefit set sequenceNumber=sequenceNumber+1 where productBenefitId=$id"); - } - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } + $_[0]->moveCollateralUp("Product_benefit","productBenefitId",$session{form}{bid}); } #------------------------------------------------------------------- sub www_moveFeatureDown { - my ($id, $seq); - if (WebGUI::Privilege::canEditPage()) { - ($seq) = WebGUI::SQL->quickArray("select sequenceNumber from Product_feature - where productFeatureId=$session{form}{fid}"); - ($id) = WebGUI::SQL->quickArray("select productFeatureId from Product_feature - where wobjectId=".$_[0]->get("wobjectId")." and sequenceNumber=$seq+1 group by wobjectId"); - if ($id ne "") { - WebGUI::SQL->write("update Product_feature set sequenceNumber=sequenceNumber+1 - where productFeatureId=$session{form}{fid}"); - WebGUI::SQL->write("update Product_feature set sequenceNumber=sequenceNumber-1 where productFeatureId=$id"); - } - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } + $_[0]->moveCollateralDown("Product_feature","productFeatureId",$session{form}{fid}); } #------------------------------------------------------------------- sub www_moveFeatureUp { - my ($id, $seq); - if (WebGUI::Privilege::canEditPage()) { - ($seq) = WebGUI::SQL->quickArray("select sequenceNumber from Product_feature - where productFeatureId=$session{form}{fid}"); - ($id) = WebGUI::SQL->quickArray("select productFeatureId from Product_feature - where wobjectId=".$_[0]->get("wobjectId")." and sequenceNumber=$seq-1 group by wobjectId"); - if ($id ne "") { - WebGUI::SQL->write("update Product_feature set sequenceNumber=sequenceNumber-1 - where productFeatureId=$session{form}{fid}"); - WebGUI::SQL->write("update Product_feature set sequenceNumber=sequenceNumber+1 where productFeatureId=$id"); - } - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } + $_[0]->moveCollateralUp("Product_feature","productFeatureId",$session{form}{fid}); } #------------------------------------------------------------------- sub www_moveRelatedDown { - my ($id, $seq); - if (WebGUI::Privilege::canEditPage()) { - ($seq) = WebGUI::SQL->quickArray("select sequenceNumber from Product_related - where relatedWobjectId=$session{form}{rid} and wobjectId=".$_[0]->get("wobjectId")); - ($id) = WebGUI::SQL->quickArray("select relatedWobjectId from Product_related - where wobjectId=".$_[0]->get("wobjectId")." and sequenceNumber=$seq+1 group by wobjectId"); - if ($id ne "") { - WebGUI::SQL->write("update Product_related set sequenceNumber=sequenceNumber+1 - where relatedWobjectId=$session{form}{rid} and wobjectId=".$_[0]->get("wobjectId")); - WebGUI::SQL->write("update Product_related set sequenceNumber=sequenceNumber-1 - where relatedWobjectId=$id and wobjectId=".$_[0]->get("wobjectId")); - } - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } + $_[0]->moveCollateralDown("Product_related","relatedWobjectId",$session{form}{rid}); } #------------------------------------------------------------------- sub www_moveRelatedUp { - my ($id, $seq); - if (WebGUI::Privilege::canEditPage()) { - ($seq) = WebGUI::SQL->quickArray("select sequenceNumber from Product_related - where relatedWobjectId=$session{form}{rid} and wobjectId=".$_[0]->get("wobjectId")); - ($id) = WebGUI::SQL->quickArray("select relatedWobjectId from Product_related - where wobjectId=".$_[0]->get("wobjectId")." and sequenceNumber=$seq-1 group by wobjectId"); - if ($id ne "") { - WebGUI::SQL->write("update Product_related set sequenceNumber=sequenceNumber-1 - where relatedWobjectId=$session{form}{rid} and wobjectId=".$_[0]->get("wobjectId")); - WebGUI::SQL->write("update Product_related set sequenceNumber=sequenceNumber+1 - where relatedWobjectId=$id and wobjectId=".$_[0]->get("wobjectId")); - } - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } + $_[0]->moveCollateralUp("Product_related","relatedWobjectId",$session{form}{rid}); } #------------------------------------------------------------------- sub www_moveSpecificationDown { - my ($id, $seq); - if (WebGUI::Privilege::canEditPage()) { - ($seq) = WebGUI::SQL->quickArray("select sequenceNumber from Product_specification - where productSpecificationId=$session{form}{sid}"); - ($id) = WebGUI::SQL->quickArray("select productSpecificationId from Product_specification - where wobjectId=".$_[0]->get("wobjectId")." and sequenceNumber=$seq+1 group by wobjectId"); - if ($id ne "") { - WebGUI::SQL->write("update Product_specification set sequenceNumber=sequenceNumber+1 - where productSpecificationId=$session{form}{sid}"); - WebGUI::SQL->write("update Product_specification set sequenceNumber=sequenceNumber-1 - where productSpecificationId=$id"); - } - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } + $_[0]->moveCollateralDown("Product_specification","productSpecificationId",$session{form}{sid}); } #------------------------------------------------------------------- sub www_moveSpecificationUp { - my ($id, $seq); - if (WebGUI::Privilege::canEditPage()) { - ($seq) = WebGUI::SQL->quickArray("select sequenceNumber from Product_specification - where productSpecificationId=$session{form}{sid}"); - ($id) = WebGUI::SQL->quickArray("select productSpecificationId from Product_specification - where wobjectId=".$_[0]->get("wobjectId")." and sequenceNumber=$seq-1 group by wobjectId"); - if ($id ne "") { - WebGUI::SQL->write("update Product_specification set sequenceNumber=sequenceNumber-1 - where productSpecificationId=$session{form}{sid}"); - WebGUI::SQL->write("update Product_specification set sequenceNumber=sequenceNumber+1 - where productSpecificationId=$id"); - } - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } + $_[0]->moveCollateralUp("Product_specification","productSpecificationId",$session{form}{sid}); } - #------------------------------------------------------------------- sub www_view { my ($output, %data, $sth, $file, $segment, $template); tie %data, 'Tie::CPHash'; $output = $_[0]->displayTitle; ($template) = WebGUI::SQL->quickArray("select template from Product_template where productTemplateId=".$_[0]->get("productTemplateId")); + #---product title + $segment = $_[0]->get("title"); + $template =~ s/\^Product_Title\;/$segment/; #---product description $segment = $_[0]->description; $template =~ s/\^Product_Description\;/$segment/; @@ -978,62 +779,71 @@ sub www_view { $segment = $_[0]->get("productNumber"); $template =~ s/\^Product_Number\;/$segment/; #---product brochure + $segment = ""; if ($_[0]->get("brochure")) { $file = WebGUI::Attachment->new($_[0]->get("brochure"),$_[0]->get("wobjectId")); $segment = ' ' .WebGUI::International::get(13,$namespace).''; - $template =~ s/\^Product_Brochure\;/$segment/; } + $template =~ s/\^Product_Brochure\;/$segment/; #---product manual + $segment = ""; if ($_[0]->get("manual")) { $file = WebGUI::Attachment->new($_[0]->get("manual"),$_[0]->get("wobjectId")); $segment = ' ' .WebGUI::International::get(14,$namespace).''; - $template =~ s/\^Product_Manual\;/$segment/; } + $template =~ s/\^Product_Manual\;/$segment/; #---product warranty + $segment = ""; if ($_[0]->get("warranty")) { $file = WebGUI::Attachment->new($_[0]->get("warranty"),$_[0]->get("wobjectId")); $segment = ' ' .WebGUI::International::get(15,$namespace).''; - $template =~ s/\^Product_Warranty\;/$segment/; } + $template =~ s/\^Product_Warranty\;/$segment/; #---product thumbnail1 + $segment = ""; if ($_[0]->get("image1")) { $file = WebGUI::Attachment->new($_[0]->get("image1"),$_[0]->get("wobjectId")); $segment = ''; - $template =~ s/\^Product_Thumbnail1\;/$segment/; } + $template =~ s/\^Product_Thumbnail1\;/$segment/; #---product thumbnail2 + $segment = ""; if ($_[0]->get("image2")) { $file = WebGUI::Attachment->new($_[0]->get("image2"),$_[0]->get("wobjectId")); $segment = ''; - $template =~ s/\^Product_Thumbnail2\;/$segment/; } + $template =~ s/\^Product_Thumbnail2\;/$segment/; #---product thumbnail3 + $segment = ""; if ($_[0]->get("image3")) { $file = WebGUI::Attachment->new($_[0]->get("image3"),$_[0]->get("wobjectId")); $segment = ''; - $template =~ s/\^Product_Thumbnail3\;/$segment/; } + $template =~ s/\^Product_Thumbnail3\;/$segment/; #---product image1 + $segment = ""; if ($_[0]->get("image1")) { $file = WebGUI::Attachment->new($_[0]->get("image1"),$_[0]->get("wobjectId")); $segment = ''; - $template =~ s/\^Product_Image1\;/$segment/; } + $template =~ s/\^Product_Image1\;/$segment/; #---product image2 + $segment = ""; if ($_[0]->get("image2")) { $file = WebGUI::Attachment->new($_[0]->get("image2"),$_[0]->get("wobjectId")); $segment = ''; - $template =~ s/\^Product_Image2\;/$segment/; } + $template =~ s/\^Product_Image2\;/$segment/; #---product image3 + $segment = ""; if ($_[0]->get("image3")) { $file = WebGUI::Attachment->new($_[0]->get("image3"),$_[0]->get("wobjectId")); $segment = ''; - $template =~ s/\^Product_Image3\;/$segment/; } + $template =~ s/\^Product_Image3\;/$segment/; #---product features $segment = ""; $sth = WebGUI::SQL->read("select feature,productFeatureId from Product_feature where wobjectId=".$_[0]->get("wobjectId")." order by sequenceNumber");