fixes to the Gallery

This commit is contained in:
Doug Bell 2007-12-18 21:17:44 +00:00
parent 99274cd4ee
commit 53a1cbc7c2
8 changed files with 72 additions and 27 deletions

View file

@ -159,6 +159,19 @@ sub applyConstraints {
#----------------------------------------------------------------------------
=head2 canAdd ( )
Override canAdd to ignore its permissions check. Permissions are handled
by the parent Gallery and other permissions methods.
=cut
sub canAdd {
return 1;
}
#----------------------------------------------------------------------------
=head2 canComment ( [userId] )
Returns true if the user can comment on this asset. C<userId> is a WebGUI
@ -556,12 +569,21 @@ sub prepareView {
sub processPropertiesFromFormPost {
my $self = shift;
my $form = $self->session->form;
my $errors = $self->SUPER::processPropertiesFromFormPost || [];
# Return if errors
return $errors if @$errors;
# Passes all checks
### Passes all checks
# Fix if adding a new photo
if ( $form->get("assetId") eq "new" ) {
$self->update({
ownerUserId => $self->session->user->userId,
});
}
$self->requestAutoCommit;
}

View file

@ -447,18 +447,31 @@ check. If no userId is passed, will check the current user.
Users can edit this gallery if they are part of the C<groupIdEdit> group.
Also checks if a user is adding a GalleryAlbum and allows them to if they are
part of the C<groupIdAddFile> group.
=cut
sub canEdit {
my $self = shift;
my $userId = shift;
my $user = $userId
? WebGUI::User->new( $self->session, $userId )
: $self->session->user
;
my $form = $self->session->form;
return $user->isInGroup( $self->get("groupIdEdit") );
if ( $form->get('func') eq "add" ) {
return $self->canAddFile( $userId );
}
elsif ( $form->get('func') eq "editSave" && $form->get('assetId') eq "new" ) {
return $self->canAddFile( $userId );
}
else {
my $user = $userId
? WebGUI::User->new( $self->session, $userId )
: $self->session->user
;
return $user->isInGroup( $self->get("groupIdEdit") );
}
}
#----------------------------------------------------------------------------

View file

@ -165,6 +165,19 @@ sub appendTemplateVarsFileLoop {
#----------------------------------------------------------------------------
=head2 canAdd ( )
Override canAdd to ignore its permissions check. Permissions are handled
by the parent Gallery and other permissions methods.
=cut
sub canAdd {
return 1;
}
#----------------------------------------------------------------------------
=head2 canAddFile ( [userId] )
Returns true if the user can add a file to this album. C<userId> is a WebGUI
@ -467,12 +480,20 @@ approval workflow.
sub processPropertiesFromFormPost {
my $self = shift;
my $form = $self->session->form;
my $errors = $self->SUPER::processPropertiesFromFormPost || [];
# Return if error
return $errors if @$errors;
# Passes all checks
### Passes all checks
# Fix if adding a new GalleryAlbum
if ( $form->get('assetId') eq "new" ) {
$self->update({
ownerUserId => $self->session->user->userId,
});
}
$self->requestAutoCommit;
}

View file

@ -119,6 +119,7 @@ our $HELP = {
namespace => 'Asset_GalleryAlbum',
},
],
variables => [ ],
},
'help slideshow' => {
@ -134,6 +135,7 @@ our $HELP = {
namespace => 'Asset_GalleryAlbum',
},
],
variables => [ ],
},
'help thumbnails' => {