we need to add the owner of the file as parameter in case someone else like the owner edits the file; if $includeOwner is set than add owner also if no other recipient was found. This changes enable all user with write access to the file to edit it and to encrypt it to the right list of users again
This commit is contained in:
parent
1df36e0c88
commit
fe58e4b1a6
|
@ -127,21 +127,21 @@ class Share {
|
||||||
/**
|
/**
|
||||||
* @brief Find which users can access a shared item
|
* @brief Find which users can access a shared item
|
||||||
* @param $path to the file
|
* @param $path to the file
|
||||||
|
* @param $user owner of the file
|
||||||
* @param include owner to the list of users with access to the file
|
* @param include owner to the list of users with access to the file
|
||||||
* @return array
|
* @return array
|
||||||
* @note $path needs to be relative to user data dir, e.g. 'file.txt'
|
* @note $path needs to be relative to user data dir, e.g. 'file.txt'
|
||||||
* not '/admin/data/file.txt'
|
* not '/admin/data/file.txt'
|
||||||
*/
|
*/
|
||||||
public static function getUsersSharingFile( $path, $includeOwner = false, $removeDuplicates = true ) {
|
public static function getUsersSharingFile( $path, $user, $includeOwner = false, $removeDuplicates = true ) {
|
||||||
|
|
||||||
$user = \OCP\User::getUser();
|
|
||||||
$path_parts = explode(DIRECTORY_SEPARATOR, trim($path, DIRECTORY_SEPARATOR));
|
$path_parts = explode(DIRECTORY_SEPARATOR, trim($path, DIRECTORY_SEPARATOR));
|
||||||
$path = '';
|
$path = '';
|
||||||
$shares = array();
|
$shares = array();
|
||||||
|
$view = new \OC\Files\View('/'.$user.'/files/');
|
||||||
foreach ($path_parts as $p) {
|
foreach ($path_parts as $p) {
|
||||||
$path .= '/'.$p;
|
$path .= '/'.$p;
|
||||||
$meta = \OC\Files\Filesystem::getFileInfo(\OC_Filesystem::normalizePath($path));
|
$meta = $view->getFileInfo(\OC_Filesystem::normalizePath($path));
|
||||||
$source = $meta['fileid'];
|
$source = $meta['fileid'];
|
||||||
|
|
||||||
// Fetch all shares of this file path from DB
|
// Fetch all shares of this file path from DB
|
||||||
|
@ -203,12 +203,9 @@ class Share {
|
||||||
$shares[] = "ownCloud";
|
$shares[] = "ownCloud";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Include owner in list of users, if requested
|
||||||
if ( ! empty( $shares ) ) {
|
if ( $includeOwner ) {
|
||||||
// Include owner in list of users, if requested
|
$shares[] = $user;
|
||||||
if ( $includeOwner ) {
|
|
||||||
$shares[] = $user;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_unique($shares);
|
return array_unique($shares);
|
||||||
|
|
Loading…
Reference in New Issue