]> source.dussan.org Git - nextcloud-server.git/commitdiff
some more checks if file is a shared file
authorBjörn Schießle <schiessle@owncloud.com>
Tue, 6 Nov 2012 15:39:58 +0000 (16:39 +0100)
committerBjörn Schießle <schiessle@owncloud.com>
Thu, 8 Nov 2012 14:18:35 +0000 (15:18 +0100)
lib/connector/sabre/directory.php
lib/connector/sabre/node.php

index 413efef73b79951c627e6b920997fe8fd9d9c33a..56c17da1a6ee115984c3425b61be90babedbd10a 100644 (file)
@@ -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;
index a740fe6cac1d086d64633aeb687538759147431e..b116f01cbc7183a83db8c29f404de4c86deb1004 100644 (file)
@@ -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)) {\r
                        $source = OC_Files_Sharing_Util::getSourcePath(str_replace('/Shared/', '', $path));\r
                        $parts = explode('/', $source, 4);\r