static function load() { global $Opt; if (!self::$loaded) { self::$loaded = true; foreach (expand_includes("src/sa/*.php") as $f) { include $f; } if (isset($Opt["searchaction_include"]) && $Opt["searchaction_include"]) { read_included_options($Opt["searchaction_include"]); } } }
function list_actions(Contact $user, $qreq, PaperList $pl, &$actions) { $xactions = SearchAction::list_subactions("get", $user, $qreq, $pl); foreach (PaperOption::option_ids() as $oid) { if ($pl->any["opt{$oid}"] && ($o = PaperOption::find($oid)) && $o->is_document()) { $xactions[] = GetDocument_SearchAction::make_option_action($o); } } usort($xactions, function ($a, $b) { return $a[0] - $b[0]; }); $sel_opt = array(); $last_group = null; foreach ($xactions as $xact) { if ($xact[2] !== $last_group) { $sel_opt[] = ["optgroup", $xact[2]]; $last_group = $xact[2]; } $sel_opt[] = ["value" => $xact[1], "label" => $xact[3]]; } if (!empty($sel_opt)) { $actions[] = [0, "get", "Download", "<b>:</b> " . Ht::select("getfn", $sel_opt, $qreq->getfn, ["tabindex" => 6, "class" => "wantcrpfocus", "style" => "max-width:10em"]) . " " . Ht::submit("fn", "Go", ["value" => "get", "tabindex" => 6, "onclick" => "return plist_submit.call(this)", "data-plist-submit-all" => 1])]; } }
private function _footer($ncol, $extra) { global $Conf; if ($this->count == 0) { return ""; } $revpref = $this->table_type == "editReviewPreference"; $lllgroups = SearchAction::list_all_actions($this->contact, $this->qreq, $this); // Upload preferences (review preferences only) if ($revpref) { $lllgroups[] = [100, "uploadpref", "Upload", "<b> preference file:</b> " . "<input class=\"wantcrpfocus\" type='file' name='uploadedFile' accept='text/plain' size='20' tabindex='6' onfocus='autosub(\"uploadpref\",this)' /> " . Ht::submit("fn", "Go", ["value" => "uploadpref", "tabindex" => 6, "onclick" => "return plist_submit.call(this)", "data-plist-submit-all" => 1])]; } // Set preferences (review preferences only) if ($revpref) { $lllgroups[] = [200, "setpref", "Set preferences", "<b>:</b> " . Ht::entry("pref", "", array("class" => "wantcrpfocus", "size" => 4, "tabindex" => 6, "onfocus" => 'autosub("setpref",this)')) . " " . Ht::submit("fn", "Go", ["value" => "setpref", "tabindex" => 6, "onclick" => "return plist_submit.call(this)"])]; } usort($lllgroups, function ($a, $b) { return $a[0] - $b[0]; }); $whichlll = 1; foreach ($lllgroups as $i => $lllg) { if ($this->qreq->fn == $lllg[1] || $this->atab == $lllg[1]) { $whichlll = $i + 1; } } // Linelinks container $foot = " <tr class=\"pl_footrow\">"; if (!$this->viewmap->columns) { $foot .= '<td class="pl_footselector">' . Ht::img("_.gif", "^^", "placthook") . "</td>"; --$ncol; } $foot .= '<td id="plact" class="pl_footer linelinks' . $whichlll . '" colspan="' . $ncol . '">'; $foot .= "<table><tbody><tr>\n" . ' <td class="pl_footer_desc"><b>Select papers</b> (or <a href="' . selfHref(["selectall" => 1]) . '#plact" onclick="return papersel(true)">select all ' . $this->count . "</a>), then </td>\n" . " </tr></tbody></table>"; foreach ($lllgroups as $i => $lllg) { $x = $i + 1; $foot .= "<table><tbody><tr>\n" . " <td class=\"pl_footer_desc lll{$x}\"><a href=\"" . selfHref(["atab" => $lllg[1]]) . "#plact\" onclick=\"return crpfocus('plact',this)\">" . $lllg[2] . "</a></td>\n"; for ($j = 3; $j < count($lllg); ++$j) { $cell = is_array($lllg[$j]) ? $lllg[$j] : ["content" => $lllg[$j]]; $class = isset($cell["class"]) ? "lld{$x} " . $cell["class"] : "lld{$x}"; $foot .= " <td class=\"{$class}\""; if (isset($cell["id"])) { $foot .= " id=\"" . $cell["id"] . "\""; } $foot .= ">" . $cell["content"] . "</td>\n"; } if ($i < count($lllgroups) - 1) { $foot .= " <td> <span class='barsep'>·</span> </td>\n"; } $foot .= " </tr></tbody></table>"; } $foot .= $extra . "<hr class=\"c\" /></td>\n </tr>\n"; return $foot; }
function showScripts() { parent::showScripts(); $this->autofocus('q'); }
<?php require dirname(__FILE__) . '/init.inc.php'; global $_tpl; $_search = new SearchAction($_tpl); $_search->_action(); $_tpl->display('search.tpl');
function get_pcassignment_csv() { global $user_chair; list($header, $texts) = SearchAction::pcassignments_csv_data($user_chair, range(1, 30)); $csvg = new CsvGenerator(); $csvg->set_header($header); $csvg->set_selection($header); $csvg->add($texts); return $csvg->unparse(); }
while ($prow = PaperInfo::fetch($result, $user)) { if ($user->can_administer($prow, true)) { $pj[$prow->paperId] = $ps->paper_json($prow); } else { $pj[$prow->paperId] = (object) ["pid" => $prow->paperId, "error" => "You don’t have permission to administer this paper."]; if ($this->iszip) { $this->zipdoc->warnings[] = "#{$prow->paperId}: You don’t have permission to administer this paper."; } } } $pj = array_values($ssel->reorder($pj)); if (count($pj) == 1) { $pj = $pj[0]; $pj_filename = $Opt["downloadPrefix"] . "paper" . $ssel->selection_at(0) . "-data.json"; } else { $pj_filename = $Opt["downloadPrefix"] . "data.json"; } if ($this->iszip) { $this->zipdoc->add(json_encode($pj, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "\n", $pj_filename); $this->zipdoc->download(); } else { header("Content-Type: application/json"); header("Content-Disposition: attachment; filename=" . mime_quote_string($pj_filename)); echo json_encode($pj, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "\n"; } exit; } } SearchAction::register("get", "json", SiteLoader::API_GET | SiteLoader::API_PAPER, new GetJson_SearchAction(false)); SearchAction::register("get", "jsonattach", SiteLoader::API_GET | SiteLoader::API_PAPER, new GetJson_SearchAction(true));
function prepare($args) { parent::prepare($args); common_set_returnto($this->selfUrl()); return true; }
<?php // sa/sa_mail.php -- HotCRP helper classes for search actions // HotCRP is Copyright (c) 2006-2016 Eddie Kohler and Regents of the UC // Distributed under an MIT-like license; see LICENSE class Mail_SearchAction extends SearchAction { function allow(Contact $user) { return $user->is_manager() && Navigation::page() !== "reviewprefs"; } function list_actions(Contact $user, $qreq, PaperList $plist, &$actions) { $actions[] = [1000, "mail", "Mail", "<b>:</b> " . Ht::select("recipients", array("au" => "Contact authors", "rev" => "Reviewers"), $qreq->recipients, ["class" => "wantcrpfocus"]) . " " . Ht::submit("fn", "Go", ["value" => "mail", "onclick" => "return plist_submit.call(this)", "data-plist-submit-all" => 1])]; } function run(Contact $user, $qreq, $ssel) { $r = in_array($qreq->recipients, ["au", "rev"]) ? $qreq->recipients : "all"; if ($ssel->equals_search(new PaperSearch($user, $qreq))) { $x = "q=" . urlencode($qreq->q) . "&plimit=1"; } else { $x = "p=" . join("+", $ssel->selection()); } go(hoturl("mail", $x . "&t=" . urlencode($qreq->t) . "&recipients={$r}")); } } SearchAction::register("mail", null, SiteLoader::API_GET | SiteLoader::API_PAPER, new Mail_SearchAction());
/** * @return array */ public function actions() { return ['index' => ['class' => IndexAction::className(), 'modelClass' => $this->modelClass], 'view' => ['class' => ViewAction::className(), 'modelClass' => $this->modelClass], 'create' => ['class' => CreateAction::className(), 'modelClass' => $this->modelClass], 'update' => ['class' => UpdateAction::className(), 'modelClass' => $this->modelClass], 'delete' => ['class' => DeleteAction::className(), 'modelClass' => $this->modelClass], 'search' => ['class' => SearchAction::className(), 'modelClass' => $this->modelClass]]; }
} } if ($errors = join("<br />\n", $assignset->errors_html())) { if ($assignset->has_assigners()) { Conf::msg_warning("Some tag assignments were ignored:<br />\n{$errors}"); $assignset->clear_errors(); } else { Conf::msg_error($errors); } } $success = $assignset->execute(); if (!$Conf->headerPrinted && $qreq->ajax) { $Conf->ajaxExit(array("ok" => $success)); } else { if (!$Conf->headerPrinted && $success) { if (!$errors) { $Conf->confirmMsg("Tags saved."); } $args = array("atab" => "tag"); foreach (array("tag", "tagfn", "tagcr_method", "tagcr_source", "tagcr_gapless") as $arg) { if (isset($qreq[$arg])) { $args[$arg] = $qreq[$arg]; } } redirectSelf($args); } } } } SearchAction::register("tag", null, SiteLoader::API_POST | SiteLoader::API_PAPER, new Tag_SearchAction());
$actions[] = [900, "decide", "Decide", "<b>:</b> Set to " . decisionSelector($qreq->decision, null, " class=\"wantcrpfocus\"") . " " . Ht::submit("fn", "Go", ["value" => "decide", "onclick" => "return plist_submit.call(this)"])]; } function run(Contact $user, $qreq, $ssel) { global $Conf; $o = cvtint($qreq->decision); $decision_map = $Conf->decision_map(); if ($o === null || !isset($decision_map[$o])) { return Conf::msg_error("Bad decision value."); } $result = Dbl::qe_raw($Conf->paperQuery($user, array("paperId" => $ssel->selection()))); $success = $fails = array(); while ($prow = PaperInfo::fetch($result, $user)) { if ($user->can_set_decision($prow, true)) { $success[] = $prow->paperId; } else { $fails[] = "#" . $prow->paperId; } } if (count($fails)) { Conf::msg_error("You cannot set paper decisions for " . pluralx($fails, "paper") . " " . commajoin($fails) . "."); } if (count($success)) { Dbl::qe("update Paper set outcome={$o} where paperId ?a", $success); $Conf->update_paperacc_setting($o > 0); redirectSelf(array("atab" => "decide", "decision" => $o)); } } } SearchAction::register("decide", null, SiteLoader::API_POST | SiteLoader::API_PAPER, new Decide_SearchAction());
function run(Contact $user, $qreq, $ssel) { list($header, $texts) = SearchAction::pcassignments_csv_data($user, $ssel->selection()); downloadCSV($texts, $header, "pcassignments", array("selection" => $header)); }
if ($asstype && $row->conflictType > 0) { $conflicts[] = $row->paperId; } else { if ($asstype && $row->reviewType >= REVIEW_PC && $asstype != $row->reviewType) { $assigned[] = $row->paperId; } else { $user->assign_review($row->paperId, $pc->contactId, $asstype); $nworked++; } } } if (count($conflicts)) { Conf::msg_error("Some papers were not assigned because of conflicts (" . join(", ", $conflicts) . "). If these conflicts are in error, remove them and try to assign again."); } if (count($assigned)) { Conf::msg_error("Some papers were not assigned because the PC member already had an assignment (" . join(", ", $assigned) . ")."); } if ($nworked) { $Conf->confirmMsg($asstype == 0 ? "Unassigned reviews." : "Assigned reviews."); } Dbl::qe_raw("unlock tables"); $Conf->update_rev_tokens_setting(false); } } } } } } } SearchAction::register("assign", null, SiteLoader::API_POST | SiteLoader::API_PAPER, new Assign_SearchAction());
<?php require 'init.inc.php'; global $templates; $search = new SearchAction('search.tpl'); $search->Action(); $templates->display('search.tpl');
protected function setupVars () { parent::setupVars (); $this->searchType = htmlentities ($_GET['type']); $this->permalink = urldecode ($_GET['p']); }
} $conflicts = $prow->conflicts(); foreach ($pcm as $cid => $p) { $pref = $prow->reviewer_preference($p); $conf = get($conflicts, $cid); $tv = $prow->topicIds ? $prow->topic_interest_score($p) : 0; if ($pref || $conf || $tv) { $texts[$prow->paperId][] = array("paper" => $prow->paperId, "title" => $prow->title, "first" => $p->firstName, "last" => $p->lastName, "email" => $p->email, "preference" => $pref[0] ?: "", "expertise" => unparse_expertise($pref[1]), "topic_score" => $tv ?: "", "conflict" => $conf ? "conflict" : ""); $has_conflict = $has_conflict || $conf; $has_expertise = $has_expertise || $pref[1] !== null; $has_topic_score = $has_topic_score || $tv; } } } $headers = array("paper", "title", "first", "last", "email", "preference"); if ($has_expertise) { $headers[] = "expertise"; } if ($has_topic_score) { $headers[] = "topic_score"; } if ($has_conflict) { $headers[] = "conflict"; } downloadCSV($ssel->reorder($texts), $headers, "allprefs", ["selection" => true]); } } SearchAction::register("get", "revpref", SiteLoader::API_GET | SiteLoader::API_PAPER, new GetRevpref_SearchAction(false)); SearchAction::register("get", "revprefx", SiteLoader::API_GET | SiteLoader::API_PAPER, new GetRevpref_SearchAction(true)); SearchAction::register("get", "allrevpref", SiteLoader::API_GET | SiteLoader::API_PAPER, new GetAllRevpref_SearchAction());