S2OJ/web/app/controllers/group.php

192 lines
4.6 KiB
PHP
Raw Normal View History

2022-03-20 00:07:46 +00:00
<?php
requirePHPLib('form');
requirePHPLib('judger');
requirePHPLib('data');
2022-04-03 10:18:17 +00:00
if (!Auth::check()) {
redirectToLogin();
2022-04-03 10:18:17 +00:00
}
if (!isNormalUser($myUser)) {
become403Page();
}
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
if (!isset($_COOKIE['bootstrap4'])) {
$REQUIRE_LIB['bootstrap5'] = '';
}
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
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<div class="row">
2022-09-26 23:57:01 +00:00
<div class="col-lg-9">
2022-09-26 04:09:54 +00:00
<div class="d-flex justify-content-between">
<?php endif ?>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<h1 class="h2">
<?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>
<?php else: ?>
2022-03-20 00:07:46 +00:00
<h2 style="margin-top: 24px"><?= $group['title'] ?></h2>
<p>(<b>小组 ID</b>: <?= $group['id'] ?>)</p>
2022-09-26 04:09:54 +00:00
<?php endif ?>
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
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<div class="text-end">
<a class="btn btn-primary" href="/group/<?= $group['id'] ?>/manage" role="button">
<?= UOJLocale::get('problems::manage') ?>
</a>
</div>
<?php else: ?>
2022-09-26 03:26:17 +00:00
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item"><a class="nav-link" href="/group/<?= $group['id'] ?>/manage" role="tab">管理</a></li>
</ul>
<?php endif ?>
2022-09-26 04:09:54 +00:00
<?php endif ?>
2022-09-26 03:26:17 +00:00
2022-09-26 04:09:54 +00:00
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
</div>
<?php endif ?>
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<div class="card card-default mb-3">
<div class="card-body">
<h2 class="card-title h4">
<?php else: ?>
2022-03-20 00:07:46 +00:00
<div class="row">
<div class="col-sm-12 mt-4">
2022-09-26 04:09:54 +00:00
<h5>
<?php endif ?>
<?= UOJLocale::get('news') ?>
</h5>
<ul
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
class="mb-0"
<?php endif ?>
>
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-09-26 04:09:54 +00:00
echo '<a ';
if (isset($REQUIRE_LIB['bootstrap5'])) {
echo ' class="text-decoration-none" ';
}
echo ' 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
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<div class="card card-default mb-3">
<div class="card-body">
<h2 class="card-title h4">
<?php else: ?>
2022-09-20 00:28:38 +00:00
<div class="row">
<div class="col-sm-12 mt-4">
2022-09-26 04:09:54 +00:00
<h5>
<?php endif ?>
<?= UOJLocale::get('assignments') ?>
</h5>
<ul
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
class="mb-0"
<?php endif ?>
>
2022-09-20 00:28:38 +00:00
<?php
2022-09-26 04:09:54 +00:00
$assignments = queryGroupActiveAssignments($group['id']);
2022-09-20 00:28:38 +00:00
foreach ($assignments as $ass) {
$ddl = DateTime::createFromFormat('Y-m-d H:i:s', $ass['deadline']);
$create_time = DateTime::createFromFormat('Y-m-d H:i:s', $ass['create_time']);
$now = new DateTime();
echo '<li>';
2022-09-26 04:09:54 +00:00
echo '<a ';
if (isset($REQUIRE_LIB['bootstrap5'])) {
echo ' class="text-decoration-none" ';
}
echo ' href="/problem_list/', $ass['list_id'], '">', $ass['title'], ' (题单 #', $ass['list_id'], ')</a>';
2022-09-20 00:28:38 +00:00
if ($ddl < $now) {
echo '<sup style="color:red">&nbsp;overdue</sup>';
} elseif ($ddl->getTimestamp() - $now->getTimestamp() < 86400) { // 1d
echo '<sup style="color:red">&nbsp;soon</sup>';
} elseif ($now->getTimestamp() - $create_time->getTimestamp() < 86400) { // 1d
echo '<sup style="color:red">&nbsp;new</sup>';
}
$ddl_str = $ddl->format('Y-m-d H:i');
2022-09-26 04:09:54 +00:00
echo ' (截止时间: ', $ddl_str, '<a ';
if (isset($REQUIRE_LIB['bootstrap5'])) {
echo ' class="text-decoration-none" ';
}
echo ' href="/assignment/', $ass['id'], '">查看完成情况</a>)';
2022-09-20 00:28:38 +00:00
echo '</li>';
}
if (count($assignments) == 0) {
echo '<p>暂无作业</p>';
2022-09-18 04:58:35 +00:00
}
?>
2022-03-20 00:07:46 +00:00
</ul>
</div>
</div>
2022-09-26 04:09:54 +00:00
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<div class="card card-default mb-3">
<div class="card-body">
<h2 class="card-title h4">
<?php else: ?>
2022-03-21 02:51:31 +00:00
<div class="row">
<div class="col-sm-12 mt-4">
2022-09-26 04:09:54 +00:00
<h5>
<?php endif ?>
<?= UOJLocale::get('top solver') ?>
</h5>
<?php echoRanklist(array(
'echo_full' => true,
'group_id' => $group_id,
'by_accepted' => true,
'table_classes' => isset($REQUIRE_LIB['bootstrap5'])
? array('table', 'text-center', 'mb-0')
: array('table', 'table-bordered', 'table-hover', 'table-striped', 'table-text-center')
)) ?>
2022-03-21 02:51:31 +00:00
</div>
</div>
2022-09-26 04:09:54 +00:00
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
</div>
2022-09-26 23:57:01 +00:00
<aside class="col mt-3 mt-lg-0">
2022-09-26 04:09:54 +00:00
<?php uojIncludeView('sidebar', array()); ?>
</aside>
</div>
<?php endif ?>
2022-03-20 00:07:46 +00:00
<?php echoUOJPageFooter() ?>