* Copyright 2001-2012 Strangecode, LLC
*
* This file is part of The Strangecode Codebase.
*
* The Strangecode Codebase is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* The Strangecode Codebase is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* The Strangecode Codebase. If not, see .
*/
/**
* lock.php
*/
require_once dirname(__FILE__) . '/_config.inc.php';
require_once 'codebase/lib/Lock.inc.php';
require_once 'codebase/lib/HTML.inc.php';
$app->sslOn();
$auth->requireLogin();
if (getFormData('boomerang', false)) {
// We remember which page we came from so we can go back there.
$boom_url = mb_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.inc.html';
// $lock->printErrorHTML();
include 'codebase/services/templates/lock.ihtml';
include 'footer.inc.html';