2022-09-26 10:56:38 +00:00
|
|
|
<?php if (Auth::check()): ?>
|
2022-10-10 10:42:49 +00:00
|
|
|
<?php if (!isset($groups_hidden)): ?>
|
2022-09-25 06:16:36 +00:00
|
|
|
<?php $groups = queryGroupsOfUser(Auth::id()); ?>
|
|
|
|
<?php if (count($groups)): ?>
|
|
|
|
<div class="card card-default mb-2" id="group-user-announcements">
|
|
|
|
<div class="card-header fw-bold bg-transparent">
|
2022-10-10 10:42:49 +00:00
|
|
|
<?= UOJLocale::get('group announcements') ?>
|
2022-09-25 06:16:36 +00:00
|
|
|
</div>
|
|
|
|
<ul class="list-group list-group-flush">
|
|
|
|
<?php foreach ($groups as $group): ?>
|
|
|
|
<?php
|
|
|
|
$group_detail = DB::selectFirst("select * from groups where id = {$group['id']}");
|
2022-09-25 10:30:17 +00:00
|
|
|
$group_announcement = $group_detail['announcement'];
|
|
|
|
?>
|
2022-09-25 06:16:36 +00:00
|
|
|
<li class="list-group-item">
|
|
|
|
<a class="fw-bold text-decoration-none" href="<?= HTML::url('/group/'.$group['id']) ?>">
|
|
|
|
<?= $group['title'] ?>
|
|
|
|
</a>
|
|
|
|
<?php if ($group_announcement): ?>
|
2022-10-08 11:40:34 +00:00
|
|
|
<div class="text-break">
|
2022-10-09 13:33:13 +00:00
|
|
|
<?= HTML::purifier_inline()->purify($group_announcement) ?>
|
2022-10-08 11:40:34 +00:00
|
|
|
</div>
|
2022-09-25 06:16:36 +00:00
|
|
|
<?php else: ?>
|
2022-10-10 10:42:49 +00:00
|
|
|
<div class="text-muted">
|
|
|
|
<?= UOJLocale::get('none') ?>
|
|
|
|
</div>
|
2022-09-25 06:16:36 +00:00
|
|
|
<?php endif ?>
|
|
|
|
</li>
|
|
|
|
<?php endforeach ?>
|
|
|
|
</ul>
|
|
|
|
</div>
|
2022-10-10 10:42:49 +00:00
|
|
|
|
|
|
|
<?php if (!isset($assignments_hidden)): ?>
|
|
|
|
<?php
|
2022-10-10 10:43:05 +00:00
|
|
|
$assignments = [];
|
2022-10-10 10:42:49 +00:00
|
|
|
foreach ($groups as $group) {
|
|
|
|
$assignments = array_merge($assignments, queryGroupActiveAssignments($group['id']));
|
|
|
|
}
|
|
|
|
|
|
|
|
usort($assignments, function($a, $b) {
|
|
|
|
$deadline_a = DateTime::createFromFormat('Y-m-d H:i:s', $a['deadline']);
|
|
|
|
$deadline_b = DateTime::createFromFormat('Y-m-d H:i:s', $b['deadline']);
|
|
|
|
|
|
|
|
return $deadline_a->getTimestamp() - $deadline_b->getTimestamp();
|
|
|
|
});
|
|
|
|
?>
|
|
|
|
<?php if (count($assignments)): ?>
|
|
|
|
<div class="card card-default mb-2" id="group-assignments">
|
|
|
|
<div class="card-header fw-bold bg-transparent">
|
|
|
|
<?= UOJLocale::get('assignments') ?>
|
|
|
|
</div>
|
|
|
|
<ul class="list-group list-group-flush">
|
|
|
|
<?php foreach ($assignments as $assignment): ?>
|
|
|
|
<li class="list-group-item">
|
|
|
|
<?php
|
|
|
|
$deadline = DateTime::createFromFormat('Y-m-d H:i:s', $assignment['deadline']);
|
|
|
|
$create_time = DateTime::createFromFormat('Y-m-d H:i:s', $assignment['create_time']);
|
|
|
|
$now = new DateTime();
|
|
|
|
?>
|
2022-10-17 12:42:32 +00:00
|
|
|
<a href="<?= HTML::url('/group/'.$assignment['group_id'].'/assignment/'.$assignment['list_id']) ?>" class="fw-bold text-decoration-none">
|
2022-10-10 10:42:49 +00:00
|
|
|
<?= $assignment['title'] ?>
|
|
|
|
<?php if ($deadline < $now): ?>
|
|
|
|
<sup class="fw-normal text-danger">overdue</sup>
|
|
|
|
<?php elseif ($deadline->getTimestamp() - $now->getTimestamp() < 86400): ?>
|
|
|
|
<sup class="fw-normal text-danger">soon</sup>
|
|
|
|
<?php elseif ($now->getTimestamp() - $create_time->getTimestamp() < 86400): ?>
|
|
|
|
<sup class="fw-normal text-danger">new</sup>
|
|
|
|
<?php endif ?>
|
|
|
|
</a>
|
|
|
|
<div class="text-end small text-muted">
|
|
|
|
截止时间: <?= $deadline->format('Y-m-d H:i') ?>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<?php endforeach ?>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<?php endif // count($assignments) ?>
|
|
|
|
<?php endif // !isset($assignments_hidden) ?>
|
2022-10-07 09:29:26 +00:00
|
|
|
<?php endif // count($groups) ?>
|
2022-10-10 10:42:49 +00:00
|
|
|
<?php endif // !isset($group_hidden) ?>
|
2022-10-07 09:29:26 +00:00
|
|
|
<?php endif // Auth::check() ?>
|
2022-09-25 06:16:36 +00:00
|
|
|
|
2022-10-07 09:29:26 +00:00
|
|
|
<?php if (!UOJConfig::$data['switch']['force-login'] || Auth::check()): ?>
|
2022-09-25 06:16:36 +00:00
|
|
|
<?php if (!isset($upcoming_contests_hidden)): ?>
|
|
|
|
<?php
|
|
|
|
$upcoming_contests = DB::selectAll("SELECT * FROM contests WHERE status = 'unfinished' ORDER BY start_time ASC, id ASC LIMIT 7");
|
2022-09-25 10:30:17 +00:00
|
|
|
?>
|
2022-09-25 06:16:36 +00:00
|
|
|
<div class="card card-default mb-2" id="group-user-announcements">
|
|
|
|
<div class="card-header fw-bold bg-transparent">
|
|
|
|
近期比赛
|
|
|
|
</div>
|
|
|
|
<?php $count = 0; ?>
|
|
|
|
<ul class="list-group list-group-flush">
|
|
|
|
<?php foreach ($upcoming_contests as $contest): ?>
|
|
|
|
<?php genMoreContestInfo($contest) ?>
|
|
|
|
<?php if ($contest['cur_progress'] == CONTEST_NOT_STARTED || $contest['cur_progress'] == CONTEST_IN_PROGRESS): ?>
|
|
|
|
<?php $count++; ?>
|
|
|
|
<li class="list-group-item text-center">
|
|
|
|
<a class="fw-bold text-decoration-none" href="<?= HTML::url('/contest/'.$contest['id']) ?>">
|
|
|
|
<?= $contest['name'] ?>
|
|
|
|
</a>
|
|
|
|
<div class="small">
|
|
|
|
<?php if ($contest['cur_progress'] == CONTEST_IN_PROGRESS): ?>
|
|
|
|
<?= UOJLocale::get('contests::in progress') ?>
|
|
|
|
<?php else: ?>
|
|
|
|
<?php
|
2022-09-25 10:30:17 +00:00
|
|
|
$rest_seconds = $contest['start_time']->getTimestamp() - UOJTime::$time_now->getTimestamp();
|
|
|
|
?>
|
2022-09-25 06:16:36 +00:00
|
|
|
<?php if ($rest_seconds > 86400): ?>
|
2022-09-26 09:04:13 +00:00
|
|
|
<?= UOJLocale::get('contests::will start in x days', ceil($rest_seconds / 86400)) ?>
|
2022-09-25 06:16:36 +00:00
|
|
|
<?php else: ?>
|
|
|
|
<div id="contest-<?= $contest['id'] ?>-countdown"></div>
|
|
|
|
<script>$('#contest-<?= $contest['id'] ?>-countdown').countdown(<?= $rest_seconds ?>, function(){}, 'inherit', false);</script>
|
|
|
|
<?php endif ?>
|
|
|
|
<?php endif ?>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<?php endif ?>
|
|
|
|
<?php endforeach ?>
|
|
|
|
<?php if ($count == 0): ?>
|
|
|
|
<li class="list-group-item text-center">
|
|
|
|
<?= UOJLocale::get('none') ?>
|
|
|
|
</li>
|
|
|
|
<?php endif ?>
|
|
|
|
</ul>
|
|
|
|
<div class="card-footer bg-transparent text-center small">
|
|
|
|
<a class="text-decoration-none" href="<?= HTML::url('/contests?all=true') ?>">
|
|
|
|
<?= UOJLocale::get('view all') ?>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-10-07 09:29:26 +00:00
|
|
|
<?php endif // !isset($upcoming_contests_hidden) ?>
|
|
|
|
<?php endif // !UOJConfig::$data['switch']['force-login'] || Auth::check() ?>
|