EPrints Technical Mailing List Archive

See the EPrints wiki for instructions on how to join this mailing list and related information.

Message: #10321


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

RE: [EP-tech] Custom Error Message for Screen Access / IRStats


CAUTION: This e-mail originated outside the University of Southampton.

Hi Tomasz,
I’ve added a ‘StaticContent’ view module to IRStats2:
https://github.com/eprintsug/irstats2/blob/static-content/plugins/EPrints/Plugin/Stats/View/StaticContent.pm
(and enabled like this: https://github.com/eprintsug/irstats2/blob/static-content/cfg.d/z_irstats2.pl#L532 )

This allows you to define phrases to display as the homepage of IRStats2:

main => {

    items => [

        {

            plugin => 'StaticContent',

            options => {

                ### title_phrase => 'main_report_title',

                page_phrase => 'main_report_page',

                ### container_class => 'bob',

                ### title_class => 'wibble',

            },

        },

        {

            plugin => 'StaticContent',

                options => {

                    title_phrase => 'guide_to_stats_title',

                    page_phrase => 'guide_to_stats_content',

                },

        },

    ],

    category => 'general',

},

 

You would have to check how this works alongside the user-restriction (auth_report) stuff.

 

Cheers,

John

John Salter

https://orcid.org/0000-0002-8611-8266

 

White Rose Libraries Technical Officer
Library and Research Management team, IT
University of Leeds

 

 

 

From: eprints-tech-request@ecs.soton.ac.uk <eprints-tech-request@ecs.soton.ac.uk> On Behalf Of David R Newman
Sent: 22 January 2026 17:03
To: Tomasz Neugebauer <Tomasz.Neugebauer@concordia.ca>; eprints-tech@ecs.soton.ac.uk
Subject: Re: [EP-tech] Custom Error Message for Screen Access / IRStats

 

CAUTION: External Message. Use caution opening links and attachments.

Hi Tomasz,

 

Customising this message is not straightforward as this message comes from the screen processor which is quite low level in the codebase.  I assume when you are talking about a "user" you mean a visitor to your repository who is not logged in.  Therefore, the best option is to edit IRStats2 cgi/stats report script.  This looks something like:

 

use EPrints;
use EPrints::ScreenProcessor;

use strict;

my $session = EPrints::Session->new();
exit( 0 ) unless( defined $session );

EPrints::ScreenProcessor->process(
        session => $session,
        screenid => "IRStats2::Report",
);

$session->terminate;

If you put some code before the EPrints::ScreenProcessor line that checks if the is a currently logged in user.  You could then redirect the user to a static page to warn the user they need to be logged in to have access.  There are other approaches but I think this requires only a minimal change to the codebase and a stand-alone static page that cannot interfere with anything else.

 

Regards

 

David Newman

 

On 22/01/2026 16:53, Tomasz Neugebauer wrote:

CAUTION: This e-mail originated outside the University of Southampton.

Hi everyone,

 

I'm in the process of putting IRStats2 behind a login, and it's going well, but I've had nothing but failure in my attempts to customize the error message that the user receives when they attempt to access the stats without logging in.  Right now, after adding specific permissions for IRStats, something ike this:

 

push @{$c->{user_roles}->{user}}, "+irstats2/view";
push @{$c->{user_roles}->{user}}, "+irstats2/export";

 

and a custom $c->{irstats2}->{allow} = sub for IRStats, we can control the access, but the default error message when a user attempts to view the stats is not ideal, it's just the default:

 

Error: You may not view this screen: IRStats2::Report.

 

I would like to customize this message to say something informative (referring to a "screen" here is not exactly user friendly) for example, "Access to statistics is restricted to logged in users."

 

I have tried so many different ways to get that custom message to display, and nothing has worked! 

 

I know that IRStats2 code has been updated recently, without a push to the bazaar, so I'm not entirely sure just how up-to-date our code is for that.  I've been waiting for the bazaar version of the plugin, but perhaps that's not the best strategy.  I doubt that this is addressed in any of those recent commits, but let me know if it is.  

 

Tomasz

 

________________________________________________

Tomasz Neugebauer
Senior Librarian | Bibliothécaire titulaire
Digital Projects & Systems Development Librarian / Bibliothécaire des Projets Numériques & Développement de Systèmes
Concordia University / Université Concordia

Tel. / Tél. 514-848-2424 ext. / poste 7738
Email / courriel:
tomasz.neugebauer@concordia.ca

Mailing address / adresse postale: 1455 De Maisonneuve Blvd. W., LB-540-03, Montreal, Quebec H3G 1M8
Street address / adresse municipale: 1400 De Maisonneuve Blvd. W., LB-540-03, Montreal, Quebec H3G 1M8

library.concordia.ca