@@ -30,70 +30,70 @@ |
||
30 | 30 | * Very thin wrapper class to make output testable |
31 | 31 | */ |
32 | 32 | class Output implements IOutput { |
33 | - /** @var string */ |
|
34 | - private $webRoot; |
|
33 | + /** @var string */ |
|
34 | + private $webRoot; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @param $webRoot |
|
38 | - */ |
|
39 | - public function __construct($webRoot) { |
|
40 | - $this->webRoot = $webRoot; |
|
41 | - } |
|
36 | + /** |
|
37 | + * @param $webRoot |
|
38 | + */ |
|
39 | + public function __construct($webRoot) { |
|
40 | + $this->webRoot = $webRoot; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param string $out |
|
45 | - */ |
|
46 | - public function setOutput($out) { |
|
47 | - print($out); |
|
48 | - } |
|
43 | + /** |
|
44 | + * @param string $out |
|
45 | + */ |
|
46 | + public function setOutput($out) { |
|
47 | + print($out); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @param string|resource $path or file handle |
|
52 | - * |
|
53 | - * @return bool false if an error occurred |
|
54 | - */ |
|
55 | - public function setReadfile($path) { |
|
56 | - if (is_resource($path)) { |
|
57 | - $output = fopen('php://output', 'w'); |
|
58 | - return stream_copy_to_stream($path, $output) > 0; |
|
59 | - } else { |
|
60 | - return @readfile($path); |
|
61 | - } |
|
62 | - } |
|
50 | + /** |
|
51 | + * @param string|resource $path or file handle |
|
52 | + * |
|
53 | + * @return bool false if an error occurred |
|
54 | + */ |
|
55 | + public function setReadfile($path) { |
|
56 | + if (is_resource($path)) { |
|
57 | + $output = fopen('php://output', 'w'); |
|
58 | + return stream_copy_to_stream($path, $output) > 0; |
|
59 | + } else { |
|
60 | + return @readfile($path); |
|
61 | + } |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @param string $header |
|
66 | - */ |
|
67 | - public function setHeader($header) { |
|
68 | - header($header); |
|
69 | - } |
|
64 | + /** |
|
65 | + * @param string $header |
|
66 | + */ |
|
67 | + public function setHeader($header) { |
|
68 | + header($header); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @param int $code sets the http status code |
|
73 | - */ |
|
74 | - public function setHttpResponseCode($code) { |
|
75 | - http_response_code($code); |
|
76 | - } |
|
71 | + /** |
|
72 | + * @param int $code sets the http status code |
|
73 | + */ |
|
74 | + public function setHttpResponseCode($code) { |
|
75 | + http_response_code($code); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @return int returns the current http response code |
|
80 | - */ |
|
81 | - public function getHttpResponseCode() { |
|
82 | - return http_response_code(); |
|
83 | - } |
|
78 | + /** |
|
79 | + * @return int returns the current http response code |
|
80 | + */ |
|
81 | + public function getHttpResponseCode() { |
|
82 | + return http_response_code(); |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * @param string $name |
|
87 | - * @param string $value |
|
88 | - * @param int $expire |
|
89 | - * @param string $path |
|
90 | - * @param string $domain |
|
91 | - * @param bool $secure |
|
92 | - * @param bool $httpOnly |
|
93 | - */ |
|
94 | - public function setCookie($name, $value, $expire, $path, $domain, $secure, $httpOnly) { |
|
95 | - $path = $this->webRoot ? : '/'; |
|
96 | - setcookie($name, $value, $expire, $path, $domain, $secure, $httpOnly); |
|
97 | - } |
|
85 | + /** |
|
86 | + * @param string $name |
|
87 | + * @param string $value |
|
88 | + * @param int $expire |
|
89 | + * @param string $path |
|
90 | + * @param string $domain |
|
91 | + * @param bool $secure |
|
92 | + * @param bool $httpOnly |
|
93 | + */ |
|
94 | + public function setCookie($name, $value, $expire, $path, $domain, $secure, $httpOnly) { |
|
95 | + $path = $this->webRoot ? : '/'; |
|
96 | + setcookie($name, $value, $expire, $path, $domain, $secure, $httpOnly); |
|
97 | + } |
|
98 | 98 | |
99 | 99 | } |
@@ -92,7 +92,7 @@ |
||
92 | 92 | * @param bool $httpOnly |
93 | 93 | */ |
94 | 94 | public function setCookie($name, $value, $expire, $path, $domain, $secure, $httpOnly) { |
95 | - $path = $this->webRoot ? : '/'; |
|
95 | + $path = $this->webRoot ?: '/'; |
|
96 | 96 | setcookie($name, $value, $expire, $path, $domain, $secure, $httpOnly); |
97 | 97 | } |
98 | 98 |
@@ -31,7 +31,7 @@ |
||
31 | 31 | * @package OC\AppFramework\Middleware\Security\Exceptions |
32 | 32 | */ |
33 | 33 | class NotConfirmedException extends SecurityException { |
34 | - public function __construct() { |
|
35 | - parent::__construct('Password confirmation is required', Http::STATUS_FORBIDDEN); |
|
36 | - } |
|
34 | + public function __construct() { |
|
35 | + parent::__construct('Password confirmation is required', Http::STATUS_FORBIDDEN); |
|
36 | + } |
|
37 | 37 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | * @package OC\AppFramework\Middleware\Security\Exceptions |
35 | 35 | */ |
36 | 36 | class CrossSiteRequestForgeryException extends SecurityException { |
37 | - public function __construct() { |
|
38 | - parent::__construct('CSRF check failed', Http::STATUS_PRECONDITION_FAILED); |
|
39 | - } |
|
37 | + public function __construct() { |
|
38 | + parent::__construct('CSRF check failed', Http::STATUS_PRECONDITION_FAILED); |
|
39 | + } |
|
40 | 40 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | * @package OC\AppFramework\Middleware\Security\Exceptions |
35 | 35 | */ |
36 | 36 | class AppNotEnabledException extends SecurityException { |
37 | - public function __construct() { |
|
38 | - parent::__construct('App is not enabled', Http::STATUS_PRECONDITION_FAILED); |
|
39 | - } |
|
37 | + public function __construct() { |
|
38 | + parent::__construct('App is not enabled', Http::STATUS_PRECONDITION_FAILED); |
|
39 | + } |
|
40 | 40 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | * @package OC\AppFramework\Middleware\Security\Exceptions |
35 | 35 | */ |
36 | 36 | class NotLoggedInException extends SecurityException { |
37 | - public function __construct() { |
|
38 | - parent::__construct('Current user is not logged in', Http::STATUS_UNAUTHORIZED); |
|
39 | - } |
|
37 | + public function __construct() { |
|
38 | + parent::__construct('Current user is not logged in', Http::STATUS_UNAUTHORIZED); |
|
39 | + } |
|
40 | 40 | } |
@@ -143,7 +143,7 @@ |
||
143 | 143 | $format = $this->request->getParam('format'); |
144 | 144 | |
145 | 145 | // if none is given try the first Accept header |
146 | - if($format === null) { |
|
146 | + if ($format === null) { |
|
147 | 147 | $headers = $this->request->getHeader('Accept'); |
148 | 148 | $format = $controller->getResponderByHTTPHeader($headers, 'xml'); |
149 | 149 | } |
@@ -40,116 +40,116 @@ |
||
40 | 40 | |
41 | 41 | class OCSMiddleware extends Middleware { |
42 | 42 | |
43 | - /** @var IRequest */ |
|
44 | - private $request; |
|
45 | - |
|
46 | - /** @var int */ |
|
47 | - private $ocsVersion; |
|
48 | - |
|
49 | - /** |
|
50 | - * @param IRequest $request |
|
51 | - */ |
|
52 | - public function __construct(IRequest $request) { |
|
53 | - $this->request = $request; |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * @param Controller $controller |
|
58 | - * @param string $methodName |
|
59 | - */ |
|
60 | - public function beforeController($controller, $methodName) { |
|
61 | - if ($controller instanceof OCSController) { |
|
62 | - if (substr_compare($this->request->getScriptName(), '/ocs/v2.php', -strlen('/ocs/v2.php')) === 0) { |
|
63 | - $this->ocsVersion = 2; |
|
64 | - } else { |
|
65 | - $this->ocsVersion = 1; |
|
66 | - } |
|
67 | - $controller->setOCSVersion($this->ocsVersion); |
|
68 | - } |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @param Controller $controller |
|
73 | - * @param string $methodName |
|
74 | - * @param \Exception $exception |
|
75 | - * @throws \Exception |
|
76 | - * @return BaseResponse |
|
77 | - */ |
|
78 | - public function afterException($controller, $methodName, \Exception $exception) { |
|
79 | - if ($controller instanceof OCSController && $exception instanceof OCSException) { |
|
80 | - $code = $exception->getCode(); |
|
81 | - if ($code === 0) { |
|
82 | - $code = API::RESPOND_UNKNOWN_ERROR; |
|
83 | - } |
|
84 | - |
|
85 | - return $this->buildNewResponse($controller, $code, $exception->getMessage()); |
|
86 | - } |
|
87 | - |
|
88 | - throw $exception; |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * @param Controller $controller |
|
93 | - * @param string $methodName |
|
94 | - * @param Response $response |
|
95 | - * @return \OCP\AppFramework\Http\Response |
|
96 | - */ |
|
97 | - public function afterController($controller, $methodName, Response $response) { |
|
98 | - /* |
|
43 | + /** @var IRequest */ |
|
44 | + private $request; |
|
45 | + |
|
46 | + /** @var int */ |
|
47 | + private $ocsVersion; |
|
48 | + |
|
49 | + /** |
|
50 | + * @param IRequest $request |
|
51 | + */ |
|
52 | + public function __construct(IRequest $request) { |
|
53 | + $this->request = $request; |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * @param Controller $controller |
|
58 | + * @param string $methodName |
|
59 | + */ |
|
60 | + public function beforeController($controller, $methodName) { |
|
61 | + if ($controller instanceof OCSController) { |
|
62 | + if (substr_compare($this->request->getScriptName(), '/ocs/v2.php', -strlen('/ocs/v2.php')) === 0) { |
|
63 | + $this->ocsVersion = 2; |
|
64 | + } else { |
|
65 | + $this->ocsVersion = 1; |
|
66 | + } |
|
67 | + $controller->setOCSVersion($this->ocsVersion); |
|
68 | + } |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * @param Controller $controller |
|
73 | + * @param string $methodName |
|
74 | + * @param \Exception $exception |
|
75 | + * @throws \Exception |
|
76 | + * @return BaseResponse |
|
77 | + */ |
|
78 | + public function afterException($controller, $methodName, \Exception $exception) { |
|
79 | + if ($controller instanceof OCSController && $exception instanceof OCSException) { |
|
80 | + $code = $exception->getCode(); |
|
81 | + if ($code === 0) { |
|
82 | + $code = API::RESPOND_UNKNOWN_ERROR; |
|
83 | + } |
|
84 | + |
|
85 | + return $this->buildNewResponse($controller, $code, $exception->getMessage()); |
|
86 | + } |
|
87 | + |
|
88 | + throw $exception; |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * @param Controller $controller |
|
93 | + * @param string $methodName |
|
94 | + * @param Response $response |
|
95 | + * @return \OCP\AppFramework\Http\Response |
|
96 | + */ |
|
97 | + public function afterController($controller, $methodName, Response $response) { |
|
98 | + /* |
|
99 | 99 | * If a different middleware has detected that a request unauthorized or forbidden |
100 | 100 | * we need to catch the response and convert it to a proper OCS response. |
101 | 101 | */ |
102 | - if ($controller instanceof OCSController && !($response instanceof BaseResponse)) { |
|
103 | - if ($response->getStatus() === Http::STATUS_UNAUTHORIZED || |
|
104 | - $response->getStatus() === Http::STATUS_FORBIDDEN) { |
|
105 | - |
|
106 | - $message = ''; |
|
107 | - if ($response instanceof JSONResponse) { |
|
108 | - /** @var DataResponse $response */ |
|
109 | - $message = $response->getData()['message']; |
|
110 | - } |
|
111 | - |
|
112 | - return $this->buildNewResponse($controller, API::RESPOND_UNAUTHORISED, $message); |
|
113 | - } |
|
114 | - } |
|
115 | - |
|
116 | - return $response; |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * @param Controller $controller |
|
121 | - * @param int $code |
|
122 | - * @param string $message |
|
123 | - * @return V1Response|V2Response |
|
124 | - */ |
|
125 | - private function buildNewResponse(Controller $controller, $code, $message) { |
|
126 | - $format = $this->getFormat($controller); |
|
127 | - |
|
128 | - $data = new DataResponse(); |
|
129 | - $data->setStatus($code); |
|
130 | - if ($this->ocsVersion === 1) { |
|
131 | - $response = new V1Response($data, $format, $message); |
|
132 | - } else { |
|
133 | - $response = new V2Response($data, $format, $message); |
|
134 | - } |
|
135 | - |
|
136 | - return $response; |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * @param Controller $controller |
|
141 | - * @return string |
|
142 | - */ |
|
143 | - private function getFormat(Controller $controller) { |
|
144 | - // get format from the url format or request format parameter |
|
145 | - $format = $this->request->getParam('format'); |
|
146 | - |
|
147 | - // if none is given try the first Accept header |
|
148 | - if($format === null) { |
|
149 | - $headers = $this->request->getHeader('Accept'); |
|
150 | - $format = $controller->getResponderByHTTPHeader($headers, 'xml'); |
|
151 | - } |
|
152 | - |
|
153 | - return $format; |
|
154 | - } |
|
102 | + if ($controller instanceof OCSController && !($response instanceof BaseResponse)) { |
|
103 | + if ($response->getStatus() === Http::STATUS_UNAUTHORIZED || |
|
104 | + $response->getStatus() === Http::STATUS_FORBIDDEN) { |
|
105 | + |
|
106 | + $message = ''; |
|
107 | + if ($response instanceof JSONResponse) { |
|
108 | + /** @var DataResponse $response */ |
|
109 | + $message = $response->getData()['message']; |
|
110 | + } |
|
111 | + |
|
112 | + return $this->buildNewResponse($controller, API::RESPOND_UNAUTHORISED, $message); |
|
113 | + } |
|
114 | + } |
|
115 | + |
|
116 | + return $response; |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * @param Controller $controller |
|
121 | + * @param int $code |
|
122 | + * @param string $message |
|
123 | + * @return V1Response|V2Response |
|
124 | + */ |
|
125 | + private function buildNewResponse(Controller $controller, $code, $message) { |
|
126 | + $format = $this->getFormat($controller); |
|
127 | + |
|
128 | + $data = new DataResponse(); |
|
129 | + $data->setStatus($code); |
|
130 | + if ($this->ocsVersion === 1) { |
|
131 | + $response = new V1Response($data, $format, $message); |
|
132 | + } else { |
|
133 | + $response = new V2Response($data, $format, $message); |
|
134 | + } |
|
135 | + |
|
136 | + return $response; |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * @param Controller $controller |
|
141 | + * @return string |
|
142 | + */ |
|
143 | + private function getFormat(Controller $controller) { |
|
144 | + // get format from the url format or request format parameter |
|
145 | + $format = $this->request->getParam('format'); |
|
146 | + |
|
147 | + // if none is given try the first Accept header |
|
148 | + if($format === null) { |
|
149 | + $headers = $this->request->getHeader('Accept'); |
|
150 | + $format = $controller->getResponderByHTTPHeader($headers, 'xml'); |
|
151 | + } |
|
152 | + |
|
153 | + return $format; |
|
154 | + } |
|
155 | 155 | } |
@@ -27,50 +27,50 @@ |
||
27 | 27 | |
28 | 28 | class V2Response extends BaseResponse { |
29 | 29 | |
30 | - /** |
|
31 | - * The V2 endpoint just passes on status codes. |
|
32 | - * Of course we have to map the OCS specific codes to proper HTTP status codes |
|
33 | - * |
|
34 | - * @return int |
|
35 | - */ |
|
36 | - public function getStatus() { |
|
30 | + /** |
|
31 | + * The V2 endpoint just passes on status codes. |
|
32 | + * Of course we have to map the OCS specific codes to proper HTTP status codes |
|
33 | + * |
|
34 | + * @return int |
|
35 | + */ |
|
36 | + public function getStatus() { |
|
37 | 37 | |
38 | - $status = parent::getStatus(); |
|
39 | - if ($status === API::RESPOND_UNAUTHORISED) { |
|
40 | - return Http::STATUS_UNAUTHORIZED; |
|
41 | - } else if ($status === API::RESPOND_NOT_FOUND) { |
|
42 | - return Http::STATUS_NOT_FOUND; |
|
43 | - } else if ($status === API::RESPOND_SERVER_ERROR || $status === API::RESPOND_UNKNOWN_ERROR) { |
|
44 | - return Http::STATUS_INTERNAL_SERVER_ERROR; |
|
45 | - } else if ($status < 200 || $status > 600) { |
|
46 | - return Http::STATUS_BAD_REQUEST; |
|
47 | - } |
|
38 | + $status = parent::getStatus(); |
|
39 | + if ($status === API::RESPOND_UNAUTHORISED) { |
|
40 | + return Http::STATUS_UNAUTHORIZED; |
|
41 | + } else if ($status === API::RESPOND_NOT_FOUND) { |
|
42 | + return Http::STATUS_NOT_FOUND; |
|
43 | + } else if ($status === API::RESPOND_SERVER_ERROR || $status === API::RESPOND_UNKNOWN_ERROR) { |
|
44 | + return Http::STATUS_INTERNAL_SERVER_ERROR; |
|
45 | + } else if ($status < 200 || $status > 600) { |
|
46 | + return Http::STATUS_BAD_REQUEST; |
|
47 | + } |
|
48 | 48 | |
49 | - return $status; |
|
50 | - } |
|
49 | + return $status; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Construct the meta part of the response |
|
54 | - * And then late the base class render |
|
55 | - * |
|
56 | - * @return string |
|
57 | - */ |
|
58 | - public function render() { |
|
59 | - $status = parent::getStatus(); |
|
52 | + /** |
|
53 | + * Construct the meta part of the response |
|
54 | + * And then late the base class render |
|
55 | + * |
|
56 | + * @return string |
|
57 | + */ |
|
58 | + public function render() { |
|
59 | + $status = parent::getStatus(); |
|
60 | 60 | |
61 | - $meta = [ |
|
62 | - 'status' => $status >= 200 && $status < 300 ? 'ok' : 'failure', |
|
63 | - 'statuscode' => $this->getOCSStatus(), |
|
64 | - 'message' => $status >= 200 && $status < 300 ? 'OK' : $this->statusMessage, |
|
65 | - ]; |
|
61 | + $meta = [ |
|
62 | + 'status' => $status >= 200 && $status < 300 ? 'ok' : 'failure', |
|
63 | + 'statuscode' => $this->getOCSStatus(), |
|
64 | + 'message' => $status >= 200 && $status < 300 ? 'OK' : $this->statusMessage, |
|
65 | + ]; |
|
66 | 66 | |
67 | - if ($this->itemsCount !== null) { |
|
68 | - $meta['totalitems'] = $this->itemsCount; |
|
69 | - } |
|
70 | - if ($this->itemsPerPage !== null) { |
|
71 | - $meta['itemsperpage'] = $this->itemsPerPage; |
|
72 | - } |
|
67 | + if ($this->itemsCount !== null) { |
|
68 | + $meta['totalitems'] = $this->itemsCount; |
|
69 | + } |
|
70 | + if ($this->itemsPerPage !== null) { |
|
71 | + $meta['itemsperpage'] = $this->itemsPerPage; |
|
72 | + } |
|
73 | 73 | |
74 | - return $this->renderResult($meta); |
|
75 | - } |
|
74 | + return $this->renderResult($meta); |
|
75 | + } |
|
76 | 76 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | */ |
36 | 36 | public function getStatus() { |
37 | 37 | |
38 | - $status = parent::getStatus(); |
|
38 | + $status = parent::getStatus(); |
|
39 | 39 | if ($status === API::RESPOND_UNAUTHORISED) { |
40 | 40 | return Http::STATUS_UNAUTHORIZED; |
41 | 41 | } else if ($status === API::RESPOND_NOT_FOUND) { |
@@ -27,52 +27,52 @@ |
||
27 | 27 | |
28 | 28 | class V1Response extends BaseResponse { |
29 | 29 | |
30 | - /** |
|
31 | - * The V1 endpoint has very limited http status codes basically everything |
|
32 | - * is status 200 except 401 |
|
33 | - * |
|
34 | - * @return int |
|
35 | - */ |
|
36 | - public function getStatus() { |
|
37 | - $status = parent::getStatus(); |
|
38 | - if ($status === Http::STATUS_FORBIDDEN || $status === API::RESPOND_UNAUTHORISED) { |
|
39 | - return Http::STATUS_UNAUTHORIZED; |
|
40 | - } |
|
30 | + /** |
|
31 | + * The V1 endpoint has very limited http status codes basically everything |
|
32 | + * is status 200 except 401 |
|
33 | + * |
|
34 | + * @return int |
|
35 | + */ |
|
36 | + public function getStatus() { |
|
37 | + $status = parent::getStatus(); |
|
38 | + if ($status === Http::STATUS_FORBIDDEN || $status === API::RESPOND_UNAUTHORISED) { |
|
39 | + return Http::STATUS_UNAUTHORIZED; |
|
40 | + } |
|
41 | 41 | |
42 | - return Http::STATUS_OK; |
|
43 | - } |
|
42 | + return Http::STATUS_OK; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * In v1 all OK is 100 |
|
47 | - * |
|
48 | - * @return int |
|
49 | - */ |
|
50 | - public function getOCSStatus() { |
|
51 | - $status = parent::getOCSStatus(); |
|
45 | + /** |
|
46 | + * In v1 all OK is 100 |
|
47 | + * |
|
48 | + * @return int |
|
49 | + */ |
|
50 | + public function getOCSStatus() { |
|
51 | + $status = parent::getOCSStatus(); |
|
52 | 52 | |
53 | - if ($status === Http::STATUS_OK) { |
|
54 | - return 100; |
|
55 | - } |
|
53 | + if ($status === Http::STATUS_OK) { |
|
54 | + return 100; |
|
55 | + } |
|
56 | 56 | |
57 | - return $status; |
|
58 | - } |
|
57 | + return $status; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Construct the meta part of the response |
|
62 | - * And then late the base class render |
|
63 | - * |
|
64 | - * @return string |
|
65 | - */ |
|
66 | - public function render() { |
|
67 | - $meta = [ |
|
68 | - 'status' => $this->getOCSStatus() === 100 ? 'ok' : 'failure', |
|
69 | - 'statuscode' => $this->getOCSStatus(), |
|
70 | - 'message' => $this->getOCSStatus() === 100 ? 'OK' : $this->statusMessage, |
|
71 | - ]; |
|
60 | + /** |
|
61 | + * Construct the meta part of the response |
|
62 | + * And then late the base class render |
|
63 | + * |
|
64 | + * @return string |
|
65 | + */ |
|
66 | + public function render() { |
|
67 | + $meta = [ |
|
68 | + 'status' => $this->getOCSStatus() === 100 ? 'ok' : 'failure', |
|
69 | + 'statuscode' => $this->getOCSStatus(), |
|
70 | + 'message' => $this->getOCSStatus() === 100 ? 'OK' : $this->statusMessage, |
|
71 | + ]; |
|
72 | 72 | |
73 | - $meta['totalitems'] = $this->itemsCount !== null ? (string)$this->itemsCount : ''; |
|
74 | - $meta['itemsperpage'] = $this->itemsPerPage !== null ? (string)$this->itemsPerPage: ''; |
|
73 | + $meta['totalitems'] = $this->itemsCount !== null ? (string)$this->itemsCount : ''; |
|
74 | + $meta['itemsperpage'] = $this->itemsPerPage !== null ? (string)$this->itemsPerPage: ''; |
|
75 | 75 | |
76 | - return $this->renderResult($meta); |
|
77 | - } |
|
76 | + return $this->renderResult($meta); |
|
77 | + } |
|
78 | 78 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @return int |
35 | 35 | */ |
36 | 36 | public function getStatus() { |
37 | - $status = parent::getStatus(); |
|
37 | + $status = parent::getStatus(); |
|
38 | 38 | if ($status === Http::STATUS_FORBIDDEN || $status === API::RESPOND_UNAUTHORISED) { |
39 | 39 | return Http::STATUS_UNAUTHORIZED; |
40 | 40 | } |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | 'message' => $this->getOCSStatus() === 100 ? 'OK' : $this->statusMessage, |
71 | 71 | ]; |
72 | 72 | |
73 | - $meta['totalitems'] = $this->itemsCount !== null ? (string)$this->itemsCount : ''; |
|
74 | - $meta['itemsperpage'] = $this->itemsPerPage !== null ? (string)$this->itemsPerPage: ''; |
|
73 | + $meta['totalitems'] = $this->itemsCount !== null ? (string) $this->itemsCount : ''; |
|
74 | + $meta['itemsperpage'] = $this->itemsPerPage !== null ? (string) $this->itemsPerPage : ''; |
|
75 | 75 | |
76 | 76 | return $this->renderResult($meta); |
77 | 77 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | |
36 | 36 | const FORMAT_NONE = -1; |
37 | 37 | const FORMAT_STATUSES = -2; |
38 | - const FORMAT_SOURCES = -3; // ToDo Check if it is still in use otherwise remove it |
|
38 | + const FORMAT_SOURCES = -3; // ToDo Check if it is still in use otherwise remove it |
|
39 | 39 | |
40 | 40 | const RESPONSE_FORMAT = 'json'; // default resonse format for ocs calls |
41 | 41 |
@@ -33,57 +33,57 @@ |
||
33 | 33 | |
34 | 34 | class Constants { |
35 | 35 | |
36 | - /** |
|
37 | - * @deprecated 17.0.0 - use IShare::TYPE_USER instead |
|
38 | - */ |
|
39 | - const SHARE_TYPE_USER = 0; |
|
40 | - /** |
|
41 | - * @deprecated 17.0.0 - use IShare::TYPE_GROUP instead |
|
42 | - */ |
|
43 | - const SHARE_TYPE_GROUP = 1; |
|
44 | - // const SHARE_TYPE_USERGROUP = 2; // Internal type used by DefaultShareProvider |
|
45 | - /** |
|
46 | - * @deprecated 17.0.0 - use IShare::TYPE_LINK instead |
|
47 | - */ |
|
48 | - const SHARE_TYPE_LINK = 3; |
|
49 | - /** |
|
50 | - * @deprecated 17.0.0 - use IShare::TYPE_EMAIL instead |
|
51 | - */ |
|
52 | - const SHARE_TYPE_EMAIL = 4; |
|
53 | - const SHARE_TYPE_CONTACT = 5; // ToDo Check if it is still in use otherwise remove it |
|
54 | - /** |
|
55 | - * @deprecated 17.0.0 - use IShare::TYPE_REMOTE instead |
|
56 | - */ |
|
57 | - const SHARE_TYPE_REMOTE = 6; |
|
58 | - /** |
|
59 | - * @deprecated 17.0.0 - use IShare::TYPE_CIRCLE instead |
|
60 | - */ |
|
61 | - const SHARE_TYPE_CIRCLE = 7; |
|
62 | - /** |
|
63 | - * @deprecated 17.0.0 - use IShare::TYPE_GUEST instead |
|
64 | - */ |
|
65 | - const SHARE_TYPE_GUEST = 8; |
|
66 | - /** |
|
67 | - * @deprecated 17.0.0 - use IShare::REMOTE_GROUP instead |
|
68 | - */ |
|
69 | - const SHARE_TYPE_REMOTE_GROUP = 9; |
|
70 | - /** |
|
71 | - * @deprecated 17.0.0 - use IShare::TYPE_ROOM instead |
|
72 | - */ |
|
73 | - const SHARE_TYPE_ROOM = 10; |
|
74 | - // const SHARE_TYPE_USERROOM = 11; // Internal type used by RoomShareProvider |
|
36 | + /** |
|
37 | + * @deprecated 17.0.0 - use IShare::TYPE_USER instead |
|
38 | + */ |
|
39 | + const SHARE_TYPE_USER = 0; |
|
40 | + /** |
|
41 | + * @deprecated 17.0.0 - use IShare::TYPE_GROUP instead |
|
42 | + */ |
|
43 | + const SHARE_TYPE_GROUP = 1; |
|
44 | + // const SHARE_TYPE_USERGROUP = 2; // Internal type used by DefaultShareProvider |
|
45 | + /** |
|
46 | + * @deprecated 17.0.0 - use IShare::TYPE_LINK instead |
|
47 | + */ |
|
48 | + const SHARE_TYPE_LINK = 3; |
|
49 | + /** |
|
50 | + * @deprecated 17.0.0 - use IShare::TYPE_EMAIL instead |
|
51 | + */ |
|
52 | + const SHARE_TYPE_EMAIL = 4; |
|
53 | + const SHARE_TYPE_CONTACT = 5; // ToDo Check if it is still in use otherwise remove it |
|
54 | + /** |
|
55 | + * @deprecated 17.0.0 - use IShare::TYPE_REMOTE instead |
|
56 | + */ |
|
57 | + const SHARE_TYPE_REMOTE = 6; |
|
58 | + /** |
|
59 | + * @deprecated 17.0.0 - use IShare::TYPE_CIRCLE instead |
|
60 | + */ |
|
61 | + const SHARE_TYPE_CIRCLE = 7; |
|
62 | + /** |
|
63 | + * @deprecated 17.0.0 - use IShare::TYPE_GUEST instead |
|
64 | + */ |
|
65 | + const SHARE_TYPE_GUEST = 8; |
|
66 | + /** |
|
67 | + * @deprecated 17.0.0 - use IShare::REMOTE_GROUP instead |
|
68 | + */ |
|
69 | + const SHARE_TYPE_REMOTE_GROUP = 9; |
|
70 | + /** |
|
71 | + * @deprecated 17.0.0 - use IShare::TYPE_ROOM instead |
|
72 | + */ |
|
73 | + const SHARE_TYPE_ROOM = 10; |
|
74 | + // const SHARE_TYPE_USERROOM = 11; // Internal type used by RoomShareProvider |
|
75 | 75 | |
76 | - const FORMAT_NONE = -1; |
|
77 | - const FORMAT_STATUSES = -2; |
|
78 | - const FORMAT_SOURCES = -3; // ToDo Check if it is still in use otherwise remove it |
|
76 | + const FORMAT_NONE = -1; |
|
77 | + const FORMAT_STATUSES = -2; |
|
78 | + const FORMAT_SOURCES = -3; // ToDo Check if it is still in use otherwise remove it |
|
79 | 79 | |
80 | - const RESPONSE_FORMAT = 'json'; // default resonse format for ocs calls |
|
80 | + const RESPONSE_FORMAT = 'json'; // default resonse format for ocs calls |
|
81 | 81 | |
82 | - const TOKEN_LENGTH = 15; // old (oc7) length is 32, keep token length in db at least that for compatibility |
|
82 | + const TOKEN_LENGTH = 15; // old (oc7) length is 32, keep token length in db at least that for compatibility |
|
83 | 83 | |
84 | - protected static $shareTypeUserAndGroups = -1; |
|
85 | - protected static $shareTypeGroupUserUnique = 2; |
|
86 | - protected static $backends = []; |
|
87 | - protected static $backendTypes = []; |
|
88 | - protected static $isResharingAllowed; |
|
84 | + protected static $shareTypeUserAndGroups = -1; |
|
85 | + protected static $shareTypeGroupUserUnique = 2; |
|
86 | + protected static $backends = []; |
|
87 | + protected static $backendTypes = []; |
|
88 | + protected static $isResharingAllowed; |
|
89 | 89 | } |