EPrints Technical Mailing List Archive

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

Message: #05704


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

Re: [EP-tech] Adding user messages from CGI


Interesting.  I had thought it was easier than this, but a scan of the code shows that this is, indeed, what's happening.  It's used 'officially' only a couple of times, but the key example is when you take an edit lock from someone it shows them a message (see https://github.com/eprints/eprints/blob/33a7bb8a8b3f80ba02ddd6618eb4e7dc3209ec68/perl_lib/EPrints/Plugin/Screen/EPrint/TakeLock.pm#L72 )

I would, however, say that if you're having to jump through hoops like this, your approach may be wrong.  The screen plugin infrastructure is there to manage things like this.  What are you doing with the cgi script, and why can't it be a screen plugin?


 

Jisc

Adam Field
SHERPA services analyst developer


From: <eprints-tech-bounces@ecs.soton.ac.uk> on behalf of "Alan.Stiles" <alan.stiles@open.ac.uk>
Reply-To: "eprints-tech@ecs.soton.ac.uk" <eprints-tech@ecs.soton.ac.uk>
Date: Monday, 16 May 2016 10:37
To: "eprints-tech@ecs.soton.ac.uk" <eprints-tech@ecs.soton.ac.uk>
Subject: Re: [EP-tech] Adding user messages from CGI

Thanks for the response Yuri, but I'm trying to add a 'job done' message for the user to see once they have been sent back to their home deposit screen, rather than generate the appropriate HTML to render immediately.

However, as so often seems to happen, I think I've got an answer, assuming the user visiting the cgi is logged in:

my $repo = new EPrints::Session;
my $db = $repo->database;
my $current_user = $repo->current_user();
my $xml_dom_value = $current_user->render_value( "name" );  # render the user name as an example

$db->save_user_message($current_user->get_value( "userid" ),
"message",
$repo->html_phrase("html_phrase_id", ("pin_name"=>$xml_dom_value)));


I'll try and find somewhere useful on the Wiki to add it.

Cheers,
Alan



-----Original Message-----
Sent: 16 May 2016 10:14
Subject: Re: [EP-tech] Adding user messages from CGI

from cgi/logout:

$page->appendChild( $session->render_message(
    "message",
    $session->make_text( "Logout OK!" ) ) );

add_message works only in plugins, and it calls $session->render_message anyway.

Il 16/05/2016 10:58, Alan.Stiles ha scritto:

Any clue if there is a function to add a message to the message queue
from a cgi script?  I can use $self->{processor}->add_message() from
within a plugin but how do I do this without a '$self' ?

Cheers,

Alan

-- The Open University is incorporated by Royal Charter (RC 000391),
an exempt charity in England & Wales and a charity registered in
Scotland (SC 038302). The Open University is authorised and regulated
by the Financial Conduct Authority.


*** Options:
*** EPrints community wiki: http://wiki.eprints.org/
*** EPrints developers Forum: http://forum.eprints.org/

*** EPrints community wiki: http://wiki.eprints.org/
*** EPrints developers Forum: http://forum.eprints.org/
-- The Open University is incorporated by Royal Charter (RC 000391), an exempt charity in England & Wales and a charity registered in Scotland (SC 038302). The Open University is authorised and regulated by the Financial Conduct Authority.

*** EPrints community wiki: http://wiki.eprints.org/
*** EPrints developers Forum: http://forum.eprints.org/



Jisc is a registered charity (number 1149740) and a company limited by guarantee which is registered in England under Company No. 5747339, VAT No. GB 197 0632 86. Jisc’s registered office is: One Castlepark, Tower Hill, Bristol, BS2 0JA. T 0203 697 5800.

Jisc Services Limited is a wholly owned Jisc subsidiary and a company limited by guarantee which is registered in England under company number 2881024, VAT number GB 197 0632 86. The registered office is: One Castle Park, Tower Hill, Bristol BS2 0JA. T 0203 697 5800.