Browse Source

redirect to magnet page on edit success, unlock editor session

main
ghost 1 year ago
parent
commit
c95213e007
  1. 11
      src/library/database.php
  2. 19
      src/public/edit.php

11
src/library/database.php

@ -960,6 +960,17 @@ class Database {
return $this->_db->lastInsertId(); return $this->_db->lastInsertId();
} }
public function flushMagnetLock(int $magnetId) : int {
$this->_debug->query->update->total++;
$query = $this->_db->prepare('DELETE FROM `magnetLock` WHERE `magnetId` = ?');
$query->execute([$magnetId]);
return $query->rowCount();
}
public function findLastMagnetLock(int $magnetId) { public function findLastMagnetLock(int $magnetId) {
$this->_debug->query->select->total++; $this->_debug->query->select->total++;

19
src/public/edit.php

@ -360,9 +360,28 @@ else {
} }
} }
// Is valid
if ($response->success &&
$response->form->metaTitle->valid->success &&
$response->form->metaDescription->valid->success &&
$response->form->tr->valid->success &&
$response->form->as->valid->success &&
$response->form->xs->valid->success)
{
// Unlock form
$db->flushMagnetLock($magnet->magnetId);
// Return redirect to the magnet page
header(
sprintf('Location: %s/magnet.php?magnetId=%s', WEBSITE_URL, $magnet->magnetId)
);
}
else
{
// Refresh magnet data // Refresh magnet data
$magnet = $db->getMagnet($magnet->magnetId); $magnet = $db->getMagnet($magnet->magnetId);
} }
}
// Meta Title, auto-replace with Display Name on empty value // Meta Title, auto-replace with Display Name on empty value
$response->form->metaTitle->value = $magnet->metaTitle ? $magnet->metaTitle : $magnet->dn; $response->form->metaTitle->value = $magnet->metaTitle ? $magnet->metaTitle : $magnet->dn;

Loading…
Cancel
Save