Implement getDirectoryPermissions() in Shared Permissions, fixes #2846
This commit is contained in:
parent
dbbf195727
commit
5a47054505
2 changed files with 31 additions and 1 deletions
|
@ -70,6 +70,28 @@ class Shared_Permissions extends Permissions {
|
||||||
return $filePermissions;
|
return $filePermissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the permissions for all files in a folder
|
||||||
|
*
|
||||||
|
* @param int $parentId
|
||||||
|
* @param string $user
|
||||||
|
* @return int[]
|
||||||
|
*/
|
||||||
|
public function getDirectoryPermissions($parentId, $user) {
|
||||||
|
// Root of the Shared folder
|
||||||
|
if ($parentId === -1) {
|
||||||
|
return \OCP\Share::getItemsSharedWith('file', \OC_Share_Backend_File::FORMAT_PERMISSIONS);
|
||||||
|
}
|
||||||
|
$permissions = $this->get($parentId, $user);
|
||||||
|
$query = \OC_DB::prepare('SELECT `fileid` FROM `*PREFIX*filecache` WHERE `parent` = ?');
|
||||||
|
$result = $query->execute(array($parentId));
|
||||||
|
$filePermissions = array();
|
||||||
|
while ($row = $result->fetchRow()) {
|
||||||
|
$filePermissions[$row['fileid']] = $permissions;
|
||||||
|
}
|
||||||
|
return $filePermissions;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* remove the permissions for a file
|
* remove the permissions for a file
|
||||||
*
|
*
|
||||||
|
@ -83,4 +105,5 @@ class Shared_Permissions extends Permissions {
|
||||||
public function removeMultiple($fileIds, $user) {
|
public function removeMultiple($fileIds, $user) {
|
||||||
// Not a valid action for Shared Permissions
|
// Not a valid action for Shared Permissions
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}
|
|
@ -26,6 +26,7 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
|
||||||
const FORMAT_FILE_APP_ROOT = 2;
|
const FORMAT_FILE_APP_ROOT = 2;
|
||||||
const FORMAT_OPENDIR = 3;
|
const FORMAT_OPENDIR = 3;
|
||||||
const FORMAT_GET_ALL = 4;
|
const FORMAT_GET_ALL = 4;
|
||||||
|
const FORMAT_PERMISSIONS = 5;
|
||||||
|
|
||||||
private $path;
|
private $path;
|
||||||
|
|
||||||
|
@ -125,6 +126,12 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
|
||||||
$ids[] = $item['file_source'];
|
$ids[] = $item['file_source'];
|
||||||
}
|
}
|
||||||
return $ids;
|
return $ids;
|
||||||
|
} else if ($format === self::FORMAT_PERMISSIONS) {
|
||||||
|
$filePermissions = array();
|
||||||
|
foreach ($items as $item) {
|
||||||
|
$filePermissions[$item['file_source']] = $item['permissions'];
|
||||||
|
}
|
||||||
|
return $filePermissions;
|
||||||
}
|
}
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue