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

@ -155,6 +155,20 @@ else if (!($user->address == $db->getUser($magnet->userId)->address || in_array(
// Process form
else {
// Validate magnet lock
if ($lastMagnetLock = $db->findLastMagnetLock($magnet->magnetId))
{
if ($lastMagnetLock->userId != $user->userId &&
$lastMagnetLock->timeAdded > time() - MAGNET_EDITOR_LOCK_TIMEOUT)
{
$response->success = false;
$response->message = _('This form have opened by owner or moderator, to prevent overwriting, try attempt later!');
}
}
// Lock form for moderators
$db->addMagnetLock($magnet->magnetId, $user->userId, time());
// Update form
if (!empty($_POST)) {