]> source.dussan.org Git - nextcloud-server.git/commitdiff
move getUidAndFilename() tu util.php
authorBjörn Schießle <schiessle@owncloud.com>
Tue, 26 Mar 2013 11:39:55 +0000 (12:39 +0100)
committerBjörn Schießle <schiessle@owncloud.com>
Tue, 26 Mar 2013 11:39:55 +0000 (12:39 +0100)
apps/files_encryption/lib/keymanager.php
apps/files_encryption/lib/util.php

index 19c9de3ece6c7c155636b61e4ffd43bec1ac17e6..23c061b8e630d1c15861136f7f6eec70f3c430b5 100755 (executable)
@@ -28,23 +28,6 @@ namespace OCA\Encryption;
  * @note Where a method requires a view object, it's root must be '/'\r
  */\r
 class Keymanager {\r
-\r
-       /**\r
-        * @brief get uid of the owners of the file and the path to the file\r
-        * @param $filename\r
-        * @return array\r
-        */\r
-       public static function getUidAndFilename($filename) {\r
-               $uid = \OC\Files\Filesystem::getOwner($filename);\r
-\r
-               \OC\Files\Filesystem::initMountPoints($uid);\r
-               if ( $uid != \OCP\User::getUser() ) {\r
-                       $info = \OC\Files\Filesystem::getFileInfo($filename);\r
-                       $ownerView = new \OC\Files\View('/'.$uid.'/files');\r
-                       $filename = $ownerView->getPath($info['fileid']);\r
-               }\r
-               return array($uid, $filename);\r
-       }\r
                \r
        /**\r
         * @brief retrieve the ENCRYPTED private key from a user\r
@@ -282,7 +265,9 @@ class Keymanager {
         */\r
        public static function setShareKey( \OC_FilesystemView $view, $path, $userId, $shareKey ) {\r
 \r
-               list($owner, $filename) = self::getUidAndFilename($path);\r
+               $util = new Util( $view, $userId );\r
+\r
+               list($owner, $filename) = $util->getUidAndFilename($path);\r
 \r
                $basePath = '/' . $owner . '/files_encryption/share-keys';\r
                \r
@@ -349,7 +334,10 @@ class Keymanager {
        public static function getShareKey( \OC_FilesystemView $view, $userId, $filePath ) {\r
                \r
                \OC_FileProxy::$enabled = false;\r
-               list($owner, $filename) = self::getUidAndFilename($filePath);\r
+\r
+               $util = new Util( $view, $userId );\r
+\r
+               list($owner, $filename) = $util->getUidAndFilename($filePath);\r
 \r
                $shareKeyPath = '/' . $owner . '/files_encryption/share-keys/' . $filename . '.' . $userId . '.shareKey';\r
                if ( $view->file_exists( $shareKeyPath ) ) {\r
index b86e7f421b86a70b2adf618b2e416bad2cb6de53..5276dae99a1ba2a26880880d5df094cd3e116ae4 100644 (file)
@@ -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);
+       }
+
 }