if (count($a) > 1) {
                    echo " (these sets might overlap)";
                }
                echo ".<a class='help' href='", hoturl("help", "t=revrate"), "' title='About ratings'>?</a></div>\n";
            }
        }
    }
    if ($Me->has_review()) {
        $plist = new PaperList(new PaperSearch($Me, ["q" => "re:me"]), ["list" => true]);
        $ptext = $plist->table_html("reviewerHome");
        if ($plist->count > 0) {
            echo "<div class='fx'><div class='g'></div>", $ptext, "</div>";
        }
    }
    if ($Me->is_reviewer()) {
        echo "<div class=\"homegrp fold20c\" id=\"homeactivity\" data-fold=\"true\" data-fold-session=\"foldhomeactivity\" data-onunfold=\"unfold_events(this)\">", foldbutton("homeactivity", 20), "<h4><a href=\"#\" onclick=\"return foldup(this,event,{n:20})\" class=\"x homeactivity\">Recent activity<span class='fx20'>:</span></a></h4>", "</div>";
        if (!$Conf->session("foldhomeactivity", 1)) {
            $Conf->footerScript("foldup(jQuery(\"#homeactivity\")[0],null,{n:20})");
        }
    }
    echo "</div>\n";
    ++$nhome_hr;
}
// Authored papers
if ($Me->is_author() || $Conf->timeStartPaper() > 0 || $Me->privChair || !$Me->is_reviewer()) {
    echo $nhome_hr ? $home_hr : "", '<div class="homegrp" id="homeau">';
    // Overview
    if ($Me->is_author()) {
        echo "<h4>Your Submissions: &nbsp;</h4> ";
    } else {
        echo "<h4>Submissions: &nbsp;</h4> ";
 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;
 }
 function render($sv)
 {
     global $Conf;
     $sv->echo_checkbox("rev_open", "<b>Open site for reviewing</b>");
     $sv->echo_checkbox("cmt_always", "Allow comments even if reviewing is closed");
     echo "<div class='g'></div>\n";
     $sv->echo_checkbox('pcrev_any', "PC members can review <strong>any</strong> submitted paper");
     echo "<div class='g'></div>\n";
     echo "<strong>Review anonymity:</strong> Are reviewer names hidden from authors?<br />\n";
     $sv->echo_radio_table("rev_blind", array(Conf::BLIND_ALWAYS => "Yes—reviews are anonymous", Conf::BLIND_NEVER => "No—reviewer names are visible to authors", Conf::BLIND_OPTIONAL => "Depends—reviewers decide whether to expose their names"));
     echo "<div class='g'></div>\n";
     $sv->echo_checkbox('rev_notifychair', 'Notify PC chairs of newly submitted reviews by email');
     // Deadlines
     echo "<h3 id=\"rounds\" class=\"settings g\">Deadlines &amp; rounds</h3>\n";
     echo '<p class="hint">Reviews are due by the deadline, but <em>cannot be modified</em> after the hard deadline. Most conferences don’t use hard deadlines for reviews.<br />', $sv->type_hint("date") ?: "", '</p>';
     $rounds = $Conf->round_list();
     if ($sv->use_req()) {
         for ($i = 1; isset($sv->req["roundname_{$i}"]); ++$i) {
             $rounds[$i] = get($sv->req, "deleteround_{$i}") ? ";" : trim(get_s($sv->req, "roundname_{$i}"));
         }
     }
     // prepare round selector
     $round_value = trim($sv->curv("rev_roundtag"));
     $current_round_value = $Conf->setting_data("rev_roundtag", "");
     if (preg_match('/\\A(?:|\\(none\\)|\\(no name\\)|default|unnamed|#0)\\z/i', $round_value)) {
         $round_value = "#0";
     } else {
         if (($round_number = $Conf->round_number($round_value, false)) || ($round_number = $Conf->round_number($current_round_value, false))) {
             $round_value = "#" . $round_number;
         } else {
             $round_value = $selector[$current_round_value] = $current_round_value;
         }
     }
     $round_map = edb_map(Dbl::ql("select reviewRound, count(*) from PaperReview group by reviewRound"));
     $print_round0 = true;
     if ($round_value !== "#0" && $round_value !== "" && $current_round_value !== "" && (!$sv->use_req() || isset($sv->req["roundname_0"])) && !$Conf->round0_defined()) {
         $print_round0 = false;
     }
     $selector = array();
     if ($print_round0) {
         $selector["#0"] = "unnamed";
     }
     for ($i = 1; $i < count($rounds); ++$i) {
         if ($rounds[$i] !== ";") {
             $selector["#{$i}"] = (object) array("label" => $rounds[$i], "id" => "rev_roundtag_{$i}");
         }
     }
     echo '<div id="round_container"', count($selector) == 1 ? ' style="display:none"' : '', '>', '<table id="rev_roundtag_table"><tr><td class="lxcaption">', $sv->label("rev_roundtag", "Current round"), '</td><td>', Ht::select("rev_roundtag", $selector, $round_value, $sv->sjs("rev_roundtag")), '</td></tr></table>', '<div class="hint">This round is used for new assignments.</div><div class="g"></div></div>';
     echo '<div id="roundtable">';
     $num_printed = 0;
     for ($i = 0; $i < count($rounds); ++$i) {
         if ($i ? $rounds[$i] !== ";" : $print_round0) {
             $this->echo_round($sv, $i, $i ? $rounds[$i] : "", +get($round_map, $i), count($selector) !== 1);
             ++$num_printed;
         }
     }
     echo '</div><div id="newround" style="display:none">';
     $this->echo_round($sv, '$', "", "", true);
     echo '</div><div class="g"></div>';
     echo Ht::js_button("Add round", "review_round_settings.add();hiliter(this)"), ' &nbsp; <span class="hint"><a href="', hoturl("help", "t=revround"), '">What is this?</a></span>', Ht::hidden("oldroundcount", count($Conf->round_list())), Ht::hidden("has_rev_roundtag", 1);
     for ($i = 1; $i < count($rounds); ++$i) {
         if ($rounds[$i] === ";") {
             echo Ht::hidden("roundname_{$i}", "", array("id" => "roundname_{$i}")), Ht::hidden("deleteround_{$i}", 1);
         }
     }
     Ht::stash_script("review_round_settings.init()");
     // External reviews
     echo "<h3 class=\"settings g\">External reviews</h3>\n";
     echo "<div class='g'></div>";
     $sv->echo_checkbox("extrev_chairreq", "PC chair must approve proposed external reviewers");
     $sv->echo_checkbox("pcrev_editdelegate", "PC members can edit external reviews they requested");
     echo "<div class='g'></div>\n";
     $t = expandMailTemplate("requestreview", false);
     echo "<table id='foldmailbody_requestreview' class='", $t == expandMailTemplate("requestreview", true) ? "foldc" : "foldo", "'><tr><td>", foldbutton("mailbody_requestreview"), "</td>", "<td><a href='#' onclick='return fold(\"mailbody_requestreview\")' class='q'><strong>Mail template for external review requests</strong></a>", " <span class='fx'>(<a href='", hoturl("mail"), "'>keywords</a> allowed; set to empty for default)<br /></span>\n<textarea class='tt fx' name='mailbody_requestreview' cols='80' rows='20'>", htmlspecialchars($t["body"]), "</textarea>", "</td></tr></table>\n";
     // Review visibility
     echo "<h3 class=\"settings g\">Visibility</h3>\n";
     echo "Can PC members <strong>see all reviews</strong> except for conflicts?<br />\n";
     $sv->echo_radio_table("pc_seeallrev", array(Conf::PCSEEREV_YES => "Yes", Conf::PCSEEREV_UNLESSINCOMPLETE => "Yes, unless they haven’t completed an assigned review for the same paper", Conf::PCSEEREV_UNLESSANYINCOMPLETE => "Yes, after completing all their assigned reviews", Conf::PCSEEREV_IFCOMPLETE => "Only after completing a review for the same paper"));
     echo "<div class='g'></div>\n";
     echo "Can PC members see <strong>reviewer names</strong> except for conflicts?<br />\n";
     $sv->echo_radio_table("pc_seeblindrev", array(0 => "Yes", 1 => "Only after completing a review for the same paper<br /><span class='hint'>This setting also hides reviewer-only comments from PC members who have not completed a review for the same paper.</span>"));
     echo "<div class='g'></div>";
     echo "Can external reviewers see the other reviews for their assigned papers, once they’ve submitted their own?<br />\n";
     $sv->echo_radio_table("extrev_view", array(2 => "Yes", 1 => "Yes, but they can’t see who wrote blind reviews", 0 => "No"));
     // Review ratings
     echo "<h3 class=\"settings g\">Review ratings</h3>\n";
     echo "Should HotCRP collect ratings of reviews? &nbsp; <a class='hint' href='", hoturl("help", "t=revrate"), "'>(Learn more)</a><br />\n";
     $sv->echo_radio_table("rev_ratings", array(REV_RATINGS_PC => "Yes, PC members can rate reviews", REV_RATINGS_PC_EXTERNAL => "Yes, PC members and external reviewers can rate reviews", REV_RATINGS_NONE => "No"));
 }