From 42227f1194aba8ff38e4429232c0c0e712dc6aee Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sun, 29 Sep 2002 22:54:10 +0000 Subject: [PATCH] Removed unncessary new method from all wobjects. Moved www_copy www_deleteMessage www_deleteMessageConfirm to Wobject superclass. --- lib/WebGUI/Wobject.pm | 54 ++++++++++++++++++++++++- lib/WebGUI/Wobject/Article.pm | 37 ----------------- lib/WebGUI/Wobject/DownloadManager.pm | 19 --------- lib/WebGUI/Wobject/EventsCalendar.pm | 19 --------- lib/WebGUI/Wobject/ExtraColumn.pm | 19 --------- lib/WebGUI/Wobject/FAQ.pm | 19 --------- lib/WebGUI/Wobject/Item.pm | 19 --------- lib/WebGUI/Wobject/LinkList.pm | 19 --------- lib/WebGUI/Wobject/MailForm.pm | 19 --------- lib/WebGUI/Wobject/MessageBoard.pm | 37 ----------------- lib/WebGUI/Wobject/Poll.pm | 19 --------- lib/WebGUI/Wobject/Product.pm | 19 --------- lib/WebGUI/Wobject/SQLReport.pm | 19 --------- lib/WebGUI/Wobject/SiteMap.pm | 19 --------- lib/WebGUI/Wobject/SyndicatedContent.pm | 19 --------- lib/WebGUI/Wobject/UserSubmission.pm | 37 ----------------- lib/WebGUI/Wobject/WobjectProxy.pm | 19 --------- 17 files changed, 53 insertions(+), 359 deletions(-) diff --git a/lib/WebGUI/Wobject.pm b/lib/WebGUI/Wobject.pm index ca6796f9e..2678bd557 100644 --- a/lib/WebGUI/Wobject.pm +++ b/lib/WebGUI/Wobject.pm @@ -406,7 +406,7 @@ sub moveCollateralUp { Constructor. - NOTE: This method is meant to be extended by all sub-classes. + NOTE: This method should never need to be overridden or extended. =item hashRef @@ -615,6 +615,25 @@ sub setCollateral { } +#------------------------------------------------------------------- + +=head2 www_copy ( ) + + Copies this instance to the clipboard. + + NOTE: Should never need to be overridden or extended. + +=cut + +sub www_copy { + if (WebGUI::Privilege::canEditPage()) { + $_[0]->duplicate; + return ""; + } else { + return WebGUI::Privilege::insufficient(); + } +} + #------------------------------------------------------------------- =head2 www_cut ( ) @@ -682,6 +701,39 @@ sub www_deleteConfirm { #------------------------------------------------------------------- +=head2 www_deleteMessage ( ) + + Displays a message asking for confirmation to delete a message from + a discussion. + +=cut + +sub www_deleteMessage { + if (WebGUI::Discussion::canEditMessage($_[0],$session{form}{mid})) { + return WebGUI::Discussion::deleteMessage(); + } else { + return WebGUI::Privilege::insufficient(); + } +} + +#------------------------------------------------------------------- + +=head2 www_deleteMessageConfirm ( ) + + Deletes a message from a discussion. + +=cut + +sub www_deleteMessageConfirm { + if (WebGUI::Discussion::canEditMessage($_[0],$session{form}{mid})) { + return WebGUI::Discussion::deleteMessageConfirm(); + } else { + return WebGUI::Privilege::insufficient(); + } +} + +#------------------------------------------------------------------- + =head2 www_edit ( formRows ) Displays the common properties of any/all wobjects. diff --git a/lib/WebGUI/Wobject/Article.pm b/lib/WebGUI/Wobject/Article.pm index 438f42bc1..4d188ff64 100644 --- a/lib/WebGUI/Wobject/Article.pm +++ b/lib/WebGUI/Wobject/Article.pm @@ -51,15 +51,6 @@ sub duplicate { WebGUI::Discussion::duplicate($_[0]->get("wobjectId"),$w->get("wobjectId")); } -#------------------------------------------------------------------- -sub new { - my ($self, $class, $property); - $class = shift; - $property = shift; - $self = WebGUI::Wobject->new($property); - bless $self, $class; -} - #------------------------------------------------------------------- sub purge { WebGUI::Discussion::purge($_[0]->get("wobjectId")); @@ -80,16 +71,6 @@ sub www_approvePost { } } -#------------------------------------------------------------------- -sub www_copy { - if (WebGUI::Privilege::canEditPage()) { - $_[0]->duplicate; - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } -} - #------------------------------------------------------------------- sub www_deleteAttachment { if (WebGUI::Privilege::canEditPage()) { @@ -110,24 +91,6 @@ sub www_deleteImage { } } -#------------------------------------------------------------------- -sub www_deleteMessage { - if (WebGUI::Discussion::canEditMessage($_[0],$session{form}{mid})) { - return WebGUI::Discussion::deleteMessage(); - } else { - return WebGUI::Privilege::insufficient(); - } -} - -#------------------------------------------------------------------- -sub www_deleteMessageConfirm { - if (WebGUI::Discussion::canEditMessage($_[0],$session{form}{mid})) { - return WebGUI::Discussion::deleteMessageConfirm(); - } else { - return WebGUI::Privilege::insufficient(); - } -} - #------------------------------------------------------------------- sub www_denyPost { if (WebGUI::Privilege::isInGroup($_[0]->get("groupToModerate"))) { diff --git a/lib/WebGUI/Wobject/DownloadManager.pm b/lib/WebGUI/Wobject/DownloadManager.pm index 9479f8321..a1a8ef719 100644 --- a/lib/WebGUI/Wobject/DownloadManager.pm +++ b/lib/WebGUI/Wobject/DownloadManager.pm @@ -90,15 +90,6 @@ sub duplicate { $sth->finish; } -#------------------------------------------------------------------- -sub new { - my ($self, $class, $property); - $class = shift; - $property = shift; - $self = WebGUI::Wobject->new($property); - bless $self, $class; -} - #------------------------------------------------------------------- sub purge { WebGUI::SQL->write("delete from DownloadManager_file where wobjectId=".$_[0]->get("wobjectId")); @@ -110,16 +101,6 @@ sub set { $_[0]->SUPER::set($_[1],[qw(paginateAfter displayThumbnails)]); } -#------------------------------------------------------------------- -sub www_copy { - if (WebGUI::Privilege::canEditPage()) { - $_[0]->duplicate; - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } -} - #------------------------------------------------------------------- sub www_deleteFile { my ($delete); diff --git a/lib/WebGUI/Wobject/EventsCalendar.pm b/lib/WebGUI/Wobject/EventsCalendar.pm index fbdd8d92b..e59c26626 100644 --- a/lib/WebGUI/Wobject/EventsCalendar.pm +++ b/lib/WebGUI/Wobject/EventsCalendar.pm @@ -106,15 +106,6 @@ sub duplicate { $sth->finish; } -#------------------------------------------------------------------- -sub new { - my ($self, $class, $property); - $class = shift; - $property = shift; - $self = WebGUI::Wobject->new($property); - bless $self, $class; -} - #------------------------------------------------------------------- sub purge { WebGUI::SQL->write("delete from EventsCalendar_event where wobjectId=".$_[0]->get("wobjectId")); @@ -126,16 +117,6 @@ sub set { $_[0]->SUPER::set($_[1],[qw(calendarLayout paginateAfter)]); } -#------------------------------------------------------------------- -sub www_copy { - if (WebGUI::Privilege::canEditPage()) { - $_[0]->duplicate; - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } -} - #------------------------------------------------------------------- sub www_deleteEvent { my ($output); diff --git a/lib/WebGUI/Wobject/ExtraColumn.pm b/lib/WebGUI/Wobject/ExtraColumn.pm index 34f574ea4..2edcad045 100644 --- a/lib/WebGUI/Wobject/ExtraColumn.pm +++ b/lib/WebGUI/Wobject/ExtraColumn.pm @@ -38,30 +38,11 @@ sub duplicate { }); } -#------------------------------------------------------------------- -sub new { - my ($self, $class, $property); - $class = shift; - $property = shift; - $self = WebGUI::Wobject->new($property); - bless $self, $class; -} - #------------------------------------------------------------------- sub set { $_[0]->SUPER::set($_[1],[qw(spacer width class)]); } -#------------------------------------------------------------------- -sub www_copy { - if (WebGUI::Privilege::canEditPage()) { - $_[0]->duplicate; - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } -} - #------------------------------------------------------------------- sub www_edit { my ($output, $f, $endDate, $width, $class, $spacer,$startDate); diff --git a/lib/WebGUI/Wobject/FAQ.pm b/lib/WebGUI/Wobject/FAQ.pm index 3ee7a3e15..5d135d3dd 100644 --- a/lib/WebGUI/Wobject/FAQ.pm +++ b/lib/WebGUI/Wobject/FAQ.pm @@ -57,15 +57,6 @@ sub duplicate { $sth->finish; } -#------------------------------------------------------------------- -sub new { - my ($self, $class, $property); - $class = shift; - $property = shift; - $self = WebGUI::Wobject->new($property); - bless $self, $class; -} - #------------------------------------------------------------------- sub purge { WebGUI::SQL->write("delete from FAQ_question where wobjectId=".$_[0]->get("wobjectId")); @@ -77,16 +68,6 @@ sub set { $_[0]->SUPER::set($_[1],[qw(topOn tocOn qaOn)]); } -#------------------------------------------------------------------- -sub www_copy { - if (WebGUI::Privilege::canEditPage()) { - $_[0]->duplicate; - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } -} - #------------------------------------------------------------------- sub www_deleteQuestion { my ($output); diff --git a/lib/WebGUI/Wobject/Item.pm b/lib/WebGUI/Wobject/Item.pm index b017ee086..e2e12a926 100644 --- a/lib/WebGUI/Wobject/Item.pm +++ b/lib/WebGUI/Wobject/Item.pm @@ -40,30 +40,11 @@ sub duplicate { $f->copy($w->get("wobjectId")); } -#------------------------------------------------------------------- -sub new { - my ($self, $class, $property); - $class = shift; - $property = shift; - $self = WebGUI::Wobject->new($property); - bless $self, $class; -} - #------------------------------------------------------------------- sub set { $_[0]->SUPER::set($_[1],[qw(linkURL attachment)]); } -#------------------------------------------------------------------- -sub www_copy { - if (WebGUI::Privilege::canEditPage()) { - $_[0]->duplicate; - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } -} - #------------------------------------------------------------------- sub www_deleteAttachment { if (WebGUI::Privilege::canEditPage()) { diff --git a/lib/WebGUI/Wobject/LinkList.pm b/lib/WebGUI/Wobject/LinkList.pm index 91ee750bd..7a98d253c 100644 --- a/lib/WebGUI/Wobject/LinkList.pm +++ b/lib/WebGUI/Wobject/LinkList.pm @@ -57,15 +57,6 @@ sub duplicate { $sth->finish; } -#------------------------------------------------------------------- -sub new { - my ($self, $class, $property); - $class = shift; - $property = shift; - $self = WebGUI::Wobject->new($property); - bless $self, $class; -} - #------------------------------------------------------------------- sub purge { WebGUI::SQL->write("delete from LinkList_link where wobjectId=".$_[0]->get("wobjectId")); @@ -77,16 +68,6 @@ sub set { $_[0]->SUPER::set($_[1],[qw(indent bullet lineSpacing)]); } -#------------------------------------------------------------------- -sub www_copy { - if (WebGUI::Privilege::canEditPage()) { - $_[0]->duplicate; - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } -} - #------------------------------------------------------------------- sub www_deleteLink { my ($output); diff --git a/lib/WebGUI/Wobject/MailForm.pm b/lib/WebGUI/Wobject/MailForm.pm index a52fd0946..81f83d9ac 100755 --- a/lib/WebGUI/Wobject/MailForm.pm +++ b/lib/WebGUI/Wobject/MailForm.pm @@ -75,15 +75,6 @@ sub duplicate { $sth->finish; } -#------------------------------------------------------------------- -sub new { - my ($self, $class, $property); - $class = shift; - $property = shift; - $self = WebGUI::Wobject->new($property); - bless $self, $class; -} - #------------------------------------------------------------------- sub purge { WebGUI::SQL->write("delete from MailForm_field where wobjectId=".$_[0]->get("wobjectId")); @@ -97,16 +88,6 @@ sub set { $_[0]->SUPER::set($_[1],[@fields]); } -#------------------------------------------------------------------- -sub www_copy { - if (WebGUI::Privilege::canEditPage()) { - $_[0]->duplicate; - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } -} - #------------------------------------------------------------------- sub www_deleteField { my ($output); diff --git a/lib/WebGUI/Wobject/MessageBoard.pm b/lib/WebGUI/Wobject/MessageBoard.pm index 1aac3de26..4e0667752 100644 --- a/lib/WebGUI/Wobject/MessageBoard.pm +++ b/lib/WebGUI/Wobject/MessageBoard.pm @@ -46,15 +46,6 @@ sub duplicate { WebGUI::Discussion::duplicate($_[0]->get("wobjectId"),$w->get("wobjectId")); } -#------------------------------------------------------------------- -sub new { - my ($self, $class, $property); - $class = shift; - $property = shift; - $self = WebGUI::Wobject->new($property); - bless $self, $class; -} - #------------------------------------------------------------------- sub purge { WebGUI::Discussion::purge($_[0]->get("wobjectId")); @@ -75,34 +66,6 @@ sub www_approvePost { } } -#------------------------------------------------------------------- -sub www_copy { - if (WebGUI::Privilege::canEditPage()) { - $_[0]->duplicate; - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } -} - -#------------------------------------------------------------------- -sub www_deleteMessage { - if (WebGUI::Discussion::canEditMessage($_[0],$session{form}{mid})) { - return WebGUI::Discussion::deleteMessage(); - } else { - return WebGUI::Privilege::insufficient(); - } -} - -#------------------------------------------------------------------- -sub www_deleteMessageConfirm { - if (WebGUI::Discussion::canEditMessage($_[0],$session{form}{mid})) { - return WebGUI::Discussion::deleteMessageConfirm(); - } else { - return WebGUI::Privilege::insufficient(); - } -} - #------------------------------------------------------------------- sub www_denyPost { if (WebGUI::Privilege::isInGroup($_[0]->get("groupToModerate"))) { diff --git a/lib/WebGUI/Wobject/Poll.pm b/lib/WebGUI/Wobject/Poll.pm index 329d7ca91..9bf46ba8a 100644 --- a/lib/WebGUI/Wobject/Poll.pm +++ b/lib/WebGUI/Wobject/Poll.pm @@ -69,15 +69,6 @@ sub duplicate { $sth->finish; } -#------------------------------------------------------------------- -sub new { - my ($self, $class, $property); - $class = shift; - $property = shift; - $self = WebGUI::Wobject->new($property); - bless $self, $class; -} - #------------------------------------------------------------------- sub purge { WebGUI::SQL->write("delete from Poll_answer where wobjectId=".$_[0]->get("wobjectId")); @@ -89,16 +80,6 @@ sub set { $_[0]->SUPER::set($_[1],[qw(active karmaPerVote graphWidth voteGroup question randomizeAnswers a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20)]); } -#------------------------------------------------------------------- -sub www_copy { - if (WebGUI::Privilege::canEditPage()) { - $_[0]->duplicate; - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } -} - #------------------------------------------------------------------- sub www_edit { my ($f, $i, $output, $active, $voteGroup, $graphWidth, $answers, $randomizeAnswers); diff --git a/lib/WebGUI/Wobject/Product.pm b/lib/WebGUI/Wobject/Product.pm index eaa76ee21..8b80eb76a 100644 --- a/lib/WebGUI/Wobject/Product.pm +++ b/lib/WebGUI/Wobject/Product.pm @@ -169,15 +169,6 @@ sub duplicate { $sth->finish; } -#------------------------------------------------------------------- -sub new { - my ($self, $class, $property); - $class = shift; - $property = shift; - $self = WebGUI::Wobject->new($property); - bless $self, $class; -} - #------------------------------------------------------------------- sub purge { WebGUI::SQL->write("delete from Product_accessory where wobjectId=".$_[0]->get("wobjectId")." @@ -281,16 +272,6 @@ sub www_addRelatedSave { } } -#------------------------------------------------------------------- -sub www_copy { - if (WebGUI::Privilege::canEditPage()) { - $_[0]->duplicate; - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } -} - #------------------------------------------------------------------- sub www_copyTemplate { my (%data); diff --git a/lib/WebGUI/Wobject/SQLReport.pm b/lib/WebGUI/Wobject/SQLReport.pm index 00553d033..f4ce44b11 100644 --- a/lib/WebGUI/Wobject/SQLReport.pm +++ b/lib/WebGUI/Wobject/SQLReport.pm @@ -46,30 +46,11 @@ sub duplicate { }); } -#------------------------------------------------------------------- -sub new { - my ($self, $class, $property); - $class = shift; - $property = shift; - $self = WebGUI::Wobject->new($property); - bless $self, $class; -} - #------------------------------------------------------------------- sub set { $_[0]->SUPER::set($_[1],[qw(template dbQuery DSN username identifier convertCarriageReturns paginateAfter preprocessMacros debugMode)]); } -#------------------------------------------------------------------- -sub www_copy { - if (WebGUI::Privilege::canEditPage()) { - $_[0]->duplicate; - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } -} - #------------------------------------------------------------------- sub www_edit { my ($output, $f, $dsn, $username, $paginateAfter); diff --git a/lib/WebGUI/Wobject/SiteMap.pm b/lib/WebGUI/Wobject/SiteMap.pm index 0e4d8a2a0..831e72de0 100644 --- a/lib/WebGUI/Wobject/SiteMap.pm +++ b/lib/WebGUI/Wobject/SiteMap.pm @@ -71,30 +71,11 @@ sub duplicate { }); } -#------------------------------------------------------------------- -sub new { - my ($self, $class, $property); - $class = shift; - $property = shift; - $self = WebGUI::Wobject->new($property); - bless $self, $class; -} - #------------------------------------------------------------------- sub set { $_[0]->SUPER::set($_[1],[qw(startAtThisLevel displaySynopsis indent bullet lineSpacing depth)]); } -#------------------------------------------------------------------- -sub www_copy { - if (WebGUI::Privilege::canEditPage()) { - $_[0]->duplicate; - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } -} - #------------------------------------------------------------------- sub www_edit { my ($output, $f, $indent, $bullet, $lineSpacing); diff --git a/lib/WebGUI/Wobject/SyndicatedContent.pm b/lib/WebGUI/Wobject/SyndicatedContent.pm index 2c912e415..428527471 100644 --- a/lib/WebGUI/Wobject/SyndicatedContent.pm +++ b/lib/WebGUI/Wobject/SyndicatedContent.pm @@ -38,30 +38,11 @@ sub duplicate { }); } -#------------------------------------------------------------------- -sub new { - my ($self, $class, $property); - $class = shift; - $property = shift; - $self = WebGUI::Wobject->new($property); - bless $self, $class; -} - #------------------------------------------------------------------- sub set { $_[0]->SUPER::set($_[1], [qw(rssUrl content lastFetched)]); } -#------------------------------------------------------------------- -sub www_copy { - if (WebGUI::Privilege::canEditPage()) { - $_[0]->duplicate; - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } -} - #------------------------------------------------------------------- sub www_edit { my ($output, $f); diff --git a/lib/WebGUI/Wobject/UserSubmission.pm b/lib/WebGUI/Wobject/UserSubmission.pm index d68b2eb89..b8d91f66e 100644 --- a/lib/WebGUI/Wobject/UserSubmission.pm +++ b/lib/WebGUI/Wobject/UserSubmission.pm @@ -218,15 +218,6 @@ sub duplicate { $sth->finish; } -#------------------------------------------------------------------- -sub new { - my ($self, $class, $property); - $class = shift; - $property = shift; - $self = WebGUI::Wobject->new($property); - bless $self, $class; -} - #------------------------------------------------------------------- sub purge { WebGUI::SQL->write("delete from UserSubmission_submission where wobjectId=".$_[0]->get("wobjectId")); @@ -265,16 +256,6 @@ sub www_approveSubmission { } } -#------------------------------------------------------------------- -sub www_copy { - if (WebGUI::Privilege::canEditPage()) { - $_[0]->duplicate; - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } -} - #------------------------------------------------------------------- sub www_deleteAttachment { my ($owner); @@ -299,24 +280,6 @@ sub www_deleteImage { } } -#------------------------------------------------------------------- -sub www_deleteMessage { - if (WebGUI::Discussion::canEditMessage($_[0],$session{form}{mid})) { - return WebGUI::Discussion::deleteMessage(); - } else { - return WebGUI::Privilege::insufficient(); - } -} - -#------------------------------------------------------------------- -sub www_deleteMessageConfirm { - if (WebGUI::Discussion::canEditMessage($_[0],$session{form}{mid})) { - return WebGUI::Discussion::deleteMessageConfirm(); - } else { - return WebGUI::Privilege::insufficient(); - } -} - #------------------------------------------------------------------- sub www_deleteSubmission { my ($output, $owner); diff --git a/lib/WebGUI/Wobject/WobjectProxy.pm b/lib/WebGUI/Wobject/WobjectProxy.pm index b399d1c6c..4ff840076 100644 --- a/lib/WebGUI/Wobject/WobjectProxy.pm +++ b/lib/WebGUI/Wobject/WobjectProxy.pm @@ -36,30 +36,11 @@ sub duplicate { }); } -#------------------------------------------------------------------- -sub new { - my ($self, $class, $property); - $class = shift; - $property = shift; - $self = WebGUI::Wobject->new($property); - bless $self, $class; -} - #------------------------------------------------------------------- sub set { $_[0]->SUPER::set($_[1],[qw(proxiedWobjectId)]); } -#------------------------------------------------------------------- -sub www_copy { - if (WebGUI::Privilege::canEditPage()) { - $_[0]->duplicate; - return ""; - } else { - return WebGUI::Privilege::insufficient(); - } -} - #------------------------------------------------------------------- sub www_edit { my ($output, $f, $startDate, $endDate, $templatePosition,%wobjects, %page, %wobject, $a, $b);