Passed
Push — master ( 56c5a1...24d0fb )
by Joas
10:52 queued 12s
created
apps/files_sharing/lib/Controller/RemoteController.php 2 patches
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -33,160 +33,160 @@
 block discarded – undo
33 33
 
34 34
 class RemoteController extends OCSController {
35 35
 
36
-	/** @var Manager */
37
-	private $externalManager;
38
-
39
-	/** @var ILogger */
40
-	private $logger;
41
-
42
-	/**
43
-	 * @NoAdminRequired
44
-	 *
45
-	 * Remote constructor.
46
-	 *
47
-	 * @param string $appName
48
-	 * @param IRequest $request
49
-	 * @param Manager $externalManager
50
-	 */
51
-	public function __construct($appName,
52
-								IRequest $request,
53
-								Manager $externalManager,
54
-								ILogger $logger) {
55
-		parent::__construct($appName, $request);
56
-
57
-		$this->externalManager = $externalManager;
58
-		$this->logger = $logger;
59
-	}
60
-
61
-	/**
62
-	 * @NoAdminRequired
63
-	 *
64
-	 * Get list of pending remote shares
65
-	 *
66
-	 * @return DataResponse
67
-	 */
68
-	public function getOpenShares() {
69
-		return new DataResponse($this->externalManager->getOpenShares());
70
-	}
71
-
72
-	/**
73
-	 * @NoAdminRequired
74
-	 *
75
-	 * Accept a remote share
76
-	 *
77
-	 * @param int $id
78
-	 * @return DataResponse
79
-	 * @throws OCSNotFoundException
80
-	 */
81
-	public function acceptShare($id) {
82
-		if ($this->externalManager->acceptShare($id)) {
83
-			return new DataResponse();
84
-		}
85
-
86
-		$this->logger->error('Could not accept federated share with id: ' . $id,
87
-			['app' => 'files_sharing']);
88
-
89
-		throw new OCSNotFoundException('wrong share ID, share doesn\'t exist.');
90
-	}
91
-
92
-	/**
93
-	 * @NoAdminRequired
94
-	 *
95
-	 * Decline a remote share
96
-	 *
97
-	 * @param int $id
98
-	 * @return DataResponse
99
-	 * @throws OCSNotFoundException
100
-	 */
101
-	public function declineShare($id) {
102
-		if ($this->externalManager->declineShare($id)) {
103
-			return new DataResponse();
104
-		}
105
-
106
-		// Make sure the user has no notification for something that does not exist anymore.
107
-		$this->externalManager->processNotification($id);
108
-
109
-		throw new OCSNotFoundException('wrong share ID, share doesn\'t exist.');
110
-	}
111
-
112
-	/**
113
-	 * @param array $share Share with info from the share_external table
114
-	 * @return array enriched share info with data from the filecache
115
-	 */
116
-	private static function extendShareInfo($share) {
117
-		$view = new \OC\Files\View('/' . \OC_User::getUser() . '/files/');
118
-		$info = $view->getFileInfo($share['mountpoint']);
119
-
120
-		if ($info === false) {
121
-			return $share;
122
-		}
123
-
124
-		$share['mimetype'] = $info->getMimetype();
125
-		$share['mtime'] = $info->getMTime();
126
-		$share['permissions'] = $info->getPermissions();
127
-		$share['type'] = $info->getType();
128
-		$share['file_id'] = $info->getId();
129
-
130
-		return $share;
131
-	}
132
-
133
-	/**
134
-	 * @NoAdminRequired
135
-	 *
136
-	 * List accepted remote shares
137
-	 *
138
-	 * @return DataResponse
139
-	 */
140
-	public function getShares() {
141
-		$shares = $this->externalManager->getAcceptedShares();
142
-		$shares = array_map('self::extendShareInfo', $shares);
143
-
144
-		return new DataResponse($shares);
145
-	}
146
-
147
-	/**
148
-	 * @NoAdminRequired
149
-	 *
150
-	 * Get info of a remote share
151
-	 *
152
-	 * @param int $id
153
-	 * @return DataResponse
154
-	 * @throws OCSNotFoundException
155
-	 */
156
-	public function getShare($id) {
157
-		$shareInfo = $this->externalManager->getShare($id);
158
-
159
-		if ($shareInfo === false) {
160
-			throw new OCSNotFoundException('share does not exist');
161
-		} else {
162
-			$shareInfo = self::extendShareInfo($shareInfo);
163
-			return new DataResponse($shareInfo);
164
-		}
165
-	}
166
-
167
-	/**
168
-	 * @NoAdminRequired
169
-	 *
170
-	 * Unshare a remote share
171
-	 *
172
-	 * @param int $id
173
-	 * @return DataResponse
174
-	 * @throws OCSNotFoundException
175
-	 * @throws OCSForbiddenException
176
-	 */
177
-	public function unshare($id) {
178
-		$shareInfo = $this->externalManager->getShare($id);
179
-
180
-		if ($shareInfo === false) {
181
-			throw new OCSNotFoundException('Share does not exist');
182
-		}
183
-
184
-		$mountPoint = '/' . \OC_User::getUser() . '/files' . $shareInfo['mountpoint'];
185
-
186
-		if ($this->externalManager->removeShare($mountPoint) === true) {
187
-			return new DataResponse();
188
-		} else {
189
-			throw new OCSForbiddenException('Could not unshare');
190
-		}
191
-	}
36
+    /** @var Manager */
37
+    private $externalManager;
38
+
39
+    /** @var ILogger */
40
+    private $logger;
41
+
42
+    /**
43
+     * @NoAdminRequired
44
+     *
45
+     * Remote constructor.
46
+     *
47
+     * @param string $appName
48
+     * @param IRequest $request
49
+     * @param Manager $externalManager
50
+     */
51
+    public function __construct($appName,
52
+                                IRequest $request,
53
+                                Manager $externalManager,
54
+                                ILogger $logger) {
55
+        parent::__construct($appName, $request);
56
+
57
+        $this->externalManager = $externalManager;
58
+        $this->logger = $logger;
59
+    }
60
+
61
+    /**
62
+     * @NoAdminRequired
63
+     *
64
+     * Get list of pending remote shares
65
+     *
66
+     * @return DataResponse
67
+     */
68
+    public function getOpenShares() {
69
+        return new DataResponse($this->externalManager->getOpenShares());
70
+    }
71
+
72
+    /**
73
+     * @NoAdminRequired
74
+     *
75
+     * Accept a remote share
76
+     *
77
+     * @param int $id
78
+     * @return DataResponse
79
+     * @throws OCSNotFoundException
80
+     */
81
+    public function acceptShare($id) {
82
+        if ($this->externalManager->acceptShare($id)) {
83
+            return new DataResponse();
84
+        }
85
+
86
+        $this->logger->error('Could not accept federated share with id: ' . $id,
87
+            ['app' => 'files_sharing']);
88
+
89
+        throw new OCSNotFoundException('wrong share ID, share doesn\'t exist.');
90
+    }
91
+
92
+    /**
93
+     * @NoAdminRequired
94
+     *
95
+     * Decline a remote share
96
+     *
97
+     * @param int $id
98
+     * @return DataResponse
99
+     * @throws OCSNotFoundException
100
+     */
101
+    public function declineShare($id) {
102
+        if ($this->externalManager->declineShare($id)) {
103
+            return new DataResponse();
104
+        }
105
+
106
+        // Make sure the user has no notification for something that does not exist anymore.
107
+        $this->externalManager->processNotification($id);
108
+
109
+        throw new OCSNotFoundException('wrong share ID, share doesn\'t exist.');
110
+    }
111
+
112
+    /**
113
+     * @param array $share Share with info from the share_external table
114
+     * @return array enriched share info with data from the filecache
115
+     */
116
+    private static function extendShareInfo($share) {
117
+        $view = new \OC\Files\View('/' . \OC_User::getUser() . '/files/');
118
+        $info = $view->getFileInfo($share['mountpoint']);
119
+
120
+        if ($info === false) {
121
+            return $share;
122
+        }
123
+
124
+        $share['mimetype'] = $info->getMimetype();
125
+        $share['mtime'] = $info->getMTime();
126
+        $share['permissions'] = $info->getPermissions();
127
+        $share['type'] = $info->getType();
128
+        $share['file_id'] = $info->getId();
129
+
130
+        return $share;
131
+    }
132
+
133
+    /**
134
+     * @NoAdminRequired
135
+     *
136
+     * List accepted remote shares
137
+     *
138
+     * @return DataResponse
139
+     */
140
+    public function getShares() {
141
+        $shares = $this->externalManager->getAcceptedShares();
142
+        $shares = array_map('self::extendShareInfo', $shares);
143
+
144
+        return new DataResponse($shares);
145
+    }
146
+
147
+    /**
148
+     * @NoAdminRequired
149
+     *
150
+     * Get info of a remote share
151
+     *
152
+     * @param int $id
153
+     * @return DataResponse
154
+     * @throws OCSNotFoundException
155
+     */
156
+    public function getShare($id) {
157
+        $shareInfo = $this->externalManager->getShare($id);
158
+
159
+        if ($shareInfo === false) {
160
+            throw new OCSNotFoundException('share does not exist');
161
+        } else {
162
+            $shareInfo = self::extendShareInfo($shareInfo);
163
+            return new DataResponse($shareInfo);
164
+        }
165
+    }
166
+
167
+    /**
168
+     * @NoAdminRequired
169
+     *
170
+     * Unshare a remote share
171
+     *
172
+     * @param int $id
173
+     * @return DataResponse
174
+     * @throws OCSNotFoundException
175
+     * @throws OCSForbiddenException
176
+     */
177
+    public function unshare($id) {
178
+        $shareInfo = $this->externalManager->getShare($id);
179
+
180
+        if ($shareInfo === false) {
181
+            throw new OCSNotFoundException('Share does not exist');
182
+        }
183
+
184
+        $mountPoint = '/' . \OC_User::getUser() . '/files' . $shareInfo['mountpoint'];
185
+
186
+        if ($this->externalManager->removeShare($mountPoint) === true) {
187
+            return new DataResponse();
188
+        } else {
189
+            throw new OCSForbiddenException('Could not unshare');
190
+        }
191
+    }
192 192
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 			return new DataResponse();
84 84
 		}
85 85
 
86
-		$this->logger->error('Could not accept federated share with id: ' . $id,
86
+		$this->logger->error('Could not accept federated share with id: '.$id,
87 87
 			['app' => 'files_sharing']);
88 88
 
89 89
 		throw new OCSNotFoundException('wrong share ID, share doesn\'t exist.');
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 * @return array enriched share info with data from the filecache
115 115
 	 */
116 116
 	private static function extendShareInfo($share) {
117
-		$view = new \OC\Files\View('/' . \OC_User::getUser() . '/files/');
117
+		$view = new \OC\Files\View('/'.\OC_User::getUser().'/files/');
118 118
 		$info = $view->getFileInfo($share['mountpoint']);
119 119
 
120 120
 		if ($info === false) {
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 			throw new OCSNotFoundException('Share does not exist');
182 182
 		}
183 183
 
184
-		$mountPoint = '/' . \OC_User::getUser() . '/files' . $shareInfo['mountpoint'];
184
+		$mountPoint = '/'.\OC_User::getUser().'/files'.$shareInfo['mountpoint'];
185 185
 
186 186
 		if ($this->externalManager->removeShare($mountPoint) === true) {
187 187
 			return new DataResponse();
Please login to merge, or discard this patch.