Prevent Event, WikiPage and Thread from being pasted places where they don't

belong.  This allows chained method calls to "getMyParent", getParent, getWiki, getCalendar, etc.
to work.
Adds the new canPaste and validParent method to Asset and AssetClipboard.
This commit is contained in:
Colin Kuskie 2009-02-03 04:43:11 +00:00
parent 151ebbde09
commit 99d6796675
6 changed files with 75 additions and 22 deletions

View file

@ -1855,6 +1855,22 @@ sub update {
}
#-------------------------------------------------------------------
=head2 validParent
Make sure that the current session asset is a Calendar for pasting and adding checks.
This is a class method.
=cut
sub validParent {
my $class = shift;
my $session = shift;
return $session->asset->isa('WebGUI::Asset::Wobject::Calendar');
}
####################################################################
=head2 view

View file

@ -868,6 +868,22 @@ sub updateThreadRating {
}
#-------------------------------------------------------------------
=head2 validParent
Make sure that the current session asset is a CS for pasting and adding checks.
This is a class method.
=cut
sub validParent {
my $class = shift;
my $session = shift;
return $session->asset->isa('WebGUI::Asset::Wobject::Collaboration');
}
#-------------------------------------------------------------------
sub view {
my $self = shift;

View file

@ -51,11 +51,9 @@ sub addRevision {
#-------------------------------------------------------------------
sub canAdd {
my $class = shift;
my $session = shift;
my $assetCanAdd = $class->next::method($session, undef, '7');
my $parentCheck = $session->asset->isa('WebGUI::Asset::Wobject::WikiPage');
return $assetCanAdd && $parentCheck;
my $class = shift;
my $session = shift;
return $class->next::method($session, undef, '7');
}
#-------------------------------------------------------------------
@ -73,20 +71,6 @@ sub canEdit {
|| ( $wiki->canEditPages && ( $addNew || $editSave || !$self->isProtected) );
}
#-------------------------------------------------------------------
=head2 canPaste
Since so much of the Wiki Page depends on the Wiki Master, do not allow it
to be pasted to anywhere but a WikiMaster.
=cut
sub canPaste {
my $self = shift;
return $self->session->asset->isa('WebGUI::Asset::Wobject::WikiMaster');
}
#-------------------------------------------------------------------
sub definition {
my $class = shift;
@ -335,6 +319,22 @@ sub update {
return $self->next::method($properties);
}
#-------------------------------------------------------------------
=head2 validParent
Make sure that the current session asset is a WikiMaster for pasting and adding checks.
This is a class method.
=cut
sub validParent {
my $class = shift;
my $session = shift;
return $session->asset->isa('WebGUI::Asset::Wobject::WikiMaster');
}
#-------------------------------------------------------------------
sub view {
my $self = shift;