| @@ 218-238 (lines=21) @@ | ||
| 215 | * @return array |
|
| 216 | * @throws \OC\User\NoUserException |
|
| 217 | */ |
|
| 218 | public static function getUidAndFilename($filename) { |
|
| 219 | $uid = Filesystem::getOwner($filename); |
|
| 220 | $userManager = \OC::$server->getUserManager(); |
|
| 221 | // if the user with the UID doesn't exists, e.g. because the UID points |
|
| 222 | // to a remote user with a federated cloud ID we use the current logged-in |
|
| 223 | // user. We need a valid local user to create the share |
|
| 224 | if (!$userManager->userExists($uid)) { |
|
| 225 | $uid = User::getUser(); |
|
| 226 | } |
|
| 227 | Filesystem::initMountPoints($uid); |
|
| 228 | if ( $uid != User::getUser() ) { |
|
| 229 | $info = Filesystem::getFileInfo($filename); |
|
| 230 | $ownerView = new View('/'.$uid.'/files'); |
|
| 231 | try { |
|
| 232 | $filename = $ownerView->getPath($info['fileid']); |
|
| 233 | } catch (NotFoundException $e) { |
|
| 234 | $filename = null; |
|
| 235 | } |
|
| 236 | } |
|
| 237 | return [$uid, $filename]; |
|
| 238 | } |
|
| 239 | ||
| 240 | /** |
|
| 241 | * Format a path to be relative to the /user/files/ directory |
|
| @@ 80-100 (lines=21) @@ | ||
| 77 | * @return array |
|
| 78 | * @throws \OC\User\NoUserException |
|
| 79 | */ |
|
| 80 | public static function getUidAndFilename($filename) { |
|
| 81 | $uid = Filesystem::getOwner($filename); |
|
| 82 | $userManager = \OC::$server->getUserManager(); |
|
| 83 | // if the user with the UID doesn't exists, e.g. because the UID points |
|
| 84 | // to a remote user with a federated cloud ID we use the current logged-in |
|
| 85 | // user. We need a valid local user to move the file to the right trash bin |
|
| 86 | if (!$userManager->userExists($uid)) { |
|
| 87 | $uid = User::getUser(); |
|
| 88 | } |
|
| 89 | Filesystem::initMountPoints($uid); |
|
| 90 | if ($uid != User::getUser()) { |
|
| 91 | $info = Filesystem::getFileInfo($filename); |
|
| 92 | $ownerView = new View('/' . $uid . '/files'); |
|
| 93 | try { |
|
| 94 | $filename = $ownerView->getPath($info['fileid']); |
|
| 95 | } catch (NotFoundException $e) { |
|
| 96 | $filename = null; |
|
| 97 | } |
|
| 98 | } |
|
| 99 | return [$uid, $filename]; |
|
| 100 | } |
|
| 101 | ||
| 102 | /** |
|
| 103 | * get original location of files for user |
|
| @@ 93-116 (lines=24) @@ | ||
| 90 | * @return array |
|
| 91 | * @throws \OC\User\NoUserException |
|
| 92 | */ |
|
| 93 | public static function getUidAndFilename($filename) { |
|
| 94 | $uid = Filesystem::getOwner($filename); |
|
| 95 | $userManager = \OC::$server->getUserManager(); |
|
| 96 | // if the user with the UID doesn't exists, e.g. because the UID points |
|
| 97 | // to a remote user with a federated cloud ID we use the current logged-in |
|
| 98 | // user. We need a valid local user to create the versions |
|
| 99 | if (!$userManager->userExists($uid)) { |
|
| 100 | $uid = User::getUser(); |
|
| 101 | } |
|
| 102 | Filesystem::initMountPoints($uid); |
|
| 103 | if ( $uid != User::getUser() ) { |
|
| 104 | $info = Filesystem::getFileInfo($filename); |
|
| 105 | $ownerView = new View('/'.$uid.'/files'); |
|
| 106 | try { |
|
| 107 | $filename = $ownerView->getPath($info['fileid']); |
|
| 108 | // make sure that the file name doesn't end with a trailing slash |
|
| 109 | // can for example happen single files shared across servers |
|
| 110 | $filename = rtrim($filename, '/'); |
|
| 111 | } catch (NotFoundException $e) { |
|
| 112 | $filename = null; |
|
| 113 | } |
|
| 114 | } |
|
| 115 | return [$uid, $filename]; |
|
| 116 | } |
|
| 117 | ||
| 118 | /** |
|
| 119 | * Remember the owner and the owner path of the source file |
|