mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2025-03-26 05:37:02 +00:00
Compare commits
4 Commits
7ab64c1ba3
...
9fc1628709
Author | SHA1 | Date | |
---|---|---|---|
9fc1628709 | |||
a56923d52a | |||
e24d9c587c | |||
d79ca1512f |
@ -12,207 +12,82 @@
|
||||
}
|
||||
|
||||
$group_id = $_GET['id'];
|
||||
$group = queryGroup($group_id);
|
||||
if (!validateUInt($group_id) || !($group = queryGroup($group_id))) {
|
||||
become404Page();
|
||||
}
|
||||
|
||||
if (isSuperUser($myUser)) {
|
||||
$group_editor = new UOJBlogEditor();
|
||||
$group_editor->name = 'group';
|
||||
$group_editor->blog_url = null;
|
||||
$group_editor->cur_data = array(
|
||||
'title' => $group['title'],
|
||||
'tags' => array(),
|
||||
'is_hidden' => $group['is_hidden']
|
||||
);
|
||||
$group_editor->label_text = array_merge($group_editor->label_text, array(
|
||||
'view blog' => '保存小组信息',
|
||||
'blog visibility' => '小组可见性'
|
||||
));
|
||||
$group_editor->show_editor = false;
|
||||
$group_editor->show_tags = false;
|
||||
|
||||
$group_editor->save = function($data) {
|
||||
global $group_id, $group;
|
||||
DB::update("update `groups` set title = '".DB::escape($data['title'])."' where id = {$group_id}");
|
||||
|
||||
if ($data['is_hidden'] != $group['is_hidden'] ) {
|
||||
DB::update("update `groups` set is_hidden = {$data['is_hidden']} where id = {$group_id}");
|
||||
}
|
||||
};
|
||||
$group_editor->runAtServer();
|
||||
|
||||
$add_new_user_form = new UOJForm('add_new_user');
|
||||
$add_new_user_form->addInput('new_username', 'text', '用户名', '',
|
||||
function ($x) {
|
||||
global $group_id;
|
||||
|
||||
if (!validateUsername($x)) {
|
||||
return '用户名不合法';
|
||||
}
|
||||
$user = queryUser($x);
|
||||
if (!$user) {
|
||||
return '用户不存在';
|
||||
}
|
||||
|
||||
if (queryUserInGroup($group_id, $x)) {
|
||||
return '该用户已经在小组中';
|
||||
}
|
||||
|
||||
return '';
|
||||
},
|
||||
null
|
||||
);
|
||||
$add_new_user_form->submit_button_config['align'] = 'compressed';
|
||||
$add_new_user_form->submit_button_config['text'] = '添加到小组';
|
||||
$add_new_user_form->handle = function() {
|
||||
global $group_id, $myUser;
|
||||
$username = $_POST['new_username'];
|
||||
|
||||
DB::insert("insert into groups_users (group_id, username) values ({$group_id}, '{$username}')");
|
||||
};
|
||||
$add_new_user_form->runAtServer();
|
||||
|
||||
$delete_user_form = new UOJForm('delete_user');
|
||||
$delete_user_form->addInput('del_username', 'text', '用户名', '',
|
||||
function ($x) {
|
||||
global $group_id;
|
||||
|
||||
if (!validateUsername($x)) {
|
||||
return '用户名不合法';
|
||||
}
|
||||
if (!queryUserInGroup($group_id, $x)) {
|
||||
return '该用户不在小组中';
|
||||
}
|
||||
|
||||
return '';
|
||||
},
|
||||
null
|
||||
);
|
||||
$delete_user_form->submit_button_config['align'] = 'compressed';
|
||||
$delete_user_form->submit_button_config['text'] = '从小组中删除';
|
||||
$delete_user_form->handle = function() {
|
||||
global $group_id, $myUser;
|
||||
$username = $_POST['del_username'];
|
||||
|
||||
DB::query("delete from groups_users where username='{$username}' and group_id={$group_id}");
|
||||
};
|
||||
$delete_user_form->runAtServer();
|
||||
|
||||
$add_new_assignment_form = new UOJForm('add_new_assignment');
|
||||
$add_new_assignment_form->addInput('new_assignment_list_id', 'text', '题单 ID', '',
|
||||
function ($x) {
|
||||
global $group_id;
|
||||
|
||||
if (!validateUInt($x)) {
|
||||
return '题单 ID 不合法';
|
||||
}
|
||||
$list = queryProblemList($x);
|
||||
if (!$list) {
|
||||
return '题单不存在';
|
||||
}
|
||||
if ($list['is_hidden'] != 0) {
|
||||
return '题单是隐藏的';
|
||||
}
|
||||
|
||||
if (queryAssignmentByGroupListID($group_id, $x)) {
|
||||
return '该题单已经在作业中';
|
||||
}
|
||||
|
||||
return '';
|
||||
},
|
||||
null
|
||||
);
|
||||
|
||||
$default_ddl = new DateTime();
|
||||
$default_ddl->setTime(17, 0, 0);
|
||||
$default_ddl->add(new DateInterval("P7D"));
|
||||
|
||||
$add_new_assignment_form->addInput('new_assignment_deadline', 'text', '截止时间', $default_ddl->format('Y-m-d H:i'),
|
||||
function ($x) {
|
||||
$ddl = DateTime::createFromFormat('Y-m-d H:i', $x);
|
||||
if (!$ddl) {
|
||||
return '截止时间格式不正确,请以类似 "2020-10-1 17:00" 的格式输入';
|
||||
}
|
||||
|
||||
return '';
|
||||
},
|
||||
null
|
||||
);
|
||||
|
||||
$add_new_assignment_form->submit_button_config['align'] = 'compressed';
|
||||
$add_new_assignment_form->submit_button_config['text'] = '添加作业';
|
||||
$add_new_assignment_form->handle = function() {
|
||||
global $group_id, $myUser;
|
||||
$list_id = $_POST['new_assignment_list_id'];
|
||||
$ddl = DateTime::createFromFormat('Y-m-d H:i', $_POST['new_assignment_deadline']);
|
||||
$ddl_str = $ddl->format('Y-m-d H:i:s');
|
||||
|
||||
DB::insert("insert into assignments (group_id, list_id, create_time, deadline) values ({$group_id}, '{$list_id}', now(), '{$ddl_str}')");
|
||||
};
|
||||
$add_new_assignment_form->runAtServer();
|
||||
|
||||
$remove_assignment_form = new UOJForm('remove_assignment');
|
||||
$remove_assignment_form->addInput('remove_assignment_list_id', 'text', '题单 ID', '',
|
||||
function ($x) {
|
||||
global $group_id;
|
||||
|
||||
if (!validateUInt($x)) {
|
||||
return '题单 ID 不合法';
|
||||
}
|
||||
if (!queryAssignmentByGroupListID($group_id, $x)) {
|
||||
return '该题单不在作业中';
|
||||
}
|
||||
|
||||
return '';
|
||||
},
|
||||
null
|
||||
);
|
||||
|
||||
$remove_assignment_form->submit_button_config['align'] = 'compressed';
|
||||
$remove_assignment_form->submit_button_config['text'] = '删除作业';
|
||||
$remove_assignment_form->handle = function() {
|
||||
global $group_id, $myUser;
|
||||
$list_id = $_POST['remove_assignment_list_id'];
|
||||
|
||||
DB::query("delete from assignments where list_id='{$list_id}' and group_id={$group_id}");
|
||||
};
|
||||
$remove_assignment_form->runAtServer();
|
||||
|
||||
$announcement_form = new UOJForm('announcement_form');
|
||||
$announcement_form->addVTextArea('announcement_content', '公告', $group['announcement'],
|
||||
function ($x) {
|
||||
return '';
|
||||
},
|
||||
null
|
||||
);
|
||||
$announcement_form->submit_button_config['align'] = 'compressed';
|
||||
$announcement_form->submit_button_config['text'] = '更新公告';
|
||||
$announcement_form->handle = function() {
|
||||
global $group_id, $myUser;
|
||||
|
||||
$content = $_POST['announcement_content'];
|
||||
$esc_content = DB::escape($content);
|
||||
DB::query("update groups set announcement = '{$esc_content}' where id = {$group_id}");
|
||||
};
|
||||
$announcement_form->runAtServer();
|
||||
if (!isset($_COOKIE['bootstrap4'])) {
|
||||
$REQUIRE_LIB['bootstrap5'] = '';
|
||||
}
|
||||
?>
|
||||
|
||||
<?php echoUOJPageHeader(UOJLocale::get('groups')) ?>
|
||||
|
||||
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-md-9">
|
||||
<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: ?>
|
||||
<h2 style="margin-top: 24px"><?= $group['title'] ?></h2>
|
||||
<p>(<b>小组 ID</b>: <?= $group['id'] ?>)</p>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if (isSuperUser($myUser)): ?>
|
||||
<?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: ?>
|
||||
<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 ?>
|
||||
<?php endif ?>
|
||||
|
||||
|
||||
<?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: ?>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 mt-4">
|
||||
<h5><?= UOJLocale::get('news') ?></h5>
|
||||
<ul>
|
||||
<h5>
|
||||
<?php endif ?>
|
||||
<?= UOJLocale::get('news') ?>
|
||||
</h5>
|
||||
<ul
|
||||
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
|
||||
class="mb-0"
|
||||
<?php endif ?>
|
||||
>
|
||||
<?php
|
||||
$current_ac = queryGroupCurrentAC($group['id']);
|
||||
$current_ac = queryGroupCurrentAC($group['id']);
|
||||
foreach ($current_ac as $ac) {
|
||||
echo '<li>';
|
||||
echo getUserLink($ac['submitter']);
|
||||
echo ' 解决了问题 ';
|
||||
echo '<a href="/problem/', $ac['problem_id'], '">', $ac['problem_title'], '</a> ';
|
||||
echo '<a ';
|
||||
if (isset($REQUIRE_LIB['bootstrap5'])) {
|
||||
echo ' class="text-decoration-none" ';
|
||||
}
|
||||
echo ' href="/problem/', $ac['problem_id'], '">', $ac['problem_title'], '</a> ';
|
||||
echo '<time class="time">(', $ac['submit_time'], ')</time>';
|
||||
echo '</li>';
|
||||
}
|
||||
@ -224,23 +99,35 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
|
||||
<div class="card card-default mb-3">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title h4">
|
||||
<?php else: ?>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 mt-4">
|
||||
<h5><?= UOJLocale::get('assignments') ?></h5>
|
||||
<ul>
|
||||
<h5>
|
||||
<?php endif ?>
|
||||
<?= UOJLocale::get('assignments') ?>
|
||||
</h5>
|
||||
<ul
|
||||
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
|
||||
class="mb-0"
|
||||
<?php endif ?>
|
||||
>
|
||||
<?php
|
||||
$assignments = queryGroupActiveAssignments($group['id']);
|
||||
$assignments = queryGroupActiveAssignments($group['id']);
|
||||
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();
|
||||
|
||||
if ($now->getTimestamp() - $ddl->getTimestamp() > 604800) {
|
||||
continue;
|
||||
} // 7d
|
||||
|
||||
echo '<li>';
|
||||
echo "<a href=\"/problem_list/{$ass['list_id']}\">{$ass['title']} (题单 #{$ass['list_id']})</a>";
|
||||
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>';
|
||||
|
||||
if ($ddl < $now) {
|
||||
echo '<sup style="color:red"> overdue</sup>';
|
||||
@ -251,7 +138,11 @@
|
||||
}
|
||||
|
||||
$ddl_str = $ddl->format('Y-m-d H:i');
|
||||
echo " (截止时间: {$ddl_str},<a href=\"/assignment/{$ass['id']}\">查看完成情况</a>)";
|
||||
echo ' (截止时间: ', $ddl_str, ',<a ';
|
||||
if (isset($REQUIRE_LIB['bootstrap5'])) {
|
||||
echo ' class="text-decoration-none" ';
|
||||
}
|
||||
echo ' href="/assignment/', $ass['id'], '">查看完成情况</a>)';
|
||||
echo '</li>';
|
||||
}
|
||||
|
||||
@ -263,35 +154,38 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
|
||||
<div class="card card-default mb-3">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title h4">
|
||||
<?php else: ?>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 mt-4">
|
||||
<h5><?= UOJLocale::get('top solver') ?></h5>
|
||||
<?php echoRanklist(array('echo_full' => true, 'group_id' => $group_id, 'by_accepted' => true)) ?>
|
||||
<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')
|
||||
)) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (isSuperUser($myUser)): ?>
|
||||
<h5>编辑小组信息</h5>
|
||||
<div class="mb-4">
|
||||
<?php $group_editor->printHTML(); ?>
|
||||
|
||||
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
|
||||
</div>
|
||||
|
||||
<h5>编辑小组公告</h5>
|
||||
<div>
|
||||
<?php $announcement_form->printHTML(); ?>
|
||||
<aside class="col mt-3 mt-md-0">
|
||||
|
||||
<?php uojIncludeView('sidebar', array()); ?>
|
||||
</aside>
|
||||
|
||||
</div>
|
||||
|
||||
<h5>添加用户到小组</h5>
|
||||
<?php $add_new_user_form->printHTML(); ?>
|
||||
|
||||
<h5>从小组中删除用户</h5>
|
||||
<?php $delete_user_form->printHTML(); ?>
|
||||
|
||||
<h5>为小组添加作业</h5>
|
||||
<?php $add_new_assignment_form->printHTML(); ?>
|
||||
|
||||
<h5>删除小组的作业</h5>
|
||||
<?php $remove_assignment_form->printHTML(); ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php echoUOJPageFooter() ?>
|
||||
|
277
web/app/controllers/group_manage.php
Normal file
277
web/app/controllers/group_manage.php
Normal file
@ -0,0 +1,277 @@
|
||||
<?php
|
||||
requirePHPLib('form');
|
||||
requirePHPLib('judger');
|
||||
requirePHPLib('data');
|
||||
|
||||
if (!Auth::check()) {
|
||||
become403Page(UOJLocale::get('need login'));
|
||||
}
|
||||
|
||||
if (!isNormalUser($myUser)) {
|
||||
become403Page();
|
||||
}
|
||||
|
||||
$group_id = $_GET['id'];
|
||||
if (!validateUInt($group_id) || !($group = queryGroup($group_id))) {
|
||||
become404Page();
|
||||
}
|
||||
|
||||
if (!isSuperUser($myUser)) {
|
||||
become403Page();
|
||||
}
|
||||
|
||||
$group_editor = new UOJBlogEditor();
|
||||
$group_editor->name = 'group';
|
||||
$group_editor->blog_url = null;
|
||||
$group_editor->cur_data = array(
|
||||
'title' => $group['title'],
|
||||
'tags' => array(),
|
||||
'is_hidden' => $group['is_hidden']
|
||||
);
|
||||
$group_editor->label_text = array_merge($group_editor->label_text, array(
|
||||
'view blog' => '保存小组信息',
|
||||
'blog visibility' => '小组可见性'
|
||||
));
|
||||
$group_editor->show_editor = false;
|
||||
$group_editor->show_tags = false;
|
||||
|
||||
$group_editor->save = function($data) {
|
||||
global $group_id, $group;
|
||||
DB::update("update `groups` set title = '".DB::escape($data['title'])."' where id = {$group_id}");
|
||||
|
||||
if ($data['is_hidden'] != $group['is_hidden'] ) {
|
||||
DB::update("update `groups` set is_hidden = {$data['is_hidden']} where id = {$group_id}");
|
||||
}
|
||||
};
|
||||
$group_editor->runAtServer();
|
||||
|
||||
$add_new_user_form = new UOJForm('add_new_user');
|
||||
$add_new_user_form->addInput('new_username', 'text', '用户名', '',
|
||||
function ($x) {
|
||||
global $group_id;
|
||||
|
||||
if (!validateUsername($x)) {
|
||||
return '用户名不合法';
|
||||
}
|
||||
$user = queryUser($x);
|
||||
if (!$user) {
|
||||
return '用户不存在';
|
||||
}
|
||||
|
||||
if (queryUserInGroup($group_id, $x)) {
|
||||
return '该用户已经在小组中';
|
||||
}
|
||||
|
||||
return '';
|
||||
},
|
||||
null
|
||||
);
|
||||
$add_new_user_form->submit_button_config['align'] = 'compressed';
|
||||
$add_new_user_form->submit_button_config['text'] = '添加到小组';
|
||||
$add_new_user_form->handle = function() {
|
||||
global $group_id, $myUser;
|
||||
$username = $_POST['new_username'];
|
||||
|
||||
DB::insert("insert into groups_users (group_id, username) values ({$group_id}, '{$username}')");
|
||||
};
|
||||
$add_new_user_form->runAtServer();
|
||||
|
||||
|
||||
$delete_user_form = new UOJForm('delete_user');
|
||||
$delete_user_form->addInput('del_username', 'text', '用户名', '',
|
||||
function ($x) {
|
||||
global $group_id;
|
||||
|
||||
if (!validateUsername($x)) {
|
||||
return '用户名不合法';
|
||||
}
|
||||
if (!queryUserInGroup($group_id, $x)) {
|
||||
return '该用户不在小组中';
|
||||
}
|
||||
|
||||
return '';
|
||||
},
|
||||
null
|
||||
);
|
||||
$delete_user_form->submit_button_config['align'] = 'compressed';
|
||||
$delete_user_form->submit_button_config['text'] = '从小组中删除';
|
||||
$delete_user_form->handle = function() {
|
||||
global $group_id, $myUser;
|
||||
$username = $_POST['del_username'];
|
||||
|
||||
DB::query("delete from groups_users where username='{$username}' and group_id={$group_id}");
|
||||
};
|
||||
$delete_user_form->runAtServer();
|
||||
|
||||
$add_new_assignment_form = new UOJForm('add_new_assignment');
|
||||
$add_new_assignment_form->addInput('new_assignment_list_id', 'text', '题单 ID', '',
|
||||
function ($x) {
|
||||
global $group_id;
|
||||
|
||||
if (!validateUInt($x)) {
|
||||
return '题单 ID 不合法';
|
||||
}
|
||||
$list = queryProblemList($x);
|
||||
if (!$list) {
|
||||
return '题单不存在';
|
||||
}
|
||||
if ($list['is_hidden'] != 0) {
|
||||
return '题单是隐藏的';
|
||||
}
|
||||
|
||||
if (queryAssignmentByGroupListID($group_id, $x)) {
|
||||
return '该题单已经在作业中';
|
||||
}
|
||||
|
||||
return '';
|
||||
},
|
||||
null
|
||||
);
|
||||
$default_ddl = new DateTime();
|
||||
$default_ddl->setTime(17, 0, 0);
|
||||
$default_ddl->add(new DateInterval("P7D"));
|
||||
$add_new_assignment_form->addInput('new_assignment_deadline', 'text', '截止时间', $default_ddl->format('Y-m-d H:i'),
|
||||
function ($x) {
|
||||
$ddl = DateTime::createFromFormat('Y-m-d H:i', $x);
|
||||
if (!$ddl) {
|
||||
return '截止时间格式不正确,请以类似 "2020-10-1 17:00" 的格式输入';
|
||||
}
|
||||
|
||||
return '';
|
||||
},
|
||||
null
|
||||
);
|
||||
$add_new_assignment_form->submit_button_config['align'] = 'compressed';
|
||||
$add_new_assignment_form->submit_button_config['text'] = '添加作业';
|
||||
$add_new_assignment_form->handle = function() {
|
||||
global $group_id, $myUser;
|
||||
$list_id = $_POST['new_assignment_list_id'];
|
||||
$ddl = DateTime::createFromFormat('Y-m-d H:i', $_POST['new_assignment_deadline']);
|
||||
$ddl_str = $ddl->format('Y-m-d H:i:s');
|
||||
|
||||
DB::insert("insert into assignments (group_id, list_id, create_time, deadline) values ({$group_id}, '{$list_id}', now(), '{$ddl_str}')");
|
||||
};
|
||||
$add_new_assignment_form->runAtServer();
|
||||
|
||||
$remove_assignment_form = new UOJForm('remove_assignment');
|
||||
$remove_assignment_form->addInput('remove_assignment_list_id', 'text', '题单 ID', '',
|
||||
function ($x) {
|
||||
global $group_id;
|
||||
|
||||
if (!validateUInt($x)) {
|
||||
return '题单 ID 不合法';
|
||||
}
|
||||
if (!queryAssignmentByGroupListID($group_id, $x)) {
|
||||
return '该题单不在作业中';
|
||||
}
|
||||
|
||||
return '';
|
||||
},
|
||||
null
|
||||
);
|
||||
|
||||
$remove_assignment_form->submit_button_config['align'] = 'compressed';
|
||||
$remove_assignment_form->submit_button_config['text'] = '删除作业';
|
||||
$remove_assignment_form->handle = function() {
|
||||
global $group_id, $myUser;
|
||||
$list_id = $_POST['remove_assignment_list_id'];
|
||||
|
||||
DB::query("delete from assignments where list_id='{$list_id}' and group_id={$group_id}");
|
||||
};
|
||||
$remove_assignment_form->runAtServer();
|
||||
|
||||
$announcement_form = new UOJForm('announcement_form');
|
||||
$announcement_form->addVTextArea('announcement_content', '公告', $group['announcement'],
|
||||
function ($x) {
|
||||
return '';
|
||||
},
|
||||
null
|
||||
);
|
||||
$announcement_form->submit_button_config['text'] = '更新公告';
|
||||
$announcement_form->handle = function() {
|
||||
global $group_id, $myUser;
|
||||
|
||||
$content = $_POST['announcement_content'];
|
||||
$esc_content = DB::escape($content);
|
||||
DB::query("update groups set announcement = '{$esc_content}' where id = {$group_id}");
|
||||
};
|
||||
$announcement_form->runAtServer();
|
||||
?>
|
||||
|
||||
<?php echoUOJPageHeader($group['title'] . ' 管理'); ?>
|
||||
|
||||
<h1 class="h2">
|
||||
<?= $group['title'] ?>(#<?= $group['id'] ?>)管理
|
||||
</h1>
|
||||
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="nav-item"><a class="nav-link" href="/group/<?= $group['id'] ?>/manage" role="tab">管理</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/group/<?= $group['id'] ?>" role="tab">返回</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="top-buffer-md"></div>
|
||||
|
||||
<h5>编辑小组信息</h5>
|
||||
<div class="mb-4">
|
||||
<?php $group_editor->printHTML(); ?>
|
||||
</div>
|
||||
|
||||
<h5>编辑小组公告</h5>
|
||||
<?php $announcement_form->printHTML(); ?>
|
||||
|
||||
<h5>添加用户到小组</h5>
|
||||
<?php $add_new_user_form->printHTML(); ?>
|
||||
|
||||
<h5>从小组中删除用户</h5>
|
||||
<?php $delete_user_form->printHTML(); ?>
|
||||
|
||||
<h5>为小组添加作业</h5>
|
||||
<?php $add_new_assignment_form->printHTML(); ?>
|
||||
|
||||
<h5>删除小组的作业</h5>
|
||||
<?php $remove_assignment_form->printHTML(); ?>
|
||||
|
||||
<h5>已被自动隐藏的作业</h5>
|
||||
<ul>
|
||||
<?php
|
||||
$assignments = queryGroupAssignments($group['id']);
|
||||
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();
|
||||
|
||||
if ($now->getTimestamp() - $ddl->getTimestamp() <= 604800) {
|
||||
continue;
|
||||
} // 7d
|
||||
|
||||
echo '<li>';
|
||||
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>';
|
||||
|
||||
if ($ddl < $now) {
|
||||
echo '<sup style="color:red"> overdue</sup>';
|
||||
} elseif ($ddl->getTimestamp() - $now->getTimestamp() < 86400) { // 1d
|
||||
echo '<sup style="color:red"> soon</sup>';
|
||||
} elseif ($now->getTimestamp() - $create_time->getTimestamp() < 86400) { // 1d
|
||||
echo '<sup style="color:red"> new</sup>';
|
||||
}
|
||||
|
||||
$ddl_str = $ddl->format('Y-m-d H:i');
|
||||
echo ' (截止时间: ', $ddl_str, ',<a ';
|
||||
if (isset($REQUIRE_LIB['bootstrap5'])) {
|
||||
echo ' class="text-decoration-none" ';
|
||||
}
|
||||
echo ' href="/assignment/', $ass['id'], '">查看完成情况</a>)';
|
||||
echo '</li>';
|
||||
}
|
||||
|
||||
if (count($assignments) == 0) {
|
||||
echo '<p>暂无作业</p>';
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
|
||||
<?php echoUOJPageFooter() ?>
|
@ -49,7 +49,6 @@
|
||||
echo ' <span class="text-info" style="font-size: 10px">' . $problem["uploader"] . '</span> ';
|
||||
|
||||
foreach (queryProblemTags($problem['id']) as $tag) {
|
||||
|
||||
if (isset($REQUIRE_LIB['bootstrap5'])) {
|
||||
echo '<a class="uoj-problem-tag my-1">';
|
||||
echo '<span class="badge bg-secondary">';
|
||||
@ -114,6 +113,9 @@ EOD;
|
||||
<div class="d-flex justify-content-between">
|
||||
<?php endif ?>
|
||||
<h1 class="h2">
|
||||
<?php if ($list['is_hidden']): ?>
|
||||
<span class="fs-5 text-danger">[隐藏]</span>
|
||||
<?php endif ?>
|
||||
<?= $list['title'] ?>
|
||||
<span class="fs-5">(ID: #<?= $list['id'] ?>)</span>
|
||||
</h1>
|
||||
@ -253,6 +255,7 @@ $('#input-show_difficulty').click(function() {
|
||||
</div>
|
||||
|
||||
<?= $pag->pagination(); ?>
|
||||
|
||||
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
|
||||
</div>
|
||||
|
||||
@ -263,4 +266,5 @@ $('#input-show_difficulty').click(function() {
|
||||
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<?php echoUOJPageFooter() ?>
|
||||
|
@ -124,8 +124,11 @@ function queryGroupmateCurrentAC($username) {
|
||||
function queryGroupCurrentAC($group_id) {
|
||||
return DB::selectAll("select a.problem_id as problem_id, a.submitter as submitter, a.submission_id as submission_id, b.submit_time as submit_time, d.title as problem_title, b.submit_time as submit_time, e.realname as realname from best_ac_submissions a inner join submissions b on (a.submission_id = b.id) inner join groups_users c on (a.submitter = c.username and c.group_id = $group_id) inner join problems d on (a.problem_id = d.id and d.is_hidden = 0) inner join user_info e on (a.submitter = e.username) where b.submit_time > addtime(now(), '-360:00:00') order by b.submit_time desc limit 10", MYSQLI_ASSOC);
|
||||
}
|
||||
function queryGroupAssignments($group_id) {
|
||||
return DB::selectAll("select a.id as id, a.list_id as list_id, a.create_time as create_time, a.deadline as deadline, b.title from assignments a left join lists b on a.list_id = b.id where a.group_id = $group_id order by a.deadline asc", MYSQLI_ASSOC);
|
||||
}
|
||||
function queryGroupActiveAssignments($group_id) {
|
||||
return DB::selectAll("select a.id as id, a.list_id as list_id, a.create_time as create_time, a.deadline as deadline, b.title from assignments a left join lists b on a.list_id = b.id where a.group_id = $group_id and a.deadline > addtime(now(), '-360:00:00') order by a.deadline asc", MYSQLI_ASSOC);
|
||||
return DB::selectAll("select a.id as id, a.list_id as list_id, a.create_time as create_time, a.deadline as deadline, b.title from assignments a left join lists b on a.list_id = b.id where a.group_id = $group_id and a.deadline > addtime(now(), '-168:00:00') order by a.deadline asc", MYSQLI_ASSOC);
|
||||
}
|
||||
|
||||
function queryAssignment($id) {
|
||||
|
@ -46,6 +46,7 @@ Route::group([
|
||||
|
||||
Route::any('/groups', '/groups.php');
|
||||
Route::any('/group/{id}', '/group.php');
|
||||
Route::any('/group/{id}/manage', '/group_manage.php');
|
||||
|
||||
Route::any('/assignment/{id}', '/assignment.php');
|
||||
|
||||
@ -68,7 +69,6 @@ Route::group([
|
||||
Route::any('/forgot-password', '/forgot_pw.php');
|
||||
Route::any('/reset-password', '/reset_pw.php');
|
||||
Route::any('/user/profile/{username}', '/user_info.php');
|
||||
Route::any('/user/self_reviews/{username}', '/user_self_reviews.php');
|
||||
Route::any('/user/modify-profile', '/change_user_info.php');
|
||||
Route::any('/user/msg', '/user_msg.php');
|
||||
Route::any('/user/system-msg', '/user_system_msg.php');
|
||||
|
Loading…
x
Reference in New Issue
Block a user