some more checks if file is a shared file

This commit is contained in:
Björn Schießle 2012-11-06 16:39:58 +01:00
parent 56c8976bac
commit 5f7d053c3a
2 changed files with 14 additions and 9 deletions

View 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;

View 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)) {
$source = OC_Files_Sharing_Util::getSourcePath(str_replace('/Shared/', '', $path));
$parts = explode('/', $source, 4);