edited comment status

This commit is contained in:
themohooks 2024-10-07 17:06:43 +03:00
parent 0f6feb123a
commit 78ace421d5
2 changed files with 16 additions and 1 deletions

View file

@ -11,11 +11,19 @@ class Edit
$postId = explode('/', $_SERVER['REQUEST_URI'])[4];
$data = DB::query('SELECT * FROM photos_comments WHERE id=:id', array(':id' => $postId))[0];
$content = json_decode($data['content'], true);
$postuserid = DB::query('SELECT user_id FROM photos_comments WHERE id=:id', array(':id' => $postId))[0]['user_id'];
if ($postuserid === Auth::userid()) {
$json = file_get_contents('php://input');
$data = json_decode($json, true);
DB::query('UPDATE photos_comments SET body=:body WHERE id=:id', array(':id' => $postId, ':body' => $data['value']));
$json_arr = $content;
if ($data['value'] != DB::query('SELECT body FROM photos_comments WHERE id=:id', array(':id' => $postId))[0]['body']) {
$json_arr['edited'] = 'true';
}
$json_str_updated = json_encode($json_arr);
DB::query('UPDATE photos_comments SET body=:body, content=:c WHERE id=:id', array(':id' => $postId, ':body' => $data['value'], ':c'=>$json_str_updated));
echo json_encode(
array(
'errorcode' => '0',

View file

@ -16,12 +16,16 @@ class Comment {
}
public function i() {
$user = new User($this->c['user_id']);
$content = json_decode($this->c['content'], true);
echo '<div class="'.$this->class.' comment" wid="'.$this->c['id'].'">
<div style="float:right; text-align:right" class="sm">
<span class="message_date">'.Date::zmdate($this->c['posted_at']).'</span><br>
<a href="#" class="quoteLink dot">Цитировать</a>
·
<a href="#'.$this->c['id'].'" class="cmLink dot">Ссылка</a>
';
echo '
</div>
<a name="2681468"></a><a name="last"></a>
<div><img src="'.$user->i('photourl').'" width="32" style="border-radius: 3px; margin-right: 5px;"><b><a href="/author/'.$this->c['user_id'].'/" class="message_author">'.htmlspecialchars($user->i('username')).'</a></b> &middot;
@ -32,6 +36,9 @@ class Comment {
if (json_decode($user->i('content'), true)['aboutlive']['value'] != null) {
echo ' '.htmlspecialchars(json_decode($user->i('content'), true)['aboutlive']['value']);
}
if ($content['edited'] === 'true') {
echo '<br>(отредактировано)';
}
if ($user->i('admin') === 1) {
$admintype = ' · Администратор сервера';
} else if ($user->i('admin') === 2) {