@@ -27,148 +27,148 @@ |
||
27 | 27 | |
28 | 28 | class Action implements IAction { |
29 | 29 | |
30 | - /** @var string */ |
|
31 | - protected $label; |
|
32 | - |
|
33 | - /** @var string */ |
|
34 | - protected $labelParsed; |
|
35 | - |
|
36 | - /** @var string */ |
|
37 | - protected $link; |
|
38 | - |
|
39 | - /** @var string */ |
|
40 | - protected $requestType; |
|
41 | - |
|
42 | - /** @var string */ |
|
43 | - protected $icon; |
|
44 | - |
|
45 | - /** @var bool */ |
|
46 | - protected $primary; |
|
47 | - |
|
48 | - /** |
|
49 | - * Constructor |
|
50 | - */ |
|
51 | - public function __construct() { |
|
52 | - $this->label = ''; |
|
53 | - $this->labelParsed = ''; |
|
54 | - $this->link = ''; |
|
55 | - $this->requestType = ''; |
|
56 | - $this->primary = false; |
|
57 | - } |
|
58 | - |
|
59 | - /** |
|
60 | - * @param string $label |
|
61 | - * @return $this |
|
62 | - * @throws \InvalidArgumentException if the label is invalid |
|
63 | - * @since 8.2.0 |
|
64 | - */ |
|
65 | - public function setLabel($label) { |
|
66 | - if (!is_string($label) || $label === '' || isset($label[32])) { |
|
67 | - throw new \InvalidArgumentException('The given label is invalid'); |
|
68 | - } |
|
69 | - $this->label = $label; |
|
70 | - return $this; |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * @return string |
|
75 | - * @since 8.2.0 |
|
76 | - */ |
|
77 | - public function getLabel() { |
|
78 | - return $this->label; |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * @param string $label |
|
83 | - * @return $this |
|
84 | - * @throws \InvalidArgumentException if the label is invalid |
|
85 | - * @since 8.2.0 |
|
86 | - */ |
|
87 | - public function setParsedLabel($label) { |
|
88 | - if (!is_string($label) || $label === '') { |
|
89 | - throw new \InvalidArgumentException('The given parsed label is invalid'); |
|
90 | - } |
|
91 | - $this->labelParsed = $label; |
|
92 | - return $this; |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * @return string |
|
97 | - * @since 8.2.0 |
|
98 | - */ |
|
99 | - public function getParsedLabel() { |
|
100 | - return $this->labelParsed; |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * @param $primary bool |
|
105 | - * @return $this |
|
106 | - * @throws \InvalidArgumentException if $primary is invalid |
|
107 | - * @since 9.0.0 |
|
108 | - */ |
|
109 | - public function setPrimary($primary) { |
|
110 | - if (!is_bool($primary)) { |
|
111 | - throw new \InvalidArgumentException('The given primary option is invalid'); |
|
112 | - } |
|
113 | - |
|
114 | - $this->primary = $primary; |
|
115 | - return $this; |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * @return bool |
|
120 | - * @since 9.0.0 |
|
121 | - */ |
|
122 | - public function isPrimary() { |
|
123 | - return $this->primary; |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * @param string $link |
|
128 | - * @param string $requestType |
|
129 | - * @return $this |
|
130 | - * @throws \InvalidArgumentException if the link is invalid |
|
131 | - * @since 8.2.0 |
|
132 | - */ |
|
133 | - public function setLink($link, $requestType) { |
|
134 | - if (!is_string($link) || $link === '' || isset($link[256])) { |
|
135 | - throw new \InvalidArgumentException('The given link is invalid'); |
|
136 | - } |
|
137 | - if (!in_array($requestType, ['GET', 'POST', 'PUT', 'DELETE'], true)) { |
|
138 | - throw new \InvalidArgumentException('The given request type is invalid'); |
|
139 | - } |
|
140 | - $this->link = $link; |
|
141 | - $this->requestType = $requestType; |
|
142 | - return $this; |
|
143 | - } |
|
144 | - |
|
145 | - /** |
|
146 | - * @return string |
|
147 | - * @since 8.2.0 |
|
148 | - */ |
|
149 | - public function getLink() { |
|
150 | - return $this->link; |
|
151 | - } |
|
152 | - |
|
153 | - /** |
|
154 | - * @return string |
|
155 | - * @since 8.2.0 |
|
156 | - */ |
|
157 | - public function getRequestType() { |
|
158 | - return $this->requestType; |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * @return bool |
|
163 | - */ |
|
164 | - public function isValid() { |
|
165 | - return $this->label !== '' && $this->link !== ''; |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * @return bool |
|
170 | - */ |
|
171 | - public function isValidParsed() { |
|
172 | - return $this->labelParsed !== '' && $this->link !== ''; |
|
173 | - } |
|
30 | + /** @var string */ |
|
31 | + protected $label; |
|
32 | + |
|
33 | + /** @var string */ |
|
34 | + protected $labelParsed; |
|
35 | + |
|
36 | + /** @var string */ |
|
37 | + protected $link; |
|
38 | + |
|
39 | + /** @var string */ |
|
40 | + protected $requestType; |
|
41 | + |
|
42 | + /** @var string */ |
|
43 | + protected $icon; |
|
44 | + |
|
45 | + /** @var bool */ |
|
46 | + protected $primary; |
|
47 | + |
|
48 | + /** |
|
49 | + * Constructor |
|
50 | + */ |
|
51 | + public function __construct() { |
|
52 | + $this->label = ''; |
|
53 | + $this->labelParsed = ''; |
|
54 | + $this->link = ''; |
|
55 | + $this->requestType = ''; |
|
56 | + $this->primary = false; |
|
57 | + } |
|
58 | + |
|
59 | + /** |
|
60 | + * @param string $label |
|
61 | + * @return $this |
|
62 | + * @throws \InvalidArgumentException if the label is invalid |
|
63 | + * @since 8.2.0 |
|
64 | + */ |
|
65 | + public function setLabel($label) { |
|
66 | + if (!is_string($label) || $label === '' || isset($label[32])) { |
|
67 | + throw new \InvalidArgumentException('The given label is invalid'); |
|
68 | + } |
|
69 | + $this->label = $label; |
|
70 | + return $this; |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * @return string |
|
75 | + * @since 8.2.0 |
|
76 | + */ |
|
77 | + public function getLabel() { |
|
78 | + return $this->label; |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * @param string $label |
|
83 | + * @return $this |
|
84 | + * @throws \InvalidArgumentException if the label is invalid |
|
85 | + * @since 8.2.0 |
|
86 | + */ |
|
87 | + public function setParsedLabel($label) { |
|
88 | + if (!is_string($label) || $label === '') { |
|
89 | + throw new \InvalidArgumentException('The given parsed label is invalid'); |
|
90 | + } |
|
91 | + $this->labelParsed = $label; |
|
92 | + return $this; |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * @return string |
|
97 | + * @since 8.2.0 |
|
98 | + */ |
|
99 | + public function getParsedLabel() { |
|
100 | + return $this->labelParsed; |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * @param $primary bool |
|
105 | + * @return $this |
|
106 | + * @throws \InvalidArgumentException if $primary is invalid |
|
107 | + * @since 9.0.0 |
|
108 | + */ |
|
109 | + public function setPrimary($primary) { |
|
110 | + if (!is_bool($primary)) { |
|
111 | + throw new \InvalidArgumentException('The given primary option is invalid'); |
|
112 | + } |
|
113 | + |
|
114 | + $this->primary = $primary; |
|
115 | + return $this; |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * @return bool |
|
120 | + * @since 9.0.0 |
|
121 | + */ |
|
122 | + public function isPrimary() { |
|
123 | + return $this->primary; |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * @param string $link |
|
128 | + * @param string $requestType |
|
129 | + * @return $this |
|
130 | + * @throws \InvalidArgumentException if the link is invalid |
|
131 | + * @since 8.2.0 |
|
132 | + */ |
|
133 | + public function setLink($link, $requestType) { |
|
134 | + if (!is_string($link) || $link === '' || isset($link[256])) { |
|
135 | + throw new \InvalidArgumentException('The given link is invalid'); |
|
136 | + } |
|
137 | + if (!in_array($requestType, ['GET', 'POST', 'PUT', 'DELETE'], true)) { |
|
138 | + throw new \InvalidArgumentException('The given request type is invalid'); |
|
139 | + } |
|
140 | + $this->link = $link; |
|
141 | + $this->requestType = $requestType; |
|
142 | + return $this; |
|
143 | + } |
|
144 | + |
|
145 | + /** |
|
146 | + * @return string |
|
147 | + * @since 8.2.0 |
|
148 | + */ |
|
149 | + public function getLink() { |
|
150 | + return $this->link; |
|
151 | + } |
|
152 | + |
|
153 | + /** |
|
154 | + * @return string |
|
155 | + * @since 8.2.0 |
|
156 | + */ |
|
157 | + public function getRequestType() { |
|
158 | + return $this->requestType; |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * @return bool |
|
163 | + */ |
|
164 | + public function isValid() { |
|
165 | + return $this->label !== '' && $this->link !== ''; |
|
166 | + } |
|
167 | + |
|
168 | + /** |
|
169 | + * @return bool |
|
170 | + */ |
|
171 | + public function isValidParsed() { |
|
172 | + return $this->labelParsed !== '' && $this->link !== ''; |
|
173 | + } |
|
174 | 174 | } |
@@ -30,32 +30,32 @@ |
||
30 | 30 | * @package OC\Integritycheck\Iterator |
31 | 31 | */ |
32 | 32 | class ExcludeFileByNameFilterIterator extends \RecursiveFilterIterator { |
33 | - /** |
|
34 | - * Array of excluded file names. Those are not scanned by the integrity checker. |
|
35 | - * This is used to exclude files which administrators could upload by mistakes |
|
36 | - * such as .DS_Store files. |
|
37 | - * |
|
38 | - * @var array |
|
39 | - */ |
|
40 | - private $excludedFilenames = [ |
|
41 | - '.DS_Store', // Mac OS X |
|
42 | - 'Thumbs.db', // Microsoft Windows |
|
43 | - '.directory', // Dolphin (KDE) |
|
44 | - '.webapp', // Gentoo/Funtoo & derivatives use a tool known as webapp-config to manager wep-apps. |
|
45 | - ]; |
|
33 | + /** |
|
34 | + * Array of excluded file names. Those are not scanned by the integrity checker. |
|
35 | + * This is used to exclude files which administrators could upload by mistakes |
|
36 | + * such as .DS_Store files. |
|
37 | + * |
|
38 | + * @var array |
|
39 | + */ |
|
40 | + private $excludedFilenames = [ |
|
41 | + '.DS_Store', // Mac OS X |
|
42 | + 'Thumbs.db', // Microsoft Windows |
|
43 | + '.directory', // Dolphin (KDE) |
|
44 | + '.webapp', // Gentoo/Funtoo & derivatives use a tool known as webapp-config to manager wep-apps. |
|
45 | + ]; |
|
46 | 46 | |
47 | - /** |
|
48 | - * @return bool |
|
49 | - */ |
|
50 | - public function accept() { |
|
51 | - if($this->isDir()) { |
|
52 | - return true; |
|
53 | - } |
|
47 | + /** |
|
48 | + * @return bool |
|
49 | + */ |
|
50 | + public function accept() { |
|
51 | + if($this->isDir()) { |
|
52 | + return true; |
|
53 | + } |
|
54 | 54 | |
55 | - return !in_array( |
|
56 | - $this->current()->getFilename(), |
|
57 | - $this->excludedFilenames, |
|
58 | - true |
|
59 | - ); |
|
60 | - } |
|
55 | + return !in_array( |
|
56 | + $this->current()->getFilename(), |
|
57 | + $this->excludedFilenames, |
|
58 | + true |
|
59 | + ); |
|
60 | + } |
|
61 | 61 | } |
@@ -24,45 +24,45 @@ |
||
24 | 24 | namespace OC\IntegrityCheck\Iterator; |
25 | 25 | |
26 | 26 | class ExcludeFoldersByPathFilterIterator extends \RecursiveFilterIterator { |
27 | - private $excludedFolders = []; |
|
27 | + private $excludedFolders = []; |
|
28 | 28 | |
29 | - public function __construct(\RecursiveIterator $iterator, $root = '') { |
|
30 | - parent::__construct($iterator); |
|
29 | + public function __construct(\RecursiveIterator $iterator, $root = '') { |
|
30 | + parent::__construct($iterator); |
|
31 | 31 | |
32 | - $appFolders = \OC::$APPSROOTS; |
|
33 | - foreach($appFolders as $key => $appFolder) { |
|
34 | - $appFolders[$key] = rtrim($appFolder['path'], '/'); |
|
35 | - } |
|
32 | + $appFolders = \OC::$APPSROOTS; |
|
33 | + foreach($appFolders as $key => $appFolder) { |
|
34 | + $appFolders[$key] = rtrim($appFolder['path'], '/'); |
|
35 | + } |
|
36 | 36 | |
37 | - $excludedFolders = [ |
|
38 | - rtrim($root . '/data', '/'), |
|
39 | - rtrim($root . '/themes', '/'), |
|
40 | - rtrim($root . '/config', '/'), |
|
41 | - rtrim($root . '/apps', '/'), |
|
42 | - rtrim($root . '/assets', '/'), |
|
43 | - rtrim($root . '/lost+found', '/'), |
|
44 | - // Ignore folders generated by updater since the updater is replaced |
|
45 | - // after the integrity check is run. |
|
46 | - // See https://github.com/owncloud/updater/issues/318#issuecomment-212497846 |
|
47 | - rtrim($root . '/updater', '/'), |
|
48 | - rtrim($root . '/_oc_upgrade', '/'), |
|
49 | - ]; |
|
50 | - $customDataDir = \OC::$server->getConfig()->getSystemValue('datadirectory', ''); |
|
51 | - if($customDataDir !== '') { |
|
52 | - $excludedFolders[] = rtrim($customDataDir, '/'); |
|
53 | - } |
|
37 | + $excludedFolders = [ |
|
38 | + rtrim($root . '/data', '/'), |
|
39 | + rtrim($root . '/themes', '/'), |
|
40 | + rtrim($root . '/config', '/'), |
|
41 | + rtrim($root . '/apps', '/'), |
|
42 | + rtrim($root . '/assets', '/'), |
|
43 | + rtrim($root . '/lost+found', '/'), |
|
44 | + // Ignore folders generated by updater since the updater is replaced |
|
45 | + // after the integrity check is run. |
|
46 | + // See https://github.com/owncloud/updater/issues/318#issuecomment-212497846 |
|
47 | + rtrim($root . '/updater', '/'), |
|
48 | + rtrim($root . '/_oc_upgrade', '/'), |
|
49 | + ]; |
|
50 | + $customDataDir = \OC::$server->getConfig()->getSystemValue('datadirectory', ''); |
|
51 | + if($customDataDir !== '') { |
|
52 | + $excludedFolders[] = rtrim($customDataDir, '/'); |
|
53 | + } |
|
54 | 54 | |
55 | - $this->excludedFolders = array_merge($excludedFolders, $appFolders); |
|
56 | - } |
|
55 | + $this->excludedFolders = array_merge($excludedFolders, $appFolders); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @return bool |
|
60 | - */ |
|
61 | - public function accept() { |
|
62 | - return !in_array( |
|
63 | - $this->current()->getPathName(), |
|
64 | - $this->excludedFolders, |
|
65 | - true |
|
66 | - ); |
|
67 | - } |
|
58 | + /** |
|
59 | + * @return bool |
|
60 | + */ |
|
61 | + public function accept() { |
|
62 | + return !in_array( |
|
63 | + $this->current()->getPathName(), |
|
64 | + $this->excludedFolders, |
|
65 | + true |
|
66 | + ); |
|
67 | + } |
|
68 | 68 | } |
@@ -29,21 +29,21 @@ |
||
29 | 29 | * @package OC\IntegrityCheck\Helpers |
30 | 30 | */ |
31 | 31 | class EnvironmentHelper { |
32 | - /** |
|
33 | - * Provides \OC::$SERVERROOT |
|
34 | - * |
|
35 | - * @return string |
|
36 | - */ |
|
37 | - public function getServerRoot() { |
|
38 | - return rtrim(\OC::$SERVERROOT, '/'); |
|
39 | - } |
|
32 | + /** |
|
33 | + * Provides \OC::$SERVERROOT |
|
34 | + * |
|
35 | + * @return string |
|
36 | + */ |
|
37 | + public function getServerRoot() { |
|
38 | + return rtrim(\OC::$SERVERROOT, '/'); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Provides \OC_Util::getChannel() |
|
43 | - * |
|
44 | - * @return string |
|
45 | - */ |
|
46 | - public function getChannel() { |
|
47 | - return \OC_Util::getChannel(); |
|
48 | - } |
|
41 | + /** |
|
42 | + * Provides \OC_Util::getChannel() |
|
43 | + * |
|
44 | + * @return string |
|
45 | + */ |
|
46 | + public function getChannel() { |
|
47 | + return \OC_Util::getChannel(); |
|
48 | + } |
|
49 | 49 | } |
@@ -29,57 +29,57 @@ |
||
29 | 29 | * @package OC\IntegrityCheck\Helpers |
30 | 30 | */ |
31 | 31 | class FileAccessHelper { |
32 | - /** |
|
33 | - * Wrapper around file_get_contents($filename, $data) |
|
34 | - * |
|
35 | - * @param string $filename |
|
36 | - * @return string|false |
|
37 | - */ |
|
38 | - public function file_get_contents($filename) { |
|
39 | - return file_get_contents($filename); |
|
40 | - } |
|
32 | + /** |
|
33 | + * Wrapper around file_get_contents($filename, $data) |
|
34 | + * |
|
35 | + * @param string $filename |
|
36 | + * @return string|false |
|
37 | + */ |
|
38 | + public function file_get_contents($filename) { |
|
39 | + return file_get_contents($filename); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Wrapper around file_exists($filename) |
|
44 | - * |
|
45 | - * @param string $filename |
|
46 | - * @return bool |
|
47 | - */ |
|
48 | - public function file_exists($filename) { |
|
49 | - return file_exists($filename); |
|
50 | - } |
|
42 | + /** |
|
43 | + * Wrapper around file_exists($filename) |
|
44 | + * |
|
45 | + * @param string $filename |
|
46 | + * @return bool |
|
47 | + */ |
|
48 | + public function file_exists($filename) { |
|
49 | + return file_exists($filename); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Wrapper around file_put_contents($filename, $data) |
|
54 | - * |
|
55 | - * @param string $filename |
|
56 | - * @param string $data |
|
57 | - * @return int |
|
58 | - * @throws \Exception |
|
59 | - */ |
|
60 | - public function file_put_contents($filename, $data) { |
|
61 | - $bytesWritten = @file_put_contents($filename, $data); |
|
62 | - if ($bytesWritten === false || $bytesWritten !== strlen($data)){ |
|
63 | - throw new \Exception('Failed to write into ' . $filename); |
|
64 | - } |
|
65 | - return $bytesWritten; |
|
66 | - } |
|
52 | + /** |
|
53 | + * Wrapper around file_put_contents($filename, $data) |
|
54 | + * |
|
55 | + * @param string $filename |
|
56 | + * @param string $data |
|
57 | + * @return int |
|
58 | + * @throws \Exception |
|
59 | + */ |
|
60 | + public function file_put_contents($filename, $data) { |
|
61 | + $bytesWritten = @file_put_contents($filename, $data); |
|
62 | + if ($bytesWritten === false || $bytesWritten !== strlen($data)){ |
|
63 | + throw new \Exception('Failed to write into ' . $filename); |
|
64 | + } |
|
65 | + return $bytesWritten; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @param string $path |
|
70 | - * @return bool |
|
71 | - */ |
|
72 | - public function is_writable($path) { |
|
73 | - return is_writable($path); |
|
74 | - } |
|
68 | + /** |
|
69 | + * @param string $path |
|
70 | + * @return bool |
|
71 | + */ |
|
72 | + public function is_writable($path) { |
|
73 | + return is_writable($path); |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @param string $path |
|
78 | - * @throws \Exception |
|
79 | - */ |
|
80 | - public function assertDirectoryExists($path) { |
|
81 | - if (!is_dir($path)) { |
|
82 | - throw new \Exception('Directory ' . $path . ' does not exist.'); |
|
83 | - } |
|
84 | - } |
|
76 | + /** |
|
77 | + * @param string $path |
|
78 | + * @throws \Exception |
|
79 | + */ |
|
80 | + public function assertDirectoryExists($path) { |
|
81 | + if (!is_dir($path)) { |
|
82 | + throw new \Exception('Directory ' . $path . ' does not exist.'); |
|
83 | + } |
|
84 | + } |
|
85 | 85 | } |
@@ -30,28 +30,28 @@ |
||
30 | 30 | * @package OC\IntegrityCheck\Helpers |
31 | 31 | */ |
32 | 32 | class AppLocator { |
33 | - /** |
|
34 | - * Provides \OC_App::getAppPath($appId) |
|
35 | - * |
|
36 | - * @param string $appId |
|
37 | - * @return string |
|
38 | - * @throws \Exception If the app cannot be found |
|
39 | - */ |
|
40 | - public function getAppPath($appId) { |
|
41 | - $path = \OC_App::getAppPath($appId); |
|
42 | - if($path === false) { |
|
33 | + /** |
|
34 | + * Provides \OC_App::getAppPath($appId) |
|
35 | + * |
|
36 | + * @param string $appId |
|
37 | + * @return string |
|
38 | + * @throws \Exception If the app cannot be found |
|
39 | + */ |
|
40 | + public function getAppPath($appId) { |
|
41 | + $path = \OC_App::getAppPath($appId); |
|
42 | + if($path === false) { |
|
43 | 43 | |
44 | - throw new \Exception('App not found'); |
|
45 | - } |
|
46 | - return $path; |
|
47 | - } |
|
44 | + throw new \Exception('App not found'); |
|
45 | + } |
|
46 | + return $path; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Providers \OC_App::getAllApps() |
|
51 | - * |
|
52 | - * @return array |
|
53 | - */ |
|
54 | - public function getAllApps() { |
|
55 | - return \OC_App::getAllApps(); |
|
56 | - } |
|
49 | + /** |
|
50 | + * Providers \OC_App::getAllApps() |
|
51 | + * |
|
52 | + * @return array |
|
53 | + */ |
|
54 | + public function getAllApps() { |
|
55 | + return \OC_App::getAllApps(); |
|
56 | + } |
|
57 | 57 | } |
@@ -35,46 +35,46 @@ |
||
35 | 35 | */ |
36 | 36 | class HintException extends \Exception { |
37 | 37 | |
38 | - private $hint; |
|
38 | + private $hint; |
|
39 | 39 | |
40 | - /** |
|
41 | - * HintException constructor. |
|
42 | - * |
|
43 | - * @param string $message The error message. It will be not revealed to the |
|
44 | - * the user (unless the hint is empty) and thus |
|
45 | - * should be not translated. |
|
46 | - * @param string $hint A useful message that is presented to the end |
|
47 | - * user. It should be translated, but must not |
|
48 | - * contain sensitive data. |
|
49 | - * @param int $code |
|
50 | - * @param \Exception|null $previous |
|
51 | - */ |
|
52 | - public function __construct($message, $hint = '', $code = 0, \Exception $previous = null) { |
|
53 | - $this->hint = $hint; |
|
54 | - parent::__construct($message, $code, $previous); |
|
55 | - } |
|
40 | + /** |
|
41 | + * HintException constructor. |
|
42 | + * |
|
43 | + * @param string $message The error message. It will be not revealed to the |
|
44 | + * the user (unless the hint is empty) and thus |
|
45 | + * should be not translated. |
|
46 | + * @param string $hint A useful message that is presented to the end |
|
47 | + * user. It should be translated, but must not |
|
48 | + * contain sensitive data. |
|
49 | + * @param int $code |
|
50 | + * @param \Exception|null $previous |
|
51 | + */ |
|
52 | + public function __construct($message, $hint = '', $code = 0, \Exception $previous = null) { |
|
53 | + $this->hint = $hint; |
|
54 | + parent::__construct($message, $code, $previous); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Returns a string representation of this Exception that includes the error |
|
59 | - * code, the message and the hint. |
|
60 | - * |
|
61 | - * @return string |
|
62 | - */ |
|
63 | - public function __toString() { |
|
64 | - return __CLASS__ . ": [{$this->code}]: {$this->message} ({$this->hint})\n"; |
|
65 | - } |
|
57 | + /** |
|
58 | + * Returns a string representation of this Exception that includes the error |
|
59 | + * code, the message and the hint. |
|
60 | + * |
|
61 | + * @return string |
|
62 | + */ |
|
63 | + public function __toString() { |
|
64 | + return __CLASS__ . ": [{$this->code}]: {$this->message} ({$this->hint})\n"; |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Returns the hint with the intention to be presented to the end user. If |
|
69 | - * an empty hint was specified upon instatiation, the message is returned |
|
70 | - * instead. |
|
71 | - * |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - public function getHint() { |
|
75 | - if (empty($this->hint)) { |
|
76 | - return $this->message; |
|
77 | - } |
|
78 | - return $this->hint; |
|
79 | - } |
|
67 | + /** |
|
68 | + * Returns the hint with the intention to be presented to the end user. If |
|
69 | + * an empty hint was specified upon instatiation, the message is returned |
|
70 | + * instead. |
|
71 | + * |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + public function getHint() { |
|
75 | + if (empty($this->hint)) { |
|
76 | + return $this->message; |
|
77 | + } |
|
78 | + return $this->hint; |
|
79 | + } |
|
80 | 80 | } |
@@ -29,136 +29,136 @@ |
||
29 | 29 | * capabilities. |
30 | 30 | */ |
31 | 31 | abstract class Backend implements UserInterface { |
32 | - /** |
|
33 | - * error code for functions not provided by the user backend |
|
34 | - */ |
|
35 | - const NOT_IMPLEMENTED = -501; |
|
32 | + /** |
|
33 | + * error code for functions not provided by the user backend |
|
34 | + */ |
|
35 | + const NOT_IMPLEMENTED = -501; |
|
36 | 36 | |
37 | - /** |
|
38 | - * actions that user backends can define |
|
39 | - */ |
|
40 | - const CREATE_USER = 1; // 1 << 0 |
|
41 | - const SET_PASSWORD = 16; // 1 << 4 |
|
42 | - const CHECK_PASSWORD = 256; // 1 << 8 |
|
43 | - const GET_HOME = 4096; // 1 << 12 |
|
44 | - const GET_DISPLAYNAME = 65536; // 1 << 16 |
|
45 | - const SET_DISPLAYNAME = 1048576; // 1 << 20 |
|
46 | - const PROVIDE_AVATAR = 16777216; // 1 << 24 |
|
47 | - const COUNT_USERS = 268435456; // 1 << 28 |
|
37 | + /** |
|
38 | + * actions that user backends can define |
|
39 | + */ |
|
40 | + const CREATE_USER = 1; // 1 << 0 |
|
41 | + const SET_PASSWORD = 16; // 1 << 4 |
|
42 | + const CHECK_PASSWORD = 256; // 1 << 8 |
|
43 | + const GET_HOME = 4096; // 1 << 12 |
|
44 | + const GET_DISPLAYNAME = 65536; // 1 << 16 |
|
45 | + const SET_DISPLAYNAME = 1048576; // 1 << 20 |
|
46 | + const PROVIDE_AVATAR = 16777216; // 1 << 24 |
|
47 | + const COUNT_USERS = 268435456; // 1 << 28 |
|
48 | 48 | |
49 | - protected $possibleActions = array( |
|
50 | - self::CREATE_USER => 'createUser', |
|
51 | - self::SET_PASSWORD => 'setPassword', |
|
52 | - self::CHECK_PASSWORD => 'checkPassword', |
|
53 | - self::GET_HOME => 'getHome', |
|
54 | - self::GET_DISPLAYNAME => 'getDisplayName', |
|
55 | - self::SET_DISPLAYNAME => 'setDisplayName', |
|
56 | - self::PROVIDE_AVATAR => 'canChangeAvatar', |
|
57 | - self::COUNT_USERS => 'countUsers', |
|
58 | - ); |
|
49 | + protected $possibleActions = array( |
|
50 | + self::CREATE_USER => 'createUser', |
|
51 | + self::SET_PASSWORD => 'setPassword', |
|
52 | + self::CHECK_PASSWORD => 'checkPassword', |
|
53 | + self::GET_HOME => 'getHome', |
|
54 | + self::GET_DISPLAYNAME => 'getDisplayName', |
|
55 | + self::SET_DISPLAYNAME => 'setDisplayName', |
|
56 | + self::PROVIDE_AVATAR => 'canChangeAvatar', |
|
57 | + self::COUNT_USERS => 'countUsers', |
|
58 | + ); |
|
59 | 59 | |
60 | - /** |
|
61 | - * Get all supported actions |
|
62 | - * @return int bitwise-or'ed actions |
|
63 | - * |
|
64 | - * Returns the supported actions as int to be |
|
65 | - * compared with self::CREATE_USER etc. |
|
66 | - */ |
|
67 | - public function getSupportedActions() { |
|
68 | - $actions = 0; |
|
69 | - foreach($this->possibleActions AS $action => $methodName) { |
|
70 | - if(method_exists($this, $methodName)) { |
|
71 | - $actions |= $action; |
|
72 | - } |
|
73 | - } |
|
60 | + /** |
|
61 | + * Get all supported actions |
|
62 | + * @return int bitwise-or'ed actions |
|
63 | + * |
|
64 | + * Returns the supported actions as int to be |
|
65 | + * compared with self::CREATE_USER etc. |
|
66 | + */ |
|
67 | + public function getSupportedActions() { |
|
68 | + $actions = 0; |
|
69 | + foreach($this->possibleActions AS $action => $methodName) { |
|
70 | + if(method_exists($this, $methodName)) { |
|
71 | + $actions |= $action; |
|
72 | + } |
|
73 | + } |
|
74 | 74 | |
75 | - return $actions; |
|
76 | - } |
|
75 | + return $actions; |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Check if backend implements actions |
|
80 | - * @param int $actions bitwise-or'ed actions |
|
81 | - * @return boolean |
|
82 | - * |
|
83 | - * Returns the supported actions as int to be |
|
84 | - * compared with self::CREATE_USER etc. |
|
85 | - */ |
|
86 | - public function implementsActions($actions) { |
|
87 | - return (bool)($this->getSupportedActions() & $actions); |
|
88 | - } |
|
78 | + /** |
|
79 | + * Check if backend implements actions |
|
80 | + * @param int $actions bitwise-or'ed actions |
|
81 | + * @return boolean |
|
82 | + * |
|
83 | + * Returns the supported actions as int to be |
|
84 | + * compared with self::CREATE_USER etc. |
|
85 | + */ |
|
86 | + public function implementsActions($actions) { |
|
87 | + return (bool)($this->getSupportedActions() & $actions); |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * delete a user |
|
92 | - * @param string $uid The username of the user to delete |
|
93 | - * @return bool |
|
94 | - * |
|
95 | - * Deletes a user |
|
96 | - */ |
|
97 | - public function deleteUser( $uid ) { |
|
98 | - return false; |
|
99 | - } |
|
90 | + /** |
|
91 | + * delete a user |
|
92 | + * @param string $uid The username of the user to delete |
|
93 | + * @return bool |
|
94 | + * |
|
95 | + * Deletes a user |
|
96 | + */ |
|
97 | + public function deleteUser( $uid ) { |
|
98 | + return false; |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * Get a list of all users |
|
103 | - * |
|
104 | - * @param string $search |
|
105 | - * @param null|int $limit |
|
106 | - * @param null|int $offset |
|
107 | - * @return string[] an array of all uids |
|
108 | - */ |
|
109 | - public function getUsers($search = '', $limit = null, $offset = null) { |
|
110 | - return array(); |
|
111 | - } |
|
101 | + /** |
|
102 | + * Get a list of all users |
|
103 | + * |
|
104 | + * @param string $search |
|
105 | + * @param null|int $limit |
|
106 | + * @param null|int $offset |
|
107 | + * @return string[] an array of all uids |
|
108 | + */ |
|
109 | + public function getUsers($search = '', $limit = null, $offset = null) { |
|
110 | + return array(); |
|
111 | + } |
|
112 | 112 | |
113 | - /** |
|
114 | - * check if a user exists |
|
115 | - * @param string $uid the username |
|
116 | - * @return boolean |
|
117 | - */ |
|
118 | - public function userExists($uid) { |
|
119 | - return false; |
|
120 | - } |
|
113 | + /** |
|
114 | + * check if a user exists |
|
115 | + * @param string $uid the username |
|
116 | + * @return boolean |
|
117 | + */ |
|
118 | + public function userExists($uid) { |
|
119 | + return false; |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * get the user's home directory |
|
124 | - * @param string $uid the username |
|
125 | - * @return boolean |
|
126 | - */ |
|
127 | - public function getHome($uid) { |
|
128 | - return false; |
|
129 | - } |
|
122 | + /** |
|
123 | + * get the user's home directory |
|
124 | + * @param string $uid the username |
|
125 | + * @return boolean |
|
126 | + */ |
|
127 | + public function getHome($uid) { |
|
128 | + return false; |
|
129 | + } |
|
130 | 130 | |
131 | - /** |
|
132 | - * get display name of the user |
|
133 | - * @param string $uid user ID of the user |
|
134 | - * @return string display name |
|
135 | - */ |
|
136 | - public function getDisplayName($uid) { |
|
137 | - return $uid; |
|
138 | - } |
|
131 | + /** |
|
132 | + * get display name of the user |
|
133 | + * @param string $uid user ID of the user |
|
134 | + * @return string display name |
|
135 | + */ |
|
136 | + public function getDisplayName($uid) { |
|
137 | + return $uid; |
|
138 | + } |
|
139 | 139 | |
140 | - /** |
|
141 | - * Get a list of all display names and user ids. |
|
142 | - * |
|
143 | - * @param string $search |
|
144 | - * @param string|null $limit |
|
145 | - * @param string|null $offset |
|
146 | - * @return array an array of all displayNames (value) and the corresponding uids (key) |
|
147 | - */ |
|
148 | - public function getDisplayNames($search = '', $limit = null, $offset = null) { |
|
149 | - $displayNames = array(); |
|
150 | - $users = $this->getUsers($search, $limit, $offset); |
|
151 | - foreach ( $users as $user) { |
|
152 | - $displayNames[$user] = $user; |
|
153 | - } |
|
154 | - return $displayNames; |
|
155 | - } |
|
140 | + /** |
|
141 | + * Get a list of all display names and user ids. |
|
142 | + * |
|
143 | + * @param string $search |
|
144 | + * @param string|null $limit |
|
145 | + * @param string|null $offset |
|
146 | + * @return array an array of all displayNames (value) and the corresponding uids (key) |
|
147 | + */ |
|
148 | + public function getDisplayNames($search = '', $limit = null, $offset = null) { |
|
149 | + $displayNames = array(); |
|
150 | + $users = $this->getUsers($search, $limit, $offset); |
|
151 | + foreach ( $users as $user) { |
|
152 | + $displayNames[$user] = $user; |
|
153 | + } |
|
154 | + return $displayNames; |
|
155 | + } |
|
156 | 156 | |
157 | - /** |
|
158 | - * Check if a user list is available or not |
|
159 | - * @return boolean if users can be listed or not |
|
160 | - */ |
|
161 | - public function hasUserListings() { |
|
162 | - return false; |
|
163 | - } |
|
157 | + /** |
|
158 | + * Check if a user list is available or not |
|
159 | + * @return boolean if users can be listed or not |
|
160 | + */ |
|
161 | + public function hasUserListings() { |
|
162 | + return false; |
|
163 | + } |
|
164 | 164 | } |
@@ -26,79 +26,79 @@ |
||
26 | 26 | use OCP\Diagnostics\IEvent; |
27 | 27 | |
28 | 28 | class Event implements IEvent { |
29 | - /** |
|
30 | - * @var string |
|
31 | - */ |
|
32 | - protected $id; |
|
29 | + /** |
|
30 | + * @var string |
|
31 | + */ |
|
32 | + protected $id; |
|
33 | 33 | |
34 | - /** |
|
35 | - * @var float |
|
36 | - */ |
|
37 | - protected $start; |
|
34 | + /** |
|
35 | + * @var float |
|
36 | + */ |
|
37 | + protected $start; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var float |
|
41 | - */ |
|
42 | - protected $end; |
|
39 | + /** |
|
40 | + * @var float |
|
41 | + */ |
|
42 | + protected $end; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @var string |
|
46 | - */ |
|
47 | - protected $description; |
|
44 | + /** |
|
45 | + * @var string |
|
46 | + */ |
|
47 | + protected $description; |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param string $id |
|
51 | - * @param string $description |
|
52 | - * @param float $start |
|
53 | - */ |
|
54 | - public function __construct($id, $description, $start) { |
|
55 | - $this->id = $id; |
|
56 | - $this->description = $description; |
|
57 | - $this->start = $start; |
|
58 | - } |
|
49 | + /** |
|
50 | + * @param string $id |
|
51 | + * @param string $description |
|
52 | + * @param float $start |
|
53 | + */ |
|
54 | + public function __construct($id, $description, $start) { |
|
55 | + $this->id = $id; |
|
56 | + $this->description = $description; |
|
57 | + $this->start = $start; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @param float $time |
|
62 | - */ |
|
63 | - public function end($time) { |
|
64 | - $this->end = $time; |
|
65 | - } |
|
60 | + /** |
|
61 | + * @param float $time |
|
62 | + */ |
|
63 | + public function end($time) { |
|
64 | + $this->end = $time; |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * @return float |
|
69 | - */ |
|
70 | - public function getStart() { |
|
71 | - return $this->start; |
|
72 | - } |
|
67 | + /** |
|
68 | + * @return float |
|
69 | + */ |
|
70 | + public function getStart() { |
|
71 | + return $this->start; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return string |
|
76 | - */ |
|
77 | - public function getId() { |
|
78 | - return $this->id; |
|
79 | - } |
|
74 | + /** |
|
75 | + * @return string |
|
76 | + */ |
|
77 | + public function getId() { |
|
78 | + return $this->id; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * @return string |
|
83 | - */ |
|
84 | - public function getDescription() { |
|
85 | - return $this->description; |
|
86 | - } |
|
81 | + /** |
|
82 | + * @return string |
|
83 | + */ |
|
84 | + public function getDescription() { |
|
85 | + return $this->description; |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * @return float |
|
90 | - */ |
|
91 | - public function getEnd() { |
|
92 | - return $this->end; |
|
93 | - } |
|
88 | + /** |
|
89 | + * @return float |
|
90 | + */ |
|
91 | + public function getEnd() { |
|
92 | + return $this->end; |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * @return float |
|
97 | - */ |
|
98 | - public function getDuration() { |
|
99 | - if (!$this->end) { |
|
100 | - $this->end = microtime(true); |
|
101 | - } |
|
102 | - return $this->end - $this->start; |
|
103 | - } |
|
95 | + /** |
|
96 | + * @return float |
|
97 | + */ |
|
98 | + public function getDuration() { |
|
99 | + if (!$this->end) { |
|
100 | + $this->end = microtime(true); |
|
101 | + } |
|
102 | + return $this->end - $this->start; |
|
103 | + } |
|
104 | 104 | } |