1 | <?php |
---|
2 | /** |
---|
3 | * The Strangecode Codebase - a general application development framework for PHP |
---|
4 | * For details visit the project site: <http://trac.strangecode.com/codebase/> |
---|
5 | * Copyright 2001-2012 Strangecode, LLC |
---|
6 | * |
---|
7 | * This file is part of The Strangecode Codebase. |
---|
8 | * |
---|
9 | * The Strangecode Codebase is free software: you can redistribute it and/or |
---|
10 | * modify it under the terms of the GNU General Public License as published by the |
---|
11 | * Free Software Foundation, either version 3 of the License, or (at your option) |
---|
12 | * any later version. |
---|
13 | * |
---|
14 | * The Strangecode Codebase is distributed in the hope that it will be useful, but |
---|
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
---|
17 | * details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License along with |
---|
20 | * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. |
---|
21 | */ |
---|
22 | |
---|
23 | /** |
---|
24 | * lock.php |
---|
25 | */ |
---|
26 | |
---|
27 | // Redefine include_path including the codebase/services but allow local templates override global ones. |
---|
28 | ini_set('include_path', join(PATH_SEPARATOR, array( |
---|
29 | get_include_path(), |
---|
30 | dirname(__FILE__) . '/templates' |
---|
31 | ))); |
---|
32 | |
---|
33 | require_once 'codebase/lib/Lock.inc.php'; |
---|
34 | require_once 'codebase/lib/HTML.inc.php'; |
---|
35 | |
---|
36 | $auth->requireLogin(); |
---|
37 | |
---|
38 | if (getFormData('boomerang', false)) { |
---|
39 | // We remember which page we came from so we can go back there. |
---|
40 | $boom_url = mb_strpos(getFormData('boomerang'), '/') !== false ? getFormData('boomerang') : $_SERVER['HTTP_REFERER']; |
---|
41 | $app->setBoomerangURL($boom_url, 'lock'); |
---|
42 | if (isset($_SERVER['HTTP_REFERER'])) { |
---|
43 | $app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'cancel-lock'); |
---|
44 | } |
---|
45 | } |
---|
46 | |
---|
47 | if (!isset($lock) || !($lock instanceof \Lock)) { |
---|
48 | $lock =& Lock::getInstance($auth); |
---|
49 | } |
---|
50 | $lock->select(getFormData('lock_id')); |
---|
51 | |
---|
52 | if (!$lock->isLocked()) { |
---|
53 | $app->logMsg('Lock not found with lock_id: ' . getFormData('lock_id') . ', from referrer: ' . $_SERVER['HTTP_REFERER'], LOG_WARNING, __FILE__, __LINE__); |
---|
54 | $app->dieBoomerangURL('lock'); |
---|
55 | } |
---|
56 | |
---|
57 | // What action to take. |
---|
58 | if (getFormData('unlock', false)) { |
---|
59 | $lock->remove(); |
---|
60 | $app->raiseMsg(sprintf(_("The record <em>%s</em> has been unlocked, and can now be modified."), $lock->getTitle('title')), MSG_NOTICE, __FILE__, __LINE__); |
---|
61 | $app->dieBoomerangURL('lock'); |
---|
62 | } else if (getFormData('cancel', false)) { |
---|
63 | // 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. |
---|
64 | $app->deleteBoomerangURL('lock'); |
---|
65 | $app->dieBoomerangURL('cancel-lock'); |
---|
66 | } |
---|
67 | |
---|
68 | // Titles and navigation header. |
---|
69 | $nav->add(sprintf(_("Locked record: <em>%s</em>"), $lock->getTitle())); |
---|
70 | $nav->set('id', 'lock'); |
---|
71 | |
---|
72 | // Templates. |
---|
73 | include 'header.ihtml'; |
---|
74 | // $lock->printErrorHTML(); |
---|
75 | include 'lock.ihtml'; |
---|
76 | include 'footer.ihtml'; |
---|
77 | |
---|