From 5f7d053c3a3690b41f6bf86b452cde035bfa62fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Tue, 6 Nov 2012 16:39:58 +0100 Subject: [PATCH] some more checks if file is a shared file --- lib/connector/sabre/directory.php | 10 +++++++--- lib/connector/sabre/node.php | 13 +++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php index 413efef73b7..56c17da1a6e 100644 --- a/lib/connector/sabre/directory.php +++ b/lib/connector/sabre/directory.php @@ -117,16 +117,20 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa */ public function getChildren() { + $source = $this->getFileSource($this->path); + $path = $source['path']; + $user = $source['user']; + $folder_content = OC_Files::getDirectoryContent($this->path); $paths = array(); foreach($folder_content as $info) { - $paths[] = $this->path.'/'.$info['name']; + $paths[] = $path.'/'.$info['name']; } $properties = array_fill_keys($paths, array()); if(count($paths)>0) { $placeholders = join(',', array_fill(0, count($paths), '?')); $query = OC_DB::prepare( 'SELECT * FROM `*PREFIX*properties` WHERE `userid` = ?' . ' AND `propertypath` IN ('.$placeholders.')' ); - array_unshift($paths, OC_User::getUser()); // prepend userid + array_unshift($paths, $user); // prepend userid $result = $query->execute( $paths ); while($row = $result->fetchRow()) { $propertypath = $row['propertypath']; @@ -139,7 +143,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa $nodes = array(); foreach($folder_content as $info) { $node = $this->getChild($info['name'], $info); - $node->setPropertyCache($properties[$this->path.'/'.$info['name']]); + $node->setPropertyCache($properties[$path.'/'.$info['name']]); $nodes[] = $node; } return $nodes; diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php index a740fe6cac1..b116f01cbc7 100644 --- a/lib/connector/sabre/node.php +++ b/lib/connector/sabre/node.php @@ -191,17 +191,19 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr * @return array */ public function getProperties($properties) { - //TODO: Shared files?!? - if (is_null($this->property_cache)) { + + $source = self::getFileSource($this->path); + + if (is_null($this->property_cache) || empty($this->property_cache)) { $query = OC_DB::prepare( 'SELECT * FROM `*PREFIX*properties` WHERE `userid` = ? AND `propertypath` = ?' ); - $result = $query->execute( array( OC_User::getUser(), $this->path )); + $result = $query->execute( array( $source['user'], $source['path'] )); $this->property_cache = array(); while( $row = $result->fetchRow()) { $this->property_cache[$row['propertyname']] = $row['propertyvalue']; } } - + // if the array was empty, we need to return everything if(count($properties) == 0) { return $this->property_cache; @@ -253,7 +255,6 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr */ static public function removeETagPropertyForPath($path) { // remove tags from this and parent paths - $source = self::getFileSource($path); $path = $source['path']; @@ -276,7 +277,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr $query->execute(array_merge( $vals, $paths )); } - private function getFileSource($path) { + protected function getFileSource($path) { if ( OC_App::isEnabled('files_sharing') && !strncmp($path, '/Shared/', 8)) { $source = OC_Files_Sharing_Util::getSourcePath(str_replace('/Shared/', '', $path)); $parts = explode('/', $source, 4);