// Function that marks all the papers in the current selectionfunction GetCurrentSelection ($db){ // Initialize the current selection $emailCurrentUser = getCurrentUserEmail($db); $qCS = "DELETE FROM CurrentSelection WHERE emailUser='$emailCurrentUser'"; $db->execRequete ($qCS); // crWhere : applies to selection on paper // crJoin : applies to outer join Paper Review $sid = session_id(); $status = minStatus($db, $sid); $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. $config = GetConfigPerso ($db, $emailCurrentUser); if ($config['papersWithStatus'] == SP_ANY_STATUS) { $crWhere .= ""; } else if ($config['papersWithStatus'] == SP_NOT_YET_ASSIGNED) { $crWhere .= " AND status IS NULL "; } else { $crWhere .= " AND status='" . $config['papersWithStatus'] . "'"; } // The category if ($config['papersCategory'] == SP_ANY_STATUS) { // NOP } else { $crWhere .= " AND category='" . $config['papersCategory'] . "'"; } // Full text search on titles? if ($config['papersWithTitle'] != "Any") $crWhere .= " AND title LIKE '%" . $config['papersWithTitle'] . "%' "; // Show uploaded or not yet uploaded papers? if ($config['papersUploaded'] == "Y") $crWhere .= " AND isUploaded = 'Y' "; if ($config['papersUploaded'] == "N") $crWhere .= " AND isUploaded = 'N' "; // Show papers for a specific reviewer? if ($config['papersWithReviewer'] != "All") { if($config['papersWithReviewer'] == "None") { // We must select the papers without reviewers $crWhere .= " AND p.id NOT IN " . "(SELECT idPaper from Review) "; } else $crWhere .= " AND email='" . $config['papersWithReviewer'] . "' "; } // Sort the papers on the average 'overall' field $sid = session_id(); if ($status == 3) { $subQuery = "(SELECT p.* from Paper p, Editor e, Session s WHERE s.idSession='$sid'" . " AND s.email=e.emailEditor AND e.idPaper=p.id ORDER BY id) AS p1"; $query = "SELECT DISTINCT * FROM $subQuery LEFT JOIN Review r ON p1.id=r.idPaper WHERE $crWhere"; } else { if ($status < 3) { if ($config['papersWithEditor']!="All") { if($config['papersWithEditor'] == "None") { // We must select the papers without reviewers $crWhere .= " AND p.id NOT IN " . "(SELECT idPaper from Editor) "; $subQuery = "Paper p"; } else { $emailEditor = $config['papersWithEditor']; $subQuery = "(SELECT p.* FROM Paper p, Editor e " . "WHERE p.id=e.idPaper AND e.emailEditor=" . "'$emailEditor') AS p"; } } else { $subQuery = "Paper p"; } $query = "SELECT DISTINCT * FROM $subQuery LEFT JOIN Review r ON p.id=r.idPaper WHERE $crWhere"; } } $res = $db->execRequete ($query); while ($paper = $db->objetSuivant($res)) { $keep = $keep2 = $keep3 = $keep4 = $keep5 = false; $keep6 = $keep7 = true; // Should we consider conflicts? if ($config['papersWithConflict'] == "Y" and PaperInConflict($paper->id,$db)) { $keep = true; } else if ($config['papersWithConflict'] == "N" and !PaperInConflict($paper->id,$db)) { $keep = true; } else if ($config['papersWithConflict'] == "A") $keep = true; // Should we consider missing review? if ($config['papersWithMissingReview'] == "Y" and MissingReview($paper->id,$db)) $keep2 = true; else if ($config['papersWithMissingReview'] == "N" and !MissingReview($paper->id,$db)) $keep2 = true; else if ($config['papersWithMissingReview'] == "A") $keep2 = true; // Take care of the filter $overall = Overall ($paper->id, $db); if ($config['papersWithFilter'] == SP_ABOVE_FILTER and $overall >= $config['papersWithRate']) $keep3 = true; else if ($config['papersWithFilter'] == SP_BELOW_FILTER and $overall <= $config['papersWithRate']) $keep3 = true; else if ($config['papersWithFilter'] == 0) $keep3 = true; // Take care of authors if ($config['papersWithAuthor'] != "Any" and !empty($config['papersWithAuthor'])) { $authors = GetAuthors($paper->id, $db, false, "string", $paper->authors); if (strpos($authors, $config['papersWithAuthor'])) { $keep4 = true; } } else $keep4 = true; // Show papers for a specific topic? if ($config['papersWithTopic'] != 0) { $the_topic = $config['papersWithTopic']; if ($paper->topic == $the_topic) $keep5 = true; // OK with the main topic else { /*$rt = $db->execRequete ("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->execRequete ("SELECT * FROM PaperAnswer WHERE id_paper='$paper->id' " . "AND id_question='$id_question' AND id_answer='$id_choice'"); if (!is_object($db->objetSuivant($rq))) { $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->execRequete ("SELECT * FROM Review r, ReviewAnswer a " . " WHERE id_paper='$paper->id' AND r.email=a.email " . "AND id_question='$id_question' AND id_answer='$id_choice'"); if (!is_object($db->objetSuivant($rq))) { $keep7 = false; break; } // No need to look further } } if ($keep and $keep2 and $keep3 and $keep4 and $keep5 and $keep6 and $keep7) { $qCS = "insert into CurrentSelection (idPaper, emailUser) " . "values ('$paper->id', '$emailCurrentUser') on duplicate key update " . "emailUser='$emailCurrentUser'"; $db->execRequete($qCS); } }}