requireLogin();
$app->sslOn();
if (getFormData('boomerang', false)) {
// We remember which page we came from so we can go back there.
$boom_url = strpos(getFormData('boomerang'), '/') !== false ? getFormData('boomerang') : $_SERVER['HTTP_REFERER'];
$app->setBoomerangURL($boom_url, 'lock');
if (isset($_SERVER['HTTP_REFERER'])) {
$app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'cancel-lock');
}
}
if (!isset($lock) || !is_a($lock, 'Lock')) {
$lock =& Lock::getInstance($auth);
}
$lock->select(getFormData('lock_id'));
if (!$lock->isLocked()) {
$app->logMsg('Lock not found with lock_id: ' . getFormData('lock_id') . ', from referrer: ' . $_SERVER['HTTP_REFERER'], LOG_WARNING, __FILE__, __LINE__);
$app->dieBoomerangURL('lock');
}
// What action to take.
if (getFormData('unlock', false)) {
$lock->remove();
$app->raiseMsg(sprintf(_("The record %s has been unlocked, and can now be modified."), $lock->getTitle('title')), MSG_NOTICE, __FILE__, __LINE__);
$app->dieBoomerangURL('lock');
} else if (getFormData('cancel', false)) {
// Since the boomerang URL will go back to the locked record, and the record was not unlocked, we must delete the boomerang URL otherwise we'll come back here.
$app->deleteBoomerangURL('lock');
$app->dieBoomerangURL('cancel-lock');
}
// Titles and navigation header.
$nav->add(sprintf(_("Locked record: %s"), $lock->getTitle()));
// Templates.
include 'header.ihtml';
$lock->printErrorHTML();
include 'footer.ihtml';
?>