function computeprefsAction() { // Load the template $this->view->setFile("content", "computeprefs.xml"); $this->view->setBlock("content", "MEMBER", "MEMBERS"); $paperTbl = new Paper(); $userTbl = new User(); $ratingTbl = new Rating(); // Loop on PC members $members = $userTbl->fetchAll("roles LIKE '%R%'"); $i = 0; foreach ($members as $member) { $this->view->css_class = Config::CssCLass($i++); $member->putInView($this->view); // Loop on papers if (1 == 1) { $qPapers = "SELECT * FROM Paper"; } else { // Loop on papers that match the reviewer's topics $qPapers = "SELECT p.* FROM (Paper p LEFT JOIN PaperTopic t ON id=id_paper), " . " UserTopic s " . " WHERE (p.topic=s.idTopic OR t.id_topic=s.idTopic) AND s.id_user='******' "; } $comments = ""; $rPapers = $this->zmax_context->db->query($qPapers); while ($p = $rPapers->fetch(Zend_Db::FETCH_OBJ)) { // instantiate a PaperRow object. Ok, not elegant, but easier $paper = $paperTbl->find($p->id)->current(); $conflict = false; // Get the rate, if exists $rating = $ratingTbl->find($paper->id, $member->id)->current(); if (!is_object($rating)) { // OK, the preference is unset. Check whether there is a conflict $rating = $ratingTbl->createRow(); $rating->idPaper = $paper->id; $rating->id_user = $member->id; $conflict = $paper->checkConflictWithuser($member, $comments); if ($conflict) { // Conflict! The default preference is 0 $rating->rate = 0; } else { // Check whether some topics match if ($member->matchTopic($paper->topic)) { // Match! The default preference is 3 $comments .= "Topic match with paper {$paper->id} ({$paper->title})<br/> "; $rating->rate = 3; } else { $rating->rate = 2; } } // OK, now save the rating $rating->save(); } else { $comments = $this->zmax_context->texts->admin->conflicts_prefs_already_set; } } // Loop on papers $this->view->comments = $comments; $this->view->append("MEMBERS", "MEMBER"); } // End of loop on users echo $this->view->render("layout"); }
/** * Modify the bid of a reviewer of the paper */ function addBid($idPaper, $rate) { $found = false; $bids = $this->findRating(); foreach ($bids as $bid) { if ($bid->idPaper == $idPaper) { $bid->rate = $rate; $found = true; $bid->save(); } } // Insert if not found if (!$found) { $ratingTbl = new Rating(); $rating = $ratingTbl->createRow(); $rating->idPaper = $idPaper; $rating->id_user = $this->id; $rating->rate = $rate; $rating->save(); } }