00001 <?php
00002
00019
00020
00021
00022
00023 define('SUBMISSION_EDITOR_DECISION_ACCEPT', 1);
00024 define('SUBMISSION_EDITOR_DECISION_PENDING_REVISIONS', 2);
00025 define('SUBMISSION_EDITOR_DECISION_RESUBMIT', 3);
00026 define('SUBMISSION_EDITOR_DECISION_DECLINE', 4);
00027
00028
00029 define('SUBMISSION_FIELD_AUTHOR', 1);
00030 define('SUBMISSION_FIELD_EDITOR', 2);
00031 define('SUBMISSION_FIELD_TITLE', 3);
00032 define('SUBMISSION_FIELD_REVIEWER', 4);
00033 define('SUBMISSION_FIELD_COPYEDITOR', 5);
00034 define('SUBMISSION_FIELD_LAYOUTEDITOR', 6);
00035 define('SUBMISSION_FIELD_PROOFREADER', 7);
00036
00037 define('SUBMISSION_FIELD_DATE_SUBMITTED', 4);
00038 define('SUBMISSION_FIELD_DATE_COPYEDIT_COMPLETE', 5);
00039 define('SUBMISSION_FIELD_DATE_LAYOUT_COMPLETE', 6);
00040 define('SUBMISSION_FIELD_DATE_PROOFREADING_COMPLETE', 7);
00041
00042 class Action {
00043
00047 function Action() {
00048
00049 }
00050
00059 function viewMetadata($article, $roleId) {
00060 if (!HookRegistry::call('Action::viewMetadata', array(&$article, &$roleId))) {
00061 import("submission.form.MetadataForm");
00062 $metadataForm = &new MetadataForm($article, $roleId);
00063 if ($metadataForm->getCanEdit() && $metadataForm->isLocaleResubmit()) {
00064 $metadataForm->readInputData();
00065 } else {
00066 $metadataForm->initData();
00067 }
00068 $metadataForm->display();
00069 }
00070 }
00071
00076 function saveMetadata($article) {
00077 if (!HookRegistry::call('Action::saveMetadata', array(&$article))) {
00078 import("submission.form.MetadataForm");
00079 $metadataForm = &new MetadataForm($article);
00080 $metadataForm->readInputData();
00081
00082 if (!$metadataForm->validate()) {
00083 return $metadataForm->display();
00084 }
00085
00086
00087 if (Request::getUserVar('addAuthor')) {
00088
00089 $editData = true;
00090 $authors = $metadataForm->getData('authors');
00091 array_push($authors, array());
00092 $metadataForm->setData('authors', $authors);
00093
00094 } else if (($delAuthor = Request::getUserVar('delAuthor')) && count($delAuthor) == 1) {
00095
00096 $editData = true;
00097 list($delAuthor) = array_keys($delAuthor);
00098 $delAuthor = (int) $delAuthor;
00099 $authors = $metadataForm->getData('authors');
00100 if (isset($authors[$delAuthor]['authorId']) && !empty($authors[$delAuthor]['authorId'])) {
00101 $deletedAuthors = explode(':', $metadataForm->getData('deletedAuthors'));
00102 array_push($deletedAuthors, $authors[$delAuthor]['authorId']);
00103 $metadataForm->setData('deletedAuthors', join(':', $deletedAuthors));
00104 }
00105 array_splice($authors, $delAuthor, 1);
00106 $metadataForm->setData('authors', $authors);
00107
00108 if ($metadataForm->getData('primaryContact') == $delAuthor) {
00109 $metadataForm->setData('primaryContact', 0);
00110 }
00111
00112 } else if (Request::getUserVar('moveAuthor')) {
00113
00114 $editData = true;
00115 $moveAuthorDir = Request::getUserVar('moveAuthorDir');
00116 $moveAuthorDir = $moveAuthorDir == 'u' ? 'u' : 'd';
00117 $moveAuthorIndex = (int) Request::getUserVar('moveAuthorIndex');
00118 $authors = $metadataForm->getData('authors');
00119
00120 if (!(($moveAuthorDir == 'u' && $moveAuthorIndex <= 0) || ($moveAuthorDir == 'd' && $moveAuthorIndex >= count($authors) - 1))) {
00121 $tmpAuthor = $authors[$moveAuthorIndex];
00122 $primaryContact = $metadataForm->getData('primaryContact');
00123 if ($moveAuthorDir == 'u') {
00124 $authors[$moveAuthorIndex] = $authors[$moveAuthorIndex - 1];
00125 $authors[$moveAuthorIndex - 1] = $tmpAuthor;
00126 if ($primaryContact == $moveAuthorIndex) {
00127 $metadataForm->setData('primaryContact', $moveAuthorIndex - 1);
00128 } else if ($primaryContact == ($moveAuthorIndex - 1)) {
00129 $metadataForm->setData('primaryContact', $moveAuthorIndex);
00130 }
00131 } else {
00132 $authors[$moveAuthorIndex] = $authors[$moveAuthorIndex + 1];
00133 $authors[$moveAuthorIndex + 1] = $tmpAuthor;
00134 if ($primaryContact == $moveAuthorIndex) {
00135 $metadataForm->setData('primaryContact', $moveAuthorIndex + 1);
00136 } else if ($primaryContact == ($moveAuthorIndex + 1)) {
00137 $metadataForm->setData('primaryContact', $moveAuthorIndex);
00138 }
00139 }
00140 }
00141 $metadataForm->setData('authors', $authors);
00142 }
00143
00144 if (isset($editData)) {
00145 $metadataForm->display();
00146 return false;
00147
00148 } else {
00149 $metadataForm->execute();
00150
00151
00152 $user = &Request::getUser();
00153 import('article.log.ArticleLog');
00154 import('article.log.ArticleEventLogEntry');
00155 ArticleLog::logEvent($article->getArticleId(), ARTICLE_LOG_METADATA_UPDATE, ARTICLE_LOG_TYPE_DEFAULT, 0, 'log.editor.metadataModified', Array('editorName' => $user->getFullName()));
00156
00157 return true;
00158 }
00159 }
00160 }
00161
00168 function downloadFile($articleId, $fileId, $revision = null) {
00169 import('file.ArticleFileManager');
00170 $articleFileManager = &new ArticleFileManager($articleId);
00171 return $articleFileManager->downloadFile($fileId, $revision);
00172 }
00173
00180 function viewFile($articleId, $fileId, $revision = null) {
00181 import('file.ArticleFileManager');
00182 $articleFileManager = &new ArticleFileManager($articleId);
00183 return $articleFileManager->viewFile($fileId, $revision);
00184 }
00185
00190 function instructions($type, $allowed = array('copy', 'layout', 'proof', 'referenceLinking')) {
00191 $journal = &Request::getJournal();
00192 $templateMgr = &TemplateManager::getManager();
00193
00194 if (!HookRegistry::call('Action::instructions', array(&$type, &$allowed))) {
00195 if (!in_array($type, $allowed)) {
00196 return false;
00197 }
00198
00199 switch ($type) {
00200 case 'copy':
00201 $title = 'submission.copyedit.instructions';
00202 $instructions = $journal->getLocalizedSetting('copyeditInstructions');
00203 break;
00204 case 'layout':
00205 $title = 'submission.layout.instructions';
00206 $instructions = $journal->getLocalizedSetting('layoutInstructions');
00207 break;
00208 case 'proof':
00209 $title = 'submission.proofread.instructions';
00210 $instructions = $journal->getLocalizedSetting('proofInstructions');
00211 break;
00212 case 'referenceLinking':
00213 if (!$journal->getSetting('provideRefLinkInstructions')) return false;
00214 $title = 'submission.layout.referenceLinking';
00215 $instructions = $journal->getLocalizedSetting('refLinkInstructions');
00216 break;
00217 default:
00218 return false;
00219 }
00220 }
00221
00222 $templateMgr->assign('pageTitle', $title);
00223 $templateMgr->assign('instructions', $instructions);
00224 $templateMgr->display('submission/instructions.tpl');
00225
00226 return true;
00227 }
00228
00233 function editComment($article, $comment) {
00234 if (!HookRegistry::call('Action::editComment', array(&$article, &$comment))) {
00235 import("submission.form.comment.EditCommentForm");
00236
00237 $commentForm = &new EditCommentForm($article, $comment);
00238 $commentForm->initData();
00239 $commentForm->display();
00240 }
00241 }
00242
00247 function saveComment($article, &$comment, $emailComment) {
00248 if (!HookRegistry::call('Action::saveComment', array(&$article, &$comment, &$emailComment))) {
00249 import("submission.form.comment.EditCommentForm");
00250
00251 $commentForm = &new EditCommentForm($article, $comment);
00252 $commentForm->readInputData();
00253
00254 if ($commentForm->validate()) {
00255 $commentForm->execute();
00256
00257 if ($emailComment) {
00258 $commentForm->email($commentForm->emailHelper());
00259 }
00260
00261 } else {
00262 $commentForm->display();
00263 }
00264 }
00265 }
00266
00272 function deleteComment($commentId, $user = null) {
00273 if ($user == null) $user = &Request::getUser();
00274
00275 $articleCommentDao = &DAORegistry::getDAO('ArticleCommentDAO');
00276 $comment = &$articleCommentDao->getArticleCommentById($commentId);
00277
00278 if ($comment->getAuthorId() == $user->getUserId()) {
00279 if (!HookRegistry::call('Action::deleteComment', array(&$comment))) {
00280 $articleCommentDao->deleteArticleComment($comment);
00281 }
00282 }
00283 }
00284 }
00285
00286 ?>