pages/author/SubmitHandler.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00015 //$Id$
00016 
00017 import('pages.author.AuthorHandler');
00018 
00019 class SubmitHandler extends AuthorHandler {
00021    var $paper;
00022 
00026    function SubmitHandler() {
00027       parent::AuthorHandler();
00028    }
00029 
00035    function submit($args) {
00036       $user =& Request::getUser();
00037       $schedConf =& Request::getSchedConf();
00038       if ($user && $schedConf && !Validation::isAuthor()) {
00039          // The user is logged in but not a author. If
00040          // possible, enroll them as a author automatically.
00041          Request::redirect(
00042             null, null,
00043             'user', 'become',
00044             array('author'),
00045             array(
00046                'source' => Request::url(
00047                   null, null, 'author', 'submit'
00048                )
00049             )
00050          );
00051       }
00052 
00053       $step = isset($args[0]) ? (int) $args[0] : 1;
00054       $paperId = (int) Request::getUserVar('paperId');
00055 
00056       $this->validate($paperId, $step);
00057       $this->setupTemplate(true);
00058 
00059       $paper =& $this->paper;
00060 
00061       $formClass = "AuthorSubmitStep{$step}Form";
00062       import("author.form.submit.$formClass");
00063 
00064       $submitForm = new $formClass($paper);
00065       if ($submitForm->isLocaleResubmit()) {
00066          $submitForm->readInputData();
00067       } else {
00068          $submitForm->initData();
00069       }
00070       $submitForm->display();
00071    }
00072 
00077    function saveSubmit($args) {
00078       $step = isset($args[0]) ? (int) $args[0] : 0;
00079       $paperId = (int) Request::getUserVar('paperId');
00080 
00081       $this->validate($paperId, $step);
00082       $this->setupTemplate(true);
00083 
00084       $paper =& $this->paper;
00085 
00086       $formClass = "AuthorSubmitStep{$step}Form";
00087       import("author.form.submit.$formClass");
00088 
00089       $submitForm = new $formClass($paper);
00090       $submitForm->readInputData();
00091 
00092       if (!HookRegistry::call('SubmitHandler::saveSubmit', array($step, &$paper, &$submitForm))) {
00093 
00094          // Check for any special cases before trying to save
00095          switch ($step) {
00096             case 2:
00097                if (Request::getUserVar('uploadSubmissionFile')) {
00098                   if (!$submitForm->uploadSubmissionFile('submissionFile')) {
00099                      $submitForm->addError('uploadSubmissionFile', __('common.uploadFailed'));
00100                   }
00101                   $editData = true;
00102                }
00103                break;
00104 
00105             case 3:
00106                if (Request::getUserVar('addAuthor')) {
00107                   // Add a sponsor
00108                   $editData = true;
00109                   $authors = $submitForm->getData('authors');
00110                   array_push($authors, array());
00111                   $submitForm->setData('authors', $authors);
00112 
00113                } else if (($delAuthor = Request::getUserVar('delAuthor')) && count($delAuthor) == 1) {
00114                   // Delete an author
00115                   $editData = true;
00116                   list($delAuthor) = array_keys($delAuthor);
00117                   $delAuthor = (int) $delAuthor;
00118                   $authors = $submitForm->getData('authors');
00119                   if (isset($authors[$delAuthor]['authorId']) && !empty($authors[$delAuthor]['authorId'])) {
00120                      $deletedAuthors = explode(':', $submitForm->getData('deletedAuthors'));
00121                      array_push($deletedAuthors, $authors[$delAuthor]['authorId']);
00122                      $submitForm->setData('deletedAuthors', join(':', $deletedAuthors));
00123                   }
00124                   array_splice($authors, $delAuthor, 1);
00125                   $submitForm->setData('authors', $authors);
00126 
00127                   if ($submitForm->getData('primaryContact') == $delAuthor) {
00128                      $submitForm->setData('primaryContact', 0);
00129                   }
00130 
00131                } else if (Request::getUserVar('moveAuthor')) {
00132                   // Move an author up/down
00133                   $editData = true;
00134                   $moveAuthorDir = Request::getUserVar('moveAuthorDir');
00135                   $moveAuthorDir = $moveAuthorDir == 'u' ? 'u' : 'd';
00136                   $moveAuthorIndex = (int) Request::getUserVar('moveAuthorIndex');
00137                   $authors = $submitForm->getData('authors');
00138 
00139                   if (!(($moveAuthorDir == 'u' && $moveAuthorIndex <= 0) || ($moveAuthorDir == 'd' && $moveAuthorIndex >= count($authors) - 1))) {
00140                      $tmpAuthor = $authors[$moveAuthorIndex];
00141                      $primaryContact = $submitForm->getData('primaryContact');
00142                      if ($moveAuthorDir == 'u') {
00143                         $authors[$moveAuthorIndex] = $authors[$moveAuthorIndex - 1];
00144                         $authors[$moveAuthorIndex - 1] = $tmpAuthor;
00145                         if ($primaryContact == $moveAuthorIndex) {
00146                            $submitForm->setData('primaryContact', $moveAuthorIndex - 1);
00147                         } else if ($primaryContact == ($moveAuthorIndex - 1)) {
00148                            $submitForm->setData('primaryContact', $moveAuthorIndex);
00149                         }
00150                      } else {
00151                         $authors[$moveAuthorIndex] = $authors[$moveAuthorIndex + 1];
00152                         $authors[$moveAuthorIndex + 1] = $tmpAuthor;
00153                         if ($primaryContact == $moveAuthorIndex) {
00154                            $submitForm->setData('primaryContact', $moveAuthorIndex + 1);
00155                         } else if ($primaryContact == ($moveAuthorIndex + 1)) {
00156                            $submitForm->setData('primaryContact', $moveAuthorIndex);
00157                         }
00158                      }
00159                   }
00160                   $submitForm->setData('authors', $authors);
00161                }
00162                break;
00163 
00164             case 4:
00165                if (Request::getUserVar('submitUploadSuppFile')) {
00166                   if ($suppFileId = SubmitHandler::submitUploadSuppFile()) {
00167                      Request::redirect(null, null, null, 'submitSuppFile', $suppFileId, array('paperId' => $paperId));
00168                   } else {
00169                      $submitForm->addError('uploadSubmissionFile', __('common.uploadFailed'));
00170                   }
00171                }
00172                break;
00173          }
00174       }
00175 
00176       if (!isset($editData) && $submitForm->validate()) {
00177          $paperId = $submitForm->execute();
00178          $conference =& Request::getConference();
00179          $schedConf =& Request::getSchedConf();
00180 
00181          // For the "abstract only" or sequential review models, nothing else needs
00182          // to be collected beyond page 2.
00183          $reviewMode = $paper?$paper->getReviewMode():$schedConf->getSetting('reviewMode');
00184          if (($step == 3 && $reviewMode == REVIEW_MODE_BOTH_SEQUENTIAL && !$schedConf->getSetting('acceptSupplementaryReviewMaterials')) || 
00185                ($step == 3 && $reviewMode == REVIEW_MODE_ABSTRACTS_ALONE && !$schedConf->getSetting('acceptSupplementaryReviewMaterials')) ||
00186                ($step == 5 )) {
00187 
00188             // Send a notification to associated users
00189             import('notification.NotificationManager');
00190             $notificationManager = new NotificationManager();
00191             $roleDao =& DAORegistry::getDAO('RoleDAO');
00192             $notificationUsers = array();
00193             $conferenceManagers = $roleDao->getUsersByRoleId(ROLE_ID_CONFERENCE_MANAGER, $conference->getId());
00194             $allUsers = $conferenceManagers->toArray();
00195             $directors = $roleDao->getUsersByRoleId(ROLE_ID_DIRECTOR, $conference->getId(), $schedConf->getId());
00196             array_merge($allUsers, $directors->toArray());
00197             foreach ($allUsers as $user) {
00198                $notificationUsers[] = array('id' => $user->getId());
00199             }
00200 
00201             foreach ($notificationUsers as $userRole) {
00202                $url = Request::url(null, null, 'director', 'submission', $paperId);
00203                $notificationManager->createNotification(
00204                   $userRole['id'], 'notification.type.paperSubmitted',
00205                   $paper->getLocalizedTitle(), $url, 1, NOTIFICATION_TYPE_PAPER_SUBMITTED
00206                );
00207             }
00208 
00209             $templateMgr =& TemplateManager::getManager();
00210             $templateMgr->assign_by_ref('conference', $conference);
00211             $templateMgr->assign('paperId', $paperId);
00212             $templateMgr->assign('helpTopicId','submission.index');
00213             $templateMgr->display('author/submit/complete.tpl');
00214          } elseif ($step == 3 && !$schedConf->getSetting('acceptSupplementaryReviewMaterials')) {
00215             Request::redirect(null, null, null, 'submit', 5, array('paperId' => $paperId));
00216          } elseif ($step == 1 && ($reviewMode == REVIEW_MODE_ABSTRACTS_ALONE || $reviewMode == REVIEW_MODE_BOTH_SEQUENTIAL)) {
00217             Request::redirect(null, null, null, 'submit', 3, array('paperId' => $paperId));
00218          } elseif ($step == 2 && $reviewMode == REVIEW_MODE_BOTH_SEQUENTIAL) {
00219             $nextStep = $schedConf->getSetting('acceptSupplementaryReviewMaterials') ? 4:5;
00220             Request::redirect(null, null, null, 'submit', $nextStep, array('paperId' => $paperId));
00221          } else {
00222             Request::redirect(null, null, null, 'submit', $step+1, array('paperId' => $paperId));
00223          }
00224 
00225       } else {
00226          $submitForm->display();
00227       }
00228    }
00229 
00233    function submitUploadSuppFile() {
00234       $paperId = (int) Request::getUserVar('paperId');
00235       $this->validate($paperId, 4);
00236       $paper =& $this->paper;
00237       $this->setupTemplate(true);
00238       $schedConf =& Request::getSchedConf();
00239 
00240       import('file.FileManager');
00241       $fileManager = new FileManager();
00242       if ($fileManager->uploadError('uploadSuppFile')) return false;
00243 
00244       if (!$schedConf->getSetting('acceptSupplementaryReviewMaterials')) return false;
00245 
00246       import('author.form.submit.AuthorSubmitSuppFileForm');
00247       $submitForm = new AuthorSubmitSuppFileForm($paper);
00248       $submitForm->setData('title', array(AppLocale::getLocale() => __('common.untitled')));
00249       return $submitForm->execute();
00250    }
00251 
00256    function submitSuppFile($args) {
00257       $paperId = (int) Request::getUserVar('paperId');
00258       $suppFileId = isset($args[0]) ? (int) $args[0] : 0;
00259 
00260       $this->validate($paperId, 4);
00261       $this->setupTemplate(true);
00262 
00263       $paper =& $this->paper;
00264       $schedConf =& Request::getSchedConf();
00265 
00266       if (!$schedConf->getSetting('acceptSupplementaryReviewMaterials')) Request::redirect(null, null, 'index');
00267 
00268       import("author.form.submit.AuthorSubmitSuppFileForm");
00269       $submitForm = new AuthorSubmitSuppFileForm($paper, $suppFileId);
00270 
00271       if ($submitForm->isLocaleResubmit()) {
00272          $submitForm->readInputData();
00273       } else {
00274          $submitForm->initData();
00275       }
00276       $submitForm->display();
00277    }
00278 
00283    function saveSubmitSuppFile($args) {
00284       $paperId = (int) Request::getUserVar('paperId');
00285       $suppFileId = isset($args[0]) ? (int) $args[0] : 0;
00286 
00287       $this->validate($paperId, 4);
00288       $this->setupTemplate(true);
00289 
00290       $schedConf =& Request::getSchedConf();
00291       $paper =& $this->paper;
00292 
00293       if (!$schedConf->getSetting('acceptSupplementaryReviewMaterials')) Request::redirect(null, null, 'index');
00294 
00295       import('author.form.submit.AuthorSubmitSuppFileForm');
00296       $submitForm = new AuthorSubmitSuppFileForm($paper, $suppFileId);
00297       $submitForm->readInputData();
00298 
00299       import('file.FileManager');
00300       $fileManager = new FileManager();
00301       if ($fileManager->uploadError('uploadSuppFile') && $suppFileId == 0) {
00302          $submitForm->addError('uploadSubmissionFile', __('common.uploadFailed'));
00303       }
00304 
00305       if ($submitForm->validate()) {
00306          $submitForm->execute();
00307          Request::redirect(null, null, null, 'submit', '4', array('paperId' => $paperId));
00308       } else {
00309          $submitForm->display();
00310       }
00311    }
00312 
00317    function deleteSubmitSuppFile($args) {
00318       import("file.PaperFileManager");
00319 
00320       $paperId = (int) Request::getUserVar('paperId');
00321       $suppFileId = isset($args[0]) ? (int) $args[0] : 0;
00322 
00323       $this->validate($paperId, 4);
00324       $this->setupTemplate(true);
00325 
00326       $schedConf =& Request::getSchedConf();
00327       $paper =& $this->paper;
00328 
00329       if (!$schedConf->getSetting('acceptSupplementaryReviewMaterials')) Request::redirect(null, null, 'index');
00330 
00331       $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
00332       $suppFile = $suppFileDao->getSuppFile($suppFileId, $paperId);
00333       $suppFileDao->deleteSuppFileById($suppFileId, $paperId);
00334 
00335       if ($suppFile->getFileId()) {
00336          $paperFileManager = new PaperFileManager($paperId);
00337          $paperFileManager->deleteFile($suppFile->getFileId());
00338       }
00339 
00340       Request::redirect(null, null, null, 'submit', '4', array('paperId' => $paperId));
00341    }
00342 
00349    function validate($paperId = null, $step = false) {
00350       parent::validate();
00351 
00352       $conference =& Request::getConference();
00353       $schedConf =& Request::getSchedConf();
00354 
00355       $paperDao =& DAORegistry::getDAO('PaperDAO');
00356       $user =& Request::getUser();
00357 
00358       if ($step !== false && ($step < 1 || $step > 5 || (!$paperId && $step != 1))) {
00359          Request::redirect(null, null, null, 'submit', array(1));
00360       }
00361 
00362       $paper = null;
00363 
00364       if ($paperId) {
00365          // Check that paper exists for this conference and user and that submission is incomplete
00366          $paper =& $paperDao->getPaper((int) $paperId);
00367          if (!$paper || $paper->getUserId() !== $user->getId() || $paper->getSchedConfId() !== $schedConf->getId()) {
00368             Request::redirect(null, null, null, 'submit');
00369          }
00370 
00371          if($step !== false && $step > $paper->getSubmissionProgress()) {
00372             Request::redirect(null, null, null, 'submit');
00373          }
00374 
00375       } else {
00376          // If the paper does not exist, require that the
00377          // submission window be open or that this user be a
00378          // director or track director.
00379          import('schedConf.SchedConfAction');
00380          $schedConf =& Request::getSchedConf();
00381          if (!$schedConf || (!SchedConfAction::submissionsOpen($schedConf) && !Validation::isDirector($schedConf->getConferenceId(), $schedConf->getId()) && !Validation::isTrackDirector($schedConf->getConferenceId()))) {
00382             Request::redirect(null, null, 'author', 'index');
00383          }
00384       }
00385 
00386       $this->paper =& $paper;
00387       return true;
00388    }
00389 }
00390 
00391 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7