diff --git a/lib/WebGUI/Content/FilePump.pm b/lib/WebGUI/Content/FilePump.pm index 937a07d66..5964bfef0 100644 --- a/lib/WebGUI/Content/FilePump.pm +++ b/lib/WebGUI/Content/FilePump.pm @@ -36,15 +36,15 @@ sub handler { my ($session) = @_; my $output = undef; return undef unless $session->form->get('op') eq 'filePump'; - my $method = $session->form->get( 'method' ) - ? 'www_' . $session->form->get( 'method' ) + my $func = $session->form->get( 'func' ) + ? 'www_' . $session->form->get( 'func' ) : 'www_manage' ; - if ($method ne "www_" && (my $sub = WebGUI::FilePump::Admin->can($method))) { + if ($func ne "www_" && (my $sub = WebGUI::FilePump::Admin->can($func))) { $output = $sub->($session); } else { - WebGUI::Error::MethodNotFound->throw(error=>"Couldn't call non-existant method $method inside FilePump", method=>$method); + WebGUI::Error::MethodNotFound->throw(error=>"Couldn't call non-existant function $func inside FilePump", method=>$func); } return $output; } diff --git a/lib/WebGUI/FilePump/Admin.pm b/lib/WebGUI/FilePump/Admin.pm index ba01a7c08..55828d957 100644 --- a/lib/WebGUI/FilePump/Admin.pm +++ b/lib/WebGUI/FilePump/Admin.pm @@ -31,7 +31,68 @@ the current user. sub canView { my $session = shift; my $user = shift || $session->user; - return $user->isInGroup( 3 ); + return $user->isInGroup( $session->setting->get('groupIdAdminFilePump') ); +} + +#------------------------------------------------------------------- + +=head2 www_addBundle ( ) + +Displays a form to add a bundle. + +Note, we do not allow bundle names to be edited. This is why. The directory to a bundle is based on +the bundle name, and the time stamp of the last build. If you change the name, then you have a few +options. + +1) You delete the build directory with the old name, which will break every macro which references it. + +2) You leave it there, which means that they accumulate with time since they can't every be deleted because +you don't know the old name. + +In short, this really means that instead of an option to edit the name, it needs a copy function. When you +copy the bundle, it asks you what you want for a new name, and it is supplied by the user at that time. + +=cut + +sub www_addBundle { + my ($session) = @_; + return $session->privilege->insufficient() unless canView($session); + + ##Build the form + my $i18n = WebGUI::International->new($session, 'FilePump'); + my $form = WebGUI::HTMLForm->new($session); + $form->hidden( name=>"op", value=>"filePump"); + $form->hidden( name=>"func", value=>"addBundleSave"); + $form->text( + name => 'bundleName', + defaultValue => $i18n->get('new bundle'), + label => $i18n->get('bundle name'), + hoverHelp => $i18n->get('bundle name help'), + ); + $form->submit; + + my $ac = WebGUI::AdminConsole->new($session,'filePump'); + return $ac->render($form->print, $i18n->get('Add Bundle')); +} + +#------------------------------------------------------------------- + +=head2 www_addBundleSave ( ) + +Saves the results of www_addBundle(). + +=cut + +sub www_addBundleSave { + my $session = shift; + return $session->privilege->insufficient() unless canView($session); + my $form = $session->form; + my $bundleName = $form->get('bundleName'); + my $bundle = WebGUI::FilePump::Bundle->create($session, { + bundleName => $bundleName, + lastModified => time(), + }); + return www_manage($session); } #------------------------------------------------------------------- @@ -74,64 +135,6 @@ sub www_demoteFile { return www_manage($session); } -#------------------------------------------------------------------- - -=head2 www_editBundle ( ) - -Displays a form to add or edit a bundle. - -=cut - -sub www_editBundle { - my ($session, $error) = @_; - return $session->privilege->insufficient() unless canView($session); - - if ($error) { - $error = qq|
| %s |
|---|