DataObjects/Core_locking.php
[Pman.Core] / Lock.php
index f92fabc..92025d8 100644 (file)
--- a/Lock.php
+++ b/Lock.php
@@ -22,6 +22,7 @@
  * baseURL + /Core/Lock/lock?on_id=...&on_table=...
  * - returns id or an array of who has the locks.
  * 
+ * Force an unlock after a warning..
  * baseURL + /Core/Lock/lock?on_id=...&on_table=...&force=1
  * - returns id..
  * 
@@ -51,15 +52,12 @@ class Pman_Core_Lock extends Pman
     {
         
         // default action is to attempt to lock..
-        $action = empty($action) ? 'lock' : 'unlock';
-        $this->$action($curlock);
-        
-       
-        
+        $action = empty($action) || $action == 'lock' ? 'lock' : 'unlock';
+        $this->$action();
         
     }
     
-    function unlock($curlock)
+    function unlock()
     {
     
         if (empty($_REQUEST['id'])) {
@@ -99,7 +97,7 @@ class Pman_Core_Lock extends Pman
         ));
         
         
-        $nlocks = $curlock->count() 
+        $nlocks = $curlock->count() ;
         if ($nlocks && empty($_REQUEST['force'])) {
             $curlock->selectAdd();
             $curlock->selectAdd('distinct(person_id), created');
@@ -113,7 +111,7 @@ class Pman_Core_Lock extends Pman
                 $ret[$p->id] = $p->toRooArray();
                 $ret[$p->id]->lock_created = $ar[$p->id];
             }
-            $this->jok($ret);
+            $this->jok(array_values($ret));
             
         }
         if ($nlocks) {