fixed #12129: AdminBar calls canAdd as an object method
This commit is contained in:
parent
0df9fb747a
commit
c1a29182ca
4 changed files with 31 additions and 3 deletions
|
|
@ -226,6 +226,10 @@ The "turn admin on" group which is group id 12.
|
|||
|
||||
sub canAdd {
|
||||
my $className = shift;
|
||||
|
||||
# just in case we get called as object method
|
||||
$className = $className->get('className') if blessed $className;
|
||||
|
||||
my $session = shift;
|
||||
my $userId = shift || $session->user->userId;
|
||||
my $user = WebGUI::User->new($session, $userId);
|
||||
|
|
|
|||
|
|
@ -160,12 +160,13 @@ sub process {
|
|||
|
||||
# prototypes
|
||||
foreach my $prototype (@{ $session->asset->getPrototypeList }) {
|
||||
next unless ($prototype->canView && $prototype->canAdd($session) && $prototype->getUiLevel <= $userUiLevel);
|
||||
my $class = $prototype->get('className');
|
||||
next unless ($prototype->canView && $class->canAdd($session) && $prototype->getUiLevel <= $userUiLevel);
|
||||
$categories{prototypes}{items} ||= [];
|
||||
push @{$categories{prototypes}{items}}, {
|
||||
title => $prototype->getTitle,
|
||||
url => $asset->getUrl(
|
||||
"func=add;class=".$prototype->get('className').";prototype=".$prototype->getId.$proceed
|
||||
"func=add;class=$class;prototype=".$prototype->getId.$proceed
|
||||
),
|
||||
icon => $prototype->getIcon(1),
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue