Ejemplo n.º 1
0
 /**
  * Send the status to authors, with anonymous reviews
  */
 function notifyAction()
 {
     $db = $this->zmax_context->db;
     $paperTbl = new Paper();
     $paperStatusTbl = new PaperStatus();
     // Load the reviews template
     $this->view->setFile("review", "review4author.xml");
     $this->view->setBlock("review", "review_mark", "review_marks");
     $this->view->setBlock("review", "review_answer", "review_answers");
     // Set the subject
     $subject = $this->texts->mail->subj_notification;
     if (isset($_REQUEST['id_paper'])) {
         // Mail for one paper
         $idPaper = $_REQUEST['id_paper'];
         $this->view->setFile("content", "showmessage.xml");
         $this->view->setBlock("content", "WARNING_TEMPLATE", " ");
         $paper = $paperTbl->find($idPaper)->current();
         if (!empty($paper->status)) {
             $paper->putInView($this->view);
             $this->view->reviews = $paper->showReviews($this->view);
             $statusRow = $paperStatusTbl->find($paper->status)->current();
             $mail = new Mail(Mail::SOME_USER, $subject, $this->view->getScriptPaths());
             $mail->setTo($paper->emailContact);
             $mail->setFormat(Mail::FORMAT_HTML);
             $mail->loadTemplate($this->lang, $statusRow->mailTemplate);
             // We know the paper, so we can instantiate the mail entities
             $this->view->setVar("mailTemplate", $mail->getTemplate());
             $this->view->assign("mailTemplate", "mailTemplate");
             $mail->setTemplate($this->view->mailTemplate);
             // Put in the view
             $mail->putInView($this->view);
         } else {
             $this->content = "Cannot send notification without a status<br/>";
         }
         echo $this->view->render("layout");
         return;
     } else {
         // Batch mail. Check that all papers have a status,
         // and that there are no missing reviews
         $this->view->setFile("content", "notify.xml");
         $this->view->setBlock("content", "TEMPLATE", "TEMPLATES");
         $res = $db->query("SELECT count(*) AS count FROM Paper p, PaperStatus s " . " WHERE p.status = s.id AND final_status != 'Y'");
         $p = $res->fetch(Zend_Db::FETCH_OBJ);
         if ($p->count > 0) {
             $this->view->content = "Cannot send notification mails: some papers do not have a status";
             echo $this->view->render("layout");
             exit;
         }
         $qReview = "SELECT count(*) AS count FROM Review WHERE overall IS NULL";
         $res = $db->query($qReview);
         $p = $res->fetch(Zend_Db::FETCH_OBJ);
         if ($p->count > 0) {
             $this->view->content = "Cannot send notification mails: missing reviews";
             echo $this->view->render("layout");
             exit;
         }
         // OK. Now give the list of the templates that will be used
         $i = 0;
         $paperStatusList = $paperStatusTbl->fetchAll("final_status = 'Y'");
         $mail = new Mail(Mail::SOME_USER, "", $this->view->getScriptPaths());
         foreach ($paperStatusList as $paperStatus) {
             $this->view->css_class = Config::CssCLass($i++);
             $paperStatus->putInView($this->view);
             $mail->loadTemplate($this->lang, $paperStatus->mailTemplate);
             $this->view->setVar("template_content-{$paperStatus->id}", $mail->getTemplate());
             $this->view->assign("template_content", "template_content-{$paperStatus->id}");
             $this->view->append("TEMPLATES", "TEMPLATE");
         }
         // Send the notification mails.
         $messages = "";
         if (isset($_REQUEST['confirmed']) or isset($_REQUEST['export'])) {
             PaperRow::$loadAbstracts = false;
             $papers = $paperTbl->fetchAll();
             $mail = new Mail(Mail::SOME_USER, $subject, $this->view->getScriptPaths());
             $mail->setFormat(Mail::FORMAT_HTML);
             $mail->setCopyToChair(true);
             foreach ($papers as $paper) {
                 $statusRow = $paperStatusTbl->find($paper->status)->current();
                 $mail->setTo($paper->emailContact);
                 $mail->loadTemplate($this->lang, $statusRow->mailTemplate);
                 $paper->putInView($mail->getEngine());
                 $mail->getEngine()->reviews = $paper->showReviews($this->view);
                 if (isset($_REQUEST['confirmed'])) {
                     $mail->send();
                 } else {
                     $messages .= $mail->getMessage() . "\n\n";
                 }
             }
         }
     }
     if (isset($_REQUEST['export'])) {
         header("Content-disposition: attachment; filename=notificationMails.txt");
         header("Content-Type: application/force-download");
         header("Content-Transfer-Encoding: text\n");
         header("Content-Length: " . strlen($messages));
         header("Pragma: no-cache");
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0, public");
         header("Expires: 0");
         echo $messages;
     } else {
         echo $this->view->render("layout");
     }
 }
Ejemplo n.º 2
0
 function submittedAction()
 {
     $paperTbl = new Paper();
     $reviewTbl = new Review();
     $requiredFileTbl = new RequiredFile();
     $db = $this->zmax_context->db;
     $this->view_initial_message = "";
     $this->view->mailType = Mail::SOME_USER;
     $this->view->setFile("content", "submitted.xml");
     // Check whether the current selection must be changed
     if (isset($_POST['spStatus'])) {
         $this->config->changeCurrentSelection();
     }
     // If required, hide the selection form
     if (isset($_REQUEST['hide_selection_form'])) {
         $this->config->show_selection_form = 'N';
         $this->config->save();
     } else {
         if (isset($_REQUEST['show_selection_form'])) {
             $this->config->show_selection_form = 'Y';
             $this->config->save();
         }
     }
     /* Select all the papers and list them.
     		 First extract the 'block' describing a line from the template */
     $this->view->setBlock("content", "PAPER_DETAIL", "PAPERS");
     $this->view->setBlock("content", "SELECTION_FORM");
     $this->view->setBlock("content", "SHOW_SELECTION_FORM");
     $this->view->setBlock("PAPER_DETAIL", "REVIEWER", "REVIEWERS");
     $this->view->setBlock("PAPER_DETAIL", "DOWNLOAD", "DOWNLOADS");
     $this->view->setBlock("DOWNLOAD", "DOWNLOAD_LINK", "THE_LINK");
     $config = $this->config_v1;
     // Show the form for filtering papers, if required
     if ($this->config->show_selection_form == 'Y') {
         $this->view->set_var("FORM_SELECT_PAPERS", $this->FormSelectPapers($this->myUrl(), $this->view, $this->db_v1));
         $this->view->set_var("SHOW_SELECTION_FORM", "");
     } else {
         $this->view->set_var("SELECTION_FORM", "");
     }
     $nbPapers = 0;
     // Check whether the paper must be removed
     if (isset($_REQUEST['instr'])) {
         if ($_REQUEST['instr'] == "remove" and isset($_REQUEST['idPaper'])) {
             $paper = $paperTbl->find($_REQUEST['idPaper'])->current();
             $paper->delete();
         }
         if ($_REQUEST['instr'] == "removeReviewer") {
             $review = $reviewTbl->find($_REQUEST['id_paper'], $_REQUEST['id_user'])->current();
             if ($review) {
                 $review->delete();
             }
         }
     }
     // Do not load abstracts
     PaperRow::$loadAbstracts = false;
     PaperRow::$loadAnswers = false;
     $papers = $paperTbl->fetchAll("inCurrentSelection='Y'", "id");
     $i = 0;
     foreach ($papers as $paper) {
         $this->view->set_var("REVIEWERS", "");
         $nbPapers++;
         $paper->putInView($this->view);
         // Choose the CSS class
         $this->view->css_class = Config::CssCLass($i++);
         $this->view->set_var("SESSION_ID", session_id());
         $this->view->set_var("SUBMISSION_URL", $this->config->submissionURL);
         /* Show the list of reviewers */
         $reviews = $paper->findReview();
         foreach ($reviews as $review) {
             $user = $review->findParentUser();
             $review->putInView($this->view);
             $user->putInView($this->view);
             $this->view->append("REVIEWERS", "REVIEWER");
         }
         // Loop on the files associated to the paper, and propose a download link
         $requiredFiles = $requiredFileTbl->fetchAll();
         $countRequired = 0;
         $this->view->DOWNLOADS = "";
         foreach ($requiredFiles as $requiredFile) {
             // Check the file is required in the current phase
             // if ($this->config->isPhaseOpen($requiredFile->id_phase)) {
             $requiredFile->putInView($this->view);
             $countRequired++;
             if (!$paper->fileExists($requiredFile)) {
                 $this->view->THE_LINK = $this->zmax_context->texts->reviewer->not_yet_uploaded;
             } else {
                 $this->view->assign("THE_LINK", "DOWNLOAD_LINK");
             }
             $this->view->assign("DOWNLOAD_BIS", "DOWNLOAD");
             $this->view->append("DOWNLOADS", "DOWNLOAD_BIS");
             // }
         }
         if ($countRequired == 0) {
             $this->view->DOWNLOADS = $this->zmax_context->texts->reviewer->no_file_to_download;
         }
         /* Instanciate the entities in PAPER_DETAIL. Put in PAPERS   */
         $this->view->append("PAPERS", "PAPER_DETAIL");
     }
     echo $this->view->render("layout");
 }