@@ -30,101 +30,101 @@ |
||
| 30 | 30 | |
| 31 | 31 | abstract class StreamWrapper extends \OC\Files\Storage\Common { |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @param string $path |
|
| 35 | - * @return string|null |
|
| 36 | - */ |
|
| 37 | - abstract public function constructUrl($path); |
|
| 38 | - |
|
| 39 | - public function mkdir($path) { |
|
| 40 | - return mkdir($this->constructUrl($path)); |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - public function rmdir($path) { |
|
| 44 | - if ($this->is_dir($path) && $this->isDeletable($path)) { |
|
| 45 | - $dh = $this->opendir($path); |
|
| 46 | - if (!is_resource($dh)) { |
|
| 47 | - return false; |
|
| 48 | - } |
|
| 49 | - while (($file = readdir($dh)) !== false) { |
|
| 50 | - if ($this->is_dir($path . '/' . $file)) { |
|
| 51 | - $this->rmdir($path . '/' . $file); |
|
| 52 | - } else { |
|
| 53 | - $this->unlink($path . '/' . $file); |
|
| 54 | - } |
|
| 55 | - } |
|
| 56 | - $url = $this->constructUrl($path); |
|
| 57 | - $success = rmdir($url); |
|
| 58 | - clearstatcache(false, $url); |
|
| 59 | - return $success; |
|
| 60 | - } else { |
|
| 61 | - return false; |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - public function opendir($path) { |
|
| 66 | - return opendir($this->constructUrl($path)); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - public function filetype($path) { |
|
| 70 | - return @filetype($this->constructUrl($path)); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - public function file_exists($path) { |
|
| 74 | - return file_exists($this->constructUrl($path)); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - public function unlink($path) { |
|
| 78 | - $url = $this->constructUrl($path); |
|
| 79 | - $success = unlink($url); |
|
| 80 | - // normally unlink() is supposed to do this implicitly, |
|
| 81 | - // but doing it anyway just to be sure |
|
| 82 | - clearstatcache(false, $url); |
|
| 83 | - return $success; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - public function fopen($path, $mode) { |
|
| 87 | - return fopen($this->constructUrl($path), $mode); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - public function touch($path, $mtime = null) { |
|
| 91 | - if ($this->file_exists($path)) { |
|
| 92 | - if (is_null($mtime)) { |
|
| 93 | - $fh = $this->fopen($path, 'a'); |
|
| 94 | - fwrite($fh, ''); |
|
| 95 | - fclose($fh); |
|
| 96 | - |
|
| 97 | - return true; |
|
| 98 | - } else { |
|
| 99 | - return false; //not supported |
|
| 100 | - } |
|
| 101 | - } else { |
|
| 102 | - $this->file_put_contents($path, ''); |
|
| 103 | - return true; |
|
| 104 | - } |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * @param string $path |
|
| 109 | - * @param string $target |
|
| 110 | - */ |
|
| 111 | - public function getFile($path, $target) { |
|
| 112 | - return copy($this->constructUrl($path), $target); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * @param string $target |
|
| 117 | - */ |
|
| 118 | - public function uploadFile($path, $target) { |
|
| 119 | - return copy($path, $this->constructUrl($target)); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - public function rename($path1, $path2) { |
|
| 123 | - return rename($this->constructUrl($path1), $this->constructUrl($path2)); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - public function stat($path) { |
|
| 127 | - return stat($this->constructUrl($path)); |
|
| 128 | - } |
|
| 33 | + /** |
|
| 34 | + * @param string $path |
|
| 35 | + * @return string|null |
|
| 36 | + */ |
|
| 37 | + abstract public function constructUrl($path); |
|
| 38 | + |
|
| 39 | + public function mkdir($path) { |
|
| 40 | + return mkdir($this->constructUrl($path)); |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + public function rmdir($path) { |
|
| 44 | + if ($this->is_dir($path) && $this->isDeletable($path)) { |
|
| 45 | + $dh = $this->opendir($path); |
|
| 46 | + if (!is_resource($dh)) { |
|
| 47 | + return false; |
|
| 48 | + } |
|
| 49 | + while (($file = readdir($dh)) !== false) { |
|
| 50 | + if ($this->is_dir($path . '/' . $file)) { |
|
| 51 | + $this->rmdir($path . '/' . $file); |
|
| 52 | + } else { |
|
| 53 | + $this->unlink($path . '/' . $file); |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | + $url = $this->constructUrl($path); |
|
| 57 | + $success = rmdir($url); |
|
| 58 | + clearstatcache(false, $url); |
|
| 59 | + return $success; |
|
| 60 | + } else { |
|
| 61 | + return false; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + public function opendir($path) { |
|
| 66 | + return opendir($this->constructUrl($path)); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + public function filetype($path) { |
|
| 70 | + return @filetype($this->constructUrl($path)); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + public function file_exists($path) { |
|
| 74 | + return file_exists($this->constructUrl($path)); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + public function unlink($path) { |
|
| 78 | + $url = $this->constructUrl($path); |
|
| 79 | + $success = unlink($url); |
|
| 80 | + // normally unlink() is supposed to do this implicitly, |
|
| 81 | + // but doing it anyway just to be sure |
|
| 82 | + clearstatcache(false, $url); |
|
| 83 | + return $success; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + public function fopen($path, $mode) { |
|
| 87 | + return fopen($this->constructUrl($path), $mode); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + public function touch($path, $mtime = null) { |
|
| 91 | + if ($this->file_exists($path)) { |
|
| 92 | + if (is_null($mtime)) { |
|
| 93 | + $fh = $this->fopen($path, 'a'); |
|
| 94 | + fwrite($fh, ''); |
|
| 95 | + fclose($fh); |
|
| 96 | + |
|
| 97 | + return true; |
|
| 98 | + } else { |
|
| 99 | + return false; //not supported |
|
| 100 | + } |
|
| 101 | + } else { |
|
| 102 | + $this->file_put_contents($path, ''); |
|
| 103 | + return true; |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * @param string $path |
|
| 109 | + * @param string $target |
|
| 110 | + */ |
|
| 111 | + public function getFile($path, $target) { |
|
| 112 | + return copy($this->constructUrl($path), $target); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * @param string $target |
|
| 117 | + */ |
|
| 118 | + public function uploadFile($path, $target) { |
|
| 119 | + return copy($path, $this->constructUrl($target)); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + public function rename($path1, $path2) { |
|
| 123 | + return rename($this->constructUrl($path1), $this->constructUrl($path2)); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + public function stat($path) { |
|
| 127 | + return stat($this->constructUrl($path)); |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | 130 | } |
@@ -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); |
@@ -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 | |
@@ -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); |
@@ -29,122 +29,122 @@ |
||
| 29 | 29 | use OCP\Files\Notify\INotifyHandler; |
| 30 | 30 | |
| 31 | 31 | class SMBNotifyHandler implements INotifyHandler { |
| 32 | - /** |
|
| 33 | - * @var \Icewind\SMB\INotifyHandler |
|
| 34 | - */ |
|
| 35 | - private $shareNotifyHandler; |
|
| 32 | + /** |
|
| 33 | + * @var \Icewind\SMB\INotifyHandler |
|
| 34 | + */ |
|
| 35 | + private $shareNotifyHandler; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @var string |
|
| 39 | - */ |
|
| 40 | - private $root; |
|
| 37 | + /** |
|
| 38 | + * @var string |
|
| 39 | + */ |
|
| 40 | + private $root; |
|
| 41 | 41 | |
| 42 | - private $oldRenamePath = null; |
|
| 42 | + private $oldRenamePath = null; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * SMBNotifyHandler constructor. |
|
| 46 | - * |
|
| 47 | - * @param \Icewind\SMB\INotifyHandler $shareNotifyHandler |
|
| 48 | - * @param string $root |
|
| 49 | - */ |
|
| 50 | - public function __construct(\Icewind\SMB\INotifyHandler $shareNotifyHandler, $root) { |
|
| 51 | - $this->shareNotifyHandler = $shareNotifyHandler; |
|
| 52 | - $this->root = $root; |
|
| 53 | - } |
|
| 44 | + /** |
|
| 45 | + * SMBNotifyHandler constructor. |
|
| 46 | + * |
|
| 47 | + * @param \Icewind\SMB\INotifyHandler $shareNotifyHandler |
|
| 48 | + * @param string $root |
|
| 49 | + */ |
|
| 50 | + public function __construct(\Icewind\SMB\INotifyHandler $shareNotifyHandler, $root) { |
|
| 51 | + $this->shareNotifyHandler = $shareNotifyHandler; |
|
| 52 | + $this->root = $root; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - private function relativePath($fullPath) { |
|
| 56 | - if ($fullPath === $this->root) { |
|
| 57 | - return ''; |
|
| 58 | - } elseif (substr($fullPath, 0, strlen($this->root)) === $this->root) { |
|
| 59 | - return substr($fullPath, strlen($this->root)); |
|
| 60 | - } else { |
|
| 61 | - return null; |
|
| 62 | - } |
|
| 63 | - } |
|
| 55 | + private function relativePath($fullPath) { |
|
| 56 | + if ($fullPath === $this->root) { |
|
| 57 | + return ''; |
|
| 58 | + } elseif (substr($fullPath, 0, strlen($this->root)) === $this->root) { |
|
| 59 | + return substr($fullPath, strlen($this->root)); |
|
| 60 | + } else { |
|
| 61 | + return null; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - public function listen(callable $callback) { |
|
| 66 | - $oldRenamePath = null; |
|
| 67 | - $this->shareNotifyHandler->listen(function (\Icewind\SMB\Change $shareChange) use ($callback) { |
|
| 68 | - $change = $this->mapChange($shareChange); |
|
| 69 | - if (!is_null($change)) { |
|
| 70 | - return $callback($change); |
|
| 71 | - } else { |
|
| 72 | - return true; |
|
| 73 | - } |
|
| 74 | - }); |
|
| 75 | - } |
|
| 65 | + public function listen(callable $callback) { |
|
| 66 | + $oldRenamePath = null; |
|
| 67 | + $this->shareNotifyHandler->listen(function (\Icewind\SMB\Change $shareChange) use ($callback) { |
|
| 68 | + $change = $this->mapChange($shareChange); |
|
| 69 | + if (!is_null($change)) { |
|
| 70 | + return $callback($change); |
|
| 71 | + } else { |
|
| 72 | + return true; |
|
| 73 | + } |
|
| 74 | + }); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Get all changes detected since the start of the notify process or the last call to getChanges |
|
| 79 | - * |
|
| 80 | - * @return IChange[] |
|
| 81 | - */ |
|
| 82 | - public function getChanges() { |
|
| 83 | - $shareChanges = $this->shareNotifyHandler->getChanges(); |
|
| 84 | - $changes = []; |
|
| 85 | - foreach ($shareChanges as $shareChange) { |
|
| 86 | - $change = $this->mapChange($shareChange); |
|
| 87 | - if ($change) { |
|
| 88 | - $changes[] = $change; |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - return $changes; |
|
| 92 | - } |
|
| 77 | + /** |
|
| 78 | + * Get all changes detected since the start of the notify process or the last call to getChanges |
|
| 79 | + * |
|
| 80 | + * @return IChange[] |
|
| 81 | + */ |
|
| 82 | + public function getChanges() { |
|
| 83 | + $shareChanges = $this->shareNotifyHandler->getChanges(); |
|
| 84 | + $changes = []; |
|
| 85 | + foreach ($shareChanges as $shareChange) { |
|
| 86 | + $change = $this->mapChange($shareChange); |
|
| 87 | + if ($change) { |
|
| 88 | + $changes[] = $change; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + return $changes; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * Stop listening for changes |
|
| 96 | - * |
|
| 97 | - * Note that any pending changes will be discarded |
|
| 98 | - */ |
|
| 99 | - public function stop() { |
|
| 100 | - $this->shareNotifyHandler->stop(); |
|
| 101 | - } |
|
| 94 | + /** |
|
| 95 | + * Stop listening for changes |
|
| 96 | + * |
|
| 97 | + * Note that any pending changes will be discarded |
|
| 98 | + */ |
|
| 99 | + public function stop() { |
|
| 100 | + $this->shareNotifyHandler->stop(); |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * @param \Icewind\SMB\Change $change |
|
| 105 | - * @return IChange|null |
|
| 106 | - */ |
|
| 107 | - private function mapChange(\Icewind\SMB\Change $change) { |
|
| 108 | - $path = $this->relativePath($change->getPath()); |
|
| 109 | - if (is_null($path)) { |
|
| 110 | - return null; |
|
| 111 | - } |
|
| 112 | - if ($change->getCode() === \Icewind\SMB\INotifyHandler::NOTIFY_RENAMED_OLD) { |
|
| 113 | - $this->oldRenamePath = $path; |
|
| 114 | - return null; |
|
| 115 | - } |
|
| 116 | - $type = $this->mapNotifyType($change->getCode()); |
|
| 117 | - if (is_null($type)) { |
|
| 118 | - return null; |
|
| 119 | - } |
|
| 120 | - if ($type === IChange::RENAMED) { |
|
| 121 | - if (!is_null($this->oldRenamePath)) { |
|
| 122 | - $result = new RenameChange($type, $this->oldRenamePath, $path); |
|
| 123 | - $this->oldRenamePath = null; |
|
| 124 | - } else { |
|
| 125 | - $result = null; |
|
| 126 | - } |
|
| 127 | - } else { |
|
| 128 | - $result = new Change($type, $path); |
|
| 129 | - } |
|
| 130 | - return $result; |
|
| 131 | - } |
|
| 103 | + /** |
|
| 104 | + * @param \Icewind\SMB\Change $change |
|
| 105 | + * @return IChange|null |
|
| 106 | + */ |
|
| 107 | + private function mapChange(\Icewind\SMB\Change $change) { |
|
| 108 | + $path = $this->relativePath($change->getPath()); |
|
| 109 | + if (is_null($path)) { |
|
| 110 | + return null; |
|
| 111 | + } |
|
| 112 | + if ($change->getCode() === \Icewind\SMB\INotifyHandler::NOTIFY_RENAMED_OLD) { |
|
| 113 | + $this->oldRenamePath = $path; |
|
| 114 | + return null; |
|
| 115 | + } |
|
| 116 | + $type = $this->mapNotifyType($change->getCode()); |
|
| 117 | + if (is_null($type)) { |
|
| 118 | + return null; |
|
| 119 | + } |
|
| 120 | + if ($type === IChange::RENAMED) { |
|
| 121 | + if (!is_null($this->oldRenamePath)) { |
|
| 122 | + $result = new RenameChange($type, $this->oldRenamePath, $path); |
|
| 123 | + $this->oldRenamePath = null; |
|
| 124 | + } else { |
|
| 125 | + $result = null; |
|
| 126 | + } |
|
| 127 | + } else { |
|
| 128 | + $result = new Change($type, $path); |
|
| 129 | + } |
|
| 130 | + return $result; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - private function mapNotifyType($smbType) { |
|
| 134 | - switch ($smbType) { |
|
| 135 | - case \Icewind\SMB\INotifyHandler::NOTIFY_ADDED: |
|
| 136 | - return IChange::ADDED; |
|
| 137 | - case \Icewind\SMB\INotifyHandler::NOTIFY_REMOVED: |
|
| 138 | - return IChange::REMOVED; |
|
| 139 | - case \Icewind\SMB\INotifyHandler::NOTIFY_MODIFIED: |
|
| 140 | - case \Icewind\SMB\INotifyHandler::NOTIFY_ADDED_STREAM: |
|
| 141 | - case \Icewind\SMB\INotifyHandler::NOTIFY_MODIFIED_STREAM: |
|
| 142 | - case \Icewind\SMB\INotifyHandler::NOTIFY_REMOVED_STREAM: |
|
| 143 | - return IChange::MODIFIED; |
|
| 144 | - case \Icewind\SMB\INotifyHandler::NOTIFY_RENAMED_NEW: |
|
| 145 | - return IChange::RENAMED; |
|
| 146 | - default: |
|
| 147 | - return null; |
|
| 148 | - } |
|
| 149 | - } |
|
| 133 | + private function mapNotifyType($smbType) { |
|
| 134 | + switch ($smbType) { |
|
| 135 | + case \Icewind\SMB\INotifyHandler::NOTIFY_ADDED: |
|
| 136 | + return IChange::ADDED; |
|
| 137 | + case \Icewind\SMB\INotifyHandler::NOTIFY_REMOVED: |
|
| 138 | + return IChange::REMOVED; |
|
| 139 | + case \Icewind\SMB\INotifyHandler::NOTIFY_MODIFIED: |
|
| 140 | + case \Icewind\SMB\INotifyHandler::NOTIFY_ADDED_STREAM: |
|
| 141 | + case \Icewind\SMB\INotifyHandler::NOTIFY_MODIFIED_STREAM: |
|
| 142 | + case \Icewind\SMB\INotifyHandler::NOTIFY_REMOVED_STREAM: |
|
| 143 | + return IChange::MODIFIED; |
|
| 144 | + case \Icewind\SMB\INotifyHandler::NOTIFY_RENAMED_NEW: |
|
| 145 | + return IChange::RENAMED; |
|
| 146 | + default: |
|
| 147 | + return null; |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | 150 | } |
@@ -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 OC_Mount_Config::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 | } |
@@ -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 | |
@@ -279,7 +279,7 @@ |
||
| 279 | 279 | if ($tagData === null) { |
| 280 | 280 | list($name, $status) = explode('|||', substr($parameter, 3, -3)); |
| 281 | 281 | $tagData = [ |
| 282 | - 'id' => 0,// No way to recover the ID |
|
| 282 | + 'id' => 0, // No way to recover the ID |
|
| 283 | 283 | 'name' => $name, |
| 284 | 284 | 'assignable' => $status === 'assignable', |
| 285 | 285 | 'visible' => $status !== 'invisible', |
@@ -33,339 +33,339 @@ |
||
| 33 | 33 | use OCP\L10N\IFactory; |
| 34 | 34 | |
| 35 | 35 | class Provider implements IProvider { |
| 36 | - public const CREATE_TAG = 'create_tag'; |
|
| 37 | - public const UPDATE_TAG = 'update_tag'; |
|
| 38 | - public const DELETE_TAG = 'delete_tag'; |
|
| 39 | - |
|
| 40 | - public const ASSIGN_TAG = 'assign_tag'; |
|
| 41 | - public const UNASSIGN_TAG = 'unassign_tag'; |
|
| 42 | - |
|
| 43 | - /** @var IFactory */ |
|
| 44 | - protected $languageFactory; |
|
| 45 | - |
|
| 46 | - /** @var IL10N */ |
|
| 47 | - protected $l; |
|
| 48 | - |
|
| 49 | - /** @var IURLGenerator */ |
|
| 50 | - protected $url; |
|
| 51 | - |
|
| 52 | - /** @var IManager */ |
|
| 53 | - protected $activityManager; |
|
| 54 | - |
|
| 55 | - /** @var IUserManager */ |
|
| 56 | - protected $userManager; |
|
| 57 | - |
|
| 58 | - /** @var string[] */ |
|
| 59 | - protected $displayNames = []; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * @param IFactory $languageFactory |
|
| 63 | - * @param IURLGenerator $url |
|
| 64 | - * @param IManager $activityManager |
|
| 65 | - * @param IUserManager $userManager |
|
| 66 | - */ |
|
| 67 | - public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager) { |
|
| 68 | - $this->languageFactory = $languageFactory; |
|
| 69 | - $this->url = $url; |
|
| 70 | - $this->activityManager = $activityManager; |
|
| 71 | - $this->userManager = $userManager; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * @param string $language |
|
| 76 | - * @param IEvent $event |
|
| 77 | - * @param IEvent|null $previousEvent |
|
| 78 | - * @return IEvent |
|
| 79 | - * @throws \InvalidArgumentException |
|
| 80 | - * @since 11.0.0 |
|
| 81 | - */ |
|
| 82 | - public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
| 83 | - if ($event->getApp() !== 'systemtags') { |
|
| 84 | - throw new \InvalidArgumentException(); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - $this->l = $this->languageFactory->get('systemtags', $language); |
|
| 88 | - |
|
| 89 | - if ($this->activityManager->isFormattingFilteredObject()) { |
|
| 90 | - try { |
|
| 91 | - return $this->parseShortVersion($event); |
|
| 92 | - } catch (\InvalidArgumentException $e) { |
|
| 93 | - // Ignore and simply use the long version... |
|
| 94 | - } |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - return $this->parseLongVersion($event); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * @param IEvent $event |
|
| 102 | - * @return IEvent |
|
| 103 | - * @throws \InvalidArgumentException |
|
| 104 | - * @since 11.0.0 |
|
| 105 | - */ |
|
| 106 | - public function parseShortVersion(IEvent $event) { |
|
| 107 | - $parsedParameters = $this->getParameters($event); |
|
| 108 | - |
|
| 109 | - if ($this->activityManager->getRequirePNG()) { |
|
| 110 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/tag.png'))); |
|
| 111 | - } else { |
|
| 112 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/tag.svg'))); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - if ($event->getSubject() === self::ASSIGN_TAG) { |
|
| 116 | - if ($parsedParameters['actor']['id'] === '') { |
|
| 117 | - $event->setParsedSubject($this->l->t('System tag %1$s added by the system', [ |
|
| 118 | - $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 119 | - ])) |
|
| 120 | - ->setRichSubject($this->l->t('Added system tag {systemtag}'), [ |
|
| 121 | - 'systemtag' => $parsedParameters['systemtag'], |
|
| 122 | - ]); |
|
| 123 | - } elseif ($parsedParameters['actor']['id'] === $this->activityManager->getCurrentUserId()) { |
|
| 124 | - $event->setParsedSubject($this->l->t('Added system tag %1$s', [ |
|
| 125 | - $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 126 | - ])) |
|
| 127 | - ->setRichSubject($this->l->t('Added system tag {systemtag}'), [ |
|
| 128 | - 'systemtag' => $parsedParameters['systemtag'], |
|
| 129 | - ]); |
|
| 130 | - } else { |
|
| 131 | - $event->setParsedSubject($this->l->t('%1$s added system tag %2$s', [ |
|
| 132 | - $parsedParameters['actor']['name'], |
|
| 133 | - $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 134 | - ])) |
|
| 135 | - ->setRichSubject($this->l->t('{actor} added system tag {systemtag}'), [ |
|
| 136 | - 'actor' => $parsedParameters['actor'], |
|
| 137 | - 'systemtag' => $parsedParameters['systemtag'], |
|
| 138 | - ]); |
|
| 139 | - } |
|
| 140 | - } elseif ($event->getSubject() === self::UNASSIGN_TAG) { |
|
| 141 | - if ($parsedParameters['actor']['id'] === '') { |
|
| 142 | - $event->setParsedSubject($this->l->t('System tag %1$s removed by the system', [ |
|
| 143 | - $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 144 | - ])) |
|
| 145 | - ->setRichSubject($this->l->t('Removed system tag {systemtag}'), [ |
|
| 146 | - 'systemtag' => $parsedParameters['systemtag'], |
|
| 147 | - ]); |
|
| 148 | - } elseif ($parsedParameters['actor']['id'] === $this->activityManager->getCurrentUserId()) { |
|
| 149 | - $event->setParsedSubject($this->l->t('Removed system tag %1$s', [ |
|
| 150 | - $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 151 | - ])) |
|
| 152 | - ->setRichSubject($this->l->t('Removed system tag {systemtag}'), [ |
|
| 153 | - 'systemtag' => $parsedParameters['systemtag'], |
|
| 154 | - ]); |
|
| 155 | - } else { |
|
| 156 | - $event->setParsedSubject($this->l->t('%1$s removed system tag %2$s', [ |
|
| 157 | - $parsedParameters['actor']['name'], |
|
| 158 | - $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 159 | - ])) |
|
| 160 | - ->setRichSubject($this->l->t('{actor} removed system tag {systemtag}'), [ |
|
| 161 | - 'actor' => $parsedParameters['actor'], |
|
| 162 | - 'systemtag' => $parsedParameters['systemtag'], |
|
| 163 | - ]); |
|
| 164 | - } |
|
| 165 | - } else { |
|
| 166 | - throw new \InvalidArgumentException(); |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - return $event; |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - /** |
|
| 173 | - * @param IEvent $event |
|
| 174 | - * @return IEvent |
|
| 175 | - * @throws \InvalidArgumentException |
|
| 176 | - * @since 11.0.0 |
|
| 177 | - */ |
|
| 178 | - public function parseLongVersion(IEvent $event) { |
|
| 179 | - $parsedParameters = $this->getParameters($event); |
|
| 180 | - |
|
| 181 | - if ($this->activityManager->getRequirePNG()) { |
|
| 182 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/tag.png'))); |
|
| 183 | - } else { |
|
| 184 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/tag.svg'))); |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - if ($event->getSubject() === self::CREATE_TAG) { |
|
| 188 | - if ($parsedParameters['actor']['id'] === $this->activityManager->getCurrentUserId()) { |
|
| 189 | - $event->setParsedSubject($this->l->t('You created system tag %1$s', [ |
|
| 190 | - $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 191 | - ])) |
|
| 192 | - ->setRichSubject($this->l->t('You created system tag {systemtag}'), $parsedParameters); |
|
| 193 | - } else { |
|
| 194 | - $event->setParsedSubject($this->l->t('%1$s created system tag %2$s', [ |
|
| 195 | - $parsedParameters['actor']['name'], |
|
| 196 | - $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 197 | - ])) |
|
| 198 | - ->setRichSubject($this->l->t('{actor} created system tag {systemtag}'), $parsedParameters); |
|
| 199 | - } |
|
| 200 | - } elseif ($event->getSubject() === self::DELETE_TAG) { |
|
| 201 | - if ($parsedParameters['actor']['id'] === $this->activityManager->getCurrentUserId()) { |
|
| 202 | - $event->setParsedSubject($this->l->t('You deleted system tag %1$s', [ |
|
| 203 | - $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 204 | - ])) |
|
| 205 | - ->setRichSubject($this->l->t('You deleted system tag {systemtag}'), $parsedParameters); |
|
| 206 | - } else { |
|
| 207 | - $event->setParsedSubject($this->l->t('%1$s deleted system tag %2$s', [ |
|
| 208 | - $parsedParameters['actor']['name'], |
|
| 209 | - $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 210 | - ])) |
|
| 211 | - ->setRichSubject($this->l->t('{actor} deleted system tag {systemtag}'), $parsedParameters); |
|
| 212 | - } |
|
| 213 | - } elseif ($event->getSubject() === self::UPDATE_TAG) { |
|
| 214 | - if ($parsedParameters['actor']['id'] === $this->activityManager->getCurrentUserId()) { |
|
| 215 | - $event->setParsedSubject($this->l->t('You updated system tag %2$s to %1$s', [ |
|
| 216 | - $this->generatePlainSystemTag($parsedParameters['newsystemtag']), |
|
| 217 | - $this->generatePlainSystemTag($parsedParameters['oldsystemtag']), |
|
| 218 | - ])) |
|
| 219 | - ->setRichSubject($this->l->t('You updated system tag {oldsystemtag} to {newsystemtag}'), $parsedParameters); |
|
| 220 | - } else { |
|
| 221 | - $event->setParsedSubject($this->l->t('%1$s updated system tag %3$s to %2$s', [ |
|
| 222 | - $parsedParameters['actor']['name'], |
|
| 223 | - $this->generatePlainSystemTag($parsedParameters['newsystemtag']), |
|
| 224 | - $this->generatePlainSystemTag($parsedParameters['oldsystemtag']), |
|
| 225 | - ])) |
|
| 226 | - ->setRichSubject($this->l->t('{actor} updated system tag {oldsystemtag} to {newsystemtag}'), $parsedParameters); |
|
| 227 | - } |
|
| 228 | - } elseif ($event->getSubject() === self::ASSIGN_TAG) { |
|
| 229 | - if ($parsedParameters['actor']['id'] === '') { |
|
| 230 | - unset($parsedParameters['actor']); |
|
| 231 | - $event->setParsedSubject($this->l->t('System tag %2$s was added to %1$s by the system', [ |
|
| 232 | - $parsedParameters['file']['path'], |
|
| 233 | - $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 234 | - ])) |
|
| 235 | - ->setRichSubject($this->l->t('System tag {systemtag} was added to {file} by the system'), $parsedParameters); |
|
| 236 | - } elseif ($parsedParameters['actor']['id'] === $this->activityManager->getCurrentUserId()) { |
|
| 237 | - $event->setParsedSubject($this->l->t('You added system tag %2$s to %1$s', [ |
|
| 238 | - $parsedParameters['file']['path'], |
|
| 239 | - $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 240 | - ])) |
|
| 241 | - ->setRichSubject($this->l->t('You added system tag {systemtag} to {file}'), $parsedParameters); |
|
| 242 | - } else { |
|
| 243 | - $event->setParsedSubject($this->l->t('%1$s added system tag %3$s to %2$s', [ |
|
| 244 | - $parsedParameters['actor']['name'], |
|
| 245 | - $parsedParameters['file']['path'], |
|
| 246 | - $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 247 | - ])) |
|
| 248 | - ->setRichSubject($this->l->t('{actor} added system tag {systemtag} to {file}'), $parsedParameters); |
|
| 249 | - } |
|
| 250 | - } elseif ($event->getSubject() === self::UNASSIGN_TAG) { |
|
| 251 | - if ($parsedParameters['actor']['id'] === '') { |
|
| 252 | - unset($parsedParameters['actor']); |
|
| 253 | - $event->setParsedSubject($this->l->t('System tag %2$s was removed from %1$s by the system', [ |
|
| 254 | - $parsedParameters['file']['path'], |
|
| 255 | - $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 256 | - ])) |
|
| 257 | - ->setRichSubject($this->l->t('System tag {systemtag} was removed from {file} by the system'), $parsedParameters); |
|
| 258 | - } elseif ($parsedParameters['actor']['id'] === $this->activityManager->getCurrentUserId()) { |
|
| 259 | - $event->setParsedSubject($this->l->t('You removed system tag %2$s from %1$s', [ |
|
| 260 | - $parsedParameters['file']['path'], |
|
| 261 | - $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 262 | - ])) |
|
| 263 | - ->setRichSubject($this->l->t('You removed system tag {systemtag} from {file}'), $parsedParameters); |
|
| 264 | - } else { |
|
| 265 | - $event->setParsedSubject($this->l->t('%1$s removed system tag %3$s from %2$s', [ |
|
| 266 | - $parsedParameters['actor']['name'], |
|
| 267 | - $parsedParameters['file']['path'], |
|
| 268 | - $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 269 | - ])) |
|
| 270 | - ->setRichSubject($this->l->t('{actor} removed system tag {systemtag} from {file}'), $parsedParameters); |
|
| 271 | - } |
|
| 272 | - } else { |
|
| 273 | - throw new \InvalidArgumentException(); |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - return $event; |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - protected function getParameters(IEvent $event) { |
|
| 280 | - $subject = $event->getSubject(); |
|
| 281 | - $parameters = $event->getSubjectParameters(); |
|
| 282 | - |
|
| 283 | - switch ($subject) { |
|
| 284 | - case self::CREATE_TAG: |
|
| 285 | - case self::DELETE_TAG: |
|
| 286 | - return [ |
|
| 287 | - 'actor' => $this->getUserParameter((string) $parameters[0]), |
|
| 288 | - 'systemtag' => $this->getSystemTagParameter($parameters[1]), |
|
| 289 | - ]; |
|
| 290 | - case self::UPDATE_TAG: |
|
| 291 | - return [ |
|
| 292 | - 'actor' => $this->getUserParameter((string) $parameters[0]), |
|
| 293 | - 'newsystemtag' => $this->getSystemTagParameter($parameters[1]), |
|
| 294 | - 'oldsystemtag' => $this->getSystemTagParameter($parameters[2]), |
|
| 295 | - ]; |
|
| 296 | - case self::ASSIGN_TAG: |
|
| 297 | - case self::UNASSIGN_TAG: |
|
| 298 | - return [ |
|
| 299 | - 'actor' => $this->getUserParameter((string) $parameters[0]), |
|
| 300 | - 'file' => $this->getFileParameter($event->getObjectId(), $parameters[1]), |
|
| 301 | - 'systemtag' => $this->getSystemTagParameter($parameters[2]), |
|
| 302 | - ]; |
|
| 303 | - } |
|
| 304 | - return []; |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - protected function getFileParameter($id, $path) { |
|
| 308 | - return [ |
|
| 309 | - 'type' => 'file', |
|
| 310 | - 'id' => $id, |
|
| 311 | - 'name' => basename($path), |
|
| 312 | - 'path' => trim($path, '/'), |
|
| 313 | - ]; |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - protected function getSystemTagParameter($parameter) { |
|
| 317 | - $tagData = json_decode($parameter, true); |
|
| 318 | - if ($tagData === null) { |
|
| 319 | - list($name, $status) = explode('|||', substr($parameter, 3, -3)); |
|
| 320 | - $tagData = [ |
|
| 321 | - 'id' => 0,// No way to recover the ID |
|
| 322 | - 'name' => $name, |
|
| 323 | - 'assignable' => $status === 'assignable', |
|
| 324 | - 'visible' => $status !== 'invisible', |
|
| 325 | - ]; |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - return [ |
|
| 329 | - 'type' => 'systemtag', |
|
| 330 | - 'id' => (int) $tagData['id'], |
|
| 331 | - 'name' => $tagData['name'], |
|
| 332 | - 'assignable' => $tagData['assignable'] ? '1' : '0', |
|
| 333 | - 'visibility' => $tagData['visible'] ? '1' : '0', |
|
| 334 | - ]; |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - protected function getUserParameter($uid) { |
|
| 338 | - if (!isset($this->displayNames[$uid])) { |
|
| 339 | - $this->displayNames[$uid] = $this->getDisplayName($uid); |
|
| 340 | - } |
|
| 341 | - |
|
| 342 | - return [ |
|
| 343 | - 'type' => 'user', |
|
| 344 | - 'id' => $uid, |
|
| 345 | - 'name' => $this->displayNames[$uid], |
|
| 346 | - ]; |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - protected function generatePlainSystemTag(array $parameter) { |
|
| 350 | - if ($parameter['assignable'] === '1') { |
|
| 351 | - return $parameter['name']; |
|
| 352 | - } elseif ($parameter['visibility'] === '1') { |
|
| 353 | - return $this->l->t('%s (restricted)', $parameter['name']); |
|
| 354 | - } else { |
|
| 355 | - return $this->l->t('%s (invisible)', $parameter['name']); |
|
| 356 | - } |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | - /** |
|
| 360 | - * @param string $uid |
|
| 361 | - * @return string |
|
| 362 | - */ |
|
| 363 | - protected function getDisplayName($uid) { |
|
| 364 | - $user = $this->userManager->get($uid); |
|
| 365 | - if ($user instanceof IUser) { |
|
| 366 | - return $user->getDisplayName(); |
|
| 367 | - } else { |
|
| 368 | - return $uid; |
|
| 369 | - } |
|
| 370 | - } |
|
| 36 | + public const CREATE_TAG = 'create_tag'; |
|
| 37 | + public const UPDATE_TAG = 'update_tag'; |
|
| 38 | + public const DELETE_TAG = 'delete_tag'; |
|
| 39 | + |
|
| 40 | + public const ASSIGN_TAG = 'assign_tag'; |
|
| 41 | + public const UNASSIGN_TAG = 'unassign_tag'; |
|
| 42 | + |
|
| 43 | + /** @var IFactory */ |
|
| 44 | + protected $languageFactory; |
|
| 45 | + |
|
| 46 | + /** @var IL10N */ |
|
| 47 | + protected $l; |
|
| 48 | + |
|
| 49 | + /** @var IURLGenerator */ |
|
| 50 | + protected $url; |
|
| 51 | + |
|
| 52 | + /** @var IManager */ |
|
| 53 | + protected $activityManager; |
|
| 54 | + |
|
| 55 | + /** @var IUserManager */ |
|
| 56 | + protected $userManager; |
|
| 57 | + |
|
| 58 | + /** @var string[] */ |
|
| 59 | + protected $displayNames = []; |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * @param IFactory $languageFactory |
|
| 63 | + * @param IURLGenerator $url |
|
| 64 | + * @param IManager $activityManager |
|
| 65 | + * @param IUserManager $userManager |
|
| 66 | + */ |
|
| 67 | + public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager) { |
|
| 68 | + $this->languageFactory = $languageFactory; |
|
| 69 | + $this->url = $url; |
|
| 70 | + $this->activityManager = $activityManager; |
|
| 71 | + $this->userManager = $userManager; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * @param string $language |
|
| 76 | + * @param IEvent $event |
|
| 77 | + * @param IEvent|null $previousEvent |
|
| 78 | + * @return IEvent |
|
| 79 | + * @throws \InvalidArgumentException |
|
| 80 | + * @since 11.0.0 |
|
| 81 | + */ |
|
| 82 | + public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
| 83 | + if ($event->getApp() !== 'systemtags') { |
|
| 84 | + throw new \InvalidArgumentException(); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + $this->l = $this->languageFactory->get('systemtags', $language); |
|
| 88 | + |
|
| 89 | + if ($this->activityManager->isFormattingFilteredObject()) { |
|
| 90 | + try { |
|
| 91 | + return $this->parseShortVersion($event); |
|
| 92 | + } catch (\InvalidArgumentException $e) { |
|
| 93 | + // Ignore and simply use the long version... |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + return $this->parseLongVersion($event); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * @param IEvent $event |
|
| 102 | + * @return IEvent |
|
| 103 | + * @throws \InvalidArgumentException |
|
| 104 | + * @since 11.0.0 |
|
| 105 | + */ |
|
| 106 | + public function parseShortVersion(IEvent $event) { |
|
| 107 | + $parsedParameters = $this->getParameters($event); |
|
| 108 | + |
|
| 109 | + if ($this->activityManager->getRequirePNG()) { |
|
| 110 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/tag.png'))); |
|
| 111 | + } else { |
|
| 112 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/tag.svg'))); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + if ($event->getSubject() === self::ASSIGN_TAG) { |
|
| 116 | + if ($parsedParameters['actor']['id'] === '') { |
|
| 117 | + $event->setParsedSubject($this->l->t('System tag %1$s added by the system', [ |
|
| 118 | + $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 119 | + ])) |
|
| 120 | + ->setRichSubject($this->l->t('Added system tag {systemtag}'), [ |
|
| 121 | + 'systemtag' => $parsedParameters['systemtag'], |
|
| 122 | + ]); |
|
| 123 | + } elseif ($parsedParameters['actor']['id'] === $this->activityManager->getCurrentUserId()) { |
|
| 124 | + $event->setParsedSubject($this->l->t('Added system tag %1$s', [ |
|
| 125 | + $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 126 | + ])) |
|
| 127 | + ->setRichSubject($this->l->t('Added system tag {systemtag}'), [ |
|
| 128 | + 'systemtag' => $parsedParameters['systemtag'], |
|
| 129 | + ]); |
|
| 130 | + } else { |
|
| 131 | + $event->setParsedSubject($this->l->t('%1$s added system tag %2$s', [ |
|
| 132 | + $parsedParameters['actor']['name'], |
|
| 133 | + $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 134 | + ])) |
|
| 135 | + ->setRichSubject($this->l->t('{actor} added system tag {systemtag}'), [ |
|
| 136 | + 'actor' => $parsedParameters['actor'], |
|
| 137 | + 'systemtag' => $parsedParameters['systemtag'], |
|
| 138 | + ]); |
|
| 139 | + } |
|
| 140 | + } elseif ($event->getSubject() === self::UNASSIGN_TAG) { |
|
| 141 | + if ($parsedParameters['actor']['id'] === '') { |
|
| 142 | + $event->setParsedSubject($this->l->t('System tag %1$s removed by the system', [ |
|
| 143 | + $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 144 | + ])) |
|
| 145 | + ->setRichSubject($this->l->t('Removed system tag {systemtag}'), [ |
|
| 146 | + 'systemtag' => $parsedParameters['systemtag'], |
|
| 147 | + ]); |
|
| 148 | + } elseif ($parsedParameters['actor']['id'] === $this->activityManager->getCurrentUserId()) { |
|
| 149 | + $event->setParsedSubject($this->l->t('Removed system tag %1$s', [ |
|
| 150 | + $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 151 | + ])) |
|
| 152 | + ->setRichSubject($this->l->t('Removed system tag {systemtag}'), [ |
|
| 153 | + 'systemtag' => $parsedParameters['systemtag'], |
|
| 154 | + ]); |
|
| 155 | + } else { |
|
| 156 | + $event->setParsedSubject($this->l->t('%1$s removed system tag %2$s', [ |
|
| 157 | + $parsedParameters['actor']['name'], |
|
| 158 | + $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 159 | + ])) |
|
| 160 | + ->setRichSubject($this->l->t('{actor} removed system tag {systemtag}'), [ |
|
| 161 | + 'actor' => $parsedParameters['actor'], |
|
| 162 | + 'systemtag' => $parsedParameters['systemtag'], |
|
| 163 | + ]); |
|
| 164 | + } |
|
| 165 | + } else { |
|
| 166 | + throw new \InvalidArgumentException(); |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + return $event; |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + /** |
|
| 173 | + * @param IEvent $event |
|
| 174 | + * @return IEvent |
|
| 175 | + * @throws \InvalidArgumentException |
|
| 176 | + * @since 11.0.0 |
|
| 177 | + */ |
|
| 178 | + public function parseLongVersion(IEvent $event) { |
|
| 179 | + $parsedParameters = $this->getParameters($event); |
|
| 180 | + |
|
| 181 | + if ($this->activityManager->getRequirePNG()) { |
|
| 182 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/tag.png'))); |
|
| 183 | + } else { |
|
| 184 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/tag.svg'))); |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + if ($event->getSubject() === self::CREATE_TAG) { |
|
| 188 | + if ($parsedParameters['actor']['id'] === $this->activityManager->getCurrentUserId()) { |
|
| 189 | + $event->setParsedSubject($this->l->t('You created system tag %1$s', [ |
|
| 190 | + $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 191 | + ])) |
|
| 192 | + ->setRichSubject($this->l->t('You created system tag {systemtag}'), $parsedParameters); |
|
| 193 | + } else { |
|
| 194 | + $event->setParsedSubject($this->l->t('%1$s created system tag %2$s', [ |
|
| 195 | + $parsedParameters['actor']['name'], |
|
| 196 | + $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 197 | + ])) |
|
| 198 | + ->setRichSubject($this->l->t('{actor} created system tag {systemtag}'), $parsedParameters); |
|
| 199 | + } |
|
| 200 | + } elseif ($event->getSubject() === self::DELETE_TAG) { |
|
| 201 | + if ($parsedParameters['actor']['id'] === $this->activityManager->getCurrentUserId()) { |
|
| 202 | + $event->setParsedSubject($this->l->t('You deleted system tag %1$s', [ |
|
| 203 | + $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 204 | + ])) |
|
| 205 | + ->setRichSubject($this->l->t('You deleted system tag {systemtag}'), $parsedParameters); |
|
| 206 | + } else { |
|
| 207 | + $event->setParsedSubject($this->l->t('%1$s deleted system tag %2$s', [ |
|
| 208 | + $parsedParameters['actor']['name'], |
|
| 209 | + $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 210 | + ])) |
|
| 211 | + ->setRichSubject($this->l->t('{actor} deleted system tag {systemtag}'), $parsedParameters); |
|
| 212 | + } |
|
| 213 | + } elseif ($event->getSubject() === self::UPDATE_TAG) { |
|
| 214 | + if ($parsedParameters['actor']['id'] === $this->activityManager->getCurrentUserId()) { |
|
| 215 | + $event->setParsedSubject($this->l->t('You updated system tag %2$s to %1$s', [ |
|
| 216 | + $this->generatePlainSystemTag($parsedParameters['newsystemtag']), |
|
| 217 | + $this->generatePlainSystemTag($parsedParameters['oldsystemtag']), |
|
| 218 | + ])) |
|
| 219 | + ->setRichSubject($this->l->t('You updated system tag {oldsystemtag} to {newsystemtag}'), $parsedParameters); |
|
| 220 | + } else { |
|
| 221 | + $event->setParsedSubject($this->l->t('%1$s updated system tag %3$s to %2$s', [ |
|
| 222 | + $parsedParameters['actor']['name'], |
|
| 223 | + $this->generatePlainSystemTag($parsedParameters['newsystemtag']), |
|
| 224 | + $this->generatePlainSystemTag($parsedParameters['oldsystemtag']), |
|
| 225 | + ])) |
|
| 226 | + ->setRichSubject($this->l->t('{actor} updated system tag {oldsystemtag} to {newsystemtag}'), $parsedParameters); |
|
| 227 | + } |
|
| 228 | + } elseif ($event->getSubject() === self::ASSIGN_TAG) { |
|
| 229 | + if ($parsedParameters['actor']['id'] === '') { |
|
| 230 | + unset($parsedParameters['actor']); |
|
| 231 | + $event->setParsedSubject($this->l->t('System tag %2$s was added to %1$s by the system', [ |
|
| 232 | + $parsedParameters['file']['path'], |
|
| 233 | + $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 234 | + ])) |
|
| 235 | + ->setRichSubject($this->l->t('System tag {systemtag} was added to {file} by the system'), $parsedParameters); |
|
| 236 | + } elseif ($parsedParameters['actor']['id'] === $this->activityManager->getCurrentUserId()) { |
|
| 237 | + $event->setParsedSubject($this->l->t('You added system tag %2$s to %1$s', [ |
|
| 238 | + $parsedParameters['file']['path'], |
|
| 239 | + $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 240 | + ])) |
|
| 241 | + ->setRichSubject($this->l->t('You added system tag {systemtag} to {file}'), $parsedParameters); |
|
| 242 | + } else { |
|
| 243 | + $event->setParsedSubject($this->l->t('%1$s added system tag %3$s to %2$s', [ |
|
| 244 | + $parsedParameters['actor']['name'], |
|
| 245 | + $parsedParameters['file']['path'], |
|
| 246 | + $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 247 | + ])) |
|
| 248 | + ->setRichSubject($this->l->t('{actor} added system tag {systemtag} to {file}'), $parsedParameters); |
|
| 249 | + } |
|
| 250 | + } elseif ($event->getSubject() === self::UNASSIGN_TAG) { |
|
| 251 | + if ($parsedParameters['actor']['id'] === '') { |
|
| 252 | + unset($parsedParameters['actor']); |
|
| 253 | + $event->setParsedSubject($this->l->t('System tag %2$s was removed from %1$s by the system', [ |
|
| 254 | + $parsedParameters['file']['path'], |
|
| 255 | + $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 256 | + ])) |
|
| 257 | + ->setRichSubject($this->l->t('System tag {systemtag} was removed from {file} by the system'), $parsedParameters); |
|
| 258 | + } elseif ($parsedParameters['actor']['id'] === $this->activityManager->getCurrentUserId()) { |
|
| 259 | + $event->setParsedSubject($this->l->t('You removed system tag %2$s from %1$s', [ |
|
| 260 | + $parsedParameters['file']['path'], |
|
| 261 | + $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 262 | + ])) |
|
| 263 | + ->setRichSubject($this->l->t('You removed system tag {systemtag} from {file}'), $parsedParameters); |
|
| 264 | + } else { |
|
| 265 | + $event->setParsedSubject($this->l->t('%1$s removed system tag %3$s from %2$s', [ |
|
| 266 | + $parsedParameters['actor']['name'], |
|
| 267 | + $parsedParameters['file']['path'], |
|
| 268 | + $this->generatePlainSystemTag($parsedParameters['systemtag']), |
|
| 269 | + ])) |
|
| 270 | + ->setRichSubject($this->l->t('{actor} removed system tag {systemtag} from {file}'), $parsedParameters); |
|
| 271 | + } |
|
| 272 | + } else { |
|
| 273 | + throw new \InvalidArgumentException(); |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + return $event; |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + protected function getParameters(IEvent $event) { |
|
| 280 | + $subject = $event->getSubject(); |
|
| 281 | + $parameters = $event->getSubjectParameters(); |
|
| 282 | + |
|
| 283 | + switch ($subject) { |
|
| 284 | + case self::CREATE_TAG: |
|
| 285 | + case self::DELETE_TAG: |
|
| 286 | + return [ |
|
| 287 | + 'actor' => $this->getUserParameter((string) $parameters[0]), |
|
| 288 | + 'systemtag' => $this->getSystemTagParameter($parameters[1]), |
|
| 289 | + ]; |
|
| 290 | + case self::UPDATE_TAG: |
|
| 291 | + return [ |
|
| 292 | + 'actor' => $this->getUserParameter((string) $parameters[0]), |
|
| 293 | + 'newsystemtag' => $this->getSystemTagParameter($parameters[1]), |
|
| 294 | + 'oldsystemtag' => $this->getSystemTagParameter($parameters[2]), |
|
| 295 | + ]; |
|
| 296 | + case self::ASSIGN_TAG: |
|
| 297 | + case self::UNASSIGN_TAG: |
|
| 298 | + return [ |
|
| 299 | + 'actor' => $this->getUserParameter((string) $parameters[0]), |
|
| 300 | + 'file' => $this->getFileParameter($event->getObjectId(), $parameters[1]), |
|
| 301 | + 'systemtag' => $this->getSystemTagParameter($parameters[2]), |
|
| 302 | + ]; |
|
| 303 | + } |
|
| 304 | + return []; |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + protected function getFileParameter($id, $path) { |
|
| 308 | + return [ |
|
| 309 | + 'type' => 'file', |
|
| 310 | + 'id' => $id, |
|
| 311 | + 'name' => basename($path), |
|
| 312 | + 'path' => trim($path, '/'), |
|
| 313 | + ]; |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + protected function getSystemTagParameter($parameter) { |
|
| 317 | + $tagData = json_decode($parameter, true); |
|
| 318 | + if ($tagData === null) { |
|
| 319 | + list($name, $status) = explode('|||', substr($parameter, 3, -3)); |
|
| 320 | + $tagData = [ |
|
| 321 | + 'id' => 0,// No way to recover the ID |
|
| 322 | + 'name' => $name, |
|
| 323 | + 'assignable' => $status === 'assignable', |
|
| 324 | + 'visible' => $status !== 'invisible', |
|
| 325 | + ]; |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + return [ |
|
| 329 | + 'type' => 'systemtag', |
|
| 330 | + 'id' => (int) $tagData['id'], |
|
| 331 | + 'name' => $tagData['name'], |
|
| 332 | + 'assignable' => $tagData['assignable'] ? '1' : '0', |
|
| 333 | + 'visibility' => $tagData['visible'] ? '1' : '0', |
|
| 334 | + ]; |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + protected function getUserParameter($uid) { |
|
| 338 | + if (!isset($this->displayNames[$uid])) { |
|
| 339 | + $this->displayNames[$uid] = $this->getDisplayName($uid); |
|
| 340 | + } |
|
| 341 | + |
|
| 342 | + return [ |
|
| 343 | + 'type' => 'user', |
|
| 344 | + 'id' => $uid, |
|
| 345 | + 'name' => $this->displayNames[$uid], |
|
| 346 | + ]; |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + protected function generatePlainSystemTag(array $parameter) { |
|
| 350 | + if ($parameter['assignable'] === '1') { |
|
| 351 | + return $parameter['name']; |
|
| 352 | + } elseif ($parameter['visibility'] === '1') { |
|
| 353 | + return $this->l->t('%s (restricted)', $parameter['name']); |
|
| 354 | + } else { |
|
| 355 | + return $this->l->t('%s (invisible)', $parameter['name']); |
|
| 356 | + } |
|
| 357 | + } |
|
| 358 | + |
|
| 359 | + /** |
|
| 360 | + * @param string $uid |
|
| 361 | + * @return string |
|
| 362 | + */ |
|
| 363 | + protected function getDisplayName($uid) { |
|
| 364 | + $user = $this->userManager->get($uid); |
|
| 365 | + if ($user instanceof IUser) { |
|
| 366 | + return $user->getDisplayName(); |
|
| 367 | + } else { |
|
| 368 | + return $uid; |
|
| 369 | + } |
|
| 370 | + } |
|
| 371 | 371 | } |
@@ -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 | |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | 24 | return [ |
| 25 | - 'routes' => [ |
|
| 26 | - ['name' => 'LastUsed#getLastUsedTagIds', 'url' => '/lastused', 'verb' => 'GET'], |
|
| 27 | - ] |
|
| 25 | + 'routes' => [ |
|
| 26 | + ['name' => 'LastUsed#getLastUsedTagIds', 'url' => '/lastused', 'verb' => 'GET'], |
|
| 27 | + ] |
|
| 28 | 28 | ]; |