Passed
Push — master ( 1ad063...0f7fb7 )
by Morris
22:31 queued 11:17
created
lib/private/Files/Storage/CommonTest.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -33,53 +33,53 @@
 block discarded – undo
33 33
 namespace OC\Files\Storage;
34 34
 
35 35
 class CommonTest extends \OC\Files\Storage\Common {
36
-	/**
37
-	 * underlying local storage used for missing functions
38
-	 * @var \OC\Files\Storage\Local
39
-	 */
40
-	private $storage;
36
+    /**
37
+     * underlying local storage used for missing functions
38
+     * @var \OC\Files\Storage\Local
39
+     */
40
+    private $storage;
41 41
 
42
-	public function __construct($params) {
43
-		$this->storage = new \OC\Files\Storage\Local($params);
44
-	}
42
+    public function __construct($params) {
43
+        $this->storage = new \OC\Files\Storage\Local($params);
44
+    }
45 45
 
46
-	public function getId() {
47
-		return 'test::'.$this->storage->getId();
48
-	}
49
-	public function mkdir($path) {
50
-		return $this->storage->mkdir($path);
51
-	}
52
-	public function rmdir($path) {
53
-		return $this->storage->rmdir($path);
54
-	}
55
-	public function opendir($path) {
56
-		return $this->storage->opendir($path);
57
-	}
58
-	public function stat($path) {
59
-		return $this->storage->stat($path);
60
-	}
61
-	public function filetype($path) {
62
-		return @$this->storage->filetype($path);
63
-	}
64
-	public function isReadable($path) {
65
-		return $this->storage->isReadable($path);
66
-	}
67
-	public function isUpdatable($path) {
68
-		return $this->storage->isUpdatable($path);
69
-	}
70
-	public function file_exists($path) {
71
-		return $this->storage->file_exists($path);
72
-	}
73
-	public function unlink($path) {
74
-		return $this->storage->unlink($path);
75
-	}
76
-	public function fopen($path, $mode) {
77
-		return $this->storage->fopen($path, $mode);
78
-	}
79
-	public function free_space($path) {
80
-		return $this->storage->free_space($path);
81
-	}
82
-	public function touch($path, $mtime = null) {
83
-		return $this->storage->touch($path, $mtime);
84
-	}
46
+    public function getId() {
47
+        return 'test::'.$this->storage->getId();
48
+    }
49
+    public function mkdir($path) {
50
+        return $this->storage->mkdir($path);
51
+    }
52
+    public function rmdir($path) {
53
+        return $this->storage->rmdir($path);
54
+    }
55
+    public function opendir($path) {
56
+        return $this->storage->opendir($path);
57
+    }
58
+    public function stat($path) {
59
+        return $this->storage->stat($path);
60
+    }
61
+    public function filetype($path) {
62
+        return @$this->storage->filetype($path);
63
+    }
64
+    public function isReadable($path) {
65
+        return $this->storage->isReadable($path);
66
+    }
67
+    public function isUpdatable($path) {
68
+        return $this->storage->isUpdatable($path);
69
+    }
70
+    public function file_exists($path) {
71
+        return $this->storage->file_exists($path);
72
+    }
73
+    public function unlink($path) {
74
+        return $this->storage->unlink($path);
75
+    }
76
+    public function fopen($path, $mode) {
77
+        return $this->storage->fopen($path, $mode);
78
+    }
79
+    public function free_space($path) {
80
+        return $this->storage->free_space($path);
81
+    }
82
+    public function touch($path, $mtime = null) {
83
+        return $this->storage->touch($path, $mtime);
84
+    }
85 85
 }
Please login to merge, or discard this patch.
lib/private/Memcache/Memcached.php 1 patch
Indentation   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -33,193 +33,193 @@
 block discarded – undo
33 33
 use OCP\IMemcache;
34 34
 
35 35
 class Memcached extends Cache implements IMemcache {
36
-	use CASTrait;
37
-
38
-	/**
39
-	 * @var \Memcached $cache
40
-	 */
41
-	private static $cache = null;
42
-
43
-	use CADTrait;
44
-
45
-	public function __construct($prefix = '') {
46
-		parent::__construct($prefix);
47
-		if (is_null(self::$cache)) {
48
-			self::$cache = new \Memcached();
49
-
50
-			$defaultOptions = [
51
-				\Memcached::OPT_CONNECT_TIMEOUT => 50,
52
-				\Memcached::OPT_RETRY_TIMEOUT => 50,
53
-				\Memcached::OPT_SEND_TIMEOUT => 50,
54
-				\Memcached::OPT_RECV_TIMEOUT => 50,
55
-				\Memcached::OPT_POLL_TIMEOUT => 50,
56
-
57
-				// Enable compression
58
-				\Memcached::OPT_COMPRESSION => true,
59
-
60
-				// Turn on consistent hashing
61
-				\Memcached::OPT_LIBKETAMA_COMPATIBLE => true,
62
-
63
-				// Enable Binary Protocol
64
-				//\Memcached::OPT_BINARY_PROTOCOL =>      true,
65
-			];
66
-			// by default enable igbinary serializer if available
67
-			if (\Memcached::HAVE_IGBINARY) {
68
-				$defaultOptions[\Memcached::OPT_SERIALIZER] =
69
-					\Memcached::SERIALIZER_IGBINARY;
70
-			}
71
-			$options = \OC::$server->getConfig()->getSystemValue('memcached_options', []);
72
-			if (is_array($options)) {
73
-				$options = $options + $defaultOptions;
74
-				self::$cache->setOptions($options);
75
-			} else {
76
-				throw new HintException("Expected 'memcached_options' config to be an array, got $options");
77
-			}
78
-
79
-			$servers = \OC::$server->getSystemConfig()->getValue('memcached_servers');
80
-			if (!$servers) {
81
-				$server = \OC::$server->getSystemConfig()->getValue('memcached_server');
82
-				if ($server) {
83
-					$servers = [$server];
84
-				} else {
85
-					$servers = [['localhost', 11211]];
86
-				}
87
-			}
88
-			self::$cache->addServers($servers);
89
-		}
90
-	}
91
-
92
-	/**
93
-	 * entries in XCache gets namespaced to prevent collisions between owncloud instances and users
94
-	 */
95
-	protected function getNameSpace() {
96
-		return $this->prefix;
97
-	}
98
-
99
-	public function get($key) {
100
-		$result = self::$cache->get($this->getNameSpace() . $key);
101
-		if ($result === false and self::$cache->getResultCode() == \Memcached::RES_NOTFOUND) {
102
-			return null;
103
-		} else {
104
-			return $result;
105
-		}
106
-	}
107
-
108
-	public function set($key, $value, $ttl = 0) {
109
-		if ($ttl > 0) {
110
-			$result = self::$cache->set($this->getNameSpace() . $key, $value, $ttl);
111
-		} else {
112
-			$result = self::$cache->set($this->getNameSpace() . $key, $value);
113
-		}
114
-		if ($result !== true) {
115
-			$this->verifyReturnCode();
116
-		}
117
-		return $result;
118
-	}
119
-
120
-	public function hasKey($key) {
121
-		self::$cache->get($this->getNameSpace() . $key);
122
-		return self::$cache->getResultCode() === \Memcached::RES_SUCCESS;
123
-	}
124
-
125
-	public function remove($key) {
126
-		$result = self::$cache->delete($this->getNameSpace() . $key);
127
-		if (self::$cache->getResultCode() !== \Memcached::RES_NOTFOUND) {
128
-			$this->verifyReturnCode();
129
-		}
130
-		return $result;
131
-	}
132
-
133
-	public function clear($prefix = '') {
134
-		$prefix = $this->getNameSpace() . $prefix;
135
-		$allKeys = self::$cache->getAllKeys();
136
-		if ($allKeys === false) {
137
-			// newer Memcached doesn't like getAllKeys(), flush everything
138
-			self::$cache->flush();
139
-			return true;
140
-		}
141
-		$keys = [];
142
-		$prefixLength = strlen($prefix);
143
-		foreach ($allKeys as $key) {
144
-			if (substr($key, 0, $prefixLength) === $prefix) {
145
-				$keys[] = $key;
146
-			}
147
-		}
148
-		if (method_exists(self::$cache, 'deleteMulti')) {
149
-			self::$cache->deleteMulti($keys);
150
-		} else {
151
-			foreach ($keys as $key) {
152
-				self::$cache->delete($key);
153
-			}
154
-		}
155
-		return true;
156
-	}
157
-
158
-	/**
159
-	 * Set a value in the cache if it's not already stored
160
-	 *
161
-	 * @param string $key
162
-	 * @param mixed $value
163
-	 * @param int $ttl Time To Live in seconds. Defaults to 60*60*24
164
-	 * @return bool
165
-	 * @throws \Exception
166
-	 */
167
-	public function add($key, $value, $ttl = 0) {
168
-		$result = self::$cache->add($this->getPrefix() . $key, $value, $ttl);
169
-		if (self::$cache->getResultCode() !== \Memcached::RES_NOTSTORED) {
170
-			$this->verifyReturnCode();
171
-		}
172
-		return $result;
173
-	}
174
-
175
-	/**
176
-	 * Increase a stored number
177
-	 *
178
-	 * @param string $key
179
-	 * @param int $step
180
-	 * @return int | bool
181
-	 */
182
-	public function inc($key, $step = 1) {
183
-		$this->add($key, 0);
184
-		$result = self::$cache->increment($this->getPrefix() . $key, $step);
185
-
186
-		if (self::$cache->getResultCode() !== \Memcached::RES_SUCCESS) {
187
-			return false;
188
-		}
189
-
190
-		return $result;
191
-	}
192
-
193
-	/**
194
-	 * Decrease a stored number
195
-	 *
196
-	 * @param string $key
197
-	 * @param int $step
198
-	 * @return int | bool
199
-	 */
200
-	public function dec($key, $step = 1) {
201
-		$result = self::$cache->decrement($this->getPrefix() . $key, $step);
202
-
203
-		if (self::$cache->getResultCode() !== \Memcached::RES_SUCCESS) {
204
-			return false;
205
-		}
206
-
207
-		return $result;
208
-	}
209
-
210
-	public static function isAvailable() {
211
-		return extension_loaded('memcached');
212
-	}
213
-
214
-	/**
215
-	 * @throws \Exception
216
-	 */
217
-	private function verifyReturnCode() {
218
-		$code = self::$cache->getResultCode();
219
-		if ($code === \Memcached::RES_SUCCESS) {
220
-			return;
221
-		}
222
-		$message = self::$cache->getResultMessage();
223
-		throw new \Exception("Error $code interacting with memcached : $message");
224
-	}
36
+    use CASTrait;
37
+
38
+    /**
39
+     * @var \Memcached $cache
40
+     */
41
+    private static $cache = null;
42
+
43
+    use CADTrait;
44
+
45
+    public function __construct($prefix = '') {
46
+        parent::__construct($prefix);
47
+        if (is_null(self::$cache)) {
48
+            self::$cache = new \Memcached();
49
+
50
+            $defaultOptions = [
51
+                \Memcached::OPT_CONNECT_TIMEOUT => 50,
52
+                \Memcached::OPT_RETRY_TIMEOUT => 50,
53
+                \Memcached::OPT_SEND_TIMEOUT => 50,
54
+                \Memcached::OPT_RECV_TIMEOUT => 50,
55
+                \Memcached::OPT_POLL_TIMEOUT => 50,
56
+
57
+                // Enable compression
58
+                \Memcached::OPT_COMPRESSION => true,
59
+
60
+                // Turn on consistent hashing
61
+                \Memcached::OPT_LIBKETAMA_COMPATIBLE => true,
62
+
63
+                // Enable Binary Protocol
64
+                //\Memcached::OPT_BINARY_PROTOCOL =>      true,
65
+            ];
66
+            // by default enable igbinary serializer if available
67
+            if (\Memcached::HAVE_IGBINARY) {
68
+                $defaultOptions[\Memcached::OPT_SERIALIZER] =
69
+                    \Memcached::SERIALIZER_IGBINARY;
70
+            }
71
+            $options = \OC::$server->getConfig()->getSystemValue('memcached_options', []);
72
+            if (is_array($options)) {
73
+                $options = $options + $defaultOptions;
74
+                self::$cache->setOptions($options);
75
+            } else {
76
+                throw new HintException("Expected 'memcached_options' config to be an array, got $options");
77
+            }
78
+
79
+            $servers = \OC::$server->getSystemConfig()->getValue('memcached_servers');
80
+            if (!$servers) {
81
+                $server = \OC::$server->getSystemConfig()->getValue('memcached_server');
82
+                if ($server) {
83
+                    $servers = [$server];
84
+                } else {
85
+                    $servers = [['localhost', 11211]];
86
+                }
87
+            }
88
+            self::$cache->addServers($servers);
89
+        }
90
+    }
91
+
92
+    /**
93
+     * entries in XCache gets namespaced to prevent collisions between owncloud instances and users
94
+     */
95
+    protected function getNameSpace() {
96
+        return $this->prefix;
97
+    }
98
+
99
+    public function get($key) {
100
+        $result = self::$cache->get($this->getNameSpace() . $key);
101
+        if ($result === false and self::$cache->getResultCode() == \Memcached::RES_NOTFOUND) {
102
+            return null;
103
+        } else {
104
+            return $result;
105
+        }
106
+    }
107
+
108
+    public function set($key, $value, $ttl = 0) {
109
+        if ($ttl > 0) {
110
+            $result = self::$cache->set($this->getNameSpace() . $key, $value, $ttl);
111
+        } else {
112
+            $result = self::$cache->set($this->getNameSpace() . $key, $value);
113
+        }
114
+        if ($result !== true) {
115
+            $this->verifyReturnCode();
116
+        }
117
+        return $result;
118
+    }
119
+
120
+    public function hasKey($key) {
121
+        self::$cache->get($this->getNameSpace() . $key);
122
+        return self::$cache->getResultCode() === \Memcached::RES_SUCCESS;
123
+    }
124
+
125
+    public function remove($key) {
126
+        $result = self::$cache->delete($this->getNameSpace() . $key);
127
+        if (self::$cache->getResultCode() !== \Memcached::RES_NOTFOUND) {
128
+            $this->verifyReturnCode();
129
+        }
130
+        return $result;
131
+    }
132
+
133
+    public function clear($prefix = '') {
134
+        $prefix = $this->getNameSpace() . $prefix;
135
+        $allKeys = self::$cache->getAllKeys();
136
+        if ($allKeys === false) {
137
+            // newer Memcached doesn't like getAllKeys(), flush everything
138
+            self::$cache->flush();
139
+            return true;
140
+        }
141
+        $keys = [];
142
+        $prefixLength = strlen($prefix);
143
+        foreach ($allKeys as $key) {
144
+            if (substr($key, 0, $prefixLength) === $prefix) {
145
+                $keys[] = $key;
146
+            }
147
+        }
148
+        if (method_exists(self::$cache, 'deleteMulti')) {
149
+            self::$cache->deleteMulti($keys);
150
+        } else {
151
+            foreach ($keys as $key) {
152
+                self::$cache->delete($key);
153
+            }
154
+        }
155
+        return true;
156
+    }
157
+
158
+    /**
159
+     * Set a value in the cache if it's not already stored
160
+     *
161
+     * @param string $key
162
+     * @param mixed $value
163
+     * @param int $ttl Time To Live in seconds. Defaults to 60*60*24
164
+     * @return bool
165
+     * @throws \Exception
166
+     */
167
+    public function add($key, $value, $ttl = 0) {
168
+        $result = self::$cache->add($this->getPrefix() . $key, $value, $ttl);
169
+        if (self::$cache->getResultCode() !== \Memcached::RES_NOTSTORED) {
170
+            $this->verifyReturnCode();
171
+        }
172
+        return $result;
173
+    }
174
+
175
+    /**
176
+     * Increase a stored number
177
+     *
178
+     * @param string $key
179
+     * @param int $step
180
+     * @return int | bool
181
+     */
182
+    public function inc($key, $step = 1) {
183
+        $this->add($key, 0);
184
+        $result = self::$cache->increment($this->getPrefix() . $key, $step);
185
+
186
+        if (self::$cache->getResultCode() !== \Memcached::RES_SUCCESS) {
187
+            return false;
188
+        }
189
+
190
+        return $result;
191
+    }
192
+
193
+    /**
194
+     * Decrease a stored number
195
+     *
196
+     * @param string $key
197
+     * @param int $step
198
+     * @return int | bool
199
+     */
200
+    public function dec($key, $step = 1) {
201
+        $result = self::$cache->decrement($this->getPrefix() . $key, $step);
202
+
203
+        if (self::$cache->getResultCode() !== \Memcached::RES_SUCCESS) {
204
+            return false;
205
+        }
206
+
207
+        return $result;
208
+    }
209
+
210
+    public static function isAvailable() {
211
+        return extension_loaded('memcached');
212
+    }
213
+
214
+    /**
215
+     * @throws \Exception
216
+     */
217
+    private function verifyReturnCode() {
218
+        $code = self::$cache->getResultCode();
219
+        if ($code === \Memcached::RES_SUCCESS) {
220
+            return;
221
+        }
222
+        $message = self::$cache->getResultMessage();
223
+        throw new \Exception("Error $code interacting with memcached : $message");
224
+    }
225 225
 }
Please login to merge, or discard this patch.
lib/private/AppFramework/OCS/V1Response.php 1 patch
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.
lib/private/AppFramework/OCS/V2Response.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -27,49 +27,49 @@
 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() {
37
-		$status = parent::getStatus();
38
-		if ($status === API::RESPOND_UNAUTHORISED) {
39
-			return Http::STATUS_UNAUTHORIZED;
40
-		} elseif ($status === API::RESPOND_NOT_FOUND) {
41
-			return Http::STATUS_NOT_FOUND;
42
-		} elseif ($status === API::RESPOND_SERVER_ERROR || $status === API::RESPOND_UNKNOWN_ERROR) {
43
-			return Http::STATUS_INTERNAL_SERVER_ERROR;
44
-		} elseif ($status < 200 || $status > 600) {
45
-			return Http::STATUS_BAD_REQUEST;
46
-		}
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
+        $status = parent::getStatus();
38
+        if ($status === API::RESPOND_UNAUTHORISED) {
39
+            return Http::STATUS_UNAUTHORIZED;
40
+        } elseif ($status === API::RESPOND_NOT_FOUND) {
41
+            return Http::STATUS_NOT_FOUND;
42
+        } elseif ($status === API::RESPOND_SERVER_ERROR || $status === API::RESPOND_UNKNOWN_ERROR) {
43
+            return Http::STATUS_INTERNAL_SERVER_ERROR;
44
+        } elseif ($status < 200 || $status > 600) {
45
+            return Http::STATUS_BAD_REQUEST;
46
+        }
47 47
 
48
-		return $status;
49
-	}
48
+        return $status;
49
+    }
50 50
 
51
-	/**
52
-	 * Construct the meta part of the response
53
-	 * And then late the base class render
54
-	 *
55
-	 * @return string
56
-	 */
57
-	public function render() {
58
-		$status = parent::getStatus();
51
+    /**
52
+     * Construct the meta part of the response
53
+     * And then late the base class render
54
+     *
55
+     * @return string
56
+     */
57
+    public function render() {
58
+        $status = parent::getStatus();
59 59
 
60
-		$meta = [
61
-			'status' => $status >= 200 && $status < 300 ? 'ok' : 'failure',
62
-			'statuscode' => $this->getOCSStatus(),
63
-			'message' => $status >= 200 && $status < 300 ? 'OK' : $this->statusMessage,
64
-		];
60
+        $meta = [
61
+            'status' => $status >= 200 && $status < 300 ? 'ok' : 'failure',
62
+            'statuscode' => $this->getOCSStatus(),
63
+            'message' => $status >= 200 && $status < 300 ? 'OK' : $this->statusMessage,
64
+        ];
65 65
 
66
-		if ($this->itemsCount !== null) {
67
-			$meta['totalitems'] = $this->itemsCount;
68
-		}
69
-		if ($this->itemsPerPage !== null) {
70
-			$meta['itemsperpage'] = $this->itemsPerPage;
71
-		}
66
+        if ($this->itemsCount !== null) {
67
+            $meta['totalitems'] = $this->itemsCount;
68
+        }
69
+        if ($this->itemsPerPage !== null) {
70
+            $meta['itemsperpage'] = $this->itemsPerPage;
71
+        }
72 72
 
73
-		return $this->renderResult($meta);
74
-	}
73
+        return $this->renderResult($meta);
74
+    }
75 75
 }
Please login to merge, or discard this patch.
apps/dav/lib/DAV/Sharing/Xml/ShareRequest.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -26,54 +26,54 @@
 block discarded – undo
26 26
 use Sabre\Xml\XmlDeserializable;
27 27
 
28 28
 class ShareRequest implements XmlDeserializable {
29
-	public $set = [];
29
+    public $set = [];
30 30
 
31
-	public $remove = [];
31
+    public $remove = [];
32 32
 
33
-	/**
34
-	 * Constructor
35
-	 *
36
-	 * @param array $set
37
-	 * @param array $remove
38
-	 */
39
-	public function __construct(array $set, array $remove) {
40
-		$this->set = $set;
41
-		$this->remove = $remove;
42
-	}
33
+    /**
34
+     * Constructor
35
+     *
36
+     * @param array $set
37
+     * @param array $remove
38
+     */
39
+    public function __construct(array $set, array $remove) {
40
+        $this->set = $set;
41
+        $this->remove = $remove;
42
+    }
43 43
 
44
-	public static function xmlDeserialize(Reader $reader) {
45
-		$elements = $reader->parseInnerTree([
46
-			'{' . Plugin::NS_OWNCLOUD. '}set' => 'Sabre\\Xml\\Element\\KeyValue',
47
-			'{' . Plugin::NS_OWNCLOUD . '}remove' => 'Sabre\\Xml\\Element\\KeyValue',
48
-		]);
44
+    public static function xmlDeserialize(Reader $reader) {
45
+        $elements = $reader->parseInnerTree([
46
+            '{' . Plugin::NS_OWNCLOUD. '}set' => 'Sabre\\Xml\\Element\\KeyValue',
47
+            '{' . Plugin::NS_OWNCLOUD . '}remove' => 'Sabre\\Xml\\Element\\KeyValue',
48
+        ]);
49 49
 
50
-		$set = [];
51
-		$remove = [];
50
+        $set = [];
51
+        $remove = [];
52 52
 
53
-		foreach ($elements as $elem) {
54
-			switch ($elem['name']) {
53
+        foreach ($elements as $elem) {
54
+            switch ($elem['name']) {
55 55
 
56
-				case '{' . Plugin::NS_OWNCLOUD . '}set':
57
-					$sharee = $elem['value'];
56
+                case '{' . Plugin::NS_OWNCLOUD . '}set':
57
+                    $sharee = $elem['value'];
58 58
 
59
-					$sumElem = '{' . Plugin::NS_OWNCLOUD . '}summary';
60
-					$commonName = '{' . Plugin::NS_OWNCLOUD . '}common-name';
59
+                    $sumElem = '{' . Plugin::NS_OWNCLOUD . '}summary';
60
+                    $commonName = '{' . Plugin::NS_OWNCLOUD . '}common-name';
61 61
 
62
-					$set[] = [
63
-						'href' => $sharee['{DAV:}href'],
64
-						'commonName' => isset($sharee[$commonName]) ? $sharee[$commonName] : null,
65
-						'summary' => isset($sharee[$sumElem]) ? $sharee[$sumElem] : null,
66
-						'readOnly' => !array_key_exists('{' . Plugin::NS_OWNCLOUD . '}read-write', $sharee),
67
-					];
68
-					break;
62
+                    $set[] = [
63
+                        'href' => $sharee['{DAV:}href'],
64
+                        'commonName' => isset($sharee[$commonName]) ? $sharee[$commonName] : null,
65
+                        'summary' => isset($sharee[$sumElem]) ? $sharee[$sumElem] : null,
66
+                        'readOnly' => !array_key_exists('{' . Plugin::NS_OWNCLOUD . '}read-write', $sharee),
67
+                    ];
68
+                    break;
69 69
 
70
-				case '{' . Plugin::NS_OWNCLOUD . '}remove':
71
-					$remove[] = $elem['value']['{DAV:}href'];
72
-					break;
70
+                case '{' . Plugin::NS_OWNCLOUD . '}remove':
71
+                    $remove[] = $elem['value']['{DAV:}href'];
72
+                    break;
73 73
 
74
-			}
75
-		}
74
+            }
75
+        }
76 76
 
77
-		return new self($set, $remove);
78
-	}
77
+        return new self($set, $remove);
78
+    }
79 79
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php 1 patch
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -35,133 +35,133 @@
 block discarded – undo
35 35
  */
36 36
 class CalendarSearchReport implements XmlDeserializable {
37 37
 
38
-	/**
39
-	 * An array with requested properties.
40
-	 *
41
-	 * @var array
42
-	 */
43
-	public $properties;
44
-
45
-	/**
46
-	 * List of property/component filters.
47
-	 *
48
-	 * @var array
49
-	 */
50
-	public $filters;
51
-
52
-	/**
53
-	 * @var int
54
-	 */
55
-	public $limit;
56
-
57
-	/**
58
-	 * @var int
59
-	 */
60
-	public $offset;
61
-
62
-	/**
63
-	 * The deserialize method is called during xml parsing.
64
-	 *
65
-	 * This method is called statically, this is because in theory this method
66
-	 * may be used as a type of constructor, or factory method.
67
-	 *
68
-	 * Often you want to return an instance of the current class, but you are
69
-	 * free to return other data as well.
70
-	 *
71
-	 * You are responsible for advancing the reader to the next element. Not
72
-	 * doing anything will result in a never-ending loop.
73
-	 *
74
-	 * If you just want to skip parsing for this element altogether, you can
75
-	 * just call $reader->next();
76
-	 *
77
-	 * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
78
-	 * the next element.
79
-	 *
80
-	 * @param Reader $reader
81
-	 * @return mixed
82
-	 */
83
-	public static function xmlDeserialize(Reader $reader) {
84
-		$elems = $reader->parseInnerTree([
85
-			'{http://nextcloud.com/ns}comp-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter',
86
-			'{http://nextcloud.com/ns}prop-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter',
87
-			'{http://nextcloud.com/ns}param-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter',
88
-			'{http://nextcloud.com/ns}search-term' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter',
89
-			'{http://nextcloud.com/ns}limit' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter',
90
-			'{http://nextcloud.com/ns}offset' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter',
91
-			'{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue',
92
-		]);
93
-
94
-		$newProps = [
95
-			'filters' => [],
96
-			'properties' => [],
97
-			'limit' => null,
98
-			'offset' => null
99
-		];
100
-
101
-		if (!is_array($elems)) {
102
-			$elems = [];
103
-		}
104
-
105
-		foreach ($elems as $elem) {
106
-			switch ($elem['name']) {
107
-				case '{DAV:}prop':
108
-					$newProps['properties'] = array_keys($elem['value']);
109
-					break;
110
-				case '{' . SearchPlugin::NS_Nextcloud . '}filter':
111
-					foreach ($elem['value'] as $subElem) {
112
-						if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') {
113
-							if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) {
114
-								$newProps['filters']['comps'] = [];
115
-							}
116
-							$newProps['filters']['comps'][] = $subElem['value'];
117
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') {
118
-							if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) {
119
-								$newProps['filters']['props'] = [];
120
-							}
121
-							$newProps['filters']['props'][] = $subElem['value'];
122
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') {
123
-							if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) {
124
-								$newProps['filters']['params'] = [];
125
-							}
126
-							$newProps['filters']['params'][] = $subElem['value'];
127
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') {
128
-							$newProps['filters']['search-term'] = $subElem['value'];
129
-						}
130
-					}
131
-					break;
132
-				case '{' . SearchPlugin::NS_Nextcloud . '}limit':
133
-					$newProps['limit'] = $elem['value'];
134
-					break;
135
-				case '{' . SearchPlugin::NS_Nextcloud . '}offset':
136
-					$newProps['offset'] = $elem['value'];
137
-					break;
138
-
139
-			}
140
-		}
141
-
142
-		if (empty($newProps['filters'])) {
143
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request');
144
-		}
145
-
146
-		$propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params']));
147
-		$noCompsDefined = empty($newProps['filters']['comps']);
148
-		if ($propsOrParamsDefined && $noCompsDefined) {
149
-			throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter');
150
-		}
151
-
152
-		if (!isset($newProps['filters']['search-term'])) {
153
-			throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request');
154
-		}
155
-
156
-		if (empty($newProps['filters']['props']) && empty($newProps['filters']['params'])) {
157
-			throw new BadRequest('At least one{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter is required for this request');
158
-		}
159
-
160
-
161
-		$obj = new self();
162
-		foreach ($newProps as $key => $value) {
163
-			$obj->$key = $value;
164
-		}
165
-		return $obj;
166
-	}
38
+    /**
39
+     * An array with requested properties.
40
+     *
41
+     * @var array
42
+     */
43
+    public $properties;
44
+
45
+    /**
46
+     * List of property/component filters.
47
+     *
48
+     * @var array
49
+     */
50
+    public $filters;
51
+
52
+    /**
53
+     * @var int
54
+     */
55
+    public $limit;
56
+
57
+    /**
58
+     * @var int
59
+     */
60
+    public $offset;
61
+
62
+    /**
63
+     * The deserialize method is called during xml parsing.
64
+     *
65
+     * This method is called statically, this is because in theory this method
66
+     * may be used as a type of constructor, or factory method.
67
+     *
68
+     * Often you want to return an instance of the current class, but you are
69
+     * free to return other data as well.
70
+     *
71
+     * You are responsible for advancing the reader to the next element. Not
72
+     * doing anything will result in a never-ending loop.
73
+     *
74
+     * If you just want to skip parsing for this element altogether, you can
75
+     * just call $reader->next();
76
+     *
77
+     * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
78
+     * the next element.
79
+     *
80
+     * @param Reader $reader
81
+     * @return mixed
82
+     */
83
+    public static function xmlDeserialize(Reader $reader) {
84
+        $elems = $reader->parseInnerTree([
85
+            '{http://nextcloud.com/ns}comp-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter',
86
+            '{http://nextcloud.com/ns}prop-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter',
87
+            '{http://nextcloud.com/ns}param-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter',
88
+            '{http://nextcloud.com/ns}search-term' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter',
89
+            '{http://nextcloud.com/ns}limit' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter',
90
+            '{http://nextcloud.com/ns}offset' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter',
91
+            '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue',
92
+        ]);
93
+
94
+        $newProps = [
95
+            'filters' => [],
96
+            'properties' => [],
97
+            'limit' => null,
98
+            'offset' => null
99
+        ];
100
+
101
+        if (!is_array($elems)) {
102
+            $elems = [];
103
+        }
104
+
105
+        foreach ($elems as $elem) {
106
+            switch ($elem['name']) {
107
+                case '{DAV:}prop':
108
+                    $newProps['properties'] = array_keys($elem['value']);
109
+                    break;
110
+                case '{' . SearchPlugin::NS_Nextcloud . '}filter':
111
+                    foreach ($elem['value'] as $subElem) {
112
+                        if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') {
113
+                            if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) {
114
+                                $newProps['filters']['comps'] = [];
115
+                            }
116
+                            $newProps['filters']['comps'][] = $subElem['value'];
117
+                        } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') {
118
+                            if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) {
119
+                                $newProps['filters']['props'] = [];
120
+                            }
121
+                            $newProps['filters']['props'][] = $subElem['value'];
122
+                        } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') {
123
+                            if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) {
124
+                                $newProps['filters']['params'] = [];
125
+                            }
126
+                            $newProps['filters']['params'][] = $subElem['value'];
127
+                        } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') {
128
+                            $newProps['filters']['search-term'] = $subElem['value'];
129
+                        }
130
+                    }
131
+                    break;
132
+                case '{' . SearchPlugin::NS_Nextcloud . '}limit':
133
+                    $newProps['limit'] = $elem['value'];
134
+                    break;
135
+                case '{' . SearchPlugin::NS_Nextcloud . '}offset':
136
+                    $newProps['offset'] = $elem['value'];
137
+                    break;
138
+
139
+            }
140
+        }
141
+
142
+        if (empty($newProps['filters'])) {
143
+            throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request');
144
+        }
145
+
146
+        $propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params']));
147
+        $noCompsDefined = empty($newProps['filters']['comps']);
148
+        if ($propsOrParamsDefined && $noCompsDefined) {
149
+            throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter');
150
+        }
151
+
152
+        if (!isset($newProps['filters']['search-term'])) {
153
+            throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request');
154
+        }
155
+
156
+        if (empty($newProps['filters']['props']) && empty($newProps['filters']['params'])) {
157
+            throw new BadRequest('At least one{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter is required for this request');
158
+        }
159
+
160
+
161
+        $obj = new self();
162
+        foreach ($newProps as $key => $value) {
163
+            $obj->$key = $value;
164
+        }
165
+        return $obj;
166
+    }
167 167
 }
Please login to merge, or discard this patch.
apps/testing/appinfo/routes.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -21,62 +21,62 @@
 block discarded – undo
21 21
  */
22 22
 
23 23
 return [
24
-	'routes' => [
25
-		[
26
-			'name' => 'RateLimitTest#userAndAnonProtected',
27
-			'url' => '/userAndAnonProtected',
28
-			'verb' => 'GET',
29
-		],
30
-		[
31
-			'name' => 'RateLimitTest#onlyAnonProtected',
32
-			'url' => '/anonProtected',
33
-			'verb' => 'GET',
34
-		],
35
-	],
24
+    'routes' => [
25
+        [
26
+            'name' => 'RateLimitTest#userAndAnonProtected',
27
+            'url' => '/userAndAnonProtected',
28
+            'verb' => 'GET',
29
+        ],
30
+        [
31
+            'name' => 'RateLimitTest#onlyAnonProtected',
32
+            'url' => '/anonProtected',
33
+            'verb' => 'GET',
34
+        ],
35
+    ],
36 36
 
37
-	'ocs' => [
38
-		[
39
-			'name' => 'Config#setAppValue',
40
-			'url' => '/api/v1/app/{appid}/{configkey}',
41
-			'verb' => 'POST',
42
-		],
43
-		[
44
-			'name' => 'Config#deleteAppValue',
45
-			'url' => '/api/v1/app/{appid}/{configkey}',
46
-			'verb' => 'DELETE',
47
-		],
48
-		[
49
-			'name' => 'Locking#isLockingEnabled',
50
-			'url' => '/api/v1/lockprovisioning',
51
-			'verb' => 'GET',
52
-		],
53
-		[
54
-			'name' => 'Locking#isLocked',
55
-			'url' => '/api/v1/lockprovisioning/{type}/{user}',
56
-			'verb' => 'GET',
57
-		],
58
-		[
59
-			'name' => 'Locking#acquireLock',
60
-			'url' => '/api/v1/lockprovisioning/{type}/{user}',
61
-			'verb' => 'POST',
62
-		],
63
-		[
64
-			'name' => 'Locking#changeLock',
65
-			'url' => '/api/v1/lockprovisioning/{type}/{user}',
66
-			'verb' => 'PUT',
67
-		],
68
-		[
69
-			'name' => 'Locking#releaseLock',
70
-			'url' => '/api/v1/lockprovisioning/{type}/{user}',
71
-			'verb' => 'DELETE',
72
-		],
73
-		[
74
-			'name' => 'Locking#releaseAll',
75
-			'url' => '/api/v1/lockprovisioning/{type}',
76
-			'verb' => 'DELETE',
77
-			'defaults' => [
78
-				'type' => null
79
-			]
80
-		],
81
-	],
37
+    'ocs' => [
38
+        [
39
+            'name' => 'Config#setAppValue',
40
+            'url' => '/api/v1/app/{appid}/{configkey}',
41
+            'verb' => 'POST',
42
+        ],
43
+        [
44
+            'name' => 'Config#deleteAppValue',
45
+            'url' => '/api/v1/app/{appid}/{configkey}',
46
+            'verb' => 'DELETE',
47
+        ],
48
+        [
49
+            'name' => 'Locking#isLockingEnabled',
50
+            'url' => '/api/v1/lockprovisioning',
51
+            'verb' => 'GET',
52
+        ],
53
+        [
54
+            'name' => 'Locking#isLocked',
55
+            'url' => '/api/v1/lockprovisioning/{type}/{user}',
56
+            'verb' => 'GET',
57
+        ],
58
+        [
59
+            'name' => 'Locking#acquireLock',
60
+            'url' => '/api/v1/lockprovisioning/{type}/{user}',
61
+            'verb' => 'POST',
62
+        ],
63
+        [
64
+            'name' => 'Locking#changeLock',
65
+            'url' => '/api/v1/lockprovisioning/{type}/{user}',
66
+            'verb' => 'PUT',
67
+        ],
68
+        [
69
+            'name' => 'Locking#releaseLock',
70
+            'url' => '/api/v1/lockprovisioning/{type}/{user}',
71
+            'verb' => 'DELETE',
72
+        ],
73
+        [
74
+            'name' => 'Locking#releaseAll',
75
+            'url' => '/api/v1/lockprovisioning/{type}',
76
+            'verb' => 'DELETE',
77
+            'defaults' => [
78
+                'type' => null
79
+            ]
80
+        ],
81
+    ],
82 82
 ];
Please login to merge, or discard this patch.
apps/comments/lib/EventHandler.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -36,56 +36,56 @@
 block discarded – undo
36 36
  * @package OCA\Comments
37 37
  */
38 38
 class EventHandler implements ICommentsEventHandler {
39
-	/** @var ActivityListener */
40
-	private $activityListener;
39
+    /** @var ActivityListener */
40
+    private $activityListener;
41 41
 
42
-	/** @var NotificationListener */
43
-	private $notificationListener;
42
+    /** @var NotificationListener */
43
+    private $notificationListener;
44 44
 
45
-	public function __construct(ActivityListener $activityListener, NotificationListener $notificationListener) {
46
-		$this->activityListener = $activityListener;
47
-		$this->notificationListener = $notificationListener;
48
-	}
45
+    public function __construct(ActivityListener $activityListener, NotificationListener $notificationListener) {
46
+        $this->activityListener = $activityListener;
47
+        $this->notificationListener = $notificationListener;
48
+    }
49 49
 
50
-	/**
51
-	 * @param CommentsEvent $event
52
-	 */
53
-	public function handle(CommentsEvent $event) {
54
-		if ($event->getComment()->getObjectType() !== 'files') {
55
-			// this is a 'files'-specific Handler
56
-			return;
57
-		}
50
+    /**
51
+     * @param CommentsEvent $event
52
+     */
53
+    public function handle(CommentsEvent $event) {
54
+        if ($event->getComment()->getObjectType() !== 'files') {
55
+            // this is a 'files'-specific Handler
56
+            return;
57
+        }
58 58
 
59
-		$eventType = $event->getEvent();
60
-		if ($eventType === CommentsEvent::EVENT_ADD
61
-		) {
62
-			$this->notificationHandler($event);
63
-			$this->activityHandler($event);
64
-			return;
65
-		}
59
+        $eventType = $event->getEvent();
60
+        if ($eventType === CommentsEvent::EVENT_ADD
61
+        ) {
62
+            $this->notificationHandler($event);
63
+            $this->activityHandler($event);
64
+            return;
65
+        }
66 66
 
67
-		$applicableEvents = [
68
-			CommentsEvent::EVENT_PRE_UPDATE,
69
-			CommentsEvent::EVENT_UPDATE,
70
-			CommentsEvent::EVENT_DELETE,
71
-		];
72
-		if (in_array($eventType, $applicableEvents)) {
73
-			$this->notificationHandler($event);
74
-			return;
75
-		}
76
-	}
67
+        $applicableEvents = [
68
+            CommentsEvent::EVENT_PRE_UPDATE,
69
+            CommentsEvent::EVENT_UPDATE,
70
+            CommentsEvent::EVENT_DELETE,
71
+        ];
72
+        if (in_array($eventType, $applicableEvents)) {
73
+            $this->notificationHandler($event);
74
+            return;
75
+        }
76
+    }
77 77
 
78
-	/**
79
-	 * @param CommentsEvent $event
80
-	 */
81
-	private function activityHandler(CommentsEvent $event) {
82
-		$this->activityListener->commentEvent($event);
83
-	}
78
+    /**
79
+     * @param CommentsEvent $event
80
+     */
81
+    private function activityHandler(CommentsEvent $event) {
82
+        $this->activityListener->commentEvent($event);
83
+    }
84 84
 
85
-	/**
86
-	 * @param CommentsEvent $event
87
-	 */
88
-	private function notificationHandler(CommentsEvent $event) {
89
-		$this->notificationListener->evaluate($event);
90
-	}
85
+    /**
86
+     * @param CommentsEvent $event
87
+     */
88
+    private function notificationHandler(CommentsEvent $event) {
89
+        $this->notificationListener->evaluate($event);
90
+    }
91 91
 }
Please login to merge, or discard this patch.
apps/encryption/lib/Crypto/DecryptAll.php 1 patch
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -34,126 +34,126 @@
 block discarded – undo
34 34
 
35 35
 class DecryptAll {
36 36
 
37
-	/** @var Util  */
38
-	protected $util;
39
-
40
-	/** @var QuestionHelper  */
41
-	protected $questionHelper;
42
-
43
-	/** @var  Crypt */
44
-	protected $crypt;
45
-
46
-	/** @var  KeyManager */
47
-	protected $keyManager;
48
-
49
-	/** @var Session  */
50
-	protected $session;
51
-
52
-	/**
53
-	 * @param Util $util
54
-	 * @param KeyManager $keyManager
55
-	 * @param Crypt $crypt
56
-	 * @param Session $session
57
-	 * @param QuestionHelper $questionHelper
58
-	 */
59
-	public function __construct(
60
-		Util $util,
61
-		KeyManager $keyManager,
62
-		Crypt $crypt,
63
-		Session $session,
64
-		QuestionHelper $questionHelper
65
-	) {
66
-		$this->util = $util;
67
-		$this->keyManager = $keyManager;
68
-		$this->crypt = $crypt;
69
-		$this->session = $session;
70
-		$this->questionHelper = $questionHelper;
71
-	}
72
-
73
-	/**
74
-	 * prepare encryption module to decrypt all files
75
-	 *
76
-	 * @param InputInterface $input
77
-	 * @param OutputInterface $output
78
-	 * @param $user
79
-	 * @return bool
80
-	 */
81
-	public function prepare(InputInterface $input, OutputInterface $output, $user) {
82
-		$question = new Question('Please enter the recovery key password: ');
83
-
84
-		if ($this->util->isMasterKeyEnabled()) {
85
-			$output->writeln('Use master key to decrypt all files');
86
-			$user = $this->keyManager->getMasterKeyId();
87
-			$password = $this->keyManager->getMasterKeyPassword();
88
-		} else {
89
-			$recoveryKeyId = $this->keyManager->getRecoveryKeyId();
90
-			if (!empty($user)) {
91
-				$output->writeln('You can only decrypt the users files if you know');
92
-				$output->writeln('the users password or if he activated the recovery key.');
93
-				$output->writeln('');
94
-				$questionUseLoginPassword = new ConfirmationQuestion(
95
-					'Do you want to use the users login password to decrypt all files? (y/n) ',
96
-					false
97
-				);
98
-				$useLoginPassword = $this->questionHelper->ask($input, $output, $questionUseLoginPassword);
99
-				if ($useLoginPassword) {
100
-					$question = new Question('Please enter the user\'s login password: ');
101
-				} elseif ($this->util->isRecoveryEnabledForUser($user) === false) {
102
-					$output->writeln('No recovery key available for user ' . $user);
103
-					return false;
104
-				} else {
105
-					$user = $recoveryKeyId;
106
-				}
107
-			} else {
108
-				$output->writeln('You can only decrypt the files of all users if the');
109
-				$output->writeln('recovery key is enabled by the admin and activated by the users.');
110
-				$output->writeln('');
111
-				$user = $recoveryKeyId;
112
-			}
113
-
114
-			$question->setHidden(true);
115
-			$question->setHiddenFallback(false);
116
-			$password = $this->questionHelper->ask($input, $output, $question);
117
-		}
118
-
119
-		$privateKey = $this->getPrivateKey($user, $password);
120
-		if ($privateKey !== false) {
121
-			$this->updateSession($user, $privateKey);
122
-			return true;
123
-		} else {
124
-			$output->writeln('Could not decrypt private key, maybe you entered the wrong password?');
125
-		}
126
-
127
-
128
-		return false;
129
-	}
130
-
131
-	/**
132
-	 * get the private key which will be used to decrypt all files
133
-	 *
134
-	 * @param string $user
135
-	 * @param string $password
136
-	 * @return bool|string
137
-	 * @throws \OCA\Encryption\Exceptions\PrivateKeyMissingException
138
-	 */
139
-	protected function getPrivateKey($user, $password) {
140
-		$recoveryKeyId = $this->keyManager->getRecoveryKeyId();
141
-		$masterKeyId = $this->keyManager->getMasterKeyId();
142
-		if ($user === $recoveryKeyId) {
143
-			$recoveryKey = $this->keyManager->getSystemPrivateKey($recoveryKeyId);
144
-			$privateKey = $this->crypt->decryptPrivateKey($recoveryKey, $password);
145
-		} elseif ($user === $masterKeyId) {
146
-			$masterKey = $this->keyManager->getSystemPrivateKey($masterKeyId);
147
-			$privateKey = $this->crypt->decryptPrivateKey($masterKey, $password, $masterKeyId);
148
-		} else {
149
-			$userKey = $this->keyManager->getPrivateKey($user);
150
-			$privateKey = $this->crypt->decryptPrivateKey($userKey, $password, $user);
151
-		}
152
-
153
-		return $privateKey;
154
-	}
155
-
156
-	protected function updateSession($user, $privateKey) {
157
-		$this->session->prepareDecryptAll($user, $privateKey);
158
-	}
37
+    /** @var Util  */
38
+    protected $util;
39
+
40
+    /** @var QuestionHelper  */
41
+    protected $questionHelper;
42
+
43
+    /** @var  Crypt */
44
+    protected $crypt;
45
+
46
+    /** @var  KeyManager */
47
+    protected $keyManager;
48
+
49
+    /** @var Session  */
50
+    protected $session;
51
+
52
+    /**
53
+     * @param Util $util
54
+     * @param KeyManager $keyManager
55
+     * @param Crypt $crypt
56
+     * @param Session $session
57
+     * @param QuestionHelper $questionHelper
58
+     */
59
+    public function __construct(
60
+        Util $util,
61
+        KeyManager $keyManager,
62
+        Crypt $crypt,
63
+        Session $session,
64
+        QuestionHelper $questionHelper
65
+    ) {
66
+        $this->util = $util;
67
+        $this->keyManager = $keyManager;
68
+        $this->crypt = $crypt;
69
+        $this->session = $session;
70
+        $this->questionHelper = $questionHelper;
71
+    }
72
+
73
+    /**
74
+     * prepare encryption module to decrypt all files
75
+     *
76
+     * @param InputInterface $input
77
+     * @param OutputInterface $output
78
+     * @param $user
79
+     * @return bool
80
+     */
81
+    public function prepare(InputInterface $input, OutputInterface $output, $user) {
82
+        $question = new Question('Please enter the recovery key password: ');
83
+
84
+        if ($this->util->isMasterKeyEnabled()) {
85
+            $output->writeln('Use master key to decrypt all files');
86
+            $user = $this->keyManager->getMasterKeyId();
87
+            $password = $this->keyManager->getMasterKeyPassword();
88
+        } else {
89
+            $recoveryKeyId = $this->keyManager->getRecoveryKeyId();
90
+            if (!empty($user)) {
91
+                $output->writeln('You can only decrypt the users files if you know');
92
+                $output->writeln('the users password or if he activated the recovery key.');
93
+                $output->writeln('');
94
+                $questionUseLoginPassword = new ConfirmationQuestion(
95
+                    'Do you want to use the users login password to decrypt all files? (y/n) ',
96
+                    false
97
+                );
98
+                $useLoginPassword = $this->questionHelper->ask($input, $output, $questionUseLoginPassword);
99
+                if ($useLoginPassword) {
100
+                    $question = new Question('Please enter the user\'s login password: ');
101
+                } elseif ($this->util->isRecoveryEnabledForUser($user) === false) {
102
+                    $output->writeln('No recovery key available for user ' . $user);
103
+                    return false;
104
+                } else {
105
+                    $user = $recoveryKeyId;
106
+                }
107
+            } else {
108
+                $output->writeln('You can only decrypt the files of all users if the');
109
+                $output->writeln('recovery key is enabled by the admin and activated by the users.');
110
+                $output->writeln('');
111
+                $user = $recoveryKeyId;
112
+            }
113
+
114
+            $question->setHidden(true);
115
+            $question->setHiddenFallback(false);
116
+            $password = $this->questionHelper->ask($input, $output, $question);
117
+        }
118
+
119
+        $privateKey = $this->getPrivateKey($user, $password);
120
+        if ($privateKey !== false) {
121
+            $this->updateSession($user, $privateKey);
122
+            return true;
123
+        } else {
124
+            $output->writeln('Could not decrypt private key, maybe you entered the wrong password?');
125
+        }
126
+
127
+
128
+        return false;
129
+    }
130
+
131
+    /**
132
+     * get the private key which will be used to decrypt all files
133
+     *
134
+     * @param string $user
135
+     * @param string $password
136
+     * @return bool|string
137
+     * @throws \OCA\Encryption\Exceptions\PrivateKeyMissingException
138
+     */
139
+    protected function getPrivateKey($user, $password) {
140
+        $recoveryKeyId = $this->keyManager->getRecoveryKeyId();
141
+        $masterKeyId = $this->keyManager->getMasterKeyId();
142
+        if ($user === $recoveryKeyId) {
143
+            $recoveryKey = $this->keyManager->getSystemPrivateKey($recoveryKeyId);
144
+            $privateKey = $this->crypt->decryptPrivateKey($recoveryKey, $password);
145
+        } elseif ($user === $masterKeyId) {
146
+            $masterKey = $this->keyManager->getSystemPrivateKey($masterKeyId);
147
+            $privateKey = $this->crypt->decryptPrivateKey($masterKey, $password, $masterKeyId);
148
+        } else {
149
+            $userKey = $this->keyManager->getPrivateKey($user);
150
+            $privateKey = $this->crypt->decryptPrivateKey($userKey, $password, $user);
151
+        }
152
+
153
+        return $privateKey;
154
+    }
155
+
156
+    protected function updateSession($user, $privateKey) {
157
+        $this->session->prepareDecryptAll($user, $privateKey);
158
+    }
159 159
 }
Please login to merge, or discard this patch.