Configuration Buttons For Bazaar Packages

From EPrints Documentation
Jump to: navigation, search

In order to better prompt users to configure Bazaar packages you can add a configure button to the EPrints Bazaar Store on the Installed Page.

An example of this can be found in the AmazonS3 package.

In order to add a configure button you can add a configure method to your EPMC screen as follows:

Step 1 - Allow Configuration

In the package initialisation you need to add "configure" to the "actions" declaration, e.g.

 $self->{actions} = [qw( enable disable configure )];

The respective "allow configuration" method also has to be defined.

 sub allow_configure { shift->can_be_viewed( @_ ) }

Step 2 - Configure configuration

This is the "configure' method, and can be included such that enable and disable methods can be used in conjunction with a re-direct to a plain text (or perl) config file that can be edited using the normal editor.

Again this example is from exif_tool and here you can change cfg.d/exif_import.pl to the path to your config file you wish to allow users to edit.


 sub action_configure
 {
       my( $self ) = @_;
 
       my $epm = $self->{processor}->{dataobj};
       my $epmid = $epm->id;
 
       foreach my $file ($epm->installed_files)
       {
               my $filename = $file->value( "filename" );
               next if $filename !~ m#^epm/$epmid/cfg/cfg\.d/(.*)#;
               my $url = $self->{repository}->current_url( host => 1 );
               $url->query_form(
                       screen => "Admin::Config::View::Perl",
                       configfile => "cfg.d/exif_import.pl",
               );
               $self->{repository}->redirect( $url );
               exit( 0 );
       }
 
       $self->{processor}->{screenid} = "Admin::EPM";
 
       $self->{processor}->add_message( "error", $self->html_phrase( "missing" ) );
 }