aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-03-16 18:18:45 +0100
committerRobin Appelman <icewind1991@gmail.com>2011-03-17 20:47:02 +0100
commit6c4b06390e3e3816f85f3adc4f618077270792e0 (patch)
treeb6d7cfe5508ad40c0fba22acd6f1acfb21b9b4d9
parente5de3dd94bce44b584937eed84710d275faaa760 (diff)
downloadnextcloud-server-6c4b06390e3e3816f85f3adc4f618077270792e0.tar.gz
nextcloud-server-6c4b06390e3e3816f85f3adc4f618077270792e0.zip
add the option to use LIKE instead of = when getting data from OCS
also fix the returned keys
-rw-r--r--inc/lib_ocs.php21
1 files changed, 17 insertions, 4 deletions
diff --git a/inc/lib_ocs.php b/inc/lib_ocs.php
index 08b4b79ae91..2b1e706462a 100644
--- a/inc/lib_ocs.php
+++ b/inc/lib_ocs.php
@@ -508,27 +508,31 @@ class OC_OCS {
* @param string $user
* @param string $app
* @param string $key
+ * @param bool $like use LIKE instead of = when comparing keys
* @return array
*/
- public static function getData($user,$app="",$key="") {
+ public static function getData($user,$app="",$key="",$like=false) {
global $CONFIG_DBTABLEPREFIX;
$user=OC_DB::escape($user);
$key=OC_DB::escape($key);
$app=OC_DB::escape($app);
- $key="$user::$key";//ugly hack for the sake of keeping database scheme compatibiliy
+ $key="$user::$key";//ugly hack for the sake of keeping database scheme compatibiliy, needs to be replaced with a seperate user field the next time we break db compatibiliy
+ $compareFunction=($like)?'LIKE':'=';
+
if($app){
if (!trim($key)) {
$result = OC_DB::select("select app, `key`,value,`timestamp` from {$CONFIG_DBTABLEPREFIX}privatedata where app='$app' order by `timestamp` desc");
} else {
- $result = OC_DB::select("select app, `key`,value,`timestamp` from {$CONFIG_DBTABLEPREFIX}privatedata where app='$app' and `key` ='$key' order by `timestamp` desc");
+ $result = OC_DB::select("select app, `key`,value,`timestamp` from {$CONFIG_DBTABLEPREFIX}privatedata where app='$app' and `key` $compareFunction '$key' order by `timestamp` desc");
}
}else{
if (!trim($key)) {
$result = OC_DB::select("select app, `key`,value,`timestamp` from {$CONFIG_DBTABLEPREFIX}privatedata order by `timestamp` desc");
} else {
- $result = OC_DB::select("select app, `key`,value,`timestamp` from {$CONFIG_DBTABLEPREFIX}privatedata where `key` ='$key' order by `timestamp` desc");
+ $result = OC_DB::select("select app, `key`,value,`timestamp` from {$CONFIG_DBTABLEPREFIX}privatedata where `key` $compareFunction '$key' order by `timestamp` desc");
}
}
+ $result=self::trimKeys($result,$user);
return $result;
}
@@ -587,6 +591,15 @@ class OC_OCS {
return true;
}
}
+
+ //trim username prefixes from $array
+ private static function trimKeys($array,$user){
+ $length=strlen("$user::");
+ foreach($array as &$item){
+ $item['key']=substr($item['key'],$length);
+ }
+ return $array;
+ }
}
?>