/**
  * Post peer review comments.
  */
 function postDirectorDecisionComment()
 {
     parent::validate();
     $this->setupTemplate(true);
     $paperId = Request::getUserVar('paperId');
     // If the user pressed the "Save and email" button, then email the comment.
     $emailComment = Request::getUserVar('saveAndEmail') != null ? true : false;
     $submissionEditHandler = new SubmissionEditHandler();
     $submissionEditHandler->validate($paperId);
     $paperDao =& DAORegistry::getDAO('PaperDAO');
     $submission =& $paperDao->getPaper($paperId);
     if (TrackDirectorAction::postDirectorDecisionComment($submission, $emailComment)) {
         TrackDirectorAction::viewDirectorDecisionComments($submission);
     }
 }
 /**
  * Validate that the user is the assigned track director for
  * the paper, or is a managing director.
  * Redirects to trackDirector index page if validation fails.
  * @param $paperId int Paper ID to validate
  * @param $access int Optional name of access level required -- see TRACK_DIRECTOR_ACCESS_... constants
  */
 function validate($request, $paperId, $access = null)
 {
     parent::validate($request);
     $isValid = true;
     $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
     $conference =& $request->getConference();
     $schedConf =& $request->getSchedConf();
     $user =& $request->getUser();
     $trackDirectorSubmission =& $trackDirectorSubmissionDao->getTrackDirectorSubmission($paperId);
     if ($trackDirectorSubmission == null) {
         $isValid = false;
     } else {
         if ($trackDirectorSubmission->getSchedConfId() != $schedConf->getId()) {
             $isValid = false;
         } else {
             if ($trackDirectorSubmission->getDateSubmitted() == null) {
                 $isValid = false;
             } else {
                 $templateMgr =& TemplateManager::getManager();
                 // If this user isn't the submission's director, they don't have access.
                 $editAssignments =& $trackDirectorSubmission->getEditAssignments();
                 $wasFound = false;
                 foreach ($editAssignments as $editAssignment) {
                     if ($editAssignment->getDirectorId() == $user->getId()) {
                         $wasFound = true;
                     }
                 }
                 if (!$wasFound && !Validation::isDirector()) {
                     $isValid = false;
                 }
             }
         }
     }
     if (!$isValid) {
         $request->redirect(null, null, null, $request->getRequestedPage());
     }
     // If necessary, note the current date and time as the "underway" date/time
     $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
     $editAssignments =& $trackDirectorSubmission->getEditAssignments();
     foreach ($editAssignments as $editAssignment) {
         if ($editAssignment->getDirectorId() == $user->getId() && $editAssignment->getDateUnderway() === null) {
             $editAssignment->setDateUnderway(Core::getCurrentDate());
             $editAssignmentDao->updateEditAssignment($editAssignment);
         }
     }
     $this->submission =& $trackDirectorSubmission;
     return true;
 }