userCanView(Auth::user(), ['ensure' => true]); if (!UOJProblem::cur()->userCanManage(Auth::user())) { UOJProblem::cur()->userPermissionCodeCheck(Auth::user(), UOJProblem::cur()->getExtraConfig('view_solution_type')) || UOJResponse::page403(); foreach (UOJProblem::cur()->findInContests() as $cp) { if ($cp->contest->progress() == CONTEST_IN_PROGRESS && $cp->contest->userHasRegistered(Auth::user())) { UOJResponse::page403(); } } } if (UOJRequest::post('submit-remove_solution') === 'remove_solution') { crsf_defend(); $blog = UOJBlog::query(UOJRequest::post('blog_id')); if (!$blog || !$blog->userCanView(Auth::user())) { dieWithAlert('博客不存在。'); } if (!UOJProblem::cur()->userCanManage(Auth::user()) && $blog->info['poster'] != Auth::id()) { dieWithAlert('您没有权限移除该题解。'); } if ($blog->info['poster'] != Auth::id()) { sendSystemMsg( $blog->info['poster'], '题解移除通知', "

" . UOJUser::getLink($blog->info['poster']) . " 您好:

" . "

您为问题 " . UOJProblem::cur()->getLink(['with' => 'id']) . " 提交的题解 " . $blog->getLink() . " 已被" . (isSuperUser(Auth::user()) ? "管理员" : " " . UOJUser::getLink(Auth::user()) . " ") . "移除。

" ); } DB::delete([ "delete from problems_solutions", "where", [ "problem_id" => UOJProblem::info('id'), "blog_id" => $blog->info['id'], ], ]); dieWithAlert('移除成功!'); } if (UOJProblem::cur()->userCanManage(Auth::user()) || UOJProblem::cur()->userPermissionCodeCheck(Auth::user(), UOJProblem::cur()->getExtraConfig('submit_solution_type'))) { $add_new_solution_form = new UOJForm('add_new_solution'); $add_new_solution_form->addInput('blog_id_2', [ 'div_class' => 'flex-grow-1', 'placeholder' => '博客 ID', 'validator_php' => function ($blog_id, &$vdata) { $blog = UOJBlog::query($blog_id); if (!$blog) { return '博客不存在'; } if (!$blog->userCanManage(Auth::user())) { if ($blog->info['poster'] != Auth::id()) { if ($blog->info['is_hidden']) { return '博客不存在'; } return '只能提交本人撰写的博客'; } } if (!UOJProblem::cur()->userCanManage(Auth::user())) { if ($blog->info['is_hidden']) { return '只能提交公开的博客'; } } if ($problem_id = $blog->getSolutionProblemId()) { return "该博客已经是题目 #$problem_id 的题解"; } $vdata['blog'] = $blog; return ''; }, ]); $add_new_solution_form->config['form']['class'] = 'd-flex'; $add_new_solution_form->config['submit_container']['class'] = 'ms-2'; $add_new_solution_form->config['submit_button']['text'] = '发布'; $add_new_solution_form->handle = function (&$vdata) { DB::insert([ "insert into problems_solutions", DB::bracketed_fields(["problem_id", "blog_id"]), "values", DB::tuple([UOJProblem::info('id'), $vdata['blog']->info['id']]), ]); }; $add_new_solution_form->runAtServer(); if (UOJUser::checkPermission(Auth::user(), 'blogs.create')) { $quick_add_new_solution_form = new UOJForm('quick_add_new_solution'); $quick_add_new_solution_form->config['submit_container']['class'] = ''; $quick_add_new_solution_form->config['submit_button']['class'] = 'btn btn-link text-decoration-none p-0'; $quick_add_new_solution_form->config['submit_button']['text'] = '快速新建文章'; $quick_add_new_solution_form->handle = function () { DB::insert([ "insert into blogs", "(title, content, content_md, poster, is_hidden, post_time, active_time)", "values", DB::tuple([ '【题解】' . UOJProblem::cur()->getTitle(), '', '', Auth::id(), false, DB::now(), DB::now() ]) ]); $blog_id = DB::insert_id(); DB::insert([ "insert into problems_solutions", DB::bracketed_fields(["problem_id", "blog_id"]), "values", DB::tuple([UOJProblem::info('id'), $blog_id]), ]); redirectTo(HTML::blog_url(Auth::id(), "/post/{$blog_id}/write")); die(); }; $quick_add_new_solution_form->runAtServer(); } } $pag_config = [ 'page_len' => 5, 'col_names' => ['blog_id', 'zan'], 'table_name' => 'problems_solutions inner join blogs on blogs.id = problems_solutions.blog_id', 'cond' => ["problem_id" => UOJProblem::info('id')], 'post_filter' => function ($row) { $blog = UOJBlog::query($row['blog_id']); // 根据实际使用需要,题目管理员可以通过题解页面看到其他用户提交的题解,并且即使该题解对应的博客是隐藏状态也会照常显示 // 如需仅允许超级管理员查看,请将下一行改为 return $blog->userCanView(Auth::user()); return $blog->userCanView(Auth::user()) || UOJProblem::cur()->userCanManage(Auth::user()); }, ]; $pag_config['tail'] = "order by zan desc, post_time desc, id asc"; $pag = new Paginator($pag_config); ?> getTitle(['with' => 'id']))) ?>

getTitle(['with' => 'id']) ?>

    get() as $row) : ?> info['poster']); ?>
  • : info['is_hidden']) : ?>
    queryContent()['content'] ?>
      userCanManage(Auth::user()) || $poster['username'] == Auth::id()) : ?>
    • userCanManage(Auth::user())) : ?>
    • 修改
    • 在 Ta 的博客上查看
    • info['id'], $blog->info['zan']) ?>
  • isEmpty()) : ?>
    暂无题解
pagination() ?>