00001 <?php
00002
00016
00017
00018
00019 import('submission.common.Action');
00020
00021 class AuthorAction extends Action {
00022
00026 function AuthorAction() {
00027 parent::Action();
00028 }
00029
00038 function designateReviewVersion($authorSubmission) {
00039 import('file.PaperFileManager');
00040 $paperFileManager = new PaperFileManager($authorSubmission->getPaperId());
00041 $authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO');
00042
00043 if (!HookRegistry::call('AuthorAction::designateReviewVersion', array(&$authorSubmission))) {
00044 $submissionFile =& $authorSubmission->getSubmissionFile();
00045 if ($submissionFile) {
00046 $reviewFileId = $paperFileManager->copyToReviewFile($submissionFile->getFileId());
00047
00048 $authorSubmission->setReviewFileId($reviewFileId);
00049
00050 $authorSubmissionDao->updateAuthorSubmission($authorSubmission);
00051
00052 $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
00053 $schedConf =& Request::getSchedConf();
00054 if (!$schedConf || $schedConf->getId() != $authorSubmission->getSchedConfId()) {
00055 $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
00056 unset($schedConf);
00057 $schedConf =& $schedConfDao->getSchedConf($authorSubmission->getSchedConfId());
00058 }
00059 $trackDirectorSubmissionDao->createReviewStage($authorSubmission->getPaperId(), REVIEW_STAGE_PRESENTATION, 1);
00060 }
00061 }
00062 }
00063
00070 function deletePaperFile($paper, $fileId, $revisionId) {
00071 import('file.PaperFileManager');
00072
00073 $paperFileManager = new PaperFileManager($paper->getId());
00074 $paperFileDao =& DAORegistry::getDAO('PaperFileDAO');
00075 $authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO');
00076
00077 $paperFile =& $paperFileDao->getPaperFile($fileId, $revisionId, $paper->getId());
00078 $authorSubmission = $authorSubmissionDao->getAuthorSubmission($paper->getId());
00079 $authorRevisions = $authorSubmission->getAuthorFileRevisions();
00080
00081
00082 if (isset($paperFile)) {
00083 HookRegistry::call('AuthorAction::deletePaperFile', array(&$paperFile, &$authorRevisions));
00084 foreach ($authorRevisions as $stage) {
00085 foreach ($stage as $revision) {
00086 if ($revision->getFileId() == $paperFile->getFileId() &&
00087 $revision->getRevision() == $paperFile->getRevision()) {
00088 $paperFileManager->deleteFile($paperFile->getFileId(), $paperFile->getRevision());
00089 }
00090 }
00091 }
00092 }
00093 }
00094
00099 function uploadRevisedVersion($authorSubmission) {
00100 import('file.PaperFileManager');
00101 $paperFileManager = new PaperFileManager($authorSubmission->getPaperId());
00102 $authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO');
00103
00104 $fileName = 'upload';
00105 if ($paperFileManager->uploadError($fileName)) return false;
00106 if (!$paperFileManager->uploadedFileExists($fileName)) return false;
00107
00108 HookRegistry::call('AuthorAction::uploadRevisedVersion', array(&$authorSubmission));
00109 if ($authorSubmission->getRevisedFileId() != null) {
00110 $fileId = $paperFileManager->uploadDirectorDecisionFile($fileName, $authorSubmission->getRevisedFileId());
00111 } else {
00112 $fileId = $paperFileManager->uploadDirectorDecisionFile($fileName);
00113 }
00114 if (!$fileId) return false;
00115
00116 $authorSubmission->setRevisedFileId($fileId);
00117 $authorSubmissionDao->updateAuthorSubmission($authorSubmission);
00118
00119
00120 $user =& Request::getUser();
00121 import('paper.log.PaperLog');
00122 import('paper.log.PaperEventLogEntry');
00123 PaperLog::logEvent($authorSubmission->getPaperId(), PAPER_LOG_AUTHOR_REVISION, LOG_TYPE_AUTHOR, $user->getId(), 'log.author.documentRevised', array('authorName' => $user->getFullName(), 'fileId' => $fileId, 'paperId' => $authorSubmission->getPaperId()));
00124 }
00125
00126
00127
00128
00129
00134 function viewDirectorDecisionComments($paper) {
00135 if (!HookRegistry::call('AuthorAction::viewDirectorDecisionComments', array(&$paper))) {
00136 import("submission.form.comment.DirectorDecisionCommentForm");
00137
00138 $commentForm = new DirectorDecisionCommentForm($paper, ROLE_ID_AUTHOR);
00139 $commentForm->initData();
00140 $commentForm->display();
00141 }
00142 }
00143
00149 function emailDirectorDecisionComment($authorSubmission, $send) {
00150 $userDao =& DAORegistry::getDAO('UserDAO');
00151 $conference =& Request::getConference();
00152 $schedConf =& Request::getSchedConf();
00153
00154 $user =& Request::getUser();
00155 import('mail.PaperMailTemplate');
00156 $email = new PaperMailTemplate($authorSubmission);
00157
00158 $editAssignments = $authorSubmission->getEditAssignments();
00159 $directors = array();
00160 foreach ($editAssignments as $editAssignment) {
00161 array_push($directors, $userDao->getUser($editAssignment->getDirectorId()));
00162 }
00163
00164 if ($send && !$email->hasErrors()) {
00165 HookRegistry::call('AuthorAction::emailDirectorDecisionComment', array(&$authorSubmission, &$email));
00166 $email->send();
00167
00168 $paperCommentDao =& DAORegistry::getDAO('PaperCommentDAO');
00169 $paperComment = new PaperComment();
00170 $paperComment->setCommentType(COMMENT_TYPE_DIRECTOR_DECISION);
00171 $paperComment->setRoleId(ROLE_ID_AUTHOR);
00172 $paperComment->setPaperId($authorSubmission->getPaperId());
00173 $paperComment->setAuthorId($authorSubmission->getUserId());
00174 $paperComment->setCommentTitle($email->getSubject());
00175 $paperComment->setComments($email->getBody());
00176 $paperComment->setDatePosted(Core::getCurrentDate());
00177 $paperComment->setViewable(true);
00178 $paperComment->setAssocId($authorSubmission->getPaperId());
00179 $paperCommentDao->insertPaperComment($paperComment);
00180
00181 return true;
00182 } else {
00183 if (!Request::getUserVar('continued')) {
00184 $email->setSubject($authorSubmission->getLocalizedTitle());
00185 if (!empty($directors)) {
00186 foreach ($directors as $director) {
00187 $email->addRecipient($director->getEmail(), $director->getFullName());
00188 }
00189 } else {
00190 $email->addRecipient($schedConf->getSetting('contactEmail'), $schedConf->getSetting('contactName'));
00191 }
00192 }
00193
00194 $email->displayEditForm(Request::url(null, null, null, 'emailDirectorDecisionComment', 'send'), array('paperId' => $authorSubmission->getPaperId()), 'submission/comment/directorDecisionEmail.tpl');
00195
00196 return false;
00197 }
00198 }
00199
00200
00201
00202
00203
00212 function downloadAuthorFile($paper, $fileId, $revision = null) {
00213 $authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO');
00214
00215 $submission =& $authorSubmissionDao->getAuthorSubmission($paper->getId());
00216
00217 $canDownload = false;
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230 if ($submission->getSubmissionFileId() == $fileId) {
00231 $canDownload = true;
00232 } else if ($submission->getRevisedFileId() == $fileId) {
00233 $canDownload = true;
00234 } else if ($submission->getLayoutFileId() == $fileId) {
00235 $canDownload = true;
00236 } else {
00237
00238 foreach ($submission->getReviewAssignments(null) as $stageReviewAssignments) {
00239 foreach ($stageReviewAssignments as $reviewAssignment) {
00240 if ($reviewAssignment->getReviewerFileId() == $fileId) {
00241 $paperFileDao =& DAORegistry::getDAO('PaperFileDAO');
00242
00243 $paperFile =& $paperFileDao->getPaperFile($fileId, $revision);
00244
00245 if ($paperFile != null && $paperFile->getViewable()) {
00246 $canDownload = true;
00247 }
00248 }
00249 }
00250 }
00251
00252
00253 foreach ($submission->getSuppFiles() as $suppFile) {
00254 if ($suppFile->getFileId() == $fileId) {
00255 $canDownload = true;
00256 }
00257 }
00258
00259
00260 foreach ($submission->getGalleys() as $galleyFile) {
00261 if ($galleyFile->getFileId() == $fileId) {
00262 $canDownload = true;
00263 }
00264 }
00265
00266
00267 $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00268 $reviewFilesByStage =& $reviewAssignmentDao->getReviewFilesByStage($paper->getId());
00269 $reviewFile = @$reviewFilesByStage[$paper->getCurrentStage()];
00270 if ($reviewFile && $fileId == $reviewFile->getFileId()) {
00271 $canDownload = true;
00272 }
00273
00274
00275 $directorFiles = $submission->getDirectorFileRevisions($paper->getCurrentStage());
00276 if (is_array($directorFiles)) foreach ($directorFiles as $directorFile) {
00277 if ($directorFile->getFileId() == $fileId) {
00278 $canDownload = true;
00279 }
00280 }
00281 }
00282
00283 $result = false;
00284 if (!HookRegistry::call('AuthorAction::downloadAuthorFile', array(&$paper, &$fileId, &$revision, &$canDownload, &$result))) {
00285 if ($canDownload) {
00286 return Action::downloadFile($paper->getId(), $fileId, $revision);
00287 } else {
00288 return false;
00289 }
00290 }
00291 return $result;
00292 }
00293
00294 function mayEditPaper(&$authorSubmission) {
00295 $schedConf =& Request::getSchedConf();
00296 if (!$schedConf || $schedConf->getId() != $authorSubmission->getSchedConfId()) {
00297 unset($schedConf);
00298 $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
00299 $schedConf =& $schedConfDao->getSchedConf($paper->getSchedConfId());
00300 }
00301
00302
00303 if (Validation::isDirector($schedConf->getConferenceId(), $schedConf->getId()) || Validation::isTrackDirector($schedConf->getConferenceId(), $schedConf->getId())) return true;
00304
00305
00306 if ($authorSubmission->getSubmissionProgress() != 0) return true;
00307
00308
00309 if ($authorSubmission->getStatus() == STATUS_ARCHIVED || $authorSubmission->getStatus() == STATUS_DECLINED) return false;
00310
00311
00312
00313 $decisions = $authorSubmission->getDecisions($authorSubmission->getCurrentStage());
00314 $decision = array_shift($decisions);
00315 if ($decision == SUBMISSION_DIRECTOR_DECISION_PENDING_REVISIONS) return true;
00316
00317
00318 $assignments = $authorSubmission->getReviewAssignments(null);
00319 if (is_array($assignments)) foreach ($assignments as $round => $roundAssignments) {
00320 if (is_array($roundAssignments)) foreach($roundAssignments as $assignment) {
00321 if ( !$assignment->getCancelled() &&
00322 !$assignment->getReplaced() &&
00323 !$assignment->getDeclined() &&
00324 $assignment->getDateCompleted() == null &&
00325 $assignment->getDateNotified() != null
00326 ) {
00327 return false;
00328 }
00329 }
00330 }
00331
00332
00333 if (strtotime($schedConf->getEndDate()) > time()) return true;
00334
00335
00336 return false;
00337 }
00338 }
00339
00340 ?>