Passed
Push — master ( d23e96...1bc100 )
by Roeland
11:25 queued 10s
created
apps/files_external/lib/Config/ExternalMountPoint.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 use OC\Files\Mount\MountPoint;
25 25
 
26 26
 class ExternalMountPoint extends MountPoint {
27
-	public function getMountType() {
28
-		return 'external';
29
-	}
27
+    public function getMountType() {
28
+        return 'external';
29
+    }
30 30
 }
Please login to merge, or discard this patch.
lib/private/App/AppStore/Bundles/SocialSharingBundle.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 	 * {@inheritDoc}
28 28
 	 */
29 29
 	public function getName() {
30
-		return (string)$this->l10n->t('Social sharing bundle');
30
+		return (string) $this->l10n->t('Social sharing bundle');
31 31
 	}
32 32
 
33 33
 	/**
Please login to merge, or discard this patch.
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -25,23 +25,23 @@
 block discarded – undo
25 25
 
26 26
 class SocialSharingBundle extends Bundle {
27 27
 
28
-	/**
29
-	 * {@inheritDoc}
30
-	 */
31
-	public function getName() {
32
-		return (string)$this->l10n->t('Social sharing bundle');
33
-	}
28
+    /**
29
+     * {@inheritDoc}
30
+     */
31
+    public function getName() {
32
+        return (string)$this->l10n->t('Social sharing bundle');
33
+    }
34 34
 
35
-	/**
36
-	 * {@inheritDoc}
37
-	 */
38
-	public function getAppIdentifiers() {
39
-		return [
40
-			'socialsharing_twitter',
41
-			'socialsharing_facebook',
42
-			'socialsharing_email',
43
-			'socialsharing_diaspora',
44
-		];
45
-	}
35
+    /**
36
+     * {@inheritDoc}
37
+     */
38
+    public function getAppIdentifiers() {
39
+        return [
40
+            'socialsharing_twitter',
41
+            'socialsharing_facebook',
42
+            'socialsharing_email',
43
+            'socialsharing_diaspora',
44
+        ];
45
+    }
46 46
 
47 47
 }
Please login to merge, or discard this patch.
lib/public/Files/Mount/IMountPoint.php 1 patch
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -29,103 +29,103 @@
 block discarded – undo
29 29
  */
30 30
 interface IMountPoint {
31 31
 
32
-	/**
33
-	 * get complete path to the mount point
34
-	 *
35
-	 * @return string
36
-	 * @since 8.0.0
37
-	 */
38
-	public function getMountPoint();
32
+    /**
33
+     * get complete path to the mount point
34
+     *
35
+     * @return string
36
+     * @since 8.0.0
37
+     */
38
+    public function getMountPoint();
39 39
 
40
-	/**
41
-	 * Set the mountpoint
42
-	 *
43
-	 * @param string $mountPoint new mount point
44
-	 * @since 8.0.0
45
-	 */
46
-	public function setMountPoint($mountPoint);
40
+    /**
41
+     * Set the mountpoint
42
+     *
43
+     * @param string $mountPoint new mount point
44
+     * @since 8.0.0
45
+     */
46
+    public function setMountPoint($mountPoint);
47 47
 
48
-	/**
49
-	 * Get the storage that is mounted
50
-	 *
51
-	 * @return \OC\Files\Storage\Storage
52
-	 * @since 8.0.0
53
-	 */
54
-	public function getStorage();
48
+    /**
49
+     * Get the storage that is mounted
50
+     *
51
+     * @return \OC\Files\Storage\Storage
52
+     * @since 8.0.0
53
+     */
54
+    public function getStorage();
55 55
 
56
-	/**
57
-	 * Get the id of the storages
58
-	 *
59
-	 * @return string
60
-	 * @since 8.0.0
61
-	 */
62
-	public function getStorageId();
56
+    /**
57
+     * Get the id of the storages
58
+     *
59
+     * @return string
60
+     * @since 8.0.0
61
+     */
62
+    public function getStorageId();
63 63
 
64
-	/**
65
-	 * Get the id of the storages
66
-	 *
67
-	 * @return int
68
-	 * @since 9.1.0
69
-	 */
70
-	public function getNumericStorageId();
64
+    /**
65
+     * Get the id of the storages
66
+     *
67
+     * @return int
68
+     * @since 9.1.0
69
+     */
70
+    public function getNumericStorageId();
71 71
 
72
-	/**
73
-	 * Get the path relative to the mountpoint
74
-	 *
75
-	 * @param string $path absolute path to a file or folder
76
-	 * @return string
77
-	 * @since 8.0.0
78
-	 */
79
-	public function getInternalPath($path);
72
+    /**
73
+     * Get the path relative to the mountpoint
74
+     *
75
+     * @param string $path absolute path to a file or folder
76
+     * @return string
77
+     * @since 8.0.0
78
+     */
79
+    public function getInternalPath($path);
80 80
 
81
-	/**
82
-	 * Apply a storage wrapper to the mounted storage
83
-	 *
84
-	 * @param callable $wrapper
85
-	 * @since 8.0.0
86
-	 */
87
-	public function wrapStorage($wrapper);
81
+    /**
82
+     * Apply a storage wrapper to the mounted storage
83
+     *
84
+     * @param callable $wrapper
85
+     * @since 8.0.0
86
+     */
87
+    public function wrapStorage($wrapper);
88 88
 
89
-	/**
90
-	 * Get a mount option
91
-	 *
92
-	 * @param string $name Name of the mount option to get
93
-	 * @param mixed $default Default value for the mount option
94
-	 * @return mixed
95
-	 * @since 8.0.0
96
-	 */
97
-	public function getOption($name, $default);
89
+    /**
90
+     * Get a mount option
91
+     *
92
+     * @param string $name Name of the mount option to get
93
+     * @param mixed $default Default value for the mount option
94
+     * @return mixed
95
+     * @since 8.0.0
96
+     */
97
+    public function getOption($name, $default);
98 98
 
99
-	/**
100
-	 * Get all options for the mount
101
-	 *
102
-	 * @return array
103
-	 * @since 8.1.0
104
-	 */
105
-	public function getOptions();
99
+    /**
100
+     * Get all options for the mount
101
+     *
102
+     * @return array
103
+     * @since 8.1.0
104
+     */
105
+    public function getOptions();
106 106
 
107
-	/**
108
-	 * Get the file id of the root of the storage
109
-	 *
110
-	 * @return int
111
-	 * @since 9.1.0
112
-	 */
113
-	public function getStorageRootId();
107
+    /**
108
+     * Get the file id of the root of the storage
109
+     *
110
+     * @return int
111
+     * @since 9.1.0
112
+     */
113
+    public function getStorageRootId();
114 114
 
115
-	/**
116
-	 * Get the id of the configured mount
117
-	 *
118
-	 * @return int|null mount id or null if not applicable
119
-	 * @since 9.1.0
120
-	 */
121
-	public function getMountId();
115
+    /**
116
+     * Get the id of the configured mount
117
+     *
118
+     * @return int|null mount id or null if not applicable
119
+     * @since 9.1.0
120
+     */
121
+    public function getMountId();
122 122
 
123
-	/**
124
-	 * Get the type of mount point, used to distinguish things like shares and external storages
125
-	 * in the web interface
126
-	 *
127
-	 * @return string
128
-	 * @since 12.0.0
129
-	 */
130
-	public function getMountType();
123
+    /**
124
+     * Get the type of mount point, used to distinguish things like shares and external storages
125
+     * in the web interface
126
+     *
127
+     * @return string
128
+     * @since 12.0.0
129
+     */
130
+    public function getMountType();
131 131
 }
Please login to merge, or discard this patch.
lib/private/App/AppStore/Fetcher/Fetcher.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@
 block discarded – undo
132 132
 				if (isset($jsonBlob['ncversion']) && $jsonBlob['ncversion'] === $this->getVersion()) {
133 133
 
134 134
 					// If the timestamp is older than 300 seconds request the files new
135
-					if ((int)$jsonBlob['timestamp'] > ($this->timeFactory->getTime() - self::INVALIDATE_AFTER_SECONDS)) {
135
+					if ((int) $jsonBlob['timestamp'] > ($this->timeFactory->getTime() - self::INVALIDATE_AFTER_SECONDS)) {
136 136
 						return $jsonBlob['data'];
137 137
 					}
138 138
 
Please login to merge, or discard this patch.
Indentation   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -39,183 +39,183 @@
 block discarded – undo
39 39
 use OCP\Util;
40 40
 
41 41
 abstract class Fetcher {
42
-	const INVALIDATE_AFTER_SECONDS = 300;
43
-
44
-	/** @var IAppData */
45
-	protected $appData;
46
-	/** @var IClientService */
47
-	protected $clientService;
48
-	/** @var ITimeFactory */
49
-	protected $timeFactory;
50
-	/** @var IConfig */
51
-	protected $config;
52
-	/** @var Ilogger */
53
-	protected $logger;
54
-	/** @var string */
55
-	protected $fileName;
56
-	/** @var string */
57
-	protected $endpointUrl;
58
-	/** @var string */
59
-	protected $version;
60
-	/** @var string */
61
-	protected $channel;
62
-
63
-	/**
64
-	 * @param Factory $appDataFactory
65
-	 * @param IClientService $clientService
66
-	 * @param ITimeFactory $timeFactory
67
-	 * @param IConfig $config
68
-	 * @param ILogger $logger
69
-	 */
70
-	public function __construct(Factory $appDataFactory,
71
-								IClientService $clientService,
72
-								ITimeFactory $timeFactory,
73
-								IConfig $config,
74
-								ILogger $logger) {
75
-		$this->appData = $appDataFactory->get('appstore');
76
-		$this->clientService = $clientService;
77
-		$this->timeFactory = $timeFactory;
78
-		$this->config = $config;
79
-		$this->logger = $logger;
80
-	}
81
-
82
-	/**
83
-	 * Fetches the response from the server
84
-	 *
85
-	 * @param string $ETag
86
-	 * @param string $content
87
-	 *
88
-	 * @return array
89
-	 */
90
-	protected function fetch($ETag, $content) {
91
-		$appstoreenabled = $this->config->getSystemValue('appstoreenabled', true);
92
-
93
-		if (!$appstoreenabled) {
94
-			return [];
95
-		}
96
-
97
-		$options = [
98
-			'timeout' => 10,
99
-		];
100
-
101
-		if ($ETag !== '') {
102
-			$options['headers'] = [
103
-				'If-None-Match' => $ETag,
104
-			];
105
-		}
106
-
107
-		$client = $this->clientService->newClient();
108
-		$response = $client->get($this->endpointUrl, $options);
109
-
110
-		$responseJson = [];
111
-		if ($response->getStatusCode() === Http::STATUS_NOT_MODIFIED) {
112
-			$responseJson['data'] = json_decode($content, true);
113
-		} else {
114
-			$responseJson['data'] = json_decode($response->getBody(), true);
115
-			$ETag = $response->getHeader('ETag');
116
-		}
117
-
118
-		$responseJson['timestamp'] = $this->timeFactory->getTime();
119
-		$responseJson['ncversion'] = $this->getVersion();
120
-		if ($ETag !== '') {
121
-			$responseJson['ETag'] = $ETag;
122
-		}
123
-
124
-		return $responseJson;
125
-	}
126
-
127
-	/**
128
-	 * Returns the array with the categories on the appstore server
129
-	 *
130
-	 * @return array
131
-	 */
132
-	public function get() {
133
-		$appstoreenabled = $this->config->getSystemValue('appstoreenabled', true);
134
-		$internetavailable = $this->config->getSystemValue('has_internet_connection', true);
135
-
136
-		if (!$appstoreenabled || !$internetavailable) {
137
-			return [];
138
-		}
139
-
140
-		$rootFolder = $this->appData->getFolder('/');
141
-
142
-		$ETag = '';
143
-		$content = '';
144
-
145
-		try {
146
-			// File does already exists
147
-			$file = $rootFolder->getFile($this->fileName);
148
-			$jsonBlob = json_decode($file->getContent(), true);
149
-			if (is_array($jsonBlob)) {
150
-
151
-				// No caching when the version has been updated
152
-				if (isset($jsonBlob['ncversion']) && $jsonBlob['ncversion'] === $this->getVersion()) {
153
-
154
-					// If the timestamp is older than 300 seconds request the files new
155
-					if ((int)$jsonBlob['timestamp'] > ($this->timeFactory->getTime() - self::INVALIDATE_AFTER_SECONDS)) {
156
-						return $jsonBlob['data'];
157
-					}
158
-
159
-					if (isset($jsonBlob['ETag'])) {
160
-						$ETag = $jsonBlob['ETag'];
161
-						$content = json_encode($jsonBlob['data']);
162
-					}
163
-				}
164
-			}
165
-		} catch (NotFoundException $e) {
166
-			// File does not already exists
167
-			$file = $rootFolder->newFile($this->fileName);
168
-		}
169
-
170
-		// Refresh the file content
171
-		try {
172
-			$responseJson = $this->fetch($ETag, $content);
173
-			$file->putContent(json_encode($responseJson));
174
-			return json_decode($file->getContent(), true)['data'];
175
-		} catch (ConnectException $e) {
176
-			$this->logger->logException($e, ['app' => 'appstoreFetcher', 'level' => ILogger::INFO, 'message' => 'Could not connect to appstore']);
177
-			return [];
178
-		} catch (\Exception $e) {
179
-			$this->logger->logException($e, ['app' => 'appstoreFetcher', 'level' => ILogger::INFO]);
180
-			return [];
181
-		}
182
-	}
183
-
184
-	/**
185
-	 * Get the currently Nextcloud version
186
-	 * @return string
187
-	 */
188
-	protected function getVersion() {
189
-		if ($this->version === null) {
190
-			$this->version = $this->config->getSystemValue('version', '0.0.0');
191
-		}
192
-		return $this->version;
193
-	}
194
-
195
-	/**
196
-	 * Set the current Nextcloud version
197
-	 * @param string $version
198
-	 */
199
-	public function setVersion(string $version) {
200
-		$this->version = $version;
201
-	}
202
-
203
-	/**
204
-	 * Get the currently Nextcloud update channel
205
-	 * @return string
206
-	 */
207
-	protected function getChannel() {
208
-		if ($this->channel === null) {
209
-			$this->channel = \OC_Util::getChannel();
210
-		}
211
-		return $this->channel;
212
-	}
213
-
214
-	/**
215
-	 * Set the current Nextcloud update channel
216
-	 * @param string $channel
217
-	 */
218
-	public function setChannel(string $channel) {
219
-		$this->channel = $channel;
220
-	}
42
+    const INVALIDATE_AFTER_SECONDS = 300;
43
+
44
+    /** @var IAppData */
45
+    protected $appData;
46
+    /** @var IClientService */
47
+    protected $clientService;
48
+    /** @var ITimeFactory */
49
+    protected $timeFactory;
50
+    /** @var IConfig */
51
+    protected $config;
52
+    /** @var Ilogger */
53
+    protected $logger;
54
+    /** @var string */
55
+    protected $fileName;
56
+    /** @var string */
57
+    protected $endpointUrl;
58
+    /** @var string */
59
+    protected $version;
60
+    /** @var string */
61
+    protected $channel;
62
+
63
+    /**
64
+     * @param Factory $appDataFactory
65
+     * @param IClientService $clientService
66
+     * @param ITimeFactory $timeFactory
67
+     * @param IConfig $config
68
+     * @param ILogger $logger
69
+     */
70
+    public function __construct(Factory $appDataFactory,
71
+                                IClientService $clientService,
72
+                                ITimeFactory $timeFactory,
73
+                                IConfig $config,
74
+                                ILogger $logger) {
75
+        $this->appData = $appDataFactory->get('appstore');
76
+        $this->clientService = $clientService;
77
+        $this->timeFactory = $timeFactory;
78
+        $this->config = $config;
79
+        $this->logger = $logger;
80
+    }
81
+
82
+    /**
83
+     * Fetches the response from the server
84
+     *
85
+     * @param string $ETag
86
+     * @param string $content
87
+     *
88
+     * @return array
89
+     */
90
+    protected function fetch($ETag, $content) {
91
+        $appstoreenabled = $this->config->getSystemValue('appstoreenabled', true);
92
+
93
+        if (!$appstoreenabled) {
94
+            return [];
95
+        }
96
+
97
+        $options = [
98
+            'timeout' => 10,
99
+        ];
100
+
101
+        if ($ETag !== '') {
102
+            $options['headers'] = [
103
+                'If-None-Match' => $ETag,
104
+            ];
105
+        }
106
+
107
+        $client = $this->clientService->newClient();
108
+        $response = $client->get($this->endpointUrl, $options);
109
+
110
+        $responseJson = [];
111
+        if ($response->getStatusCode() === Http::STATUS_NOT_MODIFIED) {
112
+            $responseJson['data'] = json_decode($content, true);
113
+        } else {
114
+            $responseJson['data'] = json_decode($response->getBody(), true);
115
+            $ETag = $response->getHeader('ETag');
116
+        }
117
+
118
+        $responseJson['timestamp'] = $this->timeFactory->getTime();
119
+        $responseJson['ncversion'] = $this->getVersion();
120
+        if ($ETag !== '') {
121
+            $responseJson['ETag'] = $ETag;
122
+        }
123
+
124
+        return $responseJson;
125
+    }
126
+
127
+    /**
128
+     * Returns the array with the categories on the appstore server
129
+     *
130
+     * @return array
131
+     */
132
+    public function get() {
133
+        $appstoreenabled = $this->config->getSystemValue('appstoreenabled', true);
134
+        $internetavailable = $this->config->getSystemValue('has_internet_connection', true);
135
+
136
+        if (!$appstoreenabled || !$internetavailable) {
137
+            return [];
138
+        }
139
+
140
+        $rootFolder = $this->appData->getFolder('/');
141
+
142
+        $ETag = '';
143
+        $content = '';
144
+
145
+        try {
146
+            // File does already exists
147
+            $file = $rootFolder->getFile($this->fileName);
148
+            $jsonBlob = json_decode($file->getContent(), true);
149
+            if (is_array($jsonBlob)) {
150
+
151
+                // No caching when the version has been updated
152
+                if (isset($jsonBlob['ncversion']) && $jsonBlob['ncversion'] === $this->getVersion()) {
153
+
154
+                    // If the timestamp is older than 300 seconds request the files new
155
+                    if ((int)$jsonBlob['timestamp'] > ($this->timeFactory->getTime() - self::INVALIDATE_AFTER_SECONDS)) {
156
+                        return $jsonBlob['data'];
157
+                    }
158
+
159
+                    if (isset($jsonBlob['ETag'])) {
160
+                        $ETag = $jsonBlob['ETag'];
161
+                        $content = json_encode($jsonBlob['data']);
162
+                    }
163
+                }
164
+            }
165
+        } catch (NotFoundException $e) {
166
+            // File does not already exists
167
+            $file = $rootFolder->newFile($this->fileName);
168
+        }
169
+
170
+        // Refresh the file content
171
+        try {
172
+            $responseJson = $this->fetch($ETag, $content);
173
+            $file->putContent(json_encode($responseJson));
174
+            return json_decode($file->getContent(), true)['data'];
175
+        } catch (ConnectException $e) {
176
+            $this->logger->logException($e, ['app' => 'appstoreFetcher', 'level' => ILogger::INFO, 'message' => 'Could not connect to appstore']);
177
+            return [];
178
+        } catch (\Exception $e) {
179
+            $this->logger->logException($e, ['app' => 'appstoreFetcher', 'level' => ILogger::INFO]);
180
+            return [];
181
+        }
182
+    }
183
+
184
+    /**
185
+     * Get the currently Nextcloud version
186
+     * @return string
187
+     */
188
+    protected function getVersion() {
189
+        if ($this->version === null) {
190
+            $this->version = $this->config->getSystemValue('version', '0.0.0');
191
+        }
192
+        return $this->version;
193
+    }
194
+
195
+    /**
196
+     * Set the current Nextcloud version
197
+     * @param string $version
198
+     */
199
+    public function setVersion(string $version) {
200
+        $this->version = $version;
201
+    }
202
+
203
+    /**
204
+     * Get the currently Nextcloud update channel
205
+     * @return string
206
+     */
207
+    protected function getChannel() {
208
+        if ($this->channel === null) {
209
+            $this->channel = \OC_Util::getChannel();
210
+        }
211
+        return $this->channel;
212
+    }
213
+
214
+    /**
215
+     * Set the current Nextcloud update channel
216
+     * @param string $channel
217
+     */
218
+    public function setChannel(string $channel) {
219
+        $this->channel = $channel;
220
+    }
221 221
 }
Please login to merge, or discard this patch.
apps/dav/lib/CardDAV/ImageExportPlugin.php 2 patches
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -32,85 +32,85 @@
 block discarded – undo
32 32
 
33 33
 class ImageExportPlugin extends ServerPlugin {
34 34
 
35
-	/** @var Server */
36
-	protected $server;
37
-	/** @var PhotoCache */
38
-	private $cache;
39
-
40
-	/**
41
-	 * ImageExportPlugin constructor.
42
-	 *
43
-	 * @param PhotoCache $cache
44
-	 */
45
-	public function __construct(PhotoCache $cache) {
46
-		$this->cache = $cache;
47
-	}
48
-
49
-	/**
50
-	 * Initializes the plugin and registers event handlers
51
-	 *
52
-	 * @param Server $server
53
-	 * @return void
54
-	 */
55
-	public function initialize(Server $server) {
56
-		$this->server = $server;
57
-		$this->server->on('method:GET', [$this, 'httpGet'], 90);
58
-	}
59
-
60
-	/**
61
-	 * Intercepts GET requests on addressbook urls ending with ?photo.
62
-	 *
63
-	 * @param RequestInterface $request
64
-	 * @param ResponseInterface $response
65
-	 * @return bool
66
-	 */
67
-	public function httpGet(RequestInterface $request, ResponseInterface $response) {
68
-
69
-		$queryParams = $request->getQueryParameters();
70
-		// TODO: in addition to photo we should also add logo some point in time
71
-		if (!array_key_exists('photo', $queryParams)) {
72
-			return true;
73
-		}
74
-
75
-		$size = isset($queryParams['size']) ? (int)$queryParams['size'] : -1;
76
-
77
-		$path = $request->getPath();
78
-		$node = $this->server->tree->getNodeForPath($path);
79
-
80
-		if (!($node instanceof Card)) {
81
-			return true;
82
-		}
83
-
84
-		$this->server->transactionType = 'carddav-image-export';
85
-
86
-		// Checking ACL, if available.
87
-		if ($aclPlugin = $this->server->getPlugin('acl')) {
88
-			/** @var \Sabre\DAVACL\Plugin $aclPlugin */
89
-			$aclPlugin->checkPrivileges($path, '{DAV:}read');
90
-		}
91
-
92
-		// Fetch addressbook
93
-		$addressbookpath = explode('/', $path);
94
-		array_pop($addressbookpath);
95
-		$addressbookpath = implode('/', $addressbookpath);
96
-		/** @var AddressBook $addressbook */
97
-		$addressbook = $this->server->tree->getNodeForPath($addressbookpath);
98
-
99
-		$response->setHeader('Cache-Control', 'private, max-age=3600, must-revalidate');
100
-		$response->setHeader('Etag', $node->getETag() );
101
-		$response->setHeader('Pragma', 'public');
102
-
103
-		try {
104
-			$file = $this->cache->get($addressbook->getResourceId(), $node->getName(), $size, $node);
105
-			$response->setHeader('Content-Type', $file->getMimeType());
106
-			$response->setHeader('Content-Disposition', 'attachment');
107
-			$response->setStatus(200);
108
-
109
-			$response->setBody($file->getContent());
110
-		} catch (NotFoundException $e) {
111
-			$response->setStatus(404);
112
-		}
113
-
114
-		return false;
115
-	}
35
+    /** @var Server */
36
+    protected $server;
37
+    /** @var PhotoCache */
38
+    private $cache;
39
+
40
+    /**
41
+     * ImageExportPlugin constructor.
42
+     *
43
+     * @param PhotoCache $cache
44
+     */
45
+    public function __construct(PhotoCache $cache) {
46
+        $this->cache = $cache;
47
+    }
48
+
49
+    /**
50
+     * Initializes the plugin and registers event handlers
51
+     *
52
+     * @param Server $server
53
+     * @return void
54
+     */
55
+    public function initialize(Server $server) {
56
+        $this->server = $server;
57
+        $this->server->on('method:GET', [$this, 'httpGet'], 90);
58
+    }
59
+
60
+    /**
61
+     * Intercepts GET requests on addressbook urls ending with ?photo.
62
+     *
63
+     * @param RequestInterface $request
64
+     * @param ResponseInterface $response
65
+     * @return bool
66
+     */
67
+    public function httpGet(RequestInterface $request, ResponseInterface $response) {
68
+
69
+        $queryParams = $request->getQueryParameters();
70
+        // TODO: in addition to photo we should also add logo some point in time
71
+        if (!array_key_exists('photo', $queryParams)) {
72
+            return true;
73
+        }
74
+
75
+        $size = isset($queryParams['size']) ? (int)$queryParams['size'] : -1;
76
+
77
+        $path = $request->getPath();
78
+        $node = $this->server->tree->getNodeForPath($path);
79
+
80
+        if (!($node instanceof Card)) {
81
+            return true;
82
+        }
83
+
84
+        $this->server->transactionType = 'carddav-image-export';
85
+
86
+        // Checking ACL, if available.
87
+        if ($aclPlugin = $this->server->getPlugin('acl')) {
88
+            /** @var \Sabre\DAVACL\Plugin $aclPlugin */
89
+            $aclPlugin->checkPrivileges($path, '{DAV:}read');
90
+        }
91
+
92
+        // Fetch addressbook
93
+        $addressbookpath = explode('/', $path);
94
+        array_pop($addressbookpath);
95
+        $addressbookpath = implode('/', $addressbookpath);
96
+        /** @var AddressBook $addressbook */
97
+        $addressbook = $this->server->tree->getNodeForPath($addressbookpath);
98
+
99
+        $response->setHeader('Cache-Control', 'private, max-age=3600, must-revalidate');
100
+        $response->setHeader('Etag', $node->getETag() );
101
+        $response->setHeader('Pragma', 'public');
102
+
103
+        try {
104
+            $file = $this->cache->get($addressbook->getResourceId(), $node->getName(), $size, $node);
105
+            $response->setHeader('Content-Type', $file->getMimeType());
106
+            $response->setHeader('Content-Disposition', 'attachment');
107
+            $response->setStatus(200);
108
+
109
+            $response->setBody($file->getContent());
110
+        } catch (NotFoundException $e) {
111
+            $response->setStatus(404);
112
+        }
113
+
114
+        return false;
115
+    }
116 116
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 			return true;
73 73
 		}
74 74
 
75
-		$size = isset($queryParams['size']) ? (int)$queryParams['size'] : -1;
75
+		$size = isset($queryParams['size']) ? (int) $queryParams['size'] : -1;
76 76
 
77 77
 		$path = $request->getPath();
78 78
 		$node = $this->server->tree->getNodeForPath($path);
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 		$addressbook = $this->server->tree->getNodeForPath($addressbookpath);
98 98
 
99 99
 		$response->setHeader('Cache-Control', 'private, max-age=3600, must-revalidate');
100
-		$response->setHeader('Etag', $node->getETag() );
100
+		$response->setHeader('Etag', $node->getETag());
101 101
 		$response->setHeader('Pragma', 'public');
102 102
 
103 103
 		try {
Please login to merge, or discard this patch.
core/templates/layout.guest.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
 									<?php p($theme->getName()); ?>
42 42
 								</h1>
43 43
 								<?php if(\OC::$server->getConfig()->getSystemValue('installed', false)
44
-									&& \OC::$server->getConfig()->getAppValue('theming', 'logoMime', false)): ?>
44
+                                    && \OC::$server->getConfig()->getAppValue('theming', 'logoMime', false)): ?>
45 45
 									<img src="<?php p($theme->getLogo()); ?>"/>
46 46
 								<?php endif; ?>
47 47
 							</div>
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,21 +18,21 @@
 block discarded – undo
18 18
 		<?php emit_script_loading_tags($_); ?>
19 19
 		<?php print_unescaped($_['headers']); ?>
20 20
 	</head>
21
-	<body id="<?php p($_['bodyid']);?>">
21
+	<body id="<?php p($_['bodyid']); ?>">
22 22
 		<?php include 'layout.noscript.warning.php'; ?>
23 23
 		<?php foreach ($_['initialStates'] as $app => $initialState) { ?>
24 24
 			<input type="hidden" id="initial-state-<?php p($app); ?>" value="<?php p(base64_encode($initialState)); ?>">
25 25
 		<?php }?>
26 26
 		<div class="wrapper">
27 27
 			<div class="v-align">
28
-				<?php if ($_['bodyid'] === 'body-login' ): ?>
28
+				<?php if ($_['bodyid'] === 'body-login'): ?>
29 29
 					<header role="banner">
30 30
 						<div id="header">
31 31
 							<div class="logo">
32 32
 								<h1 class="hidden-visually">
33 33
 									<?php p($theme->getName()); ?>
34 34
 								</h1>
35
-								<?php if(\OC::$server->getConfig()->getSystemValue('installed', false)
35
+								<?php if (\OC::$server->getConfig()->getSystemValue('installed', false)
36 36
 									&& \OC::$server->getConfig()->getAppValue('theming', 'logoMime', false)): ?>
37 37
 									<img src="<?php p($theme->getLogo()); ?>"/>
38 38
 								<?php endif; ?>
Please login to merge, or discard this patch.
lib/private/Config.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 * @return mixed the value or $default
86 86
 	 */
87 87
 	public function getValue($key, $default = null) {
88
-		$envValue = getenv(self::ENV_PREFIX . $key);
88
+		$envValue = getenv(self::ENV_PREFIX.$key);
89 89
 		if ($envValue !== false) {
90 90
 			return $envValue;
91 91
 		}
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 		foreach ($configFiles as $file) {
198 198
 			$fileExistsAndIsReadable = file_exists($file) && is_readable($file);
199 199
 			$filePointer = $fileExistsAndIsReadable ? fopen($file, 'r') : false;
200
-			if($file === $this->configFilePath &&
200
+			if ($file === $this->configFilePath &&
201 201
 				$filePointer === false) {
202 202
 				// Opening the main config might not be possible, e.g. if the wrong
203 203
 				// permissions are set (likely on a new installation)
@@ -205,13 +205,13 @@  discard block
 block discarded – undo
205 205
 			}
206 206
 
207 207
 			// Try to acquire a file lock
208
-			if(!flock($filePointer, LOCK_SH)) {
208
+			if (!flock($filePointer, LOCK_SH)) {
209 209
 				throw new \Exception(sprintf('Could not acquire a shared lock on the config file %s', $file));
210 210
 			}
211 211
 
212 212
 			unset($CONFIG);
213 213
 			include $file;
214
-			if(isset($CONFIG) && is_array($CONFIG)) {
214
+			if (isset($CONFIG) && is_array($CONFIG)) {
215 215
 				$this->cache = array_merge($this->cache, $CONFIG);
216 216
 			}
217 217
 
@@ -236,29 +236,29 @@  discard block
 block discarded – undo
236 236
 		$content .= var_export($this->cache, true);
237 237
 		$content .= ";\n";
238 238
 
239
-		touch ($this->configFilePath);
239
+		touch($this->configFilePath);
240 240
 		$filePointer = fopen($this->configFilePath, 'r+');
241 241
 
242 242
 		// Prevent others not to read the config
243 243
 		chmod($this->configFilePath, 0640);
244 244
 
245 245
 		// File does not exist, this can happen when doing a fresh install
246
-		if(!is_resource ($filePointer)) {
246
+		if (!is_resource($filePointer)) {
247 247
 			// TODO fix this via DI once it is very clear that this doesn't cause side effects due to initialization order
248 248
 			// currently this breaks app routes but also could have other side effects especially during setup and exception handling
249 249
 			$url = \OC::$server->getURLGenerator()->linkToDocs('admin-dir_permissions');
250 250
 			throw new HintException(
251 251
 				"Can't write into config directory!",
252
-				'This can usually be fixed by giving the webserver write access to the config directory. See ' . $url);
252
+				'This can usually be fixed by giving the webserver write access to the config directory. See '.$url);
253 253
 		}
254 254
 
255 255
 		// Try to acquire a file lock
256
-		if(!flock($filePointer, LOCK_EX)) {
256
+		if (!flock($filePointer, LOCK_EX)) {
257 257
 			throw new \Exception(sprintf('Could not acquire an exclusive lock on the config file %s', $this->configFilePath));
258 258
 		}
259 259
 
260 260
 		// Write the config and release the lock
261
-		ftruncate ($filePointer, 0);
261
+		ftruncate($filePointer, 0);
262 262
 		fwrite($filePointer, $content);
263 263
 		fflush($filePointer);
264 264
 		flock($filePointer, LOCK_UN);
Please login to merge, or discard this patch.
Indentation   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -41,233 +41,233 @@
 block discarded – undo
41 41
  */
42 42
 class Config {
43 43
 
44
-	const ENV_PREFIX = 'NC_';
44
+    const ENV_PREFIX = 'NC_';
45 45
 
46
-	/** @var array Associative array ($key => $value) */
47
-	protected $cache = array();
48
-	/** @var string */
49
-	protected $configDir;
50
-	/** @var string */
51
-	protected $configFilePath;
52
-	/** @var string */
53
-	protected $configFileName;
46
+    /** @var array Associative array ($key => $value) */
47
+    protected $cache = array();
48
+    /** @var string */
49
+    protected $configDir;
50
+    /** @var string */
51
+    protected $configFilePath;
52
+    /** @var string */
53
+    protected $configFileName;
54 54
 
55
-	/**
56
-	 * @param string $configDir Path to the config dir, needs to end with '/'
57
-	 * @param string $fileName (Optional) Name of the config file. Defaults to config.php
58
-	 */
59
-	public function __construct($configDir, $fileName = 'config.php') {
60
-		$this->configDir = $configDir;
61
-		$this->configFilePath = $this->configDir.$fileName;
62
-		$this->configFileName = $fileName;
63
-		$this->readData();
64
-	}
55
+    /**
56
+     * @param string $configDir Path to the config dir, needs to end with '/'
57
+     * @param string $fileName (Optional) Name of the config file. Defaults to config.php
58
+     */
59
+    public function __construct($configDir, $fileName = 'config.php') {
60
+        $this->configDir = $configDir;
61
+        $this->configFilePath = $this->configDir.$fileName;
62
+        $this->configFileName = $fileName;
63
+        $this->readData();
64
+    }
65 65
 
66
-	/**
67
-	 * Lists all available config keys
68
-	 *
69
-	 * Please note that it does not return the values.
70
-	 *
71
-	 * @return array an array of key names
72
-	 */
73
-	public function getKeys() {
74
-		return array_keys($this->cache);
75
-	}
66
+    /**
67
+     * Lists all available config keys
68
+     *
69
+     * Please note that it does not return the values.
70
+     *
71
+     * @return array an array of key names
72
+     */
73
+    public function getKeys() {
74
+        return array_keys($this->cache);
75
+    }
76 76
 
77
-	/**
78
-	 * Returns a config value
79
-	 *
80
-	 * gets its value from an `NC_` prefixed environment variable
81
-	 * if it doesn't exist from config.php
82
-	 * if this doesn't exist either, it will return the given `$default`
83
-	 *
84
-	 * @param string $key key
85
-	 * @param mixed $default = null default value
86
-	 * @return mixed the value or $default
87
-	 */
88
-	public function getValue($key, $default = null) {
89
-		$envValue = getenv(self::ENV_PREFIX . $key);
90
-		if ($envValue !== false) {
91
-			return $envValue;
92
-		}
77
+    /**
78
+     * Returns a config value
79
+     *
80
+     * gets its value from an `NC_` prefixed environment variable
81
+     * if it doesn't exist from config.php
82
+     * if this doesn't exist either, it will return the given `$default`
83
+     *
84
+     * @param string $key key
85
+     * @param mixed $default = null default value
86
+     * @return mixed the value or $default
87
+     */
88
+    public function getValue($key, $default = null) {
89
+        $envValue = getenv(self::ENV_PREFIX . $key);
90
+        if ($envValue !== false) {
91
+            return $envValue;
92
+        }
93 93
 
94
-		if (isset($this->cache[$key])) {
95
-			return $this->cache[$key];
96
-		}
94
+        if (isset($this->cache[$key])) {
95
+            return $this->cache[$key];
96
+        }
97 97
 
98
-		return $default;
99
-	}
98
+        return $default;
99
+    }
100 100
 
101
-	/**
102
-	 * Sets and deletes values and writes the config.php
103
-	 *
104
-	 * @param array $configs Associative array with `key => value` pairs
105
-	 *                       If value is null, the config key will be deleted
106
-	 */
107
-	public function setValues(array $configs) {
108
-		$needsUpdate = false;
109
-		foreach ($configs as $key => $value) {
110
-			if ($value !== null) {
111
-				$needsUpdate |= $this->set($key, $value);
112
-			} else {
113
-				$needsUpdate |= $this->delete($key);
114
-			}
115
-		}
101
+    /**
102
+     * Sets and deletes values and writes the config.php
103
+     *
104
+     * @param array $configs Associative array with `key => value` pairs
105
+     *                       If value is null, the config key will be deleted
106
+     */
107
+    public function setValues(array $configs) {
108
+        $needsUpdate = false;
109
+        foreach ($configs as $key => $value) {
110
+            if ($value !== null) {
111
+                $needsUpdate |= $this->set($key, $value);
112
+            } else {
113
+                $needsUpdate |= $this->delete($key);
114
+            }
115
+        }
116 116
 
117
-		if ($needsUpdate) {
118
-			// Write changes
119
-			$this->writeData();
120
-		}
121
-	}
117
+        if ($needsUpdate) {
118
+            // Write changes
119
+            $this->writeData();
120
+        }
121
+    }
122 122
 
123
-	/**
124
-	 * Sets the value and writes it to config.php if required
125
-	 *
126
-	 * @param string $key key
127
-	 * @param mixed $value value
128
-	 */
129
-	public function setValue($key, $value) {
130
-		if ($this->set($key, $value)) {
131
-			// Write changes
132
-			$this->writeData();
133
-		}
134
-	}
123
+    /**
124
+     * Sets the value and writes it to config.php if required
125
+     *
126
+     * @param string $key key
127
+     * @param mixed $value value
128
+     */
129
+    public function setValue($key, $value) {
130
+        if ($this->set($key, $value)) {
131
+            // Write changes
132
+            $this->writeData();
133
+        }
134
+    }
135 135
 
136
-	/**
137
-	 * This function sets the value
138
-	 *
139
-	 * @param string $key key
140
-	 * @param mixed $value value
141
-	 * @return bool True if the file needs to be updated, false otherwise
142
-	 */
143
-	protected function set($key, $value) {
144
-		if (!isset($this->cache[$key]) || $this->cache[$key] !== $value) {
145
-			// Add change
146
-			$this->cache[$key] = $value;
147
-			return true;
148
-		}
136
+    /**
137
+     * This function sets the value
138
+     *
139
+     * @param string $key key
140
+     * @param mixed $value value
141
+     * @return bool True if the file needs to be updated, false otherwise
142
+     */
143
+    protected function set($key, $value) {
144
+        if (!isset($this->cache[$key]) || $this->cache[$key] !== $value) {
145
+            // Add change
146
+            $this->cache[$key] = $value;
147
+            return true;
148
+        }
149 149
 
150
-		return false;
151
-	}
150
+        return false;
151
+    }
152 152
 
153
-	/**
154
-	 * Removes a key from the config and removes it from config.php if required
155
-	 * @param string $key
156
-	 */
157
-	public function deleteKey($key) {
158
-		if ($this->delete($key)) {
159
-			// Write changes
160
-			$this->writeData();
161
-		}
162
-	}
153
+    /**
154
+     * Removes a key from the config and removes it from config.php if required
155
+     * @param string $key
156
+     */
157
+    public function deleteKey($key) {
158
+        if ($this->delete($key)) {
159
+            // Write changes
160
+            $this->writeData();
161
+        }
162
+    }
163 163
 
164
-	/**
165
-	 * This function removes a key from the config
166
-	 *
167
-	 * @param string $key
168
-	 * @return bool True if the file needs to be updated, false otherwise
169
-	 */
170
-	protected function delete($key) {
171
-		if (isset($this->cache[$key])) {
172
-			// Delete key from cache
173
-			unset($this->cache[$key]);
174
-			return true;
175
-		}
176
-		return false;
177
-	}
164
+    /**
165
+     * This function removes a key from the config
166
+     *
167
+     * @param string $key
168
+     * @return bool True if the file needs to be updated, false otherwise
169
+     */
170
+    protected function delete($key) {
171
+        if (isset($this->cache[$key])) {
172
+            // Delete key from cache
173
+            unset($this->cache[$key]);
174
+            return true;
175
+        }
176
+        return false;
177
+    }
178 178
 
179
-	/**
180
-	 * Loads the config file
181
-	 *
182
-	 * Reads the config file and saves it to the cache
183
-	 *
184
-	 * @throws \Exception If no lock could be acquired or the config file has not been found
185
-	 */
186
-	private function readData() {
187
-		// Default config should always get loaded
188
-		$configFiles = array($this->configFilePath);
179
+    /**
180
+     * Loads the config file
181
+     *
182
+     * Reads the config file and saves it to the cache
183
+     *
184
+     * @throws \Exception If no lock could be acquired or the config file has not been found
185
+     */
186
+    private function readData() {
187
+        // Default config should always get loaded
188
+        $configFiles = array($this->configFilePath);
189 189
 
190
-		// Add all files in the config dir ending with the same file name
191
-		$extra = glob($this->configDir.'*.'.$this->configFileName);
192
-		if (is_array($extra)) {
193
-			natsort($extra);
194
-			$configFiles = array_merge($configFiles, $extra);
195
-		}
190
+        // Add all files in the config dir ending with the same file name
191
+        $extra = glob($this->configDir.'*.'.$this->configFileName);
192
+        if (is_array($extra)) {
193
+            natsort($extra);
194
+            $configFiles = array_merge($configFiles, $extra);
195
+        }
196 196
 
197
-		// Include file and merge config
198
-		foreach ($configFiles as $file) {
199
-			$fileExistsAndIsReadable = file_exists($file) && is_readable($file);
200
-			$filePointer = $fileExistsAndIsReadable ? fopen($file, 'r') : false;
201
-			if($file === $this->configFilePath &&
202
-				$filePointer === false) {
203
-				// Opening the main config might not be possible, e.g. if the wrong
204
-				// permissions are set (likely on a new installation)
205
-				continue;
206
-			}
197
+        // Include file and merge config
198
+        foreach ($configFiles as $file) {
199
+            $fileExistsAndIsReadable = file_exists($file) && is_readable($file);
200
+            $filePointer = $fileExistsAndIsReadable ? fopen($file, 'r') : false;
201
+            if($file === $this->configFilePath &&
202
+                $filePointer === false) {
203
+                // Opening the main config might not be possible, e.g. if the wrong
204
+                // permissions are set (likely on a new installation)
205
+                continue;
206
+            }
207 207
 
208
-			// Try to acquire a file lock
209
-			if(!flock($filePointer, LOCK_SH)) {
210
-				throw new \Exception(sprintf('Could not acquire a shared lock on the config file %s', $file));
211
-			}
208
+            // Try to acquire a file lock
209
+            if(!flock($filePointer, LOCK_SH)) {
210
+                throw new \Exception(sprintf('Could not acquire a shared lock on the config file %s', $file));
211
+            }
212 212
 
213
-			unset($CONFIG);
214
-			include $file;
215
-			if(isset($CONFIG) && is_array($CONFIG)) {
216
-				$this->cache = array_merge($this->cache, $CONFIG);
217
-			}
213
+            unset($CONFIG);
214
+            include $file;
215
+            if(isset($CONFIG) && is_array($CONFIG)) {
216
+                $this->cache = array_merge($this->cache, $CONFIG);
217
+            }
218 218
 
219
-			// Close the file pointer and release the lock
220
-			flock($filePointer, LOCK_UN);
221
-			fclose($filePointer);
222
-		}
223
-	}
219
+            // Close the file pointer and release the lock
220
+            flock($filePointer, LOCK_UN);
221
+            fclose($filePointer);
222
+        }
223
+    }
224 224
 
225
-	/**
226
-	 * Writes the config file
227
-	 *
228
-	 * Saves the config to the config file.
229
-	 *
230
-	 * @throws HintException If the config file cannot be written to
231
-	 * @throws \Exception If no file lock can be acquired
232
-	 */
233
-	private function writeData() {
234
-		// Create a php file ...
235
-		$content = "<?php\n";
236
-		$content .= '$CONFIG = ';
237
-		$content .= var_export($this->cache, true);
238
-		$content .= ";\n";
225
+    /**
226
+     * Writes the config file
227
+     *
228
+     * Saves the config to the config file.
229
+     *
230
+     * @throws HintException If the config file cannot be written to
231
+     * @throws \Exception If no file lock can be acquired
232
+     */
233
+    private function writeData() {
234
+        // Create a php file ...
235
+        $content = "<?php\n";
236
+        $content .= '$CONFIG = ';
237
+        $content .= var_export($this->cache, true);
238
+        $content .= ";\n";
239 239
 
240
-		touch ($this->configFilePath);
241
-		$filePointer = fopen($this->configFilePath, 'r+');
240
+        touch ($this->configFilePath);
241
+        $filePointer = fopen($this->configFilePath, 'r+');
242 242
 
243
-		// Prevent others not to read the config
244
-		chmod($this->configFilePath, 0640);
243
+        // Prevent others not to read the config
244
+        chmod($this->configFilePath, 0640);
245 245
 
246
-		// File does not exist, this can happen when doing a fresh install
247
-		if(!is_resource ($filePointer)) {
248
-			// TODO fix this via DI once it is very clear that this doesn't cause side effects due to initialization order
249
-			// currently this breaks app routes but also could have other side effects especially during setup and exception handling
250
-			$url = \OC::$server->getURLGenerator()->linkToDocs('admin-dir_permissions');
251
-			throw new HintException(
252
-				"Can't write into config directory!",
253
-				'This can usually be fixed by giving the webserver write access to the config directory. See ' . $url);
254
-		}
246
+        // File does not exist, this can happen when doing a fresh install
247
+        if(!is_resource ($filePointer)) {
248
+            // TODO fix this via DI once it is very clear that this doesn't cause side effects due to initialization order
249
+            // currently this breaks app routes but also could have other side effects especially during setup and exception handling
250
+            $url = \OC::$server->getURLGenerator()->linkToDocs('admin-dir_permissions');
251
+            throw new HintException(
252
+                "Can't write into config directory!",
253
+                'This can usually be fixed by giving the webserver write access to the config directory. See ' . $url);
254
+        }
255 255
 
256
-		// Try to acquire a file lock
257
-		if(!flock($filePointer, LOCK_EX)) {
258
-			throw new \Exception(sprintf('Could not acquire an exclusive lock on the config file %s', $this->configFilePath));
259
-		}
256
+        // Try to acquire a file lock
257
+        if(!flock($filePointer, LOCK_EX)) {
258
+            throw new \Exception(sprintf('Could not acquire an exclusive lock on the config file %s', $this->configFilePath));
259
+        }
260 260
 
261
-		// Write the config and release the lock
262
-		ftruncate ($filePointer, 0);
263
-		fwrite($filePointer, $content);
264
-		fflush($filePointer);
265
-		flock($filePointer, LOCK_UN);
266
-		fclose($filePointer);
261
+        // Write the config and release the lock
262
+        ftruncate ($filePointer, 0);
263
+        fwrite($filePointer, $content);
264
+        fflush($filePointer);
265
+        flock($filePointer, LOCK_UN);
266
+        fclose($filePointer);
267 267
 
268
-		if (function_exists('opcache_invalidate')) {
269
-			@opcache_invalidate($this->configFilePath, true);
270
-		}
271
-	}
268
+        if (function_exists('opcache_invalidate')) {
269
+            @opcache_invalidate($this->configFilePath, true);
270
+        }
271
+    }
272 272
 }
273 273
 
Please login to merge, or discard this patch.
lib/private/App/CodeChecker/LanguageParseChecker.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -25,36 +25,36 @@
 block discarded – undo
25 25
 
26 26
 class LanguageParseChecker {
27 27
 
28
-	/**
29
-	 * @param string $appId
30
-	 * @return array
31
-	 */
32
-	public function analyse($appId) {
33
-		$appPath = \OC_App::getAppPath($appId);
34
-		if ($appPath === false) {
35
-			throw new \RuntimeException("No app with given id <$appId> known.");
36
-		}
37
-
38
-		if (!is_dir($appPath . '/l10n/')) {
39
-			return [];
40
-		}
41
-
42
-		$errors = [];
43
-		$directory = new \DirectoryIterator($appPath . '/l10n/');
44
-
45
-		foreach ($directory as $file) {
46
-			if ($file->getExtension() !== 'json') {
47
-				continue;
48
-			}
49
-
50
-			$content = file_get_contents($file->getPathname());
51
-			json_decode($content, true);
52
-
53
-			if (json_last_error() !== JSON_ERROR_NONE) {
54
-				$errors[] = 'Invalid language file found: l10n/' . $file->getFilename() . ': ' . json_last_error_msg();
55
-			}
56
-		}
57
-
58
-		return $errors;
59
-	}
28
+    /**
29
+     * @param string $appId
30
+     * @return array
31
+     */
32
+    public function analyse($appId) {
33
+        $appPath = \OC_App::getAppPath($appId);
34
+        if ($appPath === false) {
35
+            throw new \RuntimeException("No app with given id <$appId> known.");
36
+        }
37
+
38
+        if (!is_dir($appPath . '/l10n/')) {
39
+            return [];
40
+        }
41
+
42
+        $errors = [];
43
+        $directory = new \DirectoryIterator($appPath . '/l10n/');
44
+
45
+        foreach ($directory as $file) {
46
+            if ($file->getExtension() !== 'json') {
47
+                continue;
48
+            }
49
+
50
+            $content = file_get_contents($file->getPathname());
51
+            json_decode($content, true);
52
+
53
+            if (json_last_error() !== JSON_ERROR_NONE) {
54
+                $errors[] = 'Invalid language file found: l10n/' . $file->getFilename() . ': ' . json_last_error_msg();
55
+            }
56
+        }
57
+
58
+        return $errors;
59
+    }
60 60
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
 			throw new \RuntimeException("No app with given id <$appId> known.");
36 36
 		}
37 37
 
38
-		if (!is_dir($appPath . '/l10n/')) {
38
+		if (!is_dir($appPath.'/l10n/')) {
39 39
 			return [];
40 40
 		}
41 41
 
42 42
 		$errors = [];
43
-		$directory = new \DirectoryIterator($appPath . '/l10n/');
43
+		$directory = new \DirectoryIterator($appPath.'/l10n/');
44 44
 
45 45
 		foreach ($directory as $file) {
46 46
 			if ($file->getExtension() !== 'json') {
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 			json_decode($content, true);
52 52
 
53 53
 			if (json_last_error() !== JSON_ERROR_NONE) {
54
-				$errors[] = 'Invalid language file found: l10n/' . $file->getFilename() . ': ' . json_last_error_msg();
54
+				$errors[] = 'Invalid language file found: l10n/'.$file->getFilename().': '.json_last_error_msg();
55 55
 			}
56 56
 		}
57 57
 
Please login to merge, or discard this patch.
apps/files_external/lib/Command/Import.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 			$json = file_get_contents('php://stdin');
113 113
 		} else {
114 114
 			if (!file_exists($path)) {
115
-				$output->writeln('<error>File not found: ' . $path . '</error>');
115
+				$output->writeln('<error>File not found: '.$path.'</error>');
116 116
 				return 1;
117 117
 			}
118 118
 			$json = file_get_contents($path);
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 					$existingMount->getApplicableUsers() === $mount->getApplicableUsers() &&
165 165
 					$existingMount->getBackendOptions() === $mount->getBackendOptions()
166 166
 				) {
167
-					$output->writeln("<error>Duplicate mount (" . $mount->getMountPoint() . ")</error>");
167
+					$output->writeln("<error>Duplicate mount (".$mount->getMountPoint().")</error>");
168 168
 					return 1;
169 169
 				}
170 170
 			}
Please login to merge, or discard this patch.
Indentation   +183 added lines, -183 removed lines patch added patch discarded remove patch
@@ -39,187 +39,187 @@
 block discarded – undo
39 39
 use Symfony\Component\Console\Output\OutputInterface;
40 40
 
41 41
 class Import extends Base {
42
-	/**
43
-	 * @var GlobalStoragesService
44
-	 */
45
-	private $globalService;
46
-
47
-	/**
48
-	 * @var UserStoragesService
49
-	 */
50
-	private $userService;
51
-
52
-	/**
53
-	 * @var IUserSession
54
-	 */
55
-	private $userSession;
56
-
57
-	/**
58
-	 * @var IUserManager
59
-	 */
60
-	private $userManager;
61
-
62
-	/** @var ImportLegacyStoragesService */
63
-	private $importLegacyStorageService;
64
-
65
-	/** @var BackendService */
66
-	private $backendService;
67
-
68
-	function __construct(GlobalStoragesService $globalService,
69
-						 UserStoragesService $userService,
70
-						 IUserSession $userSession,
71
-						 IUserManager $userManager,
72
-						 ImportLegacyStoragesService $importLegacyStorageService,
73
-						 BackendService $backendService
74
-	) {
75
-		parent::__construct();
76
-		$this->globalService = $globalService;
77
-		$this->userService = $userService;
78
-		$this->userSession = $userSession;
79
-		$this->userManager = $userManager;
80
-		$this->importLegacyStorageService = $importLegacyStorageService;
81
-		$this->backendService = $backendService;
82
-	}
83
-
84
-	protected function configure() {
85
-		$this
86
-			->setName('files_external:import')
87
-			->setDescription('Import mount configurations')
88
-			->addOption(
89
-				'user',
90
-				'',
91
-				InputOption::VALUE_OPTIONAL,
92
-				'user to add the mount configurations for, if not set the mount will be added as system mount'
93
-			)
94
-			->addArgument(
95
-				'path',
96
-				InputArgument::REQUIRED,
97
-				'path to a json file containing the mounts to import, use "-" to read from stdin'
98
-			)
99
-			->addOption(
100
-				'dry',
101
-				'',
102
-				InputOption::VALUE_NONE,
103
-				'Don\'t save the imported mounts, only list the new mounts'
104
-			);
105
-		parent::configure();
106
-	}
107
-
108
-	protected function execute(InputInterface $input, OutputInterface $output) {
109
-		$user = $input->getOption('user');
110
-		$path = $input->getArgument('path');
111
-		if ($path === '-') {
112
-			$json = file_get_contents('php://stdin');
113
-		} else {
114
-			if (!file_exists($path)) {
115
-				$output->writeln('<error>File not found: ' . $path . '</error>');
116
-				return 1;
117
-			}
118
-			$json = file_get_contents($path);
119
-		}
120
-		if (!is_string($json) || strlen($json) < 2) {
121
-			$output->writeln('<error>Error while reading json</error>');
122
-			return 1;
123
-		}
124
-		$data = json_decode($json, true);
125
-		if (!is_array($data)) {
126
-			$output->writeln('<error>Error while parsing json</error>');
127
-			return 1;
128
-		}
129
-
130
-		$isLegacy = isset($data['user']) || isset($data['group']);
131
-		if ($isLegacy) {
132
-			$this->importLegacyStorageService->setData($data);
133
-			$mounts = $this->importLegacyStorageService->getAllStorages();
134
-			foreach ($mounts as $mount) {
135
-				if ($mount->getBackendOption('password') === false) {
136
-					$output->writeln('<error>Failed to decrypt password</error>');
137
-					return 1;
138
-				}
139
-			}
140
-		} else {
141
-			if (!isset($data[0])) { //normalize to an array of mounts
142
-				$data = [$data];
143
-			}
144
-			$mounts = array_map([$this, 'parseData'], $data);
145
-		}
146
-
147
-		if ($user) {
148
-			// ensure applicables are correct for personal mounts
149
-			foreach ($mounts as $mount) {
150
-				$mount->setApplicableGroups([]);
151
-				$mount->setApplicableUsers([$user]);
152
-			}
153
-		}
154
-
155
-		$storageService = $this->getStorageService($user);
156
-
157
-		$existingMounts = $storageService->getAllStorages();
158
-
159
-		foreach ($mounts as $mount) {
160
-			foreach ($existingMounts as $existingMount) {
161
-				if (
162
-					$existingMount->getMountPoint() === $mount->getMountPoint() &&
163
-					$existingMount->getApplicableGroups() === $mount->getApplicableGroups() &&
164
-					$existingMount->getApplicableUsers() === $mount->getApplicableUsers() &&
165
-					$existingMount->getBackendOptions() === $mount->getBackendOptions()
166
-				) {
167
-					$output->writeln("<error>Duplicate mount (" . $mount->getMountPoint() . ")</error>");
168
-					return 1;
169
-				}
170
-			}
171
-		}
172
-
173
-		if ($input->getOption('dry')) {
174
-			if (count($mounts) === 0) {
175
-				$output->writeln('<error>No mounts to be imported</error>');
176
-				return 1;
177
-			}
178
-			$listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
179
-			$listInput = new ArrayInput([], $listCommand->getDefinition());
180
-			$listInput->setOption('output', $input->getOption('output'));
181
-			$listInput->setOption('show-password', true);
182
-			$listCommand->listMounts($user, $mounts, $listInput, $output);
183
-		} else {
184
-			foreach ($mounts as $mount) {
185
-				$storageService->addStorage($mount);
186
-			}
187
-		}
188
-		return 0;
189
-	}
190
-
191
-	private function parseData(array $data) {
192
-		$mount = new StorageConfig($data['mount_id']);
193
-		$mount->setMountPoint($data['mount_point']);
194
-		$mount->setBackend($this->getBackendByClass($data['storage']));
195
-		$authBackend = $this->backendService->getAuthMechanism($data['authentication_type']);
196
-		$mount->setAuthMechanism($authBackend);
197
-		$mount->setBackendOptions($data['configuration']);
198
-		$mount->setMountOptions($data['options']);
199
-		$mount->setApplicableUsers(isset($data['applicable_users']) ? $data['applicable_users'] : []);
200
-		$mount->setApplicableGroups(isset($data['applicable_groups']) ? $data['applicable_groups'] : []);
201
-		return $mount;
202
-	}
203
-
204
-	private function getBackendByClass($className) {
205
-		$backends = $this->backendService->getBackends();
206
-		foreach ($backends as $backend) {
207
-			if ($backend->getStorageClass() === $className) {
208
-				return $backend;
209
-			}
210
-		}
211
-	}
212
-
213
-	protected function getStorageService($userId) {
214
-		if (!empty($userId)) {
215
-			$user = $this->userManager->get($userId);
216
-			if (is_null($user)) {
217
-				throw new NoUserException("user $userId not found");
218
-			}
219
-			$this->userSession->setUser($user);
220
-			return $this->userService;
221
-		} else {
222
-			return $this->globalService;
223
-		}
224
-	}
42
+    /**
43
+     * @var GlobalStoragesService
44
+     */
45
+    private $globalService;
46
+
47
+    /**
48
+     * @var UserStoragesService
49
+     */
50
+    private $userService;
51
+
52
+    /**
53
+     * @var IUserSession
54
+     */
55
+    private $userSession;
56
+
57
+    /**
58
+     * @var IUserManager
59
+     */
60
+    private $userManager;
61
+
62
+    /** @var ImportLegacyStoragesService */
63
+    private $importLegacyStorageService;
64
+
65
+    /** @var BackendService */
66
+    private $backendService;
67
+
68
+    function __construct(GlobalStoragesService $globalService,
69
+                            UserStoragesService $userService,
70
+                            IUserSession $userSession,
71
+                            IUserManager $userManager,
72
+                            ImportLegacyStoragesService $importLegacyStorageService,
73
+                            BackendService $backendService
74
+    ) {
75
+        parent::__construct();
76
+        $this->globalService = $globalService;
77
+        $this->userService = $userService;
78
+        $this->userSession = $userSession;
79
+        $this->userManager = $userManager;
80
+        $this->importLegacyStorageService = $importLegacyStorageService;
81
+        $this->backendService = $backendService;
82
+    }
83
+
84
+    protected function configure() {
85
+        $this
86
+            ->setName('files_external:import')
87
+            ->setDescription('Import mount configurations')
88
+            ->addOption(
89
+                'user',
90
+                '',
91
+                InputOption::VALUE_OPTIONAL,
92
+                'user to add the mount configurations for, if not set the mount will be added as system mount'
93
+            )
94
+            ->addArgument(
95
+                'path',
96
+                InputArgument::REQUIRED,
97
+                'path to a json file containing the mounts to import, use "-" to read from stdin'
98
+            )
99
+            ->addOption(
100
+                'dry',
101
+                '',
102
+                InputOption::VALUE_NONE,
103
+                'Don\'t save the imported mounts, only list the new mounts'
104
+            );
105
+        parent::configure();
106
+    }
107
+
108
+    protected function execute(InputInterface $input, OutputInterface $output) {
109
+        $user = $input->getOption('user');
110
+        $path = $input->getArgument('path');
111
+        if ($path === '-') {
112
+            $json = file_get_contents('php://stdin');
113
+        } else {
114
+            if (!file_exists($path)) {
115
+                $output->writeln('<error>File not found: ' . $path . '</error>');
116
+                return 1;
117
+            }
118
+            $json = file_get_contents($path);
119
+        }
120
+        if (!is_string($json) || strlen($json) < 2) {
121
+            $output->writeln('<error>Error while reading json</error>');
122
+            return 1;
123
+        }
124
+        $data = json_decode($json, true);
125
+        if (!is_array($data)) {
126
+            $output->writeln('<error>Error while parsing json</error>');
127
+            return 1;
128
+        }
129
+
130
+        $isLegacy = isset($data['user']) || isset($data['group']);
131
+        if ($isLegacy) {
132
+            $this->importLegacyStorageService->setData($data);
133
+            $mounts = $this->importLegacyStorageService->getAllStorages();
134
+            foreach ($mounts as $mount) {
135
+                if ($mount->getBackendOption('password') === false) {
136
+                    $output->writeln('<error>Failed to decrypt password</error>');
137
+                    return 1;
138
+                }
139
+            }
140
+        } else {
141
+            if (!isset($data[0])) { //normalize to an array of mounts
142
+                $data = [$data];
143
+            }
144
+            $mounts = array_map([$this, 'parseData'], $data);
145
+        }
146
+
147
+        if ($user) {
148
+            // ensure applicables are correct for personal mounts
149
+            foreach ($mounts as $mount) {
150
+                $mount->setApplicableGroups([]);
151
+                $mount->setApplicableUsers([$user]);
152
+            }
153
+        }
154
+
155
+        $storageService = $this->getStorageService($user);
156
+
157
+        $existingMounts = $storageService->getAllStorages();
158
+
159
+        foreach ($mounts as $mount) {
160
+            foreach ($existingMounts as $existingMount) {
161
+                if (
162
+                    $existingMount->getMountPoint() === $mount->getMountPoint() &&
163
+                    $existingMount->getApplicableGroups() === $mount->getApplicableGroups() &&
164
+                    $existingMount->getApplicableUsers() === $mount->getApplicableUsers() &&
165
+                    $existingMount->getBackendOptions() === $mount->getBackendOptions()
166
+                ) {
167
+                    $output->writeln("<error>Duplicate mount (" . $mount->getMountPoint() . ")</error>");
168
+                    return 1;
169
+                }
170
+            }
171
+        }
172
+
173
+        if ($input->getOption('dry')) {
174
+            if (count($mounts) === 0) {
175
+                $output->writeln('<error>No mounts to be imported</error>');
176
+                return 1;
177
+            }
178
+            $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
179
+            $listInput = new ArrayInput([], $listCommand->getDefinition());
180
+            $listInput->setOption('output', $input->getOption('output'));
181
+            $listInput->setOption('show-password', true);
182
+            $listCommand->listMounts($user, $mounts, $listInput, $output);
183
+        } else {
184
+            foreach ($mounts as $mount) {
185
+                $storageService->addStorage($mount);
186
+            }
187
+        }
188
+        return 0;
189
+    }
190
+
191
+    private function parseData(array $data) {
192
+        $mount = new StorageConfig($data['mount_id']);
193
+        $mount->setMountPoint($data['mount_point']);
194
+        $mount->setBackend($this->getBackendByClass($data['storage']));
195
+        $authBackend = $this->backendService->getAuthMechanism($data['authentication_type']);
196
+        $mount->setAuthMechanism($authBackend);
197
+        $mount->setBackendOptions($data['configuration']);
198
+        $mount->setMountOptions($data['options']);
199
+        $mount->setApplicableUsers(isset($data['applicable_users']) ? $data['applicable_users'] : []);
200
+        $mount->setApplicableGroups(isset($data['applicable_groups']) ? $data['applicable_groups'] : []);
201
+        return $mount;
202
+    }
203
+
204
+    private function getBackendByClass($className) {
205
+        $backends = $this->backendService->getBackends();
206
+        foreach ($backends as $backend) {
207
+            if ($backend->getStorageClass() === $className) {
208
+                return $backend;
209
+            }
210
+        }
211
+    }
212
+
213
+    protected function getStorageService($userId) {
214
+        if (!empty($userId)) {
215
+            $user = $this->userManager->get($userId);
216
+            if (is_null($user)) {
217
+                throw new NoUserException("user $userId not found");
218
+            }
219
+            $this->userSession->setUser($user);
220
+            return $this->userService;
221
+        } else {
222
+            return $this->globalService;
223
+        }
224
+    }
225 225
 }
Please login to merge, or discard this patch.