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:
parent
151ebbde09
commit
99d6796675
6 changed files with 75 additions and 22 deletions
|
|
@ -9,6 +9,8 @@
|
|||
- fixed #9603: moving wiki page
|
||||
- fixed #9302: Spectre Problem...
|
||||
- fixed #9635: Matrix - Add attributes not working
|
||||
- fixed: Many child assets, including WikiPage, Post and Event, will no longer let you add or paste them in places
|
||||
where they do not belong.
|
||||
|
||||
7.6.10
|
||||
- fixed #9577: WebGUI::Form::Url::getValue returns blank rather than undef for blank fields
|
||||
|
|
|
|||
|
|
@ -182,7 +182,8 @@ sub assetExists {
|
|||
|
||||
=head2 canAdd ( session, [userId, groupId] )
|
||||
|
||||
Verifies that the user has the privileges necessary to add this type of asset. Return a boolean.
|
||||
Verifies that the user has the privileges necessary to add this type of asset and that the requested asset
|
||||
can be added as a child of this asset. Return a boolean.
|
||||
|
||||
A class method.
|
||||
|
||||
|
|
@ -224,7 +225,8 @@ sub canAdd {
|
|||
my $subclassGroupId = shift;
|
||||
my $addPrivsGroup = $session->config->get("assets/".$className."/addGroup");
|
||||
my $groupId = $addPrivsGroup || $subclassGroupId || '12';
|
||||
return $user->isInGroup($groupId);
|
||||
my $validParent = $className->validParent($session);
|
||||
return $user->isInGroup($groupId) && $validParent;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2431,6 +2433,22 @@ sub urlExists {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 validParent ( )
|
||||
|
||||
Make sure that the current session asset is a valid parent for the child and return true or false.
|
||||
For example, a WikiPage would check for a WikiMaster. It should be overridden by those children
|
||||
that need to perform that kind of check.
|
||||
|
||||
This is a class method.
|
||||
|
||||
=cut
|
||||
|
||||
sub validParent {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 view ( )
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@ paste a wiki page anywhere else but a wiki master.
|
|||
=cut
|
||||
|
||||
sub canPaste {
|
||||
return 1;
|
||||
my $self = shift;
|
||||
return $self->validParent($self->session); ##Lazy call to a class method
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue