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

@ -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(@_)
);
};
#-------------------------------------------------------------------