EPrints Technical Mailing List Archive
Message: #03283
< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First
[EP-tech] Re: EP_TRIGGER_URL_REWRITE and redirecting to a screen
- To: eprints-tech@ecs.soton.ac.uk
- Subject: [EP-tech] Re: EP_TRIGGER_URL_REWRITE and redirecting to a screen
- From: Sebastien Francois <sf2@ecs.soton.ac.uk>
- Date: Thu, 17 Jul 2014 14:14:25 +0100
Hola,
I think you can pass on the ScreenProcessor / a Screen from your trigger. Something like: $c->add_trigger( EP_TRIGGER_URL_REWRITE, sub { my( %args ) = @_; my( $repository, $uri, $return_code, $request ) = @args{ qw( repository uri return_code request ) }; if( defined $uri && ($uri =~ m# ^/(\d+)/$ #x ) ) { my $eprintid = $1; my $eprint = $repository->dataset( "eprint" )->dataobj( $eprintid ); # this is an overridden 'permit' that does some new things, but still returns a '1' or '0'. my $can_view = $eprint->permit( "eprint/view", $repository->current_user ); #NB current_user may be undef if( $can_view ){ $r->set_handlers( PerlResponseHandler => sub { my( $r ) = @_; # if needed my $repository = $EPrints::HANDLE->current_repository; # if needed EPrints::ScreenProcessor->process( repository => $repository, screenid => "YourScreenID", # ... whatever other params your Screen needs .... ); return HTTP_OK; } ); $$return_code = EPrints::Const::OK; return EP_TRIGGER_DONE; } } return EP_TRIGGER_OK; }, priority => 100 ); Alternatively, you can have an actual Perl Response Handler, you can use as templates: - http://bazaar.eprints.org/325/1/epm/meprints/cfg/cfg.d/z_meprints.pl (search for EP_TRIGGER_URL_REWRITE) - http://bazaar.eprints.org/325/1/plugins/EPrints/Plugin/MePrints/MePrintsHandler.pm (the handler can do whatever you want, you can print the page to STDOUT, or let the ScreenProcessor do that for you). And just, as a small add-on, on some ACL work I was looking at, my main method was called permit_action (on DataObj) and you pass the action as a param so that it looks like: my $rc = $dataobj->permit_action( "view", $current_user ); # current_user may be undef too Hope this helps, Seb. On 17/07/14 13:45, Enio Carboni wrote:
|
- References:
- [EP-tech] EP_TRIGGER_URL_REWRITE and redirecting to a screen
- From: John Salter <J.Salter@leeds.ac.uk>
- [EP-tech] Re: EP_TRIGGER_URL_REWRITE and redirecting to a screen
- From: Sebastien Francois <sf2@ecs.soton.ac.uk>
- [EP-tech] Re: EP_TRIGGER_URL_REWRITE and redirecting to a screen
- From: John Salter <J.Salter@leeds.ac.uk>
- [EP-tech] Re: EP_TRIGGER_URL_REWRITE and redirecting to a screen
- From: Enio Carboni <enio.carboni@gmail.com>
- [EP-tech] EP_TRIGGER_URL_REWRITE and redirecting to a screen
- Prev by Date: [EP-tech] Re: EP_TRIGGER_URL_REWRITE and redirecting to a screen
- Next by Date: [EP-tech] Exporting from view always in default order
- Previous by thread: [EP-tech] Re: EP_TRIGGER_URL_REWRITE and redirecting to a screen
- Next by thread: [EP-tech] Re: EP_TRIGGER_URL_REWRITE and redirecting to a screen
- Index(es):