OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Using LoadHandler hook

OJS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
The Public Knowledge Project Support Forum is moving to http://forum.pkp.sfu.ca

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.

Using LoadHandler hook

Postby pvadrevu » Sat Apr 23, 2011 4:44 pm

Hi all,
I am trying to write a small plugin that would enable the reviewers to undo their decision to reject a previous article review offer. To do this I would like to add a new "undo decision" links on the archived submissions that a reviewer gets to see. As I found no particular hooks that I can use for this, I wanted to use the loadhandler hook to intercept all calls to journal/reviewer/index

Code: Select all
HookRegistry::register ('LoadHandler', array(&$this, 'handleRequest'));   

Code: Select all
function handleRequest($hookName, $args) {
      $page =& $args[0];
      $op =& $args[1];
      $sourceFile =& $args[2];

      if ($page === 'reviewer' && $op === 'index') {
         define('HANDLER_CLASS', 'ExampleHandler');   
         $sourceFile = $this->getPluginPath() . '/' . 'ExampleHandler.inc.php';      
      }
   }   


The ExampleHandler class for now is just an empty subclass of ReviewerHandler:

Code: Select all
import('classes.reviewer.ReviewerHandler');
class ExampleHandler extends ReviewerHandler {
   function ExampleHandler() {
      parent::ReviewerHandler();
   }
}


The callback function is being invoked but all I get is this error:

Fatal error: require_once() [function.require]: Failed opening required 'classes/reviewer/ReviewerHandler.inc.php' (include_path='.:/data/www/press/ojs/htdocs/classes:/data/www/press/ojs/htdocs/pages:/data/www/press/ojs/htdocs/lib/pkp:/data/www/press/ojs/htdocs/lib/pkp/classes:/data/www/press/ojs/htdocs/lib/pkp/pages:/data/www/press/ojs/htdocs/lib/pkp/lib/adodb:/data/www/press/ojs/htdocs/lib/pkp/lib/phputf8:/data/www/press/ojs/htdocs/lib/pkp/lib/pqp/classes:/data/www/press/ojs/htdocs/lib/pkp/lib/smarty:.:/usr/share/php:/usr/share/pear') in /data/www/press/ojs/htdocs/lib/pkp/includes/functions.inc.php on line 30

Where am I going wrong? Can someone please help me with this.

Thanks,
Phani
pvadrevu
 
Posts: 4
Joined: Tue Feb 08, 2011 2:12 am

Re: Using LoadHandler hook

Postby pvadrevu » Sat Apr 23, 2011 5:02 pm

Sorry, I just made a silly mistake in my import path. Should have been pages.reviewer...

This is my first time developing a plugin. So, can someone confirm if my approach is correct or if I should be using a different hook.

Thank you,
Phani
pvadrevu
 
Posts: 4
Joined: Tue Feb 08, 2011 2:12 am

Re: Using LoadHandler hook

Postby mcrider » Mon May 02, 2011 10:42 am

Hi Phani,

That looks alright -- though I think you can just call (from your handleRequest() method) $this->import('ExampleHandler'); before you define the HANDLER_CLASS. Take a look at e.g. plugins/generic/counter/ for an example.

Cheers,
Matt
mcrider
 
Posts: 952
Joined: Mon May 05, 2008 10:29 am
Location: Vancouver, BC


Return to OJS Development

Who is online

Users browsing this forum: No registered users and 0 guests