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));
     }
 }
function savePreferences($Qreq)
{
    global $Conf, $Me, $OK, $reviewer, $incorrect_reviewer;
    if ($incorrect_reviewer) {
        Conf::msg_error("Preferences not saved.");
        return;
    }
    $setting = array();
    $error = false;
    $pmax = 0;
    foreach ($Qreq as $k => $v) {
        if (strlen($k) > 7 && $k[0] == "r" && substr($k, 0, 7) == "revpref" && ($p = cvtint(substr($k, 7))) > 0) {
            if ($pref = parse_preference($v)) {
                $setting[$p] = $pref;
                $pmax = max($pmax, $p);
            } else {
                $error = true;
            }
        }
    }
    if ($error) {
        Conf::msg_error("Preferences must be small positive or negative integers.");
    }
    if ($pmax == 0 && !$error) {
        Conf::msg_error("No reviewer preferences to update.");
    }
    if ($pmax == 0) {
        return;
    }
    $deletes = array();
    for ($p = 1; $p <= $pmax; $p++) {
        if (isset($setting[$p])) {
            $p0 = $p;
            while (isset($setting[$p + 1])) {
                ++$p;
            }
            if ($p0 == $p) {
                $deletes[] = "paperId={$p0}";
            } else {
                $deletes[] = "paperId between {$p0} and {$p}";
            }
        }
    }
    if (count($deletes)) {
        $Conf->qe("delete from PaperReviewPreference where contactId={$reviewer} and (" . join(" or ", $deletes) . ")");
    }
    $q = array();
    for ($p = 1; $p <= $pmax; $p++) {
        if (($pref = get($setting, $p)) && ($pref[0] || $pref[1] !== null)) {
            $q[] = array($p, $reviewer, $pref[0], $pref[1]);
        }
    }
    PaperActions::save_review_preferences($q);
    if ($OK) {
        $Conf->confirmMsg("Preferences saved.");
        redirectSelf();
    }
}
 public function __construct($papers = null)
 {
     if ($papers) {
         $selmap = [];
         foreach ($papers as $pid) {
             if (($pid = cvtint($pid)) > 0 && !isset($selmap[$pid])) {
                 $this->sel[] = $selmap[$pid] = $pid;
             }
         }
     }
 }
 public function __construct($data = null)
 {
     if (is_array($data)) {
         foreach ($data as $key => $value) {
             $this->add($value, $key);
         }
     } else {
         if (is_string($data) && $data !== "") {
             foreach (preg_split('/[\\s,]+/', $data) as $s) {
                 if (($i = cvtint($s)) > 0) {
                     $this->add($i);
                 }
             }
         }
     }
 }
 static function set_follow($prow)
 {
     global $Conf, $Me, $OK;
     $ajax = defval($_REQUEST, "ajax", 0);
     $cid = $Me->contactId;
     if ($Me->privChair && ($x = cvtint(@$_REQUEST["contactId"])) > 0) {
         $cid = $x;
     }
     saveWatchPreference($prow->paperId, $cid, WATCHTYPE_COMMENT, defval($_REQUEST, "follow"));
     if ($OK) {
         $Conf->confirmMsg("Saved");
     }
     if ($ajax) {
         $Conf->ajaxExit(array("ok" => $OK));
     }
 }
 function run(Contact $user, $qreq, $ssel)
 {
     global $Conf, $Opt;
     // maybe download preferences for someone else
     $Rev = $user;
     if (($cid = cvtint($qreq->reviewer)) > 0 && $user->privChair) {
         if (!($Rev = Contact::find_by_id($cid))) {
             return Conf::msg_error("No such reviewer");
         }
     }
     if (!$Rev->isPC) {
         return self::EPERM;
     }
     $q = $Conf->paperQuery($Rev, array("paperId" => $ssel->selection(), "topics" => 1, "reviewerPreference" => 1));
     $result = Dbl::qe_raw($q);
     $texts = array();
     while ($prow = PaperInfo::fetch($result, $Rev)) {
         $t = $prow->paperId . "," . CsvGenerator::quote($prow->title);
         if ($prow->conflictType > 0) {
             $t .= ",conflict";
         } else {
             $t .= "," . unparse_preference($prow);
         }
         $t .= "\n";
         if ($this->extended) {
             if ($Rev->can_view_authors($prow, false)) {
                 $t .= prefix_word_wrap("#  Authors: ", $prow->pretty_text_author_list(), "#           ");
             }
             $t .= prefix_word_wrap("# Abstract: ", rtrim($prow->abstract), "#           ");
             if ($prow->topicIds != "") {
                 $t .= prefix_word_wrap("#   Topics: ", $prow->unparse_topics_text(), "#           ");
             }
             $t .= "\n";
         }
         defappend($texts[$prow->paperId], $t);
     }
     downloadCSV(join("", $ssel->reorder($texts)), ["paper", "title", "preference"], "revprefs");
 }
示例#7
0
        $wheres[] = "(" . join(" or ", $where) . ")";
    } else {
        $Conf->infoMsg("No accounts match “" . htmlspecialchars($_REQUEST["acct"]) . "”.");
        $wheres[] = "false";
    }
}
if ($str = $_REQUEST["q"]) {
    $where = array();
    while (($str = ltrim($str)) != "") {
        preg_match('/^("[^"]+"?|[^"\\s]+)/s', $str, $m);
        $str = substr($str, strlen($m[0]));
        $where[] = "action like " . Dbl::utf8ci("'%" . sqlq_for_like($m[0]) . "%'");
    }
    $wheres[] = "(" . join(" or ", $where) . ")";
}
if (($count = cvtint(@$_REQUEST["n"])) <= 0) {
    Conf::msg_error("\"Show <i>n</i> records\" requires a number greater than 0.");
    $Eclass["n"] = " error";
    $count = $DEFAULT_COUNT;
}
$firstDate = false;
if ($_REQUEST["date"] == "") {
    $_REQUEST["date"] = "now";
}
if ($_REQUEST["date"] != "now" && isset($_REQUEST["search"])) {
    if (($firstDate = $Conf->parse_time($_REQUEST["date"])) === false) {
        Conf::msg_error("“" . htmlspecialchars($_REQUEST["date"]) . "” is not a valid date.");
        $Eclass["date"] = " error";
    }
}
function searchbar()
 private function apply_remove($pid, $contact, AssignmentState $state, $m)
 {
     $prow = $state->prow($pid);
     // resolve twiddle portion
     if ($m[1] && $m[1] != "~~" && !ctype_digit(substr($m[1], 0, strlen($m[1]) - 1))) {
         $c = substr($m[1], 0, strlen($m[1]) - 1);
         $twiddlecids = ContactSearch::make_pc($c, $state->contact->contactId)->ids;
         if (count($twiddlecids) == 0) {
             return "“" . htmlspecialchars($c) . "” doesn’t match a PC member.";
         } else {
             if (count($twiddlecids) == 1) {
                 $m[1] = $twiddlecids[0] . "~";
             } else {
                 $m[1] = "(?:" . join("|", $twiddlecids) . ")~";
             }
         }
     }
     // resolve tag portion
     $search_ltag = null;
     if (strcasecmp($m[2], "none") == 0) {
         return;
     } else {
         if (strcasecmp($m[2], "any") == 0 || strcasecmp($m[2], "all") == 0) {
             if ($m[1]) {
                 $m[2] = "[^~]*";
             } else {
                 if ($state->contact->privChair) {
                     $m[2] = "(?:~~|" . $state->contact->contactId . "~|)[^~]*";
                 } else {
                     $m[2] = "(?:" . $state->contact->contactId . "~|)[^~]*";
                 }
             }
         } else {
             if (!preg_match(',[*(],', $m[1] . $m[2])) {
                 $search_ltag = $m[1] . $m[2];
             }
             $m[2] = str_replace("\\*", "[^~]*", preg_quote($m[2]));
         }
     }
     // resolve index comparator
     if (preg_match(',\\A(?:any|all|none|clear)\\z,i', $m[4])) {
         $m[3] = $m[4] = "";
     } else {
         if ($m[3] == "#") {
             $m[3] = "=";
         }
         $m[4] = cvtint($m[4], 0);
     }
     // if you can't view the tag, you can't clear the tag
     // (information exposure)
     if ($search_ltag && !$state->contact->can_view_tag($prow, $search_ltag, $state->override)) {
         return $this->cannot_view_error($state, $pid, $search_ltag);
     }
     // query
     $res = $state->query(array("type" => "tag", "pid" => $pid, "ltag" => $search_ltag));
     $tag_re = '{\\A' . $m[1] . $m[2] . '\\z}i';
     $vote_adjustments = array();
     foreach ($res as $x) {
         if (preg_match($tag_re, $x["ltag"]) && (!$m[3] || CountMatcher::compare($x["_index"], $m[3], $m[4])) && ($search_ltag || $state->contact->can_change_tag($prow, $x["ltag"], $x["_index"], null, $state->override))) {
             $state->remove($x);
             if ($v = TagInfo::votish_base($x["ltag"])) {
                 $vote_adjustments[$v] = true;
             }
         }
     }
     foreach ($vote_adjustments as $vtag => $v) {
         $this->account_votes($pid, $vtag, $state);
     }
 }
示例#9
0
function scoreCounts($text, $max = null)
{
    $merit = $max ? array_fill(1, $max, 0) : array();
    $n = $sum = $sumsq = 0;
    foreach (preg_split('/[\\s,]+/', $text) as $i) {
        if (($i = cvtint($i)) > 0) {
            while ($i > count($merit)) {
                $merit[count($merit) + 1] = 0;
            }
            $merit[$i]++;
            $sum += $i;
            $sumsq += $i * $i;
            $n++;
        }
    }
    $avg = $n > 0 ? $sum / $n : 0;
    $dev = $n > 1 ? sqrt(($sumsq - $sum * $sum / $n) / ($n - 1)) : 0;
    return (object) array("v" => $merit, "max" => count($merit), "n" => $n, "avg" => $avg, "stddev" => $dev);
}
示例#10
0
 static function setpref_api($user, $qreq, $prow)
 {
     global $Conf;
     $cid = $user->contactId;
     if ($user->allow_administer($prow) && $qreq->reviewer && ($x = cvtint($qreq->reviewer)) > 0) {
         $cid = $x;
     }
     if ($v = parse_preference($qreq->pref)) {
         if (PaperActions::save_review_preferences([[$prow->paperId, $cid, $v[0], $v[1]]])) {
             $j = ["ok" => true, "response" => "Saved"];
         } else {
             $j = ["ok" => false];
         }
         $j["value"] = unparse_preference($v);
     } else {
         $j = ["ok" => false, "error" => "Bad preference"];
     }
     json_exit($j);
 }
示例#11
0
function document_download()
{
    global $Conf, $Me, $Opt;
    $documentType = HotCRPDocument::parse_dtype(@$_REQUEST["dt"]);
    if ($documentType === null) {
        $documentType = @$_REQUEST["final"] ? DTYPE_FINAL : DTYPE_SUBMISSION;
    }
    $attachment_filename = false;
    $docid = null;
    if (isset($_REQUEST["p"])) {
        $paperId = cvtint(@$_REQUEST["p"]);
    } else {
        if (isset($_REQUEST["paperId"])) {
            $paperId = cvtint(@$_REQUEST["paperId"]);
        } else {
            $s = $orig_s = preg_replace(',\\A/*,', "", Navigation::path());
            $documentType = $dtname = null;
            if (str_starts_with($s, $Opt["downloadPrefix"])) {
                $s = substr($s, strlen($Opt["downloadPrefix"]));
            }
            if (preg_match(',\\Ap(?:aper)?(\\d+)/+(.*)\\z,', $s, $m)) {
                $paperId = intval($m[1]);
                if (preg_match(',\\A([^/]+)\\.[^/]+\\z,', $m[2], $mm)) {
                    $dtname = $mm[1];
                } else {
                    if (preg_match(',\\A([^/]+)/+(.*)\\z,', $m[2], $mm)) {
                        list($dtype, $attachment_filename) = array($m[1], $m[2]);
                    }
                }
            } else {
                if (preg_match(',\\A(?:paper)?(\\d+)-?([-A-Za-z0-9_]*)(?:\\.[^/]+|/+(.*))\\z,', $s, $m)) {
                    list($paperId, $dtname, $attachment_filename) = array(intval($m[1]), $m[2], @$m[3]);
                } else {
                    if (preg_match(',\\A([A-Za-z_][-A-Za-z0-9_]*?)?-?(\\d+)(?:\\.[^/]+|/+(.*))\\z,', $s, $m)) {
                        list($paperId, $dtname, $attachment_filename) = array(intval($m[2]), $m[1], @$m[3]);
                    }
                }
            }
            if ($dtname !== null) {
                $documentType = HotCRPDocument::parse_dtype($dtname ?: "paper");
            }
            if ($documentType !== null && $attachment_filename) {
                $o = PaperOption::find($documentType);
                if (!$o || $o->type != "attachments") {
                    $documentType = null;
                }
            }
        }
    }
    if ($documentType === null) {
        document_error("404 Not Found", "Unknown document “" . htmlspecialchars($orig_s) . "”.");
    }
    $prow = $Conf->paperRow($paperId, $Me, $whyNot);
    if (!$prow) {
        document_error("404 Not Found", whyNotText($whyNot, "view"));
    } else {
        if ($whyNot = $Me->perm_view_pdf($prow)) {
            document_error("403 Forbidden", whyNotText($whyNot, "view"));
        } else {
            if ($documentType > 0 && !$Me->can_view_paper_option($prow, $documentType, true)) {
                document_error("403 Forbidden", "You don’t have permission to view this document.");
            }
        }
    }
    if ($attachment_filename) {
        $oa = $prow->option($documentType);
        foreach ($oa ? $oa->documents($prow) : array() as $doc) {
            if ($doc->unique_filename == $attachment_filename) {
                $docid = $doc;
            }
        }
        if (!$docid) {
            document_error("404 Not Found", "No such attachment “" . htmlspecialchars($orig_s) . "”.");
        }
    }
    // Actually download paper.
    session_write_close();
    // to allow concurrent clicks
    if ($Conf->downloadPaper($prow, cvtint(@$_REQUEST["save"]) > 0, $documentType, $docid)) {
        exit;
    }
    document_error("500 Server Error", null);
}
示例#12
0
文件: run.php 项目: kohler/peteramati
    if (!$Info->commit()) {
        quit("No commit to run");
    } else {
        if ($Qreq->run === null || !check_post()) {
            quit("Permission error");
        } else {
            if (!$Info->can_view_repo_contents) {
                quit("Unconfirmed repository");
            }
        }
    }
}
// extract request info
$Queueid = cvtint($Qreq->get("queueid", -1));
$checkt = cvtint($Qreq->get("check"));
$Offset = cvtint($Qreq->get("offset", -1));
// maybe eval
function runner_eval($runner, $info, $answer)
{
    global $ConfSitePATH;
    if (isset($runner->load) && $runner->load[0] == "/") {
        require_once $runner->load;
    } else {
        if (isset($runner->load)) {
            require_once $ConfSitePATH . "/" . $runner->load;
        }
    }
    $answer->result = call_user_func($runner->eval, $info);
}
// checkup
if ($checkt > 0 && ($answer = ContactView::runner_json($Info, $checkt, $Offset))) {
示例#13
0
function rcvtint(&$value, $default = -1)
{
    return isset($value) ? cvtint($value, $default) : $default;
}
示例#14
0
    $_REQUEST["u"] = $_REQUEST["contact"];
}
if (!isset($_REQUEST["u"]) && preg_match(',\\A/(?:new|[^\\s/]+)\\z,i', Navigation::path())) {
    $_REQUEST["u"] = substr(Navigation::path(), 1);
}
if ($Me->privChair && @$_REQUEST["new"]) {
    $_REQUEST["u"] = "new";
}
// Load user.
$Acct = $Me;
if ($Me->privChair && @$_REQUEST["u"]) {
    if ($_REQUEST["u"] === "new") {
        $Acct = new Contact();
        $newProfile = true;
    } else {
        if (($id = cvtint($_REQUEST["u"])) > 0) {
            $Acct = Contact::find_by_id($id);
        } else {
            $Acct = Contact::find_by_email($_REQUEST["u"]);
        }
    }
}
// Redirect if requested user isn't loaded user.
if (!$Acct || isset($_REQUEST["u"]) && $_REQUEST["u"] !== (string) $Acct->contactId && strcasecmp($_REQUEST["u"], $Acct->email) && ($Acct->contactId || $_REQUEST["u"] !== "new") || isset($_REQUEST["profile_contactid"]) && $_REQUEST["profile_contactid"] !== (string) $Acct->contactId) {
    if (!$Acct) {
        Conf::msg_error("Invalid user.");
    } else {
        if (isset($_REQUEST["register"]) || isset($_REQUEST["bulkregister"])) {
            Conf::msg_error("You’re logged in as a different user now, so your changes were ignored.");
        }
    }
 public function run()
 {
     global $Conf, $Me, $Qreq, $SSel, $pcsel, $badpairs, $scoreselector;
     assert($this->ok);
     session_write_close();
     // this might take a long time
     set_time_limit(240);
     // prepare autoassigner
     if ($Qreq->seed && is_numeric($Qreq->seed)) {
         srand((int) $Qreq->seed);
     }
     $this->autoassigner = $autoassigner = new Autoassigner($SSel->selection());
     if ($Qreq->pctyp === "sel") {
         $n = $autoassigner->select_pc(array_keys($pcsel));
         if ($n == 0) {
             Conf::msg_error("Select one or more PC members to assign.");
             return null;
         }
     }
     if ($Qreq->balance === "all") {
         $autoassigner->set_balance(Autoassigner::BALANCE_ALL);
     }
     foreach ($badpairs as $cid1 => $bp) {
         foreach ($bp as $cid2 => $x) {
             $autoassigner->avoid_pair_assignment($cid1, $cid2);
         }
     }
     if ($Qreq->method === "random") {
         $autoassigner->set_method(Autoassigner::METHOD_RANDOM);
     } else {
         $autoassigner->set_method(Autoassigner::METHOD_MCMF);
     }
     $autoassigner->add_progressf(array($this, "progress"));
     $this->live = true;
     echo '<div id="propass" class="propass">';
     $this->start_at = microtime(true);
     if ($this->atype === "prefconflict") {
         $autoassigner->run_prefconflict($Qreq->t);
     } else {
         if ($this->atype === "clear") {
             $autoassigner->run_clear($this->reviewtype);
         } else {
             if ($this->atype === "lead" || $this->atype === "shepherd") {
                 $autoassigner->run_paperpc($this->atype, $Qreq["{$this->atype}score"]);
             } else {
                 if ($this->atype === "revpc") {
                     $autoassigner->run_reviews_per_pc($this->reviewtype, $Qreq->rev_roundtag, cvtint($Qreq->revpcct));
                 } else {
                     if ($this->atype === "revadd") {
                         $autoassigner->run_more_reviews($this->reviewtype, $Qreq->rev_roundtag, cvtint($Qreq->revaddct));
                     } else {
                         if ($this->atype === "rev") {
                             $autoassigner->run_ensure_reviews($this->reviewtype, $Qreq->rev_roundtag, cvtint($Qreq->revct));
                         } else {
                             if ($this->atype === "discorder") {
                                 $autoassigner->run_discussion_order($this->discordertag);
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($this->live) {
         echo $this->result_html(), "</div>\n";
     } else {
         PaperList::$include_stash = false;
         $result_html = $this->result_html();
         echo Ht::take_stash(), '<script>$$("propass").innerHTML=', json_encode($result_html), ";</script>\n";
     }
     if ($this->autoassigner->assignments()) {
         $Conf->footer();
         exit;
     }
 }
 public function save($sv, $si)
 {
     global $Conf;
     // mark all used decisions
     $decs = $Conf->decision_map();
     $update = false;
     foreach ($sv->req as $k => $v) {
         if (str_starts_with($k, "dec") && ($k = cvtint(substr($k, 3), 0))) {
             if ($v == "") {
                 $Conf->qe("update Paper set outcome=0 where outcome={$k}");
                 unset($decs[$k]);
                 $update = true;
             } else {
                 if ($v != $decs[$k]) {
                     $decs[$k] = $v;
                     $update = true;
                 }
             }
         }
     }
     if (defval($sv->req, "decn", "") != "") {
         $delta = defval($sv->req, "dtypn", 1) > 0 ? 1 : -1;
         for ($k = $delta; isset($decs[$k]); $k += $delta) {
             /* skip */
         }
         $decs[$k] = $sv->req["decn"];
         $update = true;
     }
     if ($update) {
         $sv->save("outcome_map", json_encode($decs));
     }
 }
 function reviewRow($selector, &$whyNot = null)
 {
     $whyNot = array();
     if (!is_array($selector)) {
         $selector = array('reviewId' => $selector);
     }
     if (isset($selector['reviewId'])) {
         $whyNot['reviewId'] = $selector['reviewId'];
         if (($reviewId = cvtint($selector['reviewId'])) <= 0) {
             $whyNot['invalidId'] = 'review';
             return null;
         }
     }
     if (isset($selector['paperId'])) {
         $whyNot['paperId'] = $selector['paperId'];
         if (($paperId = cvtint($selector['paperId'])) <= 0) {
             $whyNot['invalidId'] = 'paper';
             return null;
         }
     }
     $q = "select PaperReview.*,\n                ContactInfo.firstName, ContactInfo.lastName, ContactInfo.email, ContactInfo.roles as contactRoles,\n                ContactInfo.contactTags,\n                ReqCI.firstName as reqFirstName, ReqCI.lastName as reqLastName, ReqCI.email as reqEmail";
     if (isset($selector["ratings"])) {
         $q .= ",\n                group_concat(ReviewRating.rating) as allRatings";
     }
     if (isset($selector["myRating"])) {
         $q .= ",\n                MyRating.rating as myRating";
     }
     $q .= "\n               from PaperReview\n                join ContactInfo using (contactId)\n                left join ContactInfo as ReqCI on (ReqCI.contactId=PaperReview.requestedBy)\n";
     if (isset($selector["ratings"])) {
         $q .= "             left join ReviewRating on (ReviewRating.reviewId=PaperReview.reviewId)\n";
     }
     if (isset($selector["myRating"])) {
         $q .= "             left join ReviewRating as MyRating on (MyRating.reviewId=PaperReview.reviewId and MyRating.contactId=" . $selector["myRating"] . ")\n";
     }
     $where = array();
     $order = array("paperId");
     if (isset($reviewId)) {
         $where[] = "PaperReview.reviewId={$reviewId}";
     }
     if (isset($paperId)) {
         $where[] = "PaperReview.paperId={$paperId}";
     }
     $cwhere = array();
     if (isset($selector["contactId"])) {
         $cwhere[] = "PaperReview.contactId=" . cvtint($selector["contactId"]);
     }
     if (get($selector, "rev_tokens")) {
         $cwhere[] = "PaperReview.reviewToken in (" . join(",", $selector["rev_tokens"]) . ")";
     }
     if (count($cwhere)) {
         $where[] = "(" . join(" or ", $cwhere) . ")";
     }
     if (count($cwhere) > 1) {
         $order[] = "(PaperReview.contactId=" . cvtint($selector["contactId"]) . ") desc";
     }
     if (isset($selector['reviewOrdinal'])) {
         $where[] = "PaperReview.reviewSubmitted>0 and reviewOrdinal=" . cvtint($selector['reviewOrdinal']);
     } else {
         if (isset($selector['submitted'])) {
             $where[] = "PaperReview.reviewSubmitted>0";
         }
     }
     if (!count($where)) {
         $whyNot['internal'] = 1;
         return null;
     }
     $q = $q . " where " . join(" and ", $where) . " group by PaperReview.reviewId\n                order by " . join(", ", $order) . ", reviewOrdinal, timeRequested, reviewType desc, reviewId";
     $result = $this->q($q);
     if (!$result) {
         $whyNot['dbError'] = "Database error while fetching review (" . htmlspecialchars($q) . "): " . htmlspecialchars($this->dblink->error);
         return null;
     }
     $x = array();
     while ($row = edb_orow($result)) {
         $x[] = $row;
     }
     Dbl::free($result);
     if (isset($selector["array"])) {
         return $x;
     } else {
         if (count($x) == 1 || count($x) > 1 && get($selector, "first")) {
             return $x[0];
         }
     }
     if (count($x) == 0) {
         $whyNot['noReview'] = 1;
     } else {
         $whyNot['multipleReviews'] = 1;
     }
     return null;
 }
    foreach ($qreq->papx as $p) {
        if (($p = cvtint($p)) > 0 && !isset($qreq->assrev[$p])) {
            $qreq->assrev[$p] = 0;
        }
    }
}
if (is_array($qreq->p) && $qreq->kind == "c") {
    foreach ($qreq->p as $p) {
        if (($p = cvtint($p)) > 0) {
            $qreq->assrev[$p] = -1;
        }
    }
}
$qreq->rev_roundtag = (string) $Conf->sanitize_round_name($qreq->rev_roundtag);
$pcm = pcMembers();
$reviewer = cvtint($qreq->reviewer);
if ($reviewer <= 0) {
    $reviewer = $Me->contactId;
}
if ($reviewer <= 0 || !isset($pcm[$reviewer])) {
    $reviewer = 0;
}
function saveAssignments($qreq, $reviewer)
{
    global $Conf, $Me, $Now, $pcm;
    $reviewer_contact = $pcm[$reviewer];
    $round_number = null;
    if (!count($qreq->assrev)) {
        return;
    }
    $result = Dbl::qe_raw($Conf->paperQuery($Me, array("paperId" => array_keys($qreq->assrev), "reviewer" => $reviewer)));
示例#19
0
        // send anticonfirmation email
        HotCRPMailer::send_to($Requester, "@denyreviewrequest", $prow, array("reviewer_contact" => (object) array("fullName" => trim(defval($_REQUEST, "name", "")), "email" => $email)));
        $Conf->confirmMsg("Proposed reviewer denied.");
    } else {
        Conf::msg_error("No one has proposed that " . htmlspecialchars($email) . " review this paper.");
    }
    Dbl::qx_raw("unlock tables");
    unset($_REQUEST["email"], $_GET["email"], $_POST["email"]);
    unset($_REQUEST["name"], $_GET["name"], $_POST["name"]);
}
// add primary or secondary reviewer
if (isset($_REQUEST["addpc"]) && $Me->allow_administer($prow) && check_post()) {
    if (($pcid = cvtint(@$_REQUEST["pcid"])) <= 0) {
        Conf::msg_error("Enter a PC member.");
    } else {
        if (($pctype = cvtint(@$_REQUEST["pctype"])) == REVIEW_PRIMARY || $pctype == REVIEW_SECONDARY || $pctype == REVIEW_PC) {
            $Me->assign_review($prow->paperId, $pcid, $pctype);
            $Conf->update_rev_tokens_setting(false);
        }
    }
    loadRows();
}
// paper table
$paperTable = new PaperTable($prow, make_qreq(), "assign");
$paperTable->initialize(false, false);
confHeader();
// begin form and table
$loginUrl = hoturl_post("assign", "p={$prow->paperId}");
$paperTable->paptabBegin();
// reviewer information
$proposals = null;
 public function parse($sv, $si)
 {
     global $Conf, $ConfSitePATH;
     if (!isset($sv->req["sub_banal"])) {
         $sv->save("sub_banal", 0);
         return false;
     }
     // check banal subsettings
     $old_error_count = $sv->error_count();
     $bs = array_fill(0, 6, "");
     if (($s = trim(defval($sv->req, "sub_banal_papersize", ""))) != "" && strcasecmp($s, "any") != 0 && strcasecmp($s, "N/A") != 0) {
         $ses = preg_split('/\\s*,\\s*|\\s+OR\\s+/i', $s);
         $sout = array();
         foreach ($ses as $ss) {
             if ($ss != "" && CheckFormat::parse_dimen($ss, 2)) {
                 $sout[] = $ss;
             } else {
                 if ($ss != "") {
                     $sv->set_error("sub_banal_papersize", "Invalid paper size.");
                     $sout = null;
                     break;
                 }
             }
         }
         if ($sout && count($sout)) {
             $bs[0] = join(" OR ", $sout);
         }
     }
     if (($s = trim(defval($sv->req, "sub_banal_pagelimit", ""))) != "" && strcasecmp($s, "N/A") != 0) {
         if (($sx = cvtint($s, -1)) > 0) {
             $bs[1] = $sx;
         } else {
             if (preg_match('/\\A(\\d+)\\s*-\\s*(\\d+)\\z/', $s, $m) && $m[1] > 0 && $m[2] > 0 && $m[1] <= $m[2]) {
                 $bs[1] = +$m[1] . "-" . +$m[2];
             } else {
                 $sv->set_error("sub_banal_pagelimit", "Page limit must be a whole number bigger than 0, or a page range such as <code>2-4</code>.");
             }
         }
     }
     if (($s = trim(defval($sv->req, "sub_banal_columns", ""))) != "" && strcasecmp($s, "any") != 0 && strcasecmp($s, "N/A") != 0) {
         if (($sx = cvtint($s, -1)) >= 0) {
             $bs[2] = $sx > 0 ? $sx : $bs[2];
         } else {
             $sv->set_error("sub_banal_columns", "Columns must be a whole number.");
         }
     }
     if (($s = trim(defval($sv->req, "sub_banal_textblock", ""))) != "" && strcasecmp($s, "any") != 0 && strcasecmp($s, "N/A") != 0) {
         // change margin specifications into text block measurements
         if (preg_match('/^(.*\\S)\\s+mar(gins?)?/i', $s, $m)) {
             $s = $m[1];
             if (!($ps = CheckFormat::parse_dimen($bs[0]))) {
                 $sv->set_error("sub_banal_pagesize", "You must specify a page size as well as margins.");
                 $sv->set_error("sub_banal_textblock");
             } else {
                 if (strpos($s, "x") !== false) {
                     if (!($m = CheckFormat::parse_dimen($s)) || !is_array($m) || count($m) > 4) {
                         $sv->set_error("sub_banal_textblock", "Invalid margin definition.");
                         $s = "";
                     } else {
                         if (count($m) == 2) {
                             $s = array($ps[0] - 2 * $m[0], $ps[1] - 2 * $m[1]);
                         } else {
                             if (count($m) == 3) {
                                 $s = array($ps[0] - 2 * $m[0], $ps[1] - $m[1] - $m[2]);
                             } else {
                                 $s = array($ps[0] - $m[0] - $m[2], $ps[1] - $m[1] - $m[3]);
                             }
                         }
                     }
                 } else {
                     $s = preg_replace('/\\s+/', 'x', $s);
                     if (!($m = CheckFormat::parse_dimen($s)) || is_array($m) && count($m) > 4) {
                         $sv->set_error("sub_banal_textblock", "Invalid margin definition.");
                     } else {
                         if (!is_array($m)) {
                             $s = array($ps[0] - 2 * $m, $ps[1] - 2 * $m);
                         } else {
                             if (count($m) == 2) {
                                 $s = array($ps[0] - 2 * $m[1], $ps[1] - 2 * $m[0]);
                             } else {
                                 if (count($m) == 3) {
                                     $s = array($ps[0] - 2 * $m[1], $ps[1] - $m[0] - $m[2]);
                                 } else {
                                     $s = array($ps[0] - $m[1] - $m[3], $ps[1] - $m[0] - $m[2]);
                                 }
                             }
                         }
                     }
                 }
             }
             $s = is_array($s) ? CheckFormat::unparse_dimen($s) : "";
         }
         // check text block measurements
         if ($s && !CheckFormat::parse_dimen($s, 2)) {
             $sv->set_error("sub_banal_textblock", "Invalid text block definition.");
         } else {
             if ($s) {
                 $bs[3] = $s;
             }
         }
     }
     if (($s = trim(defval($sv->req, "sub_banal_bodyfontsize", ""))) != "" && strcasecmp($s, "any") != 0 && strcasecmp($s, "N/A") != 0) {
         if (!is_numeric($s) || $s <= 0) {
             $sv->error("sub_banal_bodyfontsize", "Minimum body font size must be a number bigger than 0.");
         } else {
             $bs[4] = $s;
         }
     }
     if (($s = trim(defval($sv->req, "sub_banal_bodyleading", ""))) != "" && strcasecmp($s, "any") != 0 && strcasecmp($s, "N/A") != 0) {
         if (!is_numeric($s) || $s <= 0) {
             $sv->error("sub_banal_bodyleading", "Minimum body leading must be a number bigger than 0.");
         } else {
             $bs[5] = $s;
         }
     }
     if ($sv->error_count() != $old_error_count) {
         return false;
     }
     // Perhaps we have an old pdftohtml with a bad -zoom.
     $zoomarg = "";
     for ($tries = 0; $tries < 2; ++$tries) {
         $cf = new CheckFormat();
         $s1 = $cf->check_file("{$ConfSitePATH}/src/sample.pdf", "letter;2;;6.5inx9in;12;14" . $zoomarg);
         $e1 = $cf->errors;
         if ($s1 == 1 && $e1 & CheckFormat::ERR_PAPERSIZE && $tries == 0) {
             $zoomarg = ">-zoom=1";
         } else {
             if ($s1 != 2 && $tries == 1) {
                 $zoomarg = "";
             }
         }
     }
     // actually create setting
     while (count($bs) > 0 && $bs[count($bs) - 1] == "") {
         array_pop($bs);
     }
     $sv->save("sub_banal_data", join(";", $bs) . $zoomarg);
     $e1 = $cf->errors;
     $s2 = $cf->check_file("{$ConfSitePATH}/src/sample.pdf", "a4;1;;3inx3in;14;15" . $zoomarg);
     $e2 = $cf->errors;
     $want_e2 = CheckFormat::ERR_PAPERSIZE | CheckFormat::ERR_PAGELIMIT | CheckFormat::ERR_TEXTBLOCK | CheckFormat::ERR_BODYFONTSIZE | CheckFormat::ERR_BODYLEADING;
     if ($s1 != 2 || $e1 != 0 || $s2 != 1 || ($e2 & $want_e2) != $want_e2) {
         $errors = "<div class=\"fx\"><table><tr><td>Analysis:&nbsp;</td><td>{$s1} {$e1} {$s2} {$e2} (expected 2 0 1 {$want_e2})</td></tr>" . "<tr><td class=\"nw\">Exit status:&nbsp;</td><td>" . htmlspecialchars($cf->banal_status) . "</td></tr>";
         if (trim($cf->banal_stdout)) {
             $errors .= "<tr><td>Stdout:&nbsp;</td><td><pre class=\"email\">" . htmlspecialchars($cf->banal_stdout) . "</pre></td></tr>";
         }
         if (trim($cf->banal_stdout)) {
             if (trim($cf->banal_stderr)) {
                 $errors .= "<tr><td>Stderr:&nbsp;</td><td><pre class=\"email\">" . htmlspecialchars($cf->banal_stderr) . "</pre></td></tr>";
             }
         }
         $errors .= "<tr><td>Check:&nbsp;</td><td>" . join("<br />\n", array_map(function ($x) {
             return $x[1];
         }, $cf->msgs)) . "</td></tr>";
         $sv->set_warning(null, "Running the automated paper checker on a sample PDF file produced unexpected results. You should disable it for now. <div id=\"foldbanal_warning\" class=\"foldc\">" . foldbutton("banal_warning", 0, "Checker output") . $errors . "</table></div></div>");
     }
     return false;
 }
 public function parse($sv, $si)
 {
     global $Conf;
     $this->nrfj = (object) array();
     $option_error = "Review fields with options must have at least two choices, numbered sequentially from 1 (higher numbers are better) or lettered with consecutive uppercase letters (lower letters are better). Example: <pre>1. Low quality\n    2. Medium quality\n    3. High quality</pre>";
     $rf = ReviewForm::get();
     foreach ($rf->fmap as $fid => $f) {
         $fj = (object) array();
         $sn = simplify_whitespace(defval($sv->req, "shortName_{$fid}", ""));
         if ($sn == "<None>" || $sn == "<New field>" || $sn == "Field name") {
             $sn = "";
         }
         $pos = cvtint(get($sv->req, "order_{$fid}"));
         if ($pos > 0 && $sn == "" && trim(defval($sv->req, "description_{$fid}", "")) == "" && trim(defval($sv->req, "options_{$fid}", "")) == "") {
             $pos = -1;
         }
         if ($sn != "") {
             $fj->name = $sn;
         } else {
             if ($pos > 0) {
                 $sv->set_error("shortName_{$fid}", "Missing review field name.");
             }
         }
         $fj->visibility = get($sv->req, "authorView_{$fid}");
         $x = CleanHTML::basic_clean(defval($sv->req, "description_{$fid}", ""), $err);
         if ($x === false) {
             if (get($f, "description")) {
                 $fj->description = $f->description;
             }
             if ($pos > 0) {
                 $sv->set_error("description_{$fid}", htmlspecialchars($sn) . " description: " . $err);
             }
         } else {
             if (($x = trim($x)) != "") {
                 $fj->description = $x;
             }
         }
         if ($pos > 0) {
             $fj->position = $pos;
         }
         if ($f->has_options) {
             $fj->options = array_values($f->options);
             // default
             if (!$this->check_options($sv, $fid, $fj) && $pos > 0) {
                 $sv->set_error("options_{$fid}", "Invalid options.");
                 if ($option_error) {
                     $sv->set_error(null, $option_error);
                 }
                 $option_error = false;
             }
             $prefixes = array("sv", "svr", "sv-blpu", "sv-publ", "sv-viridis", "sv-viridisr");
             $class_prefix = defval($sv->req, "option_class_prefix_{$fid}", "sv");
             $prefix_index = array_search($class_prefix, $prefixes) ?: 0;
             if (get($sv->req, "option_class_prefix_flipped_{$fid}")) {
                 $prefix_index ^= 1;
             }
             $fj->option_class_prefix = $prefixes[$prefix_index];
         }
         $fj->round_mask = 0;
         if ($rlist = get($sv->req, "round_list_{$fid}")) {
             foreach (explode(" ", trim($rlist)) as $round_name) {
                 $fj->round_mask |= 1 << $Conf->round_number($round_name, false);
             }
         }
         $xf = clone $f;
         $xf->assign($fj);
         $this->nrfj->{$fid} = $xf->unparse_json();
     }
     $sv->need_lock["PaperReview"] = true;
     return true;
 }
示例#22
0
    if (!$Info->commit()) {
        quit("No commit to run");
    } else {
        if (!isset($_REQUEST["run"]) || !check_post()) {
            quit("Permission error");
        } else {
            if (!$Info->can_view_repo_contents && !$Me->isPC) {
                quit("Unconfirmed repository");
            }
        }
    }
}
// extract request info
$Queueid = cvtint(defval($_REQUEST, "queueid", -1));
$checkt = cvtint(defval($_REQUEST, "check"));
$Offset = cvtint(defval($_REQUEST, "offset", -1));
// maybe eval
function runner_eval($runner, $info, $answer)
{
    global $ConfSitePATH;
    if (isset($runner->load) && $runner->load[0] == "/") {
        require_once $runner->load;
    } else {
        if (isset($runner->load)) {
            require_once $ConfSitePATH . "/" . $runner->load;
        }
    }
    $answer->result = call_user_func($runner->eval, $info);
}
// checkup
if ($checkt > 0 && ($answer = ContactView::runner_json($Info, $checkt, $Offset))) {
示例#23
0
if (isset($_REQUEST["pap"]) && is_string($_REQUEST["pap"])) {
    $_REQUEST["pap"] = preg_split('/\\s+/', $_REQUEST["pap"]);
}
if (isset($_REQUEST["pap"]) && is_array($_REQUEST["pap"]) || $getaction && !isset($_REQUEST["pap"])) {
    $allowed_papers = array();
    $pl = new ContactList($Me, true);
    // Ensure that we only select contacts we're allowed to see.
    if ($rows = $pl->rows($_REQUEST["t"])) {
        foreach ($rows as $row) {
            $allowed_papers[$row->contactId] = true;
        }
    }
    $papersel = array();
    if (isset($_REQUEST["pap"])) {
        foreach ($_REQUEST["pap"] as $p) {
            if (($p = cvtint($p)) > 0 && isset($allowed_papers[$p])) {
                $papersel[] = $p;
            }
        }
    } else {
        $papersel = array_keys($allowed_papers);
    }
    if (count($papersel) == 0) {
        unset($papersel);
    }
}
if ($getaction == "nameemail" && isset($papersel) && $Me->isPC) {
    $result = $Conf->qe("select firstName first, lastName last, email, affiliation from ContactInfo where " . paperselPredicate($papersel) . " order by lastName, firstName, email");
    $people = edb_orows($result);
    downloadCSV($people, array("first", "last", "email", "affiliation"), "users", array("selection" => true));
}
示例#24
0
// validation because MailRecipients filters internally
if (isset($_REQUEST["prevt"]) && isset($_REQUEST["prevq"])) {
    if (!isset($_REQUEST["plimit"])) {
        unset($_REQUEST["p"]);
    } else {
        if (($_REQUEST["prevt"] !== $_REQUEST["t"] || $_REQUEST["prevq"] !== $_REQUEST["q"]) && !isset($_REQUEST["psearch"])) {
            $Conf->warnMsg("You changed the paper search. Please review the paper list.");
            $_REQUEST["psearch"] = true;
        }
    }
}
$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"] = "";
    }
}
示例#25
0
 function parseTextForm(&$tf)
 {
     $text = $tf['text'];
     $lineno = $tf['lineno'];
     $tf['firstLineno'] = $lineno + 1;
     $tf['fieldLineno'] = array();
     $req = array();
     if (isset($_REQUEST["override"])) {
         $req["override"] = $_REQUEST["override"];
     }
     $mode = 0;
     $nfields = 0;
     $field = 0;
     $anyDirectives = 0;
     while ($text != "") {
         $pos = strpos($text, "\n");
         $line = $pos === FALSE ? $text : substr($text, 0, $pos + 1);
         $lineno++;
         if (substr($line, 0, 6) == "==+== ") {
             // make sure we record that we saw the last field
             if ($mode && $field != null && !isset($req[$field])) {
                 $req[$field] = "";
             }
             $anyDirectives++;
             if (preg_match('{\\A==\\+==\\s+(.*?)\\s+(Paper Review(?: Form)?s?)\\s*\\z}', $line, $m) && $m[1] != Conf::$gShortName) {
                 $this->garbageMessage($tf, $lineno, $garbage);
                 self::tfError($tf, true, "Ignoring review form, which appears to be for a different conference.<br />(If this message is in error, replace the line that reads “<code>" . htmlspecialchars(rtrim($line)) . "</code>” with “<code>==+== " . htmlspecialchars(Conf::$gShortName) . " " . $m[2] . "</code>” and upload again.)", $lineno);
                 return null;
             } else {
                 if (preg_match('/^==\\+== Begin Review/i', $line)) {
                     if ($nfields > 0) {
                         break;
                     }
                 } else {
                     if (preg_match('/^==\\+== Paper #?(\\d+)/i', $line, $match)) {
                         if ($nfields > 0) {
                             break;
                         }
                         $req['paperId'] = $tf['paperId'] = $match[1];
                         $req['blind'] = 1;
                         $tf['firstLineno'] = $lineno;
                     } else {
                         if (preg_match('/^==\\+== Reviewer:\\s*(.*)\\s*<(\\S+?)>/', $line, $match)) {
                             $tf["fieldLineno"]["reviewerEmail"] = $lineno;
                             $req["reviewerName"] = $match[1];
                             $req["reviewerEmail"] = $match[2];
                         } else {
                             if (preg_match('/^==\\+== Paper (Number|\\#)\\s*$/i', $line)) {
                                 if ($nfields > 0) {
                                     break;
                                 }
                                 $field = "paperNumber";
                                 $tf["fieldLineno"][$field] = $lineno;
                                 $mode = 1;
                                 $req['blind'] = 1;
                                 $tf['firstLineno'] = $lineno;
                             } else {
                                 if (preg_match('/^==\\+== Submit Review\\s*$/i', $line) || preg_match('/^==\\+== Review Ready\\s*$/i', $line)) {
                                     $req['ready'] = true;
                                 } else {
                                     if (preg_match('/^==\\+== Open Review\\s*$/i', $line)) {
                                         $req['blind'] = 0;
                                     } else {
                                         if (preg_match('/^==\\+== Version\\s*(\\d+)$/i', $line, $match)) {
                                             if (defval($req, "version", 0) < $match[1]) {
                                                 $req['version'] = $match[1];
                                             }
                                         } else {
                                             if (preg_match('/^==\\+== Review Readiness\\s*/i', $line)) {
                                                 $field = "readiness";
                                                 $mode = 1;
                                             } else {
                                                 if (preg_match('/^==\\+== Review Anonymity\\s*/i', $line)) {
                                                     $field = "anonymity";
                                                     $mode = 1;
                                                 } else {
                                                     if (preg_match('/^==\\+== Review Format\\s*/i', $line)) {
                                                         $field = "reviewFormat";
                                                         $mode = 1;
                                                     } else {
                                                         if (preg_match('/^==\\+== [A-Z]\\.\\s*(.*?)\\s*$/', $line, $match)) {
                                                             $fname = $match[1];
                                                             if (!isset($this->fieldName[strtolower($fname)])) {
                                                                 $fname = preg_replace('/\\s*\\((hidden from authors|PC only|shown only to chairs|secret)\\)\\z/', "", $fname);
                                                             }
                                                             $fn =& $this->fieldName[strtolower($fname)];
                                                             if (isset($fn)) {
                                                                 $field = $fn;
                                                                 $tf['fieldLineno'][$fn] = $lineno;
                                                                 $nfields++;
                                                             } else {
                                                                 $this->garbageMessage($tf, $lineno, $garbage);
                                                                 self::tfError($tf, true, "Review field &ldquo;" . htmlentities($fname) . "&rdquo; is not used for " . htmlspecialchars(Conf::$gShortName) . " reviews.  Ignoring this section.", $lineno);
                                                                 $field = null;
                                                             }
                                                             $mode = 1;
                                                         } else {
                                                             $field = null;
                                                             $mode = 1;
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         } else {
             if ($mode < 2 && (substr($line, 0, 5) == "==-==" || ltrim($line) == "")) {
                 /* ignore line */
             } else {
                 if ($mode == 0) {
                     $garbage = $line;
                     $field = null;
                 }
                 if ($field != null) {
                     $req[$field] = defval($req, $field, "") . $line;
                 }
                 $mode = 2;
             }
         }
         $text = substr($text, strlen($line));
     }
     if ($nfields == 0 && $tf['firstLineno'] == 1) {
         self::tfError($tf, true, "That didn&rsquo;t appear to be a review form; I was not able to extract any information from it.  Please check its formatting and try again.", $lineno);
     }
     $tf['text'] = $text;
     $tf['lineno'] = $lineno - 1;
     if (isset($req["readiness"])) {
         $req["ready"] = strcasecmp(trim($req["readiness"]), "Ready") == 0;
     }
     if (isset($req["anonymity"])) {
         $req["blind"] = strcasecmp(trim($req["anonymity"]), "Open") != 0;
     }
     if (isset($req["reviewFormat"])) {
         $req["reviewFormat"] = trim($req["reviewFormat"]);
     }
     if (isset($req["paperId"])) {
         /* OK */
     } else {
         if (isset($req["paperNumber"]) && ($pid = cvtint(trim($req["paperNumber"]), -1)) > 0) {
             $req["paperId"] = $tf["paperId"] = $pid;
         } else {
             if ($nfields > 0) {
                 self::tfError($tf, true, "This review form doesn’t report which paper number it is for.  Make sure you’ve entered the paper number in the right place and try again.", defval($tf["fieldLineno"], "paperNumber", $lineno));
                 $nfields = 0;
             }
         }
     }
     if ($nfields == 0 && $text) {
         // try again
         return $this->parseTextForm($tf);
     } else {
         if ($nfields == 0) {
             return null;
         } else {
             return $req;
         }
     }
 }
示例#26
0
 public static function requested()
 {
     global $Me;
     if (self::$requested_list === false) {
         // look up list ID
         $listdesc = req("ls");
         if (isset($_COOKIE["hotcrp_ls"])) {
             $listdesc = $listdesc ?: $_COOKIE["hotcrp_ls"];
         }
         $list = null;
         if (($listno = cvtint($listdesc, null)) && ($xlist = self::lookup($listno)) && (!get($xlist, "cid") || $xlist->cid == ($Me ? $Me->contactId : 0))) {
             $list = $xlist;
         }
         // look up list description
         if (!$list && $listdesc) {
             $listtype = "p";
             if (Navigation::page() === "profile" || Navigation::page() === "users") {
                 $listtype = "u";
             }
             if (preg_match('_\\Ap/([^/]*)/([^/]*)/?(.*)\\z_', $listdesc, $m)) {
                 $list = self::try_list(["t" => $m[1], "q" => urldecode($m[2])], "p", $m[3]);
             }
             if (!$list && preg_match('/\\A(all|s):(.*)\\z/s', $listdesc, $m)) {
                 $list = self::try_list(["t" => $m[1], "q" => $m[2]], "p");
             }
             if (!$list && preg_match('/\\A[a-z]+\\z/', $listdesc)) {
                 $list = self::try_list(["t" => $listdesc], $listtype);
             }
             if (!$list) {
                 $list = self::try_list(["q" => $listdesc], $listtype);
             }
         }
         self::$requested_list = $list;
     }
     return self::$requested_list;
 }
 public function apply(Contact $user, $pj, $opj, $qreq, $action)
 {
     global $Conf;
     // Title, abstract, collaborators
     foreach (array("title", "abstract", "collaborators") as $k) {
         if (isset($qreq[$k])) {
             $pj->{$k} = $qreq[$k];
         }
     }
     // Authors
     $bad_author = ["name" => "Name", "email" => "Email", "aff" => "Affiliation"];
     $authors = array();
     foreach ($qreq as $k => $v) {
         if (preg_match('/\\Aau(name|email|aff)(\\d+)\\z/', $k, $m) && ($v = simplify_whitespace($v)) !== "" && $v !== $bad_author[$m[1]]) {
             $au = $authors[$m[2]] = get($authors, $m[2]) ?: (object) array();
             $x = $m[1] == "aff" ? "affiliation" : $m[1];
             $au->{$x} = $v;
         }
     }
     if (!empty($authors)) {
         ksort($authors, SORT_NUMERIC);
         $pj->authors = array_values($authors);
     }
     // Contacts
     if ($qreq->setcontacts || $qreq->has_contacts) {
         PaperSaver::replace_contacts($pj, $qreq);
     } else {
         if (!$opj) {
             $pj->contacts = array($user);
         }
     }
     // Status
     if ($action === "submit") {
         $pj->submitted = true;
     } else {
         if ($action === "final") {
             $pj->final_submitted = true;
         } else {
             $pj->submitted = false;
         }
     }
     // Paper upload
     if ($qreq->_FILES->paperUpload) {
         if ($action === "final") {
             $pj->final = Filer::file_upload_json($qreq->_FILES->paperUpload);
         } else {
             if ($action === "update" || $action === "submit") {
                 $pj->submission = Filer::file_upload_json($qreq->_FILES->paperUpload);
             }
         }
     }
     // Blindness
     if ($action !== "final" && $Conf->subBlindOptional()) {
         $pj->nonblind = !$qreq->blind;
     }
     // Topics
     if ($qreq->has_topics) {
         $pj->topics = (object) array();
         foreach ($Conf->topic_map() as $tid => $tname) {
             if (+$qreq["top{$tid}"] > 0) {
                 $pj->topics->{$tname} = true;
             }
         }
     }
     // Options
     if (!isset($pj->options)) {
         $pj->options = (object) [];
     }
     foreach (PaperOption::option_list() as $o) {
         if ($qreq["has_opt{$o->id}"] && (!$o->final || $action === "final")) {
             $okey = $o->abbr;
             $pj->options->{$okey} = $o->parse_request(get($pj->options, $okey), $qreq, $user, $pj);
         }
     }
     if (!count(get_object_vars($pj->options))) {
         unset($pj->options);
     }
     // PC conflicts
     if ($Conf->setting("sub_pcconf") && ($action !== "final" || $user->privChair) && $qreq->has_pcconf) {
         $cmax = $user->privChair ? CONFLICT_CHAIRMARK : CONFLICT_MAXAUTHORMARK;
         $pj->pc_conflicts = (object) array();
         foreach (pcMembers() as $pcid => $pc) {
             $ctype = cvtint($qreq["pcc{$pcid}"], 0);
             $ctype = max(min($ctype, $cmax), 0);
             if ($ctype) {
                 $email = $pc->email;
                 $pj->pc_conflicts->{$email} = Conflict::$type_names[$ctype];
             }
         }
     }
 }