function do_setting_update($sv) { global $Conf, $Group, $Me, $Now, $Opt, $OptOverride; // parse settings foreach (Si::$all as $si) { account_value($sv, $si); } // check date relationships foreach (array("sub_reg" => "sub_sub", "final_soft" => "final_done") as $dn1 => $dn2) { list($dv1, $dv2) = [$sv->savedv($dn1), $sv->savedv($dn2)]; } if (!$dv1 && $dv2) { $sv->save($dn1, $dv2); } else { if ($dv2 && $dv1 > $dv2) { $sv->set_error($dn1, unparse_setting_error(Si::get($dn1), "Must come before " . Si::get($dn2, "short_description") . ".")); $sv->set_error($dn2); } } if ($sv->has_savedv("sub_sub")) { $sv->save("sub_update", $sv->savedv("sub_sub")); } if (get($Opt, "defaultSiteContact")) { if ($sv->has_savedv("opt.contactName") && get($Opt, "contactName") === $sv->savedv("opt.contactName")) { $sv->save("opt.contactName", null); } if ($sv->has_savedv("opt.contactEmail") && get($Opt, "contactEmail") === $sv->savedv("opt.contactEmail")) { $sv->save("opt.contactEmail", null); } } if ($sv->has_savedv("resp_active") && $sv->savedv("resp_active")) { foreach (explode(" ", $sv->newv("resp_rounds")) as $i => $rname) { $isuf = $i ? "_{$i}" : ""; if ($sv->newv("resp_open{$isuf}") > $sv->newv("resp_done{$isuf}")) { $sv->set_error("resp_open{$isuf}", unparse_setting_error(Si::get("resp_open"), "Must come before " . Si::get("resp_done", "short_description") . ".")); $sv->set_error("resp_done{$isuf}"); } } } // update 'papersub' if ($sv->has_savedv("pc_seeall")) { // see also conference.php if ($sv->savedv("pc_seeall") <= 0) { $x = "timeSubmitted>0"; } else { $x = "timeWithdrawn<=0"; } $num = Dbl::fetch_ivalue("select paperId from Paper where {$x} limit 1") ? 1 : 0; if ($num != $Conf->setting("papersub")) { $sv->save("papersub", $num); } } // Setting relationships if ($sv->has_savedv("sub_open") && $sv->newv("sub_open", 1) <= 0 && $sv->oldv("sub_open") > 0 && $sv->newv("sub_sub") <= 0) { $sv->save("sub_close", $Now); } if ($sv->has_savedv("msg.clickthrough_submit")) { $sv->save("clickthrough_submit", null); } // make settings $changedn = []; if (!$sv->has_errors() && (count($sv->savedv) || count($sv->save_callbacks))) { $tables = "Settings write"; foreach ($sv->need_lock as $t => $need) { if ($need) { $tables .= ", {$t} write"; } } $Conf->qe("lock tables {$tables}"); // load db settings, pre-crosscheck $dbsettings = array(); $result = Dbl::qe("select name, value, data from Settings"); while ($row = edb_row($result)) { $dbsettings[$row[0]] = $row; } Dbl::free($result); // apply settings foreach ($sv->save_callbacks as $si) { $p = $sv->parser($si); $p->save($sv, $si); } $dv = $aq = $av = array(); foreach ($sv->savedv as $n => $v) { if (substr($n, 0, 4) === "opt." && $v !== null) { $okey = substr($n, 4); $oldv = array_key_exists($okey, $OptOverride) ? $OptOverride[$okey] : get($Opt, $okey); $Opt[$okey] = $v[1] === null ? $v[0] : $v[1]; if ($oldv === $Opt[$okey]) { $v = null; } else { if (!array_key_exists($okey, $OptOverride)) { $OptOverride[$okey] = $oldv; } } } if ($v === null ? !isset($dbsettings[$n]) : isset($dbsettings[$n]) && (int) $dbsettings[$n][1] === $v[0] && $dbsettings[$n][2] === $v[1]) { continue; } $changedn[] = $n; if ($v !== null) { $aq[] = "(?, ?, ?)"; array_push($av, $n, $v[0], $v[1]); } else { $dv[] = $n; } } if (count($dv)) { Dbl::qe_apply("delete from Settings where name?a", array($dv)); //Conf::msg_info(Ht::pre_text_wrap(Dbl::format_query_apply("delete from Settings where name?a", array($dv)))); } if (count($aq)) { Dbl::qe_apply("insert into Settings (name, value, data) values\n\t" . join(",\n\t", $aq) . "\n\ton duplicate key update value=values(value), data=values(data)", $av); //Conf::msg_info(Ht::pre_text_wrap(Dbl::format_query_apply("insert into Settings (name, value, data) values\n\t" . join(",\n\t", $aq) . "\n\ton duplicate key update value=values(value), data=values(data)", $av))); } $Conf->qe("unlock tables"); if (count($changedn)) { $Me->log_activity("Updated settings " . join(", ", $changedn)); } $Conf->load_settings(); // contactdb may need to hear about changes to shortName if ($sv->has_savedv("opt.shortName") && get($Opt, "contactdb_dsn") && ($cdb = Contact::contactdb())) { Dbl::ql($cdb, "update Conferences set shortName=? where dbName=?", $Opt["shortName"], $Opt["dbName"]); } } // update the review form in case it's changed ReviewForm::clear_cache(); if (!$sv->has_errors()) { $Conf->save_session("settings_highlight", $sv->error_fields()); if (count($changedn)) { $Conf->confirmMsg("Changes saved."); } else { $Conf->warnMsg("No changes."); } $sv->report(); redirectSelf(); } else { SettingGroup::crosscheck($sv, $Group); $sv->report(); } }
public function num_reviews_in_progress() { if (!property_exists($this, "inProgressReviewCount")) { if (isset($this->reviewCount) && isset($this->startedReviewCount) && $this->reviewCount === $this->startedReviewCount) { $this->inProgressReviewCount = $this->reviewCount; } else { $this->inProgressReviewCount = Dbl::fetch_ivalue("select count(*) from PaperReview where paperId={$this->paperId} and reviewSubmitted is null and reviewModified>0"); } } return (int) $this->inProgressReviewCount; }
} } $cf->reportMessages(); if ($ajax) { $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) . "'";
function update_schema_version($n) { if (!$n) { $n = Dbl::fetch_ivalue("select value from Settings where name='allowPaperOption'"); } if ($n && Dbl::ql("update Settings set value={$n} where name='allowPaperOption'")) { $this->sversion = $this->settings["allowPaperOption"] = $n; return true; } else { return false; } }
function fetch_ivalue() { return Dbl::fetch_ivalue(Dbl::do_query_on($this->dblink, func_get_args(), Dbl::F_ERROR)); }
function parse($sv, $si) { global $Conf; if (!isset($sv->req["rev_roundtag"])) { $sv->save("rev_roundtag", null); return false; } // round names $roundnames = $roundnames_set = array(); $roundname0 = $round_deleted = null; for ($i = 0; isset($sv->req["roundname_{$i}"]) || isset($sv->req["deleteround_{$i}"]) || !$i; ++$i) { $rname = trim(get_s($sv->req, "roundname_{$i}")); if ($rname === "(no name)" || $rname === "default" || $rname === "unnamed") { $rname = ""; } if ((get($sv->req, "deleteround_{$i}") || $rname === "") && $i) { $roundnames[] = ";"; if (Dbl::fetch_ivalue("select reviewId from PaperReview where reviewRound={$i} limit 1")) { $this->rev_round_changes[] = array($i, 0); } if ($round_deleted === null && !isset($sv->req["roundname_0"]) && $i < $sv->req["oldroundcount"]) { $round_deleted = $i; } } else { if ($rname === "") { /* ignore */ } else { if ($rerror = Conf::round_name_error($rname)) { $sv->set_error("roundname_{$i}", $rerror); } else { if ($i == 0) { $roundname0 = $rname; } else { if (get($roundnames_set, strtolower($rname))) { $roundnames[] = ";"; $this->rev_round_changes[] = array($i, $roundnames_set[strtolower($rname)]); } else { $roundnames[] = $rname; $roundnames_set[strtolower($rname)] = $i; } } } } } } if ($roundname0 && !get($roundnames_set, strtolower($roundname0))) { $roundnames[] = $roundname0; $roundnames_set[strtolower($roundname0)] = count($roundnames); } if ($roundname0) { array_unshift($this->rev_round_changes, array(0, $roundnames_set[strtolower($roundname0)])); } // round deadlines foreach ($Conf->round_list() as $i => $rname) { $suffix = $i ? "_{$i}" : ""; foreach (Conf::$review_deadlines as $k) { $sv->save($k . $suffix, null); } } $rtransform = array(); if ($roundname0 && ($ri = $roundnames_set[strtolower($roundname0)]) && !isset($sv->req["pcrev_soft_{$ri}"])) { $rtransform[0] = "_{$ri}"; $rtransform[$ri] = false; } if ($round_deleted) { $rtransform[$round_deleted] = ""; if (!isset($rtransform[0])) { $rtransform[0] = false; } } for ($i = 0; $i < count($roundnames) + 1; ++$i) { if ((isset($rtransform[$i]) || ($i ? $roundnames[$i - 1] !== ";" : !isset($sv->req["deleteround_0"]))) && get($rtransform, $i) !== false) { $isuffix = $i ? "_{$i}" : ""; if (($osuffix = get($rtransform, $i)) === null) { $osuffix = $isuffix; } $ndeadlines = 0; foreach (Conf::$review_deadlines as $k) { $v = parse_value($sv, $k . $isuffix, Si::get($k)); $sv->save($k . $osuffix, $v <= 0 ? null : $v); $ndeadlines += $v > 0; } if ($ndeadlines == 0 && $osuffix) { $sv->save("pcrev_soft{$osuffix}", 0); } foreach (array("pcrev_", "extrev_") as $k) { list($soft, $hard) = ["{$k}soft{$osuffix}", "{$k}hard{$osuffix}"]; list($softv, $hardv) = [$sv->savedv($soft), $sv->savedv($hard)]; if (!$softv && $hardv) { $sv->save($soft, $hardv); } else { if ($hardv && $softv > $hardv) { $desc = $i ? ", round " . htmlspecialchars($roundnames[$i - 1]) : ""; $sv->set_error($soft, Si::get("{$k}soft", "short_description") . $desc . ": Must come before " . Si::get("{$k}hard", "short_description") . "."); $sv->set_error($hard); } } } } } // round list (save after deadlines processing) while (count($roundnames) && $roundnames[count($roundnames) - 1] === ";") { array_pop($roundnames); } $sv->save("tag_rounds", join(" ", $roundnames)); // default round $t = trim($sv->req["rev_roundtag"]); $sv->save("rev_roundtag", null); if (preg_match('/\\A(?:|\\(none\\)|\\(no name\\)|default|unnamed)\\z/i', $t)) { /* do nothing */ } else { if ($t === "#0") { if ($roundname0) { $sv->save("rev_roundtag", $roundname0); } } else { if (preg_match('/^#[1-9][0-9]*$/', $t)) { $rname = get($roundnames, substr($t, 1) - 1); if ($rname && $rname !== ";") { $sv->save("rev_roundtag", $rname); } } else { if (!($rerror = Conf::round_name_error($t))) { $sv->save("rev_roundtag", $t); } else { $sv->set_error("rev_roundtag", $rerror); } } } } if (count($this->rev_round_changes)) { $sv->need_lock["PaperReview"] = true; return true; } else { return false; } }