/** * Assign a list of reviewers to the paper */ function assignReviewers($tabIds) { $reviewTbl = new Review(); // Loop on the reviewers ids foreach ($tabIds as $id_user) { // Check whether the review exists $review = $reviewTbl->find($this->id, $id_user)->current(); // Never delete! Just insert if (!is_object($review)) { $review = $reviewTbl->createRow(); $review->idPaper = $this->id; $review->id_user = $id_user; $review->save(); } } }
/** * List of papers with their reviews */ private function papersReviews($view, $templateName, $html = true, $anonymized = false) { $db = Zend_Db_Table::getDefaultAdapter(); $paperTbl = new Paper(); $paperStatusTbl = new PaperStatus(); $criteriaTbl = new Criteria(); $reviewTbl = new Review(); $reviewMarkTbl = new ReviewMark(); $registry = Zend_registry::getInstance(); $config = $registry->get("Config"); $config->putInView($view); // Set the mail types $view->someUser = Mail::SOME_USER; // Extract the block for each paper $view->setBlock($templateName, "PAPER_DETAIL", "PAPERS"); $view->setBlock($templateName, "REVIEW_CRITERIA", "REVIEW_CRITERIAS"); $view->setBlock("PAPER_DETAIL", "PAPER_INFO", "PAPER_DATA"); $view->setBlock("PAPER_DETAIL", "REVIEW_MARK", "REVIEW_MARKS"); $view->setBlock("PAPER_DETAIL", "REVIEWER", "REVIEWER_INFO"); // Header of the table, taken from table Criteria $criterias = $criteriaTbl->fetchAll(); $listCriterias = array(); foreach ($criterias as $criteria) { $criteria->putInView($view); $listCriterias[] = $criteria; $view->append("REVIEW_CRITERIAS", "REVIEW_CRITERIA"); } // Sort the papers on the average 'overall' field $query = "SELECT p.*, round(AVG(overall),4) AS overall " . "FROM Paper p LEFT JOIN Review r ON p.id=r.idPaper " . " WHERE inCurrentSelection='Y' GROUP BY p.id"; $result = $db->query($query); $arrPaper = $rankPaper = array(); while ($paper = $result->fetch(Zend_Db::FETCH_OBJ)) { $arrPaper[$paper->id] = $paper; $rankPaper[$paper->id] = $paper->overall; } // Get the status list $statusList = $db->fetchPairs("SELECT * FROM PaperStatus WHERE final_status='Y'"); // Sort in descending order arsort($rankPaper); reset($rankPaper); // List the papers in order $iPaper = 0; foreach ($rankPaper as $idPaper => $overall) { $paper = $arrPaper[$idPaper]; // Choose the CSS class $view->css_class = Config::CssCLass($iPaper++); $view->paper_id = $paper->id; $view->paper_title = $paper->title; if (!$anonymized) { $view->paper_authors = PaperRow::getPaperAuthors($db, $paper); } else { $view->paper_authors = "[anonymized]"; } $view->paper_email_contact = $paper->emailContact; $view->paper_rank = $iPaper; $view->paper_overall = $overall; $view->form_status = Zmax_View_Phplib::checkboxField("radio", "status[{$paper->id}]", $statusList, $paper->status, array("length" => 2)); // Now, loop on reviews $qRev = "SELECT * FROM Review r, User u " . " WHERE idPaper='{$paper->id}' AND u.id=r.id_user"; $resRev = $db->query($qRev); $countReviews = 0; $mail_reviewers = $comma = ""; while ($review = $resRev->fetch(Zend_Db::FETCH_OBJ)) { $countReviews++; $mail_reviewers .= $comma . $review->email; $comma = ", "; } $view->paper_nb_reviewers = Max(1, $countReviews); //echo "Mail reviewers = $mail_reviewers<br/>"; $view->paper_email_reviewers = $mail_reviewers; $view->append("PAPER_DATA", "PAPER_INFO"); $resRev = $db->query($qRev); $iReview = 0; while ($review = $resRev->fetch(Zend_Db::FETCH_OBJ)) { $iReview++; $view->reviewer_id = $review->id; if ($anonymized == false) { $view->reviewer_fname = $review->first_name; $view->reviewer_lname = $review->last_name; $view->external_reviewer_fname = $review->fname_ext_reviewer; $view->external_reviewer_lname = $review->lname_ext_reviewer; $view->review_comments = $review->comments; } else { $view->reviewer_fname = $iReview; $view->reviewer_lname = ""; $view->external_reviewer_fname = ""; $view->external_reviewer_lname = ""; $view->review_comments = ""; } $view->reviewer_email = $review->email; $view->review_overall = $review->overall; $view->review_summary = $review->summary; $view->review_details = $review->details; if ($review->reviewerExpertise >= 1 and $review->reviewerExpertise <= 3) { $view->reviewer_expertise = Config::$Expertise[$review->reviewerExpertise]; } // Avoid to introduce Latex commands in Latex files .... if (!$html) { $view->review_summary = str_replace("\\", "", $view->review_summary); $view->review_details = str_replace("\\", "", $view->review_details); $view->review_comments = str_replace("\\", "", $view->review_comments); } $view->assign("REVIEWER_INFO", "REVIEWER"); reset($listCriterias); $view->set_var("REVIEW_MARKS", ""); foreach ($listCriterias as $criteria) { $reviewMark = $reviewMarkTbl->find($review->idPaper, $review->id_user, $criteria->id)->current(); if (!is_object($reviewMark)) { $reviewMark = $reviewMarkTbl->createRow(); // for default values } $reviewMark->putInView($view); $view->criteria_label = $criteria->label; $view->append("REVIEW_MARKS", "REVIEW_MARK"); } $view->append("PAPERS", "PAPER_DETAIL"); // The paper data is shown only once for all the reviews $view->set_var("PAPER_DATA", " "); } // Show the paper even without reviewer if ($countReviews == 0) { $review = $reviewTbl->createRow(); $review->putInView($view); $view->set_var("REVIEW_MARKS", ""); foreach ($listCriterias as $id => $label) { $reviewMark = $reviewMarkTbl->createRow(); $reviewMark->putInView($view); $view->append("REVIEW_MARKS", "REVIEW_MARK"); } $view->set_var("REVIEWER_INFO", ""); $view->append("PAPERS", "PAPER_DETAIL"); $view->set_var("PAPER_DATA", ""); } // Summary for the paper if ($html) { $statPaper = Paper::getStats($paper->id, $listCriterias); $markFieldName = "ReviewMark" . "->mark"; $overallFieldName = "review_overall"; $view->set_var("NB_REVIEWERS", 1); if ($html) { $view->set_var("PAPER_DATA", "<td> </td><th>Summary</th>"); } $view->set_var("REVIEWER_INFO", " "); $view->set_var($overallFieldName, $paper->overall); reset($listCriterias); $view->set_var("REVIEW_MARKS", ""); foreach ($listCriterias as $c) { $view->setVar($markFieldName, $statPaper[$c->id]); $view->append("REVIEW_MARKS", "REVIEW_MARK"); } $view->append("PAPERS", "PAPER_DETAIL"); $view->set_var("PAPER_DATA", ""); } } }