Example #1
0
 public function getPapers()
 {
     if ($this->papers == null) {
         $temp = Paper::find();
         $this->papers = array();
         foreach ($temp as $paper) {
             $this->papers[$paper->id] = $paper;
         }
     }
     return $this->papers;
 }
 /**
  * The paper action: shows the detail son a paper
  */
 function paperAction()
 {
     if (!$this->config->isPhaseOpen(Config::REVIEWING_PHASE)) {
         $this->view->content = $this->texts->reviewer->review_phase_is_closed;
         echo $this->view->render("layout");
         return;
     }
     $reviewTbl = new Review();
     $paperTbl = new Paper();
     $messageTbl = new Message();
     $this->view->setFile("content", "paper.xml");
     $this->view->setBlock("content", "paper_status_link");
     $this->view->setBlock("content", "message", "messages");
     $this->view->setBlock("content", "review", "show_review");
     $this->view->setBlock("review", "review_mark", "review_marks");
     $this->view->setBlock("review", "review_answer", "review_answers");
     $this->view->initial_message = "";
     // Am I an admin? If yes I want a link to the paper status page
     if (!$this->user->isAdmin()) {
         $this->view->paper_status_link = "";
     }
     $texts = $this->zmax_context->texts;
     if (isset($_REQUEST['id_paper']) and $this->config->discussion_mode != Config::NO_DISCUSSION) {
         $idPaper = $this->getRequest()->getParam("id_paper");
         $review = $reviewTbl->find($idPaper, $this->user->id)->current();
         $paper = $paperTbl->find($idPaper)->current();
         $paper->putInView($this->view);
         // Check that the paper is REALLY assigned to the reviewer (or admin)
         if (is_object($review) or $this->user->isAdmin()) {
             // Show all other SUBMITTED reviews, do not propose to see only my review
             $this->view->show_review = "";
             $reviews = $paper->findReview();
             foreach ($reviews as $otherReview) {
                 if (!empty($otherReview->overall)) {
                     $this->view->show_review .= $otherReview->showReview($this->view);
                 }
             }
             // Message submitted ? Store it in the DB
             if (isset($_REQUEST['form_message'])) {
                 $message = $messageTbl->createRow();
                 $message->id_parent = $this->getRequest()->getParam("id_parent");
                 $message->id_user = $this->user->id;
                 $message->id_paper = $this->getRequest()->getParam("id_paper");
                 $message->message = htmlSpecialChars($this->getRequest()->getParam("message"), ENT_NOQUOTES);
                 $message->date = date("Y-m-d H-i-s");
                 $message->save();
                 // And now, we must send the message to the reviewers and to the PC chair.
                 $mail = new Mail(Mail::SOME_USER, $this->texts->mail->subj_new_message . " " . $paper->id, $this->view->getScriptPaths());
                 $mail->loadTemplate($this->lang, "new_message");
                 $mail->setFormat(Mail::FORMAT_HTML);
                 $mail->getEngine()->base_url = $this->view->base_url;
                 $mail->getEngine()->author_first_name = $this->user->first_name;
                 $mail->getEngine()->author_last_name = $this->user->last_name;
                 $paper->putInView($mail->getEngine());
                 $message->putInView($mail->getEngine());
                 // Send the message to the PC chair.
                 $fakeName = "User" . "->first_name";
                 $mail->getEngine()->setVar($fakeName, $this->config->chair_names);
                 $mail->setTo($this->config->chairMail);
                 $mail->send();
                 // Now, mail to each OTHER reviewer
                 $reviews = $paper->findReview();
                 $mailOthers = $comma = "";
                 foreach ($reviews as $review) {
                     if ($review->id_user != $this->user->id) {
                         $reviewer = $review->findParentUser();
                         $reviewer->putInView($mail->getEngine());
                         $mail->setTo($reviewer->email);
                         $mail->send();
                     }
                 }
             }
             // Show the tree of messages
             $this->view->messages = Message::display($paper->id, 0, $this->view);
         } else {
             $this->view->content = "You do not have access to this paper!<br/>";
         }
     } else {
         $this->view->content = "Invalid action<br/>";
     }
     echo $this->view->render("layout");
 }
Example #3
0
 private function getCurrentSelection()
 {
     $db = Zend_Db_Table::getDefaultAdapter();
     $paperTbl = new Paper();
     // Initialize the current selection
     $db->query("UPDATE Paper SET inCurrentSelection='N'");
     // crWhere : applies to selection on paper
     // crJoin  : applies to outer join Paper Review
     $crJoin = $crWhere = " 1 = 1 ";
     if (isset($_POST['paperQuestions'])) {
         $paperQuestions = $_POST['paperQuestions'];
     } else {
         $paperQuestions = array();
     }
     if (isset($_POST['reviewQuestions'])) {
         $reviewQuestions = $_POST['reviewQuestions'];
     } else {
         $reviewQuestions = array();
     }
     // Take into account the filtering criterias.
     if ($this->papersWithStatus == SP_ANY_STATUS) {
         $crWhere .= "";
     } else {
         if ($this->papersWithStatus == SP_NOT_YET_ASSIGNED) {
             $crWhere .= " AND p.status IS NULL";
             // EXISTS (SELECT 'c' FROM PaperStatus s WHERE p.status=s.id AND final_status !='Y') ";
         } else {
             $crWhere .= " AND status='" . $this->papersWithStatus . "'";
         }
     }
     // Full text search on titles?
     if ($this->papersWithTitle != "Any") {
         $crWhere .= " AND title LIKE '%" . $this->papersWithTitle . "%' ";
     }
     // Show uploaded or not yet uploaded papers?
     if ($this->papersUploaded == "Y") {
         $crWhere .= " AND isUploaded = 'Y' ";
     }
     if ($this->papersUploaded == "N") {
         $crWhere .= " AND isUploaded = 'N' ";
     }
     // Show papers for a specific reviewer?
     if ($this->papersWithReviewer != "All") {
         $crWhere .= " AND id_user='******' ";
     }
     // Sort the papers on the average 'overall' field
     $query = "SELECT DISTINCT p.* FROM Paper p LEFT JOIN Review r ON p.id=r.idPaper" . " WHERE {$crWhere} ";
     $res = $db->query($query);
     while ($p = $res->fetch(Zend_Db::FETCH_OBJ)) {
         $paper = $paperTbl->find($p->id)->current();
         $keep = $keep2 = $keep3 = $keep4 = $keep5 = false;
         $keep6 = $keep7 = true;
         // Should we consider conflicts?
         if ($this->papersWithConflict == "Y" and $this->paperInConflict($paper->id)) {
             $keep = true;
         } else {
             if ($this->papersWithConflict == "N" and $this->paperInConflict($paper->id)) {
                 $keep = true;
             } else {
                 if ($this->papersWithConflict == "A") {
                     $keep = true;
                 }
             }
         }
         // Should we consider missing review?
         if ($this->papersWithMissingReview == "Y" and $this->missingReview($paper->id)) {
             $keep2 = true;
         } else {
             if ($this->papersWithMissingReview == "N" and !$this->missingReview($paper->id)) {
                 $keep2 = true;
             } else {
                 if ($this->papersWithMissingReview == "A") {
                     $keep2 = true;
                 }
             }
         }
         // Take care of the filter
         $overall = $paper->averageMark();
         if ($this->papersWithFilter == SP_ABOVE_FILTER and $overall >= $this->papersWithRate) {
             $keep3 = true;
         } else {
             if ($this->papersWithFilter == SP_BELOW_FILTER and $overall <= $this->papersWithRate) {
                 $keep3 = true;
             } else {
                 if ($this->papersWithFilter == 0) {
                     $keep3 = true;
                 }
             }
         }
         // Take care of authors
         if ($this->papersWithAuthor != "Any" and !empty($this->papersWithAuthor)) {
             $authors = $paper->getAuthors();
             if (strpos($authors, $this->papersWithAuthor)) {
                 $keep4 = true;
             }
         } else {
             $keep4 = true;
         }
         // Show papers for a specific topic?
         if ($this->papersWithTopic != 0) {
             $the_topic = $this->papersWithTopic;
             if ($paper->topic == $the_topic) {
                 $keep5 = true;
                 // OK with the main topic
             } else {
                 /* FROM V1 -- NO LONGER USED
                    $rt = $db->query ("SELECT * FROM PaperTopic WHERE id_paper='$paper->id' "
                    . " AND id_topic='$the_topic'");
                    if ($db->objetSuivant($rt))
                    $keep5 = true; // found in other topics
                    else
                    $keep5 = false;
                    */
             }
         } else {
             $keep5 = true;
         }
         // Now look at the paper question
         reset($paperQuestions);
         foreach ($paperQuestions as $id_question => $id_choice) {
             if ($id_choice != SP_ANY_CHOICE) {
                 // Check that the paper's answer matches the choice
                 $rq = $db->query("SELECT * FROM PaperAnswer WHERE id_paper='{$paper->id}' " . "AND id_question='{$id_question}' AND id_answer='{$id_choice}'");
                 if (!is_object($rq->fetch(Zend_Db::FETCH_OBJ))) {
                     $keep6 = false;
                     break;
                 }
                 // No need to look further
             }
         }
         // Now look at the review question
         reset($reviewQuestions);
         foreach ($reviewQuestions as $id_question => $id_choice) {
             if ($id_choice != SP_ANY_CHOICE) {
                 // Check that some reviewer's answer matches the choice
                 $rq = $db->query("SELECT * FROM Review r, ReviewAnswer a " . " WHERE id_paper='{$paper->id}' AND r.id_user=a.id_user " . "AND id_question='{$id_question}' AND id_answer='{$id_choice}'");
                 if (!is_object($rq->fetch(Zend_Db::FETCH_OBJ))) {
                     $keep7 = false;
                     break;
                 }
                 // No need to look further
             }
         }
         //echo "Keep= (1: $keep) (2: $keep2) (3: $keep3) (4: $keep4) (5:$keep5) (6: $keep6) (7: $keep7)<br/>";
         if ($keep and $keep2 and $keep3 and $keep4 and $keep5 and $keep6 and $keep7) {
             // echo "Upate yes<br/>";
             $qCS = "UPDATE Paper SET inCurrentSelection='Y' WHERE id='{$paper->id}'";
             $db->query($qCS);
         }
     }
 }
Example #4
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");
     }
 }
Example #5
0
 /**
  * 删除Paper 表数据
  * 关联到Question,Question_ans表, 因此不能随意删除
  * 尤其是Question表, 其中的数据必须是在获取到paper_id 之后才能导入
  * @return boolean
  * true 删除成功
  * false 删除失败
  */
 public static function deletePaperData()
 {
     if (Question::count() != 0) {
         throw new Exception("The foreign key is used for table Question!");
     }
     $paper_data = Paper::find();
     try {
         $manager = new TxManager();
         $transaction = $manager->get();
         foreach ($paper_data as $record) {
             if ($record->delete() == false) {
                 $transaction->rollback("Cannot delete Paper data");
             }
         }
         $transaction->commit();
         return true;
     } catch (TxFailed $e) {
         throw new Exception("Failed, reason: " . $e->getMessage());
     }
 }
 /**
  * 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");
 }
 /**
  * Shows the info on a submission in a secondary window
  */
 function showinfoAction()
 {
     $paperTbl = new Paper();
     $this->view->setFile("content", "show_info.xml");
     $this->view->setBlock("content", "SECTION", "SECTIONS");
     $this->view->setBlock("content", "DISCUSSION", "SHOW_DISCUSSION");
     $this->view->setBlock("DISCUSSION", "message", "messages");
     $this->view->setFile("review", "show_tbl_review.xml");
     $this->view->setBlock("review", "review_mark", "review_marks");
     $this->view->setBlock("review", "review_answer", "review_answers");
     $idPaper = $this->getRequest()->getParam("id_paper");
     $paper = $paperTbl->find($idPaper)->current();
     if (!is_object($paper)) {
         throw new Zmax_Exception("showinfo: I am waiting for a valid paper id !?");
     }
     // Default: print only the basic informations. Do not show the reviews
     // nor the forum
     $this->view->setBlock("content", "ANSWER", "ANSWERS");
     $this->view->setBlock("content", "REVIEWER", "REVIEWERS");
     $this->view->setBlock("content", "REVIEWS");
     $this->view->setVar("SHOW_DISCUSSION", "");
     // instantiate the template for the paper and its dependent objects
     $paper->putInView($this->view);
     // Check the context to determine what must be printed
     if ($this->user->isAdmin() or isset($_REQUEST['in_forum'])) {
         // It is an administrator. Print everything
         $this->view->setVar("SHOW_REVIEWS", $paper->showReviews($this->view, true));
         // Add the messages if the discussion is opened
         if ($this->config->discussion_mode != Config::NO_DISCUSSION) {
             $this->view->messages = Message::display($idPaper, 0, $this->view);
             $this->view->assign("TMP_DISCUSSION", "DISCUSSION");
             $this->view->assign("SHOW_DISCUSSION", "TMP_DISCUSSION");
         }
     } else {
         if ($paper->hasReviewer($this->user->id)) {
             // It is a reviewer,
             $review = $paper->getReview($this->user->id);
             //check the 'allReviews' parameter
             if (isset($_REQUEST['allReviews'])) {
                 if ($_REQUEST['allReviews']) {
                     $this->view->SHOW_REVIEWS = $review->showReview($this->view, true);
                 } else {
                     $this->view->SHOW_REVIEWS = $paper->showReviews($this->view, true);
                 }
             }
             // Add the messages if the discussion is open
             // if ($config['discussion_mode'] != NO_DISCUSSION)
             //$this->view->set_var("FORUM", DisplayMessages($idPaper, 0, $db, false));
         }
     }
     // Take account of the 'noReview' and 'noForum' parameter
     if (isset($_REQUEST['noReview'])) {
         $this->view->REVIEWS = " ";
     }
     //  if (isSet($_REQUEST['noForum'])) $view->set_var("FORUM", "");
     $this->view->assign("action_result", "content");
     $this->view->assign("action_result2", "action_result");
     echo $this->view->action_result2;
 }