aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Connector/Sabre/locks.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Connector/Sabre/locks.php')
-rw-r--r--lib/Connector/Sabre/locks.php19
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/Connector/Sabre/locks.php b/lib/Connector/Sabre/locks.php
index ed5ea17beab..6c370b188fb 100644
--- a/lib/Connector/Sabre/locks.php
+++ b/lib/Connector/Sabre/locks.php
@@ -20,6 +20,7 @@ require_once("lib/base.php");
*
* CREATE TABLE locks (
* `id` INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ * `userid` VARCHAR(200),
* `owner` VARCHAR(100),
* `timeout` INTEGER UNSIGNED,
* `created` INTEGER,
@@ -50,8 +51,8 @@ class OC_Connector_Sabre_Locks extends Sabre_DAV_Locks_Backend_Abstract {
// NOTE: the following 10 lines or so could be easily replaced by
// pure sql. MySQL's non-standard string concatination prevents us
// from doing this though.
- $query = 'SELECT owner, token, timeout, created, scope, depth, uri FROM *PREFIX*locks WHERE ((created + timeout) > CAST(? AS UNSIGNED INTEGER)) AND ((uri = ?)';
- $params = array(time(),$uri);
+ $query = 'SELECT * FROM *PREFIX*locks WHERE userid = ? AND ((created + timeout) > CAST(? AS UNSIGNED INTEGER)) AND ((uri = ?)';
+ $params = array(OC_USER::getUser(),time(),$uri);
// We need to check locks for every part in the uri.
$uriParts = explode('/',$uri);
@@ -122,19 +123,17 @@ class OC_Connector_Sabre_Locks extends Sabre_DAV_Locks_Backend_Abstract {
}
if ($exists) {
- $query = OC_DB::prepare( 'UPDATE *PREFIX*locks SET owner = ?, timeout = ?, scope = ?, depth = ?, uri = ?, created = ? WHERE token = ?' );
- $result = $query->execute( array($lockInfo->owner,$lockInfo->timeout,$lockInfo->scope,$lockInfo->depth,$uri,$lockInfo->created,$lockInfo->token));
+ $query = OC_DB::prepare( 'UPDATE *PREFIX*locks SET owner = ?, timeout = ?, scope = ?, depth = ?, uri = ?, created = ? WHERE userid = ? AND token = ?' );
+ $result = $query->execute( array($lockInfo->owner,$lockInfo->timeout,$lockInfo->scope,$lockInfo->depth,$uri,$lockInfo->created,OC_USER::getUser(),$lockInfo->token));
} else {
- $query = OC_DB::prepare( 'INSERT INTO *PREFIX*locks (owner,timeout,scope,depth,uri,created,token) VALUES (?,?,?,?,?,?,?)' );
- $result = $query->execute( array($lockInfo->owner,$lockInfo->timeout,$lockInfo->scope,$lockInfo->depth,$uri,$lockInfo->created,$lockInfo->token));
+ $query = OC_DB::prepare( 'INSERT INTO *PREFIX*locks (userid,owner,timeout,scope,depth,uri,created,token) VALUES (?,?,?,?,?,?,?,?)' );
+ $result = $query->execute( array(OC_USER::getUser(),$lockInfo->owner,$lockInfo->timeout,$lockInfo->scope,$lockInfo->depth,$uri,$lockInfo->created,$lockInfo->token));
}
return true;
}
-
-
/**
* Removes a lock from a uri
*
@@ -144,8 +143,8 @@ class OC_Connector_Sabre_Locks extends Sabre_DAV_Locks_Backend_Abstract {
*/
public function unlock($uri,Sabre_DAV_Locks_LockInfo $lockInfo) {
- $query = OC_DB::prepare( 'DELETE FROM *PREFIX*locks WHERE path=? AND token=?' );
- $result = $query->execute( array($uri,$lockInfo->token));
+ $query = OC_DB::prepare( 'DELETE FROM *PREFIX*locks WHERE userid = ? AND path=? AND token=?' );
+ $result = $query->execute( array(OC_USER::getUser(),$uri,$lockInfo->token));
return $result->numRows() === 1;