private function _prepare_sort() { global $Conf; $this->default_sort_column = PaperColumn::lookup("id"); $this->sorters[0]->field = null; if ($this->search->sorters) { foreach ($this->search->sorters as $sorter) { if ($sorter->type && ($field = PaperColumn::lookup($sorter->type)) && $field->prepare($this, PaperColumn::PREP_SORT) && $field->comparator) { $sorter->field = $field; } else { if ($sorter->type) { if ($this->contact->can_view_tags(null) && ($tagger = new Tagger()) && ($tag = $tagger->check($sorter->type)) && ($result = Dbl::qe("select paperId from PaperTag where tag=? limit 1", $tag)) && edb_nrows($result)) { $this->search->warn("Unrecognized sort “" . htmlspecialchars($sorter->type) . "”. Did you mean “sort:#" . htmlspecialchars($sorter->type) . "”?"); } else { $this->search->warn("Unrecognized sort “" . htmlspecialchars($sorter->type) . "”."); } continue; } } ListSorter::push($this->sorters, $sorter); } if (count($this->sorters) > 1 && $this->sorters[0]->empty) { array_shift($this->sorters); } } if (get($this->sorters[0], "field")) { /* all set */ } else { if ($this->sorters[0]->type && ($c = PaperColumn::lookup($this->sorters[0]->type)) && $c->prepare($this, PaperColumn::PREP_SORT)) { $this->sorters[0]->field = $c; } else { $this->sorters[0]->field = $this->default_sort_column; } } $this->sorters[0]->type = $this->sorters[0]->field->name; // set defaults foreach ($this->sorters as $s) { if ($s->reverse === null) { $s->reverse = false; } if ($s->score === null) { $s->score = ListSorter::default_score_sort(); } } }
function parse_value($sv, $name, $info) { global $Conf, $Me, $Now, $Opt; if (!isset($sv->req[$name])) { $xname = str_replace(".", "_", $name); if (isset($sv->req[$xname])) { $sv->req[$name] = $sv->req[$xname]; } else { if ($info->type === "checkbox" || $info->type === "cdate") { return 0; } else { return null; } } } $v = trim($sv->req[$name]); if ($info->placeholder && $info->placeholder === $v || $info->invalid_value && $info->invalid_value === $v) { $v = ""; } if ($info->type === "checkbox") { return $v != "" ? 1 : 0; } else { if ($info->type === "cdate" && $v == "1") { return 1; } else { if ($info->type === "date" || $info->type === "cdate" || $info->type === "ndate") { if ($v == "" || !strcasecmp($v, "N/A") || !strcasecmp($v, "same as PC") || $v == "0" || $info->type !== "ndate" && !strcasecmp($v, "none")) { return -1; } else { if (!strcasecmp($v, "none")) { return 0; } else { if (($v = $Conf->parse_time($v)) !== false) { return $v; } else { $err = unparse_setting_error($info, "Invalid date."); } } } } else { if ($info->type === "grace") { if (($v = parseGrace($v)) !== null) { return intval($v); } else { $err = unparse_setting_error($info, "Invalid grace period."); } } else { if ($info->type === "int" || $info->type === "zint") { if (preg_match("/\\A[-+]?[0-9]+\\z/", $v)) { return intval($v); } else { $err = unparse_setting_error($info, "Should be a number."); } } else { if ($info->type === "string") { // Avoid storing the default message in the database if (substr($name, 0, 9) == "mailbody_") { $t = expandMailTemplate(substr($name, 9), true); $v = cleannl($v); if ($t["body"] == $v) { return ""; } } return $v; } else { if ($info->type === "simplestring") { return simplify_whitespace($v); } else { if ($info->type === "tag" || $info->type === "tagbase") { $tagger = new Tagger($Me); $v = trim($v); if ($v === "" && $info->optional) { return $v; } $v = $tagger->check($v, $info->type === "tagbase" ? Tagger::NOVALUE : 0); if ($v) { return $v; } $err = unparse_setting_error($info, $tagger->error_html); } else { if ($info->type === "emailheader") { $v = MimeText::encode_email_header("", $v); if ($v !== false) { return $v == "" ? "" : MimeText::decode_header($v); } $err = unparse_setting_error($info, "Invalid email header."); } else { if ($info->type === "emailstring") { $v = trim($v); if ($v === "" && $info->optional) { return ""; } else { if (validate_email($v) || $v === $v_active) { return $v; } else { $err = unparse_setting_error($info, "Invalid email."); } } } else { if ($info->type === "urlstring") { $v = trim($v); if ($v === "" && $info->optional || preg_match(',\\A(?:https?|ftp)://\\S+\\z,', $v)) { return $v; } else { $err = unparse_setting_error($info, "Invalid URL."); } } else { if ($info->type === "htmlstring") { if (($v = CleanHTML::basic_clean($v, $err)) === false) { $err = unparse_setting_error($info, $err); } else { if ($info->message_default && $v === $Conf->message_default_html($info->message_default)) { return ""; } else { return $v; } } } else { if ($info->type === "radio") { foreach ($info->values as $allowedv) { if ((string) $allowedv === $v) { return $allowedv; } } $err = unparse_setting_error($info, "Parse error (unexpected value)."); } else { return $v; } } } } } } } } } } } } } $sv->set_error($name, $err); return null; }
public function parse($sv, $si) { $tagger = new Tagger(); $tracks = (object) array(); $missing_tags = false; for ($i = 1; isset($sv->req["name_track{$i}"]); ++$i) { $trackname = trim($sv->req["name_track{$i}"]); if ($trackname === "" || $trackname === "(tag)") { continue; } else { if (!$tagger->check($trackname, Tagger::NOPRIVATE | Tagger::NOCHAIR | Tagger::NOVALUE) || $trackname === "_" && $i != 1) { if ($trackname !== "_") { $sv->set_error("name_track{$i}", "Track name: " . $tagger->error_html); } else { $sv->set_error("name_track{$i}", "Track name “_” is reserved."); } $sv->set_error("tracks"); continue; } } $t = (object) array(); foreach (Track::$map as $type => $value) { if (($ttype = defval($sv->req, "{$type}_track{$i}", "")) == "+" || $ttype == "-") { $ttag = trim(defval($sv->req, "{$type}tag_track{$i}", "")); if ($ttag === "" || $ttag === "(tag)") { $sv->set_error("{$type}_track{$i}", "Tag missing for track setting."); $sv->set_error("tracks"); } else { if ($ttype == "+" && strcasecmp($ttag, "none") == 0 || $tagger->check($ttag, Tagger::NOPRIVATE | Tagger::NOCHAIR | Tagger::NOVALUE)) { $t->{$type} = $ttype . $ttag; } else { $sv->set_error("{$type}_track{$i}", $tagger->error_html); $sv->set_error("tracks"); } } } else { if ($ttype == "none") { $t->{$type} = "+none"; } } } if (count((array) $t) || get($tracks, "_")) { $tracks->{$trackname} = $t; } } $sv->save("tracks", count((array) $tracks) ? json_encode($tracks) : null); return false; }
private function make_tags_array($x, $key) { $t0 = array(); if (is_string($x)) { $t0 = preg_split("/[\\s,]+/", $x); } else { if (is_array($x)) { $t0 = $x; } else { if ($x !== null) { $this->set_error($key, "Format error [{$key}]"); } } } $tagger = new Tagger(); $t1 = array(); foreach ($t0 as $t) { if ($t !== "" && ($t = $tagger->check($t, Tagger::NOPRIVATE))) { $t1[] = $t; } else { if ($t !== "") { $this->set_error($key, $tagger->error_html); } } } return $t1; }
public function prepare(PaperList $pl, $visible) { if (!$pl->contact->can_view_tags(null)) { return false; } if (!$this->dtag && $visible === PaperColumn::PREP_COMPLETION) { return true; } $tagger = new Tagger($pl->contact); if (!($ctag = $tagger->check($this->dtag, Tagger::NOVALUE | Tagger::ALLOWCONTACTID))) { return false; } $this->ctag = strtolower(" {$ctag}#"); if ($visible) { $pl->qopts["tags"] = 1; } $this->className = $this->is_value ? "pl_tagval" : "pl_tag"; return true; }
public function check() { global $Error, $Qreq; $atypes = array("rev" => "r", "revadd" => "r", "revpc" => "r", "lead" => true, "shepherd" => true, "prefconflict" => true, "clear" => true, "discorder" => true); $this->atype = $Qreq->a; if (!$this->atype || !isset($atypes[$this->atype])) { $Error["ass"] = true; return Conf::msg_error("Malformed request!"); } $this->atype_review = $atypes[$this->atype] === "r"; $r = false; if ($this->atype_review) { $r = $Qreq[$this->atype . "type"]; if ($r != REVIEW_PRIMARY && $r != REVIEW_SECONDARY && $r != REVIEW_PC) { $Error["ass"] = true; return Conf::msg_error("Malformed request!"); } } else { if ($this->atype === "clear") { $r = $Qreq->cleartype; if ($r != REVIEW_PRIMARY && $r != REVIEW_SECONDARY && $r != REVIEW_PC && $r !== "conflict" && $r !== "lead" && $r !== "shepherd") { $Error["clear"] = true; return Conf::msg_error("Malformed request!"); } } } $this->reviewtype = $r; if ($this->atype_review && $Qreq->rev_roundtag !== "" && ($err = Conf::round_name_error($Qreq->rev_roundtag))) { $Error["rev_roundtag"] = true; return Conf::msg_error($err); } if ($this->atype === "rev" && cvtint($Qreq->revct, -1) <= 0) { $Error["rev"] = true; return Conf::msg_error("Enter the number of reviews you want to assign."); } else { if ($this->atype === "revadd" && cvtint($Qreq->revaddct, -1) <= 0) { $Error["revadd"] = true; return Conf::msg_error("You must assign at least one review."); } else { if ($this->atype === "revpc" && cvtint($Qreq->revpcct, -1) <= 0) { $Error["revpc"] = true; return Conf::msg_error("You must assign at least one review."); } } } if ($this->atype === "discorder") { $tag = trim((string) $Qreq->discordertag); $tag = $tag === "" ? "discuss" : $tag; $tagger = new Tagger(); if (!($tag = $tagger->check($tag, Tagger::NOVALUE))) { $Error["discordertag"] = true; return Conf::msg_error($tagger->error_html); } $this->discordertag = $tag; } return $this->ok = true; }
function do_tags() { global $Conf, $Me, $papersel; // check tags $tagger = new Tagger($Me); $t1 = array(); $errors = array(); foreach (preg_split('/[\\s,]+/', (string) @$_REQUEST["tag"]) as $t) { if ($t === "") { /* nada */ } else { if (!($t = $tagger->check($t, Tagger::NOPRIVATE))) { $errors[] = $tagger->error_html; } else { if (TagInfo::base($t) === "pc") { $errors[] = "The “pc” user tag is set automatically for all PC members."; } else { $t1[] = $t; } } } } if (count($errors)) { return Conf::msg_error(join("<br>", $errors)); } else { if (!count($t1)) { return $Conf->warnMsg("Nothing to do."); } } // modify database Dbl::qe("lock tables ContactInfo write"); Conf::$no_invalidate_caches = true; $users = array(); if ($_REQUEST["tagtype"] === "s") { // erase existing tags $likes = array(); $removes = array(); foreach ($t1 as $t) { list($tag, $index) = TagInfo::split_index($t); $removes[] = $t; $likes[] = "contactTags like " . Dbl::utf8ci("'% " . sqlq_for_like($tag) . "#%'"); } foreach (Dbl::fetch_first_columns(Dbl::qe("select contactId from ContactInfo where " . join(" or ", $likes))) as $cid) { $users[(int) $cid] = (object) array("id" => (int) $cid, "add_tags" => [], "remove_tags" => $removes); } } // account for request $key = $_REQUEST["tagtype"] === "d" ? "remove_tags" : "add_tags"; foreach ($papersel as $cid) { if (!isset($users[(int) $cid])) { $users[(int) $cid] = (object) array("id" => (int) $cid, "add_tags" => [], "remove_tags" => []); } $users[(int) $cid]->{$key} = array_merge($users[(int) $cid]->{$key}, $t1); } // apply modifications foreach ($users as $cid => $cj) { $us = new UserStatus(array("send_email" => false)); if (!$us->save($cj)) { $errors = array_merge($errors, $us->error_messages()); } } Dbl::qe("unlock tables"); Conf::$no_invalidate_caches = false; $Conf->invalidateCaches(["pc" => true]); // report if (!count($errors)) { $Conf->confirmMsg("Tags saved."); redirectSelf(array("tagact" => null, "tag" => null)); } else { Conf::msg_error(join("<br>", $errors)); } }
public function save($req, $contact) { global $Conf, $Now; if (is_array($req)) { $req = (object) $req; } $Table = $this->prow->comment_table_name(); $LinkTable = $this->prow->table_name(); $LinkColumn = $this->prow->id_column(); $req_visibility = get($req, "visibility"); $is_response = !!($this->commentType & COMMENTTYPE_RESPONSE); if ($is_response && get($req, "submit")) { $ctype = COMMENTTYPE_RESPONSE | COMMENTTYPE_AUTHOR; } else { if ($is_response) { $ctype = COMMENTTYPE_RESPONSE | COMMENTTYPE_AUTHOR | COMMENTTYPE_DRAFT; } else { if ($req_visibility == "a" || $req_visibility == "au") { $ctype = COMMENTTYPE_AUTHOR; } else { if ($req_visibility == "p" || $req_visibility == "pc") { $ctype = COMMENTTYPE_PCONLY; } else { if ($req_visibility == "admin") { $ctype = COMMENTTYPE_ADMINONLY; } else { if ($this->commentId && $req_visibility === null) { $ctype = $this->commentType; } else { // $req->visibility == "r" || $req->visibility == "rev" $ctype = COMMENTTYPE_REVIEWER; } } } } } } if ($is_response ? $this->prow->blind : $Conf->is_review_blind(!!get($req, "blind"))) { $ctype |= COMMENTTYPE_BLIND; } // tags if ($is_response) { $ctags = " response "; if (($rname = $Conf->resp_round_name($this->commentRound)) != "1") { $ctags .= "{$rname}response "; } } else { if (get($req, "tags") && preg_match_all(',\\S+,', $req->tags, $m)) { $tagger = new Tagger($contact); $ctags = array(); foreach ($m[0] as $text) { if (($text = $tagger->check($text, Tagger::NOVALUE)) && !stri_ends_with($text, "response")) { $ctags[strtolower($text)] = $text; } } $tagger->sort($ctags); $ctags = count($ctags) ? " " . join(" ", $ctags) . " " : null; } else { $ctags = null; } } // notifications $displayed = !($ctype & COMMENTTYPE_DRAFT); // query $text = get_s($req, "text"); $q = ""; $qv = array(); if ($text === "" && $this->commentId) { $change = true; $q = "delete from {$Table} where commentId={$this->commentId}"; } else { if ($text === "") { /* do nothing */ } else { if (!$this->commentId) { $change = true; $qa = ["contactId, {$LinkColumn}, commentType, comment, commentOverflow, timeModified, replyTo"]; $qb = [$contact->contactId, $this->prow->{$LinkColumn}, $ctype, "?", "?", $Now, 0]; if (strlen($text) <= 32000) { array_push($qv, $text, null); } else { array_push($qv, UnicodeHelper::utf8_prefix($text, 200), $text); } if ($ctags !== null) { $qa[] = "commentTags"; $qb[] = "?"; $qv[] = $ctags; } if ($is_response) { $qa[] = "commentRound"; $qb[] = $this->commentRound; } if ($displayed) { $qa[] = "timeDisplayed, timeNotified"; $qb[] = "{$Now}, {$Now}"; } $q = "insert into {$Table} (" . join(", ", $qa) . ") select " . join(", ", $qb) . "\n"; if ($is_response) { // make sure there is exactly one response $q .= " from (select {$LinkTable}.{$LinkColumn}, coalesce(commentId, 0) commentId\n from {$LinkTable}\n left join {$Table} on ({$Table}.{$LinkColumn}={$LinkTable}.{$LinkColumn} and (commentType&" . COMMENTTYPE_RESPONSE . ")!=0 and commentRound={$this->commentRound})\n where {$LinkTable}.{$LinkColumn}={$this->prow->{$LinkColumn}} limit 1) t\n where t.commentId=0"; } } else { $change = $this->commentType >= COMMENTTYPE_AUTHOR != $ctype >= COMMENTTYPE_AUTHOR; if ($this->timeModified >= $Now) { $Now = $this->timeModified + 1; } // do not notify on updates within 3 hours $qa = ""; if ($this->timeNotified + 10800 < $Now || $ctype & COMMENTTYPE_RESPONSE && !($ctype & COMMENTTYPE_DRAFT) && $this->commentType & COMMENTTYPE_DRAFT) { $qa .= ", timeNotified={$Now}"; } // reset timeDisplayed if you change the comment type if ((!$this->timeDisplayed || $this->ordinal_missing($ctype)) && $text !== "" && $displayed) { $qa .= ", timeDisplayed={$Now}"; } $q = "update {$Table} set timeModified={$Now}{$qa}, commentType={$ctype}, comment=?, commentOverflow=?, commentTags=? where commentId={$this->commentId}"; if (strlen($text) <= 32000) { array_push($qv, $text, null); } else { array_push($qv, UnicodeHelper::utf8_prefix($text, 200), $text); } $qv[] = $ctags; } } } $result = Dbl::qe_apply($q, $qv); if (!$result) { return false; } $cmtid = $this->commentId ?: $result->insert_id; if (!$cmtid) { return false; } // log $contact->log_activity("Comment {$cmtid} " . ($text !== "" ? "saved" : "deleted"), $this->prow->{$LinkColumn}); // ordinal if ($text !== "" && $this->ordinal_missing($ctype)) { $this->save_ordinal($cmtid, $ctype, $Table, $LinkTable, $LinkColumn); } // reload if ($text !== "") { $comments = $this->prow->fetch_comments("commentId={$cmtid}"); $this->merge($comments[$cmtid], $this->prow); if ($this->timeNotified == $this->timeModified) { self::$watching = $this; $this->prow->notify(WATCHTYPE_COMMENT, "CommentInfo::watch_callback", $contact); self::$watching = null; } } else { $this->commentId = 0; $this->comment = ""; $this->commentTags = null; } return true; }
function run(Contact $user, $qreq, $ssel) { global $Conf; $papers = $ssel->selection(); $act = $qreq->tagfn; $tagreq = trim(str_replace(",", " ", (string) $qreq->tag)); $tags = preg_split('/\\s+/', $tagreq); if ($act == "da") { $otags = $tags; foreach ($otags as $t) { $tags[] = "all~" . preg_replace(',\\A.*~([^~]+)\\z', '$1', $t); } $act = "d"; } else { if ($act == "sor") { shuffle($papers); } } $x = array("action,paper,tag\n"); if ($act == "s" || $act == "so" || $act == "sos" || $act == "sor") { foreach ($tags as $t) { $x[] = "cleartag,all," . TagInfo::base($t) . "\n"; } } if ($act == "s" || $act == "a") { $action = "tag"; } else { if ($act == "d") { $action = "cleartag"; } else { if ($act == "so" || $act == "sor" || $act == "ao") { $action = "nexttag"; } else { if ($act == "sos" || $act == "aos") { $action = "seqnexttag"; } else { $action = null; } } } } $assignset = new AssignmentSet($user, $user->privChair); if (count($papers) && $action) { foreach ($papers as $p) { foreach ($tags as $t) { $x[] = "{$action},{$p},{$t}\n"; } } $assignset->parse(join("", $x)); } else { if (count($papers) && $act == "cr" && $user->privChair) { $source_tag = trim((string) $qreq->tagcr_source); if ($source_tag == "") { $source_tag = substr($tagreq, 0, 2) == "~~" ? substr($tagreq, 2) : $tagreq; } $tagger = new Tagger($user); if ($tagger->check($tagreq, Tagger::NOPRIVATE | Tagger::NOVALUE) && $tagger->check($source_tag, Tagger::NOPRIVATE | Tagger::NOCHAIR | Tagger::NOVALUE)) { $r = new PaperRank($source_tag, $tagreq, $papers, $qreq->tagcr_gapless, "Search", "search"); $r->run($qreq->tagcr_method); $r->apply($assignset); $assignset->finish(); if ($qreq->q === "") { $qreq->q = "order:{$tagreq}"; } } else { $assignset->error($tagger->error_html); } } } 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); } } }
function run(Contact $user, $qreq, $ssel) { global $Conf; $settingrank = $Conf->setting("tag_rank") && $qreq->tag == "~" . $Conf->setting_data("tag_rank"); if (!$user->isPC && !($user->is_reviewer() && $settingrank)) { return self::EPERM; } $tagger = new Tagger($user); if ($tag = $tagger->check($qreq->tag, Tagger::NOVALUE | Tagger::NOCHAIR)) { $result = Dbl::qe_raw($Conf->paperQuery($user, array("paperId" => $ssel->selection(), "tagIndex" => $tag, "order" => "order by tagIndex, PaperReview.overAllMerit desc, Paper.paperId"))); $real = ""; $null = "\n"; while ($prow = PaperInfo::fetch($result, $user)) { if ($user->can_change_tag($prow, $tag, null, 1)) { if ($prow->tagIndex === null) { $null .= "X\t{$prow->paperId}\t{$prow->title}\n"; } else { if ($real === "" || $lastIndex == $row->tagIndex - 1) { $real .= "\t{$prow->paperId}\t{$prow->title}\n"; } else { if ($lastIndex == $row->tagIndex) { $real .= "=\t{$prow->paperId}\t{$prow->title}\n"; } else { $real .= str_pad("", min($prow->tagIndex - $lastIndex, 5), ">") . "\t{$prow->paperId}\t{$prow->title}\n"; } } } $lastIndex = $prow->tagIndex; } } $text = "# Edit the rank order by rearranging this file's lines.\n\n# The first line has the highest rank. Lines starting with \"#\" are\n# ignored. Unranked papers appear at the end in lines starting with\n# \"X\", sorted by overall merit. Create a rank by removing the \"X\"s and\n# rearranging the lines. Lines starting with \"=\" mark papers with the\n# same rank as the preceding papers. Lines starting with \">>\", \">>>\",\n# and so forth indicate rank gaps between papers. When you are done,\n# upload the file at\n" . "# " . hoturl_absolute("offline") . "\n\n" . "Tag: " . trim($qreq->tag) . "\n" . "\n" . $real . $null; downloadText($text, "rank"); } else { Conf::msg_error($tagger->error_html); } }
private function _tag_description() { if ($this->q === "") { return false; } else { if (strlen($this->q) <= 24) { return htmlspecialchars($this->q); } else { if (!preg_match(',\\A(#|-#|tag:|-tag:|notag:|order:|rorder:)(.*)\\z,', $this->q, $m)) { return false; } } } $tagger = new Tagger($this->contact); if (!$tagger->check($m[2])) { return false; } else { if ($m[1] === "-tag:") { return "no" . substr($this->q, 1); } else { return $this->q; } } }
function setTagIndexes() { global $Conf, $Me, $Error; $filename = null; if (isset($_REQUEST["upload"]) && fileUploaded($_FILES["file"])) { if (($text = file_get_contents($_FILES["file"]["tmp_name"])) === false) { Conf::msg_error("Internal error: cannot read file."); return; } $filename = @$_FILES["file"]["name"]; } else { if (!($text = defval($_REQUEST, "data"))) { Conf::msg_error("Choose a file first."); return; } } $RealMe = $Me; $tagger = new Tagger(); if ($tag = defval($_REQUEST, "tag")) { $tag = $tagger->check($tag, Tagger::NOVALUE); } $curIndex = 0; $lineno = 1; $settings = $titles = $linenos = $errors = array(); foreach (explode("\n", rtrim(cleannl($text))) as $l) { if (substr($l, 0, 4) == "Tag:" || substr($l, 0, 6) == "# Tag:") { if (!$tag) { $tag = $tagger->check(trim(substr($l, $l[0] == "#" ? 6 : 4)), Tagger::NOVALUE); } ++$lineno; continue; } else { if ($l == "" || $l[0] == "#") { ++$lineno; continue; } } if (preg_match('/\\A\\s*?([Xx=]|>*|\\([-\\d]+\\))\\s+(\\d+)\\s*(.*?)\\s*\\z/', $l, $m)) { if (isset($settings[$m[2]])) { $errors[$lineno] = "Paper #{$m['2']} already given on line " . $linenos[$m[2]]; } if ($m[1] == "X" || $m[1] == "x") { $settings[$m[2]] = null; } else { if ($m[1] == "" || $m[1] == ">") { $settings[$m[2]] = $curIndex = $curIndex + 1; } else { if ($m[1][0] == "(") { $settings[$m[2]] = $curIndex = substr($m[1], 1, -1); } else { if ($m[1] == "=") { $settings[$m[2]] = $curIndex; } else { $settings[$m[2]] = $curIndex = $curIndex + strlen($m[1]); } } } } $titles[$m[2]] = $m[3]; $linenos[$m[2]] = $lineno; } else { if ($RealMe->privChair && preg_match('/\\A\\s*<\\s*([^<>]*?(|<[^<>]*>))\\s*>\\s*\\z/', $l, $m)) { if (count($settings) && $Me) { saveTagIndexes($tag, $filename, $settings, $titles, $linenos, $errors); } $ret = ContactSearch::make_pc($m[1], $RealMe); $Me = null; if (count($ret->ids) == 1) { $Me = $ret->contact(0); } else { if (count($ret->ids) == 0) { $errors[$lineno] = htmlspecialchars($m[1]) . " matches no PC member"; } else { $errors[$lineno] = htmlspecialchars($m[1]) . " matches more than one PC member, give a full email address to disambiguate"; } } } else { if (trim($l) !== "") { $errors[$lineno] = "Syntax error"; } } } ++$lineno; } if (count($settings) && $Me) { saveTagIndexes($tag, $filename, $settings, $titles, $linenos, $errors); } $Me = $RealMe; if (count($errors)) { ksort($errors); if ($filename) { foreach ($errors as $lineno => &$error) { $error = '<span class="lineno">' . htmlspecialchars($filename) . ':' . $lineno . ':</span> ' . $error; } } $Error["tags"] = '<div class="parseerr"><p>' . join("</p>\n<p>", $errors) . '</p></div>'; } if (isset($Error["tags"])) { Conf::msg_error($Error["tags"]); } else { if (isset($_REQUEST["setvote"])) { $Conf->confirmMsg("Votes saved."); } else { $Conf->confirmMsg("Ranking saved. To view it, <a href='" . hoturl("search", "q=order:" . urlencode($tag)) . "'>search for “order:{$tag}”</a>."); } } }
static function votereport_api($user, $qreq, $prow) { $tagger = new Tagger($user); if (!($tag = $tagger->check($qreq->tag, Tagger::NOVALUE))) { json_exit(["ok" => false, "error" => $tagger->error_html]); } if (!$user->can_view_peruser_tags($prow, $tag)) { json_exit(["ok" => false, "error" => "Permission error."]); } $votemap = []; preg_match_all('/ (\\d+)~' . preg_quote($tag) . '#(\\S+)/i', $prow->all_tags_text(), $m); $is_approval = TagInfo::is_approval($tag); $min_vote = $is_approval ? 0 : 0.001; for ($i = 0; $i != count($m[0]); ++$i) { if ($m[2][$i] >= $min_vote) { $votemap[$m[1][$i]] = $m[2][$i]; } } $user->ksort_cid_array($votemap); $result = []; foreach ($votemap as $k => $v) { if ($is_approval) { $result[] = $user->reviewer_html_for($k); } else { $result[] = $user->reviewer_html_for($k) . " ({$v})"; } } if (empty($result)) { json_exit(["ok" => true, "result" => ""]); } else { json_exit(["ok" => true, "result" => '<span class="nw">' . join(',</span> <span class="nw">', $result) . '</span>']); } }
public function compile(FormulaCompiler $state) { $state->queryOptions["tags"] = true; $tagger = new Tagger($state->contact); $e_tag = $tagger->check($this->tag); $t_tags = $state->define_gvar("tags", "\$contact->can_view_tags(\$prow, \$forceShow) ? \$prow->all_tags_text() : \"\""); $t_tagpos = $state->define_gvar("tagpos_{$this->tag}", "stripos({$t_tags}, \" {$e_tag}#\")"); $t_tagval = $state->define_gvar("tagval_{$this->tag}", "({$t_tagpos} !== false ? (float) substr({$t_tags}, {$t_tagpos} + " . (strlen($e_tag) + 2) . ") : false)"); if ($this->isvalue) { return $t_tagval; } else { return "({$t_tagval} !== (float) 0 ? {$t_tagval} : true)"; } }