S2OJ/web/app/controllers/group.php

162 lines
4.0 KiB
PHP
Raw Normal View History

2022-03-20 00:07:46 +00:00
<?php
2022-10-21 12:42:48 +00:00
requireLib('bootstrap5');
2022-03-20 00:07:46 +00:00
requirePHPLib('form');
requirePHPLib('judger');
requirePHPLib('data');
2022-11-06 02:26:21 +00:00
if (!Auth::check()) {
redirectToLogin();
2022-04-03 10:18:17 +00:00
}
2022-03-20 00:07:46 +00:00
$group_id = $_GET['id'];
2022-09-26 03:26:17 +00:00
if (!validateUInt($group_id) || !($group = queryGroup($group_id))) {
become404Page();
2022-03-20 00:07:46 +00:00
}
2022-09-26 04:09:54 +00:00
2022-10-21 12:42:48 +00:00
if (!isSuperUser($myUser) && $group['is_hidden']) {
become403Page();
2022-09-26 04:09:54 +00:00
}
2022-09-18 04:58:35 +00:00
?>
2022-03-20 00:07:46 +00:00
<?php echoUOJPageHeader(UOJLocale::get('groups')) ?>
2022-09-26 04:09:54 +00:00
<div class="row">
2022-10-21 12:42:48 +00:00
<!-- left col -->
2022-09-26 23:57:01 +00:00
<div class="col-lg-9">
2022-09-26 04:09:54 +00:00
2022-10-21 12:42:48 +00:00
<!-- title -->
<div class="d-flex justify-content-between">
2022-11-06 02:26:21 +00:00
<h1>
2022-09-26 04:09:54 +00:00
<?php if ($group['is_hidden']): ?>
<span class="fs-5 text-danger">[隐藏]</span>
<?php endif ?>
<?= $group['title'] ?>
<span class="fs-5">(ID: #<?= $group['id'] ?>)</span>
</h1>
2022-03-20 00:07:46 +00:00
2022-09-26 03:26:17 +00:00
<?php if (isSuperUser($myUser)): ?>
2022-09-26 04:09:54 +00:00
<div class="text-end">
<a class="btn btn-primary" href="/group/<?= $group['id'] ?>/manage" role="button">
<?= UOJLocale::get('problems::manage') ?>
</a>
</div>
<?php endif ?>
2022-10-21 12:42:48 +00:00
</div>
<!-- end title -->
2022-09-26 03:26:17 +00:00
2022-10-21 12:42:48 +00:00
<!-- main content -->
<div class="card mb-3">
<div class="card-body">
2022-11-06 02:26:21 +00:00
<h2 class="h3">
2022-10-21 12:42:48 +00:00
<?= UOJLocale::get('group announcement') ?>
</h2>
<?php if ($group['announcement']): ?>
<div class="text-break">
<?= HTML::purifier_inline()->purify(HTML::parsedown()->line($group['announcement'])) ?>
</div>
<?php else: ?>
<div class="text-muted">
<?= UOJLocale::get('none') ?>
</div>
<?php endif ?>
</div>
2022-09-26 04:09:54 +00:00
</div>
2022-10-21 12:42:48 +00:00
<div class="card mb-3">
2022-09-26 04:09:54 +00:00
<div class="card-body">
2022-11-06 02:26:21 +00:00
<h2 class="card-title h3">
2022-09-26 04:09:54 +00:00
<?= UOJLocale::get('news') ?>
</h5>
2022-10-21 12:42:48 +00:00
<ul class="mb-0">
2022-03-20 00:07:46 +00:00
<?php
2022-09-26 04:09:54 +00:00
$current_ac = queryGroupCurrentAC($group['id']);
2022-09-18 04:58:35 +00:00
foreach ($current_ac as $ac) {
echo '<li>';
echo getUserLink($ac['submitter']);
echo ' 解决了问题 ';
2022-10-21 12:42:48 +00:00
echo '<a class="text-decoration-none" href="/problem/', $ac['problem_id'], '">', $ac['problem_title'], '</a> ';
2022-09-18 04:58:35 +00:00
echo '<time class="time">(', $ac['submit_time'], ')</time>';
echo '</li>';
}
2022-09-20 00:28:38 +00:00
if (count($current_ac) == 0) {
echo '暂无最新动态';
}
?>
</ul>
</div>
</div>
2022-09-26 04:09:54 +00:00
<div class="card card-default mb-3">
<div class="card-body">
2022-11-06 02:26:21 +00:00
<h2 class="card-title h3">
2022-09-26 04:09:54 +00:00
<?= UOJLocale::get('assignments') ?>
</h5>
2022-10-23 05:58:34 +00:00
<?php
echoLongTable(
[
'groups_assignments.list_id as list_id',
'lists.title as title',
'groups_assignments.end_time as end_time'
],
'groups_assignments left join lists on lists.id = groups_assignments.list_id',
"groups_assignments.group_id = {$group['id']} and groups_assignments.end_time > addtime(now(), '-168:00:00')",
'order by end_time desc, list_id desc',
<<<EOD
<tr>
<th style="width:3em" class="text-center">ID</th>
<th style="width:12em">标题</th>
<th style="width:4em">状态</th>
<th style="width:8em">结束时间</th>
</tr>
2022-10-21 12:42:48 +00:00
EOD,
2022-10-23 05:58:34 +00:00
function($row) use ($group) {
$end_time = DateTime::createFromFormat('Y-m-d H:i:s', $row['end_time']);
echo '<tr>';
echo '<td class="text-center">', $row['list_id'], '</td>';
echo '<td>', '<a class="text-decoration-none" href="/group/', $group['id'], '/assignment/', $row['list_id'],'">', HTML::escape($row['title']), '</a>', '</td>';
if ($end_time < UOJTime::$time_now) {
echo '<td class="text-danger">已结束</td>';
} else {
echo '<td class="text-success">进行中</td>';
}
echo '<td>', $end_time->format('Y-m-d H:i:s'), '</td>';
echo '</tr>';
},
[
'echo_full' => true,
'div_classes' => ['table-responsive'],
'table_classes' => ['table', 'align-middle', 'mb-0'],
]
);
2022-09-18 04:58:35 +00:00
?>
2022-03-20 00:07:46 +00:00
</div>
</div>
2022-09-26 04:09:54 +00:00
<div class="card card-default mb-3">
<div class="card-body">
2022-11-06 02:26:21 +00:00
<h2 class="card-title h3">
2022-09-26 04:09:54 +00:00
<?= UOJLocale::get('top solver') ?>
</h5>
2022-10-21 12:42:48 +00:00
<?php echoRanklist([
'page_len' => 50,
2022-09-26 04:09:54 +00:00
'group_id' => $group_id,
'by_accepted' => true,
'div_classes' => ['table-responsive', 'mb-3'],
2022-10-21 12:42:48 +00:00
'table_classes' => ['table', 'text-center', 'mb-0'],
]) ?>
2022-03-21 02:51:31 +00:00
</div>
</div>
2022-10-19 03:57:06 +00:00
<!-- end left col -->
2022-09-26 04:09:54 +00:00
</div>
2022-10-19 03:57:06 +00:00
<!-- right col -->
<aside class="col-lg-3 mt-3 mt-lg-0">
2022-10-21 12:42:48 +00:00
<?php uojIncludeView('sidebar'); ?>
2022-09-26 04:09:54 +00:00
</aside>
</div>
2022-03-20 00:07:46 +00:00
<?php echoUOJPageFooter() ?>