Passed
Push — master ( acbe08...812f16 )
by Roeland
13:17 queued 12s
created
AppFramework/Middleware/Security/Exceptions/NotLoggedInException.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/private/AppFramework/Middleware/OCSMiddleware.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.
Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -39,116 +39,116 @@
 block discarded – undo
39 39
 
40 40
 class OCSMiddleware extends Middleware {
41 41
 
42
-	/** @var IRequest */
43
-	private $request;
44
-
45
-	/** @var int */
46
-	private $ocsVersion;
47
-
48
-	/**
49
-	 * @param IRequest $request
50
-	 */
51
-	public function __construct(IRequest $request) {
52
-		$this->request = $request;
53
-	}
54
-
55
-	/**
56
-	 * @param Controller $controller
57
-	 * @param string $methodName
58
-	 */
59
-	public function beforeController($controller, $methodName) {
60
-		if ($controller instanceof OCSController) {
61
-			if (substr_compare($this->request->getScriptName(), '/ocs/v2.php', -strlen('/ocs/v2.php')) === 0) {
62
-				$this->ocsVersion = 2;
63
-			} else {
64
-				$this->ocsVersion = 1;
65
-			}
66
-			$controller->setOCSVersion($this->ocsVersion);
67
-		}
68
-	}
69
-
70
-	/**
71
-	 * @param Controller $controller
72
-	 * @param string $methodName
73
-	 * @param \Exception $exception
74
-	 * @throws \Exception
75
-	 * @return BaseResponse
76
-	 */
77
-	public function afterException($controller, $methodName, \Exception $exception) {
78
-		if ($controller instanceof OCSController && $exception instanceof OCSException) {
79
-			$code = $exception->getCode();
80
-			if ($code === 0) {
81
-				$code = API::RESPOND_UNKNOWN_ERROR;
82
-			}
83
-
84
-			return $this->buildNewResponse($controller, $code, $exception->getMessage());
85
-		}
86
-
87
-		throw $exception;
88
-	}
89
-
90
-	/**
91
-	 * @param Controller $controller
92
-	 * @param string $methodName
93
-	 * @param Response $response
94
-	 * @return \OCP\AppFramework\Http\Response
95
-	 */
96
-	public function afterController($controller, $methodName, Response $response) {
97
-		/*
42
+    /** @var IRequest */
43
+    private $request;
44
+
45
+    /** @var int */
46
+    private $ocsVersion;
47
+
48
+    /**
49
+     * @param IRequest $request
50
+     */
51
+    public function __construct(IRequest $request) {
52
+        $this->request = $request;
53
+    }
54
+
55
+    /**
56
+     * @param Controller $controller
57
+     * @param string $methodName
58
+     */
59
+    public function beforeController($controller, $methodName) {
60
+        if ($controller instanceof OCSController) {
61
+            if (substr_compare($this->request->getScriptName(), '/ocs/v2.php', -strlen('/ocs/v2.php')) === 0) {
62
+                $this->ocsVersion = 2;
63
+            } else {
64
+                $this->ocsVersion = 1;
65
+            }
66
+            $controller->setOCSVersion($this->ocsVersion);
67
+        }
68
+    }
69
+
70
+    /**
71
+     * @param Controller $controller
72
+     * @param string $methodName
73
+     * @param \Exception $exception
74
+     * @throws \Exception
75
+     * @return BaseResponse
76
+     */
77
+    public function afterException($controller, $methodName, \Exception $exception) {
78
+        if ($controller instanceof OCSController && $exception instanceof OCSException) {
79
+            $code = $exception->getCode();
80
+            if ($code === 0) {
81
+                $code = API::RESPOND_UNKNOWN_ERROR;
82
+            }
83
+
84
+            return $this->buildNewResponse($controller, $code, $exception->getMessage());
85
+        }
86
+
87
+        throw $exception;
88
+    }
89
+
90
+    /**
91
+     * @param Controller $controller
92
+     * @param string $methodName
93
+     * @param Response $response
94
+     * @return \OCP\AppFramework\Http\Response
95
+     */
96
+    public function afterController($controller, $methodName, Response $response) {
97
+        /*
98 98
 		 * If a different middleware has detected that a request unauthorized or forbidden
99 99
 		 * we need to catch the response and convert it to a proper OCS response.
100 100
 		 */
101
-		if ($controller instanceof OCSController && !($response instanceof BaseResponse)) {
102
-			if ($response->getStatus() === Http::STATUS_UNAUTHORIZED ||
103
-			    $response->getStatus() === Http::STATUS_FORBIDDEN) {
104
-
105
-				$message = '';
106
-				if ($response instanceof JSONResponse) {
107
-					/** @var DataResponse $response */
108
-					$message = $response->getData()['message'];
109
-				}
110
-
111
-				return $this->buildNewResponse($controller, API::RESPOND_UNAUTHORISED, $message);
112
-			}
113
-		}
114
-
115
-		return $response;
116
-	}
117
-
118
-	/**
119
-	 * @param Controller $controller
120
-	 * @param int $code
121
-	 * @param string $message
122
-	 * @return V1Response|V2Response
123
-	 */
124
-	private function buildNewResponse(Controller $controller, $code, $message) {
125
-		$format = $this->getFormat($controller);
126
-
127
-		$data = new DataResponse();
128
-		$data->setStatus($code);
129
-		if ($this->ocsVersion === 1) {
130
-			$response = new V1Response($data, $format, $message);
131
-		} else {
132
-			$response = new V2Response($data, $format, $message);
133
-		}
134
-
135
-		return $response;
136
-	}
137
-
138
-	/**
139
-	 * @param Controller $controller
140
-	 * @return string
141
-	 */
142
-	private function getFormat(Controller $controller) {
143
-		// get format from the url format or request format parameter
144
-		$format = $this->request->getParam('format');
145
-
146
-		// if none is given try the first Accept header
147
-		if($format === null) {
148
-			$headers = $this->request->getHeader('Accept');
149
-			$format = $controller->getResponderByHTTPHeader($headers, 'xml');
150
-		}
151
-
152
-		return $format;
153
-	}
101
+        if ($controller instanceof OCSController && !($response instanceof BaseResponse)) {
102
+            if ($response->getStatus() === Http::STATUS_UNAUTHORIZED ||
103
+                $response->getStatus() === Http::STATUS_FORBIDDEN) {
104
+
105
+                $message = '';
106
+                if ($response instanceof JSONResponse) {
107
+                    /** @var DataResponse $response */
108
+                    $message = $response->getData()['message'];
109
+                }
110
+
111
+                return $this->buildNewResponse($controller, API::RESPOND_UNAUTHORISED, $message);
112
+            }
113
+        }
114
+
115
+        return $response;
116
+    }
117
+
118
+    /**
119
+     * @param Controller $controller
120
+     * @param int $code
121
+     * @param string $message
122
+     * @return V1Response|V2Response
123
+     */
124
+    private function buildNewResponse(Controller $controller, $code, $message) {
125
+        $format = $this->getFormat($controller);
126
+
127
+        $data = new DataResponse();
128
+        $data->setStatus($code);
129
+        if ($this->ocsVersion === 1) {
130
+            $response = new V1Response($data, $format, $message);
131
+        } else {
132
+            $response = new V2Response($data, $format, $message);
133
+        }
134
+
135
+        return $response;
136
+    }
137
+
138
+    /**
139
+     * @param Controller $controller
140
+     * @return string
141
+     */
142
+    private function getFormat(Controller $controller) {
143
+        // get format from the url format or request format parameter
144
+        $format = $this->request->getParam('format');
145
+
146
+        // if none is given try the first Accept header
147
+        if($format === null) {
148
+            $headers = $this->request->getHeader('Accept');
149
+            $format = $controller->getResponderByHTTPHeader($headers, 'xml');
150
+        }
151
+
152
+        return $format;
153
+    }
154 154
 }
Please login to merge, or discard this patch.
lib/private/AppFramework/Middleware/SessionMiddleware.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@
 block discarded – undo
71 71
 	 * @param Response $response
72 72
 	 * @return Response
73 73
 	 */
74
-	public function afterController($controller, $methodName, Response $response){
74
+	public function afterController($controller, $methodName, Response $response) {
75 75
 		$useSession = $this->reflector->hasAnnotation('UseSession');
76 76
 		if ($useSession) {
77 77
 			$this->session->close();
Please login to merge, or discard this patch.
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -34,41 +34,41 @@
 block discarded – undo
34 34
 
35 35
 class SessionMiddleware extends Middleware {
36 36
 
37
-	/** @var ControllerMethodReflector */
38
-	private $reflector;
37
+    /** @var ControllerMethodReflector */
38
+    private $reflector;
39 39
 
40
-	/** @var ISession */
41
-	private $session;
40
+    /** @var ISession */
41
+    private $session;
42 42
 
43
-	public function __construct(ControllerMethodReflector $reflector,
44
-								ISession $session) {
45
-		$this->reflector = $reflector;
46
-		$this->session = $session;
47
-	}
43
+    public function __construct(ControllerMethodReflector $reflector,
44
+                                ISession $session) {
45
+        $this->reflector = $reflector;
46
+        $this->session = $session;
47
+    }
48 48
 
49
-	/**
50
-	 * @param Controller $controller
51
-	 * @param string $methodName
52
-	 */
53
-	public function beforeController($controller, $methodName) {
54
-		$useSession = $this->reflector->hasAnnotation('UseSession');
55
-		if (!$useSession) {
56
-			$this->session->close();
57
-		}
58
-	}
49
+    /**
50
+     * @param Controller $controller
51
+     * @param string $methodName
52
+     */
53
+    public function beforeController($controller, $methodName) {
54
+        $useSession = $this->reflector->hasAnnotation('UseSession');
55
+        if (!$useSession) {
56
+            $this->session->close();
57
+        }
58
+    }
59 59
 
60
-	/**
61
-	 * @param Controller $controller
62
-	 * @param string $methodName
63
-	 * @param Response $response
64
-	 * @return Response
65
-	 */
66
-	public function afterController($controller, $methodName, Response $response){
67
-		$useSession = $this->reflector->hasAnnotation('UseSession');
68
-		if ($useSession) {
69
-			$this->session->close();
70
-		}
71
-		return $response;
72
-	}
60
+    /**
61
+     * @param Controller $controller
62
+     * @param string $methodName
63
+     * @param Response $response
64
+     * @return Response
65
+     */
66
+    public function afterController($controller, $methodName, Response $response){
67
+        $useSession = $this->reflector->hasAnnotation('UseSession');
68
+        if ($useSession) {
69
+            $this->session->close();
70
+        }
71
+        return $response;
72
+    }
73 73
 
74 74
 }
Please login to merge, or discard this patch.
lib/private/AppFramework/OCS/BaseResponse.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
 use OCP\AppFramework\Http\EmptyContentSecurityPolicy;
27 27
 use OCP\AppFramework\Http\Response;
28 28
 
29
-abstract class BaseResponse extends Response   {
29
+abstract class BaseResponse extends Response {
30 30
 	/** @var array */
31 31
 	protected $data;
32 32
 
Please login to merge, or discard this patch.
Indentation   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -30,122 +30,122 @@
 block discarded – undo
30 30
 use OCP\AppFramework\Http\Response;
31 31
 
32 32
 abstract class BaseResponse extends Response   {
33
-	/** @var array */
34
-	protected $data;
35
-
36
-	/** @var string */
37
-	protected $format;
38
-
39
-	/** @var string */
40
-	protected $statusMessage;
41
-
42
-	/** @var int */
43
-	protected $itemsCount;
44
-
45
-	/** @var int */
46
-	protected $itemsPerPage;
47
-
48
-	/**
49
-	 * BaseResponse constructor.
50
-	 *
51
-	 * @param DataResponse $dataResponse
52
-	 * @param string $format
53
-	 * @param string|null $statusMessage
54
-	 * @param int|null $itemsCount
55
-	 * @param int|null $itemsPerPage
56
-	 */
57
-	public function __construct(DataResponse $dataResponse,
58
-								$format = 'xml',
59
-								$statusMessage = null,
60
-								$itemsCount = null,
61
-								$itemsPerPage = null) {
62
-		parent::__construct();
63
-
64
-		$this->format = $format;
65
-		$this->statusMessage = $statusMessage;
66
-		$this->itemsCount = $itemsCount;
67
-		$this->itemsPerPage = $itemsPerPage;
68
-
69
-		$this->data = $dataResponse->getData();
70
-
71
-		$this->setHeaders($dataResponse->getHeaders());
72
-		$this->setStatus($dataResponse->getStatus());
73
-		$this->setETag($dataResponse->getETag());
74
-		$this->setLastModified($dataResponse->getLastModified());
75
-		$this->setCookies($dataResponse->getCookies());
76
-
77
-		if ($format === 'json') {
78
-			$this->addHeader(
79
-				'Content-Type', 'application/json; charset=utf-8'
80
-			);
81
-		} else {
82
-			$this->addHeader(
83
-				'Content-Type', 'application/xml; charset=utf-8'
84
-			);
85
-		}
86
-	}
87
-
88
-	/**
89
-	 * @param string[] $meta
90
-	 * @return string
91
-	 */
92
-	protected function renderResult(array $meta): string {
93
-		$status = $this->getStatus();
94
-		if ($status === Http::STATUS_NO_CONTENT ||
95
-			$status === Http::STATUS_NOT_MODIFIED ||
96
-			($status >= 100 && $status <= 199)) {
97
-			// Those status codes are not supposed to have a body:
98
-			// https://stackoverflow.com/q/8628725
99
-			return '';
100
-		}
101
-
102
-		$response = [
103
-			'ocs' => [
104
-				'meta' => $meta,
105
-				'data' => $this->data,
106
-			],
107
-		];
108
-
109
-		if ($this->format === 'json') {
110
-			return json_encode($response, JSON_HEX_TAG);
111
-		}
112
-
113
-		$writer = new \XMLWriter();
114
-		$writer->openMemory();
115
-		$writer->setIndent(true);
116
-		$writer->startDocument();
117
-		$this->toXML($response, $writer);
118
-		$writer->endDocument();
119
-		return $writer->outputMemory(true);
120
-
121
-	}
122
-
123
-	/**
124
-	 * @param array $array
125
-	 * @param \XMLWriter $writer
126
-	 */
127
-	protected function toXML(array $array, \XMLWriter $writer) {
128
-		foreach ($array as $k => $v) {
129
-			if (\is_string($k) && strpos($k, '@') === 0) {
130
-				$writer->writeAttribute(substr($k, 1), $v);
131
-				continue;
132
-			}
133
-
134
-			if (\is_numeric($k)) {
135
-				$k = 'element';
136
-			}
137
-
138
-			if (\is_array($v)) {
139
-				$writer->startElement($k);
140
-				$this->toXML($v, $writer);
141
-				$writer->endElement();
142
-			} else {
143
-				$writer->writeElement($k, $v);
144
-			}
145
-		}
146
-	}
147
-
148
-	public function getOCSStatus() {
149
-		return parent::getStatus();
150
-	}
33
+    /** @var array */
34
+    protected $data;
35
+
36
+    /** @var string */
37
+    protected $format;
38
+
39
+    /** @var string */
40
+    protected $statusMessage;
41
+
42
+    /** @var int */
43
+    protected $itemsCount;
44
+
45
+    /** @var int */
46
+    protected $itemsPerPage;
47
+
48
+    /**
49
+     * BaseResponse constructor.
50
+     *
51
+     * @param DataResponse $dataResponse
52
+     * @param string $format
53
+     * @param string|null $statusMessage
54
+     * @param int|null $itemsCount
55
+     * @param int|null $itemsPerPage
56
+     */
57
+    public function __construct(DataResponse $dataResponse,
58
+                                $format = 'xml',
59
+                                $statusMessage = null,
60
+                                $itemsCount = null,
61
+                                $itemsPerPage = null) {
62
+        parent::__construct();
63
+
64
+        $this->format = $format;
65
+        $this->statusMessage = $statusMessage;
66
+        $this->itemsCount = $itemsCount;
67
+        $this->itemsPerPage = $itemsPerPage;
68
+
69
+        $this->data = $dataResponse->getData();
70
+
71
+        $this->setHeaders($dataResponse->getHeaders());
72
+        $this->setStatus($dataResponse->getStatus());
73
+        $this->setETag($dataResponse->getETag());
74
+        $this->setLastModified($dataResponse->getLastModified());
75
+        $this->setCookies($dataResponse->getCookies());
76
+
77
+        if ($format === 'json') {
78
+            $this->addHeader(
79
+                'Content-Type', 'application/json; charset=utf-8'
80
+            );
81
+        } else {
82
+            $this->addHeader(
83
+                'Content-Type', 'application/xml; charset=utf-8'
84
+            );
85
+        }
86
+    }
87
+
88
+    /**
89
+     * @param string[] $meta
90
+     * @return string
91
+     */
92
+    protected function renderResult(array $meta): string {
93
+        $status = $this->getStatus();
94
+        if ($status === Http::STATUS_NO_CONTENT ||
95
+            $status === Http::STATUS_NOT_MODIFIED ||
96
+            ($status >= 100 && $status <= 199)) {
97
+            // Those status codes are not supposed to have a body:
98
+            // https://stackoverflow.com/q/8628725
99
+            return '';
100
+        }
101
+
102
+        $response = [
103
+            'ocs' => [
104
+                'meta' => $meta,
105
+                'data' => $this->data,
106
+            ],
107
+        ];
108
+
109
+        if ($this->format === 'json') {
110
+            return json_encode($response, JSON_HEX_TAG);
111
+        }
112
+
113
+        $writer = new \XMLWriter();
114
+        $writer->openMemory();
115
+        $writer->setIndent(true);
116
+        $writer->startDocument();
117
+        $this->toXML($response, $writer);
118
+        $writer->endDocument();
119
+        return $writer->outputMemory(true);
120
+
121
+    }
122
+
123
+    /**
124
+     * @param array $array
125
+     * @param \XMLWriter $writer
126
+     */
127
+    protected function toXML(array $array, \XMLWriter $writer) {
128
+        foreach ($array as $k => $v) {
129
+            if (\is_string($k) && strpos($k, '@') === 0) {
130
+                $writer->writeAttribute(substr($k, 1), $v);
131
+                continue;
132
+            }
133
+
134
+            if (\is_numeric($k)) {
135
+                $k = 'element';
136
+            }
137
+
138
+            if (\is_array($v)) {
139
+                $writer->startElement($k);
140
+                $this->toXML($v, $writer);
141
+                $writer->endElement();
142
+            } else {
143
+                $writer->writeElement($k, $v);
144
+            }
145
+        }
146
+    }
147
+
148
+    public function getOCSStatus() {
149
+        return parent::getStatus();
150
+    }
151 151
 }
Please login to merge, or discard this patch.
lib/private/AppFramework/OCS/V2Response.php 2 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -27,50 +27,50 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
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) {
Please login to merge, or discard this patch.
lib/private/AppFramework/OCS/V1Response.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -27,52 +27,52 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
lib/private/Share/SearchResultSorter.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -26,51 +26,51 @@
 block discarded – undo
26 26
 use OCP\ILogger;
27 27
 
28 28
 class SearchResultSorter {
29
-	private $search;
30
-	private $encoding;
31
-	private $key;
32
-	private $log;
29
+    private $search;
30
+    private $encoding;
31
+    private $key;
32
+    private $log;
33 33
 
34
-	/**
35
-	 * @param string $search the search term as was given by the user
36
-	 * @param string $key the array key containing the value that should be compared
37
-	 * against
38
-	 * @param string $encoding optional, encoding to use, defaults to UTF-8
39
-	 * @param ILogger $log optional
40
-	 */
41
-	public function __construct($search, $key, ILogger $log = null, $encoding = 'UTF-8') {
42
-		$this->encoding = $encoding;
43
-		$this->key = $key;
44
-		$this->log = $log;
45
-		$this->search = mb_strtolower($search, $this->encoding);
46
-	}
34
+    /**
35
+     * @param string $search the search term as was given by the user
36
+     * @param string $key the array key containing the value that should be compared
37
+     * against
38
+     * @param string $encoding optional, encoding to use, defaults to UTF-8
39
+     * @param ILogger $log optional
40
+     */
41
+    public function __construct($search, $key, ILogger $log = null, $encoding = 'UTF-8') {
42
+        $this->encoding = $encoding;
43
+        $this->key = $key;
44
+        $this->log = $log;
45
+        $this->search = mb_strtolower($search, $this->encoding);
46
+    }
47 47
 
48
-	/**
49
-	 * User and Group names matching the search term at the beginning shall appear
50
-	 * on top of the share dialog. Following entries in alphabetical order.
51
-	 * Callback function for usort. http://php.net/usort
52
-	 */
53
-	public function sort($a, $b) {
54
-		if(!isset($a[$this->key]) || !isset($b[$this->key])) {
55
-			if(!is_null($this->log)) {
56
-				$this->log->error('Sharing dialogue: cannot sort due to ' .
57
-								  'missing array key', array('app' => 'core'));
58
-			}
59
-			return 0;
60
-		}
61
-		$nameA = mb_strtolower($a[$this->key], $this->encoding);
62
-		$nameB = mb_strtolower($b[$this->key], $this->encoding);
63
-		$i = mb_strpos($nameA, $this->search, 0, $this->encoding);
64
-		$j = mb_strpos($nameB, $this->search, 0, $this->encoding);
48
+    /**
49
+     * User and Group names matching the search term at the beginning shall appear
50
+     * on top of the share dialog. Following entries in alphabetical order.
51
+     * Callback function for usort. http://php.net/usort
52
+     */
53
+    public function sort($a, $b) {
54
+        if(!isset($a[$this->key]) || !isset($b[$this->key])) {
55
+            if(!is_null($this->log)) {
56
+                $this->log->error('Sharing dialogue: cannot sort due to ' .
57
+                                    'missing array key', array('app' => 'core'));
58
+            }
59
+            return 0;
60
+        }
61
+        $nameA = mb_strtolower($a[$this->key], $this->encoding);
62
+        $nameB = mb_strtolower($b[$this->key], $this->encoding);
63
+        $i = mb_strpos($nameA, $this->search, 0, $this->encoding);
64
+        $j = mb_strpos($nameB, $this->search, 0, $this->encoding);
65 65
 
66
-		if($i === $j || $i > 0 && $j > 0) {
67
-			return strcmp(mb_strtolower($nameA, $this->encoding),
68
-						  mb_strtolower($nameB, $this->encoding));
69
-		} elseif ($i === 0) {
70
-			return -1;
71
-		} else {
72
-			return 1;
73
-		}
74
-	}
66
+        if($i === $j || $i > 0 && $j > 0) {
67
+            return strcmp(mb_strtolower($nameA, $this->encoding),
68
+                            mb_strtolower($nameB, $this->encoding));
69
+        } elseif ($i === 0) {
70
+            return -1;
71
+        } else {
72
+            return 1;
73
+        }
74
+    }
75 75
 }
76 76
 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
 	 * Callback function for usort. http://php.net/usort
52 52
 	 */
53 53
 	public function sort($a, $b) {
54
-		if(!isset($a[$this->key]) || !isset($b[$this->key])) {
55
-			if(!is_null($this->log)) {
56
-				$this->log->error('Sharing dialogue: cannot sort due to ' .
54
+		if (!isset($a[$this->key]) || !isset($b[$this->key])) {
55
+			if (!is_null($this->log)) {
56
+				$this->log->error('Sharing dialogue: cannot sort due to '.
57 57
 								  'missing array key', array('app' => 'core'));
58 58
 			}
59 59
 			return 0;
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 		$i = mb_strpos($nameA, $this->search, 0, $this->encoding);
64 64
 		$j = mb_strpos($nameB, $this->search, 0, $this->encoding);
65 65
 
66
-		if($i === $j || $i > 0 && $j > 0) {
66
+		if ($i === $j || $i > 0 && $j > 0) {
67 67
 			return strcmp(mb_strtolower($nameA, $this->encoding),
68 68
 						  mb_strtolower($nameB, $this->encoding));
69 69
 		} elseif ($i === 0) {
Please login to merge, or discard this patch.
lib/private/Share/Constants.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -31,57 +31,57 @@
 block discarded – undo
31 31
 
32 32
 class Constants {
33 33
 
34
-	/**
35
-	 * @deprecated 17.0.0 - use IShare::TYPE_USER instead
36
-	 */
37
-	const SHARE_TYPE_USER = 0;
38
-	/**
39
-	 * @deprecated 17.0.0 - use IShare::TYPE_GROUP instead
40
-	 */
41
-	const SHARE_TYPE_GROUP = 1;
42
-	// const SHARE_TYPE_USERGROUP = 2; // Internal type used by DefaultShareProvider
43
-	/**
44
-	 * @deprecated 17.0.0 - use IShare::TYPE_LINK instead
45
-	 */
46
-	const SHARE_TYPE_LINK = 3;
47
-	/**
48
-	 * @deprecated 17.0.0 - use IShare::TYPE_EMAIL instead
49
-	 */
50
-	const SHARE_TYPE_EMAIL = 4;
51
-	const SHARE_TYPE_CONTACT = 5; // ToDo Check if it is still in use otherwise remove it
52
-	/**
53
-	 * @deprecated 17.0.0 - use IShare::TYPE_REMOTE instead
54
-	 */
55
-	const SHARE_TYPE_REMOTE = 6;
56
-	/**
57
-	 * @deprecated 17.0.0 - use IShare::TYPE_CIRCLE instead
58
-	 */
59
-	const SHARE_TYPE_CIRCLE = 7;
60
-	/**
61
-	 * @deprecated 17.0.0 - use IShare::TYPE_GUEST instead
62
-	 */
63
-	const SHARE_TYPE_GUEST = 8;
64
-	/**
65
-	 * @deprecated 17.0.0 - use IShare::REMOTE_GROUP instead
66
-	 */
67
-	const SHARE_TYPE_REMOTE_GROUP = 9;
68
-	/**
69
-	 * @deprecated 17.0.0 - use IShare::TYPE_ROOM instead
70
-	 */
71
-	const SHARE_TYPE_ROOM = 10;
72
-	// const SHARE_TYPE_USERROOM = 11; // Internal type used by RoomShareProvider
34
+    /**
35
+     * @deprecated 17.0.0 - use IShare::TYPE_USER instead
36
+     */
37
+    const SHARE_TYPE_USER = 0;
38
+    /**
39
+     * @deprecated 17.0.0 - use IShare::TYPE_GROUP instead
40
+     */
41
+    const SHARE_TYPE_GROUP = 1;
42
+    // const SHARE_TYPE_USERGROUP = 2; // Internal type used by DefaultShareProvider
43
+    /**
44
+     * @deprecated 17.0.0 - use IShare::TYPE_LINK instead
45
+     */
46
+    const SHARE_TYPE_LINK = 3;
47
+    /**
48
+     * @deprecated 17.0.0 - use IShare::TYPE_EMAIL instead
49
+     */
50
+    const SHARE_TYPE_EMAIL = 4;
51
+    const SHARE_TYPE_CONTACT = 5; // ToDo Check if it is still in use otherwise remove it
52
+    /**
53
+     * @deprecated 17.0.0 - use IShare::TYPE_REMOTE instead
54
+     */
55
+    const SHARE_TYPE_REMOTE = 6;
56
+    /**
57
+     * @deprecated 17.0.0 - use IShare::TYPE_CIRCLE instead
58
+     */
59
+    const SHARE_TYPE_CIRCLE = 7;
60
+    /**
61
+     * @deprecated 17.0.0 - use IShare::TYPE_GUEST instead
62
+     */
63
+    const SHARE_TYPE_GUEST = 8;
64
+    /**
65
+     * @deprecated 17.0.0 - use IShare::REMOTE_GROUP instead
66
+     */
67
+    const SHARE_TYPE_REMOTE_GROUP = 9;
68
+    /**
69
+     * @deprecated 17.0.0 - use IShare::TYPE_ROOM instead
70
+     */
71
+    const SHARE_TYPE_ROOM = 10;
72
+    // const SHARE_TYPE_USERROOM = 11; // Internal type used by RoomShareProvider
73 73
 
74
-	const FORMAT_NONE = -1;
75
-	const FORMAT_STATUSES = -2;
76
-	const FORMAT_SOURCES = -3;  // ToDo Check if it is still in use otherwise remove it
74
+    const FORMAT_NONE = -1;
75
+    const FORMAT_STATUSES = -2;
76
+    const FORMAT_SOURCES = -3;  // ToDo Check if it is still in use otherwise remove it
77 77
 
78
-	const RESPONSE_FORMAT = 'json'; // default resonse format for ocs calls
78
+    const RESPONSE_FORMAT = 'json'; // default resonse format for ocs calls
79 79
 
80
-	const TOKEN_LENGTH = 15; // old (oc7) length is 32, keep token length in db at least that for compatibility
80
+    const TOKEN_LENGTH = 15; // old (oc7) length is 32, keep token length in db at least that for compatibility
81 81
 
82
-	protected static $shareTypeUserAndGroups = -1;
83
-	protected static $shareTypeGroupUserUnique = 2;
84
-	protected static $backends = array();
85
-	protected static $backendTypes = array();
86
-	protected static $isResharingAllowed;
82
+    protected static $shareTypeUserAndGroups = -1;
83
+    protected static $shareTypeGroupUserUnique = 2;
84
+    protected static $backends = array();
85
+    protected static $backendTypes = array();
86
+    protected static $isResharingAllowed;
87 87
 }
Please login to merge, or discard this patch.
lib/private/Repair/MoveUpdaterStepFile.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -28,53 +28,53 @@
 block discarded – undo
28 28
 
29 29
 class MoveUpdaterStepFile implements IRepairStep {
30 30
 
31
-	/** @var \OCP\IConfig */
32
-	protected $config;
31
+    /** @var \OCP\IConfig */
32
+    protected $config;
33 33
 
34
-	/**
35
-	 * @param \OCP\IConfig $config
36
-	 */
37
-	public function __construct($config) {
38
-		$this->config = $config;
39
-	}
34
+    /**
35
+     * @param \OCP\IConfig $config
36
+     */
37
+    public function __construct($config) {
38
+        $this->config = $config;
39
+    }
40 40
 
41
-	public function getName() {
42
-		return 'Move .step file of updater to backup location';
43
-	}
41
+    public function getName() {
42
+        return 'Move .step file of updater to backup location';
43
+    }
44 44
 
45
-	public function run(IOutput $output) {
45
+    public function run(IOutput $output) {
46 46
 
47
-		$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
48
-		$instanceId = $this->config->getSystemValue('instanceid', null);
47
+        $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
48
+        $instanceId = $this->config->getSystemValue('instanceid', null);
49 49
 
50
-		if(!is_string($instanceId) || empty($instanceId)) {
51
-			return;
52
-		}
50
+        if(!is_string($instanceId) || empty($instanceId)) {
51
+            return;
52
+        }
53 53
 
54
-		$updaterFolderPath = $dataDir . '/updater-' . $instanceId;
55
-		$stepFile = $updaterFolderPath . '/.step';
56
-		if(file_exists($stepFile)) {
57
-			$output->info('.step file exists');
54
+        $updaterFolderPath = $dataDir . '/updater-' . $instanceId;
55
+        $stepFile = $updaterFolderPath . '/.step';
56
+        if(file_exists($stepFile)) {
57
+            $output->info('.step file exists');
58 58
 
59
-			$previousStepFile = $updaterFolderPath . '/.step-previous-update';
59
+            $previousStepFile = $updaterFolderPath . '/.step-previous-update';
60 60
 
61
-			// cleanup
62
-			if(file_exists($previousStepFile)) {
63
-				if(\OC_Helper::rmdirr($previousStepFile)) {
64
-					$output->info('.step-previous-update removed');
65
-				} else {
66
-					$output->info('.step-previous-update can\'t be removed - abort move of .step file');
67
-					return;
68
-				}
69
-			}
61
+            // cleanup
62
+            if(file_exists($previousStepFile)) {
63
+                if(\OC_Helper::rmdirr($previousStepFile)) {
64
+                    $output->info('.step-previous-update removed');
65
+                } else {
66
+                    $output->info('.step-previous-update can\'t be removed - abort move of .step file');
67
+                    return;
68
+                }
69
+            }
70 70
 
71
-			// move step file
72
-			if(rename($stepFile, $previousStepFile)) {
73
-				$output->info('.step file moved to .step-previous-update');
74
-			} else {
75
-				$output->warning('.step file can\'t be moved');
76
-			}
77
-		}
78
-	}
71
+            // move step file
72
+            if(rename($stepFile, $previousStepFile)) {
73
+                $output->info('.step file moved to .step-previous-update');
74
+            } else {
75
+                $output->warning('.step file can\'t be moved');
76
+            }
77
+        }
78
+    }
79 79
 }
80 80
 
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -44,23 +44,23 @@  discard block
 block discarded – undo
44 44
 
45 45
 	public function run(IOutput $output) {
46 46
 
47
-		$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
47
+		$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data');
48 48
 		$instanceId = $this->config->getSystemValue('instanceid', null);
49 49
 
50
-		if(!is_string($instanceId) || empty($instanceId)) {
50
+		if (!is_string($instanceId) || empty($instanceId)) {
51 51
 			return;
52 52
 		}
53 53
 
54
-		$updaterFolderPath = $dataDir . '/updater-' . $instanceId;
55
-		$stepFile = $updaterFolderPath . '/.step';
56
-		if(file_exists($stepFile)) {
54
+		$updaterFolderPath = $dataDir.'/updater-'.$instanceId;
55
+		$stepFile = $updaterFolderPath.'/.step';
56
+		if (file_exists($stepFile)) {
57 57
 			$output->info('.step file exists');
58 58
 
59
-			$previousStepFile = $updaterFolderPath . '/.step-previous-update';
59
+			$previousStepFile = $updaterFolderPath.'/.step-previous-update';
60 60
 
61 61
 			// cleanup
62
-			if(file_exists($previousStepFile)) {
63
-				if(\OC_Helper::rmdirr($previousStepFile)) {
62
+			if (file_exists($previousStepFile)) {
63
+				if (\OC_Helper::rmdirr($previousStepFile)) {
64 64
 					$output->info('.step-previous-update removed');
65 65
 				} else {
66 66
 					$output->info('.step-previous-update can\'t be removed - abort move of .step file');
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 			}
70 70
 
71 71
 			// move step file
72
-			if(rename($stepFile, $previousStepFile)) {
72
+			if (rename($stepFile, $previousStepFile)) {
73 73
 				$output->info('.step file moved to .step-previous-update');
74 74
 			} else {
75 75
 				$output->warning('.step file can\'t be moved');
Please login to merge, or discard this patch.