S2OJ/web/app/models/UOJBlogComment.php

49 lines
970 B
PHP
Raw Permalink Normal View History

2022-11-06 02:26:21 +00:00
<?php
class UOJBlogComment {
use UOJDataTrait;
2023-02-07 10:38:24 +00:00
const HIDE_REASONS = [
'unhide' => '解除隐藏',
'spam' => '疑似为垃圾信息',
'garbage' => '疑似为无意义的乱码',
'insult' => '包含不和谐内容',
'violate' => '违反法律法规',
'other' => '其他(请在下方说明)',
];
2022-11-06 02:26:21 +00:00
public static function query($id) {
if (!isset($id) || !validateUInt($id)) {
return null;
}
$info = DB::selectFirst([
"select * from blogs_comments",
2023-02-07 10:38:24 +00:00
"where", ['id' => $id]
2022-11-06 02:26:21 +00:00
]);
if (!$info) {
return null;
}
return new UOJBlogComment($info);
}
public function __construct($info) {
$this->info = $info;
}
public function hide($reason) {
DB::update([
2023-02-07 10:38:24 +00:00
"update blogs_comments",
"set", [
'is_hidden' => ($reason !== ''),
'reason_to_hide' => $reason
],
"where", ['id' => $this->info['id']]
2022-11-06 02:26:21 +00:00
]);
$blog = UOJBlog::query($this->info['blog_id']);
if ($blog) {
$blog->updateActiveTime($blog);
}
}
}