S2OJ/web/app/models/UOJBlogComment.php

40 lines
732 B
PHP
Raw Normal View History

2022-11-06 02:26:21 +00:00
<?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);
}
}
}