add magnet form lock to prevent moderation overwrite

This commit is contained in:
ghost 2023-08-28 18:35:02 +03:00
parent 3ffe4a8651
commit 64e841ec4c
4 changed files with 39 additions and 1 deletions

View file

@ -839,7 +839,6 @@ class Database {
return $this->_db->lastInsertId();
}
public function deleteMagnetToExactSourceByMagnetId(int $magnetId) : int {
$this->_debug->query->delete->total++;
@ -938,6 +937,29 @@ class Database {
return $this->addMagnetToKeywordTopic($magnetId, $keywordTopicId);
}
// Magnet lock
public function addMagnetLock(int $magnetId, int $userId, int $timeAdded) : int {
$this->_debug->query->insert->total++;
$query = $this->_db->prepare('INSERT INTO `magnetLock` SET `magnetId` = ?, `userId` = ?, `timeAdded` = ?');
$query->execute([$magnetId, $userId, $timeAdded]);
return $this->_db->lastInsertId();
}
public function findLastMagnetLock(int $magnetId) {
$this->_debug->query->select->total++;
$query = $this->_db->prepare('SELECT * FROM `magnetLock` WHERE `magnetId` = ? ORDER BY `magnetLockId` DESC LIMIT 1');
$query->execute([$magnetId]);
return $query->fetch();
}
// Magnet comment
public function getMagnetCommentsTotal(int $magnetId) : int {