I try to make a simple plugin, basically just use hooks. It seem to be working fine, but I still get following error while accesing http://www.kme.zcu.cz/acm/index.php/acm/manager/plugins :
.Fatal error: Cannot redeclare class UserEmailEditorovi in /var/www/www/html/acm/plugins/generic/editors/UserEmailEditorovi.inc.php on line 36
Plugin basically hide editor's email address for user and replace it by a conference address acm@kme.zcu.cz
Plugin code:
installed in plugins/generic/editors directory
has 2 files:
index.php
- Code: Select all
<?php
require('UserEmailEditorovi.inc.php');
return new UserEmailEditorovi();
?>
and
UserEmailEditorovi.inc.php
- Code: Select all
<?php
import('classes.plugins.GenericPlugin');
class UserEmailEditorovi extends GenericPlugin {
function register($category, $path) {
if (parent::register($category, $path)) {
HookRegistry::register('AuthorAction::emailEditorDecisionComment',array(&$this, 'callback'));
return true;
}
return false;
}
function getName() {
return 'UserEmailEditorovi';
}
function getDisplayName() {
return 'UserEmailEditorovi Plugin';
}
function getDescription() {
return 'Nezobrazi jmeno a email editora priposilani komentaru od autora editorovi';
}
function callback($hookName, $args) {
$authorSubmission=$args[0];
$email=$args[1];
$editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
$editAssignments =& $editAssignmentDao->getEditorAssignmentsByArticleId($authorSubmission->getArticleId());
while ($editAssignment =& $editAssignments->next()) {
$email->addRecipient($editAssignment->getEditorEmail(), $editAssignment->getEditorFullName());
$email->setSubject($email->getSubject().' - '.$editAssignment->getEditorFullName());
unset($editAssignment);
}
return false;
}
}
?>
In classes/submission/author/ AuthorAction.inc.php I change function emailEditorDecisionComment($authorSubmission, $send)
- Code: Select all
} else {
if (!Request::getUserVar('continued')) {
$email->setSubject($authorSubmission->getArticleTitle());
if (!empty($editors)) {
foreach ($editors as $editor) {
$email->addRecipient($editor->getEmail(), $editor->getFullName());
$email->clearAllRecipients();
$email->addRecipient("acm@kme.zcu.cz");
}
} else {
$email->addRecipient($journal->getSetting('contactEmail'), $journal->getSetting('contactName'));
}
}
Any ideas, what I have done wrong?
