@@ -31,14 +31,14 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | class SessionStorageWrapper extends PermissionsMask { |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @param array $arguments ['storage' => $storage] |
|
| 36 | - */ |
|
| 37 | - public function __construct($arguments) { |
|
| 38 | - // disable sharing permission |
|
| 39 | - $arguments['mask'] = Constants::PERMISSION_ALL & ~Constants::PERMISSION_SHARE; |
|
| 40 | - parent::__construct($arguments); |
|
| 41 | - } |
|
| 34 | + /** |
|
| 35 | + * @param array $arguments ['storage' => $storage] |
|
| 36 | + */ |
|
| 37 | + public function __construct($arguments) { |
|
| 38 | + // disable sharing permission |
|
| 39 | + $arguments['mask'] = Constants::PERMISSION_ALL & ~Constants::PERMISSION_SHARE; |
|
| 40 | + parent::__construct($arguments); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | 43 | } |
| 44 | 44 | |
@@ -47,10 +47,10 @@ |
||
| 47 | 47 | return false; |
| 48 | 48 | } |
| 49 | 49 | while (($file = readdir($dh)) !== false) { |
| 50 | - if ($this->is_dir($path . '/' . $file)) { |
|
| 51 | - $this->rmdir($path . '/' . $file); |
|
| 50 | + if ($this->is_dir($path.'/'.$file)) { |
|
| 51 | + $this->rmdir($path.'/'.$file); |
|
| 52 | 52 | } else { |
| 53 | - $this->unlink($path . '/' . $file); |
|
| 53 | + $this->unlink($path.'/'.$file); |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | $url = $this->constructUrl($path); |
@@ -28,100 +28,100 @@ |
||
| 28 | 28 | |
| 29 | 29 | abstract class StreamWrapper extends \OC\Files\Storage\Common { |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @param string $path |
|
| 33 | - * @return string|null |
|
| 34 | - */ |
|
| 35 | - abstract public function constructUrl($path); |
|
| 31 | + /** |
|
| 32 | + * @param string $path |
|
| 33 | + * @return string|null |
|
| 34 | + */ |
|
| 35 | + abstract public function constructUrl($path); |
|
| 36 | 36 | |
| 37 | - public function mkdir($path) { |
|
| 38 | - return mkdir($this->constructUrl($path)); |
|
| 39 | - } |
|
| 37 | + public function mkdir($path) { |
|
| 38 | + return mkdir($this->constructUrl($path)); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - public function rmdir($path) { |
|
| 42 | - if ($this->is_dir($path) && $this->isDeletable($path)) { |
|
| 43 | - $dh = $this->opendir($path); |
|
| 44 | - if (!is_resource($dh)) { |
|
| 45 | - return false; |
|
| 46 | - } |
|
| 47 | - while (($file = readdir($dh)) !== false) { |
|
| 48 | - if ($this->is_dir($path . '/' . $file)) { |
|
| 49 | - $this->rmdir($path . '/' . $file); |
|
| 50 | - } else { |
|
| 51 | - $this->unlink($path . '/' . $file); |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - $url = $this->constructUrl($path); |
|
| 55 | - $success = rmdir($url); |
|
| 56 | - clearstatcache(false, $url); |
|
| 57 | - return $success; |
|
| 58 | - } else { |
|
| 59 | - return false; |
|
| 60 | - } |
|
| 61 | - } |
|
| 41 | + public function rmdir($path) { |
|
| 42 | + if ($this->is_dir($path) && $this->isDeletable($path)) { |
|
| 43 | + $dh = $this->opendir($path); |
|
| 44 | + if (!is_resource($dh)) { |
|
| 45 | + return false; |
|
| 46 | + } |
|
| 47 | + while (($file = readdir($dh)) !== false) { |
|
| 48 | + if ($this->is_dir($path . '/' . $file)) { |
|
| 49 | + $this->rmdir($path . '/' . $file); |
|
| 50 | + } else { |
|
| 51 | + $this->unlink($path . '/' . $file); |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + $url = $this->constructUrl($path); |
|
| 55 | + $success = rmdir($url); |
|
| 56 | + clearstatcache(false, $url); |
|
| 57 | + return $success; |
|
| 58 | + } else { |
|
| 59 | + return false; |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - public function opendir($path) { |
|
| 64 | - return opendir($this->constructUrl($path)); |
|
| 65 | - } |
|
| 63 | + public function opendir($path) { |
|
| 64 | + return opendir($this->constructUrl($path)); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - public function filetype($path) { |
|
| 68 | - return @filetype($this->constructUrl($path)); |
|
| 69 | - } |
|
| 67 | + public function filetype($path) { |
|
| 68 | + return @filetype($this->constructUrl($path)); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - public function file_exists($path) { |
|
| 72 | - return file_exists($this->constructUrl($path)); |
|
| 73 | - } |
|
| 71 | + public function file_exists($path) { |
|
| 72 | + return file_exists($this->constructUrl($path)); |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - public function unlink($path) { |
|
| 76 | - $url = $this->constructUrl($path); |
|
| 77 | - $success = unlink($url); |
|
| 78 | - // normally unlink() is supposed to do this implicitly, |
|
| 79 | - // but doing it anyway just to be sure |
|
| 80 | - clearstatcache(false, $url); |
|
| 81 | - return $success; |
|
| 82 | - } |
|
| 75 | + public function unlink($path) { |
|
| 76 | + $url = $this->constructUrl($path); |
|
| 77 | + $success = unlink($url); |
|
| 78 | + // normally unlink() is supposed to do this implicitly, |
|
| 79 | + // but doing it anyway just to be sure |
|
| 80 | + clearstatcache(false, $url); |
|
| 81 | + return $success; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - public function fopen($path, $mode) { |
|
| 85 | - return fopen($this->constructUrl($path), $mode); |
|
| 86 | - } |
|
| 84 | + public function fopen($path, $mode) { |
|
| 85 | + return fopen($this->constructUrl($path), $mode); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - public function touch($path, $mtime = null) { |
|
| 89 | - if ($this->file_exists($path)) { |
|
| 90 | - if (is_null($mtime)) { |
|
| 91 | - $fh = $this->fopen($path, 'a'); |
|
| 92 | - fwrite($fh, ''); |
|
| 93 | - fclose($fh); |
|
| 88 | + public function touch($path, $mtime = null) { |
|
| 89 | + if ($this->file_exists($path)) { |
|
| 90 | + if (is_null($mtime)) { |
|
| 91 | + $fh = $this->fopen($path, 'a'); |
|
| 92 | + fwrite($fh, ''); |
|
| 93 | + fclose($fh); |
|
| 94 | 94 | |
| 95 | - return true; |
|
| 96 | - } else { |
|
| 97 | - return false; //not supported |
|
| 98 | - } |
|
| 99 | - } else { |
|
| 100 | - $this->file_put_contents($path, ''); |
|
| 101 | - return true; |
|
| 102 | - } |
|
| 103 | - } |
|
| 95 | + return true; |
|
| 96 | + } else { |
|
| 97 | + return false; //not supported |
|
| 98 | + } |
|
| 99 | + } else { |
|
| 100 | + $this->file_put_contents($path, ''); |
|
| 101 | + return true; |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * @param string $path |
|
| 107 | - * @param string $target |
|
| 108 | - */ |
|
| 109 | - public function getFile($path, $target) { |
|
| 110 | - return copy($this->constructUrl($path), $target); |
|
| 111 | - } |
|
| 105 | + /** |
|
| 106 | + * @param string $path |
|
| 107 | + * @param string $target |
|
| 108 | + */ |
|
| 109 | + public function getFile($path, $target) { |
|
| 110 | + return copy($this->constructUrl($path), $target); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - /** |
|
| 114 | - * @param string $target |
|
| 115 | - */ |
|
| 116 | - public function uploadFile($path, $target) { |
|
| 117 | - return copy($path, $this->constructUrl($target)); |
|
| 118 | - } |
|
| 113 | + /** |
|
| 114 | + * @param string $target |
|
| 115 | + */ |
|
| 116 | + public function uploadFile($path, $target) { |
|
| 117 | + return copy($path, $this->constructUrl($target)); |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - public function rename($path1, $path2) { |
|
| 121 | - return rename($this->constructUrl($path1), $this->constructUrl($path2)); |
|
| 122 | - } |
|
| 120 | + public function rename($path1, $path2) { |
|
| 121 | + return rename($this->constructUrl($path1), $this->constructUrl($path2)); |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - public function stat($path) { |
|
| 125 | - return stat($this->constructUrl($path)); |
|
| 126 | - } |
|
| 124 | + public function stat($path) { |
|
| 125 | + return stat($this->constructUrl($path)); |
|
| 126 | + } |
|
| 127 | 127 | } |
@@ -43,28 +43,28 @@ |
||
| 43 | 43 | */ |
| 44 | 44 | trait StorageModifierTrait { |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Modify a StorageConfig parameters |
|
| 48 | - * |
|
| 49 | - * @param StorageConfig $storage |
|
| 50 | - * @param IUser $user User the storage is being used as |
|
| 51 | - * @throws InsufficientDataForMeaningfulAnswerException |
|
| 52 | - * @throws StorageNotAvailableException |
|
| 53 | - */ |
|
| 54 | - public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
| 55 | - } |
|
| 46 | + /** |
|
| 47 | + * Modify a StorageConfig parameters |
|
| 48 | + * |
|
| 49 | + * @param StorageConfig $storage |
|
| 50 | + * @param IUser $user User the storage is being used as |
|
| 51 | + * @throws InsufficientDataForMeaningfulAnswerException |
|
| 52 | + * @throws StorageNotAvailableException |
|
| 53 | + */ |
|
| 54 | + public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Wrap a Storage if necessary |
|
| 59 | - * |
|
| 60 | - * @param Storage $storage |
|
| 61 | - * @return Storage |
|
| 62 | - * @throws InsufficientDataForMeaningfulAnswerException |
|
| 63 | - * @throws StorageNotAvailableException |
|
| 64 | - */ |
|
| 65 | - public function wrapStorage(Storage $storage) { |
|
| 66 | - return $storage; |
|
| 67 | - } |
|
| 57 | + /** |
|
| 58 | + * Wrap a Storage if necessary |
|
| 59 | + * |
|
| 60 | + * @param Storage $storage |
|
| 61 | + * @return Storage |
|
| 62 | + * @throws InsufficientDataForMeaningfulAnswerException |
|
| 63 | + * @throws StorageNotAvailableException |
|
| 64 | + */ |
|
| 65 | + public function wrapStorage(Storage $storage) { |
|
| 66 | + return $storage; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | 69 | } |
| 70 | 70 | |
@@ -51,7 +51,7 @@ |
||
| 51 | 51 | * @throws InsufficientDataForMeaningfulAnswerException |
| 52 | 52 | * @throws StorageNotAvailableException |
| 53 | 53 | */ |
| 54 | - public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
| 54 | + public function manipulateStorageConfig(StorageConfig & $storage, IUser $user = null) { |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -64,7 +64,7 @@ |
||
| 64 | 64 | |
| 65 | 65 | public function listen(callable $callback) { |
| 66 | 66 | $oldRenamePath = null; |
| 67 | - $this->shareNotifyHandler->listen(function (\Icewind\SMB\Change $shareChange) use ($callback) { |
|
| 67 | + $this->shareNotifyHandler->listen(function(\Icewind\SMB\Change $shareChange) use ($callback) { |
|
| 68 | 68 | $change = $this->mapChange($shareChange); |
| 69 | 69 | if (!is_null($change)) { |
| 70 | 70 | return $callback($change); |
@@ -30,122 +30,122 @@ |
||
| 30 | 30 | use OCP\Files\Notify\INotifyHandler; |
| 31 | 31 | |
| 32 | 32 | class SMBNotifyHandler implements INotifyHandler { |
| 33 | - /** |
|
| 34 | - * @var \Icewind\SMB\INotifyHandler |
|
| 35 | - */ |
|
| 36 | - private $shareNotifyHandler; |
|
| 33 | + /** |
|
| 34 | + * @var \Icewind\SMB\INotifyHandler |
|
| 35 | + */ |
|
| 36 | + private $shareNotifyHandler; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @var string |
|
| 40 | - */ |
|
| 41 | - private $root; |
|
| 38 | + /** |
|
| 39 | + * @var string |
|
| 40 | + */ |
|
| 41 | + private $root; |
|
| 42 | 42 | |
| 43 | - private $oldRenamePath = null; |
|
| 43 | + private $oldRenamePath = null; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * SMBNotifyHandler constructor. |
|
| 47 | - * |
|
| 48 | - * @param \Icewind\SMB\INotifyHandler $shareNotifyHandler |
|
| 49 | - * @param string $root |
|
| 50 | - */ |
|
| 51 | - public function __construct(\Icewind\SMB\INotifyHandler $shareNotifyHandler, $root) { |
|
| 52 | - $this->shareNotifyHandler = $shareNotifyHandler; |
|
| 53 | - $this->root = str_replace('\\', '/', $root); |
|
| 54 | - } |
|
| 45 | + /** |
|
| 46 | + * SMBNotifyHandler constructor. |
|
| 47 | + * |
|
| 48 | + * @param \Icewind\SMB\INotifyHandler $shareNotifyHandler |
|
| 49 | + * @param string $root |
|
| 50 | + */ |
|
| 51 | + public function __construct(\Icewind\SMB\INotifyHandler $shareNotifyHandler, $root) { |
|
| 52 | + $this->shareNotifyHandler = $shareNotifyHandler; |
|
| 53 | + $this->root = str_replace('\\', '/', $root); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - private function relativePath($fullPath) { |
|
| 57 | - if ($fullPath === $this->root) { |
|
| 58 | - return ''; |
|
| 59 | - } elseif (substr($fullPath, 0, strlen($this->root)) === $this->root) { |
|
| 60 | - return substr($fullPath, strlen($this->root)); |
|
| 61 | - } else { |
|
| 62 | - return null; |
|
| 63 | - } |
|
| 64 | - } |
|
| 56 | + private function relativePath($fullPath) { |
|
| 57 | + if ($fullPath === $this->root) { |
|
| 58 | + return ''; |
|
| 59 | + } elseif (substr($fullPath, 0, strlen($this->root)) === $this->root) { |
|
| 60 | + return substr($fullPath, strlen($this->root)); |
|
| 61 | + } else { |
|
| 62 | + return null; |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - public function listen(callable $callback) { |
|
| 67 | - $oldRenamePath = null; |
|
| 68 | - $this->shareNotifyHandler->listen(function (\Icewind\SMB\Change $shareChange) use ($callback) { |
|
| 69 | - $change = $this->mapChange($shareChange); |
|
| 70 | - if (!is_null($change)) { |
|
| 71 | - return $callback($change); |
|
| 72 | - } else { |
|
| 73 | - return true; |
|
| 74 | - } |
|
| 75 | - }); |
|
| 76 | - } |
|
| 66 | + public function listen(callable $callback) { |
|
| 67 | + $oldRenamePath = null; |
|
| 68 | + $this->shareNotifyHandler->listen(function (\Icewind\SMB\Change $shareChange) use ($callback) { |
|
| 69 | + $change = $this->mapChange($shareChange); |
|
| 70 | + if (!is_null($change)) { |
|
| 71 | + return $callback($change); |
|
| 72 | + } else { |
|
| 73 | + return true; |
|
| 74 | + } |
|
| 75 | + }); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Get all changes detected since the start of the notify process or the last call to getChanges |
|
| 80 | - * |
|
| 81 | - * @return IChange[] |
|
| 82 | - */ |
|
| 83 | - public function getChanges() { |
|
| 84 | - $shareChanges = $this->shareNotifyHandler->getChanges(); |
|
| 85 | - $changes = []; |
|
| 86 | - foreach ($shareChanges as $shareChange) { |
|
| 87 | - $change = $this->mapChange($shareChange); |
|
| 88 | - if ($change) { |
|
| 89 | - $changes[] = $change; |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - return $changes; |
|
| 93 | - } |
|
| 78 | + /** |
|
| 79 | + * Get all changes detected since the start of the notify process or the last call to getChanges |
|
| 80 | + * |
|
| 81 | + * @return IChange[] |
|
| 82 | + */ |
|
| 83 | + public function getChanges() { |
|
| 84 | + $shareChanges = $this->shareNotifyHandler->getChanges(); |
|
| 85 | + $changes = []; |
|
| 86 | + foreach ($shareChanges as $shareChange) { |
|
| 87 | + $change = $this->mapChange($shareChange); |
|
| 88 | + if ($change) { |
|
| 89 | + $changes[] = $change; |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + return $changes; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * Stop listening for changes |
|
| 97 | - * |
|
| 98 | - * Note that any pending changes will be discarded |
|
| 99 | - */ |
|
| 100 | - public function stop() { |
|
| 101 | - $this->shareNotifyHandler->stop(); |
|
| 102 | - } |
|
| 95 | + /** |
|
| 96 | + * Stop listening for changes |
|
| 97 | + * |
|
| 98 | + * Note that any pending changes will be discarded |
|
| 99 | + */ |
|
| 100 | + public function stop() { |
|
| 101 | + $this->shareNotifyHandler->stop(); |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - /** |
|
| 105 | - * @param \Icewind\SMB\Change $change |
|
| 106 | - * @return IChange|null |
|
| 107 | - */ |
|
| 108 | - private function mapChange(\Icewind\SMB\Change $change) { |
|
| 109 | - $path = $this->relativePath($change->getPath()); |
|
| 110 | - if (is_null($path)) { |
|
| 111 | - return null; |
|
| 112 | - } |
|
| 113 | - if ($change->getCode() === \Icewind\SMB\INotifyHandler::NOTIFY_RENAMED_OLD) { |
|
| 114 | - $this->oldRenamePath = $path; |
|
| 115 | - return null; |
|
| 116 | - } |
|
| 117 | - $type = $this->mapNotifyType($change->getCode()); |
|
| 118 | - if (is_null($type)) { |
|
| 119 | - return null; |
|
| 120 | - } |
|
| 121 | - if ($type === IChange::RENAMED) { |
|
| 122 | - if (!is_null($this->oldRenamePath)) { |
|
| 123 | - $result = new RenameChange($type, $this->oldRenamePath, $path); |
|
| 124 | - $this->oldRenamePath = null; |
|
| 125 | - } else { |
|
| 126 | - $result = null; |
|
| 127 | - } |
|
| 128 | - } else { |
|
| 129 | - $result = new Change($type, $path); |
|
| 130 | - } |
|
| 131 | - return $result; |
|
| 132 | - } |
|
| 104 | + /** |
|
| 105 | + * @param \Icewind\SMB\Change $change |
|
| 106 | + * @return IChange|null |
|
| 107 | + */ |
|
| 108 | + private function mapChange(\Icewind\SMB\Change $change) { |
|
| 109 | + $path = $this->relativePath($change->getPath()); |
|
| 110 | + if (is_null($path)) { |
|
| 111 | + return null; |
|
| 112 | + } |
|
| 113 | + if ($change->getCode() === \Icewind\SMB\INotifyHandler::NOTIFY_RENAMED_OLD) { |
|
| 114 | + $this->oldRenamePath = $path; |
|
| 115 | + return null; |
|
| 116 | + } |
|
| 117 | + $type = $this->mapNotifyType($change->getCode()); |
|
| 118 | + if (is_null($type)) { |
|
| 119 | + return null; |
|
| 120 | + } |
|
| 121 | + if ($type === IChange::RENAMED) { |
|
| 122 | + if (!is_null($this->oldRenamePath)) { |
|
| 123 | + $result = new RenameChange($type, $this->oldRenamePath, $path); |
|
| 124 | + $this->oldRenamePath = null; |
|
| 125 | + } else { |
|
| 126 | + $result = null; |
|
| 127 | + } |
|
| 128 | + } else { |
|
| 129 | + $result = new Change($type, $path); |
|
| 130 | + } |
|
| 131 | + return $result; |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - private function mapNotifyType($smbType) { |
|
| 135 | - switch ($smbType) { |
|
| 136 | - case \Icewind\SMB\INotifyHandler::NOTIFY_ADDED: |
|
| 137 | - return IChange::ADDED; |
|
| 138 | - case \Icewind\SMB\INotifyHandler::NOTIFY_REMOVED: |
|
| 139 | - return IChange::REMOVED; |
|
| 140 | - case \Icewind\SMB\INotifyHandler::NOTIFY_MODIFIED: |
|
| 141 | - case \Icewind\SMB\INotifyHandler::NOTIFY_ADDED_STREAM: |
|
| 142 | - case \Icewind\SMB\INotifyHandler::NOTIFY_MODIFIED_STREAM: |
|
| 143 | - case \Icewind\SMB\INotifyHandler::NOTIFY_REMOVED_STREAM: |
|
| 144 | - return IChange::MODIFIED; |
|
| 145 | - case \Icewind\SMB\INotifyHandler::NOTIFY_RENAMED_NEW: |
|
| 146 | - return IChange::RENAMED; |
|
| 147 | - default: |
|
| 148 | - return null; |
|
| 149 | - } |
|
| 150 | - } |
|
| 134 | + private function mapNotifyType($smbType) { |
|
| 135 | + switch ($smbType) { |
|
| 136 | + case \Icewind\SMB\INotifyHandler::NOTIFY_ADDED: |
|
| 137 | + return IChange::ADDED; |
|
| 138 | + case \Icewind\SMB\INotifyHandler::NOTIFY_REMOVED: |
|
| 139 | + return IChange::REMOVED; |
|
| 140 | + case \Icewind\SMB\INotifyHandler::NOTIFY_MODIFIED: |
|
| 141 | + case \Icewind\SMB\INotifyHandler::NOTIFY_ADDED_STREAM: |
|
| 142 | + case \Icewind\SMB\INotifyHandler::NOTIFY_MODIFIED_STREAM: |
|
| 143 | + case \Icewind\SMB\INotifyHandler::NOTIFY_REMOVED_STREAM: |
|
| 144 | + return IChange::MODIFIED; |
|
| 145 | + case \Icewind\SMB\INotifyHandler::NOTIFY_RENAMED_NEW: |
|
| 146 | + return IChange::RENAMED; |
|
| 147 | + default: |
|
| 148 | + return null; |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | 151 | } |
@@ -62,18 +62,18 @@ |
||
| 62 | 62 | $placeholder = substr($placeholder, 1); |
| 63 | 63 | } |
| 64 | 64 | switch ($placeholder[0]) { |
| 65 | - case '!': |
|
| 66 | - $type = DefinitionParameter::VALUE_BOOLEAN; |
|
| 67 | - $placeholder = substr($placeholder, 1); |
|
| 68 | - break; |
|
| 69 | - case '*': |
|
| 70 | - $type = DefinitionParameter::VALUE_PASSWORD; |
|
| 71 | - $placeholder = substr($placeholder, 1); |
|
| 72 | - break; |
|
| 73 | - case '#': |
|
| 74 | - $type = DefinitionParameter::VALUE_HIDDEN; |
|
| 75 | - $placeholder = substr($placeholder, 1); |
|
| 76 | - break; |
|
| 65 | + case '!': |
|
| 66 | + $type = DefinitionParameter::VALUE_BOOLEAN; |
|
| 67 | + $placeholder = substr($placeholder, 1); |
|
| 68 | + break; |
|
| 69 | + case '*': |
|
| 70 | + $type = DefinitionParameter::VALUE_PASSWORD; |
|
| 71 | + $placeholder = substr($placeholder, 1); |
|
| 72 | + break; |
|
| 73 | + case '#': |
|
| 74 | + $type = DefinitionParameter::VALUE_HIDDEN; |
|
| 75 | + $placeholder = substr($placeholder, 1); |
|
| 76 | + break; |
|
| 77 | 77 | } |
| 78 | 78 | $this->addParameter((new DefinitionParameter($name, $placeholder)) |
| 79 | 79 | ->setType($type) |
@@ -32,72 +32,72 @@ |
||
| 32 | 32 | * Legacy compatibility for OCA\Files_External\MountConfig::registerBackend() |
| 33 | 33 | */ |
| 34 | 34 | class LegacyBackend extends Backend { |
| 35 | - use LegacyDependencyCheckPolyfill { |
|
| 36 | - LegacyDependencyCheckPolyfill::checkDependencies as doCheckDependencies; |
|
| 37 | - } |
|
| 35 | + use LegacyDependencyCheckPolyfill { |
|
| 36 | + LegacyDependencyCheckPolyfill::checkDependencies as doCheckDependencies; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** @var bool */ |
|
| 40 | - protected $hasDependencies = false; |
|
| 39 | + /** @var bool */ |
|
| 40 | + protected $hasDependencies = false; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @param string $class |
|
| 44 | - * @param array $definition |
|
| 45 | - * @param Builtin $authMechanism |
|
| 46 | - */ |
|
| 47 | - public function __construct($class, array $definition, Builtin $authMechanism) { |
|
| 48 | - $this |
|
| 49 | - ->setIdentifier($class) |
|
| 50 | - ->setStorageClass($class) |
|
| 51 | - ->setText($definition['backend']) |
|
| 52 | - ->addAuthScheme(Builtin::SCHEME_BUILTIN) |
|
| 53 | - ->setLegacyAuthMechanism($authMechanism) |
|
| 54 | - ; |
|
| 42 | + /** |
|
| 43 | + * @param string $class |
|
| 44 | + * @param array $definition |
|
| 45 | + * @param Builtin $authMechanism |
|
| 46 | + */ |
|
| 47 | + public function __construct($class, array $definition, Builtin $authMechanism) { |
|
| 48 | + $this |
|
| 49 | + ->setIdentifier($class) |
|
| 50 | + ->setStorageClass($class) |
|
| 51 | + ->setText($definition['backend']) |
|
| 52 | + ->addAuthScheme(Builtin::SCHEME_BUILTIN) |
|
| 53 | + ->setLegacyAuthMechanism($authMechanism) |
|
| 54 | + ; |
|
| 55 | 55 | |
| 56 | - foreach ($definition['configuration'] as $name => $placeholder) { |
|
| 57 | - $flags = DefinitionParameter::FLAG_NONE; |
|
| 58 | - $type = DefinitionParameter::VALUE_TEXT; |
|
| 59 | - if ($placeholder[0] === '&') { |
|
| 60 | - $flags = DefinitionParameter::FLAG_OPTIONAL; |
|
| 61 | - $placeholder = substr($placeholder, 1); |
|
| 62 | - } |
|
| 63 | - switch ($placeholder[0]) { |
|
| 64 | - case '!': |
|
| 65 | - $type = DefinitionParameter::VALUE_BOOLEAN; |
|
| 66 | - $placeholder = substr($placeholder, 1); |
|
| 67 | - break; |
|
| 68 | - case '*': |
|
| 69 | - $type = DefinitionParameter::VALUE_PASSWORD; |
|
| 70 | - $placeholder = substr($placeholder, 1); |
|
| 71 | - break; |
|
| 72 | - case '#': |
|
| 73 | - $type = DefinitionParameter::VALUE_HIDDEN; |
|
| 74 | - $placeholder = substr($placeholder, 1); |
|
| 75 | - break; |
|
| 76 | - } |
|
| 77 | - $this->addParameter((new DefinitionParameter($name, $placeholder)) |
|
| 78 | - ->setType($type) |
|
| 79 | - ->setFlags($flags) |
|
| 80 | - ); |
|
| 81 | - } |
|
| 56 | + foreach ($definition['configuration'] as $name => $placeholder) { |
|
| 57 | + $flags = DefinitionParameter::FLAG_NONE; |
|
| 58 | + $type = DefinitionParameter::VALUE_TEXT; |
|
| 59 | + if ($placeholder[0] === '&') { |
|
| 60 | + $flags = DefinitionParameter::FLAG_OPTIONAL; |
|
| 61 | + $placeholder = substr($placeholder, 1); |
|
| 62 | + } |
|
| 63 | + switch ($placeholder[0]) { |
|
| 64 | + case '!': |
|
| 65 | + $type = DefinitionParameter::VALUE_BOOLEAN; |
|
| 66 | + $placeholder = substr($placeholder, 1); |
|
| 67 | + break; |
|
| 68 | + case '*': |
|
| 69 | + $type = DefinitionParameter::VALUE_PASSWORD; |
|
| 70 | + $placeholder = substr($placeholder, 1); |
|
| 71 | + break; |
|
| 72 | + case '#': |
|
| 73 | + $type = DefinitionParameter::VALUE_HIDDEN; |
|
| 74 | + $placeholder = substr($placeholder, 1); |
|
| 75 | + break; |
|
| 76 | + } |
|
| 77 | + $this->addParameter((new DefinitionParameter($name, $placeholder)) |
|
| 78 | + ->setType($type) |
|
| 79 | + ->setFlags($flags) |
|
| 80 | + ); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - if (isset($definition['priority'])) { |
|
| 84 | - $this->setPriority($definition['priority']); |
|
| 85 | - } |
|
| 86 | - if (isset($definition['custom'])) { |
|
| 87 | - $this->addCustomJs($definition['custom']); |
|
| 88 | - } |
|
| 89 | - if (isset($definition['has_dependencies']) && $definition['has_dependencies']) { |
|
| 90 | - $this->hasDependencies = true; |
|
| 91 | - } |
|
| 92 | - } |
|
| 83 | + if (isset($definition['priority'])) { |
|
| 84 | + $this->setPriority($definition['priority']); |
|
| 85 | + } |
|
| 86 | + if (isset($definition['custom'])) { |
|
| 87 | + $this->addCustomJs($definition['custom']); |
|
| 88 | + } |
|
| 89 | + if (isset($definition['has_dependencies']) && $definition['has_dependencies']) { |
|
| 90 | + $this->hasDependencies = true; |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * @return MissingDependency[] |
|
| 96 | - */ |
|
| 97 | - public function checkDependencies() { |
|
| 98 | - if ($this->hasDependencies) { |
|
| 99 | - return $this->doCheckDependencies(); |
|
| 100 | - } |
|
| 101 | - return []; |
|
| 102 | - } |
|
| 94 | + /** |
|
| 95 | + * @return MissingDependency[] |
|
| 96 | + */ |
|
| 97 | + public function checkDependencies() { |
|
| 98 | + if ($this->hasDependencies) { |
|
| 99 | + return $this->doCheckDependencies(); |
|
| 100 | + } |
|
| 101 | + return []; |
|
| 102 | + } |
|
| 103 | 103 | } |
@@ -61,11 +61,11 @@ |
||
| 61 | 61 | ; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
| 64 | + public function manipulateStorageConfig(StorageConfig & $storage, IUser $user = null) { |
|
| 65 | 65 | $username_as_share = ($storage->getBackendOption('username_as_share') === true); |
| 66 | 66 | |
| 67 | 67 | if ($username_as_share) { |
| 68 | - $share = '/' . $storage->getBackendOption('user'); |
|
| 68 | + $share = '/'.$storage->getBackendOption('user'); |
|
| 69 | 69 | $storage->setBackendOption('share', $share); |
| 70 | 70 | } |
| 71 | 71 | } |
@@ -37,35 +37,35 @@ |
||
| 37 | 37 | * Deprecated SMB_OC class - use SMB with the password::sessioncredentials auth mechanism |
| 38 | 38 | */ |
| 39 | 39 | class SMB_OC extends Backend { |
| 40 | - use LegacyDependencyCheckPolyfill; |
|
| 40 | + use LegacyDependencyCheckPolyfill; |
|
| 41 | 41 | |
| 42 | - public function __construct(IL10N $l, SessionCredentials $legacyAuth, SMB $smbBackend) { |
|
| 43 | - $this |
|
| 44 | - ->setIdentifier('\OC\Files\Storage\SMB_OC') |
|
| 45 | - ->setStorageClass('\OCA\Files_External\Lib\Storage\SMB') |
|
| 46 | - ->setText($l->t('SMB/CIFS using OC login')) |
|
| 47 | - ->addParameters([ |
|
| 48 | - new DefinitionParameter('host', $l->t('Host')), |
|
| 49 | - (new DefinitionParameter('username_as_share', $l->t('Username as share'))) |
|
| 50 | - ->setType(DefinitionParameter::VALUE_BOOLEAN), |
|
| 51 | - (new DefinitionParameter('share', $l->t('Share'))) |
|
| 52 | - ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
| 53 | - (new DefinitionParameter('root', $l->t('Remote subfolder'))) |
|
| 54 | - ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
| 55 | - ]) |
|
| 56 | - ->setPriority(BackendService::PRIORITY_DEFAULT - 10) |
|
| 57 | - ->addAuthScheme(AuthMechanism::SCHEME_PASSWORD) |
|
| 58 | - ->setLegacyAuthMechanism($legacyAuth) |
|
| 59 | - ->deprecateTo($smbBackend) |
|
| 60 | - ; |
|
| 61 | - } |
|
| 42 | + public function __construct(IL10N $l, SessionCredentials $legacyAuth, SMB $smbBackend) { |
|
| 43 | + $this |
|
| 44 | + ->setIdentifier('\OC\Files\Storage\SMB_OC') |
|
| 45 | + ->setStorageClass('\OCA\Files_External\Lib\Storage\SMB') |
|
| 46 | + ->setText($l->t('SMB/CIFS using OC login')) |
|
| 47 | + ->addParameters([ |
|
| 48 | + new DefinitionParameter('host', $l->t('Host')), |
|
| 49 | + (new DefinitionParameter('username_as_share', $l->t('Username as share'))) |
|
| 50 | + ->setType(DefinitionParameter::VALUE_BOOLEAN), |
|
| 51 | + (new DefinitionParameter('share', $l->t('Share'))) |
|
| 52 | + ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
| 53 | + (new DefinitionParameter('root', $l->t('Remote subfolder'))) |
|
| 54 | + ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
| 55 | + ]) |
|
| 56 | + ->setPriority(BackendService::PRIORITY_DEFAULT - 10) |
|
| 57 | + ->addAuthScheme(AuthMechanism::SCHEME_PASSWORD) |
|
| 58 | + ->setLegacyAuthMechanism($legacyAuth) |
|
| 59 | + ->deprecateTo($smbBackend) |
|
| 60 | + ; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
| 64 | - $username_as_share = ($storage->getBackendOption('username_as_share') === true); |
|
| 63 | + public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { |
|
| 64 | + $username_as_share = ($storage->getBackendOption('username_as_share') === true); |
|
| 65 | 65 | |
| 66 | - if ($username_as_share) { |
|
| 67 | - $share = '/' . $storage->getBackendOption('user'); |
|
| 68 | - $storage->setBackendOption('share', $share); |
|
| 69 | - } |
|
| 70 | - } |
|
| 66 | + if ($username_as_share) { |
|
| 67 | + $share = '/' . $storage->getBackendOption('user'); |
|
| 68 | + $storage->setBackendOption('share', $share); |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | 71 | } |
@@ -27,39 +27,39 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class MissingDependency { |
| 29 | 29 | |
| 30 | - /** @var string */ |
|
| 31 | - private $dependency; |
|
| 30 | + /** @var string */ |
|
| 31 | + private $dependency; |
|
| 32 | 32 | |
| 33 | - /** @var string|null Custom message */ |
|
| 34 | - private $message = null; |
|
| 33 | + /** @var string|null Custom message */ |
|
| 34 | + private $message = null; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @param string $dependency |
|
| 38 | - */ |
|
| 39 | - public function __construct($dependency) { |
|
| 40 | - $this->dependency = $dependency; |
|
| 41 | - } |
|
| 36 | + /** |
|
| 37 | + * @param string $dependency |
|
| 38 | + */ |
|
| 39 | + public function __construct($dependency) { |
|
| 40 | + $this->dependency = $dependency; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @return string |
|
| 45 | - */ |
|
| 46 | - public function getDependency() { |
|
| 47 | - return $this->dependency; |
|
| 48 | - } |
|
| 43 | + /** |
|
| 44 | + * @return string |
|
| 45 | + */ |
|
| 46 | + public function getDependency() { |
|
| 47 | + return $this->dependency; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @return string|null |
|
| 52 | - */ |
|
| 53 | - public function getMessage() { |
|
| 54 | - return $this->message; |
|
| 55 | - } |
|
| 50 | + /** |
|
| 51 | + * @return string|null |
|
| 52 | + */ |
|
| 53 | + public function getMessage() { |
|
| 54 | + return $this->message; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @param string $message |
|
| 59 | - * @return self |
|
| 60 | - */ |
|
| 61 | - public function setMessage($message) { |
|
| 62 | - $this->message = $message; |
|
| 63 | - return $this; |
|
| 64 | - } |
|
| 57 | + /** |
|
| 58 | + * @param string $message |
|
| 59 | + * @return self |
|
| 60 | + */ |
|
| 61 | + public function setMessage($message) { |
|
| 62 | + $this->message = $message; |
|
| 63 | + return $this; |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -29,14 +29,14 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | trait DependencyTrait { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Check if object is valid for use |
|
| 34 | - * |
|
| 35 | - * @return MissingDependency[] Unsatisfied dependencies |
|
| 36 | - */ |
|
| 37 | - public function checkDependencies() { |
|
| 38 | - return []; // no dependencies by default |
|
| 39 | - } |
|
| 32 | + /** |
|
| 33 | + * Check if object is valid for use |
|
| 34 | + * |
|
| 35 | + * @return MissingDependency[] Unsatisfied dependencies |
|
| 36 | + */ |
|
| 37 | + public function checkDependencies() { |
|
| 38 | + return []; // no dependencies by default |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | 41 | } |
| 42 | 42 | |
@@ -27,72 +27,72 @@ |
||
| 27 | 27 | |
| 28 | 28 | class Setting implements ISetting { |
| 29 | 29 | |
| 30 | - /** @var IL10N */ |
|
| 31 | - protected $l; |
|
| 30 | + /** @var IL10N */ |
|
| 31 | + protected $l; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @param IL10N $l |
|
| 35 | - */ |
|
| 36 | - public function __construct(IL10N $l) { |
|
| 37 | - $this->l = $l; |
|
| 38 | - } |
|
| 33 | + /** |
|
| 34 | + * @param IL10N $l |
|
| 35 | + */ |
|
| 36 | + public function __construct(IL10N $l) { |
|
| 37 | + $this->l = $l; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @return string Lowercase a-z and underscore only identifier |
|
| 42 | - * @since 11.0.0 |
|
| 43 | - */ |
|
| 44 | - public function getIdentifier() { |
|
| 45 | - return 'systemtags'; |
|
| 46 | - } |
|
| 40 | + /** |
|
| 41 | + * @return string Lowercase a-z and underscore only identifier |
|
| 42 | + * @since 11.0.0 |
|
| 43 | + */ |
|
| 44 | + public function getIdentifier() { |
|
| 45 | + return 'systemtags'; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @return string A translated string |
|
| 50 | - * @since 11.0.0 |
|
| 51 | - */ |
|
| 52 | - public function getName() { |
|
| 53 | - return $this->l->t('<strong>System tags</strong> for a file have been modified'); |
|
| 54 | - } |
|
| 48 | + /** |
|
| 49 | + * @return string A translated string |
|
| 50 | + * @since 11.0.0 |
|
| 51 | + */ |
|
| 52 | + public function getName() { |
|
| 53 | + return $this->l->t('<strong>System tags</strong> for a file have been modified'); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @return int whether the filter should be rather on the top or bottom of |
|
| 58 | - * the admin section. The filters are arranged in ascending order of the |
|
| 59 | - * priority values. It is required to return a value between 0 and 100. |
|
| 60 | - * @since 11.0.0 |
|
| 61 | - */ |
|
| 62 | - public function getPriority() { |
|
| 63 | - return 50; |
|
| 64 | - } |
|
| 56 | + /** |
|
| 57 | + * @return int whether the filter should be rather on the top or bottom of |
|
| 58 | + * the admin section. The filters are arranged in ascending order of the |
|
| 59 | + * priority values. It is required to return a value between 0 and 100. |
|
| 60 | + * @since 11.0.0 |
|
| 61 | + */ |
|
| 62 | + public function getPriority() { |
|
| 63 | + return 50; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * @return bool True when the option can be changed for the stream |
|
| 68 | - * @since 11.0.0 |
|
| 69 | - */ |
|
| 70 | - public function canChangeStream() { |
|
| 71 | - return true; |
|
| 72 | - } |
|
| 66 | + /** |
|
| 67 | + * @return bool True when the option can be changed for the stream |
|
| 68 | + * @since 11.0.0 |
|
| 69 | + */ |
|
| 70 | + public function canChangeStream() { |
|
| 71 | + return true; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * @return bool True when the option can be changed for the stream |
|
| 76 | - * @since 11.0.0 |
|
| 77 | - */ |
|
| 78 | - public function isDefaultEnabledStream() { |
|
| 79 | - return true; |
|
| 80 | - } |
|
| 74 | + /** |
|
| 75 | + * @return bool True when the option can be changed for the stream |
|
| 76 | + * @since 11.0.0 |
|
| 77 | + */ |
|
| 78 | + public function isDefaultEnabledStream() { |
|
| 79 | + return true; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * @return bool True when the option can be changed for the mail |
|
| 84 | - * @since 11.0.0 |
|
| 85 | - */ |
|
| 86 | - public function canChangeMail() { |
|
| 87 | - return true; |
|
| 88 | - } |
|
| 82 | + /** |
|
| 83 | + * @return bool True when the option can be changed for the mail |
|
| 84 | + * @since 11.0.0 |
|
| 85 | + */ |
|
| 86 | + public function canChangeMail() { |
|
| 87 | + return true; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * @return bool True when the option can be changed for the stream |
|
| 92 | - * @since 11.0.0 |
|
| 93 | - */ |
|
| 94 | - public function isDefaultEnabledMail() { |
|
| 95 | - return false; |
|
| 96 | - } |
|
| 90 | + /** |
|
| 91 | + * @return bool True when the option can be changed for the stream |
|
| 92 | + * @since 11.0.0 |
|
| 93 | + */ |
|
| 94 | + public function isDefaultEnabledMail() { |
|
| 95 | + return false; |
|
| 96 | + } |
|
| 97 | 97 | } |
| 98 | 98 | |