forked from kohler/hotcrp
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Page partials are moved into src/pages. * Remove initweb.php in favor of initialize_request().
- Loading branch information
Showing
55 changed files
with
4,004 additions
and
3,738 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,125 +1,5 @@ | ||
<?php | ||
// api.php -- HotCRP JSON API access page | ||
// Copyright (c) 2006-2020 Eddie Kohler; see LICENSE. | ||
// api.php -- HotCRP delegation page | ||
// Copyright (c) 2006-2021 Eddie Kohler; see LICENSE. | ||
|
||
// argument cleaning | ||
require_once("lib/navigation.php"); | ||
if (!isset($_GET["fn"])) { | ||
$fn = Navigation::path_component(0, true); | ||
if ($fn && ctype_digit($fn)) { | ||
if (!isset($_GET["p"])) { | ||
$_GET["p"] = $fn; | ||
} | ||
$fn = Navigation::path_component(1, true); | ||
} | ||
if ($fn) { | ||
$_GET["fn"] = $fn; | ||
} else if (isset($_GET["track"])) { | ||
$_GET["fn"] = "track"; | ||
} else { | ||
http_response_code(404); | ||
header("Content-Type: text/plain; charset=utf-8"); | ||
echo json_encode(["ok" => false, "error" => "API function missing."]); | ||
exit; | ||
} | ||
} | ||
if ($_GET["fn"] === "deadlines") { | ||
$_GET["fn"] = "status"; | ||
} | ||
if (!isset($_GET["p"]) | ||
&& ($p = Navigation::path_component(1, true)) | ||
&& ctype_digit($p)) { | ||
$_GET["p"] = $p; | ||
} | ||
|
||
// trackerstatus is a special case: prevent session creation | ||
if ($_GET["fn"] === "trackerstatus") { | ||
require_once("src/init.php"); | ||
Contact::$no_main_user = true; | ||
require_once("src/initweb.php"); | ||
MeetingTracker::trackerstatus_api(new Contact(null, $Conf)); | ||
exit; | ||
} | ||
|
||
// initialization | ||
require_once("src/initweb.php"); | ||
|
||
function handle_api(Conf $conf, Contact $me, Qrequest $qreq) { | ||
if ($qreq->base !== null) { | ||
$conf->set_siteurl($qreq->base); | ||
} | ||
if (!$me->has_account_here() | ||
&& ($key = $me->capability("@kiosk"))) { | ||
$kiosks = $conf->setting_json("__tracker_kiosk") ? : (object) array(); | ||
if (isset($kiosks->$key) && $kiosks->$key->update_at >= Conf::$now - 172800) { | ||
if ($kiosks->$key->update_at < Conf::$now - 3600) { | ||
$kiosks->$key->update_at = Conf::$now; | ||
$conf->save_setting("__tracker_kiosk", 1, $kiosks); | ||
} | ||
$me->tracker_kiosk_state = $kiosks->$key->show_papers ? 2 : 1; | ||
} | ||
} | ||
if ($qreq->p) { | ||
$conf->set_paper_request($qreq, $me); | ||
} | ||
|
||
// requests | ||
if ($conf->has_api($qreq->fn) || $me->is_disabled()) { | ||
$conf->call_api_exit($qreq->fn, $me, $qreq, $conf->paper); | ||
} | ||
|
||
if ($qreq->fn === "events") { | ||
if (!$me->is_reviewer()) { | ||
json_exit(403, ["ok" => false]); | ||
} | ||
$from = $qreq->from; | ||
if (!$from || !ctype_digit($from)) { | ||
$from = Conf::$now; | ||
} | ||
$when = $from; | ||
$rf = $conf->review_form(); | ||
$events = new PaperEvents($me); | ||
$rows = []; | ||
$more = false; | ||
foreach ($events->events($when, 11) as $xr) { | ||
if (count($rows) == 10) { | ||
$more = true; | ||
} else { | ||
if ($xr->crow) { | ||
$rows[] = $xr->crow->unparse_flow_entry($me); | ||
} else { | ||
$rows[] = $rf->unparse_flow_entry($xr->prow, $xr->rrow, $me); | ||
} | ||
$when = $xr->eventTime; | ||
} | ||
} | ||
json_exit(["ok" => true, "from" => (int) $from, "to" => (int) $when - 1, | ||
"rows" => $rows, "more" => $more]); | ||
} | ||
|
||
// from here on: `status` and `track` requests | ||
$is_track = $qreq->fn === "track"; | ||
if ($is_track) { | ||
MeetingTracker::track_api($me, $qreq); // may fall through to act like `status` | ||
} else if ($qreq->fn !== "status") { | ||
json_exit(404, "Unknown request “" . $qreq->fn . "”"); | ||
} | ||
|
||
$j = $me->my_deadlines($conf->paper ? [$conf->paper] : []); | ||
|
||
if ($conf->paper && $me->can_view_tags($conf->paper)) { | ||
$pj = (object) ["pid" => $conf->paper->paperId]; | ||
$conf->paper->add_tag_info_json($pj, $me); | ||
if (count((array) $pj) > 1) { | ||
$j->p = [$conf->paper->paperId => $pj]; | ||
} | ||
} | ||
|
||
if ($is_track && ($new_trackerid = $qreq->annex("new_trackerid"))) { | ||
$j->new_trackerid = $new_trackerid; | ||
} | ||
$j->ok = true; | ||
json_exit($j); | ||
} | ||
|
||
handle_api(Conf::$main, Contact::$main_user, $Qreq); | ||
include("index.php"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,136 +1,5 @@ | ||
<?php | ||
// deadlines.php -- HotCRP deadline reporting page | ||
// deadlines.php -- HotCRP delegation page | ||
// Copyright (c) 2006-2021 Eddie Kohler; see LICENSE. | ||
|
||
require_once("src/initweb.php"); | ||
|
||
$Viewer = $Me; | ||
if ($Me->contactId && $Me->is_disabled()) { | ||
$Viewer = new Contact(["email" => $Me->email], $Conf); | ||
} | ||
|
||
// *** NB If you change this script, also change the logic in index.php *** | ||
// *** that hides the link when there are no deadlines to show. *** | ||
|
||
// header and script | ||
$Conf->header("Deadlines", "deadlines"); | ||
|
||
if ($Viewer->privChair) { | ||
echo "<p>As PC chair, you can <a href=\"", $Conf->hoturl("settings"), "\">change the deadlines</a>.</p>\n"; | ||
} | ||
|
||
echo "<dl>\n"; | ||
|
||
|
||
function printDeadline($time, $phrase, $description) { | ||
global $Conf; | ||
echo "<dt><strong>", $phrase, "</strong>: ", $Conf->unparse_time_long($time), | ||
$Conf->unparse_usertime_span($time), "</dt>\n", | ||
"<dd>", $description, ($description ? "<br />" : ""), "</dd>"; | ||
} | ||
|
||
$dl = $Viewer->my_deadlines(); | ||
|
||
// If you change these, also change Contact::has_reportable_deadline(). | ||
if ($dl->sub->reg ?? false) { | ||
printDeadline($dl->sub->reg, $Conf->_("Registration deadline"), | ||
$Conf->_("You can register new submissions until this deadline.")); | ||
} | ||
|
||
if ($dl->sub->update ?? false) { | ||
printDeadline($dl->sub->update, $Conf->_("Update deadline"), | ||
$Conf->_("You can update submissions and upload new versions until this deadline.")); | ||
} | ||
|
||
if ($dl->sub->sub ?? false) { | ||
printDeadline($dl->sub->sub, $Conf->_("Submission deadline"), | ||
$Conf->_("Submissions must be ready by this deadline to be reviewed.")); | ||
} | ||
|
||
if ($dl->resps ?? false) { | ||
foreach ($dl->resps as $rname => $dlr) { | ||
if (($dlr->open ?? false) | ||
&& $dlr->open <= Conf::$now | ||
&& ($dlr->done ?? false)) { | ||
if ($rname == 1) { | ||
printDeadline($dlr->done, $Conf->_("Response deadline"), | ||
$Conf->_("You can submit responses to the reviews until this deadline.")); | ||
} else { | ||
printDeadline($dlr->done, $Conf->_("%s response deadline", $rname), | ||
$Conf->_("You can submit %s responses to the reviews until this deadline.", $rname)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (($dl->rev ?? false) && ($dl->rev->open ?? false)) { | ||
$dlbyround = []; | ||
$last_dlbyround = null; | ||
foreach ($Conf->defined_round_list() as $i => $round_name) { | ||
$isuf = $i ? "_$i" : ""; | ||
$es = +$Conf->setting("extrev_soft$isuf"); | ||
$eh = +$Conf->setting("extrev_hard$isuf"); | ||
$ps = $ph = -1; | ||
|
||
$thisdl = []; | ||
if ($Viewer->isPC) { | ||
$ps = +$Conf->setting("pcrev_soft$isuf"); | ||
$ph = +$Conf->setting("pcrev_hard$isuf"); | ||
if ($ph && ($ph < Conf::$now || $ps < Conf::$now)) { | ||
$thisdl[] = "PH" . $ph; | ||
} else if ($ps) { | ||
$thisdl[] = "PS" . $ps; | ||
} | ||
} | ||
if ($es != $ps || $eh != $ph) { | ||
if ($eh && ($eh < Conf::$now || $es < Conf::$now)) { | ||
$thisdl[] = "EH" . $eh; | ||
} else if ($es) { | ||
$thisdl[] = "ES" . $es; | ||
} | ||
} | ||
if (count($thisdl)) { | ||
$dlbyround[$round_name] = $last_dlbyround = join(" ", $thisdl); | ||
} | ||
} | ||
|
||
$dlroundunify = true; | ||
foreach ($dlbyround as $x) { | ||
if ($x !== $last_dlbyround) | ||
$dlroundunify = false; | ||
} | ||
|
||
foreach ($dlbyround as $roundname => $dltext) { | ||
if ($dltext === "") { | ||
continue; | ||
} | ||
$suffix = $roundname === "" ? "" : "_$roundname"; | ||
if ($dlroundunify) { | ||
$roundname = ""; | ||
} | ||
foreach (explode(" ", $dltext) as $dldesc) { | ||
$dt = substr($dldesc, 0, 2); | ||
$dv = (int) substr($dldesc, 2); | ||
if ($dt === "PS") { | ||
printDeadline($dv, $Conf->_("%s review deadline", $roundname), | ||
$Conf->_("%s reviews are requested by this deadline.", $roundname)); | ||
} else if ($dt === "PH") { | ||
printDeadline($dv, $Conf->_("%s review hard deadline", $roundname), | ||
$Conf->_("%s reviews must be submitted by this deadline.", $roundname)); | ||
} else if ($dt === "ES") { | ||
printDeadline($dv, $Conf->_("%s external review deadline", $roundname), | ||
$Conf->_("%s reviews are requested by this deadline.", $roundname)); | ||
} else if ($dt === "EH") { | ||
printDeadline($dv, $Conf->_("%s external review hard deadline", $roundname), | ||
$Conf->_("%s reviews must be submitted by this deadline.", $roundname)); | ||
} | ||
} | ||
if ($dlroundunify) { | ||
break; | ||
} | ||
} | ||
} | ||
|
||
echo "</table>\n"; | ||
|
||
$Conf->footer(); | ||
include("index.php"); |
Oops, something went wrong.