Completed
Push — stable9 ( 11047b...318578 )
by Lukas
20:03 queued 09:36
created
apps/files_sharing/lib/share/file.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	public function generateTarget($filePath, $shareWith, $exclude = null) {
98 98
 		$shareFolder = \OCA\Files_Sharing\Helper::getShareFolder();
99
-		$target = \OC\Files\Filesystem::normalizePath($shareFolder . '/' . basename($filePath));
99
+		$target = \OC\Files\Filesystem::normalizePath($shareFolder.'/'.basename($filePath));
100 100
 
101 101
 		// for group shares we return the target right away
102 102
 		if ($shareWith === false) {
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
 		}
105 105
 
106 106
 		\OC\Files\Filesystem::initMountPoints($shareWith);
107
-		$view = new \OC\Files\View('/' . $shareWith . '/files');
107
+		$view = new \OC\Files\View('/'.$shareWith.'/files');
108 108
 
109 109
 		if (!$view->is_dir($shareFolder)) {
110 110
 			$dir = '';
111 111
 			$subdirs = explode('/', $shareFolder);
112 112
 			foreach ($subdirs as $subdir) {
113
-				$dir = $dir . '/' . $subdir;
113
+				$dir = $dir.'/'.$subdir;
114 114
 				if (!$view->is_dir($dir)) {
115 115
 					$view->mkdir($dir);
116 116
 				}
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 		if ($share['item_type'] === 'folder' && $target !== '') {
238 238
 			// note: in case of ext storage mount points the path might be empty
239 239
 			// which would cause a leading slash to appear
240
-			$share['path'] = ltrim($share['path'] . '/' . $target, '/');
240
+			$share['path'] = ltrim($share['path'].'/'.$target, '/');
241 241
 		}
242 242
 		return self::resolveReshares($share);
243 243
 	}
Please login to merge, or discard this patch.
Indentation   +192 added lines, -192 removed lines patch added patch discarded remove patch
@@ -31,196 +31,196 @@
 block discarded – undo
31 31
 
32 32
 class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
33 33
 
34
-	const FORMAT_SHARED_STORAGE = 0;
35
-	const FORMAT_GET_FOLDER_CONTENTS = 1;
36
-	const FORMAT_FILE_APP_ROOT = 2;
37
-	const FORMAT_OPENDIR = 3;
38
-	const FORMAT_GET_ALL = 4;
39
-	const FORMAT_PERMISSIONS = 5;
40
-	const FORMAT_TARGET_NAMES = 6;
41
-
42
-	private $path;
43
-
44
-	public function isValidSource($itemSource, $uidOwner) {
45
-		try {
46
-			$path = \OC\Files\Filesystem::getPath($itemSource);
47
-			// FIXME: attributes should not be set here,
48
-			// keeping this pattern for now to avoid unexpected
49
-			// regressions
50
-			$this->path = \OC\Files\Filesystem::normalizePath(basename($path));
51
-			return true;
52
-		} catch (\OCP\Files\NotFoundException $e) {
53
-			return false;
54
-		}
55
-	}
56
-
57
-	public function getFilePath($itemSource, $uidOwner) {
58
-		if (isset($this->path)) {
59
-			$path = $this->path;
60
-			$this->path = null;
61
-			return $path;
62
-		} else {
63
-			try {
64
-				$path = \OC\Files\Filesystem::getPath($itemSource);
65
-				return $path;
66
-			} catch (\OCP\Files\NotFoundException $e) {
67
-				return false;
68
-			}
69
-		}
70
-	}
71
-
72
-	/**
73
-	 * create unique target
74
-	 * @param string $filePath
75
-	 * @param string $shareWith
76
-	 * @param array $exclude (optional)
77
-	 * @return string
78
-	 */
79
-	public function generateTarget($filePath, $shareWith, $exclude = null) {
80
-		$shareFolder = \OCA\Files_Sharing\Helper::getShareFolder();
81
-		$target = \OC\Files\Filesystem::normalizePath($shareFolder . '/' . basename($filePath));
82
-
83
-		// for group shares we return the target right away
84
-		if ($shareWith === false) {
85
-			return $target;
86
-		}
87
-
88
-		\OC\Files\Filesystem::initMountPoints($shareWith);
89
-		$view = new \OC\Files\View('/' . $shareWith . '/files');
90
-
91
-		if (!$view->is_dir($shareFolder)) {
92
-			$dir = '';
93
-			$subdirs = explode('/', $shareFolder);
94
-			foreach ($subdirs as $subdir) {
95
-				$dir = $dir . '/' . $subdir;
96
-				if (!$view->is_dir($dir)) {
97
-					$view->mkdir($dir);
98
-				}
99
-			}
100
-		}
101
-
102
-		$excludeList = (is_array($exclude)) ? $exclude : array();
103
-
104
-		return \OCA\Files_Sharing\Helper::generateUniqueTarget($target, $excludeList, $view);
105
-	}
106
-
107
-	public function formatItems($items, $format, $parameters = null) {
108
-		if ($format == self::FORMAT_SHARED_STORAGE) {
109
-			// Only 1 item should come through for this format call
110
-			$item = array_shift($items);
111
-			return array(
112
-				'parent' => $item['parent'],
113
-				'path' => $item['path'],
114
-				'storage' => $item['storage'],
115
-				'permissions' => $item['permissions'],
116
-				'uid_owner' => $item['uid_owner'],
117
-			);
118
-		} else if ($format == self::FORMAT_GET_FOLDER_CONTENTS) {
119
-			$files = array();
120
-			foreach ($items as $item) {
121
-				$file = array();
122
-				$file['fileid'] = $item['file_source'];
123
-				$file['storage'] = $item['storage'];
124
-				$file['path'] = $item['file_target'];
125
-				$file['parent'] = $item['file_parent'];
126
-				$file['name'] = basename($item['file_target']);
127
-				$file['mimetype'] = $item['mimetype'];
128
-				$file['mimepart'] = $item['mimepart'];
129
-				$file['mtime'] = $item['mtime'];
130
-				$file['encrypted'] = $item['encrypted'];
131
-				$file['etag'] = $item['etag'];
132
-				$file['uid_owner'] = $item['uid_owner'];
133
-				$file['displayname_owner'] = $item['displayname_owner'];
134
-
135
-				$storage = \OC\Files\Filesystem::getStorage('/');
136
-				$cache = $storage->getCache();
137
-				$file['size'] = $item['size'];
138
-				$files[] = $file;
139
-			}
140
-			return $files;
141
-		} else if ($format == self::FORMAT_OPENDIR) {
142
-			$files = array();
143
-			foreach ($items as $item) {
144
-				$files[] = basename($item['file_target']);
145
-			}
146
-			return $files;
147
-		} else if ($format == self::FORMAT_GET_ALL) {
148
-			$ids = array();
149
-			foreach ($items as $item) {
150
-				$ids[] = $item['file_source'];
151
-			}
152
-			return $ids;
153
-		} else if ($format === self::FORMAT_PERMISSIONS) {
154
-			$filePermissions = array();
155
-			foreach ($items as $item) {
156
-				$filePermissions[$item['file_source']] = $item['permissions'];
157
-			}
158
-			return $filePermissions;
159
-		} else if ($format === self::FORMAT_TARGET_NAMES) {
160
-			$targets = array();
161
-			foreach ($items as $item) {
162
-				$targets[] = $item['file_target'];
163
-			}
164
-			return $targets;
165
-		}
166
-		return array();
167
-	}
168
-
169
-	/**
170
-	 * check if server2server share is enabled
171
-	 *
172
-	 * @param int $shareType
173
-	 * @return boolean
174
-	 */
175
-	public function isShareTypeAllowed($shareType) {
176
-		if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE) {
177
-			return \OCA\Files_Sharing\Helper::isOutgoingServer2serverShareEnabled();
178
-		}
179
-
180
-		return true;
181
-	}
182
-
183
-	/**
184
-	 * resolve reshares to return the correct source item
185
-	 * @param array $source
186
-	 * @return array source item
187
-	 */
188
-	protected static function resolveReshares($source) {
189
-		if (isset($source['parent'])) {
190
-			$parent = $source['parent'];
191
-			while (isset($parent)) {
192
-				$query = \OCP\DB::prepare('SELECT `parent`, `uid_owner` FROM `*PREFIX*share` WHERE `id` = ?', 1);
193
-				$item = $query->execute(array($parent))->fetchRow();
194
-				if (isset($item['parent'])) {
195
-					$parent = $item['parent'];
196
-				} else {
197
-					$fileOwner = $item['uid_owner'];
198
-					break;
199
-				}
200
-			}
201
-		} else {
202
-			$fileOwner = $source['uid_owner'];
203
-		}
204
-		if (isset($fileOwner)) {
205
-			$source['fileOwner'] = $fileOwner;
206
-		} else {
207
-			\OCP\Util::writeLog('files_sharing', "No owner found for reshare", \OCP\Util::ERROR);
208
-		}
209
-
210
-		return $source;
211
-	}
212
-
213
-	/**
214
-	 * @param string $target
215
-	 * @param array $share
216
-	 * @return array|false source item
217
-	 */
218
-	public static function getSource($target, $share) {
219
-		if ($share['item_type'] === 'folder' && $target !== '') {
220
-			// note: in case of ext storage mount points the path might be empty
221
-			// which would cause a leading slash to appear
222
-			$share['path'] = ltrim($share['path'] . '/' . $target, '/');
223
-		}
224
-		return self::resolveReshares($share);
225
-	}
34
+    const FORMAT_SHARED_STORAGE = 0;
35
+    const FORMAT_GET_FOLDER_CONTENTS = 1;
36
+    const FORMAT_FILE_APP_ROOT = 2;
37
+    const FORMAT_OPENDIR = 3;
38
+    const FORMAT_GET_ALL = 4;
39
+    const FORMAT_PERMISSIONS = 5;
40
+    const FORMAT_TARGET_NAMES = 6;
41
+
42
+    private $path;
43
+
44
+    public function isValidSource($itemSource, $uidOwner) {
45
+        try {
46
+            $path = \OC\Files\Filesystem::getPath($itemSource);
47
+            // FIXME: attributes should not be set here,
48
+            // keeping this pattern for now to avoid unexpected
49
+            // regressions
50
+            $this->path = \OC\Files\Filesystem::normalizePath(basename($path));
51
+            return true;
52
+        } catch (\OCP\Files\NotFoundException $e) {
53
+            return false;
54
+        }
55
+    }
56
+
57
+    public function getFilePath($itemSource, $uidOwner) {
58
+        if (isset($this->path)) {
59
+            $path = $this->path;
60
+            $this->path = null;
61
+            return $path;
62
+        } else {
63
+            try {
64
+                $path = \OC\Files\Filesystem::getPath($itemSource);
65
+                return $path;
66
+            } catch (\OCP\Files\NotFoundException $e) {
67
+                return false;
68
+            }
69
+        }
70
+    }
71
+
72
+    /**
73
+     * create unique target
74
+     * @param string $filePath
75
+     * @param string $shareWith
76
+     * @param array $exclude (optional)
77
+     * @return string
78
+     */
79
+    public function generateTarget($filePath, $shareWith, $exclude = null) {
80
+        $shareFolder = \OCA\Files_Sharing\Helper::getShareFolder();
81
+        $target = \OC\Files\Filesystem::normalizePath($shareFolder . '/' . basename($filePath));
82
+
83
+        // for group shares we return the target right away
84
+        if ($shareWith === false) {
85
+            return $target;
86
+        }
87
+
88
+        \OC\Files\Filesystem::initMountPoints($shareWith);
89
+        $view = new \OC\Files\View('/' . $shareWith . '/files');
90
+
91
+        if (!$view->is_dir($shareFolder)) {
92
+            $dir = '';
93
+            $subdirs = explode('/', $shareFolder);
94
+            foreach ($subdirs as $subdir) {
95
+                $dir = $dir . '/' . $subdir;
96
+                if (!$view->is_dir($dir)) {
97
+                    $view->mkdir($dir);
98
+                }
99
+            }
100
+        }
101
+
102
+        $excludeList = (is_array($exclude)) ? $exclude : array();
103
+
104
+        return \OCA\Files_Sharing\Helper::generateUniqueTarget($target, $excludeList, $view);
105
+    }
106
+
107
+    public function formatItems($items, $format, $parameters = null) {
108
+        if ($format == self::FORMAT_SHARED_STORAGE) {
109
+            // Only 1 item should come through for this format call
110
+            $item = array_shift($items);
111
+            return array(
112
+                'parent' => $item['parent'],
113
+                'path' => $item['path'],
114
+                'storage' => $item['storage'],
115
+                'permissions' => $item['permissions'],
116
+                'uid_owner' => $item['uid_owner'],
117
+            );
118
+        } else if ($format == self::FORMAT_GET_FOLDER_CONTENTS) {
119
+            $files = array();
120
+            foreach ($items as $item) {
121
+                $file = array();
122
+                $file['fileid'] = $item['file_source'];
123
+                $file['storage'] = $item['storage'];
124
+                $file['path'] = $item['file_target'];
125
+                $file['parent'] = $item['file_parent'];
126
+                $file['name'] = basename($item['file_target']);
127
+                $file['mimetype'] = $item['mimetype'];
128
+                $file['mimepart'] = $item['mimepart'];
129
+                $file['mtime'] = $item['mtime'];
130
+                $file['encrypted'] = $item['encrypted'];
131
+                $file['etag'] = $item['etag'];
132
+                $file['uid_owner'] = $item['uid_owner'];
133
+                $file['displayname_owner'] = $item['displayname_owner'];
134
+
135
+                $storage = \OC\Files\Filesystem::getStorage('/');
136
+                $cache = $storage->getCache();
137
+                $file['size'] = $item['size'];
138
+                $files[] = $file;
139
+            }
140
+            return $files;
141
+        } else if ($format == self::FORMAT_OPENDIR) {
142
+            $files = array();
143
+            foreach ($items as $item) {
144
+                $files[] = basename($item['file_target']);
145
+            }
146
+            return $files;
147
+        } else if ($format == self::FORMAT_GET_ALL) {
148
+            $ids = array();
149
+            foreach ($items as $item) {
150
+                $ids[] = $item['file_source'];
151
+            }
152
+            return $ids;
153
+        } else if ($format === self::FORMAT_PERMISSIONS) {
154
+            $filePermissions = array();
155
+            foreach ($items as $item) {
156
+                $filePermissions[$item['file_source']] = $item['permissions'];
157
+            }
158
+            return $filePermissions;
159
+        } else if ($format === self::FORMAT_TARGET_NAMES) {
160
+            $targets = array();
161
+            foreach ($items as $item) {
162
+                $targets[] = $item['file_target'];
163
+            }
164
+            return $targets;
165
+        }
166
+        return array();
167
+    }
168
+
169
+    /**
170
+     * check if server2server share is enabled
171
+     *
172
+     * @param int $shareType
173
+     * @return boolean
174
+     */
175
+    public function isShareTypeAllowed($shareType) {
176
+        if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE) {
177
+            return \OCA\Files_Sharing\Helper::isOutgoingServer2serverShareEnabled();
178
+        }
179
+
180
+        return true;
181
+    }
182
+
183
+    /**
184
+     * resolve reshares to return the correct source item
185
+     * @param array $source
186
+     * @return array source item
187
+     */
188
+    protected static function resolveReshares($source) {
189
+        if (isset($source['parent'])) {
190
+            $parent = $source['parent'];
191
+            while (isset($parent)) {
192
+                $query = \OCP\DB::prepare('SELECT `parent`, `uid_owner` FROM `*PREFIX*share` WHERE `id` = ?', 1);
193
+                $item = $query->execute(array($parent))->fetchRow();
194
+                if (isset($item['parent'])) {
195
+                    $parent = $item['parent'];
196
+                } else {
197
+                    $fileOwner = $item['uid_owner'];
198
+                    break;
199
+                }
200
+            }
201
+        } else {
202
+            $fileOwner = $source['uid_owner'];
203
+        }
204
+        if (isset($fileOwner)) {
205
+            $source['fileOwner'] = $fileOwner;
206
+        } else {
207
+            \OCP\Util::writeLog('files_sharing', "No owner found for reshare", \OCP\Util::ERROR);
208
+        }
209
+
210
+        return $source;
211
+    }
212
+
213
+    /**
214
+     * @param string $target
215
+     * @param array $share
216
+     * @return array|false source item
217
+     */
218
+    public static function getSource($target, $share) {
219
+        if ($share['item_type'] === 'folder' && $target !== '') {
220
+            // note: in case of ext storage mount points the path might be empty
221
+            // which would cause a leading slash to appear
222
+            $share['path'] = ltrim($share['path'] . '/' . $target, '/');
223
+        }
224
+        return self::resolveReshares($share);
225
+    }
226 226
 }
Please login to merge, or discard this patch.
apps/files_sharing/appinfo/routes.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
 /** @var $this \OCP\Route\IRouter */
46 46
 $this->create('core_ajax_public_preview', '/publicpreview')->action(
47 47
 	function() {
48
-		require_once __DIR__ . '/../ajax/publicpreview.php';
48
+		require_once __DIR__.'/../ajax/publicpreview.php';
49 49
 	});
50 50
 
51 51
 $this->create('files_sharing_ajax_list', 'ajax/list.php')
Please login to merge, or discard this patch.
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -31,32 +31,32 @@  discard block
 block discarded – undo
31 31
 
32 32
 $application = new Application();
33 33
 $application->registerRoutes($this, [
34
-	'resources' => [
35
-		'ExternalShares' => ['url' => '/api/externalShares'],
36
-	],
37
-	'routes' => [
38
-		[
39
-			'name' => 'externalShares#testRemote',
40
-			'url' => '/testremote',
41
-			'verb' => 'GET'
42
-		],
43
-	],
34
+    'resources' => [
35
+        'ExternalShares' => ['url' => '/api/externalShares'],
36
+    ],
37
+    'routes' => [
38
+        [
39
+            'name' => 'externalShares#testRemote',
40
+            'url' => '/testremote',
41
+            'verb' => 'GET'
42
+        ],
43
+    ],
44 44
 ]);
45 45
 
46 46
 /** @var $this \OCP\Route\IRouter */
47 47
 $this->create('core_ajax_public_preview', '/publicpreview')->action(
48
-	function() {
49
-		require_once __DIR__ . '/../ajax/publicpreview.php';
50
-	});
48
+    function() {
49
+        require_once __DIR__ . '/../ajax/publicpreview.php';
50
+    });
51 51
 
52 52
 $this->create('files_sharing_ajax_list', 'ajax/list.php')
53
-	->actionInclude('files_sharing/ajax/list.php');
53
+    ->actionInclude('files_sharing/ajax/list.php');
54 54
 $this->create('files_sharing_ajax_publicpreview', 'ajax/publicpreview.php')
55
-	->actionInclude('files_sharing/ajax/publicpreview.php');
55
+    ->actionInclude('files_sharing/ajax/publicpreview.php');
56 56
 $this->create('sharing_external_shareinfo', '/shareinfo')
57
-	->actionInclude('files_sharing/ajax/shareinfo.php');
57
+    ->actionInclude('files_sharing/ajax/shareinfo.php');
58 58
 $this->create('sharing_external_add', '/external')
59
-	->actionInclude('files_sharing/ajax/external.php');
59
+    ->actionInclude('files_sharing/ajax/external.php');
60 60
 
61 61
 // OCS API
62 62
 
@@ -65,73 +65,73 @@  discard block
 block discarded – undo
65 65
 $OCSShare = new \OCA\Files_Sharing\API\OCSShareWrapper();
66 66
 
67 67
 API::register('get',
68
-		'/apps/files_sharing/api/v1/shares',
69
-		[$OCSShare, 'getAllShares'],
70
-		'files_sharing');
68
+        '/apps/files_sharing/api/v1/shares',
69
+        [$OCSShare, 'getAllShares'],
70
+        'files_sharing');
71 71
 
72 72
 API::register('post',
73
-		'/apps/files_sharing/api/v1/shares',
74
-		[$OCSShare, 'createShare'],
75
-		'files_sharing');
73
+        '/apps/files_sharing/api/v1/shares',
74
+        [$OCSShare, 'createShare'],
75
+        'files_sharing');
76 76
 
77 77
 API::register('get',
78
-		'/apps/files_sharing/api/v1/shares/{id}',
79
-		[$OCSShare, 'getShare'],
80
-		'files_sharing');
78
+        '/apps/files_sharing/api/v1/shares/{id}',
79
+        [$OCSShare, 'getShare'],
80
+        'files_sharing');
81 81
 
82 82
 API::register('put',
83
-		'/apps/files_sharing/api/v1/shares/{id}',
84
-		[$OCSShare, 'updateShare'],
85
-		'files_sharing');
83
+        '/apps/files_sharing/api/v1/shares/{id}',
84
+        [$OCSShare, 'updateShare'],
85
+        'files_sharing');
86 86
 
87 87
 API::register('delete',
88
-		'/apps/files_sharing/api/v1/shares/{id}',
89
-		[$OCSShare, 'deleteShare'],
90
-		'files_sharing');
88
+        '/apps/files_sharing/api/v1/shares/{id}',
89
+        [$OCSShare, 'deleteShare'],
90
+        'files_sharing');
91 91
 
92 92
 API::register('get',
93
-		'/apps/files_sharing/api/v1/remote_shares',
94
-		array('\OCA\Files_Sharing\API\Remote', 'getShares'),
95
-		'files_sharing');
93
+        '/apps/files_sharing/api/v1/remote_shares',
94
+        array('\OCA\Files_Sharing\API\Remote', 'getShares'),
95
+        'files_sharing');
96 96
 
97 97
 API::register('get',
98
-		'/apps/files_sharing/api/v1/remote_shares/pending',
99
-		array('\OCA\Files_Sharing\API\Remote', 'getOpenShares'),
100
-		'files_sharing');
98
+        '/apps/files_sharing/api/v1/remote_shares/pending',
99
+        array('\OCA\Files_Sharing\API\Remote', 'getOpenShares'),
100
+        'files_sharing');
101 101
 
102 102
 API::register('post',
103
-		'/apps/files_sharing/api/v1/remote_shares/pending/{id}',
104
-		array('\OCA\Files_Sharing\API\Remote', 'acceptShare'),
105
-		'files_sharing');
103
+        '/apps/files_sharing/api/v1/remote_shares/pending/{id}',
104
+        array('\OCA\Files_Sharing\API\Remote', 'acceptShare'),
105
+        'files_sharing');
106 106
 
107 107
 API::register('delete',
108
-		'/apps/files_sharing/api/v1/remote_shares/pending/{id}',
109
-		array('\OCA\Files_Sharing\API\Remote', 'declineShare'),
110
-		'files_sharing');
108
+        '/apps/files_sharing/api/v1/remote_shares/pending/{id}',
109
+        array('\OCA\Files_Sharing\API\Remote', 'declineShare'),
110
+        'files_sharing');
111 111
 
112 112
 API::register('get',
113
-		'/apps/files_sharing/api/v1/remote_shares/{id}',
114
-		array('\OCA\Files_Sharing\API\Remote', 'getShare'),
115
-		'files_sharing');
113
+        '/apps/files_sharing/api/v1/remote_shares/{id}',
114
+        array('\OCA\Files_Sharing\API\Remote', 'getShare'),
115
+        'files_sharing');
116 116
 
117 117
 API::register('delete',
118
-		'/apps/files_sharing/api/v1/remote_shares/{id}',
119
-		array('\OCA\Files_Sharing\API\Remote', 'unshare'),
120
-		'files_sharing');
118
+        '/apps/files_sharing/api/v1/remote_shares/{id}',
119
+        array('\OCA\Files_Sharing\API\Remote', 'unshare'),
120
+        'files_sharing');
121 121
 
122 122
 
123 123
 $sharees = new \OCA\Files_Sharing\API\Sharees(\OC::$server->getGroupManager(),
124
-                                              \OC::$server->getUserManager(),
125
-                                              \OC::$server->getContactsManager(),
126
-                                              \OC::$server->getConfig(),
127
-                                              \OC::$server->getUserSession(),
128
-                                              \OC::$server->getURLGenerator(),
129
-                                              \OC::$server->getRequest(),
130
-                                              \OC::$server->getLogger(),
131
-                                              \OC::$server->getShareManager());
124
+                                                \OC::$server->getUserManager(),
125
+                                                \OC::$server->getContactsManager(),
126
+                                                \OC::$server->getConfig(),
127
+                                                \OC::$server->getUserSession(),
128
+                                                \OC::$server->getURLGenerator(),
129
+                                                \OC::$server->getRequest(),
130
+                                                \OC::$server->getLogger(),
131
+                                                \OC::$server->getShareManager());
132 132
 
133 133
 API::register('get',
134
-		'/apps/files_sharing/api/v1/sharees',
135
-		[$sharees, 'search'],
136
-		'files_sharing', API::USER_AUTH);
134
+        '/apps/files_sharing/api/v1/sharees',
135
+        [$sharees, 'search'],
136
+        'files_sharing', API::USER_AUTH);
137 137
 
Please login to merge, or discard this patch.
apps/dav/templates/exception.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2
-	/** @var array $_ */
3
-	/** @var OC_L10N $l */
2
+    /** @var array $_ */
3
+    /** @var OC_L10N $l */
4 4
 
5 5
 style('core', ['styles', 'header']);
6 6
 ?>
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	<ul>
16 16
 		<li><?php p($l->t('Remote Address: %s', $_['remoteAddr'])) ?></li>
17 17
 		<li><?php p($l->t('Request ID: %s', $_['requestID'])) ?></li>
18
-		<?php if($_['debugMode']): ?>
18
+		<?php if ($_['debugMode']): ?>
19 19
 			<li><?php p($l->t('Type: %s', $_['errorClass'])) ?></li>
20 20
 			<li><?php p($l->t('Code: %s', $_['errorCode'])) ?></li>
21 21
 			<li><?php p($l->t('Message: %s', $_['errorMsg'])) ?></li>
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 		<?php endif; ?>
25 25
 	</ul>
26 26
 
27
-	<?php if($_['debugMode']): ?>
27
+	<?php if ($_['debugMode']): ?>
28 28
 		<br />
29 29
 		<h2><strong><?php p($l->t('Trace')) ?></strong></h2>
30 30
 		<pre><?php p($_['trace']) ?></pre>
Please login to merge, or discard this patch.
apps/dav/appinfo/app.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -29,27 +29,27 @@
 block discarded – undo
29 29
 $app->registerHooks();
30 30
 
31 31
 \OC::$server->registerService('CardDAVSyncService', function() use ($app) {
32
-	return $app->getSyncService();
32
+    return $app->getSyncService();
33 33
 });
34 34
 
35 35
 $eventDispatcher = \OC::$server->getEventDispatcher();
36 36
 
37 37
 $eventDispatcher->addListener('OCP\Federation\TrustedServerEvent::remove',
38
-	function(GenericEvent $event) use ($app) {
39
-		/** @var \OCA\DAV\CardDAV\CardDavBackend $cardDavBackend */
40
-		$cardDavBackend = $app->getContainer()->query('CardDavBackend');
41
-		$addressBookUri = $event->getSubject();
42
-		$addressBook = $cardDavBackend->getAddressBooksByUri('principals/system/system', $addressBookUri);
43
-		if (!is_null($addressBook)) {
44
-			$cardDavBackend->deleteAddressBook($addressBook['id']);
45
-		}
46
-	}
38
+    function(GenericEvent $event) use ($app) {
39
+        /** @var \OCA\DAV\CardDAV\CardDavBackend $cardDavBackend */
40
+        $cardDavBackend = $app->getContainer()->query('CardDavBackend');
41
+        $addressBookUri = $event->getSubject();
42
+        $addressBook = $cardDavBackend->getAddressBooksByUri('principals/system/system', $addressBookUri);
43
+        if (!is_null($addressBook)) {
44
+            $cardDavBackend->deleteAddressBook($addressBook['id']);
45
+        }
46
+    }
47 47
 );
48 48
 
49 49
 $cm = \OC::$server->getContactsManager();
50 50
 $cm->register(function() use ($cm, $app) {
51
-	$user = \OC::$server->getUserSession()->getUser();
52
-	if (!is_null($user)) {
53
-		$app->setupContactsProvider($cm, $user->getUID());
54
-	}
51
+    $user = \OC::$server->getUserSession()->getUser();
52
+    if (!is_null($user)) {
53
+        $app->setupContactsProvider($cm, $user->getUID());
54
+    }
55 55
 });
Please login to merge, or discard this patch.
apps/user_ldap/appinfo/routes.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -23,16 +23,16 @@
 block discarded – undo
23 23
 
24 24
 /** @var $this \OCP\Route\IRouter */
25 25
 $this->create('user_ldap_ajax_clearMappings', 'ajax/clearMappings.php')
26
-	->actionInclude('user_ldap/ajax/clearMappings.php');
26
+    ->actionInclude('user_ldap/ajax/clearMappings.php');
27 27
 $this->create('user_ldap_ajax_deleteConfiguration', 'ajax/deleteConfiguration.php')
28
-	->actionInclude('user_ldap/ajax/deleteConfiguration.php');
28
+    ->actionInclude('user_ldap/ajax/deleteConfiguration.php');
29 29
 $this->create('user_ldap_ajax_getConfiguration', 'ajax/getConfiguration.php')
30
-	->actionInclude('user_ldap/ajax/getConfiguration.php');
30
+    ->actionInclude('user_ldap/ajax/getConfiguration.php');
31 31
 $this->create('user_ldap_ajax_getNewServerConfigPrefix', 'ajax/getNewServerConfigPrefix.php')
32
-	->actionInclude('user_ldap/ajax/getNewServerConfigPrefix.php');
32
+    ->actionInclude('user_ldap/ajax/getNewServerConfigPrefix.php');
33 33
 $this->create('user_ldap_ajax_setConfiguration', 'ajax/setConfiguration.php')
34
-	->actionInclude('user_ldap/ajax/setConfiguration.php');
34
+    ->actionInclude('user_ldap/ajax/setConfiguration.php');
35 35
 $this->create('user_ldap_ajax_testConfiguration', 'ajax/testConfiguration.php')
36
-	->actionInclude('user_ldap/ajax/testConfiguration.php');
36
+    ->actionInclude('user_ldap/ajax/testConfiguration.php');
37 37
 $this->create('user_ldap_ajax_wizard', 'ajax/wizard.php')
38
-	->actionInclude('user_ldap/ajax/wizard.php');
38
+    ->actionInclude('user_ldap/ajax/wizard.php');
Please login to merge, or discard this patch.
apps/federation/appinfo/routes.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -23,26 +23,26 @@
 block discarded – undo
23 23
 $application = new \OCA\Federation\AppInfo\Application();
24 24
 
25 25
 $application->registerRoutes(
26
-	$this,
27
-	[
28
-		'routes' => [
29
-			[
30
-				'name' => 'Settings#addServer',
31
-				'url' => '/trusted-servers',
32
-				'verb' => 'POST'
33
-			],
34
-			[
35
-				'name' => 'Settings#removeServer',
36
-				'url' => '/trusted-servers/{id}',
37
-				'verb' => 'DELETE'
38
-			],
39
-			[
40
-				'name' => 'Settings#autoAddServers',
41
-				'url' => '/auto-add-servers',
42
-				'verb' => 'POST'
43
-			],
44
-		]
45
-	]
26
+    $this,
27
+    [
28
+        'routes' => [
29
+            [
30
+                'name' => 'Settings#addServer',
31
+                'url' => '/trusted-servers',
32
+                'verb' => 'POST'
33
+            ],
34
+            [
35
+                'name' => 'Settings#removeServer',
36
+                'url' => '/trusted-servers/{id}',
37
+                'verb' => 'DELETE'
38
+            ],
39
+            [
40
+                'name' => 'Settings#autoAddServers',
41
+                'url' => '/auto-add-servers',
42
+                'verb' => 'POST'
43
+            ],
44
+        ]
45
+    ]
46 46
 );
47 47
 
48 48
 $application->registerOCSApi();
Please login to merge, or discard this patch.
apps/admin_audit/lib/actions/trashbin.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -30,16 +30,16 @@
 block discarded – undo
30 30
 
31 31
 class Trashbin extends Action {
32 32
 
33
-	public function delete($params) {
34
-		$this->log('File "%s" deleted from trash bin.',
35
-			['path' => $params['path']], ['path']
36
-		);
37
-	}
38
-
39
-	public function restore($params) {
40
-		$this->log('File "%s" restored from trash bin.',
41
-			['path' => $params['filePath']], ['path']
42
-		);
43
-	}
33
+    public function delete($params) {
34
+        $this->log('File "%s" deleted from trash bin.',
35
+            ['path' => $params['path']], ['path']
36
+        );
37
+    }
38
+
39
+    public function restore($params) {
40
+        $this->log('File "%s" restored from trash bin.',
41
+            ['path' => $params['filePath']], ['path']
42
+        );
43
+    }
44 44
 
45 45
 }
Please login to merge, or discard this patch.
apps/files/ajax/upload.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
 if (empty($_POST['dirToken'])) {
51 51
 	// The standard case, files are uploaded through logged in users :)
52 52
 	OCP\JSON::checkLoggedIn();
53
-	$dir = isset($_POST['dir']) ? (string)$_POST['dir'] : '';
53
+	$dir = isset($_POST['dir']) ? (string) $_POST['dir'] : '';
54 54
 	if (!$dir || empty($dir) || $dir === false) {
55 55
 		OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('Unable to set upload directory.')))));
56 56
 		die();
57 57
 	}
58 58
 } else {
59 59
 	$shareManager = \OC::$server->getShareManager();
60
-	$share = $shareManager->getShareByToken((string)$_POST['dirToken']);
60
+	$share = $shareManager->getShareByToken((string) $_POST['dirToken']);
61 61
 
62 62
 	// TODO: ideally this code should be in files_sharing/ajax/upload.php
63 63
 	// and the upload/file transfer code needs to be refactored into a utility method
@@ -68,12 +68,12 @@  discard block
 block discarded – undo
68 68
 	// If it is a write-only folder no subdirectory can be specified
69 69
 	$publicDirectory = '';
70 70
 	if ($share->getPermissions() & \OCP\Constants::PERMISSION_READ) {
71
-		$publicDirectory = !empty($_POST['subdir']) ? (string)$_POST['subdir'] : '/';
71
+		$publicDirectory = !empty($_POST['subdir']) ? (string) $_POST['subdir'] : '/';
72 72
 	} else {
73 73
 		$_POST['file_directory'] = '';
74 74
 	}
75 75
 
76
-	$linkItem = OCP\Share::getShareByToken((string)$_POST['dirToken']);
76
+	$linkItem = OCP\Share::getShareByToken((string) $_POST['dirToken']);
77 77
 	if ($linkItem === false) {
78 78
 		OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('Invalid Token')))));
79 79
 		die();
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 
93 93
 		// The token defines the target directory (security reasons)
94 94
 		$path = \OC\Files\Filesystem::getPath($linkItem['file_source']);
95
-		if($path === null) {
95
+		if ($path === null) {
96 96
 			OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('Unable to set upload directory.')))));
97 97
 			die();
98 98
 		}
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 			$resolution = null;
173 173
 		}
174 174
 
175
-		if(isset($_POST['dirToken'])) {
175
+		if (isset($_POST['dirToken'])) {
176 176
 			// If it is a read only share the resolution will always be autorename
177 177
 			if (!($share->getPermissions() & \OCP\Constants::PERMISSION_READ)) {
178 178
 				$resolution = 'autorename';
@@ -181,25 +181,25 @@  discard block
 block discarded – undo
181 181
 
182 182
 		// target directory for when uploading folders
183 183
 		$relativePath = '';
184
-		if(!empty($_POST['file_directory'])) {
184
+		if (!empty($_POST['file_directory'])) {
185 185
 			$relativePath = '/'.$_POST['file_directory'];
186 186
 		}
187 187
 
188 188
 		// $path needs to be normalized - this failed within drag'n'drop upload to a sub-folder
189 189
 		if ($resolution === 'autorename') {
190 190
 			// append a number in brackets like 'filename (2).ext'
191
-			$target = OCP\Files::buildNotExistingFileName($dir . $relativePath, $files['name'][$i]);
191
+			$target = OCP\Files::buildNotExistingFileName($dir.$relativePath, $files['name'][$i]);
192 192
 		} else {
193
-			$target = \OC\Files\Filesystem::normalizePath($dir . $relativePath.'/'.$files['name'][$i]);
193
+			$target = \OC\Files\Filesystem::normalizePath($dir.$relativePath.'/'.$files['name'][$i]);
194 194
 		}
195 195
 
196 196
 		// relative dir to return to the client
197 197
 		if (isset($publicDirectory)) {
198 198
 			// path relative to the public root
199
-			$returnedDir = $publicDirectory . $relativePath;
199
+			$returnedDir = $publicDirectory.$relativePath;
200 200
 		} else {
201 201
 			// full path
202
-			$returnedDir = $dir . $relativePath;
202
+			$returnedDir = $dir.$relativePath;
203 203
 		}
204 204
 		$returnedDir = \OC\Files\Filesystem::normalizePath($returnedDir);
205 205
 
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 		if ($exists) {
209 209
 			$updatable = \OC\Files\Filesystem::isUpdatable($target);
210 210
 		}
211
-		if ( ! $exists || ($updatable && $resolution === 'replace' ) ) {
211
+		if (!$exists || ($updatable && $resolution === 'replace')) {
212 212
 			// upload and overwrite file
213 213
 			try
214 214
 			{
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 					$error = $l->t('Upload failed. Could not find uploaded file');
237 237
 					$errorFileName = $files['name'][$i];
238 238
 				}
239
-			} catch(Exception $ex) {
239
+			} catch (Exception $ex) {
240 240
 				$error = $ex->getMessage();
241 241
 			}
242 242
 
@@ -267,12 +267,12 @@  discard block
 block discarded – undo
267 267
 
268 268
 if ($error === false) {
269 269
 	// Do not leak file information if it is a read-only share
270
-	if(isset($_POST['dirToken'])) {
270
+	if (isset($_POST['dirToken'])) {
271 271
 		$shareManager = \OC::$server->getShareManager();
272
-		$share = $shareManager->getShareByToken((string)$_POST['dirToken']);
272
+		$share = $shareManager->getShareByToken((string) $_POST['dirToken']);
273 273
 		if (!($share->getPermissions() & \OCP\Constants::PERMISSION_READ)) {
274 274
 			$newResults = [];
275
-			foreach($result as $singleResult) {
275
+			foreach ($result as $singleResult) {
276 276
 				$fileName = $singleResult['originalname'];
277 277
 				$newResults['filename'] = $fileName;
278 278
 				$newResults['mimetype'] = \OC::$server->getMimeTypeDetector()->detectPath($fileName);
Please login to merge, or discard this patch.
Indentation   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -48,67 +48,67 @@  discard block
 block discarded – undo
48 48
 
49 49
 $l = \OC::$server->getL10N('files');
50 50
 if (empty($_POST['dirToken'])) {
51
-	// The standard case, files are uploaded through logged in users :)
52
-	OCP\JSON::checkLoggedIn();
53
-	$dir = isset($_POST['dir']) ? (string)$_POST['dir'] : '';
54
-	if (!$dir || empty($dir) || $dir === false) {
55
-		OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('Unable to set upload directory.')))));
56
-		die();
57
-	}
51
+    // The standard case, files are uploaded through logged in users :)
52
+    OCP\JSON::checkLoggedIn();
53
+    $dir = isset($_POST['dir']) ? (string)$_POST['dir'] : '';
54
+    if (!$dir || empty($dir) || $dir === false) {
55
+        OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('Unable to set upload directory.')))));
56
+        die();
57
+    }
58 58
 } else {
59
-	$shareManager = \OC::$server->getShareManager();
60
-	$share = $shareManager->getShareByToken((string)$_POST['dirToken']);
61
-
62
-	// TODO: ideally this code should be in files_sharing/ajax/upload.php
63
-	// and the upload/file transfer code needs to be refactored into a utility method
64
-	// that could be used there
65
-
66
-	\OC_User::setIncognitoMode(true);
67
-
68
-	// If it is a write-only folder no subdirectory can be specified
69
-	$publicDirectory = '';
70
-	if ($share->getPermissions() & \OCP\Constants::PERMISSION_READ) {
71
-		$publicDirectory = !empty($_POST['subdir']) ? (string)$_POST['subdir'] : '/';
72
-	} else {
73
-		$_POST['file_directory'] = '';
74
-	}
75
-
76
-	$linkItem = OCP\Share::getShareByToken((string)$_POST['dirToken']);
77
-	if ($linkItem === false) {
78
-		OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('Invalid Token')))));
79
-		die();
80
-	}
81
-
82
-	if (!($linkItem['permissions'] & \OCP\Constants::PERMISSION_CREATE)) {
83
-		OCP\JSON::checkLoggedIn();
84
-	} else {
85
-		// resolve reshares
86
-		$rootLinkItem = OCP\Share::resolveReShare($linkItem);
87
-
88
-		OCP\JSON::checkUserExists($rootLinkItem['uid_owner']);
89
-		// Setup FS with owner
90
-		OC_Util::tearDownFS();
91
-		OC_Util::setupFS($rootLinkItem['uid_owner']);
92
-
93
-		// The token defines the target directory (security reasons)
94
-		$path = \OC\Files\Filesystem::getPath($linkItem['file_source']);
95
-		if($path === null) {
96
-			OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('Unable to set upload directory.')))));
97
-			die();
98
-		}
99
-		$dir = sprintf(
100
-			"/%s/%s",
101
-			$path,
102
-			$publicDirectory
103
-		);
104
-
105
-		if (!$dir || empty($dir) || $dir === false) {
106
-			OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('Unable to set upload directory.')))));
107
-			die();
108
-		}
109
-
110
-		$dir = rtrim($dir, '/');
111
-	}
59
+    $shareManager = \OC::$server->getShareManager();
60
+    $share = $shareManager->getShareByToken((string)$_POST['dirToken']);
61
+
62
+    // TODO: ideally this code should be in files_sharing/ajax/upload.php
63
+    // and the upload/file transfer code needs to be refactored into a utility method
64
+    // that could be used there
65
+
66
+    \OC_User::setIncognitoMode(true);
67
+
68
+    // If it is a write-only folder no subdirectory can be specified
69
+    $publicDirectory = '';
70
+    if ($share->getPermissions() & \OCP\Constants::PERMISSION_READ) {
71
+        $publicDirectory = !empty($_POST['subdir']) ? (string)$_POST['subdir'] : '/';
72
+    } else {
73
+        $_POST['file_directory'] = '';
74
+    }
75
+
76
+    $linkItem = OCP\Share::getShareByToken((string)$_POST['dirToken']);
77
+    if ($linkItem === false) {
78
+        OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('Invalid Token')))));
79
+        die();
80
+    }
81
+
82
+    if (!($linkItem['permissions'] & \OCP\Constants::PERMISSION_CREATE)) {
83
+        OCP\JSON::checkLoggedIn();
84
+    } else {
85
+        // resolve reshares
86
+        $rootLinkItem = OCP\Share::resolveReShare($linkItem);
87
+
88
+        OCP\JSON::checkUserExists($rootLinkItem['uid_owner']);
89
+        // Setup FS with owner
90
+        OC_Util::tearDownFS();
91
+        OC_Util::setupFS($rootLinkItem['uid_owner']);
92
+
93
+        // The token defines the target directory (security reasons)
94
+        $path = \OC\Files\Filesystem::getPath($linkItem['file_source']);
95
+        if($path === null) {
96
+            OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('Unable to set upload directory.')))));
97
+            die();
98
+        }
99
+        $dir = sprintf(
100
+            "/%s/%s",
101
+            $path,
102
+            $publicDirectory
103
+        );
104
+
105
+        if (!$dir || empty($dir) || $dir === false) {
106
+            OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('Unable to set upload directory.')))));
107
+            die();
108
+        }
109
+
110
+        $dir = rtrim($dir, '/');
111
+    }
112 112
 }
113 113
 
114 114
 OCP\JSON::callCheck();
@@ -117,27 +117,27 @@  discard block
 block discarded – undo
117 117
 $storageStats = \OCA\Files\Helper::buildFileStorageStatistics($dir);
118 118
 
119 119
 if (!isset($_FILES['files'])) {
120
-	OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('No file was uploaded. Unknown error')), $storageStats)));
121
-	exit();
120
+    OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('No file was uploaded. Unknown error')), $storageStats)));
121
+    exit();
122 122
 }
123 123
 
124 124
 foreach ($_FILES['files']['error'] as $error) {
125
-	if ($error != 0) {
126
-		$errors = array(
127
-			UPLOAD_ERR_OK => $l->t('There is no error, the file uploaded with success'),
128
-			UPLOAD_ERR_INI_SIZE => $l->t('The uploaded file exceeds the upload_max_filesize directive in php.ini: ')
129
-			. OC::$server->getIniWrapper()->getNumeric('upload_max_filesize'),
130
-			UPLOAD_ERR_FORM_SIZE => $l->t('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'),
131
-			UPLOAD_ERR_PARTIAL => $l->t('The uploaded file was only partially uploaded'),
132
-			UPLOAD_ERR_NO_FILE => $l->t('No file was uploaded'),
133
-			UPLOAD_ERR_NO_TMP_DIR => $l->t('Missing a temporary folder'),
134
-			UPLOAD_ERR_CANT_WRITE => $l->t('Failed to write to disk'),
135
-		);
136
-		$errorMessage = $errors[$error];
137
-		\OC::$server->getLogger()->alert("Upload error: $error - $errorMessage", array('app' => 'files'));
138
-		OCP\JSON::error(array('data' => array_merge(array('message' => $errorMessage), $storageStats)));
139
-		exit();
140
-	}
125
+    if ($error != 0) {
126
+        $errors = array(
127
+            UPLOAD_ERR_OK => $l->t('There is no error, the file uploaded with success'),
128
+            UPLOAD_ERR_INI_SIZE => $l->t('The uploaded file exceeds the upload_max_filesize directive in php.ini: ')
129
+            . OC::$server->getIniWrapper()->getNumeric('upload_max_filesize'),
130
+            UPLOAD_ERR_FORM_SIZE => $l->t('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'),
131
+            UPLOAD_ERR_PARTIAL => $l->t('The uploaded file was only partially uploaded'),
132
+            UPLOAD_ERR_NO_FILE => $l->t('No file was uploaded'),
133
+            UPLOAD_ERR_NO_TMP_DIR => $l->t('Missing a temporary folder'),
134
+            UPLOAD_ERR_CANT_WRITE => $l->t('Failed to write to disk'),
135
+        );
136
+        $errorMessage = $errors[$error];
137
+        \OC::$server->getLogger()->alert("Upload error: $error - $errorMessage", array('app' => 'files'));
138
+        OCP\JSON::error(array('data' => array_merge(array('message' => $errorMessage), $storageStats)));
139
+        exit();
140
+    }
141 141
 }
142 142
 $files = $_FILES['files'];
143 143
 
@@ -150,142 +150,142 @@  discard block
 block discarded – undo
150 150
 $isReceivedShare = \OC::$server->getRequest()->getParam('isReceivedShare', false) === 'true';
151 151
 // defer quota check for received shares
152 152
 if (!$isReceivedShare && $storageStats['freeSpace'] >= 0) {
153
-	foreach ($files['size'] as $size) {
154
-		$totalSize += $size;
155
-	}
153
+    foreach ($files['size'] as $size) {
154
+        $totalSize += $size;
155
+    }
156 156
 }
157 157
 if ($maxUploadFileSize >= 0 and $totalSize > $maxUploadFileSize) {
158
-	OCP\JSON::error(array('data' => array('message' => $l->t('Not enough storage available'),
159
-		'uploadMaxFilesize' => $maxUploadFileSize,
160
-		'maxHumanFilesize' => $maxHumanFileSize)));
161
-	exit();
158
+    OCP\JSON::error(array('data' => array('message' => $l->t('Not enough storage available'),
159
+        'uploadMaxFilesize' => $maxUploadFileSize,
160
+        'maxHumanFilesize' => $maxHumanFileSize)));
161
+    exit();
162 162
 }
163 163
 
164 164
 $result = array();
165 165
 if (\OC\Files\Filesystem::isValidPath($dir) === true) {
166
-	$fileCount = count($files['name']);
167
-	for ($i = 0; $i < $fileCount; $i++) {
168
-
169
-		if (isset($_POST['resolution'])) {
170
-			$resolution = $_POST['resolution'];
171
-		} else {
172
-			$resolution = null;
173
-		}
174
-
175
-		if(isset($_POST['dirToken'])) {
176
-			// If it is a read only share the resolution will always be autorename
177
-			if (!($share->getPermissions() & \OCP\Constants::PERMISSION_READ)) {
178
-				$resolution = 'autorename';
179
-			}
180
-		}
181
-
182
-		// target directory for when uploading folders
183
-		$relativePath = '';
184
-		if(!empty($_POST['file_directory'])) {
185
-			$relativePath = '/'.$_POST['file_directory'];
186
-		}
187
-
188
-		// $path needs to be normalized - this failed within drag'n'drop upload to a sub-folder
189
-		if ($resolution === 'autorename') {
190
-			// append a number in brackets like 'filename (2).ext'
191
-			$target = OCP\Files::buildNotExistingFileName($dir . $relativePath, $files['name'][$i]);
192
-		} else {
193
-			$target = \OC\Files\Filesystem::normalizePath($dir . $relativePath.'/'.$files['name'][$i]);
194
-		}
195
-
196
-		// relative dir to return to the client
197
-		if (isset($publicDirectory)) {
198
-			// path relative to the public root
199
-			$returnedDir = $publicDirectory . $relativePath;
200
-		} else {
201
-			// full path
202
-			$returnedDir = $dir . $relativePath;
203
-		}
204
-		$returnedDir = \OC\Files\Filesystem::normalizePath($returnedDir);
205
-
206
-
207
-		$exists = \OC\Files\Filesystem::file_exists($target);
208
-		if ($exists) {
209
-			$updatable = \OC\Files\Filesystem::isUpdatable($target);
210
-		}
211
-		if ( ! $exists || ($updatable && $resolution === 'replace' ) ) {
212
-			// upload and overwrite file
213
-			try
214
-			{
215
-				if (is_uploaded_file($files['tmp_name'][$i]) and \OC\Files\Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
216
-
217
-					// updated max file size after upload
218
-					$storageStats = \OCA\Files\Helper::buildFileStorageStatistics($dir);
219
-
220
-					$meta = \OC\Files\Filesystem::getFileInfo($target);
221
-					if ($meta === false) {
222
-						$error = $l->t('The target folder has been moved or deleted.');
223
-						$errorCode = 'targetnotfound';
224
-					} else {
225
-						$data = \OCA\Files\Helper::formatFileInfo($meta);
226
-						$data['status'] = 'success';
227
-						$data['originalname'] = $files['name'][$i];
228
-						$data['uploadMaxFilesize'] = $maxUploadFileSize;
229
-						$data['maxHumanFilesize'] = $maxHumanFileSize;
230
-						$data['permissions'] = $meta['permissions'];
231
-						$data['directory'] = $returnedDir;
232
-						$result[] = $data;
233
-					}
234
-
235
-				} else {
236
-					$error = $l->t('Upload failed. Could not find uploaded file');
237
-					$errorFileName = $files['name'][$i];
238
-				}
239
-			} catch(Exception $ex) {
240
-				$error = $ex->getMessage();
241
-			}
242
-
243
-		} else {
244
-			// file already exists
245
-			$meta = \OC\Files\Filesystem::getFileInfo($target);
246
-			if ($meta === false) {
247
-				$error = $l->t('Upload failed. Could not get file info.');
248
-			} else {
249
-				$data = \OCA\Files\Helper::formatFileInfo($meta);
250
-				if ($updatable) {
251
-					$data['status'] = 'existserror';
252
-				} else {
253
-					$data['status'] = 'readonly';
254
-				}
255
-				$data['originalname'] = $files['name'][$i];
256
-				$data['uploadMaxFilesize'] = $maxUploadFileSize;
257
-				$data['maxHumanFilesize'] = $maxHumanFileSize;
258
-				$data['permissions'] = $meta['permissions'];
259
-				$data['directory'] = $returnedDir;
260
-				$result[] = $data;
261
-			}
262
-		}
263
-	}
166
+    $fileCount = count($files['name']);
167
+    for ($i = 0; $i < $fileCount; $i++) {
168
+
169
+        if (isset($_POST['resolution'])) {
170
+            $resolution = $_POST['resolution'];
171
+        } else {
172
+            $resolution = null;
173
+        }
174
+
175
+        if(isset($_POST['dirToken'])) {
176
+            // If it is a read only share the resolution will always be autorename
177
+            if (!($share->getPermissions() & \OCP\Constants::PERMISSION_READ)) {
178
+                $resolution = 'autorename';
179
+            }
180
+        }
181
+
182
+        // target directory for when uploading folders
183
+        $relativePath = '';
184
+        if(!empty($_POST['file_directory'])) {
185
+            $relativePath = '/'.$_POST['file_directory'];
186
+        }
187
+
188
+        // $path needs to be normalized - this failed within drag'n'drop upload to a sub-folder
189
+        if ($resolution === 'autorename') {
190
+            // append a number in brackets like 'filename (2).ext'
191
+            $target = OCP\Files::buildNotExistingFileName($dir . $relativePath, $files['name'][$i]);
192
+        } else {
193
+            $target = \OC\Files\Filesystem::normalizePath($dir . $relativePath.'/'.$files['name'][$i]);
194
+        }
195
+
196
+        // relative dir to return to the client
197
+        if (isset($publicDirectory)) {
198
+            // path relative to the public root
199
+            $returnedDir = $publicDirectory . $relativePath;
200
+        } else {
201
+            // full path
202
+            $returnedDir = $dir . $relativePath;
203
+        }
204
+        $returnedDir = \OC\Files\Filesystem::normalizePath($returnedDir);
205
+
206
+
207
+        $exists = \OC\Files\Filesystem::file_exists($target);
208
+        if ($exists) {
209
+            $updatable = \OC\Files\Filesystem::isUpdatable($target);
210
+        }
211
+        if ( ! $exists || ($updatable && $resolution === 'replace' ) ) {
212
+            // upload and overwrite file
213
+            try
214
+            {
215
+                if (is_uploaded_file($files['tmp_name'][$i]) and \OC\Files\Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
216
+
217
+                    // updated max file size after upload
218
+                    $storageStats = \OCA\Files\Helper::buildFileStorageStatistics($dir);
219
+
220
+                    $meta = \OC\Files\Filesystem::getFileInfo($target);
221
+                    if ($meta === false) {
222
+                        $error = $l->t('The target folder has been moved or deleted.');
223
+                        $errorCode = 'targetnotfound';
224
+                    } else {
225
+                        $data = \OCA\Files\Helper::formatFileInfo($meta);
226
+                        $data['status'] = 'success';
227
+                        $data['originalname'] = $files['name'][$i];
228
+                        $data['uploadMaxFilesize'] = $maxUploadFileSize;
229
+                        $data['maxHumanFilesize'] = $maxHumanFileSize;
230
+                        $data['permissions'] = $meta['permissions'];
231
+                        $data['directory'] = $returnedDir;
232
+                        $result[] = $data;
233
+                    }
234
+
235
+                } else {
236
+                    $error = $l->t('Upload failed. Could not find uploaded file');
237
+                    $errorFileName = $files['name'][$i];
238
+                }
239
+            } catch(Exception $ex) {
240
+                $error = $ex->getMessage();
241
+            }
242
+
243
+        } else {
244
+            // file already exists
245
+            $meta = \OC\Files\Filesystem::getFileInfo($target);
246
+            if ($meta === false) {
247
+                $error = $l->t('Upload failed. Could not get file info.');
248
+            } else {
249
+                $data = \OCA\Files\Helper::formatFileInfo($meta);
250
+                if ($updatable) {
251
+                    $data['status'] = 'existserror';
252
+                } else {
253
+                    $data['status'] = 'readonly';
254
+                }
255
+                $data['originalname'] = $files['name'][$i];
256
+                $data['uploadMaxFilesize'] = $maxUploadFileSize;
257
+                $data['maxHumanFilesize'] = $maxHumanFileSize;
258
+                $data['permissions'] = $meta['permissions'];
259
+                $data['directory'] = $returnedDir;
260
+                $result[] = $data;
261
+            }
262
+        }
263
+    }
264 264
 } else {
265
-	$error = $l->t('Invalid directory.');
265
+    $error = $l->t('Invalid directory.');
266 266
 }
267 267
 
268 268
 if ($error === false) {
269
-	// Do not leak file information if it is a read-only share
270
-	if(isset($_POST['dirToken'])) {
271
-		$shareManager = \OC::$server->getShareManager();
272
-		$share = $shareManager->getShareByToken((string)$_POST['dirToken']);
273
-		if (!($share->getPermissions() & \OCP\Constants::PERMISSION_READ)) {
274
-			$newResults = [];
275
-			foreach($result as $singleResult) {
276
-				$fileName = $singleResult['originalname'];
277
-				$newResults['filename'] = $fileName;
278
-				$newResults['mimetype'] = \OC::$server->getMimeTypeDetector()->detectPath($fileName);
279
-			}
280
-			$result = $newResults;
281
-		}
282
-	}
283
-
284
-	OCP\JSON::encodedPrint($result);
269
+    // Do not leak file information if it is a read-only share
270
+    if(isset($_POST['dirToken'])) {
271
+        $shareManager = \OC::$server->getShareManager();
272
+        $share = $shareManager->getShareByToken((string)$_POST['dirToken']);
273
+        if (!($share->getPermissions() & \OCP\Constants::PERMISSION_READ)) {
274
+            $newResults = [];
275
+            foreach($result as $singleResult) {
276
+                $fileName = $singleResult['originalname'];
277
+                $newResults['filename'] = $fileName;
278
+                $newResults['mimetype'] = \OC::$server->getMimeTypeDetector()->detectPath($fileName);
279
+            }
280
+            $result = $newResults;
281
+        }
282
+    }
283
+
284
+    OCP\JSON::encodedPrint($result);
285 285
 } else {
286
-	OCP\JSON::error(array(array('data' => array_merge(array(
287
-		'message' => $error,
288
-		'code' => $errorCode,
289
-		'filename' => $errorFileName
290
-	), $storageStats))));
286
+    OCP\JSON::error(array(array('data' => array_merge(array(
287
+        'message' => $error,
288
+        'code' => $errorCode,
289
+        'filename' => $errorFileName
290
+    ), $storageStats))));
291 291
 }
Please login to merge, or discard this patch.
apps/files/list.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 $config = \OC::$server->getConfig();
25 25
 // TODO: move this to the generated config.js
26 26
 $publicUploadEnabled = $config->getAppValue('core', 'shareapi_allow_public_upload', 'yes');
27
-$uploadLimit=OCP\Util::uploadLimit();
27
+$uploadLimit = OCP\Util::uploadLimit();
28 28
 
29 29
 // renders the controls and table headers template
30 30
 $tmpl = new OCP\Template('files', 'list', '');
Please login to merge, or discard this patch.