OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Creating a plugin for limiting the number of articles

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

Moderators: jmacgreg, michael

Forum rules
Developer Resources:

Documentation: The OJS Technical Reference and the OJS API Reference are both available from the OJS Documentation page. While these are OJS-specific, the OCS codebase is similar enough to OJS they should be of help. There is also an [url=http://pkp.sfu.ca/ocs_documentation[/url]OCS Documentation[/url] page with some more general documentation that might also be of interest.

Git: You can access our public Git Repository here. Comprehensive Git usage instructions are available on the wiki.

Bugzilla: You can access our Bugzilla report tracker here.

Search: You can use our Google Custom Search to search across our main website, the support forum, and Bugzilla.

Questions and discussion are welcome, but if you have a workflow or usability question you should probably post to the OCS Conference Support and Discussion subforum; if you have a technical support question, try the OCS Technical Support subforum.

Creating a plugin for limiting the number of articles

Postby pablovaleriopolonia » Sun Dec 23, 2007 12:49 pm

Hi

I have created a plugin to create a limit for the number of articles that an author can submit(to provide a conference especific feature).

The plugin must be called on the first step of the submission process, so i registed it on the hook "presentersubmitform::Constructor" (created dynamically on the Form.inc.php class).

To show an error message on the form i called the "addError" function and after that i called "validate" to display the error message, but it didn't worked because "validate" uses some class attributes that are created after the plugin is called.

To make this work I've made a workaround, putting the variables before the hook is called:

Code: Select all
$this->_template = $template;
      $this->_data = array();
      $this->_checks = array();
      $this->_errors = array();
      $this->errorsArray = array();
      $this->errorFields = array();
      
      if ($callHooks === true && checkPhpVersion('4.3.0')) {
         $trace = debug_backtrace();
         // Call hooks based on the calling entity, assuming
         // this method is only called by a subclass. Results
         // in hook calls named e.g. "articlegalleyform::Constructor"
         // Note that class names are always lower case.
         HookRegistry::call(strtolower($trace[1]['class']) . '::Constructor', array(&$this, &$template));
      }


Is there another way to do what i want? (without changing the OCS base code), or the code I've changed is a valid contribution to the project?

Thanks

Pablo Valério Polônia
pablovaleriopolonia
 
Posts: 2
Joined: Sun Dec 23, 2007 12:07 pm

Re: Creating a plugin for limiting the number of articles

Postby pablovaleriopolonia » Tue Jan 01, 2008 9:30 am

Hi

I found a way to do that without changing any code on the Form class, I found a hook on the TemplateManager class, which is called every time a template is displayed, i registered the plugin on it, and assigned the error array to the template on the callback function when the correct template is called.

Thank you

Pablo Valério Polônia
pablovaleriopolonia
 
Posts: 2
Joined: Sun Dec 23, 2007 12:07 pm


Return to OCS Development

Who is online

Users browsing this forum: No registered users and 0 guests