1<?php 2// settings.php -- HotCRP chair-only conference settings management page 3// Copyright (c) 2006-2018 Eddie Kohler; see LICENSE. 4 5require_once("src/initweb.php"); 6if (!$Me->privChair) 7 $Me->escape(); 8 9require_once("src/settingvalues.php"); 10$Sv = SettingValues::make_request($Me, $Qreq); 11$Sv->session_highlight(); 12 13function choose_setting_group($qreq, SettingValues $sv) { 14 global $Me; 15 $req_group = $qreq->group; 16 if (!$req_group && preg_match(',\A/\w+\z,', Navigation::path())) 17 $req_group = substr(Navigation::path(), 1); 18 $want_group = $req_group; 19 if (!$want_group && isset($_SESSION["sg"])) // NB not conf-specific session, global 20 $want_group = $_SESSION["sg"]; 21 $want_group = $sv->canonical_group($want_group); 22 if (!$want_group || !$sv->is_titled_group($want_group)) { 23 if ($sv->conf->can_some_author_view_review()) 24 $want_group = $sv->canonical_group("decisions"); 25 else if ($sv->conf->deadlinesAfter("sub_sub") || $sv->conf->time_review_open()) 26 $want_group = $sv->canonical_group("reviews"); 27 else 28 $want_group = $sv->canonical_group("sub"); 29 } 30 if (!$want_group) 31 $Me->escape(); 32 if ($want_group !== $req_group && !$qreq->post && $qreq->post_empty()) 33 SelfHref::redirect($qreq, ["group" => $want_group]); 34 $sv->mark_interesting_group($want_group); 35 return $want_group; 36} 37$Group = $Qreq->group = choose_setting_group($Qreq, $Sv); 38$_SESSION["sg"] = $Group; 39 40if (isset($Qreq->update) && $Qreq->post_ok()) { 41 if ($Sv->execute()) { 42 $Sv->conf->save_session("settings_highlight", $Sv->message_field_map()); 43 if (!empty($Sv->changes)) 44 $Sv->conf->confirmMsg("Changes saved."); 45 else 46 $Sv->conf->warnMsg("No changes."); 47 $Sv->report(); 48 SelfHref::redirect($Qreq); 49 } 50} 51if (isset($Qreq->cancel) && $Qreq->post_ok()) 52 SelfHref::redirect($Qreq); 53 54$Sv->crosscheck(); 55 56$group_titles = $Sv->group_titles(); 57$Conf->header("Settings ∕ <strong>" . $group_titles[$Group] . "</strong>", "settings"); 58echo Ht::unstash(); // clear out other script references 59echo $Conf->make_script_file("scripts/settings.js"), "\n"; 60 61echo Ht::form(hoturl_post("settings", "group=$Group"), array("id" => "settingsform")); 62 63echo '<div class="leftmenu-menu-container"><div class="leftmenu-list">'; 64foreach ($group_titles as $name => $title) { 65 if ($name === $Group) 66 echo '<div class="leftmenu-item-on">', $title, '</div>'; 67 else 68 echo '<div class="leftmenu-item ui js-click-child">', 69 '<a href="', hoturl("settings", "group={$name}"), '">', $title, '</a></div>'; 70} 71echo "</div></div>\n", 72 '<div class="leftmenu-content-container"><div class="leftmenu-content">'; 73 74function doActionArea($top) { 75 echo '<div class="aab aabr aabig">', 76 '<div class="aabut">', Ht::submit("update", "Save changes", ["class" => "btn btn-primary"]), '</div>', 77 '<div class="aabut">', Ht::submit("cancel", "Cancel"), '</div>', 78 '<hr class="c" /></div>'; 79} 80 81doActionArea(true); 82 83$Sv->report(isset($Qreq->update) && $Qreq->post_ok()); 84$Sv->render_group($Group); 85 86doActionArea(false); 87echo "</div></div></form>\n"; 88 89Ht::stash_script('hiliter_children("#settingsform", true)'); 90$Conf->footer(); 91