예제 #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");
     }
 }
예제 #2
0
 /**
  * Show the list of papers wit their status
  */
 function paperstatusAction()
 {
     $paperTbl = new Paper();
     $paperStatusTbl = new PaperStatus();
     $exportLatex = $exportExcel = false;
     if (isset($_REQUEST['export_latex'])) {
         $exportLatex = true;
         $this->view->message = "The LaTeX file <i>paperstatus.tex</i> has been generated in files/selection";
     }
     if (isset($_REQUEST['export_excel'])) {
         $exportExcel = true;
         $this->view->message = "The LaTeX file <i>paperstatus.tex</i> has been generated in files/selection";
     } else {
         $this->view->MESSAGE = "";
     }
     if (!$exportExcel) {
         $this->view->set_file("content", "paperstatus.xml");
         $this->view->set_block("content", "SELECTION_FORM");
         $this->view->set_block("content", "MESSAGE");
         $this->view->set_block("content", "SHOW_SELECTION_FORM");
         $this->view->set_file("ranked_papers_list", "ranked_papers.xml");
     } else {
         $this->view->set_file("ranked_papers_list", "paperstatus_excel.xml");
     }
     // Check whether the current selection must be changed
     if (isset($_POST['spStatus'])) {
         $this->config->changeCurrentSelection();
     }
     if (isset($_REQUEST['remove'])) {
         $reviewTbl = new Review();
         $review = $reviewTbl->find($_REQUEST['idPaper'], $_REQUEST['remove'])->current();
         if (is_object($review)) {
             $review->delete();
         }
     } else {
         if (isset($_REQUEST['idPaper'])) {
             // If the status is submitted: update in the DB
             $idPaper = $_REQUEST['idPaper'];
             $status = $_REQUEST['status'];
             foreach ($idPaper as $key => $val) {
                 if (isset($status[$val])) {
                     // echo "ID = $val<br/>";
                     $paper = $paperTbl->find($val)->current();
                     if (is_object($paper)) {
                         $paper->status = $status[$val];
                         $paper->save();
                     } else {
                         throw new Zmax_Exception("Unknown paper id sent to the change status function?");
                     }
                 }
             }
         }
     }
     // 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();
         }
     }
     // 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->view->base_url . "/admin/chair/paperstatus", $this->view, $this->db_v1));
         $this->view->set_var("SHOW_SELECTION_FORM", "");
     } else {
         $this->view->set_var("SELECTION_FORM", "");
     }
     // Create the list of lists to toggle all the selected papers
     $comma = $listLinks = "";
     $statusList = $paperStatusTbl->fetchAll("final_status='Y'");
     foreach ($statusList as $status) {
         $listLinks .= $comma . " <a href='#' onClick=\"TogglePaperStatus('{$status->id}')\">" . $status->label . "</a>";
         $comma = ",";
     }
     $this->view->set_var("TOGGLE_LIST", $listLinks);
     // Always list the papers
     if ($exportExcel) {
         $this->papersReviews($this->view, "ranked_papers_list", false);
     } else {
         $this->papersReviews($this->view, "ranked_papers_list");
     }
     // In addition, produce the Latex file
     if ($exportLatex) {
         $anonymized = false;
         if (isset($_REQUEST['anonymized'])) {
             $anonymized = true;
         }
         // Instantiate the data export object
         $dataExport = new DataExport($this->view->getScriptPaths());
         // Load the latex templates
         $dataExport->getView()->setFile("latex_papers_list", "paperstatus.tex");
         $this->papersReviews($dataExport->getView(), "latex_papers_list", false, $anonymized);
         // The directory where Latex files are produced
         $tex_dir = "selection/";
         $dataExport->getView()->assign("result", "latex_papers_list");
         $result = $dataExport->replaceBadChars($dataExport->getView()->result);
         $dataExport->writeFile($tex_dir, "paperstatus.tex", $result);
         $dataExport->downloadFile($tex_dir, "paperstatus.tex");
     }
     if ($exportExcel) {
         $this->view->assign("export", "ranked_papers_list");
         $this->exportFile("submissions.xls", "text/xls", $this->view->export);
         return;
     }
     echo $this->view->render("layout");
 }