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 UOJBs4Form('add_new_solution'); $add_new_solution_form->addVInput( 'blog_id_2', 'text', '博客 ID', '', function ($blog_id) { $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 的题解"; } return ''; }, null ); $add_new_solution_form->submit_button_config['text'] = '发布'; $add_new_solution_form->submit_button_config['align'] = 'center'; $add_new_solution_form->submit_button_config['class_str'] = 'btn btn-secondary'; $add_new_solution_form->handle = function () { DB::insert([ "insert into problems_solutions", DB::bracketed_fields(["problem_id", "blog_id"]), "values", DB::tuple([UOJProblem::info('id'), $_POST['blog_id_2']]), ]); }; $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() ?>