mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-10 09:18:41 +00:00
40 lines
732 B
PHP
40 lines
732 B
PHP
|
<?php
|
||
|
|
||
|
class UOJBlogComment {
|
||
|
use UOJDataTrait;
|
||
|
|
||
|
public static function query($id) {
|
||
|
if (!isset($id) || !validateUInt($id)) {
|
||
|
return null;
|
||
|
}
|
||
|
$info = DB::selectFirst([
|
||
|
"select * from blogs_comments",
|
||
|
"where", ['id' => $id]
|
||
|
]);
|
||
|
if (!$info) {
|
||
|
return null;
|
||
|
}
|
||
|
return new UOJBlogComment($info);
|
||
|
}
|
||
|
|
||
|
public function __construct($info) {
|
||
|
$this->info = $info;
|
||
|
}
|
||
|
|
||
|
public function hide($reason) {
|
||
|
DB::update([
|
||
|
"update blogs_comments",
|
||
|
"set", [
|
||
|
'is_hidden' => ($reason !== ''),
|
||
|
'reason_to_hide' => $reason
|
||
|
],
|
||
|
"where", ['id' => $this->info['id']]
|
||
|
]);
|
||
|
|
||
|
$blog = UOJBlog::query($this->info['blog_id']);
|
||
|
if ($blog) {
|
||
|
$blog->updateActiveTime($blog);
|
||
|
}
|
||
|
}
|
||
|
}
|