From a65d741a3fda0a35326e0dee7627a69c00e3d0f1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Tue, 26 Mar 2013 12:39:55 +0100 Subject: [PATCH] move getUidAndFilename() tu util.php --- apps/files_encryption/lib/keymanager.php | 26 +++++++----------------- apps/files_encryption/lib/util.php | 17 ++++++++++++++++ 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php index 19c9de3ece6..23c061b8e63 100755 --- a/apps/files_encryption/lib/keymanager.php +++ b/apps/files_encryption/lib/keymanager.php @@ -28,23 +28,6 @@ namespace OCA\Encryption; * @note Where a method requires a view object, it's root must be '/' */ class Keymanager { - - /** - * @brief get uid of the owners of the file and the path to the file - * @param $filename - * @return array - */ - public static function getUidAndFilename($filename) { - $uid = \OC\Files\Filesystem::getOwner($filename); - - \OC\Files\Filesystem::initMountPoints($uid); - if ( $uid != \OCP\User::getUser() ) { - $info = \OC\Files\Filesystem::getFileInfo($filename); - $ownerView = new \OC\Files\View('/'.$uid.'/files'); - $filename = $ownerView->getPath($info['fileid']); - } - return array($uid, $filename); - } /** * @brief retrieve the ENCRYPTED private key from a user @@ -282,7 +265,9 @@ class Keymanager { */ public static function setShareKey( \OC_FilesystemView $view, $path, $userId, $shareKey ) { - list($owner, $filename) = self::getUidAndFilename($path); + $util = new Util( $view, $userId ); + + list($owner, $filename) = $util->getUidAndFilename($path); $basePath = '/' . $owner . '/files_encryption/share-keys'; @@ -349,7 +334,10 @@ class Keymanager { public static function getShareKey( \OC_FilesystemView $view, $userId, $filePath ) { \OC_FileProxy::$enabled = false; - list($owner, $filename) = self::getUidAndFilename($filePath); + + $util = new Util( $view, $userId ); + + list($owner, $filename) = $util->getUidAndFilename($filePath); $shareKeyPath = '/' . $owner . '/files_encryption/share-keys/' . $filename . '.' . $userId . '.shareKey'; if ( $view->file_exists( $shareKeyPath ) ) { diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php index b86e7f421b8..5276dae99a1 100644 --- a/apps/files_encryption/lib/util.php +++ b/apps/files_encryption/lib/util.php @@ -815,4 +815,21 @@ class Util { return true; } + /** + * @brief get uid of the owners of the file and the path to the file + * @param $filename + * @return array + */ + public function getUidAndFilename($filename) { + $uid = \OC\Files\Filesystem::getOwner($filename); + + \OC\Files\Filesystem::initMountPoints($uid); + if ( $uid != \OCP\User::getUser() ) { + $info = \OC\Files\Filesystem::getFileInfo($filename); + $ownerView = new \OC\Files\View('/'.$uid.'/files'); + $filename = $ownerView->getPath($info['fileid']); + } + return array($uid, $filename); + } + } -- 2.39.5