userCanManage(Auth::user()); $show_ip = isSuperUser(Auth::user()); if ($is_manager) { $add_new_contestant_form = new UOJForm('add_new_contestant_form'); $add_new_contestant_form->addInput( 'new_username', [ 'placeholder' => '用户名', 'validator_php' => function ($username, &$vdata) { $user = UOJUser::query($username); if (!$user) { return '用户不存在'; } if (UOJContest::cur()->userHasRegistered($user)) { return '该用户已经报名'; } $vdata['user'] = $user; return ''; }, ] ); $add_new_contestant_form->config['submit_container']['class'] = 'mt-3 text-center'; $add_new_contestant_form->config['submit_button']['class'] = 'btn btn-secondary'; $add_new_contestant_form->config['submit_button']['text'] = '注册该用户'; $add_new_contestant_form->handle = function (&$vdata) { UOJContest::cur()->userRegister($vdata['user']); }; $add_new_contestant_form->runAtServer(); $add_group_to_contest_form = new UOJForm('add_group_to_contest'); $add_group_to_contest_form->addInput( 'group_id', [ 'placeholder' => '小组 ID', 'validator_php' => function ($group_id, &$vdata) { $group = UOJGroup::query($group_id); if (!$group) { return '小组不存在'; } $vdata['group'] = $group; return ''; }, ] ); $add_group_to_contest_form->config['submit_container']['class'] = 'mt-3 text-center'; $add_group_to_contest_form->config['submit_button']['class'] = 'btn btn-secondary'; $add_group_to_contest_form->config['submit_button']['text'] = '注册该小组中的用户'; $add_group_to_contest_form->handle = function (&$vdata) { $usernames = $vdata['group']->getUsernames(); foreach ($usernames as $username) { $user = UOJUser::query($username); UOJContest::cur()->userRegister($user); } }; $add_group_to_contest_form->runAtServer(); $remove_user_from_contest_form = new UOJForm('remove_user_from_contest'); $remove_user_from_contest_form->addInput( 'remove_username', [ 'placeholder' => '用户名', 'validator_php' => function ($username, &$vdata) { $user = UOJUser::query($username); if (!$user) { return '用户不存在'; } if (!UOJContest::cur()->userHasRegistered($user)) { return '该用户未报名'; } $vdata['user'] = $user; return ''; }, ] ); $remove_user_from_contest_form->config['submit_container']['class'] = 'mt-3 text-center'; $remove_user_from_contest_form->config['submit_button']['class'] = 'btn btn-danger'; $remove_user_from_contest_form->config['submit_button']['text'] = '移除该用户'; $remove_user_from_contest_form->handle = function (&$vdata) { UOJContest::cur()->userUnregister($vdata['user']); }; $remove_user_from_contest_form->runAtServer(); $force_set_user_participated_form = new UOJForm('force_set_user_participated'); $force_set_user_participated_form->addInput( 'force_set_username', [ 'placeholder' => '用户名', 'validator_php' => function ($username, &$vdata) { $user = UOJUser::query($username); if (!$user) { return '用户不存在'; } if (!UOJContest::cur()->userHasRegistered($user)) { return '该用户未报名'; } $vdata['user'] = $user; return ''; }, ] ); $force_set_user_participated_form->config['submit_container']['class'] = 'mt-3 text-center'; $force_set_user_participated_form->config['submit_button']['class'] = 'btn btn-warning'; $force_set_user_participated_form->config['submit_button']['text'] = '强制参赛'; $force_set_user_participated_form->handle = function (&$vdata) { UOJContest::cur()->markUserAsParticipated($vdata['user']); }; $force_set_user_participated_form->runAtServer(); } if ($contest['cur_progress'] == CONTEST_NOT_STARTED) { $iHasRegistered = UOJContest::cur()->userHasRegistered(Auth::user()); if ($iHasRegistered) { if ($iHasRegistered && UOJContest::cur()->freeRegistration()) { $unregister_form = new UOJForm('unregister'); $unregister_form->handle = function () { UOJContest::cur()->userUnregister(Auth::user()); }; $unregister_form->config['submit_container']['class'] = 'text-end'; $unregister_form->config['submit_button']['class'] = 'btn btn-danger btn-xs'; $unregister_form->config['submit_button']['text'] = '取消报名'; $unregister_form->succ_href = "/contests"; $unregister_form->runAtServer(); } } } ?>

progress() == CONTEST_NOT_STARTED) : ?>
已报名
printHTML() ?>
当前尚未报名,您可以 报名
'; $header_row .= '#' . UOJLocale::get('username') . ''; if ($show_ip) { $header_row .= 'remote_addrhttp_x_forwarded_for'; } if ($is_manager) { $header_row .= '是否参赛'; } $header_row .= ''; echoLongTable( ['*'], 'contests_registrants', ['contest_id' => $contest['id']], 'order by username desc', $header_row, function ($contestant, $num) use ($is_manager, $show_ip) { $user = UOJUser::query($contestant['username']); echo ''; echo '' . $num . ''; echo '' . UOJUser::getLink($user) . ''; if ($show_ip) { echo '' . $user['remote_addr'] . ''; echo '' . $user['http_x_forwarded_for'] . ''; } if ($is_manager) { echo '' . ($contestant['has_participated'] ? 'Yes' : 'No') . ''; } echo ''; }, [ 'page_len' => 50, 'get_row_index' => '', 'div_classes' => ['table-responsive', 'card', 'mb-3'], 'table_classes' => ['table', 'uoj-table', 'mb-0', 'text-center'], ] ); ?>
添加参赛者
printHTML() ?>
小组报名
printHTML() ?>
移除选手
printHTML() ?>
强制参赛
printHTML() ?>