pages/trackDirector/SubmissionEditHandler.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00016 // $Id$
00017 
00018 
00019 define('TRACK_DIRECTOR_ACCESS_EDIT', 0x00001);
00020 define('TRACK_DIRECTOR_ACCESS_REVIEW', 0x00002);
00021 
00022 import('pages.trackDirector.TrackDirectorHandler');
00023 
00024 class SubmissionEditHandler extends TrackDirectorHandler {
00026    var $submission;
00027    
00031    function SubmissionEditHandler() {
00032       parent::TrackDirectorHandler();
00033    }
00034    
00035    function submission($args) {
00036       $paperId = isset($args[0]) ? (int) $args[0] : 0;
00037       $this->validate($paperId);
00038       $conference =& Request::getConference();
00039       $schedConf =& Request::getSchedConf();
00040       $submission =& $this->submission;
00041       $this->setupTemplate(true, $paperId);
00042 
00043       // FIXME? For comments.readerComments under Status
00044       AppLocale::requireComponents(array(LOCALE_COMPONENT_PKP_READER));
00045 
00046       $user =& Request::getUser();
00047 
00048       $roleDao =& DAORegistry::getDAO('RoleDAO');
00049       $isDirector = $roleDao->roleExists($conference->getId(), $schedConf->getId(), $user->getId(), ROLE_ID_DIRECTOR);
00050 
00051       $trackDao =& DAORegistry::getDAO('TrackDAO');
00052       $track =& $trackDao->getTrack($submission->getTrackId());
00053 
00054       $enableComments = $conference->getSetting('enableComments');
00055 
00056       $templateMgr =& TemplateManager::getManager();
00057 
00058       $templateMgr->assign_by_ref('submission', $submission);
00059       $templateMgr->assign_by_ref('track', $track);
00060       $templateMgr->assign_by_ref('submissionFile', $submission->getSubmissionFile());
00061       $templateMgr->assign_by_ref('suppFiles', $submission->getSuppFiles());
00062       $templateMgr->assign_by_ref('reviewFile', $submission->getReviewFile());
00063       $templateMgr->assign_by_ref('reviewMode', $submission->getReviewMode());
00064       $templateMgr->assign('userId', $user->getId());
00065       $templateMgr->assign('isDirector', $isDirector);
00066       $templateMgr->assign('enableComments', $enableComments);
00067 
00068       $trackDao =& DAORegistry::getDAO('TrackDAO');
00069       $templateMgr->assign_by_ref('tracks', $trackDao->getTrackTitles($schedConf->getId()));
00070       if ($enableComments) {
00071          import('paper.Paper');
00072          $templateMgr->assign('commentsStatus', $submission->getCommentsStatus());
00073          $templateMgr->assign_by_ref('commentsStatusOptions', Paper::getCommentsStatusOptions());
00074       }
00075 
00076       $publishedPaperDao =& DAORegistry::getDAO('PublishedPaperDAO');
00077       $publishedPaper =& $publishedPaperDao->getPublishedPaperByPaperId($submission->getPaperId());
00078       if ($publishedPaper) {
00079          $templateMgr->assign_by_ref('publishedPaper', $publishedPaper);
00080       }
00081 
00082       if ($isDirector) {
00083          $templateMgr->assign('helpTopicId', 'editorial.directorsRole.summaryPage');
00084       }
00085 
00086       $controlledVocabDao =& DAORegistry::getDAO('ControlledVocabDAO');
00087       $templateMgr->assign('sessionTypes', $controlledVocabDao->enumerateBySymbolic('paperType', ASSOC_TYPE_SCHED_CONF, $schedConf->getId()));
00088 
00089       $templateMgr->assign('mayEditPaper', true);
00090 
00091       $templateMgr->display('trackDirector/submission.tpl');
00092    }
00093 
00094    function submissionRegrets($args) {
00095       $paperId = isset($args[0]) ? (int) $args[0] : 0;
00096       $this->validate($paperId);
00097       $conference =& Request::getConference();
00098       $schedConf =& Request::getSchedConf();
00099       $submission =& $this->submission;
00100       $this->setupTemplate(true, $paperId, 'review');
00101 
00102       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00103       $cancelsAndRegrets = $reviewAssignmentDao->getCancelsAndRegrets($paperId);
00104       $reviewFilesByStage = $reviewAssignmentDao->getReviewFilesByStage($paperId);
00105 
00106       $stages = $submission->getReviewAssignments();
00107       $numStages = $submission->getCurrentStage();
00108 
00109       $directorDecisions = $submission->getDecisions();
00110 
00111       $reviewFormResponseDao =& DAORegistry::getDAO('ReviewFormResponseDAO');
00112       $reviewFormResponses = array();
00113       if (isset($stages[$numStages-1])) {
00114          foreach ($stages[$numStages-1] as $stage) {
00115             $reviewFormResponses[$stage->getReviewId()] = $reviewFormResponseDao->reviewFormResponseExists($stage->getReviewId());
00116          }
00117       }
00118 
00119       $templateMgr =& TemplateManager::getManager();
00120       $templateMgr->assign('reviewMode', $submission->getReviewMode());
00121       $templateMgr->assign_by_ref('submission', $submission);
00122       $templateMgr->assign_by_ref('reviewAssignmentStages', $stages);
00123       $templateMgr->assign('reviewFormResponses', $reviewFormResponses);
00124       $templateMgr->assign_by_ref('cancelsAndRegrets', $cancelsAndRegrets);
00125       $templateMgr->assign_by_ref('reviewFilesByStage', $reviewFilesByStage);
00126       $templateMgr->assign_by_ref('directorDecisions', $directorDecisions);
00127       $templateMgr->assign_by_ref('directorDecisionOptions', TrackDirectorSubmission::getDirectorDecisionOptions());
00128       $templateMgr->assign('rateReviewerOnQuality', $schedConf->getSetting('rateReviewerOnQuality'));
00129 
00130       import('submission.reviewAssignment.ReviewAssignment');
00131       $templateMgr->assign_by_ref('reviewerRatingOptions', ReviewAssignment::getReviewerRatingOptions());
00132       $templateMgr->assign_by_ref('reviewerRecommendationOptions', ReviewAssignment::getReviewerRecommendationOptions());
00133 
00134       $templateMgr->display('trackDirector/submissionRegrets.tpl');
00135    }
00136 
00137    function submissionReview($args) {
00138       $paperId = (isset($args[0]) ? $args[0] : null);
00139 
00140       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_REVIEW);
00141       $conference =& Request::getConference();
00142       $schedConf =& Request::getSchedConf();
00143       $submission =& $this->submission;
00144       
00145       $stage = (isset($args[1]) ? (int) $args[1] : null);
00146       $reviewMode = $submission->getReviewMode();
00147       switch ($reviewMode) {
00148          case REVIEW_MODE_ABSTRACTS_ALONE:
00149             $stage = REVIEW_STAGE_ABSTRACT;
00150             break;
00151          case REVIEW_MODE_BOTH_SIMULTANEOUS:
00152          case REVIEW_MODE_PRESENTATIONS_ALONE:
00153             $stage = REVIEW_STAGE_PRESENTATION;
00154             break;
00155          case REVIEW_MODE_BOTH_SEQUENTIAL:
00156             if ($stage != REVIEW_STAGE_ABSTRACT && $stage != REVIEW_STAGE_PRESENTATION) $stage = $submission->getCurrentStage();
00157             break;
00158       }
00159 
00160       $this->setupTemplate(true, $paperId);
00161 
00162       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00163       $reviewFormDao =& DAORegistry::getDAO('ReviewFormDAO');
00164 
00165       $trackDao =& DAORegistry::getDAO('TrackDAO');
00166       $tracks =& $trackDao->getSchedConfTracks($schedConf->getId());
00167 
00168       $directorDecisions = $submission->getDecisions($stage);
00169       $lastDecision = count($directorDecisions) >= 1 ? $directorDecisions[count($directorDecisions) - 1]['decision'] : null;
00170 
00171       $editAssignments =& $submission->getEditAssignments();
00172       $isCurrent = ($stage == $submission->getCurrentStage());
00173       $showPeerReviewOptions = $isCurrent && $submission->getReviewFile() != null ? true : false;
00174 
00175       $allowRecommendation = ($isCurrent  || ($stage == REVIEW_STAGE_ABSTRACT && $reviewMode == REVIEW_MODE_BOTH_SEQUENTIAL)) &&
00176          !empty($editAssignments);
00177 
00178       $reviewingAbstractOnly = ($reviewMode == REVIEW_MODE_BOTH_SEQUENTIAL && $stage == REVIEW_STAGE_ABSTRACT) || $reviewMode == REVIEW_MODE_ABSTRACTS_ALONE;
00179 
00180       // Prepare an array to store the 'Notify Reviewer' email logs
00181       $notifyReviewerLogs = array();
00182       if($submission->getReviewAssignments($stage)) {
00183          foreach ($submission->getReviewAssignments($stage) as $reviewAssignment) {
00184             $notifyReviewerLogs[$reviewAssignment->getId()] = array();
00185          }
00186       }
00187 
00188       // Parse the list of email logs and populate the array.
00189       import('paper.log.PaperLog');
00190       $emailLogEntries =& PaperLog::getEmailLogEntries($paperId);
00191       foreach ($emailLogEntries->toArray() as $emailLog) {
00192          if ($emailLog->getEventType() == PAPER_EMAIL_REVIEW_NOTIFY_REVIEWER) {
00193             if (isset($notifyReviewerLogs[$emailLog->getAssocId()]) && is_array($notifyReviewerLogs[$emailLog->getAssocId()])) {
00194                array_push($notifyReviewerLogs[$emailLog->getAssocId()], $emailLog);
00195             }
00196          }
00197       }
00198 
00199       // get conference published review form titles
00200       $reviewFormTitles =& $reviewFormDao->getTitlesByAssocId(ASSOC_TYPE_CONFERENCE, $conference->getId(), 1);
00201 
00202       $reviewFormResponseDao =& DAORegistry::getDAO('ReviewFormResponseDAO');
00203       $reviewFormResponses = array();
00204 
00205       $reviewFormDao =& DAORegistry::getDAO('ReviewFormDAO');
00206       $reviewFormTitles = array();
00207 
00208       if ($submission->getReviewAssignments($stage)) {
00209          foreach ($submission->getReviewAssignments($stage) as $reviewAssignment) {
00210             $reviewForm =& $reviewFormDao->getReviewForm($reviewAssignment->getReviewFormId());
00211             if ($reviewForm) {
00212                $reviewFormTitles[$reviewForm->getId()] = $reviewForm->getLocalizedTitle();
00213             }
00214             unset($reviewForm);
00215             $reviewFormResponses[$reviewAssignment->getId()] = $reviewFormResponseDao->reviewFormResponseExists($reviewAssignment->getId());
00216          }
00217       }
00218 
00219       $templateMgr =& TemplateManager::getManager();
00220 
00221       $templateMgr->assign_by_ref('submission', $submission);
00222       $templateMgr->assign_by_ref('reviewIndexes', $reviewAssignmentDao->getReviewIndexesForStage($paperId, $stage));
00223       $templateMgr->assign('stage', $stage);
00224       $templateMgr->assign_by_ref('reviewAssignments', $submission->getReviewAssignments($stage));
00225       $templateMgr->assign('reviewFormResponses', $reviewFormResponses);
00226       $templateMgr->assign('reviewFormTitles', $reviewFormTitles);
00227       $templateMgr->assign_by_ref('notifyReviewerLogs', $notifyReviewerLogs);
00228       $templateMgr->assign_by_ref('submissionFile', $submission->getSubmissionFile());
00229       $templateMgr->assign_by_ref('suppFiles', $submission->getSuppFiles());
00230       $templateMgr->assign_by_ref('reviewFile', $submission->getReviewFile());
00231       $templateMgr->assign_by_ref('revisedFile', $submission->getRevisedFile());
00232       $templateMgr->assign_by_ref('directorFile', $submission->getDirectorFile());
00233       $templateMgr->assign('rateReviewerOnQuality', $schedConf->getSetting('rateReviewerOnQuality'));
00234       $templateMgr->assign('showPeerReviewOptions', $showPeerReviewOptions);
00235       $templateMgr->assign_by_ref('tracks', $tracks->toArray());
00236       $templateMgr->assign_by_ref('directorDecisionOptions', TrackDirectorSubmission::getDirectorDecisionOptions());
00237       $templateMgr->assign_by_ref('lastDecision', $lastDecision);
00238       $templateMgr->assign_by_ref('directorDecisions', $directorDecisions);
00239 
00240       if ($reviewMode != REVIEW_MODE_BOTH_SEQUENTIAL || $stage == REVIEW_STAGE_PRESENTATION) {
00241          $templateMgr->assign('isFinalReview', true);
00242       }
00243 
00244       import('submission.reviewAssignment.ReviewAssignment');
00245       $templateMgr->assign_by_ref('reviewerRecommendationOptions', ReviewAssignment::getReviewerRecommendationOptions());
00246       $templateMgr->assign_by_ref('reviewerRatingOptions', ReviewAssignment::getReviewerRatingOptions());
00247 
00248       $templateMgr->assign('isCurrent', $isCurrent);
00249       $templateMgr->assign('allowRecommendation', $allowRecommendation);
00250       $templateMgr->assign('reviewingAbstractOnly', $reviewingAbstractOnly);
00251 
00252       $templateMgr->assign('helpTopicId', 'editorial.trackDirectorsRole.review');
00253 
00254       $controlledVocabDao =& DAORegistry::getDAO('ControlledVocabDAO');
00255       $templateMgr->assign('sessionTypes', $controlledVocabDao->enumerateBySymbolic('sessionTypes', ASSOC_TYPE_SCHED_CONF, $schedConf->getId()));
00256 
00257       $templateMgr->display('trackDirector/submissionReview.tpl');
00258    }
00259 
00263    function submissionHistory($args) {
00264       $paperId = isset($args[0]) ? (int) $args[0] : 0;
00265       $this->validate($paperId);
00266       $conference =& Request::getConference();
00267       $schedConf =& Request::getSchedConf();
00268       $submission =& $this->submission;
00269 
00270       $this->setupTemplate(true, $paperId);
00271 
00272       // submission notes
00273       $paperNoteDao =& DAORegistry::getDAO('PaperNoteDAO');
00274 
00275       $rangeInfo =& Handler::getRangeInfo('submissionNotes', array($paperId));
00276       while (true) {
00277          $submissionNotes =& $paperNoteDao->getPaperNotes($paperId, $rangeInfo);
00278          unset($rangeInfo);
00279          if ($submissionNotes->isInBounds()) break;
00280          $rangeInfo =& $submissionNotes->getLastPageRangeInfo();
00281          unset($submissionNotes);
00282       }
00283 
00284       import('paper.log.PaperLog');
00285 
00286       $rangeInfo =& Handler::getRangeInfo('eventLogEntries', array($paperId));
00287       while (true) {
00288          $eventLogEntries =& PaperLog::getEventLogEntries($paperId, $rangeInfo);
00289          unset($rangeInfo);
00290          if ($eventLogEntries->isInBounds()) break;
00291          $rangeInfo =& $eventLogEntries->getLastPageRangeInfo();
00292          unset($eventLogEntries);
00293       }
00294 
00295       $rangeInfo =& Handler::getRangeInfo('emailLogEntries', array($paperId));
00296       while (true) {
00297          $emailLogEntries =& PaperLog::getEmailLogEntries($paperId, $rangeInfo);
00298          unset($rangeInfo);
00299          if ($emailLogEntries->isInBounds()) break;
00300          $rangeInfo =& $emailLogEntries->getLastPageRangeInfo();
00301          unset($emailLogEntries);
00302       }
00303 
00304       $templateMgr =& TemplateManager::getManager();
00305 
00306       $templateMgr->assign_by_ref('reviewMode', $submission->getReviewMode());
00307 
00308       $templateMgr->assign('isDirector', Validation::isDirector());
00309       $templateMgr->assign_by_ref('submission', $submission);
00310       $templateMgr->assign_by_ref('eventLogEntries', $eventLogEntries);
00311       $templateMgr->assign_by_ref('emailLogEntries', $emailLogEntries);
00312       $templateMgr->assign_by_ref('submissionNotes', $submissionNotes);
00313 
00314       $templateMgr->display('trackDirector/submissionHistory.tpl');
00315    }
00316 
00320    function changeTrack() {
00321       $paperId = Request::getUserVar('paperId');
00322       $this->validate($paperId);
00323       $conference =& Request::getConference();
00324       $schedConf =& Request::getSchedConf();
00325       $submission =& $this->submission;
00326 
00327       $trackId = Request::getUserVar('trackId');
00328 
00329       TrackDirectorAction::changeTrack($submission, $trackId);
00330 
00331       Request::redirect(null, null, null, 'submission', $paperId);
00332    }
00333 
00337    function changeSessionType() {
00338       $paperId = Request::getUserVar('paperId');
00339       $this->validate($paperId);
00340       $conference =& Request::getConference();
00341       $schedConf =& Request::getSchedConf();
00342       $submission =& $this->submission;
00343       $sessionType = Request::getUserVar('sessionType');
00344       TrackDirectorAction::changeSessionType($submission, $sessionType);
00345       Request::redirect(null, null, null, 'submission', $paperId);
00346    }
00347 
00348    function recordDecision($args) {
00349       $paperId = (int) Request::getUserVar('paperId');
00350       $decision = (int) Request::getUserVar('decision');
00351       $stage = (int) array_shift($args);
00352 
00353       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_REVIEW);
00354       $conference =& Request::getConference();
00355       $schedConf =& Request::getSchedConf();
00356       $submission =& $this->submission;
00357 
00358       // If the director changes the decision on the first round,
00359       // roll back to the abstract review stage.
00360       if (
00361          $submission->getCurrentStage() == REVIEW_STAGE_PRESENTATION &&
00362          $stage == REVIEW_STAGE_ABSTRACT
00363       ) {
00364          $submission->setCurrentStage(REVIEW_STAGE_ABSTRACT);
00365 
00366          // Now, unassign all reviewers from the paper review
00367          foreach ($submission->getReviewAssignments(REVIEW_STAGE_PRESENTATION) as $reviewAssignment) {
00368             if ($reviewAssignment->getRecommendation() !== null && $reviewAssignment->getRecommendation() !== '') {
00369                TrackDirectorAction::clearReview($submission, $reviewAssignment->getId());
00370             }
00371          }
00372 
00373          TrackDirectorAction::recordDecision($submission, $decision, $stage);
00374       } else {
00375          switch ($decision) {
00376             case SUBMISSION_DIRECTOR_DECISION_ACCEPT:
00377             case SUBMISSION_DIRECTOR_DECISION_INVITE:
00378             case SUBMISSION_DIRECTOR_DECISION_PENDING_REVISIONS:
00379             case SUBMISSION_DIRECTOR_DECISION_DECLINE:
00380                TrackDirectorAction::recordDecision($submission, $decision, $stage);
00381                break;
00382          }
00383       }
00384 
00385       Request::redirect(null, null, null, 'submissionReview', array($paperId, $stage));
00386    }
00387 
00388    function completePaper($args) {
00389       $paperId = Request::getUserVar('paperId');
00390       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_EDIT);
00391       $conference =& Request::getConference();
00392       $schedConf =& Request::getSchedConf();
00393       $submission =& $this->submission;
00394 
00395       if (Request::getUserVar('complete')) $complete = true;
00396       elseif (Request::getUserVar('remove')) $complete = false;
00397       else Request::redirect(null, null, null, 'index');
00398 
00399       TrackDirectorAction::completePaper($submission, $complete);
00400 
00401       Request::redirect(null, null, null, 'submissions', array($complete?'submissionsAccepted':'submissionsInReview'));
00402    }
00403 
00404    //
00405    // Peer Review
00406    //
00407 
00408    function selectReviewer($args) {
00409       $paperId = isset($args[0]) ? (int) $args[0] : 0;
00410       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_REVIEW);
00411       $conference =& Request::getConference();
00412       $schedConf =& Request::getSchedConf();
00413       $submission =& $this->submission;
00414 
00415       AppLocale::requireComponents(array(LOCALE_COMPONENT_PKP_MANAGER)); // manager.people.noneEnrolled FIXME?
00416 
00417       $sort = Request::getUserVar('sort');
00418       $sort = isset($sort) ? $sort : 'name';
00419       $sortDirection = Request::getUserVar('sortDirection');
00420 
00421       $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
00422 
00423       if (isset($args[1]) && $args[1] != null) {
00424          // Assign reviewer to paper
00425          TrackDirectorAction::addReviewer($submission, (int) $args[1], $submission->getCurrentStage());
00426          Request::redirect(null, null, null, 'submissionReview', $paperId);
00427 
00428          // FIXME: Prompt for due date.
00429       } else {
00430          $this->setupTemplate(true, $paperId, 'review');
00431 
00432          $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
00433 
00434          $searchType = null;
00435          $searchMatch = null;
00436          $search = $searchQuery = Request::getUserVar('search');
00437          $searchInitial = Request::getUserVar('searchInitial');
00438          if (!empty($search)) {
00439             $searchType = Request::getUserVar('searchField');
00440             $searchMatch = Request::getUserVar('searchMatch');
00441 
00442          } elseif (!empty($searchInitial)) {
00443             $searchInitial = String::strtoupper($searchInitial);
00444             $searchType = USER_FIELD_INITIAL;
00445             $search = $searchInitial;
00446          }
00447 
00448          $rangeInfo =& Handler::getRangeInfo('reviewers', array($submission->getCurrentStage(), (string) $searchType, (string) $search, (string) $searchMatch)); // Paper ID intentionally omitted
00449          while (true) {
00450             $reviewers = $trackDirectorSubmissionDao->getReviewersForPaper($schedConf->getId(), $paperId, $submission->getCurrentStage(), $searchType, $search, $searchMatch, $rangeInfo, $sort, $sortDirection);
00451             if ($reviewers->isInBounds()) break;
00452             unset($rangeInfo);
00453             $rangeInfo =& $reviewers->getLastPageRangeInfo();
00454             unset($reviewers);
00455          }
00456 
00457          $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00458 
00459          $templateMgr =& TemplateManager::getManager();
00460 
00461          $templateMgr->assign('searchField', $searchType);
00462          $templateMgr->assign('searchMatch', $searchMatch);
00463          $templateMgr->assign('search', $searchQuery);
00464          $templateMgr->assign('searchInitial', Request::getUserVar('searchInitial'));
00465 
00466          $templateMgr->assign_by_ref('reviewers', $reviewers);
00467          $templateMgr->assign('paperId', $paperId);
00468          $templateMgr->assign('reviewerStatistics', $trackDirectorSubmissionDao->getReviewerStatistics($schedConf->getId()));
00469          $templateMgr->assign('fieldOptions', Array(
00470             USER_FIELD_INTERESTS => 'user.interests',
00471             USER_FIELD_FIRSTNAME => 'user.firstName',
00472             USER_FIELD_LASTNAME => 'user.lastName',
00473             USER_FIELD_USERNAME => 'user.username',
00474             USER_FIELD_EMAIL => 'user.email'
00475          ));
00476          $templateMgr->assign('completedReviewCounts', $reviewAssignmentDao->getCompletedReviewCounts($schedConf->getId()));
00477          $templateMgr->assign('rateReviewerOnQuality', $schedConf->getSetting('rateReviewerOnQuality'));
00478          $templateMgr->assign('averageQualityRatings', $reviewAssignmentDao->getAverageQualityRatings($schedConf->getId()));
00479 
00480          $templateMgr->assign('helpTopicId', 'conference.roles.reviewers');
00481          $templateMgr->assign('alphaList', explode(' ', __('common.alphaList')));
00482          $templateMgr->assign('sort', $sort);
00483          $templateMgr->assign('sortDirection', $sortDirection);
00484          $templateMgr->display('trackDirector/selectReviewer.tpl');
00485       }
00486    }
00487 
00491    function createReviewer($args) {
00492       $paperId = isset($args[0]) ? (int) $args[0] : 0;
00493       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_REVIEW);
00494       $conference =& Request::getConference();
00495       $schedConf =& Request::getSchedConf();
00496       $submission =& $this->submission;
00497 
00498 
00499       import('trackDirector.form.CreateReviewerForm');
00500       $createReviewerForm = new CreateReviewerForm($paperId);
00501       AppLocale::requireComponents(array(LOCALE_COMPONENT_PKP_MANAGER));
00502       $this->setupTemplate(true, $paperId);
00503 
00504       if (isset($args[1]) && $args[1] === 'create') {
00505          $createReviewerForm->readInputData();
00506          if ($createReviewerForm->validate()) {
00507             // Create a user and enroll them as a reviewer.
00508             $newUserId = $createReviewerForm->execute();
00509             Request::redirect(null, null, null, 'selectReviewer', array($paperId, $newUserId));
00510          } else {
00511             $createReviewerForm->display();
00512          }
00513       } else {
00514          // Display the "create user" form.
00515          if ($createReviewerForm->isLocaleResubmit()) {
00516             $createReviewerForm->readInputData();
00517          } else {
00518             $createReviewerForm->initData();
00519          }
00520          $createReviewerForm->display();
00521       }
00522 
00523    }
00524 
00529    function suggestUsername() {
00530       parent::validate();
00531       $suggestion = Validation::suggestUsername(
00532          Request::getUserVar('firstName'),
00533          Request::getUserVar('lastName')
00534       );
00535       echo $suggestion;
00536    }
00537 
00541    function enrollSearch($args) {
00542       $paperId = isset($args[0]) ? (int) $args[0] : 0;
00543       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_REVIEW);
00544       AppLocale::requireComponents(array(LOCALE_COMPONENT_PKP_MANAGER)); // manager.people.enrollment, manager.people.enroll
00545       $conference =& Request::getConference();
00546       $schedConf =& Request::getSchedConf();
00547       $submission =& $this->submission;
00548 
00549 
00550       $roleDao =& DAORegistry::getDAO('RoleDAO');
00551       $roleId = $roleDao->getRoleIdFromPath('reviewer');
00552 
00553       $user =& Request::getUser();
00554 
00555       $templateMgr =& TemplateManager::getManager();
00556       $this->setupTemplate(true);
00557 
00558       $searchType = null;
00559       $searchMatch = null;
00560       $search = $searchQuery = Request::getUserVar('search');
00561       $searchInitial = Request::getUserVar('searchInitial');
00562       if (!empty($search)) {
00563          $searchType = Request::getUserVar('searchField');
00564          $searchMatch = Request::getUserVar('searchMatch');
00565 
00566       } elseif (!empty($searchInitial)) {
00567          $searchInitial = String::strtoupper($searchInitial);
00568          $searchType = USER_FIELD_INITIAL;
00569          $search = $searchInitial;
00570       }
00571 
00572       $rangeInfo = Handler::getRangeInfo('users', array((string) $searchType, (string) $searchMatch, (string) $search)); // Paper ID intentionally omitted
00573       $userDao =& DAORegistry::getDAO('UserDAO');
00574       while (true) {
00575          $users =& $userDao->getUsersByField($searchType, $searchMatch, $search, false, $rangeInfo);
00576          if ($users->isInBounds()) break;
00577          unset($rangeInfo);
00578          $rangeInfo =& $users->getLastPageRangeInfo();
00579          unset($users);
00580       }
00581 
00582       $templateMgr->assign('searchField', $searchType);
00583       $templateMgr->assign('searchMatch', $searchMatch);
00584       $templateMgr->assign('search', $searchQuery);
00585       $templateMgr->assign('searchInitial', Request::getUserVar('searchInitial'));
00586 
00587       $templateMgr->assign('paperId', $paperId);
00588       $templateMgr->assign('fieldOptions', Array(
00589          USER_FIELD_INTERESTS => 'user.interests',
00590          USER_FIELD_FIRSTNAME => 'user.firstName',
00591          USER_FIELD_LASTNAME => 'user.lastName',
00592          USER_FIELD_USERNAME => 'user.username',
00593          USER_FIELD_EMAIL => 'user.email'
00594       ));
00595       $templateMgr->assign('roleId', $roleId);
00596       $templateMgr->assign_by_ref('users', $users);
00597       $templateMgr->assign('alphaList', explode(' ', __('common.alphaList')));
00598 
00599       $templateMgr->assign('helpTopicId', 'conference.roles.index');
00600       $templateMgr->display('trackDirector/searchUsers.tpl');
00601    }
00602 
00603    function enroll($args) {
00604       $paperId = isset($args[0]) ? (int) $args[0] : 0;
00605       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_REVIEW);
00606       $conference =& Request::getConference();
00607       $schedConf =& Request::getSchedConf();
00608       $submission =& $this->submission;
00609 
00610 
00611       $roleDao =& DAORegistry::getDAO('RoleDAO');
00612       $roleId = $roleDao->getRoleIdFromPath('reviewer');
00613 
00614       $users = Request::getUserVar('users');
00615       if (!is_array($users) && Request::getUserVar('userId') != null) $users = array(Request::getUserVar('userId'));
00616 
00617       // Enroll reviewer
00618       for ($i=0; $i<count($users); $i++) {
00619          if (!$roleDao->roleExists($schedConf->getConferenceId(), $schedConf->getId(), $users[$i], $roleId)) {
00620             $role = new Role();
00621             $role->setConferenceId($schedConf->getConferenceId());
00622             $role->setSchedConfId($schedConf->getId());
00623             $role->setUserId($users[$i]);
00624             $role->setRoleId($roleId);
00625 
00626             $roleDao->insertRole($role);
00627          }
00628       }
00629       Request::redirect(null, null, null, 'selectReviewer', $paperId);
00630    }
00631 
00632    function notifyReviewer($args = array()) {
00633       $paperId = Request::getUserVar('paperId');
00634       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_REVIEW);
00635       $conference =& Request::getConference();
00636       $schedConf =& Request::getSchedConf();
00637       $submission =& $this->submission;
00638 
00639 
00640       $reviewId = Request::getUserVar('reviewId');
00641 
00642       $send = Request::getUserVar('send')?true:false;
00643       $this->setupTemplate(true, $paperId, 'review');
00644 
00645       if (TrackDirectorAction::notifyReviewer($submission, $reviewId, $send)) {
00646          Request::redirect(null, null, null, 'submissionReview', $paperId);
00647       }
00648    }
00649 
00650    function clearReview($args) {
00651       $paperId = isset($args[0])?$args[0]:0;
00652       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_REVIEW);
00653       $conference =& Request::getConference();
00654       $schedConf =& Request::getSchedConf();
00655       $submission =& $this->submission;
00656 
00657 
00658       $reviewId = $args[1];
00659 
00660       TrackDirectorAction::clearReview($submission, $reviewId);
00661 
00662       Request::redirect(null, null, null, 'submissionReview', $paperId);
00663    }
00664 
00665    function cancelReview($args) {
00666       $paperId = Request::getUserVar('paperId');
00667       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_REVIEW);
00668       $conference =& Request::getConference();
00669       $schedConf =& Request::getSchedConf();
00670       $submission =& $this->submission;
00671 
00672       $reviewId = Request::getUserVar('reviewId');
00673 
00674       $send = Request::getUserVar('send')?true:false;
00675       $this->setupTemplate(true, $paperId, 'review');
00676 
00677       if (TrackDirectorAction::cancelReview($submission, $reviewId, $send)) {
00678          Request::redirect(null, null, null, 'submissionReview', $paperId);
00679       }
00680    }
00681 
00682    function remindReviewer($args = null) {
00683       $paperId = Request::getUserVar('paperId');
00684       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_REVIEW);
00685       $conference =& Request::getConference();
00686       $schedConf =& Request::getSchedConf();
00687       $submission =& $this->submission;
00688 
00689       $reviewId = Request::getUserVar('reviewId');
00690       $this->setupTemplate(true, $paperId, 'review');
00691 
00692       if (TrackDirectorAction::remindReviewer($submission, $reviewId, Request::getUserVar('send'))) {
00693          Request::redirect(null, null, null, 'submissionReview', $paperId);
00694       }
00695    }
00696 
00697    function thankReviewer($args = array()) {
00698       $paperId = Request::getUserVar('paperId');
00699       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_REVIEW);
00700       $conference =& Request::getConference();
00701       $schedConf =& Request::getSchedConf();
00702       $submission =& $this->submission;
00703 
00704       $reviewId = Request::getUserVar('reviewId');
00705 
00706       $send = Request::getUserVar('send')?true:false;
00707       $this->setupTemplate(true, $paperId, 'review');
00708 
00709       if (TrackDirectorAction::thankReviewer($submission, $reviewId, $send)) {
00710          Request::redirect(null, null, null, 'submissionReview', $paperId);
00711       }
00712    }
00713 
00714    function rateReviewer() {
00715       $paperId = Request::getUserVar('paperId');
00716       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_REVIEW);
00717       $conference =& Request::getConference();
00718       $schedConf =& Request::getSchedConf();
00719       $submission =& $this->submission;
00720 
00721       $this->setupTemplate(true, $paperId, 'review');
00722 
00723       $reviewId = Request::getUserVar('reviewId');
00724       $quality = Request::getUserVar('quality');
00725 
00726       TrackDirectorAction::rateReviewer($paperId, $reviewId, $quality);
00727 
00728       Request::redirect(null, null, null, 'submissionReview', $paperId);
00729    }
00730 
00731    function confirmReviewForReviewer($args) {
00732       $paperId = (int) isset($args[0])?$args[0]:0;
00733       $accept = Request::getUserVar('accept')?true:false;
00734       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_REVIEW);
00735       $conference =& Request::getConference();
00736       $schedConf =& Request::getSchedConf();
00737       $submission =& $this->submission;
00738 
00739       $reviewId = (int) isset($args[1])?$args[1]:0;
00740 
00741       TrackDirectorAction::confirmReviewForReviewer($reviewId);
00742       Request::redirect(null, null, null, 'submissionReview', $paperId);
00743    }
00744 
00745    function uploadReviewForReviewer($args) {
00746       $paperId = (int) Request::getUserVar('paperId');
00747       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_REVIEW);
00748       $conference =& Request::getConference();
00749       $schedConf =& Request::getSchedConf();
00750       $submission =& $this->submission;
00751 
00752       $reviewId = (int) Request::getUserVar('reviewId');
00753 
00754       TrackDirectorAction::uploadReviewForReviewer($reviewId);
00755       Request::redirect(null, null, null, 'submissionReview', $paperId);
00756    }
00757 
00758    function makeReviewerFileViewable() {
00759       $paperId = Request::getUserVar('paperId');
00760       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_REVIEW);
00761       $conference =& Request::getConference();
00762       $schedConf =& Request::getSchedConf();
00763       $submission =& $this->submission;
00764 
00765       $reviewId = Request::getUserVar('reviewId');
00766       $fileId = Request::getUserVar('fileId');
00767       $revision = Request::getUserVar('revision');
00768       $viewable = Request::getUserVar('viewable');
00769 
00770       TrackDirectorAction::makeReviewerFileViewable($paperId, $reviewId, $fileId, $revision, $viewable);
00771 
00772       Request::redirect(null, null, null, 'submissionReview', $paperId);
00773    }
00774 
00775    function setDueDate($args) {
00776       $paperId = isset($args[0]) ? (int) $args[0] : 0;
00777       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_REVIEW);
00778       $conference =& Request::getConference();
00779       $schedConf =& Request::getSchedConf();
00780       $submission =& $this->submission;
00781 
00782       $reviewId = isset($args[1]) ? $args[1] : 0;
00783       $dueDate = Request::getUserVar('dueDate');
00784       $numWeeks = Request::getUserVar('numWeeks');
00785 
00786       if ($dueDate != null || $numWeeks != null) {
00787          TrackDirectorAction::setDueDate($paperId, $reviewId, $dueDate, $numWeeks);
00788          Request::redirect(null, null, null, 'submissionReview', $paperId);
00789 
00790       } else {
00791          $this->setupTemplate(true, $paperId, 'review');
00792 
00793          $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00794          $reviewAssignment = $reviewAssignmentDao->getReviewAssignmentById($reviewId);
00795 
00796          $settings = $schedConf->getSettings();
00797 
00798          $templateMgr =& TemplateManager::getManager();
00799 
00800          if ($reviewAssignment->getDateDue() != null) {
00801             $templateMgr->assign('dueDate', $reviewAssignment->getDateDue());
00802          }
00803 
00804          if ($schedConf->getSetting('reviewDeadlineType') == REVIEW_DEADLINE_TYPE_ABSOLUTE) {
00805             // Get number of days from now until review deadline date
00806             $reviewDeadlineDate = $schedConf->getSetting('numWeeksPerReviewAbsolute');
00807             $daysDiff = ($reviewDeadlineDate - strtotime(date("Y-m-d"))) / (60 * 60 * 24);
00808             $numWeeksPerReview = round($daysDiff / 7);
00809          } elseif ($schedConf->getSetting('reviewDeadlineType') == REVIEW_DEADLINE_TYPE_RELATIVE) {
00810             $numWeeksPerReview = ((int) $schedConf->getSetting('numWeeksPerReviewRelative'));
00811          } else $numWeeksPerReview = 0;
00812 
00813          $templateMgr->assign('paperId', $paperId);
00814          $templateMgr->assign('reviewId', $reviewId);
00815          $templateMgr->assign('todaysDate', date('Y-m-d'));
00816          $templateMgr->assign('numWeeksPerReview', $numWeeksPerReview);
00817          $templateMgr->assign('actionHandler', 'setDueDate');
00818 
00819          $templateMgr->display('trackDirector/setDueDate.tpl');
00820       }
00821    }
00822 
00823    function enterReviewerRecommendation($args) {
00824       $paperId = Request::getUserVar('paperId');
00825       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_REVIEW);
00826       $conference =& Request::getConference();
00827       $schedConf =& Request::getSchedConf();
00828       $submission =& $this->submission;
00829 
00830       $reviewId = Request::getUserVar('reviewId');
00831 
00832       $recommendation = Request::getUserVar('recommendation');
00833 
00834       if ($recommendation != null) {
00835          TrackDirectorAction::setReviewerRecommendation($paperId, $reviewId, $recommendation, SUBMISSION_REVIEWER_RECOMMENDATION_ACCEPT);
00836          Request::redirect(null, null, null, 'submissionReview', $paperId);
00837       } else {
00838          $this->setupTemplate(true, $paperId, 'review');
00839 
00840          $templateMgr =& TemplateManager::getManager();
00841 
00842          $templateMgr->assign('paperId', $paperId);
00843          $templateMgr->assign('reviewId', $reviewId);
00844 
00845          import('submission.reviewAssignment.ReviewAssignment');
00846          $templateMgr->assign_by_ref('reviewerRecommendationOptions', ReviewAssignment::getReviewerRecommendationOptions());
00847 
00848          $templateMgr->display('trackDirector/reviewerRecommendation.tpl');
00849       }
00850    }
00851 
00856    function userProfile($args) {
00857       parent::validate();
00858       $this->setupTemplate(true);
00859 
00860       $templateMgr =& TemplateManager::getManager();
00861       $templateMgr->assign('currentUrl', Request::url(null, null, null, Request::getRequestedPage()));
00862 
00863       $userDao =& DAORegistry::getDAO('UserDAO');
00864       $userId = isset($args[0]) ? $args[0] : 0;
00865       if (is_numeric($userId)) {
00866          $userId = (int) $userId;
00867          $user = $userDao->getUser($userId);
00868       } else {
00869          $user = $userDao->getUserByUsername($userId);
00870       }
00871 
00872 
00873       if ($user == null) {
00874          // Non-existent user requested
00875          $templateMgr->assign('pageTitle', 'manager.people');
00876          $templateMgr->assign('errorMsg', 'manager.people.invalidUser');
00877          $templateMgr->display('common/error.tpl');
00878 
00879       } else {
00880          $site =& Request::getSite();
00881 
00882          $countryDao =& DAORegistry::getDAO('CountryDAO');
00883          $country = null;
00884          if ($user->getCountry() != '') {
00885             $country = $countryDao->getCountry($user->getCountry());
00886          }
00887          $templateMgr->assign('country', $country);
00888 
00889          $templateMgr->assign_by_ref('user', $user);
00890          $templateMgr->assign('localeNames', AppLocale::getAllLocales());
00891          $templateMgr->assign('helpTopicId', 'conference.roles.index');
00892          $templateMgr->display('trackDirector/userProfile.tpl');
00893       }
00894    }
00895 
00896    function viewMetadata($args) {
00897       $paperId = isset($args[0]) ? (int) $args[0] : 0;
00898       $this->validate($paperId);
00899       $submission =& $this->submission;
00900       $this->setupTemplate(true, $paperId, 'summary');
00901 
00902       TrackDirectorAction::viewMetadata($submission, ROLE_ID_TRACK_DIRECTOR);
00903    }
00904 
00905    function saveMetadata() {
00906       $paperId = Request::getUserVar('paperId');
00907       $this->validate($paperId);
00908       $submission =& $this->submission;
00909       $this->setupTemplate(true, $paperId, 'summary');
00910 
00911       if (TrackDirectorAction::saveMetadata($submission)) {
00912          Request::redirect(null, null, null, 'submission', $paperId);
00913       }
00914    }
00915 
00916    //
00917    // Review Form
00918    //
00919 
00924    function previewReviewForm($args) {
00925       parent::validate();
00926       $this->setupTemplate(true);
00927 
00928       $reviewId = isset($args[0]) ? (int) $args[0] : null;
00929       $reviewFormId = isset($args[1]) ? (int)$args[1] : null;
00930 
00931       $conference =& Request::getConference();
00932       $reviewFormDao =& DAORegistry::getDAO('ReviewFormDAO');
00933       $reviewForm =& $reviewFormDao->getReviewForm($reviewFormId, ASSOC_TYPE_CONFERENCE, $conference->getId());
00934       $reviewFormElementDao =& DAORegistry::getDAO('ReviewFormElementDAO');
00935       $reviewFormElements =& $reviewFormElementDao->getReviewFormElements($reviewFormId);
00936       $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00937       $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
00938 
00939       $templateMgr =& TemplateManager::getManager();
00940       $templateMgr->assign('pageTitle', 'manager.reviewForms.preview');
00941       $templateMgr->assign_by_ref('reviewForm', $reviewForm);
00942       $templateMgr->assign('reviewFormElements', $reviewFormElements);
00943       $templateMgr->assign('reviewId', $reviewId);
00944       $templateMgr->assign('paperId', $reviewAssignment->getPaperId());
00945       //$templateMgr->assign('helpTopicId','conference.managementPages.reviewForms');
00946       $templateMgr->display('trackDirector/previewReviewForm.tpl');
00947    }
00948 
00953    function clearReviewForm($args) {
00954       $paperId = isset($args[0]) ? (int) $args[0] : 0;
00955       $reviewId = isset($args[1]) ? (int) $args[1] : null;
00956       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_REVIEW);
00957       $submission =& $this->submission;
00958       
00959       TrackDirectorAction::clearReviewForm($submission, $reviewId);
00960 
00961       Request::redirect(null, null, null, 'submissionReview', $paperId);
00962    }
00963 
00968    function selectReviewForm($args) {
00969       $paperId = isset($args[0]) ? (int) $args[0] : 0;
00970       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_REVIEW);
00971       $conference =& Request::getConference();
00972       $schedConf =& Request::getSchedConf();
00973       $submission =& $this->submission;
00974 
00975       $reviewId = isset($args[1]) ? (int) $args[1] : null;
00976       $reviewFormId = isset($args[2]) ? (int) $args[2] : null;
00977 
00978       if ($reviewFormId != null) {
00979          TrackDirectorAction::addReviewForm($submission, $reviewId, $reviewFormId);
00980          Request::redirect(null, null, null, 'submissionReview', $paperId);
00981       } else {
00982          $conference =& Request::getConference();
00983          $rangeInfo =& Handler::getRangeInfo('reviewForms');
00984          $reviewFormDao =& DAORegistry::getDAO('ReviewFormDAO');
00985          $reviewForms =& $reviewFormDao->getActiveByAssocId(ASSOC_TYPE_CONFERENCE, $conference->getId(), $rangeInfo);
00986          $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00987          $reviewAssignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
00988 
00989          $this->setupTemplate(true, $paperId, 'review');
00990          $templateMgr =& TemplateManager::getManager();
00991 
00992          $templateMgr->assign('paperId', $paperId);
00993          $templateMgr->assign('reviewId', $reviewId);
00994          $templateMgr->assign('assignedReviewFormId', $reviewAssignment->getReviewFormId());
00995          $templateMgr->assign_by_ref('reviewForms', $reviewForms);
00996          //$templateMgr->assign('helpTopicId','conference.managementPages.reviewForms');
00997          $templateMgr->display('trackDirector/selectReviewForm.tpl');
00998       }
00999    }
01000 
01005    function viewReviewFormResponse($args) {
01006       $paperId = isset($args[0]) ? (int) $args[0] : 0;
01007       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_REVIEW);
01008       $submission =& $this->submission;
01009       $this->setupTemplate(true, $paperId, 'summary');
01010 
01011       $reviewId = isset($args[1]) ? (int) $args[1] : null;
01012 
01013       TrackDirectorAction::viewReviewFormResponse($submission, $reviewId);
01014    }
01015 
01016    //
01017    // Director Review
01018    //
01019 
01020    function directorReview($args) {
01021       import('paper.Paper');
01022 
01023       $stage = (isset($args[0]) ? $args[0] : REVIEW_STAGE_ABSTRACT);
01024       $paperId = Request::getUserVar('paperId');
01025       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_REVIEW);
01026       $submission =& $this->submission;
01027 
01028       $redirectArgs = array($paperId, $stage);
01029 
01030       // If the Upload button was pressed.
01031       if (Request::getUserVar('submit')) {
01032          TrackDirectorAction::uploadDirectorVersion($submission);
01033       } elseif (Request::getUserVar('setEditingFile')) {
01034          // If the Send To Editing button was pressed
01035          $file = explode(',', Request::getUserVar('directorDecisionFile'));
01036          $submission->stampDateToPresentations();
01037          $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
01038          $trackDirectorSubmissionDao->updateTrackDirectorSubmission($submission);
01039 
01040          if (isset($file[0]) && isset($file[1])) {
01041             TrackDirectorAction::setEditingFile($submission, $file[0], $file[1], Request::getUserVar('createGalley'));
01042          }
01043 
01044       }
01045 
01046       Request::redirect(null, null, null, 'submissionReview', $redirectArgs);
01047    }
01048 
01049    function uploadReviewVersion() {
01050       $paperId = Request::getUserVar('paperId');
01051       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_REVIEW);
01052       $submission =& $this->submission;
01053 
01054       TrackDirectorAction::uploadReviewVersion($submission);
01055 
01056       Request::redirect(null, null, null, 'submissionReview', $paperId);
01057    }
01058 
01063    function addSuppFile($args) {
01064       $paperId = isset($args[0]) ? (int) $args[0] : 0;
01065       $this->validate($paperId);
01066       $submission =& $this->submission;
01067       $this->setupTemplate(true, $paperId, 'summary');
01068 
01069       import('submission.form.SuppFileForm');
01070 
01071       $submitForm = new SuppFileForm($submission);
01072 
01073       if ($submitForm->isLocaleResubmit()) {
01074          $submitForm->readInputData();
01075       } else {
01076          $submitForm->initData();
01077       }
01078       $submitForm->display();
01079    }
01080 
01085    function editSuppFile($args) {
01086       $paperId = isset($args[0]) ? (int) $args[0] : 0;
01087       $suppFileId = isset($args[1]) ? (int) $args[1] : 0;
01088       $this->validate($paperId);
01089       $submission =& $this->submission;
01090       $this->setupTemplate(true, $paperId, 'summary');
01091 
01092       import('submission.form.SuppFileForm');
01093 
01094       $submitForm = new SuppFileForm($submission, $suppFileId);
01095 
01096       if ($submitForm->isLocaleResubmit()) {
01097          $submitForm->readInputData();
01098       } else {
01099          $submitForm->initData();
01100       }
01101       $submitForm->display();
01102    }
01103 
01108    function setSuppFileVisibility($args) {
01109       $paperId = Request::getUserVar('paperId');
01110       $this->validate($paperId);
01111       $submission =& $this->submission;
01112 
01113       $suppFileId = Request::getUserVar('fileId');
01114       $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
01115       $suppFile = $suppFileDao->getSuppFile($suppFileId, $paperId);
01116 
01117       if (isset($suppFile) && $suppFile != null) {
01118          $suppFile->setShowReviewers(Request::getUserVar('show')==1?1:0);
01119          $suppFileDao->updateSuppFile($suppFile);
01120       }
01121       Request::redirect(null, null, null, 'submissionReview', $paperId);
01122    }
01123 
01128    function saveSuppFile($args) {
01129       $paperId = Request::getUserVar('paperId');
01130       $this->validate($paperId);
01131       $this->setupTemplate(true, $paperId, 'summary');
01132       $submission =& $this->submission;
01133 
01134       $suppFileId = isset($args[0]) ? (int) $args[0] : 0;
01135 
01136       import('submission.form.SuppFileForm');
01137 
01138       $submitForm = new SuppFileForm($submission, $suppFileId);
01139       $submitForm->readInputData();
01140 
01141       if ($submitForm->validate()) {
01142          $submitForm->execute();
01143 
01144          // Send a notification to associated users
01145          import('notification.NotificationManager');
01146          $notificationManager = new NotificationManager();
01147          $paperDao =& DAORegistry::getDAO('PaperDAO');
01148          $paper =& $paperDao->getPaper($paperId);
01149          $notificationUsers = $paper->getAssociatedUserIds(true, false);
01150          foreach ($notificationUsers as $userRole) {
01151             $url = Request::url(null, null, $userRole['role'], 'submissionReview', $paper->getId(), null, 'layout');
01152             $notificationManager->createNotification(
01153                $userRole['id'], 'notification.type.suppFileModified',
01154                $paper->getLocalizedTitle(), $url, 1, NOTIFICATION_TYPE_SUPP_FILE_MODIFIED
01155             );
01156          }
01157 
01158          Request::redirect(null, null, null, 'submissionReview', $paperId);
01159       } else {
01160          $submitForm->display();
01161       }
01162    }
01163 
01168    function deletePaperFile($args) {
01169       $paperId = isset($args[0]) ? (int) $args[0] : 0;
01170       $fileId = isset($args[1]) ? (int) $args[1] : 0;
01171       $revisionId = isset($args[2]) ? (int) $args[2] : 0;
01172 
01173       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_REVIEW);
01174       $submission =& $this->submission;
01175       TrackDirectorAction::deletePaperFile($submission, $fileId, $revisionId);
01176 
01177       Request::redirect(null, null, null, 'submissionReview', $paperId);
01178    }
01179 
01184    function deleteSuppFile($args) {
01185       $paperId = isset($args[0]) ? (int) $args[0] : 0;
01186       $suppFileId = isset($args[1]) ? (int) $args[1] : 0;
01187       $this->validate($paperId);
01188       $submission =& $this->submission;
01189 
01190       TrackDirectorAction::deleteSuppFile($submission, $suppFileId);
01191 
01192       Request::redirect(null, null, null, 'submissionReview', $paperId);
01193    }
01194 
01195    function archiveSubmission($args) {
01196       $paperId = isset($args[0]) ? (int) $args[0] : 0;
01197       $this->validate($paperId);
01198       $submission =& $this->submission;
01199 
01200       TrackDirectorAction::archiveSubmission($submission);
01201 
01202       Request::redirect(null, null, null, 'submission', $paperId);
01203    }
01204 
01205    function restoreToQueue($args) {
01206       $paperId = isset($args[0]) ? (int) $args[0] : 0;
01207       $this->validate($paperId);
01208       $submission =& $this->submission;
01209       
01210       TrackDirectorAction::restoreToQueue($submission);
01211 
01212       Request::redirect(null, null, null, 'submission', $paperId);
01213    }
01214 
01215    function unsuitableSubmission($args) {
01216       $paperId = Request::getUserVar('paperId');
01217       $this->validate($paperId);
01218       $submission =& $this->submission;
01219       
01220       $send = Request::getUserVar('send')?true:false;
01221       $this->setupTemplate(true, $paperId, 'summary');
01222 
01223       if (TrackDirectorAction::unsuitableSubmission($submission, $send)) {
01224          Request::redirect(null, null, null, 'submission', $paperId);
01225       }
01226    }
01227 
01232    function updateCommentsStatus($args) {
01233       $paperId = isset($args[0]) ? (int) $args[0] : 0;
01234       $this->validate($paperId);
01235       $submission =& $this->submission;
01236       TrackDirectorAction::updateCommentsStatus($submission, Request::getUserVar('commentsStatus'));
01237       Request::redirect(null, null, null, 'submission', $paperId);
01238    }
01239 
01240 
01241    //
01242    // Layout Editing
01243    //
01244 
01248    function uploadLayoutFile() {
01249       $layoutFileType = Request::getUserVar('layoutFileType');
01250       $stage = (int) Request::getUserVar('stage');
01251 
01252       import('file.FileManager');
01253       $fileManager = new FileManager();
01254       if ($fileManager->uploadError('layoutFile')) {
01255          $templateMgr =& TemplateManager::getManager();
01256          $this->setupTemplate(true);
01257          $templateMgr->assign('pageTitle', 'submission.review');
01258          $templateMgr->assign('message', 'common.uploadFailed');
01259          $templateMgr->assign('backLink', Request::url(null, null, null, 'submissionReview', array(Request::getUserVar('paperId'))));
01260          $templateMgr->assign('backLinkLabel', 'submission.review');
01261          return $templateMgr->display('common/message.tpl');
01262       }
01263       
01264       if ($layoutFileType == 'galley') {
01265          $this->uploadGalley('layoutFile', $stage);
01266 
01267       } else if ($layoutFileType == 'supp') {
01268          $this->uploadSuppFile('layoutFile', $stage);
01269 
01270       } else {
01271          Request::redirect(null, null, null, 'submission', Request::getUserVar('paperId'));
01272       }
01273    }
01274 
01279    function deletePaperImage($args) {
01280       $paperId = isset($args[0]) ? (int) $args[0] : 0;
01281       $galleyId = isset($args[1]) ? (int) $args[1] : 0;
01282       $fileId = isset($args[2]) ? (int) $args[2] : 0;
01283       $revisionId = isset($args[3]) ? (int) $args[3] : 0;
01284 
01285       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_EDIT);
01286       $submission =& $this->submission;
01287 
01288       TrackDirectorAction::deletePaperImage($submission, $fileId, $revisionId);
01289 
01290       Request::redirect(null, null, 'editGalley', array($paperId, $galleyId));
01291    }
01292 
01298    function uploadGalley($fileName = null, $stage = null) {
01299       $paperId = Request::getUserVar('paperId');
01300       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_EDIT);
01301       $submission =& $this->submission;
01302 
01303 
01304       import('submission.form.PaperGalleyForm');
01305 
01306       $galleyForm = new PaperGalleyForm($paperId);
01307       $galleyId = $galleyForm->execute($fileName);
01308 
01309       Request::redirect(null, null, null, 'editGalley', array($paperId, $galleyId, $stage));
01310    }
01311 
01316    function editGalley($args) {
01317       $paperId = (int) array_shift($args);
01318       $galleyId = (int) array_shift($args);
01319       $stage = (int) array_shift($args);
01320       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_EDIT);
01321       $submission =& $this->submission;
01322 
01323       $this->setupTemplate(true, $paperId, 'review');
01324 
01325       import('submission.form.PaperGalleyForm');
01326 
01327       $submitForm = new PaperGalleyForm($paperId, $galleyId, $stage);
01328 
01329       if ($submitForm->isLocaleResubmit()) {
01330          $submitForm->readInputData();
01331       } else {
01332          $submitForm->initData();
01333       }
01334       $submitForm->display();
01335    }
01336 
01341    function saveGalley($args) {
01342       $paperId = (int) array_shift($args);
01343       $galleyId = (int) array_shift($args);
01344       $stage = (int) array_shift($args);
01345       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_EDIT);
01346       $this->setupTemplate(true, $paperId, 'editing');
01347       $submission =& $this->submission;
01348 
01349       import('submission.form.PaperGalleyForm');
01350 
01351       $submitForm = new PaperGalleyForm($paperId, $galleyId, $stage);
01352       $submitForm->readInputData();
01353 
01354       if ($submitForm->validate()) {
01355          $submitForm->execute();
01356 
01357          // Send a notification to associated users
01358          import('notification.NotificationManager');
01359          $notificationManager = new NotificationManager();
01360          $paperDao =& DAORegistry::getDAO('PaperDAO');
01361          $paper =& $paperDao->getPaper($paperId);
01362          $notificationUsers = $paper->getAssociatedUserIds(true, false);
01363          foreach ($notificationUsers as $userRole) {
01364             $url = Request::url(null, null, $userRole['role'], 'submissionReview', $paper->getId(), null, 'layout');
01365             $notificationManager->createNotification(
01366                $userRole['id'], 'notification.type.galleyModified',
01367                $paper->getLocalizedTitle(), $url, 1, NOTIFICATION_TYPE_GALLEY_MODIFIED
01368             );
01369          }
01370 
01371          if (Request::getUserVar('uploadImage')) {
01372             $submitForm->uploadImage();
01373             Request::redirect(null, null, null, 'editGalley', array($paperId, $galleyId, $stage));
01374          } else if(($deleteImage = Request::getUserVar('deleteImage')) && count($deleteImage) == 1) {
01375             list($imageId) = array_keys($deleteImage);
01376             $submitForm->deleteImage($imageId);
01377             Request::redirect(null, null, null, 'editGalley', array($paperId, $galleyId, $stage));
01378          }
01379          Request::redirect(null, null, null, 'submissionReview', array($paperId, $stage));
01380       } else {
01381          $submitForm->display();
01382       }
01383    }
01384 
01388    function orderGalley() {
01389       $paperId = Request::getUserVar('paperId');
01390       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_EDIT);
01391       $submission =& $this->submission;
01392 
01393 
01394       TrackDirectorAction::orderGalley($submission, Request::getUserVar('galleyId'), Request::getUserVar('d'));
01395 
01396       Request::redirect(null, null, null, 'submissionReview', $paperId);
01397    }
01398 
01403    function deleteGalley($args) {
01404       $paperId = isset($args[0]) ? (int) $args[0] : 0;
01405       $galleyId = isset($args[1]) ? (int) $args[1] : 0;
01406       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_EDIT);
01407       $submission =& $this->submission;
01408 
01409       TrackDirectorAction::deleteGalley($submission, $galleyId);
01410 
01411       Request::redirect(null, null, null, 'submissionReview', $paperId);
01412    }
01413 
01418    function proofGalley($args) {
01419       $paperId = isset($args[0]) ? (int) $args[0] : 0;
01420       $galleyId = isset($args[1]) ? (int) $args[1] : 0;
01421       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_EDIT);
01422 
01423       $templateMgr =& TemplateManager::getManager();
01424       $templateMgr->assign('paperId', $paperId);
01425       $templateMgr->assign('galleyId', $galleyId);
01426       $templateMgr->display('submission/layout/proofGalley.tpl');
01427    }
01428 
01433    function proofGalleyTop($args) {
01434       $paperId = isset($args[0]) ? (int) $args[0] : 0;
01435       $galleyId = isset($args[1]) ? (int) $args[1] : 0;
01436       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_EDIT);
01437 
01438       $templateMgr =& TemplateManager::getManager();
01439       $templateMgr->assign('paperId', $paperId);
01440       $templateMgr->assign('galleyId', $galleyId);
01441       $templateMgr->assign('backHandler', 'submissionReview');
01442       $templateMgr->display('submission/layout/proofGalleyTop.tpl');
01443    }
01444 
01449    function proofGalleyFile($args) {
01450       $paperId = isset($args[0]) ? (int) $args[0] : 0;
01451       $galleyId = isset($args[1]) ? (int) $args[1] : 0;
01452       $this->validate($paperId, TRACK_DIRECTOR_ACCESS_EDIT);
01453 
01454       $galleyDao =& DAORegistry::getDAO('PaperGalleyDAO');
01455       $galley =& $galleyDao->getGalley($galleyId, $paperId);
01456 
01457       import('file.PaperFileManager'); // FIXME
01458 
01459       if (isset($galley)) {
01460          if ($galley->isHTMLGalley()) {
01461             $templateMgr =& TemplateManager::getManager();
01462             $templateMgr->assign_by_ref('galley', $galley);
01463             if ($galley->isHTMLGalley() && $styleFile =& $galley->getStyleFile()) {
01464                $templateMgr->addStyleSheet(Request::url(null, null, 'paper', 'viewFile', array(
01465                   $paperId, $galleyId, $styleFile->getFileId()
01466                )));
01467             }
01468             $templateMgr->display('submission/layout/proofGalleyHTML.tpl');
01469 
01470          } else {
01471             // View non-HTML file inline
01472             $this->viewFile(array($paperId, $galley->getFileId()));
01473          }
01474       }
01475    }
01476 
01482    function uploadSuppFile($fileName = null, $stage = null) {
01483       $paperId = Request::getUserVar('paperId');
01484       $this->validate($paperId);
01485       $conference =& Request::getConference();
01486       $schedConf =& Request::getSchedConf();
01487       $submission =& $this->submission;
01488 
01489       import('submission.form.SuppFileForm');
01490 
01491       $suppFileForm = new SuppFileForm($submission);
01492       $suppFileForm->setData('title', array(AppLocale::getLocale() => __('common.untitled')));
01493       $suppFileId = $suppFileForm->execute($fileName);
01494 
01495       Request::redirect(null, null, null, 'editSuppFile', array($paperId, $suppFileId));
01496    }
01497 
01501    function orderSuppFile() {
01502       $paperId = Request::getUserVar('paperId');
01503       $this->validate($paperId);
01504       $submission =& $this->submission;
01505 
01506       TrackDirectorAction::orderSuppFile($submission, Request::getUserVar('suppFileId'), Request::getUserVar('d'));
01507 
01508       Request::redirect(null, null, null, 'submissionReview', $paperId);
01509    }
01510 
01511 
01512    //
01513    // Submission History (FIXME Move to separate file?)
01514    //
01515 
01519    function submissionEventLog($args) {
01520       $paperId = isset($args[0]) ? (int) $args[0] : 0;
01521       $logId = isset($args[1]) ? (int) $args[1] : 0;
01522       $this->validate($paperId);
01523       $submission =& $this->submission;
01524 
01525       $this->setupTemplate(true, $paperId, 'history');
01526 
01527       $templateMgr =& TemplateManager::getManager();
01528 
01529       $templateMgr->assign('isDirector', Validation::isDirector());
01530       $templateMgr->assign_by_ref('submission', $submission);
01531 
01532       if ($logId) {
01533          $logDao =& DAORegistry::getDAO('PaperEventLogDAO');
01534          $logEntry =& $logDao->getLogEntry($logId, $paperId);
01535       }
01536 
01537       if (isset($logEntry)) {
01538          $templateMgr->assign('logEntry', $logEntry);
01539          $templateMgr->display('trackDirector/submissionEventLogEntry.tpl');
01540 
01541       } else {
01542          $rangeInfo =& Handler::getRangeInfo('eventLogEntries', array($paperId));
01543 
01544          import('paper.log.PaperLog');
01545          while (true) {
01546             $eventLogEntries =& PaperLog::getEventLogEntries($paperId, $rangeInfo);
01547             if ($eventLogEntries->isInBounds()) break;
01548             unset($rangeInfo);
01549             $rangeInfo =& $eventLogEntries->getLastPageRangeInfo();
01550             unset($eventLogEntries);
01551          }
01552          $templateMgr->assign('eventLogEntries', $eventLogEntries);
01553          $templateMgr->display('trackDirector/submissionEventLog.tpl');
01554       }
01555    }
01556 
01560    function submissionEventLogType($args) {
01561       $paperId = isset($args[0]) ? (int) $args[0] : 0;
01562       $assocType = isset($args[1]) ? (int) $args[1] : null;
01563       $assocId = isset($args[2]) ? (int) $args[2] : null;
01564       $this->validate($paperId);
01565       $submission =& $this->submission;
01566 
01567       $this->setupTemplate(true, $paperId, 'history');
01568 
01569       $rangeInfo =& Handler::getRangeInfo('eventLogEntries', array($paperId, $assocType, $assocId));
01570       $logDao =& DAORegistry::getDAO('PaperEventLogDAO');
01571       while (true) {
01572          $eventLogEntries =& $logDao->getPaperLogEntriesByAssoc($paperId, $assocType, $assocId, $rangeInfo);
01573          if ($eventLogEntries->isInBounds()) break;
01574          unset($rangeInfo);
01575          $rangeInfo =& $eventLogEntries->getLastPageRangeInfo();
01576          unset($eventLogEntries);
01577       }
01578 
01579       $templateMgr =& TemplateManager::getManager();
01580 
01581       $templateMgr->assign('showBackLink', true);
01582       $templateMgr->assign('isDirector', Validation::isDirector());
01583       $templateMgr->assign_by_ref('submission', $submission);
01584       $templateMgr->assign_by_ref('eventLogEntries', $eventLogEntries);
01585       $templateMgr->display('trackDirector/submissionEventLog.tpl');
01586    }
01587 
01591    function clearSubmissionEventLog($args) {
01592       $paperId = isset($args[0]) ? (int) $args[0] : 0;
01593       $logId = isset($args[1]) ? (int) $args[1] : 0;
01594       $this->validate($paperId);
01595       $submission =& $this->submission;
01596 
01597       $logDao =& DAORegistry::getDAO('PaperEventLogDAO');
01598 
01599       if ($logId) {
01600          $logDao->deleteLogEntry($logId, $paperId);
01601 
01602       } else {
01603          $logDao->deletePaperLogEntries($paperId);
01604       }
01605 
01606       Request::redirect(null, null, null, 'submissionEventLog', $paperId);
01607    }
01608 
01612    function submissionEmailLog($args) {
01613       $paperId = isset($args[0]) ? (int) $args[0] : 0;
01614       $logId = isset($args[1]) ? (int) $args[1] : 0;
01615       $this->validate($paperId);
01616       $submission =& $this->submission;
01617       
01618       $this->setupTemplate(true, $paperId, 'history');
01619 
01620       $templateMgr =& TemplateManager::getManager();
01621 
01622       $templateMgr->assign('isDirector', Validation::isDirector());
01623       $templateMgr->assign_by_ref('submission', $submission);
01624 
01625       if ($logId) {
01626          $logDao =& DAORegistry::getDAO('PaperEmailLogDAO');
01627          $logEntry =& $logDao->getLogEntry($logId, $paperId);
01628       }
01629 
01630       if (isset($logEntry)) {
01631          $templateMgr->assign_by_ref('logEntry', $logEntry);
01632          $templateMgr->display('trackDirector/submissionEmailLogEntry.tpl');
01633 
01634       } else {
01635          $rangeInfo =& Handler::getRangeInfo('emailLogEntries', array($paperId));
01636 
01637          import('paper.log.PaperLog');
01638          while (true) {
01639             $emailLogEntries =& PaperLog::getEmailLogEntries($paperId, $rangeInfo);
01640             if ($emailLogEntries->isInBounds()) break;
01641             unset($rangeInfo);
01642             $rangeInfo =& $emailLogEntries->getLastPageRangeInfo();
01643             unset($emailLogEntries);
01644          }
01645          $templateMgr->assign_by_ref('emailLogEntries', $emailLogEntries);
01646          $templateMgr->display('trackDirector/submissionEmailLog.tpl');
01647       }
01648    }
01649 
01653    function submissionEmailLogType($args) {
01654       $paperId = isset($args[0]) ? (int) $args[0] : 0;
01655       $assocType = isset($args[1]) ? (int) $args[1] : null;
01656       $assocId = isset($args[2]) ? (int) $args[2] : null;
01657       $this->validate($paperId);
01658       $submission =& $this->submission;
01659       $this->setupTemplate(true, $paperId, 'history');
01660 
01661       $rangeInfo =& Handler::getRangeInfo('eventLogEntries', array($paperId, $assocType, $assocId));
01662       $logDao =& DAORegistry::getDAO('PaperEmailLogDAO');
01663       while (true) {
01664          $emailLogEntries =& $logDao->getPaperLogEntriesByAssoc($paperId, $assocType, $assocId, $rangeInfo);
01665          if ($emailLogEntries->isInBounds()) break;
01666          unset($rangeInfo);
01667          $rangeInfo =& $emailLogEntries->getLastPageRangeInfo();
01668          unset($emailLogEntries);
01669       }
01670 
01671       $templateMgr =& TemplateManager::getManager();
01672 
01673       $templateMgr->assign('showBackLink', true);
01674       $templateMgr->assign('isDirector', Validation::isDirector());
01675       $templateMgr->assign_by_ref('submission', $submission);
01676       $templateMgr->assign_by_ref('emailLogEntries', $emailLogEntries);
01677       $templateMgr->display('trackDirector/submissionEmailLog.tpl');
01678    }
01679 
01683    function clearSubmissionEmailLog($args) {
01684       $paperId = isset($args[0]) ? (int) $args[0] : 0;
01685       $logId = isset($args[1]) ? (int) $args[1] : 0;
01686       $this->validate($paperId);
01687 
01688       $logDao =& DAORegistry::getDAO('PaperEmailLogDAO');
01689 
01690       if ($logId) {
01691          $logDao->deleteLogEntry($logId, $paperId);
01692 
01693       } else {
01694          $logDao->deletePaperLogEntries($paperId);
01695       }
01696 
01697       Request::redirect(null, null, null, 'submissionEmailLog', $paperId);
01698    }
01699 
01700    // Submission Notes Functions
01701 
01706    function addSubmissionNote() {
01707       $paperId = Request::getUserVar('paperId');
01708       $this->validate($paperId);
01709 
01710       TrackDirectorAction::addSubmissionNote($paperId);
01711       Request::redirect(null, null, null, 'submissionNotes', $paperId);
01712    }
01713 
01718    function removeSubmissionNote() {
01719       $paperId = Request::getUserVar('paperId');
01720       $this->validate($paperId);
01721 
01722       TrackDirectorAction::removeSubmissionNote($paperId);
01723       Request::redirect(null, null, null, 'submissionNotes', $paperId);
01724    }
01725 
01730    function updateSubmissionNote() {
01731       $paperId = Request::getUserVar('paperId');
01732       $this->validate($paperId);
01733 
01734       TrackDirectorAction::updateSubmissionNote($paperId);
01735       Request::redirect(null, null, null, 'submissionNotes', $paperId);
01736    }
01737 
01742    function clearAllSubmissionNotes() {
01743       $paperId = Request::getUserVar('paperId');
01744       $this->validate($paperId);
01745 
01746       TrackDirectorAction::clearAllSubmissionNotes($paperId);
01747       Request::redirect(null, null, null, 'submissionNotes', $paperId);
01748    }
01749 
01753    function submissionNotes($args) {
01754       $paperId = isset($args[0]) ? (int) $args[0] : 0;
01755       $noteViewType = isset($args[1]) ? $args[1] : '';
01756       $noteId = isset($args[2]) ? (int) $args[2] : 0;
01757 
01758       $this->validate($paperId);
01759       $this->setupTemplate(true, $paperId, 'history');
01760       $submission =& $this->submission;
01761 
01762       $paperNoteDao =& DAORegistry::getDAO('PaperNoteDAO');
01763 
01764       // submission note edit
01765       if ($noteViewType == 'edit') {
01766          $paperNote = $paperNoteDao->getPaperNoteById($noteId);
01767       }
01768 
01769       $templateMgr =& TemplateManager::getManager();
01770 
01771       $templateMgr->assign('paperId', $paperId);
01772       $templateMgr->assign_by_ref('submission', $submission);
01773       $templateMgr->assign('noteViewType', $noteViewType);
01774       if (isset($paperNote)) {
01775          $templateMgr->assign_by_ref('paperNote', $paperNote);
01776       }
01777 
01778       if ($noteViewType == 'edit' || $noteViewType == 'add') {
01779          $templateMgr->assign('showBackLink', true);
01780       } else {
01781          $rangeInfo =& Handler::getRangeInfo('submissionNotes', array($paperId));
01782          while (true) {
01783             $submissionNotes =& $paperNoteDao->getPaperNotes($paperId, $rangeInfo);
01784             if ($submissionNotes->isInBounds()) break;
01785             unset($rangeInfo);
01786             $rangeInfo =& $submissionNotes->getLastPageRangeInfo();
01787             unset($submissionNotes);
01788          }
01789          $templateMgr->assign_by_ref('submissionNotes', $submissionNotes);
01790       }
01791 
01792       $templateMgr->display('trackDirector/submissionNotes.tpl');
01793    }
01794 
01795 
01796    //
01797    // Misc
01798    //
01799 
01804    function downloadFile($args) {
01805       $paperId = isset($args[0]) ? $args[0] : 0;
01806       $fileId = isset($args[1]) ? $args[1] : 0;
01807       $revision = isset($args[2]) ? $args[2] : null;
01808 
01809       $this->validate($paperId);
01810       if (!TrackDirectorAction::downloadFile($paperId, $fileId, $revision)) {
01811          Request::redirect(null, null, null, 'submission', $paperId);
01812       }
01813    }
01814 
01819    function viewFile($args) {
01820       $paperId = isset($args[0]) ? $args[0] : 0;
01821       $fileId = isset($args[1]) ? $args[1] : 0;
01822       $revision = isset($args[2]) ? $args[2] : null;
01823 
01824       $this->validate($paperId);
01825       if (!TrackDirectorAction::viewFile($paperId, $fileId, $revision)) {
01826          Request::redirect(null, null, null, 'submission', $paperId);
01827       }
01828    }
01829 
01830 
01831    //
01832    // Validation
01833    //
01834 
01842    function validate($paperId, $access = null) {
01843       parent::validate();
01844 
01845       $isValid = true;
01846 
01847       $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
01848       $conference =& Request::getConference();
01849       $schedConf =& Request::getSchedConf();
01850       $user =& Request::getUser();
01851 
01852       $trackDirectorSubmission =& $trackDirectorSubmissionDao->getTrackDirectorSubmission($paperId);
01853 
01854       if ($trackDirectorSubmission == null) {
01855          $isValid = false;
01856 
01857       } else if ($trackDirectorSubmission->getSchedConfId() != $schedConf->getId()) {
01858          $isValid = false;
01859 
01860       } else if ($trackDirectorSubmission->getDateSubmitted() == null) {
01861          $isValid = false;
01862 
01863       } else {
01864          $templateMgr =& TemplateManager::getManager();
01865          // If this user isn't the submission's director, they don't have access.
01866          $editAssignments =& $trackDirectorSubmission->getEditAssignments();
01867          $wasFound = false;
01868          foreach ($editAssignments as $editAssignment) {
01869             if ($editAssignment->getDirectorId() == $user->getId()) {
01870                $wasFound = true;
01871             }
01872          }
01873          if (!$wasFound && !Validation::isDirector()) $isValid = false;
01874       }
01875 
01876       if (!$isValid) {
01877          Request::redirect(null, null, null, Request::getRequestedPage());
01878       }
01879 
01880       // If necessary, note the current date and time as the "underway" date/time
01881       $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
01882       $editAssignments =& $trackDirectorSubmission->getEditAssignments();
01883       foreach ($editAssignments as $editAssignment) {
01884          if ($editAssignment->getDirectorId() == $user->getId() && $editAssignment->getDateUnderway() === null) {
01885             $editAssignment->setDateUnderway(Core::getCurrentDate());
01886             $editAssignmentDao->updateEditAssignment($editAssignment);
01887          }
01888       }
01889 
01890       $this->submission =& $trackDirectorSubmission;
01891       return true;
01892    }
01893 }
01894 ?>

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