Skip to content

Commit f35f57c

Browse files
committed
Auto-format sources with PHPCBF
1 parent a8d956a commit f35f57c

34 files changed

+352
-254
lines changed

authorise.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,33 @@
5353
if ($action === 'logout') {
5454
// Remove access token.
5555
$userclient->log_out();
56-
redirect($nextpage, get_string('logoutsuccess', 'mod_collaborativefolders', $servicename), null,
57-
\core\output\notification::NOTIFY_SUCCESS);
56+
redirect(
57+
$nextpage,
58+
get_string('logoutsuccess', 'mod_collaborativefolders', $servicename),
59+
null,
60+
\core\output\notification::NOTIFY_SUCCESS
61+
);
5862
exit;
5963
}
6064

6165
if ($action === 'login') {
6266
// Callback from remote system. Use received authorisation code to convert it into an access token.
6367
if ($userclient->check_login()) {
6468
// Token received! Continuing...
65-
redirect($nextpage, get_string('loginsuccess', 'mod_collaborativefolders', $servicename), null,
66-
\core\output\notification::NOTIFY_SUCCESS);
69+
redirect(
70+
$nextpage,
71+
get_string('loginsuccess', 'mod_collaborativefolders', $servicename),
72+
null,
73+
\core\output\notification::NOTIFY_SUCCESS
74+
);
6775
} else {
6876
// Authorisation failed for some reason.
69-
redirect($nextpage, get_string('loginfailure', 'mod_collaborativefolders', $servicename), null,
70-
\core\output\notification::NOTIFY_ERROR);
77+
redirect(
78+
$nextpage,
79+
get_string('loginfailure', 'mod_collaborativefolders', $servicename),
80+
null,
81+
\core\output\notification::NOTIFY_ERROR
82+
);
7183
}
7284
exit;
7385
}

classes/configuration_exception.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3333
*/
3434
class configuration_exception extends \moodle_exception {
35-
3635
/**
3736
* Constructor
3837
* This exception is used when the configuration of the plugin can not be processed or database entries are

classes/event/course_module_viewed.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3636
*/
3737
class course_module_viewed extends \core\event\course_module_viewed {
38-
3938
/**
4039
* Initialize the event
4140
*/

classes/event/link_generated.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
3232
* @copyright 2017 Project seminar (Learnweb, University of Münster)
3333
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3434
*/
35-
class link_generated extends \core\event\base {
36-
35+
class link_generated extends \core\event\base {
3736
/**
3837
* Init method.
3938
*
@@ -70,6 +69,6 @@ public static function get_name() {
7069
* @return \moodle_url
7170
*/
7271
public function get_url() {
73-
return new \moodle_url('/mod/collaborativefolders/view.php', array('id' => $this->contextinstanceid));
72+
return new \moodle_url('/mod/collaborativefolders/view.php', ['id' => $this->contextinstanceid]);
7473
}
7574
}

classes/issuer_management.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public static function create_issuer(string $issuername, string $baseurl): issue
8686
$record = (object) [
8787
'issuerid' => $issuer->get('id'),
8888
'externalfield' => $external,
89-
'internalfield' => $internal
89+
'internalfield' => $internal,
9090
];
9191
$userfieldmapping = new \core\oauth2\user_field_mapping(0, $record);
9292
$userfieldmapping->create();

classes/local/clients/system_client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ protected function get_stored_token() {
4848
return null;
4949
}
5050

51-
public function upgrade_refresh_token(\core\oauth2\system_account $systemaccount) : bool {
51+
public function upgrade_refresh_token(\core\oauth2\system_account $systemaccount): bool {
5252
$this->store_token(null); // Make sure the existing token is cleared, before calling refresh.
5353
return parent::upgrade_refresh_token($systemaccount);
5454
}

classes/local/clients/system_folder_access.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class system_folder_access {
8888
* Construct the wrapper and initialise the clients.
8989
* @throws \mod_collaborativefolders\configuration_exception if essential data is missing.
9090
*/
91-
public function __construct () {
91+
public function __construct() {
9292
// Get issuer and system account client. Fail early, if needed.
9393
$selectedissuer = get_config("collaborativefolders", "issuerid");
9494
if (empty($selectedissuer)) {
@@ -216,7 +216,6 @@ public function generate_share(string $path, string $username, string $chosennam
216216
}
217217

218218
throw new share_failed_exception(get_string('ocserror', 'mod_collaborativefolders'));
219-
220219
}
221220

222221
/**
@@ -263,7 +262,7 @@ public function get_existing_share_path(string $path, string $username) {
263262
* @return int status code received from the client.
264263
* @throws \moodle_exception on connection error.
265264
*/
266-
public function make_folder($path, $recursive = true) : int {
265+
public function make_folder($path, $recursive = true): int {
267266
$this->initiate_webdavclient($this->systemclient);
268267
if (!$this->webdav->open()) {
269268
throw new \moodle_exception(get_string('socketerror', 'mod_collaborativefolders'));
@@ -273,7 +272,7 @@ public function make_folder($path, $recursive = true) : int {
273272
$parts = array_filter(explode('/', $path));
274273
$currpath = rtrim($this->davbasepath, '/');
275274
foreach ($parts as $part) {
276-
$currpath .= '/'.$part;
275+
$currpath .= '/' . $part;
277276
if (!$this->webdav->is_dir($currpath)) {
278277
// Folder doesn't already exist.
279278
if (!$this->rename_by_id($currpath)) {
@@ -283,7 +282,7 @@ public function make_folder($path, $recursive = true) : int {
283282
}
284283
}
285284
} else {
286-
$result = $this->webdav->mkcol($this->davbasepath.$path);
285+
$result = $this->webdav->mkcol($this->davbasepath . $path);
287286
}
288287
$this->webdav->close();
289288
return $result;
@@ -300,9 +299,9 @@ public function rename_by_id($path) {
300299
if (!preg_match($idregex, $path, $matches)) {
301300
return false;
302301
}
303-
list(, $id) = $matches;
304-
$idmatch = '| \(id '.$id.'\)$|';
305-
$legacyidmatch = '|_id_'.$id.'$|'; // For folders created with earlier versions of mod_collaborativefolders.
302+
[, $id] = $matches;
303+
$idmatch = '| \(id ' . $id . '\)$|';
304+
$legacyidmatch = '|_id_' . $id . '$|'; // For folders created with earlier versions of mod_collaborativefolders.
306305
$dir = dirname($path);
307306
$files = $this->webdav->ls($dir);
308307
if (!$files) {
@@ -317,8 +316,10 @@ public function rename_by_id($path) {
317316
continue;
318317
}
319318

320-
if (substr($filepath, -strlen($idmatch)) === $idmatch ||
321-
substr($filepath, -strlen($legacyidmatch)) === $legacyidmatch) {
319+
if (
320+
substr($filepath, -strlen($idmatch)) === $idmatch ||
321+
substr($filepath, -strlen($legacyidmatch)) === $legacyidmatch
322+
) {
322323
// We've found a folder with the same id, but a different name - rename the folder.
323324
if (!$this->webdav->move($filepath, $path, false)) {
324325
return false;

classes/local/clients/user_folder_access.php

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
*/
4040
class user_folder_access {
4141
use webdav_client_trait;
42+
4243
/**
4344
* Additional scopes needed by the user account. Currently, ownCloud does not actually support/use scopes, so
4445
* this is intended as a hint at required functionality and will help declare future scopes.
@@ -76,7 +77,7 @@ class user_folder_access {
7677
* @param \moodle_url $oauthloginreturnurl URL that will be redirected to after the login callback has succeeded.
7778
* @throws configuration_exception If essential data is missing.
7879
*/
79-
public function __construct (\moodle_url $oauthloginreturnurl) {
80+
public function __construct(\moodle_url $oauthloginreturnurl) {
8081
// Get issuer and system account client. Fail early, if needed.
8182
$selectedissuer = get_config("collaborativefolders", "issuerid");
8283
if (empty($selectedissuer)) {
@@ -97,7 +98,6 @@ public function __construct (\moodle_url $oauthloginreturnurl) {
9798
if (!$this->userclient) {
9899
throw new configuration_exception(get_string('incompletedata', 'mod_collaborativefolders'));
99100
}
100-
101101
}
102102

103103
/**
@@ -130,16 +130,14 @@ public function rename($pathtofolder, $newname) {
130130

131131
$renamed = null;
132132

133-
$ret = array();
133+
$ret = [];
134134

135135
if ($this->webdav->open()) {
136-
137136
// After the socket's opening, the WebDAV MOVE method has to be performed in
138137
// order to rename the folder.
139138
// TODO check number of slashes in `dst_path`.
140-
$renamed = $this->webdav->move($this->davbasepath . $pathtofolder, $this->davbasepath . '/' . $newname, false);
139+
$renamed = $this->webdav->move($this->davbasepath . $pathtofolder, $this->davbasepath . '/' . $newname, false);
141140
} else {
142-
143141
// If the socket could not be opened, a socket error needs to be returned.
144142
$ret['status'] = false;
145143
$ret['content'] = get_string('socketerror', 'mod_collaborativefolders');
@@ -151,7 +149,6 @@ public function rename($pathtofolder, $newname) {
151149
$ret['status'] = true;
152150
return $ret;
153151
} else {
154-
155152
// If the WebDAV operation failed, a error message, containing the specific response code,
156153
// is returned.
157154
$ret['status'] = false;
@@ -183,7 +180,7 @@ public function get_login_url() {
183180
*
184181
* @return bool false, if no Access Token is set or can be requested.
185182
*/
186-
public function check_login() : bool {
183+
public function check_login(): bool {
187184
if (!$this->userclient->is_logged_in()) {
188185
self::clear_userinfo_cache();
189186
return false;
@@ -205,11 +202,11 @@ public function store_link($cmid, $groupid, $userid, $value) {
205202
// TODO use persistent API instead.
206203
global $DB;
207204

208-
$params = array(
205+
$params = [
209206
'cmid' => $cmid,
210207
'groupid' => $groupid,
211208
'userid' => $userid,
212-
);
209+
];
213210

214211
$record = $DB->get_record('collaborativefolders_link', $params);
215212

@@ -240,11 +237,11 @@ public function get_link($cmid, $groupid, $userid) {
240237
// TODO use persistent API instead.
241238
global $DB;
242239

243-
$params = array(
240+
$params = [
244241
'cmid' => $cmid,
245242
'groupid' => $groupid,
246243
'userid' => $userid,
247-
);
244+
];
248245

249246
return $DB->get_record('collaborativefolders_link', $params);
250247
}
@@ -253,7 +250,7 @@ public function get_link($cmid, $groupid, $userid) {
253250
* Get the session cache that stores the user info, to save on repeated webservice calls.
254251
* @return \cache
255252
*/
256-
private static function get_userinfo_cache() : \cache {
253+
private static function get_userinfo_cache(): \cache {
257254
return \cache::make('mod_collaborativefolders', 'userinfo');
258255
}
259256

@@ -290,8 +287,8 @@ public function get_username() {
290287
* @param string $foldername Name of a folder
291288
* @return string URL where the folder should be found
292289
*/
293-
public function link_from_foldername($foldername) : string {
294-
$baseurl = rtrim($this->issuer->get('baseurl'), '/').'/';
290+
public function link_from_foldername($foldername): string {
291+
$baseurl = rtrim($this->issuer->get('baseurl'), '/') . '/';
295292
return sprintf('%sindex.php/apps/files/?dir=/%s', $baseurl, urlencode($foldername));
296293
}
297294
}

classes/local/clients/webdav_client_trait.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ trait webdav_client_trait {
4343
* @return \webdav_client An initialised WebDAV client for ownCloud.
4444
* @throws configuration_exception If configuration is missing (endpoints).
4545
*/
46-
private function initiate_webdavclient($client) : \webdav_client {
46+
private function initiate_webdavclient($client): \webdav_client {
4747
if ($this->webdav !== null) {
4848
return $this->webdav;
4949
}
@@ -72,8 +72,14 @@ private function initiate_webdavclient($client) : \webdav_client {
7272
}
7373

7474
// Authentication method is `bearer` for OAuth 2. Pass oauth client from which WebDAV obtains the token when needed.
75-
$this->webdav = new \webdav_client($server, '', '', 'bearer', $webdavtype,
76-
$client->get_accesstoken()->token);
75+
$this->webdav = new \webdav_client(
76+
$server,
77+
'',
78+
'',
79+
'bearer',
80+
$webdavtype,
81+
$client->get_accesstoken()->token
82+
);
7783

7884
$this->davbasepath = $webdavendpoint['path'];
7985

classes/local/sharing/share_exists_exception.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3333
*/
3434
class share_exists_exception extends \moodle_exception {
35-
3635
/**
3736
* Constructor
3837
* @param string $hint optional param for additional information of the problem

0 commit comments

Comments
 (0)