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