feat(web/blog/delete): send blog_delete system msg
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Baoshuo Ren 2022-10-17 21:44:50 +08:00
parent 0568633496
commit dd730a4d6a
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
2 changed files with 15 additions and 2 deletions

View File

@ -898,7 +898,7 @@ UNLOCK TABLES;
CREATE TABLE `user_system_msg` ( CREATE TABLE `user_system_msg` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, `title` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`content` varchar(300) COLLATE utf8mb4_unicode_ci NOT NULL, `content` text COLLATE utf8mb4_unicode_ci NOT NULL,
`receiver` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL, `receiver` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
`send_time` datetime NOT NULL, `send_time` datetime NOT NULL,
`read_time` datetime DEFAULT NULL, `read_time` datetime DEFAULT NULL,

View File

@ -20,7 +20,20 @@
$delete_form = new UOJForm('delete'); $delete_form = new UOJForm('delete');
$delete_form->handle = function() { $delete_form->handle = function() {
global $blog; global $myUser, $blog;
if ($myUser['username'] != $blog['poster']) {
$poster_user_link = getUserLink($blog['poster']);
$admin_user_link = isSuperUser($myUser) ? '管理员' : getUserLink($myUser['username']);
$blog_content = HTML::escape($blog['content_md']);
$content = <<<EOD
<p>{$poster_user_link} 您好:</p>
<p>您的博客 <b>{$blog['title']}</b>ID{$blog['id']})已经被 {$admin_user_link} 删除,现将博客原文备份发送给您,请查收。</p>
<pre><code class="language-markdown">{$blog_content}</code></pre>
EOD;
sendSystemMsg($blog['poster'], '博客删除通知', $content);
}
deleteBlog($blog['id']); deleteBlog($blog['id']);
}; };
$delete_form->submit_button_config['class_str'] = 'btn btn-danger'; $delete_form->submit_button_config['class_str'] = 'btn btn-danger';