[1] | 1 | <?php |
---|
| 2 | /** |
---|
[42] | 3 | * lock.php |
---|
[1] | 4 | * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information |
---|
| 5 | */ |
---|
| 6 | |
---|
| 7 | // require_once dirname(__FILE__) . '/_config.inc.php'; |
---|
[137] | 8 | require_once 'codebase/lib/Lock.inc.php'; |
---|
[1] | 9 | |
---|
| 10 | $auth->requireLogin(); |
---|
[136] | 11 | $app->sslOn(); |
---|
[1] | 12 | |
---|
[22] | 13 | if (getFormData('boomerang', false)) { |
---|
[1] | 14 | // We remember which page we came from so we can go back there. |
---|
[247] | 15 | $boom_url = mb_strpos(getFormData('boomerang'), '/') !== false ? getFormData('boomerang') : $_SERVER['HTTP_REFERER']; |
---|
[136] | 16 | $app->setBoomerangURL($boom_url, 'lock'); |
---|
[53] | 17 | if (isset($_SERVER['HTTP_REFERER'])) { |
---|
[136] | 18 | $app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'cancel-lock'); |
---|
[53] | 19 | } |
---|
[1] | 20 | } |
---|
| 21 | |
---|
[137] | 22 | if (!isset($lock) || !is_a($lock, 'Lock')) { |
---|
| 23 | $lock =& Lock::getInstance($auth); |
---|
[22] | 24 | } |
---|
[1] | 25 | $lock->select(getFormData('lock_id')); |
---|
| 26 | |
---|
| 27 | if (!$lock->isLocked()) { |
---|
[136] | 28 | $app->logMsg('Lock not found with lock_id: ' . getFormData('lock_id') . ', from referrer: ' . $_SERVER['HTTP_REFERER'], LOG_WARNING, __FILE__, __LINE__); |
---|
| 29 | $app->dieBoomerangURL('lock'); |
---|
[1] | 30 | } |
---|
| 31 | |
---|
| 32 | // What action to take. |
---|
| 33 | if (getFormData('unlock', false)) { |
---|
| 34 | $lock->remove(); |
---|
[141] | 35 | $app->raiseMsg(sprintf(_("The record <em>%s</em> has been unlocked, and can now be modified."), $lock->getTitle('title')), MSG_NOTICE, __FILE__, __LINE__); |
---|
[136] | 36 | $app->dieBoomerangURL('lock'); |
---|
[1] | 37 | } else if (getFormData('cancel', false)) { |
---|
[22] | 38 | // 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. |
---|
[136] | 39 | $app->deleteBoomerangURL('lock'); |
---|
| 40 | $app->dieBoomerangURL('cancel-lock'); |
---|
[1] | 41 | } |
---|
| 42 | |
---|
| 43 | // Titles and navigation header. |
---|
[202] | 44 | $nav->add(sprintf(_("Locked record: <em>%s</em>"), $lock->getTitle())); |
---|
[1] | 45 | |
---|
| 46 | // Templates. |
---|
| 47 | include 'header.ihtml'; |
---|
| 48 | $lock->printErrorHTML(); |
---|
| 49 | include 'footer.ihtml'; |
---|
| 50 | |
---|
| 51 | ?> |
---|