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
