$Conf->ajaxExit(array("status" => $status), true);
    }
}
// withdraw and revive actions
if (isset($_REQUEST["withdraw"]) && !$newPaper && check_post()) {
    if (!($whyNot = $Me->perm_withdraw_paper($prow))) {
        $reason = defval($_REQUEST, "reason", "");
        if ($reason == "" && $Me->privChair && defval($_REQUEST, "doemail") > 0) {
            $reason = defval($_REQUEST, "emailNote", "");
        }
        Dbl::qe("update Paper set timeWithdrawn={$Now}, timeSubmitted=if(timeSubmitted>0,-100,0), withdrawReason=? where paperId={$prow->paperId}", $reason != "" ? $reason : null);
        $numreviews = Dbl::fetch_ivalue("select count(*) from PaperReview where paperId={$prow->paperId} and reviewNeedsSubmit!=0");
        $Conf->update_papersub_setting(false);
        loadRows();
        // email contact authors themselves
        if (!$Me->privChair || defval($_REQUEST, "doemail") > 0) {
            HotCRPMailer::send_contacts($prow->conflictType >= CONFLICT_AUTHOR ? "@authorwithdraw" : "@adminwithdraw", $prow, array("reason" => $reason, "infoNames" => 1));
        }
        // email reviewers
        if ($numreviews > 0 && $Conf->time_review_open() || $prow->num_reviews_assigned() > 0) {
            HotCRPMailer::send_reviewers("@withdrawreviewer", $prow, array("reason" => $reason));
        }
        // remove voting tags so people don't have phantom votes
        if (TagInfo::has_vote()) {
            $q = array();
            foreach (TagInfo::vote_tags() as $t => $v) {
                $q[] = "tag='" . sqlq($t) . "' or tag like '%~" . sqlq_for_like($t) . "'";
            }
            Dbl::qe_raw("delete from PaperTag where paperId={$prow->paperId} and (" . join(" or ", $q) . ")");
        }
        $Me->log_activity("Withdrew", $prow->paperId);
function loadRows()
{
    global $Conf, $Me, $prow, $paperTable, $crow, $Error;
    $Conf->paper = $prow = PaperTable::paperRow($whyNot);
    if (!$prow) {
        exit_to_paper();
    }
    $paperTable = new PaperTable($prow, make_qreq());
    $paperTable->resolveReview(false);
    $paperTable->resolveComments();
    $cid = defval($_REQUEST, "commentId", "xxx");
    $crow = null;
    foreach ($paperTable->crows as $row) {
        if ($row->commentId == $cid || $cid == "response" && $row->commentType & COMMENTTYPE_RESPONSE) {
            $crow = $row;
        }
    }
    if (!$crow && $cid != "xxx" && $cid != "new" && $cid != "response" && $cid != "newresponse") {
        Conf::msg_error("No such comment.");
        $Conf->ajaxExit(array("ok" => false));
    }
    if (isset($Error["paperId"]) && $Error["paperId"] != $prow->paperId) {
        $Error = array();
    }
}
Beispiel #3
0
function ensure_session()
{
    global $Opt;
    if (session_id() !== "") {
        return true;
    }
    if (!($sn = make_session_name(@$Opt["sessionName"]))) {
        return false;
    }
    // maybe upgrade from an old session name to this one
    if (!isset($_COOKIE[$sn]) && isset($Opt["sessionUpgrade"]) && ($upgrade_sn = make_session_name($Opt["sessionUpgrade"])) && isset($_COOKIE[$upgrade_sn])) {
        session_id($_COOKIE[$upgrade_sn]);
        setcookie($upgrade_sn, "", time() - 3600, "/", defval($Opt, "sessionUpgradeDomain", defval($Opt, "sessionDomain", "")), defval($Opt, "sessionSecure", false));
    }
    if (isset($Opt["sessionSecure"]) || isset($Opt["sessionDomain"])) {
        $params = session_get_cookie_params();
        if (isset($Opt["sessionSecure"])) {
            $params["secure"] = !!$Opt["sessionSecure"];
        }
        if (isset($Opt["sessionDomain"])) {
            $params["domain"] = $Opt["sessionDomain"];
        }
        session_set_cookie_params($params["lifetime"], $params["path"], $params["domain"], $params["secure"]);
    }
    session_name($sn);
    session_cache_limiter("");
    if (isset($_COOKIE[$sn]) && !preg_match(';\\A[-a-zA-Z0-9,]{1,128}\\z;', $_COOKIE[$sn])) {
        error_log("unexpected session ID <" . $_COOKIE[$sn] . ">");
        unset($_COOKIE[$sn]);
    }
    session_start();
    return true;
}
 public static function default_score_sort($nosession = false)
 {
     global $Conf, $Opt;
     if (!$nosession && $Conf && ($sv = $Conf->session("scoresort"))) {
         return $sv;
     } else {
         if ($Conf && ($s = $Conf->setting_data("scoresort_default"))) {
             return $s;
         } else {
             return defval($Opt, "defaultScoreSort", "C");
         }
     }
 }
 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));
     }
 }
 public function create($capabilityType, $options = array())
 {
     global $Opt;
     $contactId = defval($options, "contactId", 0);
     if (!$contactId && ($user = @$options["user"])) {
         $contactId = $this->prefix === "U" ? $user->contactDbId : $user->contactId;
     }
     $paperId = defval($options, "paperId", 0);
     $timeExpires = defval($options, "timeExpires", time() + 259200);
     $data = defval($options, "data");
     $capid = false;
     for ($tries = 0; !$capid && $tries < 4; ++$tries) {
         if (($salt = hotcrp_random_bytes(16)) !== false) {
             Dbl::ql($this->dblink, "insert into Capability set capabilityType={$capabilityType}, contactId=?, paperId=?, timeExpires=?, salt=?, data=?", $contactId, $paperId, $timeExpires, $salt, $data);
             $capid = $this->dblink->insert_id;
         }
     }
     if (!$capid) {
         return false;
     }
     return $this->prefix . "1" . str_replace(array("+", "/", "="), array("-a", "-b", ""), base64_encode($salt));
 }
    header("Content-Type: text/plain");
} else {
    header("Content-Type: application/json");
}
if ($Me->privChair && isset($_REQUEST["ignore"])) {
    $when = time() + 86400 * 2;
    $Conf->qe("insert into Settings (name, value) values ('ignoreupdate_" . sqlq($_REQUEST["ignore"]) . "', {$when}) on duplicate key update value={$when}");
}
$messages = array();
if ($Me->privChair && isset($_REQUEST["data"]) && ($data = json_decode($_REQUEST["data"], true)) && isset($data["updates"]) && is_array($data["updates"])) {
    foreach ($data["updates"] as $update) {
        $ok = true;
        if (isset($update["opt"]) && is_array($update["opt"])) {
            foreach ($update["opt"] as $k => $v) {
                $kk = $k[0] == "-" ? substr($k, 1) : $k;
                $test = defval($Opt, $kk, null) == $v;
                $ok = $ok && ($k[0] == "-" ? !$test : $test);
            }
        }
        if (isset($update["settings"]) && is_array($update["settings"])) {
            foreach ($update["settings"] as $k => $v) {
                if (preg_match('/\\A([!<>]?)(-?\\d+|now)\\z/', $v, $m)) {
                    $setting = $Conf->setting($k, 0);
                    if ($m[2] == "now") {
                        $m[2] = time();
                    }
                    if ($m[1] == "!") {
                        $test = $setting != +$m[2];
                    } else {
                        if ($m[1] == ">") {
                            $test = $setting > +$m[2];
} else {
    echo "<h2 style='margin-top:1em'>Assignments by PC member</h2>\n";
}
// Change PC member
echo "<table><tr><td><div class='aahc assignpc_pcsel'>", Ht::form_div(hoturl("manualassign"), array("method" => "get", "id" => "selectreviewerform"));
$result = $Conf->qe("select ContactInfo.contactId, count(reviewId)\n                from ContactInfo\n                left join PaperReview on (PaperReview.contactId=ContactInfo.contactId and PaperReview.reviewType>=" . REVIEW_SECONDARY . ")\n                where (roles&" . Contact::ROLE_PC . ")!=0\n                group by ContactInfo.contactId");
$rev_count = array();
while ($row = edb_row($result)) {
    $rev_count[$row[0]] = $row[1];
}
$rev_opt = array();
if ($reviewer <= 0) {
    $rev_opt[0] = "(Select a PC member)";
}
foreach ($pcm as $pc) {
    $rev_opt[$pc->contactId] = Text::name_html($pc) . " (" . plural(defval($rev_count, $pc->contactId, 0), "assignment") . ")";
}
echo "<table><tr><td><strong>PC member:</strong> &nbsp;</td>", "<td>", Ht::select("reviewer", $rev_opt, $reviewer, array("onchange" => "hiliter(this)")), "</td></tr>", "<tr><td colspan='2'><div class='g'></div></td></tr>\n";
// Paper selection
$q = $qreq->q == "" ? "(All)" : $qreq->q;
echo "<tr><td>Paper selection: &nbsp;</td><td>", Ht::entry_h("q", $q, array("id" => "manualassignq", "size" => 40, "placeholder" => "(All)", "title" => "Paper numbers or search terms")), " &nbsp;in &nbsp;";
if (count($tOpt) > 1) {
    echo Ht::select("t", $tOpt, $qreq->t, array("onchange" => "hiliter(this)"));
} else {
    echo join("", $tOpt);
}
echo "</td></tr>\n", "<tr><td colspan='2'><div class='g'></div>\n";
echo Ht::radio("kind", "a", $qreq->kind == "a", array("onchange" => "hiliter(this)")), "&nbsp;", Ht::label("Assign reviews and/or conflicts"), "<br />\n", Ht::radio("kind", "c", $qreq->kind == "c", array("onchange" => "hiliter(this)")), "&nbsp;", Ht::label("Assign conflicts only (and limit papers to potential conflicts)"), "</td></tr>\n";
echo "<tr><td colspan='2'><div class='aax' style='text-align:right'>", Ht::submit("Go", array("class" => "bb")), "</div></td></tr>\n", "</table>\n</div></form></div></td></tr></table>\n";
function make_match_preg($str)
{
function web_request_as_json($cj)
{
    global $Conf, $Me, $Acct, $newProfile, $UserStatus;
    if ($newProfile || !$Acct->has_database_account()) {
        $cj->id = "new";
    } else {
        $cj->id = $Acct->contactId;
    }
    if (!Contact::external_login()) {
        $cj->email = trim(defval($_REQUEST, "uemail", ""));
    } else {
        if ($newProfile) {
            $cj->email = trim(defval($_REQUEST, "newUsername", ""));
        } else {
            $cj->email = $Acct->email;
        }
    }
    foreach (array("firstName", "lastName", "preferredEmail", "affiliation", "collaborators", "addressLine1", "addressLine2", "city", "state", "zipCode", "country", "voicePhoneNumber") as $k) {
        if (isset($_REQUEST[$k])) {
            $cj->{$k} = $_REQUEST[$k];
        }
    }
    if (!Contact::external_login() && !$newProfile && $Me->can_change_password($Acct)) {
        if (@$_REQUEST["whichpassword"] === "t" && @$_REQUEST["upasswordt"]) {
            $pw = $pw2 = @trim($_REQUEST["upasswordt"]);
        } else {
            $pw = @trim($_REQUEST["upassword"]);
            $pw2 = @trim($_REQUEST["upassword2"]);
        }
        if ($pw === "" && $pw2 === "") {
            /* do nothing */
        } else {
            if ($pw !== $pw2) {
                $UserStatus->set_error("password", "Those passwords do not match.");
            } else {
                if (!Contact::valid_password($pw)) {
                    $UserStatus->set_error("password", "Invalid new password.");
                } else {
                    if (!$Acct || $Me->can_change_password(null)) {
                        $cj->old_password = null;
                        $cj->new_password = $pw;
                    } else {
                        $cj->old_password = @trim($_REQUEST["oldpassword"]);
                        if ($Acct->check_password($cj->old_password)) {
                            $cj->new_password = $pw;
                        } else {
                            $UserStatus->set_error("password", "Incorrect current password. New password ignored.");
                        }
                    }
                }
            }
        }
    }
}
Beispiel #10
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();
    }
}
Beispiel #11
0
if (count($notelinks)) {
    ContactView::echo_group("notes", join(", ", $notelinks));
}
// check for any linenotes
$has_any_linenotes = false;
foreach ($diff as $file => $dinfo) {
    if (defval($all_linenotes, $file, null)) {
        $has_any_linenotes = true;
        break;
    }
}
// line notes
foreach ($diff as $file => $dinfo) {
    $fileid = html_id_encode($file);
    $tabid = "file61_" . $fileid;
    $linenotes = defval($all_linenotes, $file, null);
    $display_table = $linenotes || !$dinfo->boring;
    echo '<h3><a class="fold61" href="#" onclick="return fold61(', "'#{$tabid}'", ',this)"><span class="foldarrow">', $display_table ? "&#x25BC;" : "&#x25B6;", "</span>&nbsp;", htmlspecialchars($file), "</a>";
    if (!$dinfo->removed) {
        echo '<a style="display:inline-block;margin-left:2em;font-weight:normal" href="', $Info->hoturl("raw", array("file" => $file)), '">[Raw]</a>';
    }
    echo '</h3>';
    echo '<table id="', $tabid, '" class="code61 diff61 filediff61';
    if ($Me != $User) {
        echo ' live';
    }
    if (!$Info->user_can_see_grades) {
        echo " hidegrade61";
    }
    if (!$display_table) {
        echo '" style="display:none';
 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;
 }
Beispiel #13
0
 static function send_preparation($prep)
 {
     global $Conf, $Opt;
     if (!isset($Opt["internalMailer"])) {
         $Opt["internalMailer"] = strncasecmp(PHP_OS, "WIN", 3) != 0;
     }
     $headers = $prep->headers;
     // create valid To: header
     $to = $prep->to;
     if (is_array($to)) {
         $to = join(", ", $to);
     }
     $to = MimeText::encode_email_header("To: ", $to);
     $headers["to"] = $to . MAILER_EOL;
     // set sendmail parameters
     $extra = defval($Opt, "sendmailParam", "");
     if (isset($Opt["emailSender"])) {
         @ini_set("sendmail_from", $Opt["emailSender"]);
         if (!isset($Opt["sendmailParam"])) {
             $extra = "-f" . escapeshellarg($Opt["emailSender"]);
         }
     }
     if ($prep->sendable && $Opt["internalMailer"] && ($sendmail = ini_get("sendmail_path"))) {
         $htext = join("", $headers);
         $f = popen($extra ? "{$sendmail} {$extra}" : $sendmail, "wb");
         fwrite($f, $htext . MAILER_EOL . $prep->body);
         $status = pclose($f);
         if (pcntl_wifexited($status) && pcntl_wexitstatus($status) == 0) {
             return true;
         } else {
             $Opt["internalMailer"] = false;
             error_log("Mail " . $headers["to"] . " failed to send, falling back (status {$status})");
         }
     }
     if ($prep->sendable) {
         if (strpos($to, MAILER_EOL) === false) {
             unset($headers["to"]);
             $to = substr($to, 4);
             // skip "To: "
         } else {
             $to = "";
         }
         unset($headers["subject"]);
         $htext = substr(join("", $headers), 0, -2);
         return mail($to, $prep->subject, $prep->body, $htext, $extra);
     } else {
         if (!$Opt["sendEmail"] && !preg_match('/\\Aanonymous\\d*\\z/', $to)) {
             unset($headers["mime-version"], $headers["content-type"]);
             $text = join("", $headers) . MAILER_EOL . $prep->body;
             if (PHP_SAPI == "cli" && !@$Opt["disablePrintEmail"]) {
                 fwrite(STDERR, "========================================\n" . str_replace("\r\n", "\n", $text) . "========================================\n");
             } else {
                 $Conf->infoMsg("<pre>" . htmlspecialchars($text) . "</pre>");
             }
             return null;
         }
     }
 }
                echo '<div class="g"></div>', '<div class="aahc"><div class="aa">', Ht::submit("Apply changes"), ' &nbsp;', Ht::submit("cancel", "Cancel"), Ht::hidden("default_action", $defaults["action"]), Ht::hidden("rev_roundtag", $defaults["round"]), Ht::hidden("file", $text), Ht::hidden("assignment_size_estimate", $csv_lineno), Ht::hidden("filename", $filename), Ht::hidden("requestreview_notify", req("requestreview_notify")), Ht::hidden("requestreview_subject", req("requestreview_subject")), Ht::hidden("requestreview_body", req("requestreview_body")), Ht::hidden("bulkentry", req("bulkentry")), '</div></div></div></form>', "\n";
                $Conf->footer();
                exit;
            }
        }
    }
}
if (isset($_REQUEST["saveassignment"]) && check_post() && isset($_POST["file"]) && get($_POST, "assignment_size_estimate") >= 1000) {
    complete_assignment("keep_browser_alive");
    finish_browser_alive();
}
echo Ht::form_div(hoturl_post("bulkassign", "upload=1"), array("divstyle" => "margin-top:1em"));
// Upload
echo '<div class="f-contain"><div class="f-i"><div class="f-e">', Ht::textarea("bulkentry", req_s("bulkentry"), ["rows" => 1, "cols" => 80, "placeholder" => "Enter assignments"]), '</div></div></div>';
echo '<div class="g"><strong>OR</strong> &nbsp;', '<input type="file" name="bulk" accept="text/plain,text/csv" size="30" /></div>';
echo '<div id="foldoptions" class="lg foldc fold2o">', 'By default, assign&nbsp; ', Ht::select("default_action", array("primary" => "primary reviews", "secondary" => "secondary reviews", "pcreview" => "optional PC reviews", "review" => "external reviews", "conflict" => "PC conflicts", "lead" => "discussion leads", "shepherd" => "shepherds", "tag" => "add tags", "settag" => "replace tags", "preference" => "reviewer preferences"), defval($_REQUEST, "default_action", "primary"), array("id" => "tsel", "onchange" => "fold(\"options\",this.value!=\"review\");fold(\"options\",!/^(?:primary|secondary|(?:pc)?review)\$/.test(this.value),2)"));
$rev_rounds = $Conf->round_selector_options();
if (count($rev_rounds) > 1) {
    echo '<span class="fx2">&nbsp; in round &nbsp;', Ht::select("rev_roundtag", $rev_rounds, $_REQUEST["rev_roundtag"] ?: "unnamed"), '</span>';
} else {
    if (!get($rev_rounds, "unnamed")) {
        echo '<span class="fx2">&nbsp; in round ', $Conf->current_round_name(), '</span>';
    }
}
echo '<div class="g"></div>', "\n";
$requestreview_template = $null_mailer->expand_template("requestreview");
echo Ht::hidden("requestreview_subject", $requestreview_template["subject"]);
if (isset($_REQUEST["requestreview_body"])) {
    $t = $_REQUEST["requestreview_body"];
} else {
    $t = $requestreview_template["body"];
Beispiel #15
0
$User = null;
if (isset($_REQUEST["u"]) && !($User = ContactView::prepare_user($_REQUEST["u"]))) {
    redirectSelf(array("u" => null));
}
if (!$Me->isPC || !$User) {
    $User = $Me;
}
// check problem set openness
$max_pset = $Conf->setting("pset_forwarded");
foreach (Pset::$all as $pset) {
    if (Contact::student_can_see_pset($pset) && $pset->id > $max_pset && !$pset->gitless) {
        Contact::forward_pset_links($pset->id);
    }
}
if (!$Me->is_empty() && ($Me === $User || $Me->isPC) && isset($_REQUEST["set_seascode_username"]) && check_post()) {
    if ($User->set_seascode_username(defval($_REQUEST, "username"))) {
        redirectSelf();
    }
} else {
    if (!$Me->is_empty() && !$User->seascode_username && preg_match('/\\A(.*?)@.*harvard\\.edu\\z/', $User->email, $m) && $User->check_seascode_username($m[1], false)) {
        $User->set_seascode_username($m[1]);
    }
}
function try_set_seascode_repo()
{
    global $Me, $Conf;
    $min_pset = null;
    foreach (Pset::$all as $p) {
        if (!$min_pset || ContactView::pset_compare($min_pset, $p) > 0) {
            $min_pset = $p;
        }
 function echo_unparse_display()
 {
     $this->set_my_conflicts();
     $bypaper = array();
     foreach ($this->assigners as $assigner) {
         if ($text = $assigner->unparse_display($this)) {
             $c = $assigner->contact;
             if ($c && !isset($c->sorter)) {
                 Contact::set_sorter($c);
             }
             arrayappend($bypaper[$assigner->pid], (object) array("text" => $text, "sorter" => $c ? $c->sorter : $text));
         }
     }
     AutoassignmentPaperColumn::$header = "Assignment";
     $assinfo = array();
     PaperColumn::register(new AutoassignmentPaperColumn());
     foreach ($bypaper as $pid => $list) {
         uasort($list, "Contact::compare");
         $t = "";
         foreach ($list as $x) {
             $t .= ($t ? ", " : "") . '<span class="nw">' . $x->text . '</span>';
         }
         if (isset($this->my_conflicts[$pid])) {
             if ($this->my_conflicts[$pid] !== true) {
                 $t = '<em>Hidden for conflict</em>';
             } else {
                 $t = PaperList::wrapChairConflict($t);
             }
         }
         $assinfo[$pid] = $t;
     }
     ksort($assinfo);
     AutoassignmentPaperColumn::$info = $assinfo;
     if ($this->unparse_search) {
         $query_order = "(" . $this->unparse_search . ") THEN HEADING:none " . join(" ", array_keys($assinfo));
     } else {
         $query_order = count($assinfo) ? join(" ", array_keys($assinfo)) : "NONE";
     }
     foreach ($this->unparse_columns as $k => $v) {
         $query_order .= " show:{$k}";
     }
     $query_order .= " show:autoassignment";
     $search = new PaperSearch($this->contact, array("t" => defval($_REQUEST, "t", "s"), "q" => $query_order));
     $plist = new PaperList($search);
     echo $plist->table_html("reviewers", ["nofooter" => 1]);
     $deltarev = new AssignmentCountSet();
     foreach ($this->assigners as $assigner) {
         $assigner->account($deltarev);
     }
     if (count(array_intersect_key($deltarev->bypc, pcMembers()))) {
         $summary = [];
         $tagger = new Tagger($this->contact);
         $nrev = new AssignmentCountSet();
         $deltarev->rev && $nrev->load_rev();
         $deltarev->lead && $nrev->load_lead();
         $deltarev->shepherd && $nrev->load_shepherd();
         foreach (pcMembers() as $p) {
             if ($deltarev->get($p->contactId)->ass) {
                 $t = '<div class="ctelt"><div class="ctelti';
                 if ($k = $p->viewable_color_classes($this->contact)) {
                     $t .= ' ' . $k;
                 }
                 $t .= '"><span class="taghl">' . $this->contact->name_html_for($p) . "</span>: " . plural($deltarev->get($p->contactId)->ass, "assignment") . self::review_count_report($nrev, $deltarev, $p, "After assignment:&nbsp;") . "<hr class=\"c\" /></div></div>";
                 $summary[] = $t;
             }
         }
         if (count($summary)) {
             echo "<div class=\"g\"></div>\n", "<h3>Summary</h3>\n", '<div class="pc_ctable">', join("", $summary), "</div>\n";
         }
     }
 }
Beispiel #17
0
function paperOptions($id = null)
{
    global $Conf;
    if ($Conf->setting("paperOption") <= 0 || $Conf->sversion <= 0) {
        return array();
    }
    $svar = defval($_SESSION, "paperOption", null);
    if (!$svar || !is_array($svar) || count($svar) < 3 || $svar[2] < 2 || $svar[0] < $Conf->setting("paperOption")) {
        $opt = array();
        $result = $Conf->q("select * from OptionType order by sortOrder, optionName");
        $order = 0;
        while ($row = edb_orow($result)) {
            // begin backwards compatibility to old schema versions
            if (!isset($row->optionValues)) {
                $row->optionValues = "";
            }
            if (!isset($row->type) && $row->optionValues == "i") {
                $row->type = PaperOption::T_NUMERIC;
            } else {
                if (!isset($row->type)) {
                    $row->type = $row->optionValues ? PaperOption::T_SELECTOR : PaperOption::T_CHECKBOX;
                }
            }
            // end backwards compatibility to old schema versions
            $row->optionAbbrev = preg_replace("/-+\$/", "", preg_replace("/[^a-z0-9_]+/", "-", strtolower($row->optionName)));
            if ($row->optionAbbrev == "paper" || $row->optionAbbrev == "submission" || $row->optionAbbrev == "final" || ctype_digit($row->optionAbbrev)) {
                $row->optionAbbrev = "opt" . $row->optionId;
            }
            $row->sortOrder = $order++;
            if (!isset($row->displayType)) {
                $row->displayType = PaperOption::DT_NORMAL;
            }
            if ($row->type == PaperOption::T_FINALPDF) {
                $row->displayType = PaperOption::DT_SUBMISSION;
            }
            $row->isDocument = PaperOption::type_is_document($row->type);
            $row->isFinal = PaperOption::type_is_final($row->type);
            $opt[$row->optionId] = $row;
        }
        $_SESSION["paperOption"] = $svar = array($Conf->setting("paperOption"), $opt, 2);
    }
    return $id ? defval($svar[1], $id, null) : $svar[1];
}
    } else {
        Conf::msg_error(join("<br>", $errors));
    }
}
if ($Me->privChair && @$_REQUEST["tagact"] && check_post() && isset($papersel) && preg_match('/\\A[ads]\\z/', (string) @$_REQUEST["tagtype"])) {
    do_tags();
}
// set scores to view
if (isset($_REQUEST["redisplay"])) {
    $Conf->save_session("uldisplay", "");
    foreach (ContactList::$folds as $key) {
        displayOptionsSet("uldisplay", $key, defval($_REQUEST, "show{$key}", 0));
    }
    foreach (ReviewForm::all_fields() as $f) {
        if ($f->has_options) {
            displayOptionsSet("uldisplay", $f->id, defval($_REQUEST, "show{$f->id}", 0));
        }
    }
}
if (isset($_REQUEST["scoresort"]) && ($_REQUEST["scoresort"] == "A" || $_REQUEST["scoresort"] == "V" || $_REQUEST["scoresort"] == "D")) {
    $Conf->save_session("scoresort", $_REQUEST["scoresort"]);
}
if ($_REQUEST["t"] == "pc") {
    $title = "Program committee";
} else {
    if (str_starts_with($_REQUEST["t"], "#")) {
        $title = "#" . substr($_REQUEST["t"], 1) . " program committee";
    } else {
        $title = "Users";
    }
}
Beispiel #19
0
if ($iscdb) {
    $Acct = Contact::contactdb_find_by_id($capdata->contactId);
} else {
    $Acct = Contact::find_by_id($capdata->contactId);
}
if (!$Acct) {
    error_go(false, "That password reset code refers to a user who no longer exists. Either create a new account or contact the conference administrator.");
}
if (isset($Opt["ldapLogin"]) || isset($Opt["httpAuthLogin"])) {
    error_go(false, "Password reset links aren’t used for this conference. Contact your system administrator if you’ve forgotten your password.");
}
// don't show information about the current user, if there is one
$Me = new Contact();
$password_class = "";
if (isset($_REQUEST["go"]) && check_post()) {
    if (defval($_REQUEST, "useauto") == "y") {
        $_REQUEST["upassword"] = $_REQUEST["upassword2"] = $_REQUEST["autopassword"];
    }
    if (!isset($_REQUEST["upassword"]) || $_REQUEST["upassword"] == "") {
        $Conf->errorMsg("You must enter a password.");
    } else {
        if ($_REQUEST["upassword"] !== $_REQUEST["upassword2"]) {
            $Conf->errorMsg("The two passwords you entered did not match.");
        } else {
            if (!Contact::valid_password($_REQUEST["upassword"])) {
                $Conf->errorMsg("Invalid password.");
            } else {
                $Acct->change_password($_REQUEST["upassword"], true);
                $Acct->log_activity("Reset password");
                $Conf->confirmMsg("Your password has been changed. You may now sign in to the conference site.");
                $capmgr->delete($capdata);
 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;
 }
Beispiel #21
0
if (isset($Runner->queue)) {
    if ($Queueid < 0 && $checkt > 0) {
        quit("No such job");
    }
    if ($Queueid < 0) {
        $Conf->qe("insert into ExecutionQueue set\n            queueclass='" . sqlq($Runner->queue) . "',\n            insertat={$Now}, updateat={$Now}, repoid={$Info->repo->repoid},\n            runat=0, status=0, psetid={$Pset->id}, hash='" . sqlq($Info->commit_hash()) . "',\n            nconcurrent=" . (isset($Runner->nconcurrent) && $Runner->nconcurrent ? sqlq($Runner->nconcurrent) : "null"));
        $Queueid = $Conf->dblink->insert_id;
    } else {
        $Conf->qe("update ExecutionQueue set updateat={$Now} where queueid={$Queueid}");
    }
    $Queue = load_queue($Queueid, $Info->repo);
    $qconf = defval(defval($PsetInfo, "_queues", array()), $Runner->queue);
    if (!$qconf) {
        $qconf = (object) array("nconcurrent" => 1);
    }
    $nconcurrent = defval($qconf, "nconcurrent", 1000);
    if ($Runner->nconcurrent > 0 && $Runner->nconcurrent < $nconcurrent) {
        $nconcurrent = $Runner->nconcurrent;
    }
    if (@$Queue->ahead_nconcurrent > 0 && $Queue->ahead_nconcurrent < $nconcurrent) {
        $nconcurrent = $Queue->ahead_nconcurrent;
    }
    for ($tries = 0; $tries < 2; ++$tries) {
        // error_log($User->seascode_username . ": $Queue->queueid, $nconcurrent, $Queue->nahead, $Queue->ahead_nconcurrent");
        if ($nconcurrent > 0 && $Queue->nahead >= $nconcurrent) {
            if ($tries) {
                $Conf->ajaxExit(array("onqueue" => true, "queueid" => $Queue->queueid, "nahead" => $Queue->nahead, "headage" => $Queue->head_runat ? $Now - $Queue->head_runat : null));
            }
            clean_queue($Runner->queue, $qconf, $Queue->queueid);
            $Queue = load_queue($Queueid, $Info->repo);
        } else {
Beispiel #22
0
 private function run()
 {
     global $Conf, $Opt, $Me, $Error, $subjectPrefix, $mailer_options;
     $subject = trim(defval($_REQUEST, "subject", ""));
     if (substr($subject, 0, strlen($subjectPrefix)) != $subjectPrefix) {
         $subject = $subjectPrefix . $subject;
     }
     $emailBody = $_REQUEST["emailBody"];
     $template = array("subject" => $subject, "body" => $emailBody);
     $rest = array("cc" => $_REQUEST["cc"], "reply-to" => $_REQUEST["replyto"], "no_error_quit" => true);
     $rest = array_merge($rest, $mailer_options);
     // test whether this mail is paper-sensitive
     $mailer = new HotCRPMailer($Me, null, $rest);
     $prep = $mailer->make_preparation($template, $rest);
     $paper_sensitive = preg_match('/%[A-Z0-9]+[(%]/', $prep->subject . $prep->body);
     $q = $this->recip->query($paper_sensitive);
     if (!$q) {
         return Conf::msg_error("Bad recipients value");
     }
     $result = $Conf->qe($q);
     if (!$result) {
         return;
     }
     $recipients = defval($_REQUEST, "recipients", "");
     if ($this->sending) {
         $q = "recipients='" . sqlq($recipients) . "', cc='" . sqlq($_REQUEST["cc"]) . "', replyto='" . sqlq($_REQUEST["replyto"]) . "', subject='" . sqlq($_REQUEST["subject"]) . "', emailBody='" . sqlq($_REQUEST["emailBody"]) . "'";
         if ($Conf->sversion >= 79) {
             $q .= ", q='" . sqlq($_REQUEST["q"]) . "', t='" . sqlq($_REQUEST["t"]) . "'";
         }
         if ($log_result = Dbl::query_raw("insert into MailLog set {$q}")) {
             $this->mailid_text = " #" . $log_result->insert_id;
         }
         $Me->log_activity("Sending mail{$this->mailid_text} \"{$subject}\"");
     } else {
         $rest["no_send"] = true;
     }
     $mailer = new HotCRPMailer();
     $mailer->combination_type = $this->recip->combination_type($paper_sensitive);
     $fake_prep = new HotCRPMailPreparation();
     $fake_prep->fake = true;
     $last_prep = $fake_prep;
     $nrows_done = 0;
     $nrows_left = edb_nrows($result);
     $nwarnings = 0;
     $preperrors = array();
     $revinform = $recipients == "newpcrev" ? array() : null;
     while ($row = PaperInfo::fetch($result, $Me)) {
         ++$nrows_done;
         $contact = new Contact($row);
         $rest["newrev_since"] = $this->recip->newrev_since;
         $mailer->reset($contact, $row, $rest);
         $prep = $mailer->make_preparation($template, $rest);
         if ($prep->errors) {
             foreach ($prep->errors as $lcfield => $hline) {
                 $reqfield = $lcfield == "reply-to" ? "replyto" : $lcfield;
                 $Error[$reqfield] = true;
                 $emsg = Mailer::$email_fields[$lcfield] . " destination isn’t a valid email list: <blockquote><tt>" . htmlspecialchars($hline) . "</tt></blockquote> Make sure email address are separated by commas; put names in \"quotes\" and email addresses in &lt;angle brackets&gt;.";
                 if (!isset($preperrors[$emsg])) {
                     Conf::msg_error($emsg);
                 }
                 $preperrors[$emsg] = true;
             }
         } else {
             if ($this->process_prep($prep, $last_prep, $row)) {
                 if ((!$Me->privChair || @$Opt["chairHidePasswords"]) && !@$last_prep->sensitive) {
                     $srest = array_merge($rest, array("sensitivity" => "display"));
                     $mailer->reset($contact, $row, $srest);
                     $last_prep->sensitive = $mailer->make_preparation($template, $srest);
                 }
             }
         }
         if ($nwarnings != $mailer->nwarnings() || $nrows_done % 5 == 0) {
             $this->echo_mailinfo($nrows_done, $nrows_left);
         }
         if ($nwarnings != $mailer->nwarnings()) {
             $this->echo_prologue();
             $nwarnings = $mailer->nwarnings();
             echo "<div id='foldmailwarn{$nwarnings}' class='hidden'><div class='warning'>", join("<br />", $mailer->warnings()), "</div></div>";
             $Conf->echoScript("\$\$('mailwarnings').innerHTML = \$\$('foldmailwarn{$nwarnings}').innerHTML;");
         }
         if ($this->sending && $revinform !== null) {
             $revinform[] = "(paperId={$row->paperId} and contactId={$row->contactId})";
         }
     }
     $this->process_prep($fake_prep, $last_prep, (object) array("paperId" => -1));
     $this->echo_mailinfo($nrows_done, $nrows_left);
     if (!$this->started && !count($preperrors)) {
         return Conf::msg_error("No users match “" . $this->recip->unparse() . "” for that search.");
     } else {
         if (!$this->started) {
             return false;
         } else {
             if (!$this->sending) {
                 $this->echo_actions();
             }
         }
     }
     if ($revinform) {
         $Conf->qe("update PaperReview set timeRequestNotified=" . time() . " where " . join(" or ", $revinform));
     }
     echo "</div></form>";
     $Conf->echoScript("fold('mail', null);");
     $Conf->footer();
     exit;
 }
Beispiel #23
0
 $notelinks = array();
 foreach ($lnorder->seq() as $fl) {
     $f = str_starts_with($fl[0], $Pset->directory_slash) ? substr($fl[0], strlen($Pset->directory_slash)) : $fl[0];
     $notelinks[] = '<a href="#L' . $fl[1] . '_' . html_id_encode($fl[0]) . '" onclick="return gotoline61(this)" class="noteref61' . (!$fl[2] && !$Info->user_can_see_grades ? " hiddennote61" : "") . '">' . htmlspecialchars($f) . ':' . substr($fl[1], 1) . '</a>';
 }
 if (count($notelinks)) {
     ContactView::echo_group("notes", join(", ", $notelinks));
 }
 // print runners
 $crunners = $Info->commit_info("run");
 $runclasses = [];
 foreach ($Pset->runners as $r) {
     if (!$Me->can_view_run($Pset, $r, $User) || isset($runclasses[$r->runclass])) {
         continue;
     }
     $checkt = defval($crunners, $r->runclass);
     $rj = $checkt ? ContactView::runner_json($Info, $checkt) : null;
     if (!$rj && !$Me->can_run($Pset, $r, $User)) {
         continue;
     }
     echo '<div id="run61out_' . $r->runclass . '"';
     if (!$rj || !isset($rj->timestamp)) {
         echo ' style="display:none"';
     }
     echo '><h3><a class="fold61" href="#" onclick="', "return runfold61('{$r->runclass}')", '">', '<span class="foldarrow">&#x25B6;</span>&nbsp;', htmlspecialchars($r->output_title), '</a></h3>', '<div class="run61" id="run61_', $r->runclass, '" style="display:none"';
     if ($Pset->directory_noslash !== "") {
         echo ' data-pa-directory="', htmlspecialchars($Pset->directory_noslash), '"';
     }
     if ($rj && isset($rj->timestamp)) {
         echo ' data-pa-timestamp="', $rj->timestamp, '"';
     }
 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;
     }
 }
Beispiel #25
0
// access only allowed through index.php
if (!$Conf) {
    exit;
}
global $Qreq;
ContactView::set_path_request(array("/u"));
$Qreq = make_qreq();
$email_class = "";
$password_class = "";
$LastPsetFix = false;
$Profile = $Me && $Me->privChair && $Qreq->profile;
// signin links
// auto-signin when email & password set
if (isset($_REQUEST["email"]) && isset($_REQUEST["password"])) {
    $_REQUEST["action"] = defval($_REQUEST, "action", "login");
    $_REQUEST["signin"] = defval($_REQUEST, "signin", "go");
}
// CSRF protection: ignore unvalidated signin/signout for known users
if (!$Me->is_empty() && !check_post()) {
    unset($_REQUEST["signout"]);
}
if ($Me->has_email() && (!check_post() || strcasecmp($Me->email, trim($Qreq->email)) == 0)) {
    unset($_REQUEST["signin"]);
}
if (!isset($_REQUEST["email"]) || !isset($_REQUEST["action"])) {
    unset($_REQUEST["signin"]);
}
// signout
if (isset($_REQUEST["signout"])) {
    LoginHelper::logout(true);
} else {
 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 requestReview($email)
{
    global $Conf, $Me, $Error, $prow;
    $Them = Contact::create(array("name" => @$_REQUEST["name"], "email" => $email));
    if (!$Them) {
        if (trim($email) === "" || !validate_email($email)) {
            Conf::msg_error("“" . htmlspecialchars(trim($email)) . "” is not a valid email address.");
            $Error["email"] = true;
        } else {
            Conf::msg_error("Error while finding account for “" . htmlspecialchars(trim($email)) . ".”");
        }
        return false;
    }
    $reason = trim(defval($_REQUEST, "reason", ""));
    $round = $Conf->current_round();
    if (isset($_REQUEST["round"]) && $_REQUEST["round"] != "" && ($rname = $Conf->sanitize_round_name($_REQUEST["round"])) !== false) {
        $round = $Conf->round_number($rname, false);
    }
    // look up the requester
    $Requester = $Me;
    if ($Conf->setting("extrev_chairreq")) {
        $result = Dbl::qe("select firstName, lastName, u.email, u.contactId from ReviewRequest rr join ContactInfo u on (u.contactId=rr.requestedBy) where paperId={$prow->paperId} and rr.email=?", $Them->email);
        if ($result && ($recorded_requester = Contact::fetch($result))) {
            $Requester = $recorded_requester;
        }
    }
    Dbl::qe_raw("lock tables PaperReview write, PaperReviewRefused write, ReviewRequest write, ContactInfo read, PaperConflict read, ActionLog write");
    // NB caller unlocks tables on error
    // check for outstanding review request
    if (!($result = requestReviewChecks(Text::user_html($Them), $Them->contactId))) {
        return $result;
    }
    // at this point, we think we've succeeded.
    // store the review request
    $Me->assign_review($prow->paperId, $Them->contactId, REVIEW_EXTERNAL, ["mark_notify" => true, "requester_contact" => $Requester, "requested_email" => $Them->email, "round_number" => $round]);
    Dbl::qx_raw("unlock tables");
    // send confirmation email
    HotCRPMailer::send_to($Them, "@requestreview", $prow, array("requester_contact" => $Requester, "other_contact" => $Requester, "reason" => $reason));
    $Conf->confirmMsg("Created a request to review paper #{$prow->paperId}.");
    return true;
}
Beispiel #28
0
function searchbar()
{
    global $Conf, $Eclass, $page, $start, $count, $nrows, $maxNrows, $nlinks, $offset;
    echo Ht::form_div(hoturl("log"), array("method" => "get")), "<table id='searchform'><tr>\n  <td class='lxcaption", $Eclass['q'], "'>With <b>any</b> of the words</td>\n  <td class='lentry", $Eclass['q'], "'><input type='text' size='40' name='q' value=\"", htmlspecialchars(defval($_REQUEST, "q", "")), "\" /><span class='sep'></span></td>\n  <td rowspan='3'>", Ht::submit("search", "Search"), "</td>\n</tr><tr>\n  <td class='lxcaption", $Eclass['pap'], "'>Concerning paper(s)</td>\n  <td class='lentry", $Eclass['pap'], "'><input type='text' size='40' name='pap' value=\"", htmlspecialchars(defval($_REQUEST, "pap", "")), "\" /></td>\n</tr><tr>\n  <td class='lxcaption", $Eclass['acct'], "'>Concerning account(s)</td>\n  <td class='lentry'><input type='text' size='40' name='acct' value=\"", htmlspecialchars(defval($_REQUEST, "acct", "")), "\" /></td>\n</tr><tr>\n  <td class='lxcaption", $Eclass['n'], "'>Show</td>\n  <td class='lentry", $Eclass['n'], "'><input type='text' size='4' name='n' value=\"", htmlspecialchars($_REQUEST["n"]), "\" /> &nbsp;records at a time</td>\n</tr><tr>\n  <td class='lxcaption", $Eclass['date'], "'>Starting at</td>\n  <td class='lentry", $Eclass['date'], "'><input type='text' size='40' name='date' value=\"", htmlspecialchars($_REQUEST["date"]), "\" /></td>\n</tr></table></div></form>";
    if ($nrows > $count || $page > 1) {
        $urls = array();
        $_REQUEST["offset"] = $offset;
        foreach (array("q", "pap", "acct", "n", "offset") as $x) {
            if ($_REQUEST[$x]) {
                $urls[] = "{$x}=" . urlencode($_REQUEST[$x]);
            }
        }
        $url = hoturl("log", join("&amp;", $urls));
        echo "<table class='lognav'><tr><td id='newest'><div>";
        if ($page > 1) {
            echo "<a href='{$url}&amp;page=1'><strong>Newest</strong></a> &nbsp;|&nbsp;&nbsp;";
        }
        echo "</div></td><td id='newer'><div>";
        if ($page > 1) {
            echo "<a href='{$url}&amp;page=", $page - 1, "'><strong>", Ht::img("_.gif", "<-", array("class" => "prev")), " Newer</strong></a>";
        }
        echo "</div></td><td id='newnum'><div>";
        if ($page - $nlinks > 1) {
            echo "&nbsp;...";
        }
        for ($p = max($page - $nlinks - 1, 0); $p + 1 < $page; $p++) {
            echo "&nbsp;<a href='{$url}&amp;page=", $p + 1, "'>", $p + 1, "</a>";
        }
        echo "</div></td><td id='thisnum'><div><strong class='thispage'>&nbsp;", $page, "&nbsp;</strong></div></td><td id='oldnum'><div>";
        $o = $offset ? $offset - $count : 0;
        for ($p = $page; $p * $count + $o < $start + min($nlinks * $count + 1, $nrows); $p++) {
            echo "<a href='{$url}&amp;page=", $p + 1, "'>", $p + 1, "</a>&nbsp;";
        }
        if ($nrows == $maxNrows) {
            echo "...&nbsp;";
        }
        echo "</div></td><td id='older'><div>";
        if ($nrows > $count) {
            echo "<a href='{$url}&amp;page=", $page + 1, "'><strong>Older ", Ht::img("_.gif", "->", array("class" => "next")), "</strong></a>";
        }
        echo "</div></td><td id='oldest'><div>";
        if ($nrows > $count) {
            echo "&nbsp;&nbsp;|&nbsp; <a href='{$url}&amp;page=earliest'><strong>Oldest</strong></a>";
        }
        echo "</div></td></tr></table>";
    }
    echo "<div class='g'></div>\n";
}
 public function table_html($listname, $options = array())
 {
     global $Conf;
     if (!$this->_prepare()) {
         return null;
     }
     if (isset($options["fold"])) {
         foreach ($options["fold"] as $n => $v) {
             $this->viewmap->{$n} = $v;
         }
     }
     if (isset($options["table_id"])) {
         $this->viewmap->table_id = $options["table_id"];
     }
     // need tags for row coloring
     if ($this->contact->can_view_tags(null)) {
         $this->qopts["tags"] = 1;
     }
     $this->table_type = $listname;
     // get column list, check sort
     $field_list = $this->_list_columns($listname);
     if (!$field_list) {
         Conf::msg_error("There is no paper list query named “" . htmlspecialchars($listname) . "”.");
         return null;
     }
     $field_list = $this->_columns($field_list, true);
     $body_attr = $this->row_attr;
     $rows = $this->_rows($field_list);
     if ($rows === null) {
         return null;
     }
     // return IDs if requested
     if (empty($rows)) {
         if ($altq = $this->search->alternate_query()) {
             $altqh = htmlspecialchars($altq);
             $url = $this->search->url_site_relative_raw($altq);
             if (substr($url, 0, 5) == "search") {
                 $altqh = "<a href=\"" . htmlspecialchars(Navigation::siteurl() . $url) . "\">" . $altqh . "</a>";
             }
             return "No matching papers. Did you mean “{$altqh}”?";
         } else {
             return "No matching papers";
         }
     }
     // get field array
     $fieldDef = array();
     $ncol = $titlecol = 0;
     // folds: au:1, anonau:2, fullrow:3, aufull:4, force:5, rownum:6, [fields]
     $next_fold = 7;
     foreach ($field_list as $fdef) {
         if ($fdef->view != Column::VIEW_NONE) {
             $fieldDef[] = $fdef;
         }
         if ($fdef->view != Column::VIEW_NONE && $fdef->foldable) {
             $fdef->foldable = $next_fold;
             ++$next_fold;
         }
         if ($fdef->name == "title") {
             $titlecol = $ncol;
         }
         if ($fdef->view == Column::VIEW_COLUMN && !$fdef->is_folded) {
             ++$ncol;
         }
     }
     // count non-callout columns
     $skipcallout = 0;
     foreach ($fieldDef as $fdef) {
         if ($fdef->name != "id" && !isset($fdef->is_selector)) {
             break;
         } else {
             ++$skipcallout;
         }
     }
     // create render state
     $rstate = new PaperListRenderState($ncol, $titlecol, $skipcallout);
     // collect row data
     $body = array();
     $lastheading = !empty($this->search->groupmap) ? -1 : -2;
     $need_render = false;
     foreach ($rows as $row) {
         ++$this->count;
         if ($lastheading > -2) {
             $lastheading = $this->_check_heading($this->_row_thenval($row), $rstate, $rows, $lastheading, $body);
         }
         $body[] = $this->_row_text($rstate, $row, $fieldDef);
         if ($this->need_render && !$need_render) {
             $Conf->footerScript('$(plinfo.render_needed)', 'plist_render_needed');
             $need_render = true;
         }
         if ($this->need_render && $this->count % 16 == 15) {
             $body[count($body) - 1] .= "  <script>plinfo.render_needed()</script>\n";
             $this->need_render = false;
         }
     }
     if ($lastheading > -2 && $this->search->is_order_anno) {
         while ($lastheading + 1 < count($this->search->groupmap)) {
             $lastheading = $this->_check_heading($lastheading + 1, $rstate, $rows, $lastheading, $body);
         }
     }
     // header cells
     $colhead = "";
     $url = $this->search->url_site_relative_raw();
     if (!defval($options, "noheader")) {
         $colhead .= " <thead class=\"pltable\">\n  <tr class=\"pl_headrow\">";
         $ord = 0;
         $titleextra = $this->_make_title_header_extra($rstate, $fieldDef, get($options, "header_links"));
         foreach ($fieldDef as $fdef) {
             if ($fdef->view != Column::VIEW_COLUMN || $fdef->is_folded) {
                 continue;
             }
             $colhead .= "<th class=\"pl " . $fdef->className;
             if ($fdef->foldable) {
                 $colhead .= " fx" . $fdef->foldable;
             }
             $colhead .= "\">";
             if ($fdef->has_content) {
                 $colhead .= $this->_field_title($fdef, $ord);
             }
             if ($titleextra && $fdef->className == "pl_title") {
                 $colhead .= $titleextra;
                 $titleextra = false;
             }
             $colhead .= "</th>";
             ++$ord;
         }
         $colhead .= "</tr>\n";
         if ($this->search->is_order_anno) {
             $colhead .= "  <tr class=\"pl_headrow pl_annorow\" data-anno-tag=\"{$this->search->is_order_anno}\">";
             if ($rstate->titlecol) {
                 $colhead .= "<td colspan=\"{$rstate->titlecol}\"></td>";
             }
             $colhead .= "<td colspan=\"" . ($rstate->ncol - $rstate->titlecol) . "\"><a href=\"#\" onclick=\"return plinfo_tags.edit_anno(this)\">Annotate order</a></td></tr>\n";
         }
         $colhead .= " </thead>\n";
     }
     // table skeleton including fold classes
     $foldclasses = array();
     if ($this->foldable) {
         $foldclasses = $this->_analyze_folds($rstate, $fieldDef);
     }
     $enter = "";
     if (self::$include_stash) {
         $enter .= Ht::take_stash();
     }
     $enter .= "<table class=\"pltable plt_" . htmlspecialchars($listname);
     if (defval($options, "class")) {
         $enter .= " " . $options["class"];
     }
     if ($this->listNumber) {
         $enter .= " has_hotcrp_list";
     }
     if (!empty($foldclasses)) {
         $enter .= " " . join(" ", $foldclasses);
     }
     if ($this->viewmap->table_id) {
         $enter .= "\" id=\"" . $this->viewmap->table_id;
     }
     if (defval($options, "attributes")) {
         foreach ($options["attributes"] as $n => $v) {
             $enter .= "\" {$n}=\"" . htmlspecialchars($v);
         }
     }
     if ($this->search->is_order_anno) {
         $enter .= "\" data-order-tag=\"{$this->search->is_order_anno}";
     }
     foreach ($body_attr as $k => $v) {
         $enter .= "\" {$k}=\"" . htmlspecialchars($v);
     }
     if ($this->listNumber) {
         $enter .= '" data-hotcrp-list="' . $this->listNumber;
     }
     $enter .= "\" data-fold=\"true\">\n";
     $exit = "</table>";
     // maybe make columns, maybe not
     $tbody_class = "pltable";
     if ($this->viewmap->columns && !empty($rstate->ids) && $this->_column_split($rstate, $colhead, $body)) {
         $enter = '<div class="plsplit_col_ctr_ctr"><div class="plsplit_col_ctr">' . $enter;
         $exit = $exit . "</div></div>";
         $ncol = $rstate->split_ncol;
         $tbody_class = "pltable_split";
     } else {
         $enter .= $colhead;
         $tbody_class .= $rstate->hascolors ? " pltable_colored" : "";
     }
     // footer
     $foot = "";
     if ($this->viewmap->statistics && !$this->viewmap->columns) {
         $foot .= $this->_statistics_rows($rstate, $fieldDef);
     }
     if ($fieldDef[0] instanceof SelectorPaperColumn && !defval($options, "nofooter")) {
         $foot .= $this->_footer($ncol, get_s($options, "footer_extra"));
     }
     if ($foot) {
         $enter .= ' <tfoot' . ($rstate->hascolors ? ' class="pltable_colored"' : "") . ">\n" . $foot . " </tfoot>\n";
     }
     // body
     $enter .= " <tbody class=\"{$tbody_class}\">\n";
     // header scripts to set up delegations
     if ($this->_header_script) {
         $enter .= '  <script>' . $this->_header_script . "</script>\n";
     }
     // session variable to remember the list
     if ($this->listNumber) {
         $sl = $this->search->create_session_list_object($rstate->ids, self::_listDescription($listname), $this->sortdef());
         if (isset($this->qreq->sort)) {
             $url .= (strpos($url, "?") ? "&" : "?") . "sort=" . urlencode($this->qreq->sort);
         }
         $sl->url = $url;
         if (get($options, "list_properties")) {
             foreach ($options["list_properties"] as $k => $v) {
                 $sl->{$k} = $v;
             }
         }
         SessionList::change($this->listNumber, $sl);
     }
     foreach ($fieldDef as $fdef) {
         if ($fdef->has_content) {
             $this->any[$fdef->name] = true;
         }
     }
     if ($rstate->has_openau) {
         $this->any->openau = true;
     }
     if ($rstate->has_anonau) {
         $this->any->anonau = true;
     }
     $this->ids = $rstate->ids;
     return $enter . join("", $body) . " </tbody>\n" . $exit;
 }
Beispiel #30
0
function echo_commit($Info)
{
    global $Conf, $Me, $User, $Pset;
    global $TABWIDTH, $WDIFF;
    $Notes = $Info->commit_info();
    $TABWIDTH = defval($Notes, "tabwidth", 8);
    $WDIFF = isset($Notes->wdiff) ? $Notes->wdiff : false;
    // current commit and commit selector
    $sel = array();
    $curhead = $grouphead = null;
    foreach ($Info->recent_commits() as $k) {
        // visually separate older heads
        if ($curhead === null) {
            $curhead = $k->fromhead;
        }
        if ($curhead != $k->fromhead) {
            if (!$grouphead) {
                $sel["from.{$k->fromhead}"] = (object) array("type" => "optgroup", "label" => "Other snapshots");
            } else {
                $sel["from.{$k->fromhead}"] = null;
            }
            $curhead = $grouphead = $k->fromhead;
        }
        // actual option
        $x = utf8_substr($k->subject, 0, 72);
        if (strlen($x) != strlen($k->subject)) {
            $x .= "...";
        }
        $sel[$k->hash] = substr($k->hash, 0, 7) . " " . htmlspecialchars($x);
    }
    $result = $Conf->qe("select hash from CommitNotes where (haslinenotes&" . ($Me == $User && !$Info->can_see_grades ? HASNOTES_COMMENT : HASNOTES_ANY) . ")!=0 and pset={$Pset->psetid} and hash in ('" . join("','", array_keys($sel)) . "')");
    while ($row = edb_row($result)) {
        $sel[$row[0]] .= " &nbsp;♪";
    }
    if (($h = $Info->grading_hash()) && isset($sel[$h])) {
        $sel[$h] = preg_replace('_(.*?)(?: &nbsp;)?(♪?)\\z_', '$1 &nbsp;✱$2', $sel[$h]);
    }
    if ($Info->is_grading_commit()) {
        $key = "grading commit";
    } else {
        $key = "this commit";
    }
    $value = Ht::select("newcommit", $sel, $Info->commit_hash(), array("onchange" => "jQuery(this).closest('form').submit()"));
    if ($Me != $User) {
        $x = $Info->is_grading_commit() ? "" : "font-weight:bold";
        $value .= " " . Ht::submit("grade", "Grade", array("style" => $x));
    }
    // view options
    $fold_viewoptions = !isset($_REQUEST["tab"]) && !isset($_REQUEST["wdiff"]);
    $value .= '<div class="viewoptions61">' . '<a class="q" href="#" onclick="return fold61(this.nextSibling,this.parentNode)">' . '<span class="foldarrow">' . ($fold_viewoptions ? '&#x25B6;' : '&#x25BC;') . '</span>&nbsp;options</a><span style="padding-left:1em' . ($fold_viewoptions ? ';display:none' : '') . '">tab width:';
    foreach (array(2, 4, 8) as $i) {
        $value .= '&nbsp;<a href="' . self_href(array("tab" => $i)) . '"' . ($TABWIDTH == $i ? " class=\"q\"><strong>{$i}</strong>" : '>' . $i) . '</a>';
    }
    $value .= '<span style="padding-left:1em">wdiff:';
    foreach (array("no", "yes") as $i => $t) {
        $value .= '&nbsp;<a href="' . self_href(array("wdiff" => $i)) . '"' . (!$WDIFF == !$i ? " class=\"q\"><strong>{$t}</strong>" : '>' . $t) . '</a>';
    }
    $value .= '</span></span></div>';
    // warnings
    $remarks = array();
    if (!$Info->grading_hash() && $Me != $User && !$Pset->gitless_grades) {
        $remarks[] = array(true, "No commit has been marked for grading.");
    } else {
        if (!$Info->is_grading_commit() && $Info->grading_hash()) {
            $remarks[] = array(true, "This is not " . "<a class=\"uu\" href=\"" . $Info->hoturl("pset", array("commit" => $Info->grading_hash())) . "\">the commit currently marked for grading</a>" . " <span style=\"font-weight:normal\">(<a href=\"" . $Info->hoturl("diff", array("commit1" => $Info->grading_hash())) . "\">see diff</a>)</span>.");
        }
    }
    if (!$Info->is_latest_commit()) {
        $remarks[] = array(true, "This is not " . "<a class=\"uu\" href=\"" . $Info->hoturl("pset", array("commit" => $Info->latest_hash())) . "\">the latest commit</a>" . " <span style=\"font-weight:normal\">(<a href=\"" . $Info->hoturl("diff", array("commit1" => $Info->latest_hash())) . "\">see diff</a>)</span>.");
    }
    if (($lh = $Info->late_hours()) && $lh->hours > 0) {
        $extra = array();
        if (@$lh->commitat) {
            $extra[] = "commit at " . $Conf->printableTimestamp($lh->commitat);
        }
        if (@$lh->deadline) {
            $extra[] = "deadline " . $Conf->printableTimestamp($lh->deadline);
        }
        $extra = count($extra) ? ' <span style="font-weight:normal">(' . join(", ", $extra) . ')</span>' : "";
        $remarks[] = array(true, "This commit uses " . plural($lh->hours, "late hour") . $extra . ".");
    }
    if (($Info->is_latest_commit() || $Me->isPC) && $Pset->handout_repo_url) {
        $last_handout = Contact::handout_repo_latest_commit($Pset);
        $last_myhandout = $last_handout ? $Info->derived_handout_hash() : false;
        if ($last_handout && $last_myhandout && $last_handout == $last_myhandout) {
            /* this is ideal: they have the latest handout commit */
        } else {
            if ($last_handout && $last_myhandout) {
                // they don't have the latest updates
                $remarks[] = array(true, "Updates are available for this problem set <span style=\"font-weight:normal\">(<a href=\"" . $Info->hoturl("diff", array("commit" => $last_myhandout, "commit1" => $last_handout)) . "\">see diff</a>)</span>. Run <code>git pull handout master</code> to merge these updates.");
            } else {
                if ($last_handout) {
                    $remarks[] = array(true, "Please create your repository by cloning our repository. Creating your repository from scratch makes it harder for you to get pset updates.");
                } else {
                    if (!$last_handout && $Me->isPC) {
                        $handout_files = Contact::repo_ls_files(Contact::handout_repo($Pset), "master");
                        if (!count($handout_files)) {
                            $remarks[] = array(true, "The handout repository, " . htmlspecialchars($Pset->handout_repo_url) . ", contains no files; perhaps handout_repo_url is misconfigured.");
                        } else {
                            $remarks[] = array(true, "The handout repository, " . htmlspecialchars($Pset->handout_repo_url) . ", does not contain problem set code yet.");
                        }
                    }
                }
            }
        }
    }
    // actually print
    echo Ht::form($Info->hoturl_post("pset", array("commit" => null, "setcommit" => 1)), array("class" => "commitcontainer61", "peteramati_pset" => $Info->pset->urlkey, "peteramati_commit" => $Info->latest_hash())), "<div class=\"f-contain\">";
    ContactView::echo_group($key, $value, $remarks);
    echo "</div></form>\n";
}