public static function make($qreq, Contact $user = null, $key = null)
 {
     $ps = null;
     if ($key !== null && isset($qreq[$key])) {
         $ps = $qreq[$key];
     } else {
         if ($key === null && isset($qreq["p"])) {
             $ps = $qreq["p"];
         } else {
             if ($key === null && isset($qreq["pap"])) {
                 $ps = $qreq["pap"];
             }
         }
     }
     if ($user && $ps === "all") {
         $s = new PaperSearch($user, $qreq);
         $ps = $s->paperList();
     } else {
         if ($ps === "all") {
             $ps = null;
         }
     }
     if (is_string($ps)) {
         $ps = preg_split('/\\s+/', $ps);
     }
     return new SearchSelection($ps);
 }
예제 #2
0
 public static function parse_sorter($text)
 {
     // parse the sorter
     $text = simplify_whitespace($text);
     if (preg_match('/\\A(\\d+)([a-z]*)\\z/i', $text, $m) || preg_match('/\\A([^-,+#]+)[,+#]([a-z]*)\\z/i', $text, $m)) {
         $sort = new ListSorter($m[1]);
         foreach (str_split(strtoupper($m[2])) as $x) {
             if ($x === "R" || $x === "N") {
                 $sort->reverse = $x === "R";
             } else {
                 if ($x === "M") {
                     $sort->score = "C";
                 } else {
                     if (isset(self::$score_sorts[$x])) {
                         $sort->score = $x;
                     }
                 }
             }
         }
     } else {
         $sort = PaperSearch::parse_sorter($text);
     }
     if ($sort->score === null) {
         $sort->score = self::default_score_sort();
     }
     return $sort;
 }
예제 #3
0
 /**
  * Show advanced search results.
  * @param $args array
  * @param $request PKPRequest
  */
 function advancedResults($args, &$request)
 {
     parent::validate();
     $this->setupTemplate($request, true);
     $rangeInfo = $this->getRangeInfo($request, 'search');
     $publishedPaperDao = DAORegistry::getDAO('PublishedPaperDAO');
     $searchConferenceId = $request->getUserVar('searchConference');
     if (!empty($searchConferenceId)) {
         $conferenceDao = DAORegistry::getDAO('ConferenceDAO');
         $conference =& $conferenceDao->getById($searchConferenceId);
         $yearRange = $publishedPaperDao->getPaperYearRange($conference->getId());
     } else {
         $conference =& $request->getConference();
         $yearRange = $publishedPaperDao->getPaperYearRange(null);
     }
     // Load the keywords array with submitted values
     $keywords = array(null => PaperSearch::parseQuery($request->getUserVar('query')));
     $keywords[PAPER_SEARCH_AUTHOR] = PaperSearch::parseQuery($request->getUserVar('author'));
     $keywords[PAPER_SEARCH_TITLE] = PaperSearch::parseQuery($request->getUserVar('title'));
     $keywords[PAPER_SEARCH_DISCIPLINE] = PaperSearch::parseQuery($request->getUserVar('discipline'));
     $keywords[PAPER_SEARCH_SUBJECT] = PaperSearch::parseQuery($request->getUserVar('subject'));
     $keywords[PAPER_SEARCH_TYPE] = PaperSearch::parseQuery($request->getUserVar('type'));
     $keywords[PAPER_SEARCH_COVERAGE] = PaperSearch::parseQuery($request->getUserVar('coverage'));
     $keywords[PAPER_SEARCH_GALLEY_FILE] = PaperSearch::parseQuery($request->getUserVar('fullText'));
     $keywords[PAPER_SEARCH_SUPPLEMENTARY_FILE] = PaperSearch::parseQuery($request->getUserVar('supplementaryFiles'));
     $fromDate = $request->getUserDateVar('dateFrom', 1, 1);
     if ($fromDate !== null) {
         $fromDate = date('Y-m-d H:i:s', $fromDate);
     }
     $toDate = $request->getUserDateVar('dateTo', 32, 12, null, 23, 59, 59);
     if ($toDate !== null) {
         $toDate = date('Y-m-d H:i:s', $toDate);
     }
     $results =& PaperSearch::retrieveResults($conference, $keywords, $fromDate, $toDate, $rangeInfo);
     $templateMgr =& TemplateManager::getManager($request);
     $templateMgr->setCacheability(CACHEABILITY_NO_STORE);
     $templateMgr->assign_by_ref('results', $results);
     $this->_assignAdvancedSearchParameters($request, $templateMgr, $yearRange);
     $templateMgr->display('search/searchResults.tpl');
 }
     echo "<table><tr>\n";
     foreach ($col as $thecol) {
         if (count($thecol)) {
             echo "<td class='top'><table>";
             foreach ($thecol as $td) {
                 echo "<tr><td style='padding:0 2em 1ex 0'>", $td, "</td></tr>";
             }
             echo "</table></td>\n";
         }
     }
     echo "</tr></table>\n";
 }
 // ajax assignment form
 echo Ht::form(hoturl_post("assign", "update=1"), array("id" => "assrevform")), "<div class='clear'>", Ht::hidden("kind", $qreq->kind), Ht::hidden("p", ""), Ht::hidden("pcs{$reviewer}", ""), Ht::hidden("reviewer", $reviewer), Ht::hidden("rev_roundtag", $qreq->rev_roundtag), "</div></form>\n\n";
 // main assignment form
 $search = new PaperSearch($Me, array("t" => $qreq->t, "q" => $qreq->q, "urlbase" => hoturl_site_relative_raw("manualassign", "reviewer={$reviewer}")));
 $paperList = new PaperList($search, ["sort" => true, "list" => true, "reviewer" => $pcm[$reviewer]], make_qreq());
 $paperList->display .= " topics ";
 if ($qreq->kind != "c") {
     $paperList->display .= "reviewers ";
 }
 if (isset($showau)) {
     $search->overrideMatchPreg = true;
     $search->matchPreg = array();
     if ($showau) {
         $search->matchPreg["authorInformation"] = make_match_preg($showau);
     }
     if ($showco) {
         $search->matchPreg["collaborators"] = make_match_preg($showco);
     }
 }
예제 #5
0
 /**
  * Execute import/export tasks using the command-line interface.
  * @param $args Parameters to the plugin
  */
 function executeCLI($scriptName, &$args)
 {
     //		$command = array_shift($args);
     $xmlFile = array_shift($args);
     $conferencePath = array_shift($args);
     $conferenceDao =& DAORegistry::getDAO('ConferenceDAO');
     $userDao =& DAORegistry::getDAO('UserDAO');
     $publishedPaperDao =& DAORegistry::getDAO('PublishedPaperDAO');
     $conference =& $conferenceDao->getConferenceByPath($conferencePath);
     if (!$conference) {
         if ($conferencePath != '') {
             echo Locale::translate('plugins.importexport.nlm.cliError') . "\n";
             echo Locale::translate('plugins.importexport.nlm.export.error.unknownConference', array('conferencePath' => $conferencePath)) . "\n\n";
         }
         $this->usage($scriptName);
         return;
     }
     if ($xmlFile != '') {
         switch (array_shift($args)) {
             case 'papers':
                 $results =& PaperSearch::formatResults($args);
                 if (!$this->exportPapers($results, $xmlFile)) {
                     echo Locale::translate('plugins.importexport.nlm.cliError') . "\n";
                     echo Locale::translate('plugins.importexport.nlm.export.error.couldNotWrite', array('fileName' => $xmlFile)) . "\n\n";
                 }
                 return;
         }
     }
     $this->usage($scriptName);
 }
예제 #6
0
    $start = ($page - 1) * $count;
    $offset = 0;
} else {
    $start = ($page - 2) * $count + $offset;
}
$nlinks = 4;
$Conf->header("Log", "actionlog", actionBar());
$wheres = array();
$Eclass["q"] = $Eclass["pap"] = $Eclass["acct"] = $Eclass["n"] = $Eclass["date"] = "";
$_REQUEST["q"] = trim(defval($_REQUEST, "q", ""));
$_REQUEST["pap"] = trim(defval($_REQUEST, "pap", ""));
$_REQUEST["acct"] = trim(defval($_REQUEST, "acct", ""));
$_REQUEST["n"] = trim(defval($_REQUEST, "n", "{$DEFAULT_COUNT}"));
$_REQUEST["date"] = trim(defval($_REQUEST, "date", "now"));
if ($_REQUEST["pap"]) {
    $Search = new PaperSearch($Me, array("t" => "all", "q" => $_REQUEST["pap"], "allow_deleted" => true));
    if (count($Search->warnings)) {
        $Conf->warnMsg(join("<br />\n", $Search->warnings));
    }
    $pl = $Search->paperList();
    if (count($pl)) {
        $where = array();
        foreach ($pl as $p) {
            $where[] = "paperId={$p}";
            $where[] = "action like '%(papers% {$p},%'";
            $where[] = "action like '%(papers% {$p})%'";
        }
        $wheres[] = "(" . join(" or ", $where) . ")";
    } else {
        if (!count($Search->warnings)) {
            $Conf->warnMsg("No papers match that search.");
예제 #7
0
 }
 if ($Conf->deadlinesAfter("rev_open") || $Me->privChair) {
     echo $sep, '<a href="', hoturl("offline"), '">Offline reviewing</a>';
     $sep = $xsep;
 }
 if ($Me->is_requester()) {
     echo $sep, '<a href="', hoturl("mail", "monreq=1"), '">Monitor external reviews</a>';
     $sep = $xsep;
 }
 if ($Conf->setting("rev_tokens")) {
     echo $sep;
     reviewTokenGroup(false);
     $sep = $xsep;
 }
 if ($myrow && $Conf->setting("rev_ratings") != REV_RATINGS_NONE) {
     $badratings = PaperSearch::unusableRatings($Me->privChair, $Me->contactId);
     $qx = count($badratings) ? " and not (PaperReview.reviewId in (" . join(",", $badratings) . "))" : "";
     $result = Dbl::qe_raw("select rating, count(PaperReview.reviewId) from PaperReview join ReviewRating on (PaperReview.contactId={$Me->contactId} and PaperReview.reviewId=ReviewRating.reviewId{$qx}) group by rating order by rating desc");
     if (edb_nrows($result)) {
         $a = array();
         while ($row = edb_row($result)) {
             if (isset(ReviewForm::$rating_types[$row[0]])) {
                 $a[] = "<a href=\"" . hoturl("search", "q=re:me+rate:%22" . urlencode(ReviewForm::$rating_types[$row[0]]) . "%22") . "\" title='List rated reviews'>{$row['1']} &ldquo;" . htmlspecialchars(ReviewForm::$rating_types[$row[0]]) . "&rdquo; " . pluralx($row[1], "rating") . "</a>";
             }
         }
         if (count($a) > 0) {
             echo "<div class='hint g'>\nYour reviews have received ", commajoin($a);
             if (count($a) > 1) {
                 echo " (these sets might overlap)";
             }
             echo ".<a class='help' href='", hoturl("help", "t=revrate"), "' title='About ratings'>?</a></div>\n";
예제 #8
0
 private function _parse_expr(&$t, $level, $in_qc)
 {
     global $Conf;
     if (($t = ltrim($t)) === "") {
         return null;
     }
     $lpos = -strlen($t);
     $e = null;
     if ($t[0] === "(") {
         $t = substr($t, 1);
         $e = $this->_parse_ternary($t, false);
         $t = ltrim($t);
         if (!$e || $t === "" || $t[0] !== ")") {
             return null;
         }
         $t = substr($t, 1);
     } else {
         if ($t[0] === "-" || $t[0] === "+" || $t[0] === "!") {
             $op = $t[0];
             $t = substr($t, 1);
             if (!($e = $this->_parse_expr($t, self::$opprec["u{$op}"], $in_qc))) {
                 return null;
             }
             $e = $op == "!" ? new NegateFexpr($e) : new Fexpr($op, $e);
         } else {
             if (preg_match('/\\Aopt(?:ion)?:\\s*(.*)\\z/s', $t, $m)) {
                 $rest = self::_pop_argument($m[1]);
                 $os = PaperSearch::analyze_option_search($rest[1]);
                 foreach ($os->warn as $w) {
                     $this->_error_html[] = $w;
                 }
                 if (!count($os->os) && !count($os->warn)) {
                     $this->_error_html[] = "“" . htmlspecialchars($rest[1]) . "” doesn’t match a submission option.";
                 }
                 if (!count($os->os)) {
                     return null;
                 }
                 foreach ($os->os as $o) {
                     $ex = new OptionFexpr($o->option);
                     if ($o->kind) {
                         $this->_error_html[] = "“" . htmlspecialchars($rest[1]) . "” can’t be used in formulas.";
                     } else {
                         if ($o->value_word === "") {
                             /* stick with raw option fexpr */
                         } else {
                             if (is_array($o->value) && $o->compar === "!=") {
                                 $ex = new NegateFexpr(new InFexpr($ex, $o->value));
                             } else {
                                 if (is_array($o->value)) {
                                     $ex = new InFexpr($ex, $o->value);
                                 } else {
                                     $ex = new Fexpr(get(self::$_oprewrite, $o->compar, $o->compar), $ex, new ConstantFexpr($o->value, $o->option));
                                 }
                             }
                         }
                     }
                     $e = $e ? new Fexpr("||", $e, $ex) : $ex;
                 }
                 if ($os->negate) {
                     $e = new NegateFexpr($e);
                 }
                 $t = $rest[2];
             } else {
                 if (preg_match('/\\Anot([\\s(].*|)\\z/i', $t, $m)) {
                     $t = $m[1];
                     if (!($e = $this->_parse_expr($t, self::$opprec["u!"], $in_qc))) {
                         return null;
                     }
                     $e = new NegateFexpr($e);
                 } else {
                     if (preg_match('/\\A(\\d+\\.?\\d*|\\.\\d+)(.*)\\z/s', $t, $m)) {
                         $e = new ConstantFexpr($m[1] + 0.0);
                         $t = $m[2];
                     } else {
                         if (preg_match('/\\A(false|true)\\b(.*)\\z/si', $t, $m)) {
                             $e = new ConstantFexpr($m[1], Fexpr::FBOOL);
                             $t = $m[2];
                         } else {
                             if (preg_match('/\\A(?:pid|paperid)\\b(.*)\\z/si', $t, $m)) {
                                 $e = new PidFexpr();
                                 $t = $m[1];
                             } else {
                                 if (preg_match('/\\A(?:dec|decision):\\s*' . self::ARGUMENT_REGEX . '(.*)\\z/si', $t, $m)) {
                                     $e = $this->field_search_fexpr(["outcome", PaperSearch::matching_decisions($m[1])]);
                                     $t = $m[2];
                                 } else {
                                     if (preg_match('/\\A(?:dec|decision)\\b(.*)\\z/si', $t, $m)) {
                                         $e = new DecisionFexpr();
                                         $t = $m[1];
                                     } else {
                                         if (preg_match('/\\A(?:is|status):\\s*' . self::ARGUMENT_REGEX . '(.*)\\z/si', $t, $m)) {
                                             $e = $this->field_search_fexpr(PaperSearch::status_field_matcher($m[1]));
                                             $t = $m[2];
                                         } else {
                                             if (preg_match('/\\A(?:tag(?:\\s*:\\s*|\\s+)|#)(' . TAG_REGEX . ')(.*)\\z/is', $t, $m) || preg_match('/\\Atag\\s*\\(\\s*(' . TAG_REGEX . ')\\s*\\)(.*)\\z/is', $t, $m)) {
                                                 $e = new TagFexpr($m[1], false);
                                                 $t = $m[2];
                                             } else {
                                                 if (preg_match('/\\Atag(?:v|-?val|-?value)(?:\\s*:\\s*|\\s+)(' . TAG_REGEX . ')(.*)\\z/is', $t, $m) || preg_match('/\\Atag(?:v|-?val|-?value)\\s*\\(\\s*(' . TAG_REGEX . ')\\s*\\)(.*)\\z/is', $t, $m)) {
                                                     $e = new TagFexpr($m[1], true);
                                                     $t = $m[2];
                                                 } else {
                                                     if (preg_match('/\\A(r|re|rev|review|r(?:|e|ev|eview)type|(?:|r|re|rev|review)round|reviewer|r(?:|e|ev|eview)(?:|au)words)(?::|(?=#))\\s*' . self::ARGUMENT_REGEX . '(.*)\\z/is', $t, $m)) {
                                                         $e = $this->_reviewer_decoration($this->_reviewer_base($m[1]), $m[2]);
                                                         $t = $m[3];
                                                     } else {
                                                         if (preg_match('/\\A((?:r|re|rev|review)(?:type|round|(?:|au)words)|(?:round|reviewer))\\b(.*)\\z/is', $t, $m)) {
                                                             $e = $this->_reviewer_base($m[1]);
                                                             $t = $m[2];
                                                         } else {
                                                             if (preg_match('/\\A(my|all|any|avg|average|mean|median|quantile|count|min|max|atminof|atmaxof|argmin|argmax|std(?:d?ev(?:_pop|_samp|[_.][ps])?)?|sum|var(?:iance)?(?:_pop|_samp|[_.][ps])?|wavg)\\b(.*)\\z/is', $t, $m)) {
                                                                 $t = $m[2];
                                                                 if (!($e = $this->_parse_function($m[1], $t, true))) {
                                                                     return null;
                                                                 }
                                                             } else {
                                                                 if (preg_match('/\\A(greatest|least|round|floor|trunc|ceil|log|sqrt|pow|exp)\\b(.*)\\z/is', $t, $m)) {
                                                                     $t = $m[2];
                                                                     if (!($e = $this->_parse_function($m[1], $t, false))) {
                                                                         return null;
                                                                     }
                                                                 } else {
                                                                     if (preg_match('/\\Anull\\b(.*)\\z/s', $t, $m)) {
                                                                         $e = ConstantFexpr::cnull();
                                                                         $t = $m[1];
                                                                     } else {
                                                                         if (preg_match('/\\A(?:is:?)?(rev?|pc(?:rev?)?|pri(?:mary)?|sec(?:ondary)?|ext(?:ernal)?)\\b(.*)\\z/is', $t, $m)) {
                                                                             $rt = ReviewSearchMatcher::parse_review_type($m[1]);
                                                                             $op = $rt == 0 || $rt == REVIEW_PC ? ">=" : "==";
                                                                             $e = new Fexpr($op, new RevtypeFexpr(), new ConstantFexpr($rt, Fexpr::FREVTYPE));
                                                                             $t = $m[2];
                                                                         } else {
                                                                             if (preg_match('/\\Atopicscore\\b(.*)\\z/is', $t, $m)) {
                                                                                 $e = new TopicScoreFexpr();
                                                                                 $t = $m[1];
                                                                             } else {
                                                                                 if (preg_match('/\\Aconf(?:lict)?\\b(.*)\\z/is', $t, $m)) {
                                                                                     $e = new ConflictFexpr(false);
                                                                                     $t = $m[1];
                                                                                 } else {
                                                                                     if (preg_match('/\\Apcconf(?:lict)?\\b(.*)\\z/is', $t, $m)) {
                                                                                         $e = new ConflictFexpr(true);
                                                                                         $t = $m[1];
                                                                                     } else {
                                                                                         if (preg_match('/\\A(?:rev)?pref\\b(.*)\\z/is', $t, $m)) {
                                                                                             $e = new PrefFexpr(false);
                                                                                             $t = $m[1];
                                                                                         } else {
                                                                                             if (preg_match('/\\A(?:rev)?prefexp(?:ertise)?\\b(.*)\\z/is', $t, $m)) {
                                                                                                 $e = new PrefFexpr(true);
                                                                                                 $t = $m[1];
                                                                                             } else {
                                                                                                 if (preg_match('/\\A([A-Za-z0-9_]+|\\".*?\\")(.*)\\z/s', $t, $m) && $m[1] !== "\"\"" && !preg_match('/\\A\\s*\\(/', $m[2])) {
                                                                                                     $field = $m[1];
                                                                                                     $t = $m[2];
                                                                                                     if ($quoted = $field[0] === "\"") {
                                                                                                         $field = substr($field, 1, strlen($field) - 2);
                                                                                                     }
                                                                                                     if (($f = ReviewForm::field_search($field)) && $f->has_options) {
                                                                                                         $e = new ScoreFexpr($f);
                                                                                                     } else {
                                                                                                         if (!$quoted) {
                                                                                                             $e = new ConstantFexpr($field, false);
                                                                                                         } else {
                                                                                                             return null;
                                                                                                         }
                                                                                                     }
                                                                                                 }
                                                                                             }
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if (!$e) {
         return null;
     }
     $e->set_landmark($lpos, -strlen($t));
     while (1) {
         if (($t = ltrim($t)) === "") {
             return $e;
         } else {
             if (preg_match(self::BINARY_OPERATOR_REGEX, $t, $m)) {
                 $op = $m[0];
                 $tn = substr($t, strlen($m[0]));
             } else {
                 if (preg_match('/\\A(and|or)([\\s(].*|)\\z/i', $t, $m)) {
                     $op = strlen($m[1]) == 3 ? "&&" : "||";
                     $tn = $m[2];
                 } else {
                     if (!$in_qc && substr($t, 0, 1) === ":") {
                         $op = ":";
                         $tn = substr($t, 1);
                     } else {
                         return $e;
                     }
                 }
             }
         }
         $opprec = self::$opprec[$op];
         if ($opprec < $level) {
             return $e;
         }
         $t = $tn;
         $op = get(self::$_oprewrite, $op) ?: $op;
         if (!($e2 = $this->_parse_expr($t, get(self::$_oprassoc, $op) ? $opprec : $opprec + 1, $in_qc))) {
             return null;
         }
         $e = new Fexpr($op, $e, $e2);
         $e->set_landmark($lpos, -strlen($t));
     }
 }
예제 #9
0
 /**
  * Return an array of search results matching the supplied
  * keyword IDs in decreasing order of match quality.
  * Keywords are supplied in an array of the following format:
  * $keywords[PAPER_SEARCH_AUTHOR] = array('John', 'Doe');
  * $keywords[PAPER_SEARCH_...] = array(...);
  * $keywords[null] = array('Matches', 'All', 'Fields');
  * @param $conference object The conference to search
  * @param $keywords array List of keywords
  * @param $publishedFrom object Search-from date
  * @param $publishedTo object Search-to date
  * @param $rangeInfo Information on the range of results to return
  */
 function &retrieveResults(&$conference, &$keywords, $publishedFrom = null, $publishedTo = null, $rangeInfo = null)
 {
     // Fetch all the results from all the keywords into one array
     // (mergedResults), where mergedResults[paper_id]
     // = sum of all the occurences for all keywords associated with
     // that paper ID.
     // resultCount contains the sum of result counts for all keywords.
     $mergedResults =& PaperSearch::_getMergedArray($conference, $keywords, $publishedFrom, $publishedTo, $resultCount);
     // Convert mergedResults into an array (frequencyIndicator =>
     // $paperId).
     // The frequencyIndicator is a synthetically-generated number,
     // where higher is better, indicating the quality of the match.
     // It is generated here in such a manner that matches with
     // identical frequency do not collide.
     $results =& PaperSearch::_getSparseArray($mergedResults, $resultCount);
     $totalResults = count($results);
     // Use only the results for the specified page, if specified.
     if ($rangeInfo && $rangeInfo->isValid()) {
         $results = array_slice($results, $rangeInfo->getCount() * ($rangeInfo->getPage() - 1), $rangeInfo->getCount());
         $page = $rangeInfo->getPage();
         $itemsPerPage = $rangeInfo->getCount();
     } else {
         $page = 1;
         $itemsPerPage = max($totalResults, 1);
     }
     // Take the range of results and retrieve the Paper, Conference,
     // and associated objects.
     $results =& PaperSearch::formatResults($results);
     // Return the appropriate iterator.
     import('core.VirtualArrayIterator');
     $returner = new VirtualArrayIterator($results, $totalResults, $page, $itemsPerPage);
     return $returner;
 }
예제 #10
0
if (isset($Qreq->prevt) && isset($Qreq->t) && $Qreq->prevt !== $Qreq->t || isset($Qreq->prevq) && isset($Qreq->q) && $Qreq->prevq !== $Qreq->q) {
    if (isset($Qreq->assign)) {
        $Conf->warnMsg("You changed the paper search. Please review the paper list.");
    }
    unset($Qreq->assign);
    $Qreq->requery = 1;
}
if (isset($Qreq->saveassignment)) {
    $SSel = SearchSelection::make($Qreq, $Me, $Qreq->submit ? "pap" : "p");
} else {
    $SSel = new SearchSelection();
    if (!$Qreq->requery) {
        $SSel = SearchSelection::make($Qreq, $Me);
    }
    if ($SSel->is_empty()) {
        $search = new PaperSearch($Me, array("t" => $Qreq->t, "q" => $Qreq->q));
        $SSel = new SearchSelection($search->paperList());
    }
}
$SSel->sort_selection();
// rev_roundtag
if (($x = $Conf->sanitize_round_name($Qreq->rev_roundtag)) !== false) {
    $Qreq->rev_roundtag = $x;
}
// score selector
$scoreselector = array("+overAllMerit" => "", "-overAllMerit" => "");
foreach (ReviewForm::all_fields() as $f) {
    if ($f->has_options) {
        $scoreselector["+" . $f->id] = "high {$f->name_html} scores";
        $scoreselector["-" . $f->id] = "low {$f->name_html} scores";
    }
예제 #11
0
 public static function parse_sorter($text)
 {
     if (!self::$_sort_keywords) {
         self::$_sort_keywords = array("by" => "by", "up" => "up", "down" => "down", "reverse" => "down", "reversed" => "down", "count" => "C", "counts" => "C", "av" => "A", "ave" => "A", "average" => "A", "med" => "E", "median" => "E", "var" => "V", "variance" => "V", "max-min" => "D", "my" => "Y", "score" => "");
     }
     $text = simplify_whitespace($text);
     $sort = ListSorter::make_empty($text === "");
     if (($ch1 = substr($text, 0, 1)) === "-" || $ch1 === "+") {
         $sort->reverse = $ch1 === "-";
         $text = ltrim(substr($text, 1));
     }
     // separate text into words
     $words = array();
     $bypos = false;
     while ($text !== "") {
         preg_match(',\\A([^\\s\\(]*)(.*)\\z,s', $text, $m);
         if (substr($m[2], 0, 1) === "(") {
             $pos = self::find_end_balanced_parens($m[2]);
             $m[1] .= substr($m[2], 0, $pos);
             $m[2] = substr($m[2], $pos);
         }
         $words[] = $m[1];
         $text = ltrim($m[2]);
         if ($m[1] === "by" && $bypos === false) {
             $bypos = count($words) - 1;
         }
     }
     // go over words
     $next_words = array();
     for ($i = 0; $i != count($words); ++$i) {
         $w = $words[$i];
         if (($bypos === false || $i > $bypos) && isset(self::$_sort_keywords[$w])) {
             $x = self::$_sort_keywords[$w];
             if ($x === "up") {
                 $sort->reverse = false;
             } else {
                 if ($x === "down") {
                     $sort->reverse = true;
                 } else {
                     if (ctype_upper($x)) {
                         $sort->score = $x;
                     }
                 }
             }
         } else {
             if ($bypos === false || $i < $bypos) {
                 $next_words[] = $w;
             }
         }
     }
     if (count($next_words)) {
         $sort->type = join(" ", $next_words);
     }
     return $sort;
 }
예제 #12
0
        if ($xr->isComment) {
            $rows[] = CommentInfo::unparse_flow_entry($xr, $Me, "");
            $when = $xr->timeModified;
        } else {
            $rows[] = $rf->reviewFlowEntry($Me, $xr, "");
            $when = $xr->reviewSubmitted;
        }
    }
    json_exit(["ok" => true, "from" => (int) $from, "to" => (int) $when - 1, "rows" => $rows]);
} else {
    if ($qreq->fn === "events") {
        json_exit(["ok" => false]);
    }
}
if ($qreq->fn === "searchcompletion") {
    $s = new PaperSearch($Me, "");
    $Conf->ajaxExit(array("ok" => true, "searchcompletion" => $s->search_completion()));
}
// from here on: `status` and `track` requests
if ($qreq->fn === "track") {
    MeetingTracker::track_api($qreq, $Me);
}
// may fall through to act like `status`
$j = $Me->my_deadlines($Conf->paper);
if ($qreq->conflist && $Me->has_email() && ($cdb = Contact::contactdb())) {
    $j->conflist = array();
    $result = Dbl::ql($cdb, "select c.confid, siteclass, shortName, url\n        from Roles r join Conferences c on (c.confid=r.confid)\n        join ContactInfo u on (u.contactDbId=r.contactDbId)\n        where u.email=? order by r.updated_at desc", $Me->email);
    while ($row = edb_orow($result)) {
        $row->confid = (int) $row->confid;
        $j->conflist[] = $row;
    }
 public function add_query($q, $style, $fieldname = false)
 {
     global $Me;
     $qn = count($this->queries);
     $this->queries[] = $q;
     if ($style === "by-tag" || $style === "default") {
         $style = "";
     }
     $this->query_styles[] = $style;
     $psearch = new PaperSearch($Me, array("q" => $q));
     foreach ($psearch->paperList() as $pid) {
         $this->papermap[$pid][] = $qn;
     }
     if (count($psearch->warnings)) {
         $this->error_html = array_merge($this->error_html, $psearch->warnings);
         if ($fieldname) {
             $this->errf[$fieldname] = true;
         }
     }
 }
예제 #14
0
    }
}
$papersel = null;
if (isset($_REQUEST["p"]) && is_array($_REQUEST["p"]) && !isset($_REQUEST["psearch"])) {
    $papersel = array();
    foreach ($_REQUEST["p"] as $p) {
        if (($p = cvtint($p)) > 0) {
            $papersel[] = $p;
        }
    }
    sort($papersel);
    $_REQUEST["q"] = join(" ", $papersel);
    $_REQUEST["plimit"] = 1;
} else {
    if (isset($_REQUEST["plimit"])) {
        $search = new PaperSearch($Me, array("t" => $_REQUEST["t"], "q" => $_REQUEST["q"]));
        $papersel = $search->paperList();
        sort($papersel);
    } else {
        $_REQUEST["q"] = "";
    }
}
// Load template if requested
if (isset($_REQUEST["loadtmpl"])) {
    $t = defval($_REQUEST, "template", "genericmailtool");
    if (!isset($mailTemplates[$t]) || !isset($mailTemplates[$t]["mailtool_name"])) {
        $t = "genericmailtool";
    }
    $template = $mailTemplates[$t];
    $_REQUEST["recipients"] = defval($template, "mailtool_recipients", "s");
    if (isset($template["mailtool_search_type"])) {
예제 #15
0
function _tryNewList($opt, $listtype)
{
    global $Conf, $ConfSiteSuffix, $Me;
    if ($listtype == "u" && $Me->privChair) {
        $searchtype = defval($opt, "t") === "all" ? "all" : "pc";
        $q = "select email from ContactInfo";
        if ($searchtype == "pc") {
            $q .= " where (roles&" . Contact::ROLE_PC . ")!=0";
        }
        $result = $Conf->qx("{$q} order by lastName, firstName, email");
        $a = array();
        while ($row = edb_row($result)) {
            $a[] = $row[0];
        }
        $a["description"] = $searchtype == "pc" ? "Program committee" : "Users";
        $a["listid"] = "u:" . $searchtype . "::";
        $a["url"] = "users{$ConfSiteSuffix}?t=" . $searchtype;
        return $a;
    } else {
        require_once "search.inc";
        $search = new PaperSearch($Me, $opt);
        return $search->sessionList();
    }
}
예제 #16
0
 /**
  * Execute import/export tasks using the command-line interface.
  * @param $args Parameters to the plugin
  */
 function executeCLI($scriptName, &$args)
 {
     $command = array_shift($args);
     $xmlFile = array_shift($args);
     $conferencePath = array_shift($args);
     $schedConfPath = array_shift($args);
     $conferenceDao = DAORegistry::getDAO('ConferenceDAO');
     $schedConfDao = DAORegistry::getDAO('SchedConfDAO');
     $trackDao = DAORegistry::getDAO('TrackDAO');
     $userDao = DAORegistry::getDAO('UserDAO');
     $publishedPaperDao = DAORegistry::getDAO('PublishedPaperDAO');
     $conference =& $conferenceDao->getByPath($conferencePath);
     if ($conference) {
         $schedConf =& $schedConfDao->getByPath($schedConfPath, $conference->getId());
     }
     if (!$conference || !$schedConfPath) {
         if ($conferencePath != '') {
             echo __('plugins.importexport.native.cliError') . "\n";
             echo __('plugins.importexport.native.error.unknownConference', array('conferencePath' => $conferencePath, 'schedConfPath' => $schedConfPath)) . "\n\n";
         }
         $this->usage($scriptName);
         return;
     }
     $this->import('NativeImportDom');
     if ($xmlFile && NativeImportDom::isRelativePath($xmlFile)) {
         $xmlFile = PWD . '/' . $xmlFile;
     }
     switch ($command) {
         case 'import':
             $userName = array_shift($args);
             $user =& $userDao->getByUsername($userName);
             if (!$user) {
                 if ($userName != '') {
                     echo __('plugins.importexport.native.cliError') . "\n";
                     echo __('plugins.importexport.native.error.unknownUser', array('userName' => $userName)) . "\n\n";
                 }
                 $this->usage($scriptName);
                 return;
             }
             $doc =& $this->getDocument($xmlFile);
             $context = array('user' => $user, 'conference' => $conference, 'schedConf' => $schedConf);
             switch ($this->getRootNodeName($doc)) {
                 case 'paper':
                 case 'papers':
                     // Determine the extra context information required
                     // for importing papers.
                     switch (array_shift($args)) {
                         case 'track_id':
                             $track =& $trackDao->getTrack($trackIdentifier = array_shift($args));
                             break;
                         case 'track_name':
                             $track =& $trackDao->getTrackByTitle($trackIdentifier = array_shift($args), $schedConf->getId());
                             break;
                         case 'track_abbrev':
                             $track =& $trackDao->getTrackByAbbrev($trackIdentifier = array_shift($args), $schedConf->getId());
                             break;
                         default:
                             return $this->usage($scriptName);
                     }
                     if (!$track) {
                         echo __('plugins.importexport.native.cliError') . "\n";
                         echo __('plugins.importexport.native.export.error.trackNotFound', array('trackIdentifier' => $trackIdentifier)) . "\n\n";
                         return;
                     }
                     $context['track'] =& $track;
             }
             $result = $this->handleImport($context, $doc, $errors, $papers, true);
             if ($result) {
                 echo __('plugins.importexport.native.import.success.description') . "\n\n";
                 AppLocale::requireComponents(LOCALE_COMPONENT_APP_COMMON);
                 if (!empty($papers)) {
                     echo __('paper.papers') . ":\n";
                 }
                 foreach ($papers as $paper) {
                     echo "\t" . $paper->getLocalizedTitle() . "\n";
                 }
             } else {
                 echo __('plugins.importexport.native.cliError') . "\n";
                 foreach ($errors as $error) {
                     echo "\t" . __($error[0], $error[1]) . "\n";
                 }
             }
             return;
             break;
         case 'export':
             if ($xmlFile != '') {
                 switch (array_shift($args)) {
                     case 'paper':
                         $paperId = array_shift($args);
                         $publishedPaper =& $publishedPaperDao->getPublishedPaperByBestPaperId($schedConf->getId(), $paperId);
                         if ($publishedPaper == null) {
                             echo __('plugins.importexport.native.cliError') . "\n";
                             echo __('plugins.importexport.native.export.error.paperNotFound', array('paperId' => $paperId)) . "\n\n";
                             return;
                         }
                         $trackDao = DAORegistry::getDAO('TrackDAO');
                         $track =& $trackDao->getTrack($publishedPaper->getTrackId());
                         if (!$this->exportPaper($schedConf, $track, $publishedPaper, $xmlFile)) {
                             echo __('plugins.importexport.native.cliError') . "\n";
                             echo __('plugins.importexport.native.export.error.couldNotWrite', array('fileName' => $xmlFile)) . "\n\n";
                         }
                         return;
                     case 'papers':
                         $results =& PaperSearch::formatResults($args);
                         if (!$this->exportPapers($results, $xmlFile)) {
                             echo __('plugins.importexport.native.cliError') . "\n";
                             echo __('plugins.importexport.native.export.error.couldNotWrite', array('fileName' => $xmlFile)) . "\n\n";
                         }
                         return;
                 }
             }
             break;
     }
     $this->usage($scriptName);
 }
예제 #17
0
 private function collect_papers($req, &$pids, $report_error)
 {
     $pfield = trim(get_s($req, "paper"));
     if ($pfield !== "" && ctype_digit($pfield)) {
         $pids[intval($pfield)] = 2;
     } else {
         if ($pfield !== "") {
             if (!isset($this->searches[$pfield])) {
                 $search = new PaperSearch($this->contact, $pfield);
                 $this->searches[$pfield] = $search->paperList();
                 if ($report_error) {
                     foreach ($search->warnings as $w) {
                         $this->error($w);
                     }
                 }
             }
             foreach ($this->searches[$pfield] as $pid) {
                 $pids[$pid] = 1;
             }
             if (!count($this->searches[$pfield]) && $report_error) {
                 $this->error("No papers match “" . htmlspecialchars($pfield) . "”");
             }
         } else {
             if ($report_error) {
                 $this->error("Bad paper column");
             }
         }
     }
 }
예제 #18
0
 private static function try_list($opt, $listtype, $sort = null)
 {
     global $Conf, $Me;
     if ($listtype == "u" && $Me->privChair) {
         $searchtype = defval($opt, "t") === "all" ? "all" : "pc";
         $q = "select contactId from ContactInfo";
         if ($searchtype == "pc") {
             $q .= " where (roles&" . Contact::ROLE_PC . ")!=0";
         }
         $result = Dbl::ql("{$q} order by lastName, firstName, email");
         $a = array();
         while ($row = edb_row($result)) {
             $a[] = (int) $row[0];
         }
         Dbl::free($result);
         return self::create("u/" . $searchtype, $a, $searchtype == "pc" ? "Program committee" : "Users", hoturl_site_relative_raw("users", "t={$searchtype}"));
     } else {
         $search = new PaperSearch($Me, $opt);
         $x = $search->session_list_object($sort);
         if ($sort || $search->has_sort()) {
             $pl = new PaperList($search, array("sort" => $sort));
             $x->ids = $pl->id_array();
         }
         return $x;
     }
 }
예제 #19
0
 function _rows($queryOptions)
 {
     global $Conf;
     $aulimit = strlen($this->limit) >= 2 && $this->limit[0] == 'a' && $this->limit[1] == 'u';
     $pq = "select u.contactId,\n        firstName, lastName, email, affiliation, roles, contactTags,\n        voicePhoneNumber,\n        u.collaborators, lastLogin, disabled";
     if (isset($queryOptions['topics'])) {
         $pq .= ",\n topicIds, topicInterest";
     }
     if (isset($queryOptions["reviews"])) {
         $pq .= ",\n        count(if(r.reviewNeedsSubmit<=0,r.reviewSubmitted,r.reviewId)) as numReviews,\n        count(r.reviewSubmitted) as numReviewsSubmitted";
         if (isset($queryOptions["revratings"])) {
             $pq .= ",\n     sum(r.numRatings) as numRatings,\n        sum(r.sumRatings) as sumRatings";
         }
     }
     if (isset($queryOptions["leads"])) {
         $pq .= ",\n leadPaperIds, numLeads";
     }
     if (isset($queryOptions["shepherds"])) {
         $pq .= ",\n shepherdPaperIds, numShepherds";
     }
     if (isset($queryOptions['scores'])) {
         foreach ($queryOptions['scores'] as $score) {
             $pq .= ",\n\tgroup_concat(if(r.reviewSubmitted>0,r.{$score},null)) as {$score}";
         }
     }
     if (isset($queryOptions["repapers"])) {
         $pq .= ",\n\tgroup_concat(r.paperId) as paperIds,\n        group_concat(r.reviewId) as reviewIds,\n        group_concat(coalesce(r.reviewOrdinal,0)) as reviewOrdinals";
     } else {
         if (isset($queryOptions['papers'])) {
             $pq .= ",\n\tgroup_concat(PaperConflict.paperId) as paperIds";
         }
     }
     $pq .= "\n      from ContactInfo u\n";
     if (isset($queryOptions['topics'])) {
         $pq .= "    left join (select contactId, group_concat(topicId) as topicIds, group_concat(interest) as topicInterest\n                from TopicInterest\n                group by contactId) as ti on (ti.contactId=u.contactId)\n";
     }
     if (isset($queryOptions["reviews"])) {
         $j = "left join";
         if ($this->limit == "re" || $this->limit == "req" || $this->limit == "ext" || $this->limit == "resub" || $this->limit == "extsub") {
             $j = "join";
         }
         $pq .= "    {$j} (select r.*";
         if (isset($queryOptions["revratings"])) {
             $pq .= ", count(rating) as numRatings, sum(if(rating>0,1,0)) as sumRatings";
         }
         $pq .= "\n\t\tfrom PaperReview r\n                join Paper p on (p.paperId=r.paperId)";
         if (!$this->contact->privChair) {
             $pq .= "\n\t\tleft join PaperConflict pc on (pc.paperId=p.paperId and pc.contactId=" . $this->contact->contactId . ")";
         }
         if (isset($queryOptions["revratings"])) {
             $badratings = PaperSearch::unusableRatings($this->contact->privChair, $this->contact->contactId);
             $pq .= "\n\t\tleft join ReviewRating rr on (rr.reviewId=r.reviewId";
             if (count($badratings) > 0) {
                 $pq .= " and not (rr.reviewId in (" . join(",", $badratings) . "))";
             }
             $pq .= ")";
         }
         $jwhere = array();
         if ($this->limit == "req" || $this->limit == "ext" || $this->limit == "extsub") {
             $jwhere[] = "r.reviewType=" . REVIEW_EXTERNAL;
         }
         if ($this->limit == "req") {
             $jwhere[] = "r.requestedBy=" . $this->contact->contactId;
         }
         if (!$this->contact->privChair) {
             $jwhere[] = "(pc.conflictType is null or pc.conflictType=0 or r.contactId=" . $this->contact->contactId . ")";
         }
         $jwhere[] = "(p.timeSubmitted>0 or r.reviewSubmitted>0)";
         if (count($jwhere)) {
             $pq .= "\n\t\twhere " . join(" and ", $jwhere);
         }
         if (isset($queryOptions["revratings"])) {
             $pq .= "\n\t\tgroup by r.reviewId";
         }
         $pq .= ") as r on (r.contactId=u.contactId)\n";
     }
     if (isset($queryOptions["leads"])) {
         $pq .= "    left join (select p.leadContactId, group_concat(p.paperId) as leadPaperIds, count(p.paperId) as numLeads\n\t\tfrom Paper p";
         $jwhere = array("leadContactId is not null");
         if (!$this->contact->privChair) {
             $pq .= "\n\t\tleft join PaperConflict pc on (pc.paperId=p.paperId and pc.contactId=" . $this->contact->contactId . ")";
             $jwhere[] = "(conflictType is null or conflictType=0)";
         }
         $pq .= "\n\t\twhere " . join(" and ", $jwhere) . "\n\t\tgroup by p.leadContactId) as lead on (lead.leadContactId=u.contactId)\n";
     }
     if (isset($queryOptions["shepherds"])) {
         $pq .= "    left join (select p.shepherdContactId, group_concat(p.paperId) as shepherdPaperIds, count(p.paperId) as numShepherds\n\t\tfrom Paper p";
         $jwhere = array("shepherdContactId is not null");
         if (!$this->contact->privChair && !$Conf->timePCViewDecision(true)) {
             $pq .= "\n\t\tleft join PaperConflict pc on (pc.paperId=p.paperId and pc.contactId=" . $this->contact->contactId . ")";
             $mywhere = "conflictType is null or conflictType=0";
             if ($Conf->timeAuthorViewDecision()) {
                 $mywhere .= " or conflictType>=" . CONFLICT_AUTHOR;
             }
             $jwhere[] = "({$mywhere})";
         }
         $pq .= "\n\t\twhere " . join(" and ", $jwhere) . "\n\t\tgroup by p.shepherdContactId) as shep on (shep.shepherdContactId=u.contactId)\n";
     }
     if ($aulimit) {
         $pq .= "\tjoin PaperConflict on (PaperConflict.contactId=u.contactId and PaperConflict.conflictType>=" . CONFLICT_AUTHOR . ")\n";
     }
     if ($this->limit == "au") {
         $pq .= "\tjoin Paper on (Paper.paperId=PaperConflict.paperId and Paper.timeSubmitted>0)\n";
     }
     if ($this->limit == "aurej") {
         $pq .= "\tjoin Paper on (Paper.paperId=PaperConflict.paperId and Paper.outcome<0)\n";
     }
     if ($this->limit == "auacc") {
         $pq .= "\tjoin Paper on (Paper.paperId=PaperConflict.paperId and Paper.outcome>0)\n";
     }
     if ($this->limit == "auuns") {
         $pq .= "\tjoin Paper on (Paper.paperId=PaperConflict.paperId and Paper.timeSubmitted<=0)\n";
     }
     if ($this->limit == "all") {
         $pq .= "\tleft join PaperConflict on (PaperConflict.contactId=u.contactId and PaperConflict.conflictType>=" . CONFLICT_AUTHOR . ")\n";
     }
     $mainwhere = array();
     if (isset($queryOptions["where"])) {
         $mainwhere[] = $queryOptions["where"];
     }
     if ($this->limit == "pc") {
         $mainwhere[] = "(u.roles&" . Contact::ROLE_PC . ")!=0";
     }
     if ($this->limit == "admin") {
         $mainwhere[] = "(u.roles&" . (Contact::ROLE_ADMIN | Contact::ROLE_CHAIR) . ")!=0";
     }
     if ($this->limit == "pcadmin" || $this->limit == "pcadminx") {
         $mainwhere[] = "(u.roles&" . Contact::ROLE_PCLIKE . ")!=0";
     }
     if (count($mainwhere)) {
         $pq .= "\twhere " . join(" and ", $mainwhere) . "\n";
     }
     $pq .= "        group by u.contactId\n        order by lastName, firstName, email";
     // make query
     $result = $Conf->qe($pq);
     if (!$result) {
         return NULL;
     }
     // fetch data
     Contact::$allow_nonexistent_properties = true;
     $rows = array();
     while ($row = Contact::fetch($result)) {
         $rows[] = $row;
     }
     Contact::$allow_nonexistent_properties = false;
     return $rows;
 }