source: trunk/services/lock.php @ 25

Last change on this file since 25 was 22, checked in by scdev, 18 years ago

More bugs and shifting things about.

File size: 1.7 KB
Line 
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';
8require_once 'codebase/lib/RecordLock.inc.php';
9
10$auth->requireLogin();
11App::sslOn();
12
13if (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    App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'cancel-lock');
18}
19
20if (!isset($lock) || !is_a($lock, 'RecordLock')) {
21    $lock =& RecordLock::getInstance($auth);
22}
23$lock->select(getFormData('lock_id'));
24
25if (!$lock->isLocked()) {
26    App::logMsg('Lock not found with lock_id: ' . getFormData('lock_id') . ', from referrer: ' . $_SERVER['HTTP_REFERER'], LOG_WARNING, __FILE__, __LINE__);
27    App::dieBoomerangURL('lock');
28}
29
30// What action to take.
31if (getFormData('unlock', false)) {
32    $lock->remove();
33    App::raiseMsg(sprintf(_("The record <strong>%s</strong> has been unlocked, and can now be modified."), $lock->getTitle('title')), MSG_NOTICE, __FILE__, __LINE__);
34    App::dieBoomerangURL('lock');
35} else if (getFormData('cancel', false)) {
36    // 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.
37    App::deleteBoomerangURL('lock');
38    App::dieBoomerangURL('cancel-lock');
39}
40
41// Titles and navigation header.
42$nav->addPage(sprintf(_("Locked record: %s"), $lock->getTitle()));
43
44// Templates.
45include 'header.ihtml';
46$lock->printErrorHTML();
47include 'footer.ihtml';
48
49?>
Note: See TracBrowser for help on using the repository browser.