*/
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'];
$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;
* @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;
*/
static public function removeETagPropertyForPath($path) {
// remove tags from this and parent paths
-
$source = self::getFileSource($path);
$path = $source['path'];
$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