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