projects
/
Pman.Core
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix #8131 - chinese translations
[Pman.Core]
/
Lock.php
diff --git
a/Lock.php
b/Lock.php
index
f49338a
..
661381f
100644
(file)
--- a/
Lock.php
+++ b/
Lock.php
@@
-40,7
+40,7
@@
class Pman_Core_Lock extends Pman
{
$au = $this->getAuthUser();
if (!$au) {
{
$au = $this->getAuthUser();
if (!$au) {
- $this->jerr
(
"Not authenticated", array('authFailure' => true));
+ $this->jerr
or("LOGIN-NOAUTH",
"Not authenticated", array('authFailure' => true));
}
$this->authUser = $au;
// check that it's a supplier!!!!
}
$this->authUser = $au;
// check that it's a supplier!!!!
@@
-48,7
+48,7
@@
class Pman_Core_Lock extends Pman
return true;
}
return true;
}
- function get($action)
+ function get($action
, $opts=array()
)
{
// should we allow url links to lock things???
// only for debugging??
{
// should we allow url links to lock things???
// only for debugging??
@@
-72,12
+72,12
@@
class Pman_Core_Lock extends Pman
if (empty($_REQUEST['id'])) {
$this->jerr("No lock id");
}
if (empty($_REQUEST['id'])) {
$this->jerr("No lock id");
}
- $curlock = DB_DataObject::factory('
C
ore_locking');
+ $curlock = DB_DataObject::factory('
c
ore_locking');
if (!$curlock->get($_REQUEST['id'])) {
$this->jok("No lock exists"); // been deleted before.. probably ok..
}
if (!$curlock->get($_REQUEST['id'])) {
$this->jok("No lock exists"); // been deleted before.. probably ok..
}
- if ($curlock->person_id != $this->authUser->id) {
+ if ($curlock->person_id != $this->authUser->id
&& empty($_REQUEST['force'])
) {
// this is an error conditon..
$this->jerr("Lock id is invalid");
}
// this is an error conditon..
$this->jerr("Lock id is invalid");
}
@@
-100,21
+100,39
@@
class Pman_Core_Lock extends Pman
}
// is there a current lock on the item..
}
// is there a current lock on the item..
- $curlock = DB_DataObject::factory('
C
ore_locking');
+ $curlock = DB_DataObject::factory('
c
ore_locking');
$curlock->setFrom(array(
'on_id' => $_REQUEST['on_id'],
'on_table' => strtolower($_REQUEST['on_table'])
));
$curlock->setFrom(array(
'on_id' => $_REQUEST['on_id'],
'on_table' => strtolower($_REQUEST['on_table'])
));
+ // remove old locks..
+ $llc = clone($curlock);
+ $exp = date('Y-m-d', strtotime('NOW - 1 WEEK'));
+ $llc->whereAdd("created < '$exp'");
+ if ($llc->count()) {
+ $llc->find();
+ while($llc->fetch()) {
+ $llcd = clone($llc);
+ $llcd->delete();
+
+ }
+ }
+
+
$curlock_ex = clone($curlock);
$curlock_ex = clone($curlock);
- $curlock
_ex->whereAdd('person_id != '. $this->authUser->id)
;
+ $curlock
->person_id = $this->authUser->id
;
+ $curlock_ex->whereAdd('person_id != '. $this->authUser->id);
$nlocks = $curlock_ex->count() ;
$nlocks = $curlock_ex->count() ;
+
+ $ret = false;
+
if ($nlocks && empty($_REQUEST['force'])) {
// DB_DataObjecT::debugLevel(1);
if ($nlocks && empty($_REQUEST['force'])) {
// DB_DataObjecT::debugLevel(1);
- $ar = $curlock->fetchAll('person_id', 'created');
- $p = DB_DataObject::factory('
P
erson');
+ $ar = $curlock
_ex
->fetchAll('person_id', 'created');
+ $p = DB_DataObject::factory('
core_p
erson');
$p->selectAdd();
$p->selectAdd('id,name,email');
$p->selectAdd();
$p->selectAdd('id,name,email');
@@
-125,29
+143,39
@@
class Pman_Core_Lock extends Pman
$ret[$p->id] = $p->toArray();
$ret[$p->id]['lock_created'] = $ar[$p->id];
}
$ret[$p->id] = $p->toArray();
$ret[$p->id]['lock_created'] = $ar[$p->id];
}
- $this->jok(array_values($ret));
+
$this->jok(array_values($ret));
}
// trash the lock if it belongs to current user..
}
// trash the lock if it belongs to current user..
- $
n
locks = $curlock->count();
- if ($
n
locks) {
+ $
u
locks = $curlock->count();
+ if ($
u
locks) {
// trash all the locks..
// trash all the locks..
- $curlock = DB_DataObject::factory('
C
ore_locking');
+ $curlock = DB_DataObject::factory('
c
ore_locking');
$curlock->setFrom(array(
'on_id' => $_REQUEST['on_id'],
$curlock->setFrom(array(
'on_id' => $_REQUEST['on_id'],
- 'on_table' => strtolower($_REQUEST['on_table'])
+ 'on_table' => strtolower($_REQUEST['on_table']),
+ 'person_id' => $this->authUser->id
));
));
- $curlock->person_id = $this->authUser->id;
+
$curlock->find();
while($curlock->fetch()) {
$cc =clone($curlock);
$cc->delete();
}
}
$curlock->find();
while($curlock->fetch()) {
$cc =clone($curlock);
$cc->delete();
}
}
+ if ($nlocks && !empty($_REQUEST['force'])) {
+ // user has decied to delete eveyone elses locks..
+ $curlock_ex->find();
+ while($curlock_ex->fetch()) {
+ $cc =clone($curlock_ex);
+ $cc->delete();
+ }
+ }
+
// make a lock..
// make a lock..
- $curlock = DB_DataObject::factory('
C
ore_locking');
+ $curlock = DB_DataObject::factory('
c
ore_locking');
$curlock->setFrom(array(
'on_id' => $_REQUEST['on_id'],
'on_table' => strtolower($_REQUEST['on_table']),
$curlock->setFrom(array(
'on_id' => $_REQUEST['on_id'],
'on_table' => strtolower($_REQUEST['on_table']),
@@
-155,7
+183,7
@@
class Pman_Core_Lock extends Pman
'person_id' => $this->authUser->id,
));
$id = $curlock->insert();
'person_id' => $this->authUser->id,
));
$id = $curlock->insert();
- $this->jok($id);
+ $this->jok(
$id);
}
}