Пример #1
0
function parse_value($sv, $name, $info)
{
    global $Conf, $Me, $Now, $Opt;
    if (!isset($sv->req[$name])) {
        $xname = str_replace(".", "_", $name);
        if (isset($sv->req[$xname])) {
            $sv->req[$name] = $sv->req[$xname];
        } else {
            if ($info->type === "checkbox" || $info->type === "cdate") {
                return 0;
            } else {
                return null;
            }
        }
    }
    $v = trim($sv->req[$name]);
    if ($info->placeholder && $info->placeholder === $v || $info->invalid_value && $info->invalid_value === $v) {
        $v = "";
    }
    if ($info->type === "checkbox") {
        return $v != "" ? 1 : 0;
    } else {
        if ($info->type === "cdate" && $v == "1") {
            return 1;
        } else {
            if ($info->type === "date" || $info->type === "cdate" || $info->type === "ndate") {
                if ($v == "" || !strcasecmp($v, "N/A") || !strcasecmp($v, "same as PC") || $v == "0" || $info->type !== "ndate" && !strcasecmp($v, "none")) {
                    return -1;
                } else {
                    if (!strcasecmp($v, "none")) {
                        return 0;
                    } else {
                        if (($v = $Conf->parse_time($v)) !== false) {
                            return $v;
                        } else {
                            $err = unparse_setting_error($info, "Invalid date.");
                        }
                    }
                }
            } else {
                if ($info->type === "grace") {
                    if (($v = parseGrace($v)) !== null) {
                        return intval($v);
                    } else {
                        $err = unparse_setting_error($info, "Invalid grace period.");
                    }
                } else {
                    if ($info->type === "int" || $info->type === "zint") {
                        if (preg_match("/\\A[-+]?[0-9]+\\z/", $v)) {
                            return intval($v);
                        } else {
                            $err = unparse_setting_error($info, "Should be a number.");
                        }
                    } else {
                        if ($info->type === "string") {
                            // Avoid storing the default message in the database
                            if (substr($name, 0, 9) == "mailbody_") {
                                $t = expandMailTemplate(substr($name, 9), true);
                                $v = cleannl($v);
                                if ($t["body"] == $v) {
                                    return "";
                                }
                            }
                            return $v;
                        } else {
                            if ($info->type === "simplestring") {
                                return simplify_whitespace($v);
                            } else {
                                if ($info->type === "tag" || $info->type === "tagbase") {
                                    $tagger = new Tagger($Me);
                                    $v = trim($v);
                                    if ($v === "" && $info->optional) {
                                        return $v;
                                    }
                                    $v = $tagger->check($v, $info->type === "tagbase" ? Tagger::NOVALUE : 0);
                                    if ($v) {
                                        return $v;
                                    }
                                    $err = unparse_setting_error($info, $tagger->error_html);
                                } else {
                                    if ($info->type === "emailheader") {
                                        $v = MimeText::encode_email_header("", $v);
                                        if ($v !== false) {
                                            return $v == "" ? "" : MimeText::decode_header($v);
                                        }
                                        $err = unparse_setting_error($info, "Invalid email header.");
                                    } else {
                                        if ($info->type === "emailstring") {
                                            $v = trim($v);
                                            if ($v === "" && $info->optional) {
                                                return "";
                                            } else {
                                                if (validate_email($v) || $v === $v_active) {
                                                    return $v;
                                                } else {
                                                    $err = unparse_setting_error($info, "Invalid email.");
                                                }
                                            }
                                        } else {
                                            if ($info->type === "urlstring") {
                                                $v = trim($v);
                                                if ($v === "" && $info->optional || preg_match(',\\A(?:https?|ftp)://\\S+\\z,', $v)) {
                                                    return $v;
                                                } else {
                                                    $err = unparse_setting_error($info, "Invalid URL.");
                                                }
                                            } else {
                                                if ($info->type === "htmlstring") {
                                                    if (($v = CleanHTML::basic_clean($v, $err)) === false) {
                                                        $err = unparse_setting_error($info, $err);
                                                    } else {
                                                        if ($info->message_default && $v === $Conf->message_default_html($info->message_default)) {
                                                            return "";
                                                        } else {
                                                            return $v;
                                                        }
                                                    }
                                                } else {
                                                    if ($info->type === "radio") {
                                                        foreach ($info->values as $allowedv) {
                                                            if ((string) $allowedv === $v) {
                                                                return $allowedv;
                                                            }
                                                        }
                                                        $err = unparse_setting_error($info, "Parse error (unexpected value).");
                                                    } else {
                                                        return $v;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    $sv->set_error($name, $err);
    return null;
}
Пример #2
0
 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"));
 }