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

@ -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 ( )