function expandMailTemplate($name, $default)
{
    global $null_mailer;
    if (!isset($null_mailer)) {
        $null_mailer = new HotCRPMailer(null, null, array("width" => false));
    }
    return $null_mailer->expand_template($name, $default);
}
                echo "&nbsp; (<a class='q' href=\"" . hoturl("search", "q=pri:" . urlencode($pc->email)) . "\">{$numPrimary} primary</a>)";
            }
        }
        echo "</div><hr class=\"c\" /></div></div>\n";
    }
    echo "</div>\n", "<div class='aa' style='margin-bottom:0'>", Ht::submit("update", "Save assignments", array("class" => "bb")), " &nbsp;", Ht::submit("cancel", "Cancel"), " <span id='assresult' style='padding-left:1em'></span></div>\n\n", '</div></form>';
}
echo "</div></div>\n";
// add external reviewers
echo Ht::form($loginUrl), '<div class="aahc revcard"><div class="revcard_head">', "<h3>Request an external review</h3>\n", "<div class='hint'>External reviewers get access to their assigned papers, including ";
if (setting("extrev_view") >= 2) {
    echo "the other reviewers' identities and ";
}
echo "any eventual decision.  Before requesting an external review,\n you should generally check personally whether they are interested.";
if ($Me->allow_administer($prow)) {
    echo "\nTo create a review with no associated reviewer, leave Name and Email blank.";
}
echo '</div></div><div class="revcard_body">';
echo "<div class='f-i'><div class='f-ix'>\n  <div class='f-c'>Name</div>\n  <div class='f-e'><input type='text' name='name' value=\"", htmlspecialchars(defval($_REQUEST, "name", "")), "\" size='32' tabindex='1' /></div>\n</div><div class='f-ix'>\n  <div class='f-c", isset($Error["email"]) ? " error" : "", "'>Email</div>\n  <div class='f-e'><input type='text' name='email' value=\"", htmlspecialchars(defval($_REQUEST, "email", "")), "\" size='28' tabindex='1' /></div>\n</div><hr class=\"c\" /></div>\n\n";
// reason area
$null_mailer = new HotCRPMailer();
$reqbody = $null_mailer->expand_template("requestreview", false);
if (strpos($reqbody["body"], "%REASON%") !== false) {
    echo "<div class='f-i'>\n  <div class='f-c'>Note to reviewer <span class='f-cx'>(optional)</span></div>\n  <div class='f-e'>", Ht::textarea("reason", @$_REQUEST["reason"], array("class" => "papertext", "rows" => 2, "cols" => 60, "tabindex" => 1, "spellcheck" => "true")), "</div><hr class=\"c\" /></div>\n\n";
}
echo "<div class='f-i'>\n", Ht::submit("add", "Request review", array("tabindex" => 2)), "</div>\n\n";
if ($Me->can_administer($prow)) {
    echo "<div class='f-i'>\n  ", Ht::checkbox("override"), "&nbsp;", Ht::label("Override deadlines and any previous refusal"), "\n</div>\n";
}
echo "</div></div></form>\n";
$Conf->footer();
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"];
}
echo "<table class='fx'><tr><td>", Ht::checkbox("requestreview_notify", 1, true), "&nbsp;</td><td>", Ht::label("Send email to external reviewers:"), "</td></tr>\n<tr><td></td><td>", Ht::textarea("requestreview_body", $t, array("class" => "tt", "cols" => 80, "rows" => 20, "spellcheck" => "true")), "</td></tr></table>\n";
echo '<div class="g"></div><div class="aa">', Ht::submit("Prepare assignments"), " &nbsp; <span class='hint'>You’ll be able to check the assignment before it is saved.</span></div>\n";
echo '<div style="margin-top:1.5em"><a href="', hoturl_post("search", "t=manager&q=&get=pcassignments&p=all"), '">Download current PC assignments</a></div>';
echo "</div></form>\n\n<hr style='margin-top:1em' />\n\n<div class='helppagetext'>\n<h3>Instructions</h3>\n\n<p>Upload a comma-separated value file to prepare an assignment of reviews,\nconflicts, leads, shepherds, and tags. HotCRP calculates the minimal changes\nbetween the current state and the requested assignment; you’ll confirm those\nchanges before they are committed.</p>\n\n<p>A simple example:</p>\n\n<pre class='entryexample'>paper,assignment,email\n1,primary,man@alice.org\n2,secondary,slugger@manny.com\n1,primary,slugger@manny.com</pre>\n\n<p>This assigns PC members man@alice.org and slugger@manny.com as primary\nreviewers for paper #1, and slugger@manny.com as a secondary\nreviewer for paper #2. Errors will be reported if those users aren’t PC\nmembers, or if they have conflicts with their assigned papers.</p>\n\n<p>A more complex example:</p>\n\n<pre class='entryexample'>paper,assignment,email,round\nall,clearreview,all,R2\n1,primary,man@alice.org,R2\n10,primary,slugger@manny.com,R2\n#manny OR #ramirez,primary,slugger@manny.com,R2</pre>\n\n<p>The first assignment line clears all review assignments in\nround R2. (Review assignments in other rounds are left alone.) The next\nlines assign man@alice.org as a primary reviewer for paper #1, and slugger@manny.com\nas a primary reviewer for paper #10. The last line assigns slugger@manny.com\nas a primary reviewer for all papers tagged #manny or #ramirez.</p>\n\n<p>Assignment types are:</p>\n\n<dl class=\"spaced\">\n<dt><code>review</code></dt>\n\n<dd>Assign a review. The <code>email</code> and/or <code>name</code> columns\nlocate the user. (<code>first</code> and <code>last</code> columns may be used\nin place of <code>name</code>.) The <code>reviewtype</code> column sets the\nreview type; it can be <code>primary</code>, <code>secondary</code>,\n<code>pcreview</code> (optional PC review), or <code>external</code>, or\n<code>clear</code> to unassign the review. The optional\n<code>round</code> column sets the review round.\n\n<p>Only PC members can be assigned primary, secondary, and optional PC\nreviews. Accounts will be created for new external reviewers as necessary. The\n<code>clear</code> action doesn’t delete reviews that have already been\nentered.</p>\n\n<p>Assignments can create new reviews or change existing reviews. Use\n“<code>any</code>” or “old:new” syntax in the <code>round</code> and/or\n<code>reviewtype</code> columns to restrict assignments to existing reviews.\nFor example, to create a new assignment or modify an existing review:</p>\n\n<pre class=\"entryexample\">paper,assignment,email,reviewtype,round\n1,review,drew@harvard.edu,primary,R2</pre>\n\n<p>To modify an existing review’s round (“<code>any</code>” restricts the\nassignment to existing reviews):</p>\n\n<pre class=\"entryexample\">paper,assignment,email,reviewtype,round\n1,review,drew@harvard.edu,any,R2</pre>\n\n<p>To change an existing review from round R1 to round R2:</p>\n\n<pre class=\"entryexample\">paper,assignment,email,reviewtype,round\n1,review,drew@harvard.edu,any,R1:R2</pre>\n\n<p>To change all round-R1 primary reviews to round R2:</p>\n\n<pre class=\"entryexample\">paper,assignment,email,reviewtype,round\nall,review,all,primary,R1:R2</pre>\n\n</dd>\n\n<dt><code>primary</code>, <code>secondary</code>, <code>pcreview</code>,\n<code>external</code>, <code>clearreview</code></dt>\n<dd>Like <code>review</code>, assign a primary, secondary, optional PC, or\nexternal review, or clear existing reviews.</dd>\n\n<dt><code>unsubmitreview</code></dt>\n<dd>Unsubmit a submitted review. The <code>email</code>, <code>name</code>,\n<code>reviewtype</code>, and <code>round</code> columns locate the review.</dd>\n\n<dt><code>lead</code></dt>\n<dd>Set the discussion lead. The <code>email</code>, <code>name</code>,\nand/or <code>user</code> columns locate the PC user. To clear the discussion lead,\nuse email <code>none</code> or assignment type <code>clearlead</code>.</dd>\n\n<dt><code>shepherd</code></dt>\n<dd>Set the shepherd. The <code>email</code>, <code>name</code>,\nand/or <code>user</code> columns locate the PC user. To clear the shepherd,\nuse email <code>none</code> or assignment type <code>clearshepherd</code>.</dd>\n\n<dt><code>conflict</code></dt>\n<dd>Mark a PC conflict. The <code>email</code>, <code>name</code>,\nand/or <code>user</code> columns locate the PC user. To clear a conflict,\nuse assignment type <code>clearconflict</code>.</dd>\n\n<dt><code>tag</code></dt>\n<dd>Add a tag. The <code>tag</code> column names the tag and the optional\n<code>value</code> column sets the tag value.\nTo clear a tag, use assignment type <code>cleartag</code> or value <code>none</code>.</dd>\n\n<dt><code>preference</code></dt>\n<dd>Set reviewer preference and expertise. The <code>preference</code> column\ngives the preference value.</dd>\n</dl>\n\n</div>\n";
$Conf->footerScript('$("#tsel").trigger("change");$("textarea").autogrow()');
$Conf->footer();