mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-08 13:38:41 +00:00
feat: group announcement
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
32caffc3ec
commit
4e1d156f0e
@ -442,6 +442,7 @@ UNLOCK TABLES;
|
||||
CREATE TABLE `groups` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`title` text NOT NULL,
|
||||
`announcement` text NOT NULL DEFAULT '',
|
||||
`is_hidden` tinyint(1) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
|
||||
|
@ -176,6 +176,24 @@
|
||||
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();
|
||||
}
|
||||
?>
|
||||
|
||||
@ -258,6 +276,11 @@
|
||||
<?php $group_editor->printHTML(); ?>
|
||||
</div>
|
||||
|
||||
<h5>编辑小组公告</h5>
|
||||
<div>
|
||||
<?php $announcement_form->printHTML(); ?>
|
||||
</div>
|
||||
|
||||
<h5>添加用户到小组</h5>
|
||||
<?php $add_new_user_form->printHTML(); ?>
|
||||
|
||||
|
@ -115,7 +115,7 @@ function queryGroup($id) {
|
||||
function queryUserInGroup($group_id, $username) {
|
||||
return DB::selectFirst("select * from groups_users where username='$username' and group_id='$group_id'", MYSQLI_ASSOC);
|
||||
}
|
||||
function queryGroupOfUser($username) {
|
||||
function queryGroupsOfUser($username) {
|
||||
return DB::selectAll("select b.title as title, b.id as id from groups_users a inner join groups b on a.group_id = b.id where a.username = '$username' and b.is_hidden = 0 order by id", MYSQLI_ASSOC);
|
||||
}
|
||||
function queryGroupmateCurrentAC($username) {
|
||||
|
@ -282,6 +282,41 @@
|
||||
<?php endif ?>
|
||||
|
||||
<?php uojIncludeView($PageNav, array('REQUIRE_LIB' => $REQUIRE_LIB)) ?>
|
||||
|
||||
<?php if (!isset($REQUIRE_LIB['bootstrap5'])): ?>
|
||||
<?php if (Auth::check()): ?>
|
||||
<?php $groups = queryGroupsOfUser(Auth::id()); ?>
|
||||
<?php if (count($groups)): ?>
|
||||
<div class="card card-default mb-2" id="group-user-announcements">
|
||||
<div class="card-header">
|
||||
小组公告
|
||||
</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']}");
|
||||
$group_announcement = $group_detail['announcement'];
|
||||
?>
|
||||
<li class="list-group-item">
|
||||
<a href="<?= HTML::url('/group/'.$group['id']) ?>">
|
||||
<b><?= $group['title'] ?></b>
|
||||
</a>
|
||||
<?php if ($group_announcement): ?>
|
||||
<div id="announcement-content-<?= $group['id'] ?>"></div>
|
||||
<script>(function(){
|
||||
$('#announcement-content-<?= $group['id'] ?>')
|
||||
.html(DOMPurify.sanitize(decodeURIComponent("<?= urlencode($group_announcement) ?>"), <?= DOM_SANITIZE_CONFIG ?>));
|
||||
})();</script>
|
||||
<?php else: ?>
|
||||
<div>(暂无公告)</div>
|
||||
<?php endif ?>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user