From ff41b8761ffe70c2f6484e7209c2360e85502be6 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Mon, 14 Nov 2022 07:44:00 +0800 Subject: [PATCH] chore(web/contest/manage): move extra_registration to rule_form --- web/app/controllers/contest_manage.php | 71 +++++--------------------- 1 file changed, 12 insertions(+), 59 deletions(-) diff --git a/web/app/controllers/contest_manage.php b/web/app/controllers/contest_manage.php index 4ede4b2..5ef3f81 100644 --- a/web/app/controllers/contest_manage.php +++ b/web/app/controllers/contest_manage.php @@ -373,6 +373,10 @@ EOD); 1 => '所有人都可以自由报名', 0 => '只能由管理员帮选手报名' ], "报名方式", $contest['extra_config']['free_registration']); + $rule_form->addVCheckboxes('extra_registration', [ + '0' => '禁止', + '1' => '允许' + ], '是否允许额外报名', isset($contest['extra_config']['extra_registration']) ? $contest['extra_config']['extra_registration'] : '1'); $rule_form->addVSelect('individual_or_team', [ 'individual' => '个人赛', 'team' => '团体赛' @@ -392,6 +396,7 @@ EOD); $contest['extra_config']['free_registration'] = (int)$_POST['free_registration']; $contest['extra_config']['individual_or_team'] = $_POST['individual_or_team']; $contest['extra_config']['max_n_submissions_per_problem'] = (int)$_POST['max_n_submissions_per_problem']; + $contest['extra_config']['extra_registration'] = (int)$_POST['extra_registration']; $esc_extra_config = json_encode($contest['extra_config']); DB::update([ @@ -521,39 +526,6 @@ function(res) { } EOD); $blog_link_contests->runAtServer(); - - $extra_registration_form = new UOJBs4Form('extra_registration_form'); - $extra_registration_form->addVCheckboxes('extra_registration', [ - '0' => '禁止', - '1' => '允许' - ], '是否允许额外报名', isset($contest['extra_config']['extra_registration']) ? $contest['extra_config']['extra_registration'] : '1'); - $extra_registration_form->handle = function () use ($contest) { - $contest['extra_config']['extra_registration'] = $_POST['extra_registration']; - $esc_extra_config = DB::escape(json_encode($contest['extra_config'])); - DB::update("UPDATE contests SET extra_config = '$esc_extra_config' WHERE id = {$contest['id']}"); - - dieWithJsonData(['status' => 'success', 'message' => $_POST['extra_registration'] ? '已允许额外报名' : '已禁止额外报名']); - }; - $extra_registration_form->setAjaxSubmit(<<runAtServer(); } ?> @@ -567,7 +539,6 @@ EOD);