From: Alan Knowles Date: Thu, 18 Nov 2010 08:19:18 +0000 (+0800) Subject: Lock.php X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=commitdiff_plain;h=42fadf5046909ab2fffcfcf22483b1849ce59100 Lock.php --- diff --git a/Lock.php b/Lock.php index 69b0171f..9d16bb24 100644 --- a/Lock.php +++ b/Lock.php @@ -25,6 +25,7 @@ class Pman_Core_Lock extends Pman if (empty($_REQUEST['on_id']) || empty($_REQUEST['on_table'])) { $this->jerr("Missing table or id"); } + $action = empty($_REQUEST['unlock']) ? 'lock' : 'unlock'; $tab = str_replace('/', '',$_REQUEST['on_table']); // basic protection?? $x = DB_DataObject::factory($tab); if (!$x->get($_REQUEST['on_id'])) { @@ -33,16 +34,26 @@ class Pman_Core_Lock extends Pman $curlock = DB_DataObject::factory('Core_locking'); $curlock->setFrom(array( 'on_id' => $_REQUEST['on_id'], - 'on_table' => $_REQUEST['on_table'] + 'on_table' => $_REQUEST['on_table'], + //'person_id' => $this->authUser->id, )); $locked = false; if ($curlock->find(true)) { $locked = true; } + $this->$action($curlock); + } + + function unlock($curlock) + { + if (!$curlock->id) { + $this->jok("No lock"); + } - - + $curlock->delete(); + $this->jok('locked'); } + } \ No newline at end of file