00001 <?php
00002
00019
00020
00021
00022 define('SUBMISSION_DIRECTOR_DECISION_INVITE', 1);
00023 define('SUBMISSION_DIRECTOR_DECISION_ACCEPT', 2);
00024 define('SUBMISSION_DIRECTOR_DECISION_PENDING_REVISIONS', 3);
00025 define('SUBMISSION_DIRECTOR_DECISION_DECLINE', 4);
00026
00027 class Action {
00032 function viewMetadata($paper, $roleId) {
00033 if (!HookRegistry::call('Action::viewMetadata', array(&$paper, &$roleId))) {
00034 import("submission.form.MetadataForm");
00035 $metadataForm = new MetadataForm($paper, $roleId);
00036 if ($metadataForm->getCanEdit() && $metadataForm->isLocaleResubmit()) {
00037 $metadataForm->readInputData();
00038 } else {
00039 $metadataForm->initData();
00040 }
00041 $metadataForm->display();
00042 }
00043 }
00044
00049 function saveMetadata($paper) {
00050 if (!HookRegistry::call('Action::saveMetadata', array(&$paper))) {
00051 import("submission.form.MetadataForm");
00052 $metadataForm = new MetadataForm($paper);
00053 $metadataForm->readInputData();
00054
00055
00056 if (Request::getUserVar('addAuthor')) {
00057
00058 $editData = true;
00059 $authors = $metadataForm->getData('authors');
00060 array_push($authors, array());
00061 $metadataForm->setData('authors', $authors);
00062
00063 } else if (($delAuthor = Request::getUserVar('delAuthor')) && count($delAuthor) == 1) {
00064
00065 $editData = true;
00066 list($delAuthor) = array_keys($delAuthor);
00067 $delAuthor = (int) $delAuthor;
00068 $authors = $metadataForm->getData('authors');
00069 if (isset($authors[$delAuthor]['authorId']) && !empty($authors[$delAuthor]['authorId'])) {
00070 $deletedAuthors = explode(':', $metadataForm->getData('deletedAuthors'));
00071 array_push($deletedAuthors, $authors[$delAuthor]['authorId']);
00072 $metadataForm->setData('deletedAuthors', join(':', $deletedAuthors));
00073 }
00074 array_splice($authors, $delAuthor, 1);
00075 $metadataForm->setData('authors', $authors);
00076
00077 if ($metadataForm->getData('primaryContact') == $delAuthor) {
00078 $metadataForm->setData('primaryContact', 0);
00079 }
00080
00081 } else if (Request::getUserVar('moveAuthor')) {
00082
00083 $editData = true;
00084 $moveAuthorDir = Request::getUserVar('moveAuthorDir');
00085 $moveAuthorDir = $moveAuthorDir == 'u' ? 'u' : 'd';
00086 $moveAuthorIndex = (int) Request::getUserVar('moveAuthorIndex');
00087 $authors = $metadataForm->getData('authors');
00088
00089 if (!(($moveAuthorDir == 'u' && $moveAuthorIndex <= 0) || ($moveAuthorDir == 'd' && $moveAuthorIndex >= count($authors) - 1))) {
00090 $tmpAuthor = $authors[$moveAuthorIndex];
00091 $primaryContact = $metadataForm->getData('primaryContact');
00092 if ($moveAuthorDir == 'u') {
00093 $authors[$moveAuthorIndex] = $authors[$moveAuthorIndex - 1];
00094 $authors[$moveAuthorIndex - 1] = $tmpAuthor;
00095 if ($primaryContact == $moveAuthorIndex) {
00096 $metadataForm->setData('primaryContact', $moveAuthorIndex - 1);
00097 } else if ($primaryContact == ($moveAuthorIndex - 1)) {
00098 $metadataForm->setData('primaryContact', $moveAuthorIndex);
00099 }
00100 } else {
00101 $authors[$moveAuthorIndex] = $authors[$moveAuthorIndex + 1];
00102 $authors[$moveAuthorIndex + 1] = $tmpAuthor;
00103 if ($primaryContact == $moveAuthorIndex) {
00104 $metadataForm->setData('primaryContact', $moveAuthorIndex + 1);
00105 } else if ($primaryContact == ($moveAuthorIndex + 1)) {
00106 $metadataForm->setData('primaryContact', $moveAuthorIndex);
00107 }
00108 }
00109 }
00110 $metadataForm->setData('authors', $authors);
00111 }
00112
00113 if (isset($editData)) {
00114 $metadataForm->display();
00115 return false;
00116
00117 } else {
00118 if (!$metadataForm->validate()) {
00119 return $metadataForm->display();
00120 }
00121 $metadataForm->execute();
00122
00123
00124 import('notification.NotificationManager');
00125 $notificationManager = new NotificationManager();
00126 $notificationUsers = $paper->getAssociatedUserIds();
00127 foreach ($notificationUsers as $userRole) {
00128 $url = Request::url(null, null, $userRole['role'], 'submission', $paper->getId(), null, 'metadata');
00129 $notificationManager->createNotification(
00130 $userRole['id'], 'notification.type.metadataModified',
00131 $paper->getLocalizedTitle(), $url, 1, NOTIFICATION_TYPE_METADATA_MODIFIED
00132 );
00133 }
00134
00135
00136
00137 $user =& Request::getUser();
00138 import('paper.log.PaperLog');
00139 import('paper.log.PaperEventLogEntry');
00140 PaperLog::logEvent($paper->getId(), PAPER_LOG_METADATA_UPDATE, LOG_TYPE_DEFAULT, 0, 'log.director.metadataModified', array('directorName' => $user->getFullName()));
00141
00142 return true;
00143 }
00144 }
00145 }
00146
00153 function downloadFile($paperId, $fileId, $revision = null) {
00154 import('file.PaperFileManager');
00155 $paperFileManager = new PaperFileManager($paperId);
00156 return $paperFileManager->downloadFile($fileId, $revision);
00157 }
00158
00165 function viewFile($paperId, $fileId, $revision = null) {
00166 import('file.PaperFileManager');
00167 $paperFileManager = new PaperFileManager($paperId);
00168 return $paperFileManager->viewFile($fileId, $revision);
00169 }
00170
00175 function editComment($paper, $comment) {
00176 if (!HookRegistry::call('Action::editComment', array(&$paper, &$comment))) {
00177 import("submission.form.comment.EditCommentForm");
00178
00179 $commentForm = new EditCommentForm($paper, $comment);
00180 $commentForm->initData();
00181 $commentForm->display();
00182 }
00183 }
00184
00189 function saveComment($paper, &$comment, $emailComment) {
00190 if (!HookRegistry::call('Action::saveComment', array(&$paper, &$comment, &$emailComment))) {
00191 import("submission.form.comment.EditCommentForm");
00192
00193 $commentForm = new EditCommentForm($paper, $comment);
00194 $commentForm->readInputData();
00195
00196 if ($commentForm->validate()) {
00197 $commentForm->execute();
00198
00199
00200 import('notification.NotificationManager');
00201 $notificationManager = new NotificationManager();
00202 $notificationUsers = $paper->getAssociatedUserIds(true, false);
00203 foreach ($notificationUsers as $userRole) {
00204 $url = Request::url(null, null, $userRole['role'], 'submissionReview', $paper->getId(), null, 'editorDecision');
00205 $notificationManager->createNotification(
00206 $userRole['id'], 'notification.type.submissionComment',
00207 $paper->getLocalizedTitle(), $url, 1, NOTIFICATION_TYPE_SUBMISSION_COMMENT
00208 );
00209 }
00210
00211
00212 if ($emailComment) {
00213 $commentForm->email($commentForm->emailHelper());
00214 }
00215
00216 } else {
00217 $commentForm->display();
00218 }
00219 }
00220 }
00221
00227 function deleteComment($commentId, $user = null) {
00228 if ($user == null) $user =& Request::getUser();
00229
00230 $paperCommentDao =& DAORegistry::getDAO('PaperCommentDAO');
00231 $comment =& $paperCommentDao->getPaperCommentById($commentId);
00232
00233 if ($comment->getAuthorId() == $user->getId()) {
00234 if (!HookRegistry::call('Action::deleteComment', array(&$comment))) {
00235 $paperCommentDao->deletePaperComment($comment);
00236 }
00237 }
00238 }
00239 }
00240
00241 ?>