summaryrefslogtreecommitdiffstats
path: root/apps/remoteStorage/lib_remoteStorage.php
diff options
context:
space:
mode:
authorMichiel de Jong <michiel@unhosted.org>2011-12-07 21:51:47 +0700
committerMichiel de Jong <michiel@unhosted.org>2011-12-07 21:51:47 +0700
commitb9e6f5e42d54fc91205f03f4b19bbf313278f476 (patch)
tree5aeeb1365cb8610574a2a694aa16a04888571d15 /apps/remoteStorage/lib_remoteStorage.php
parenta0548a416a56f6e0fd3269279777d57156c47d15 (diff)
downloadnextcloud-server-b9e6f5e42d54fc91205f03f4b19bbf313278f476.tar.gz
nextcloud-server-b9e6f5e42d54fc91205f03f4b19bbf313278f476.zip
compliance with http://www.w3.org/community/unhosted/wiki/remoteStorage
Diffstat (limited to 'apps/remoteStorage/lib_remoteStorage.php')
-rw-r--r--apps/remoteStorage/lib_remoteStorage.php30
1 files changed, 14 insertions, 16 deletions
diff --git a/apps/remoteStorage/lib_remoteStorage.php b/apps/remoteStorage/lib_remoteStorage.php
index 4bbadafe7d2..4f19310904e 100644
--- a/apps/remoteStorage/lib_remoteStorage.php
+++ b/apps/remoteStorage/lib_remoteStorage.php
@@ -1,26 +1,25 @@
<?php
class OC_remoteStorage {
- public static function getValidTokens($ownCloudUser, $userAddress, $dataScope) {
- $query=OC_DB::prepare("SELECT token,appUrl FROM *PREFIX*authtoken WHERE user=? AND userAddress=? AND dataScope=? LIMIT 100");
- $result=$query->execute(array($ownCloudUser,$userAddress,$dataScope));
+ public static function getValidTokens($ownCloudUser, $category) {
+ $query=OC_DB::prepare("SELECT token,appUrl FROM *PREFIX*authtoken WHERE user=? AND category=? LIMIT 100");
+ $result=$query->execute(array($ownCloudUser,$category));
$ret = array();
while($row=$result->fetchRow()){
- $ret[$row['token']]=$userAddress;
+ $ret[$row['token']]=true;
}
return $ret;
}
public static function getAllTokens() {
$user=OC_User::getUser();
- $query=OC_DB::prepare("SELECT token,appUrl,userAddress,dataScope FROM *PREFIX*authtoken WHERE user=? LIMIT 100");
+ $query=OC_DB::prepare("SELECT token,appUrl,category FROM *PREFIX*authtoken WHERE user=? LIMIT 100");
$result=$query->execute(array($user));
$ret = array();
while($row=$result->fetchRow()){
$ret[$row['token']] = array(
'appUrl' => $row['appurl'],
- 'userAddress' => $row['useraddress'],
- 'dataScope' => $row['datascope'],
+ 'category' => $row['category'],
);
}
return $ret;
@@ -31,24 +30,23 @@ class OC_remoteStorage {
$query=OC_DB::prepare("DELETE FROM *PREFIX*authtoken WHERE token=? AND user=?");
$result=$query->execute(array($token,$user));
}
- private static function addToken($token, $appUrl, $userAddress, $dataScope){
+ private static function addToken($token, $appUrl, $category){
$user=OC_User::getUser();
- $query=OC_DB::prepare("INSERT INTO *PREFIX*authtoken (`token`,`appUrl`,`user`,`userAddress`,`dataScope`) VALUES(?,?,?,?,?)");
- $result=$query->execute(array($token,$appUrl,$user,$userAddress,$dataScope));
+ $query=OC_DB::prepare("INSERT INTO *PREFIX*authtoken (`token`,`appUrl`,`user`,`category`) VALUES(?,?,?,?)");
+ $result=$query->execute(array($token,$appUrl,$user,$category));
}
- public static function createDataScope($appUrl, $userAddress, $dataScope){
+ public static function createCategory($appUrl, $category) {
$token=uniqid();
- self::addToken($token, $appUrl, $userAddress, $dataScope);
- //TODO: input checking on $userAddress and $dataScope
- list($userName, $userHost) = explode('@', $userAddress);
+ self::addToken($token, $appUrl, $category);
+ //TODO: input checking on $category
OC_Util::setupFS(OC_User::getUser());
- $scopePathParts = array('remoteStorage', 'webdav', $userHost, $userName, $dataScope);
+ $scopePathParts = array('remoteStorage', $category);
for($i=0;$i<=count($scopePathParts);$i++){
$thisPath = '/'.implode('/', array_slice($scopePathParts, 0, $i));
if(!OC_Filesystem::file_exists($thisPath)) {
OC_Filesystem::mkdir($thisPath);
}
}
- return $token;
+ return base64_encode('remoteStorage:'.$token);
}
}