зеркало из https://github.com/nextcloud/server.git
Improved formatting of getPublicKeys()
This commit is contained in:
Родитель
453fd66c70
Коммит
398b52e4f0
|
@ -82,19 +82,37 @@ class Keymanager {
|
|||
* @param string path to file
|
||||
* @return array of public keys for the given file
|
||||
*/
|
||||
public static function getPublicKeys($path) {
|
||||
public static function getPublicKeys( $path ) {
|
||||
|
||||
$userId = \OCP\User::getUser();
|
||||
|
||||
$path = ltrim( $path, '/' );
|
||||
|
||||
$filepath = '/'.$userId.'/files/'.$path;
|
||||
|
||||
// Check if sharing is enabled
|
||||
if ( OC_App::isEnabled( 'files_sharing' ) ) {
|
||||
|
||||
// // Check if file was shared with other users
|
||||
// $query = \OC_DB::prepare( "SELECT uid_owner, source, target, uid_shared_with FROM `*PREFIX*sharing` WHERE ( target = ? AND uid_shared_with = ? ) OR source = ? " );
|
||||
// $result = $query->execute( array ($filepath, $userId, $filepath));
|
||||
// $query = \OC_DB::prepare( "
|
||||
// SELECT
|
||||
// uid_owner
|
||||
// , source
|
||||
// , target
|
||||
// , uid_shared_with
|
||||
// FROM
|
||||
// `*PREFIX*sharing`
|
||||
// WHERE
|
||||
// ( target = ? AND uid_shared_with = ? )
|
||||
// OR source = ?
|
||||
// " );
|
||||
//
|
||||
// $result = $query->execute( array ( $filepath, $userId, $filepath ) );
|
||||
//
|
||||
// $users = array();
|
||||
// if ($row = $result->fetchRow()){
|
||||
//
|
||||
// if ( $row = $result->fetchRow() )
|
||||
// {
|
||||
// $source = $row['source'];
|
||||
// $owner = $row['uid_owner'];
|
||||
// $users[] = $owner;
|
||||
|
@ -103,23 +121,34 @@ class Keymanager {
|
|||
// $result = $query->execute( array ($source));
|
||||
// while ( ($row = $result->fetchRow()) ) {
|
||||
// $users[] = $row['uid_shared_with'];
|
||||
//
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
} else {
|
||||
|
||||
// check if it is a file owned by the user and not shared at all
|
||||
$userview = new \OC_FilesystemView( '/'.$userId.'/files/' );
|
||||
if ($userview->file_exists($path)) {
|
||||
|
||||
if ( $userview->file_exists( $path ) ) {
|
||||
|
||||
$users[] = $userId;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$view = new \OC_FilesystemView( '/public-keys/' );
|
||||
|
||||
$keylist = array();
|
||||
|
||||
$count = 0;
|
||||
foreach ($users as $user) {
|
||||
$keylist['key'.++$count] = $view->file_get_contents($user.'.public.key');
|
||||
|
||||
foreach ( $users as $user ) {
|
||||
|
||||
$keylist['key'.++$count] = $view->file_get_contents( $user.'.public.key' );
|
||||
|
||||
}
|
||||
|
||||
return $keylist;
|
||||
|
|
Загрузка…
Ссылка в новой задаче