summaryrefslogtreecommitdiffstats
path: root/lib/filecache.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-02-08 17:29:54 +0100
committerRobin Appelman <icewind@owncloud.com>2012-02-08 17:29:54 +0100
commitbcebfbfbe229b5fdb1cfc1c058e11e78550ff088 (patch)
tree306c79cc32a9bd486a63c019c7e754ae13815e10 /lib/filecache.php
parent36d696c30dcd1dbb4f92293fef852a2afc19c156 (diff)
downloadnextcloud-server-bcebfbfbe229b5fdb1cfc1c058e11e78550ff088.tar.gz
nextcloud-server-bcebfbfbe229b5fdb1cfc1c058e11e78550ff088.zip
bugfix in searching files by mimetype
Diffstat (limited to 'lib/filecache.php')
-rw-r--r--lib/filecache.php22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/filecache.php b/lib/filecache.php
index 964099c7fcd..a053e4cbc1b 100644
--- a/lib/filecache.php
+++ b/lib/filecache.php
@@ -466,6 +466,7 @@ class OC_FileCache{
* fine files by mimetype
* @param string $part1
* @param string $part2 (optional)
+ * @param string root (optional)
* @return array of file paths
*
* $part1 and $part2 together form the complete mimetype.
@@ -474,17 +475,24 @@ class OC_FileCache{
* seccond mimetype part can be ommited
* e.g. searchByMime('audio')
*/
- public static function searchByMime($part1,$part2=''){
- if($part2){
- $query=OC_DB::prepare('SELECT path FROM *PREFIX*fscache WHERE mimepart=?');
- $result=$query->execute(array($part1));
+ public static function searchByMime($part1,$part2='',$root=''){
+ if(!$root){
+ $root=OC_Filesystem::getRoot();
+ }elseif($root='/'){
+ $root='';
+ }
+ $rootLen=strlen($root);
+ $user=OC_User::getUser();
+ if(!$part2){
+ $query=OC_DB::prepare('SELECT path FROM *PREFIX*fscache WHERE mimepart=? AND user=?');
+ $result=$query->execute(array($part1,$user));
}else{
- $query=OC_DB::prepare('SELECT path FROM *PREFIX*fscache WHERE mimetype=?');
- $result=$query->execute(array($part1.'/'.$part2));
+ $query=OC_DB::prepare('SELECT path FROM *PREFIX*fscache WHERE mimetype=? AND user=?');
+ $result=$query->execute(array($part1.'/'.$part2,$user));
}
$names=array();
while($row=$result->fetchRow()){
- $names[]=$row['path'];
+ $names[]=substr($row['path'],$rootLen);
}
return $names;
}