source: trunk/services/lock.php @ 674

Last change on this file since 674 was 535, checked in by anonymous, 9 years ago

Added nav page ids to service scripts. Logging unauthenticated sessions.

File size: 2.8 KB
RevLine 
[1]1<?php
2/**
[362]3 * The Strangecode Codebase - a general application development framework for PHP
4 * For details visit the project site: <http://trac.strangecode.com/codebase/>
[396]5 * Copyright 2001-2012 Strangecode, LLC
[468]6 *
[362]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.
[468]13 *
[362]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.
[468]18 *
[362]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/**
[42]24 * lock.php
[1]25 */
26
[497]27// Redefine include_path including the codebase/services but allow local templates override global ones.
28ini_set('include_path', join(PATH_SEPARATOR, array(
29    get_include_path(),
30    dirname(__FILE__) . '/templates'
31)));
32
[137]33require_once 'codebase/lib/Lock.inc.php';
[497]34require_once 'codebase/lib/HTML.inc.php';
[1]35
[457]36$app->sslOn();
[1]37$auth->requireLogin();
38
[22]39if (getFormData('boomerang', false)) {
[1]40    // We remember which page we came from so we can go back there.
[247]41    $boom_url = mb_strpos(getFormData('boomerang'), '/') !== false ? getFormData('boomerang') : $_SERVER['HTTP_REFERER'];
[136]42    $app->setBoomerangURL($boom_url, 'lock');
[53]43    if (isset($_SERVER['HTTP_REFERER'])) {
[136]44        $app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'cancel-lock');
[53]45    }
[1]46}
47
[137]48if (!isset($lock) || !is_a($lock, 'Lock')) {
49    $lock =& Lock::getInstance($auth);
[22]50}
[1]51$lock->select(getFormData('lock_id'));
52
53if (!$lock->isLocked()) {
[136]54    $app->logMsg('Lock not found with lock_id: ' . getFormData('lock_id') . ', from referrer: ' . $_SERVER['HTTP_REFERER'], LOG_WARNING, __FILE__, __LINE__);
55    $app->dieBoomerangURL('lock');
[1]56}
57
58// What action to take.
59if (getFormData('unlock', false)) {
60    $lock->remove();
[141]61    $app->raiseMsg(sprintf(_("The record <em>%s</em> has been unlocked, and can now be modified."), $lock->getTitle('title')), MSG_NOTICE, __FILE__, __LINE__);
[136]62    $app->dieBoomerangURL('lock');
[1]63} else if (getFormData('cancel', false)) {
[22]64    // 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]65    $app->deleteBoomerangURL('lock');
66    $app->dieBoomerangURL('cancel-lock');
[1]67}
68
69// Titles and navigation header.
[202]70$nav->add(sprintf(_("Locked record: <em>%s</em>"), $lock->getTitle()));
[535]71$nav->set('id', 'lock');
[1]72
73// Templates.
74include 'header.ihtml';
[497]75// $lock->printErrorHTML();
76include 'lock.ihtml';
[1]77include 'footer.ihtml';
78
Note: See TracBrowser for help on using the repository browser.