summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorFrank Karlitschek <frank@owncloud.org>2012-05-03 13:06:08 +0200
committerFrank Karlitschek <frank@owncloud.org>2012-05-03 13:06:08 +0200
commit97a8af7f2519e9ba01c2ff0c16a3102f716c0d13 (patch)
tree9f6a83c9da6a18ce0cd14f8513c6f647a8edc956 /apps/files_sharing
parentf85d076a4e1df2de8b7b75e379d52fd71807ae01 (diff)
downloadnextcloud-server-97a8af7f2519e9ba01c2ff0c16a3102f716c0d13.tar.gz
nextcloud-server-97a8af7f2519e9ba01c2ff0c16a3102f716c0d13.zip
ported oc_db
Diffstat (limited to 'apps/files_sharing')
-rwxr-xr-xapps/files_sharing/lib_share.php50
-rwxr-xr-xapps/files_sharing/sharedstorage.php4
2 files changed, 27 insertions, 27 deletions
diff --git a/apps/files_sharing/lib_share.php b/apps/files_sharing/lib_share.php
index 96df29c4f42..fe8aa64fa81 100755
--- a/apps/files_sharing/lib_share.php
+++ b/apps/files_sharing/lib_share.php
@@ -40,7 +40,7 @@ class OC_Share {
*/
public function __construct($source, $uid_shared_with, $permissions) {
$uid_owner = OCP\USER::getUser();
- $query = OC_DB::prepare("INSERT INTO *PREFIX*sharing VALUES(?,?,?,?,?)");
+ $query = OCP\DB::prepare("INSERT INTO *PREFIX*sharing VALUES(?,?,?,?,?)");
if ($uid_shared_with == self::PUBLICLINK) {
$token = sha1("$uid_shared_with-$source");
$query->execute(array($uid_owner, self::PUBLICLINK, $source, $token, $permissions));
@@ -69,7 +69,7 @@ class OC_Share {
}
foreach ($uid_shared_with as $uid) {
// Check if this item is already shared with the user
- $checkSource = OC_DB::prepare("SELECT source FROM *PREFIX*sharing WHERE source = ? AND uid_shared_with ".self::getUsersAndGroups($uid));
+ $checkSource = OCP\DB::prepare("SELECT source FROM *PREFIX*sharing WHERE source = ? AND uid_shared_with ".self::getUsersAndGroups($uid));
$resultCheckSource = $checkSource->execute(array($source))->fetchAll();
// TODO Check if the source is inside a folder
if (count($resultCheckSource) > 0 && !isset($gid)) {
@@ -101,11 +101,11 @@ class OC_Share {
// Add file to filesystem cache
$userDirectory = "/".OCP\USER::getUser()."/files";
$data = OC_Filecache::get(substr($source, strlen($userDirectory)));
- $parentQuery = OC_DB::prepare('SELECT id FROM *PREFIX*fscache WHERE path=?');
+ $parentQuery = OCP\DB::prepare('SELECT id FROM *PREFIX*fscache WHERE path=?');
$parentResult = $parentQuery->execute(array($sharedFolder))->fetchRow();
$parent = $parentResult['id'];
$is_writeable = $permissions & OC_Share::WRITE;
- $cacheQuery = OC_DB::prepare('INSERT INTO *PREFIX*fscache(parent, name, path, size, mtime, ctime, mimetype, mimepart, user, writable) VALUES(?,?,?,?,?,?,?,?,?,?)');
+ $cacheQuery = OCP\DB::prepare('INSERT INTO *PREFIX*fscache(parent, name, path, size, mtime, ctime, mimetype, mimepart, user, writable) VALUES(?,?,?,?,?,?,?,?,?,?)');
$cacheQuery->execute(array($parent, basename($target), $target, $data['size'], $data['mtime'], $data['ctime'], $data['mimetype'], dirname($data['mimetype']), $uid, $is_writeable));
}
}
@@ -169,7 +169,7 @@ class OC_Share {
$folders = self::getParentFolders($oldTarget);
$source = $folders['source'].substr($oldTarget, strlen($folders['target']));
$item = self::getItem($folders['target']);
- $query = OC_DB::prepare("INSERT INTO *PREFIX*sharing VALUES(?,?,?,?,?)");
+ $query = OCP\DB::prepare("INSERT INTO *PREFIX*sharing VALUES(?,?,?,?,?)");
$query->execute(array($item[0]['uid_owner'], OCP\USER::getUser(), $source, $newTarget, $item[0]['permissions']));
}
@@ -180,7 +180,7 @@ class OC_Share {
*/
public static function getItem($target) {
$target = self::cleanPath($target);
- $query = OC_DB::prepare("SELECT uid_owner, source, permissions FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with = ? LIMIT 1");
+ $query = OCP\DB::prepare("SELECT uid_owner, source, permissions FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with = ? LIMIT 1");
return $query->execute(array($target, OCP\USER::getUser()))->fetchAll();
}
@@ -191,7 +191,7 @@ class OC_Share {
*/
public static function getMySharedItem($source) {
$source = self::cleanPath($source);
- $query = OC_DB::prepare("SELECT uid_shared_with, permissions FROM *PREFIX*sharing WHERE source = ? AND uid_owner = ?");
+ $query = OCP\DB::prepare("SELECT uid_shared_with, permissions FROM *PREFIX*sharing WHERE source = ? AND uid_owner = ?");
$result = $query->execute(array($source, OCP\USER::getUser()))->fetchAll();
if (count($result) > 0) {
return $result;
@@ -207,7 +207,7 @@ class OC_Share {
* @return An array with all items the user is sharing
*/
public static function getMySharedItems() {
- $query = OC_DB::prepare("SELECT uid_shared_with, source, permissions FROM *PREFIX*sharing WHERE uid_owner = ?");
+ $query = OCP\DB::prepare("SELECT uid_shared_with, source, permissions FROM *PREFIX*sharing WHERE uid_owner = ?");
return $query->execute(array(OCP\USER::getUser()))->fetchAll();
}
@@ -226,7 +226,7 @@ class OC_Share {
$folder .= "/";
}
$length = strlen($folder);
- $query = OC_DB::prepare("SELECT uid_owner, source, target, permissions FROM *PREFIX*sharing WHERE SUBSTR(source, 1, ?) = ? OR SUBSTR(target, 1, ?) = ? AND uid_shared_with ".self::getUsersAndGroups());
+ $query = OCP\DB::prepare("SELECT uid_owner, source, target, permissions FROM *PREFIX*sharing WHERE SUBSTR(source, 1, ?) = ? OR SUBSTR(target, 1, ?) = ? AND uid_shared_with ".self::getUsersAndGroups());
return $query->execute(array($length, $folder, $length, $folder))->fetchAll();
}
@@ -237,7 +237,7 @@ class OC_Share {
*/
public static function getParentFolders($target) {
$target = self::cleanPath($target);
- $query = OC_DB::prepare("SELECT source FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with".self::getUsersAndGroups()." LIMIT 1");
+ $query = OCP\DB::prepare("SELECT source FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with".self::getUsersAndGroups()." LIMIT 1");
// Prevent searching for user directory e.g. '/MTGap/files'
$userDirectory = substr($target, 0, strpos($target, "files") + 5);
$target = dirname($target);
@@ -265,7 +265,7 @@ class OC_Share {
*/
public static function getSource($target) {
$target = self::cleanPath($target);
- $query = OC_DB::prepare("SELECT source FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with ".self::getUsersAndGroups()." LIMIT 1");
+ $query = OCP\DB::prepare("SELECT source FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with ".self::getUsersAndGroups()." LIMIT 1");
$result = $query->execute(array($target))->fetchAll();
if (count($result) > 0) {
return $result[0]['source'];
@@ -281,7 +281,7 @@ class OC_Share {
public static function getTarget($source) {
$source = self::cleanPath($source);
- $query = OC_DB::prepare("SELECT target FROM *PREFIX*sharing WHERE source = ? AND uid_owner = ? LIMIT 1");
+ $query = OCP\DB::prepare("SELECT target FROM *PREFIX*sharing WHERE source = ? AND uid_owner = ? LIMIT 1");
$result = $query->execute(array($source, OCP\USER::getUser()))->fetchAll();
if (count($result) > 0) {
return $result[0]['target'];
@@ -298,7 +298,7 @@ class OC_Share {
*/
public static function getPermissions($target) {
$target = self::cleanPath($target);
- $query = OC_DB::prepare("SELECT permissions FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with ".self::getUsersAndGroups()." LIMIT 1");
+ $query = OCP\DB::prepare("SELECT permissions FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with ".self::getUsersAndGroups()." LIMIT 1");
$result = $query->execute(array($target))->fetchAll();
if (count($result) > 0) {
return $result[0]['permissions'];
@@ -330,7 +330,7 @@ class OC_Share {
* @return The token of the public link, a sha1 hash
*/
public static function getTokenFromSource($source) {
- $query = OC_DB::prepare("SELECT target FROM *PREFIX*sharing WHERE source = ? AND uid_shared_with = ? AND uid_owner = ? LIMIT 1");
+ $query = OCP\DB::prepare("SELECT target FROM *PREFIX*sharing WHERE source = ? AND uid_shared_with = ? AND uid_owner = ? LIMIT 1");
$result = $query->execute(array($source, self::PUBLICLINK, OCP\USER::getUser()))->fetchAll();
if (count($result) > 0) {
return $result[0]['target'];
@@ -350,7 +350,7 @@ class OC_Share {
public static function setTarget($oldTarget, $newTarget) {
$oldTarget = self::cleanPath($oldTarget);
$newTarget = self::cleanPath($newTarget);
- $query = OC_DB::prepare("UPDATE *PREFIX*sharing SET target = REPLACE(target, ?, ?) WHERE uid_shared_with ".self::getUsersAndGroups());
+ $query = OCP\DB::prepare("UPDATE *PREFIX*sharing SET target = REPLACE(target, ?, ?) WHERE uid_shared_with ".self::getUsersAndGroups());
$query->execute(array($oldTarget, $newTarget));
}
@@ -365,7 +365,7 @@ class OC_Share {
*/
public static function setPermissions($source, $uid_shared_with, $permissions) {
$source = self::cleanPath($source);
- $query = OC_DB::prepare("UPDATE *PREFIX*sharing SET permissions = ? WHERE SUBSTR(source, 1, ?) = ? AND uid_owner = ? AND uid_shared_with ".self::getUsersAndGroups($uid_shared_with));
+ $query = OCP\DB::prepare("UPDATE *PREFIX*sharing SET permissions = ? WHERE SUBSTR(source, 1, ?) = ? AND uid_owner = ? AND uid_shared_with ".self::getUsersAndGroups($uid_shared_with));
$query->execute(array($permissions, strlen($source), $source, OCP\USER::getUser()));
}
@@ -379,7 +379,7 @@ class OC_Share {
*/
public static function unshare($source, $uid_shared_with) {
$source = self::cleanPath($source);
- $query = OC_DB::prepare("DELETE FROM *PREFIX*sharing WHERE SUBSTR(source, 1, ?) = ? AND uid_owner = ? AND uid_shared_with ".self::getUsersAndGroups($uid_shared_with));
+ $query = OCP\DB::prepare("DELETE FROM *PREFIX*sharing WHERE SUBSTR(source, 1, ?) = ? AND uid_owner = ? AND uid_shared_with ".self::getUsersAndGroups($uid_shared_with));
$query->execute(array(strlen($source), $source, OCP\USER::getUser()));
}
@@ -394,10 +394,10 @@ class OC_Share {
public static function unshareFromMySelf($target, $delete = true) {
$target = self::cleanPath($target);
if ($delete) {
- $query = OC_DB::prepare("DELETE FROM *PREFIX*sharing WHERE SUBSTR(target, 1, ?) = ? AND uid_shared_with ".self::getUsersAndGroups());
+ $query = OCP\DB::prepare("DELETE FROM *PREFIX*sharing WHERE SUBSTR(target, 1, ?) = ? AND uid_shared_with ".self::getUsersAndGroups());
$query->execute(array(strlen($target), $target));
} else {
- $query = OC_DB::prepare("UPDATE *PREFIX*sharing SET permissions = ? WHERE SUBSTR(target, 1, ?) = ? AND uid_shared_with ".self::getUsersAndGroups());
+ $query = OCP\DB::prepare("UPDATE *PREFIX*sharing SET permissions = ? WHERE SUBSTR(target, 1, ?) = ? AND uid_shared_with ".self::getUsersAndGroups());
$query->execute(array(self::UNSHARED, strlen($target), $target));
}
}
@@ -411,7 +411,7 @@ class OC_Share {
if ($target = self::getTarget($source)) {
// Forward hook to notify of changes to target file
OC_Hook::emit("OC_Filesystem", "post_delete", array('path' => $target));
- $query = OC_DB::prepare("DELETE FROM *PREFIX*sharing WHERE SUBSTR(source, 1, ?) = ? AND uid_owner = ?");
+ $query = OCP\DB::prepare("DELETE FROM *PREFIX*sharing WHERE SUBSTR(source, 1, ?) = ? AND uid_owner = ?");
$query->execute(array(strlen($source), $source, OCP\USER::getUser()));
}
@@ -424,7 +424,7 @@ class OC_Share {
public static function renameItem($arguments) {
$oldSource = "/".OCP\USER::getUser()."/files".self::cleanPath($arguments['oldpath']);
$newSource = "/".OCP\USER::getUser()."/files".self::cleanPath($arguments['newpath']);
- $query = OC_DB::prepare("UPDATE *PREFIX*sharing SET source = REPLACE(source, ?, ?) WHERE uid_owner = ?");
+ $query = OCP\DB::prepare("UPDATE *PREFIX*sharing SET source = REPLACE(source, ?, ?) WHERE uid_owner = ?");
$query->execute(array($oldSource, $newSource, OCP\USER::getUser()));
}
@@ -437,17 +437,17 @@ class OC_Share {
}
public static function removeUser($arguments) {
- $query = OC_DB::prepare('DELETE FROM *PREFIX*sharing WHERE uid_owner = ? OR uid_shared_with '.self::getUsersAndGroups($arguments['uid']));
+ $query = OCP\DB::prepare('DELETE FROM *PREFIX*sharing WHERE uid_owner = ? OR uid_shared_with '.self::getUsersAndGroups($arguments['uid']));
$query->execute(array($arguments['uid']));
}
public static function addToGroupShare($arguments) {
$length = -strlen($arguments['gid']) - 1;
- $query = OC_DB::prepare('SELECT uid_owner, source, permissions FROM *PREFIX*sharing WHERE SUBSTR(uid_shared_with, '.$length.') = ?');
+ $query = OCP\DB::prepare('SELECT uid_owner, source, permissions FROM *PREFIX*sharing WHERE SUBSTR(uid_shared_with, '.$length.') = ?');
$gid = '@'.$arguments['gid'];
$result = $query->execute(array($gid))->fetchAll();
if (count($result) > 0) {
- $query = OC_DB::prepare('INSERT INTO *PREFIX*sharing VALUES(?,?,?,?,?)');
+ $query = OCP\DB::prepare('INSERT INTO *PREFIX*sharing VALUES(?,?,?,?,?)');
$sharedFolder = '/'.$arguments['uid'].'/files/Shared/';
$lastSource = '';
for ($i = 0; $i < count($result) - 1; $i++) {
@@ -460,7 +460,7 @@ class OC_Share {
}
public static function removeFromGroupShare($arguments) {
- $query = OC_DB::prepare('DELETE FROM *PREFIX*sharing WHERE uid_shared_with = ?');
+ $query = OCP\DB::prepare('DELETE FROM *PREFIX*sharing WHERE uid_shared_with = ?');
$query->execute(array($arguments['uid'].'@'.$arguments['gid']));
}
diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php
index f64d52551ff..c7c2131f872 100755
--- a/apps/files_sharing/sharedstorage.php
+++ b/apps/files_sharing/sharedstorage.php
@@ -227,7 +227,7 @@ class OC_Filestorage_Shared extends OC_Filestorage {
}
if ($size > 0) {
$dbpath = rtrim($this->datadir.$path, "/");
-// $query = OC_DB::prepare("INSERT INTO *PREFIX*foldersize VALUES(?,?)");
+// $query = OCP\DB::prepare("INSERT INTO *PREFIX*foldersize VALUES(?,?)");
// $result = $query->execute(array($dbpath, $size));
}
}
@@ -241,7 +241,7 @@ class OC_Filestorage_Shared extends OC_Filestorage {
$path = dirname($path);
}
$dbpath = rtrim($this->datadir.$path, "/");
-// $query = OC_DB::prepare("DELETE FROM *PREFIX*/*foldersize*/ WHERE path = ?");
+// $query = OCP\DB::prepare("DELETE FROM *PREFIX*/*foldersize*/ WHERE path = ?");
// $result = $query->execute(array($dbpath));
if ($path != "/" && $path != "") {
$parts = explode("/", $path);