Fixing require loops. Moose overrides for canEdit using packages.

This commit is contained in:
Colin Kuskie 2010-04-08 15:13:13 -07:00
parent d69ed84fd4
commit c835344813
14 changed files with 69 additions and 60 deletions

View file

@ -150,12 +150,13 @@ group to edit the parent Map are allowed to edit MapPoint.
=cut
sub canEdit {
around canEdit => sub {
my $orig = shift;
my $self = shift;
my $userId = shift || $self->session->user->userId;
return 1 if $userId eq $self->ownerUserId;
return $self->SUPER::canEdit( $userId );
}
return $self->$orig( $userId );
};
#-------------------------------------------------------------------

View file

@ -200,11 +200,12 @@ can manage the parent you can edit this Shortcut.
=cut
sub canEdit {
my $self = shift;
return 1 if ($self->SUPER::canEdit || ($self->isDashlet && $self->getParent->canManage));
return 0;
}
around canEdit => sub {
my $orig = shift;
my $self = shift;
return 1 if ($self->$orig(@_) || ($self->isDashlet && $self->getParent->canManage));
return 0;
};
#-------------------------------------------------------------------

View file

@ -136,16 +136,17 @@ You can't add children to a Story.
=cut
sub canEdit {
around canEdit => sub {
my $orig = shift;
my $self = shift;
my $userId = shift || $self->session->user->userId;
if ($userId eq $self->ownerUserId) {
return 1;
}
my $user = WebGUI::User->new($self->session, $userId);
return $self->SUPER::canEdit($userId)
return $self->$orig($userId)
|| $self->getArchive->canPostStories($userId);
}
};
#-------------------------------------------------------------------

View file

@ -412,7 +412,8 @@ around the canEdit check when www_editSave is being used to add an asset).
=cut
sub canEdit {
around canEdit => sub {
my $orig = shift;
my $self = shift;
my $userId = shift || $self->session->user->userId;
my $form = $self->session->form;
@ -430,13 +431,13 @@ sub canEdit {
);
# Who can edit the Calendar can do everything
if ( $self->SUPER::canEdit( $userId ) ) {
if ( $self->$orig( $userId ) ) {
return 1;
}
# Fails all checks
return 0;
}
};
#----------------------------------------------------------------------------

View file

@ -715,24 +715,25 @@ the current session user.
=cut
sub canEdit {
my $self = shift;
my $userId = shift || $self->session->user->userId;
return (
(
(
$self->session->form->process("func") eq "add" ||
(
$self->session->form->process("assetId") eq "new" &&
$self->session->form->process("func") eq "editSave" &&
$self->session->form->process("class") eq "WebGUI::Asset::Post::Thread"
)
) &&
$self->canStartThread( $userId )
) || # account for new threads
$self->next::method( $userId )
);
}
around canEdit => sub {
my $orig = shift;
my $self = shift;
my $userId = shift || $self->session->user->userId;
return (
(
(
$self->session->form->process("func") eq "add" ||
(
$self->session->form->process("assetId") eq "new" &&
$self->session->form->process("func") eq "editSave" &&
$self->session->form->process("class") eq "WebGUI::Asset::Post::Thread"
)
) &&
$self->canStartThread( $userId )
) || # account for new threads
$self->$orig( $userId )
);
};
#-------------------------------------------------------------------

View file

@ -266,12 +266,14 @@ part of the C<groupToAdd> group.
=cut
sub canEdit {
my $self = shift;
my $orig = shift;
my $self = shift;
my $userId = shift || $self->session->user->userId;
my $form = $self->session->form;
if ( $form->get('func') eq "editSave" && $form->get('assetId') eq "new" && $form->get( 'class' )->isa(
'WebGUI::Asset::MatrixListing' ) ) {
my $form = $self->session->form;
if ( $form->get('func') eq "editSave"
&& $form->get('assetId') eq "new"
&& $form->get( 'class' )->isa( 'WebGUI::Asset::MatrixListing' ) ) {
return $self->canAddMatrixListing();
}
else {

View file

@ -402,23 +402,24 @@ Overriding canEdit method to check permissions correctly when someone is adding
=cut
sub canEdit {
my $self = shift;
return (
(
(
$self->session->form->process("func") eq "add" ||
(
$self->session->form->process("assetId") eq "new" &&
$self->session->form->process("func") eq "editSave" &&
$self->session->form->process("class") eq "WebGUI::Asset::WikiPage"
)
) &&
$self->canEditPages
) || # account for new posts
$self->next::method()
);
}
around canEdit => sub {
my $orig = shift;
my $self = shift;
return (
(
(
$self->session->form->process("func") eq "add" ||
(
$self->session->form->process("assetId") eq "new" &&
$self->session->form->process("func") eq "editSave" &&
$self->session->form->process("class") eq "WebGUI::Asset::WikiPage"
)
) &&
$self->canEditPages
) || # account for new posts
$self->$orig(@_)
);
};
#-------------------------------------------------------------------