fix problems with gallery URLs. fixed disk space check. added error messages to photo template
This commit is contained in:
parent
5b467483f5
commit
58417faf8a
9 changed files with 84 additions and 2 deletions
Binary file not shown.
|
|
@ -653,9 +653,15 @@ sub processCommentEditForm {
|
|||
|
||||
sub processPropertiesFromFormPost {
|
||||
my $self = shift;
|
||||
my $i18n = __PACKAGE__->i18n( $self->session );
|
||||
my $form = $self->session->form;
|
||||
my $errors = $self->SUPER::processPropertiesFromFormPost || [];
|
||||
|
||||
# Make sure we have the disk space for this
|
||||
if ( !$self->getGallery->hasSpaceAvailable( $self->get( 'assetSize' ) ) ) {
|
||||
push @{ $errors }, $i18n->get( "error no space" );
|
||||
}
|
||||
|
||||
# Return if errors
|
||||
return $errors if @$errors;
|
||||
|
||||
|
|
@ -668,6 +674,11 @@ sub processPropertiesFromFormPost {
|
|||
} );
|
||||
}
|
||||
|
||||
# Fix URLs
|
||||
$self->update( {
|
||||
url => $self->getParent->get( "url" ) . '/' . $self->session->url->urlize( $self->get( "menuTitle" ) )
|
||||
} );
|
||||
|
||||
$self->requestAutoCommit;
|
||||
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -506,6 +506,15 @@ sub www_edit {
|
|||
url_addArchive => $self->getParent->getUrl('func=addArchive'),
|
||||
url_album => $self->getParent->getUrl('func=album'),
|
||||
};
|
||||
|
||||
# Process errors if any
|
||||
if ( $session->stow->get( 'editFormErrors' ) ) {
|
||||
for my $error ( @{ $session->stow->get( 'editFormErrors' ) } ) {
|
||||
push @{ $var->{ errors } }, {
|
||||
error => $error,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if ( $form->get('func') eq "add" ) {
|
||||
$var->{ isNewPhoto } = 1;
|
||||
|
|
|
|||
|
|
@ -812,6 +812,46 @@ sub getUserFilePaginator {
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 hasSpaceAvailable ( spaceWanted [, userId ] )
|
||||
|
||||
Returns true if the user has at least the specified bytes of C<spaceWanted>
|
||||
available to use in this Gallery.
|
||||
|
||||
=cut
|
||||
|
||||
sub hasSpaceAvailable {
|
||||
my $self = shift;
|
||||
my $spaceWanted = shift;
|
||||
my $userId = shift || $self->session->user->userId;
|
||||
|
||||
# If we don't care, just return
|
||||
return 1 if ( $self->get( "maxSpacePerUser" ) == 0 );
|
||||
|
||||
my $db = $self->session->db;
|
||||
|
||||
# Compile the amount of disk space used
|
||||
my $maxSpace = $self->get( "maxSpacePerUser" ) * ( 1_024 ** 2 ); # maxSpacePerUser is in MB
|
||||
my $spaceUsed = 0;
|
||||
my $fileIds
|
||||
= $self->getLineage( [ 'descendants' ], {
|
||||
joinClass => 'WebGUI::Asset::File::GalleryFile',
|
||||
whereClause => 'ownerUserId = ' . $db->quote( $userId ),
|
||||
} );
|
||||
|
||||
for my $assetId ( @{ $fileIds } ) {
|
||||
my $asset = WebGUI::Asset->newByDynamicClass( $self->session, $assetId );
|
||||
next unless $asset;
|
||||
$spaceUsed += $asset->get( 'assetSize' );
|
||||
|
||||
return 0 if ( $spaceUsed + $spaceWanted >= $maxSpace );
|
||||
}
|
||||
|
||||
# We must have enough space
|
||||
return 1;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 prepareView ( )
|
||||
|
||||
See WebGUI::Asset::prepareView() for details.
|
||||
|
|
|
|||
|
|
@ -649,6 +649,10 @@ sub processPropertiesFromFormPost {
|
|||
return $errors if @$errors;
|
||||
|
||||
### Passes all checks
|
||||
# Fix URLs
|
||||
$self->update( {
|
||||
url => $self->getParent->get( "url" ) . '/' . $self->session->url->urlize( $self->get( "menuTitle" ) )
|
||||
} );
|
||||
|
||||
$self->requestAutoCommit;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -198,6 +198,16 @@ our $HELP = {
|
|||
title => 'help edit title',
|
||||
body => 'help edit body',
|
||||
variables => [
|
||||
{
|
||||
name => 'errors',
|
||||
description => 'helpvar errors',
|
||||
variables => [
|
||||
{
|
||||
name => 'error',
|
||||
description => 'helpvar error',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name => 'isNewPhoto',
|
||||
description => 'helpvar isNewPhoto',
|
||||
|
|
|
|||
|
|
@ -649,6 +649,12 @@ our $I18N = {
|
|||
context => q{Description of template variable},
|
||||
},
|
||||
|
||||
'error no space' => {
|
||||
message => q{You do not have enough disk space to upload this file.},
|
||||
lastUpdated => 0,
|
||||
context => q{Error when user is out of disk space.},
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ my %oldSettings;
|
|||
# userFunctionStyleId
|
||||
$oldSettings{ userFunctionStyleId } = $session->setting->get( 'userFunctionStyleId' );
|
||||
$session->setting->set( 'userFunctionStyleId', 'PBtmpl0000000000000132' );
|
||||
$oldSettings{ defaultVersionTagWorkflow } = $session->setting->get( 'defaultVersionTagWorkflow' );
|
||||
$session->setting->set( 'defaultVersionTagWorkflow', 'pbworkflow000000000003' );
|
||||
|
||||
# Create a user for testing purposes
|
||||
my $user = WebGUI::User->new( $session, "new" );
|
||||
|
|
@ -54,7 +56,7 @@ my $calendar = $node->addChild( {
|
|||
className => 'WebGUI::Asset::Wobject::Calendar',
|
||||
groupIdEventEdit => '2', # Registered Users
|
||||
groupIdEdit => '3', # Admins
|
||||
workflowIdCommit => 'realtimeworkflow-00001', # Commit content immediately
|
||||
workflowIdCommit => 'pbworkflow000000000003', # Commit Without approval
|
||||
} );
|
||||
|
||||
# Remember this event url when we want to edit it later
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ my $gallery
|
|||
= $node->addChild( {
|
||||
className => 'WebGUI::Asset::Wobject::Gallery',
|
||||
groupIdAddFile => '2', # Registered Users
|
||||
workflowIdCommit => 'realtimeworkflow-00001', # Commit Content Immediately
|
||||
workflowIdCommit => 'pbworkflow000000000003', # Commit Content Immediately
|
||||
} );
|
||||
|
||||
$versionTags[-1]->commit;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue