From bce0b34b5ec30d2f90c33819545f6ff11c880827 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Thu, 18 Nov 2010 17:17:51 +0800 Subject: [PATCH] Lock.php --- Lock.php | 67 ++++++++++++-------------------------------------------- 1 file changed, 14 insertions(+), 53 deletions(-) diff --git a/Lock.php b/Lock.php index cb3c720f..b06a262d 100644 --- a/Lock.php +++ b/Lock.php @@ -11,6 +11,9 @@ * Do you to prevent them saving and lock it yourself.. * * + * + * + * * -- interacts with Roo and _lock = id.. * * @@ -83,7 +86,16 @@ class Pman_Core_Lock extends Pman 'on_id' => $_REQUEST['on_id'], 'on_table' => $_REQUEST['on_table'] )); - if ($curlock->count()) { + + + + if ($curlock->count() && empty($_REQUEST['force'])) { + $curlock->selectAdd(); + $curlock->selectAdd('distinct(person_id)'); + $ar = $curlock->fetchAll('person_id'); + $p = DB_DataObject::factory('Person'); + + $err = $this->canUnlock(); if ($err !== true) { $this->jerr($err); @@ -102,58 +114,7 @@ class Pman_Core_Lock extends Pman $this->jok($id); } - - function canUnlock() - { - // the only scenario where we can automatically unlock is::: - - // this user owns the lock. - - $curlock = DB_DataObject::factory('Core_locking'); - $curlock->setFrom(array( - 'on_id' => $_REQUEST['on_id'], - 'on_table' => $_REQUEST['on_table'] - )); - $cc = clone($curlock); - // the user who owns the lock is not logged in.. ?? - their last - $curlock->find(); - $users = array(); - while ($curlock->fetch()) { - $u = DB_DataObject::factory('Person'); - $u->get($curlock->person_id); - if (!$u->isCurrentlyLoggedIn()) { - $cc = clone($curlock); - $cc->delete(); - continue; - } - $users[] = clone($u); - - } - if (empty($users)) { - return true; - - } - // situations - - //- the user is logged in, and we can clear it.. - - //- the user is logged in multiple times, on different browser.. - - //- the user is logged in multiple times on the same browser.. - - - - // one of two error messages.. - - $this->jerr("Item is Locked by " . $u->name . ' (' . $u->email . "), Try asking them to log out"); - - return true; - - - - - - } + -- 2.39.2