How to make a Screen for the Admin Section

From EPrints Documentation
Jump to: navigation, search
Known to work for EPrints 3.2+ 

The basic structure

To make a Screen plugin, you create a Perl Module in [eprints]/archives/<ARCHIVE_ID>/cfg/plugins/EPrints/Plugin/Screen/ with the following basic structure


package EPrints::Plugin::Screen::Mypackage;

use EPrints::Plugin::Screen;

@ISA = ( 'EPrints::Plugin::Screen' );

use strict;

sub new
{
	my( $class, %params ) = @_;
	my $self = $class->SUPER::new(%params);
	$self->{priv} = undef;
	$self->{appears} = [
		{ 
			place => "admin_actions_editorial", # see notes below
			position => 1450, 
		},
	];
	return $self;
}

sub can_be_viewed
{
	my( $self ) = @_;
	return $self->allow( "my/conf/value" );
}

sub render
{
	my( $self ) = @_;
	my $session = $self->{session};
        my $user = $session->current_user;

        my $p = $session->make_doc_fragment;

        # create page contents:
        my $h = $session->make_element( "h3" );
        $h->appendChild($session->make_text( "Look up organisations known to OA-RJ" ));
        $p->appendChild($h);

	return $p
}

In theory, one should be able to have multiple bits of functionality (view a little, view a lot, edit, etc), simply by testing for different values of $self->allow( "my/conf/value" )

The locations

Where the link for the page appears is defined by $self->{appears}->[n]->{place} (in the new function.)

We are defining a screen that appears in the "admin" area, and there are 4 tabs defined within the admin screen:

  • admin_actions_editorial
  • admin_actions_system
  • admin_actions_config
  • admin_actions_misc

Other places the link can appear are

  • unknown to me

Making the page appear

There are three steps to making a page appear:

1. The screen plugin should test for view-ability

# in EPrints::Plugin::Screen::Mypackage
sub can_be_viewed
{
	my( $self ) = @_;
	return $self->allow( "my/conf/value" );
}

2 The User DataObject needs to list the privilege under a role:

  # In EPrints::DataObj::User
  foo_bar => [
    "my/view/value",
  ],
  foo_baz => [
    "my/view/value",
    "my/conf/value",
  ],

3 The user_roles.pl file needs to make the role available to the user-type:

# in [eprints]/archive/<ARCHIVE_ID>/cfg/cfg/user_roles.pl
$c->{user_roles}->{user} = [qw{
	// truncated
	foo_bar
}],
$c->{user_roles}->{admin} = [qw{
        // truncated
	foo_baz
}],

Return to the main Screen_Plugins page.

See Also