[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[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]<http://www.jisc.ac.uk/>

Adam Field
SHERPA services analyst developer


From: <eprints-tech-bounces at ecs.soton.ac.uk<mailto:eprints-tech-bounces at ecs.soton.ac.uk>> on behalf of "Alan.Stiles" <alan.stiles at open.ac.uk<mailto:alan.stiles at open.ac.uk>>
Reply-To: "eprints-tech at ecs.soton.ac.uk<mailto:eprints-tech at ecs.soton.ac.uk>" <eprints-tech at ecs.soton.ac.uk<mailto:eprints-tech at ecs.soton.ac.uk>>
Date: Monday, 16 May 2016 10:37
To: "eprints-tech at ecs.soton.ac.uk<mailto:eprints-tech at ecs.soton.ac.uk>" <eprints-tech at ecs.soton.ac.uk<mailto:eprints-tech at 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-----
From: eprints-tech-bounces at ecs.soton.ac.uk<mailto:eprints-tech-bounces at ecs.soton.ac.uk> [mailto:eprints-tech-bounces at ecs.soton.ac.uk] On Behalf Of Yuri
Sent: 16 May 2016 10:14
To: eprints-tech at ecs.soton.ac.uk<mailto:eprints-tech at ecs.soton.ac.uk>
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:
http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** EPrints community wiki: http://wiki.eprints.org/
*** EPrints developers Forum: http://forum.eprints.org/

*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** 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.

*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** 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.  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/attachments/20160516/e1a96a92/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 6B9928AE-9C97-4E75-8330-7E24168F02D7[3].png
Type: image/png
Size: 1264 bytes
Desc: 6B9928AE-9C97-4E75-8330-7E24168F02D7[3].png
Url : http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/attachments/20160516/e1a96a92/attachment-0001.png