Skip to content

Commit f95a5e8

Browse files
committed
set prettier line length to 100
1 parent ea89d12 commit f95a5e8

32 files changed

+208
-702
lines changed

coverage.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22

33
use RobinIngelbrecht\PHPUnitCoverageTools\MinCoverage\MinCoverageRule;
44

5-
return [
6-
new MinCoverageRule(pattern: "*", minCoverage: 62, exitOnLowCoverage: true),
7-
];
5+
return [new MinCoverageRule(pattern: "*", minCoverage: 62, exitOnLowCoverage: true)];

resources/config.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,4 @@
22

33
use UnityWebPortal\lib\UnityConfig;
44

5-
define(
6-
"CONFIG",
7-
UnityConfig::getConfig(
8-
__DIR__ . "/../defaults",
9-
__DIR__ . "/../deployment",
10-
),
11-
);
5+
define("CONFIG", UnityConfig::getConfig(__DIR__ . "/../defaults", __DIR__ . "/../deployment"));

resources/init.php

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
use UnityWebPortal\lib\UnityHTTPD;
1616

1717
if (CONFIG["site"]["enable_exception_handler"]) {
18-
set_exception_handler([
19-
"UnityWebPortal\lib\UnityHTTPD",
20-
"exceptionHandler",
21-
]);
18+
set_exception_handler(["UnityWebPortal\lib\UnityHTTPD", "exceptionHandler"]);
2219
}
2320

2421
session_start();
@@ -40,25 +37,11 @@
4037
$SSO = UnitySSO::getSSO();
4138
$_SESSION["SSO"] = $SSO;
4239

43-
$OPERATOR = new UnityUser(
44-
$SSO["user"],
45-
$LDAP,
46-
$SQL,
47-
$MAILER,
48-
$REDIS,
49-
$WEBHOOK,
50-
);
40+
$OPERATOR = new UnityUser($SSO["user"], $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK);
5141
$_SESSION["is_admin"] = $OPERATOR->isAdmin();
5242

5343
if (isset($_SESSION["viewUser"]) && $_SESSION["is_admin"]) {
54-
$USER = new UnityUser(
55-
$_SESSION["viewUser"],
56-
$LDAP,
57-
$SQL,
58-
$MAILER,
59-
$REDIS,
60-
$WEBHOOK,
61-
);
44+
$USER = new UnityUser($_SESSION["viewUser"], $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK);
6245
} else {
6346
$USER = $OPERATOR;
6447
}
@@ -67,12 +50,7 @@
6750
$_SESSION["is_pi"] = $USER->isPI();
6851
$SEND_PIMESG_TO_ADMINS = CONFIG["mail"]["send_pimesg_to_admins"];
6952

70-
$SQL->addLog(
71-
$OPERATOR->uid,
72-
$_SERVER["REMOTE_ADDR"],
73-
"user_login",
74-
$OPERATOR->uid,
75-
);
53+
$SQL->addLog($OPERATOR->uid, $_SERVER["REMOTE_ADDR"], "user_login", $OPERATOR->uid);
7654

7755
if (!$_SESSION["user_exists"]) {
7856
// populate cache

resources/lib/UnityConfig.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,9 @@
44

55
class UnityConfig
66
{
7-
public static function getConfig(
8-
string $def_config_loc,
9-
string $deploy_loc,
10-
): array {
11-
$CONFIG = parse_ini_file(
12-
$def_config_loc . "/config.ini.default",
13-
true,
14-
INI_SCANNER_TYPED,
15-
);
7+
public static function getConfig(string $def_config_loc, string $deploy_loc): array
8+
{
9+
$CONFIG = parse_ini_file($def_config_loc . "/config.ini.default", true, INI_SCANNER_TYPED);
1610
$CONFIG = self::pullConfig($CONFIG, $deploy_loc);
1711
if (array_key_exists("HTTP_HOST", $_SERVER)) {
1812
$cur_url = $_SERVER["HTTP_HOST"];
@@ -28,11 +22,7 @@ private static function pullConfig(array $CONFIG, string $loc): array
2822
{
2923
$file_loc = $loc . "/config/config.ini";
3024
if (file_exists($file_loc)) {
31-
$CONFIG_override = parse_ini_file(
32-
$file_loc,
33-
true,
34-
INI_SCANNER_TYPED,
35-
);
25+
$CONFIG_override = parse_ini_file($file_loc, true, INI_SCANNER_TYPED);
3626
return array_replace_recursive($CONFIG, $CONFIG_override);
3727
} else {
3828
return $CONFIG;

resources/lib/UnityGroup.php

Lines changed: 53 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,7 @@ public function requestGroup(
7979
if ($this->SQL->accDeletionRequestExists($this->getOwner()->uid)) {
8080
return;
8181
}
82-
$this->SQL->addRequest(
83-
$this->getOwner()->uid,
84-
$firstname,
85-
$lastname,
86-
$email,
87-
$org,
88-
);
82+
$this->SQL->addRequest($this->getOwner()->uid, $firstname, $lastname, $email, $org);
8983
if ($send_mail) {
9084
$this->MAILER->sendMail($email, "group_request");
9185
$this->WEBHOOK->sendWebhook("group_request_admin", [
@@ -114,10 +108,8 @@ public function requestGroup(
114108
/**
115109
* This method will create the group (this is what is executed when an admin approved the group)
116110
*/
117-
public function approveGroup(
118-
?UnityUser $operator = null,
119-
bool $send_mail = true,
120-
): void {
111+
public function approveGroup(?UnityUser $operator = null, bool $send_mail = true): void
112+
{
121113
$uid = $this->getOwner()->uid;
122114
$request = $this->SQL->getRequest($uid, UnitySQL::REQUEST_BECOME_PI);
123115
if ($this->exists()) {
@@ -134,9 +126,7 @@ public function approveGroup(
134126
}
135127
$this->init();
136128
$this->SQL->removeRequest($this->getOwner()->uid);
137-
$operator = is_null($operator)
138-
? $this->getOwner()->uid
139-
: $operator->uid;
129+
$operator = is_null($operator) ? $this->getOwner()->uid : $operator->uid;
140130
$this->SQL->addLog(
141131
$operator,
142132
$_SERVER["REMOTE_ADDR"],
@@ -151,21 +141,14 @@ public function approveGroup(
151141
/**
152142
* This method is executed when an admin denys the PI group request
153143
*/
154-
public function denyGroup(
155-
?UnityUser $operator = null,
156-
bool $send_mail = true,
157-
): void {
158-
$request = $this->SQL->getRequest(
159-
$this->getOwner()->uid,
160-
UnitySQL::REQUEST_BECOME_PI,
161-
);
144+
public function denyGroup(?UnityUser $operator = null, bool $send_mail = true): void
145+
{
146+
$request = $this->SQL->getRequest($this->getOwner()->uid, UnitySQL::REQUEST_BECOME_PI);
162147
$this->SQL->removeRequest($this->getOwner()->uid);
163148
if ($this->exists()) {
164149
return;
165150
}
166-
$operator = is_null($operator)
167-
? $this->getOwner()->uid
168-
: $operator->uid;
151+
$operator = is_null($operator) ? $this->getOwner()->uid : $operator->uid;
169152
$this->SQL->addLog(
170153
$operator,
171154
$_SERVER["REMOTE_ADDR"],
@@ -190,20 +173,16 @@ public function cancelGroupRequest(bool $send_mail = true): void
190173
}
191174
}
192175

193-
public function cancelGroupJoinRequest(
194-
UnityUser $user,
195-
bool $send_mail = true,
196-
): void {
176+
public function cancelGroupJoinRequest(UnityUser $user, bool $send_mail = true): void
177+
{
197178
if (!$this->requestExists($user)) {
198179
return;
199180
}
200181
$this->SQL->removeRequest($user->uid, $this->gid);
201182
if ($send_mail) {
202-
$this->MAILER->sendMail(
203-
$this->getOwner()->getMail(),
204-
"group_join_request_cancelled",
205-
["uid" => $user->uid],
206-
);
183+
$this->MAILER->sendMail($this->getOwner()->getMail(), "group_join_request_cancelled", [
184+
"uid" => $user->uid,
185+
]);
207186
}
208187
}
209188

@@ -248,10 +227,8 @@ public function cancelGroupJoinRequest(
248227
* This method is executed when a user is approved to join the group
249228
* (either by admin or the group owner)
250229
*/
251-
public function approveUser(
252-
UnityUser $new_user,
253-
bool $send_mail = true,
254-
): void {
230+
public function approveUser(UnityUser $new_user, bool $send_mail = true): void
231+
{
255232
$request = $this->SQL->getRequest($new_user->uid, $this->gid);
256233
if (!$new_user->exists()) {
257234
$new_user->init(
@@ -267,18 +244,13 @@ public function approveUser(
267244
$this->MAILER->sendMail($new_user->getMail(), "group_user_added", [
268245
"group" => $this->gid,
269246
]);
270-
$this->MAILER->sendMail(
271-
$this->getOwner()->getMail(),
272-
"group_user_added_owner",
273-
[
274-
"group" => $this->gid,
275-
"user" => $new_user->uid,
276-
"name" =>
277-
$request["firstname"] . " " . $request["lastname"],
278-
"email" => $request["email"],
279-
"org" => $request["org"],
280-
],
281-
);
247+
$this->MAILER->sendMail($this->getOwner()->getMail(), "group_user_added_owner", [
248+
"group" => $this->gid,
249+
"user" => $new_user->uid,
250+
"name" => $request["firstname"] . " " . $request["lastname"],
251+
"email" => $request["email"],
252+
"org" => $request["org"],
253+
]);
282254
}
283255
}
284256

@@ -291,51 +263,37 @@ public function denyUser(UnityUser $new_user, bool $send_mail = true): void
291263
$this->MAILER->sendMail($request["email"], "group_user_denied", [
292264
"group" => $this->gid,
293265
]);
294-
$this->MAILER->sendMail(
295-
$this->getOwner()->getMail(),
296-
"group_user_denied_owner",
297-
[
298-
"group" => $this->gid,
299-
"user" => $new_user->uid,
300-
"name" => $new_user->getFullName(),
301-
"email" => $new_user->getMail(),
302-
"org" => $new_user->getOrg(),
303-
],
304-
);
266+
$this->MAILER->sendMail($this->getOwner()->getMail(), "group_user_denied_owner", [
267+
"group" => $this->gid,
268+
"user" => $new_user->uid,
269+
"name" => $new_user->getFullName(),
270+
"email" => $new_user->getMail(),
271+
"org" => $new_user->getOrg(),
272+
]);
305273
}
306274
}
307275

308-
public function removeUser(
309-
UnityUser $new_user,
310-
bool $send_mail = true,
311-
): void {
276+
public function removeUser(UnityUser $new_user, bool $send_mail = true): void
277+
{
312278
if (!$this->memberExists($new_user)) {
313279
return;
314280
}
315281
if ($new_user->uid == $this->getOwner()->uid) {
316-
throw new Exception(
317-
"Cannot delete group owner from group. Disband group instead",
318-
);
282+
throw new Exception("Cannot delete group owner from group. Disband group instead");
319283
}
320284
// remove request, this will fail silently if the request doesn't exist
321285
$this->removeUserFromGroup($new_user);
322286
if ($send_mail) {
323-
$this->MAILER->sendMail(
324-
$new_user->getMail(),
325-
"group_user_removed",
326-
["group" => $this->gid],
327-
);
328-
$this->MAILER->sendMail(
329-
$this->getOwner()->getMail(),
330-
"group_user_removed_owner",
331-
[
332-
"group" => $this->gid,
333-
"user" => $new_user->uid,
334-
"name" => $new_user->getFullName(),
335-
"email" => $new_user->getMail(),
336-
"org" => $new_user->getOrg(),
337-
],
338-
);
287+
$this->MAILER->sendMail($new_user->getMail(), "group_user_removed", [
288+
"group" => $this->gid,
289+
]);
290+
$this->MAILER->sendMail($this->getOwner()->getMail(), "group_user_removed_owner", [
291+
"group" => $this->gid,
292+
"user" => $new_user->uid,
293+
"name" => $new_user->getFullName(),
294+
"email" => $new_user->getMail(),
295+
"org" => $new_user->getOrg(),
296+
]);
339297
}
340298
}
341299

@@ -348,17 +306,11 @@ public function newUserRequest(
348306
bool $send_mail = true,
349307
): void {
350308
if ($this->memberExists($new_user)) {
351-
UnityHTTPD::errorLog(
352-
"warning",
353-
"user '$new_user' already in group",
354-
);
309+
UnityHTTPD::errorLog("warning", "user '$new_user' already in group");
355310
return;
356311
}
357312
if ($this->requestExists($new_user)) {
358-
UnityHTTPD::errorLog(
359-
"warning",
360-
"user '$new_user' already requested group membership",
361-
);
313+
UnityHTTPD::errorLog("warning", "user '$new_user' already requested group membership");
362314
return;
363315
}
364316
if ($this->SQL->accDeletionRequestExists($new_user->uid)) {
@@ -370,17 +322,13 @@ public function newUserRequest(
370322
$this->MAILER->sendMail($email, "group_user_request", [
371323
"group" => $this->gid,
372324
]);
373-
$this->MAILER->sendMail(
374-
$this->getOwner()->getMail(),
375-
"group_user_request_owner",
376-
[
377-
"group" => $this->gid,
378-
"user" => $new_user->uid,
379-
"name" => "$firstname $lastname",
380-
"email" => $email,
381-
"org" => $org,
382-
],
383-
);
325+
$this->MAILER->sendMail($this->getOwner()->getMail(), "group_user_request_owner", [
326+
"group" => $this->gid,
327+
"user" => $new_user->uid,
328+
"name" => "$firstname $lastname",
329+
"email" => $email,
330+
"org" => $org,
331+
]);
384332
}
385333
}
386334

@@ -502,14 +450,7 @@ private function addRequest(
502450
string $email,
503451
string $org,
504452
): void {
505-
$this->SQL->addRequest(
506-
$uid,
507-
$firstname,
508-
$lastname,
509-
$email,
510-
$org,
511-
$this->gid,
512-
);
453+
$this->SQL->addRequest($uid, $firstname, $lastname, $email, $org, $this->gid);
513454
}
514455

515456
public function getOwner(): UnityUser
@@ -532,9 +473,7 @@ public static function ownerUID2GID(string $uid): string
532473
public static function GID2OwnerUID(string $gid): string
533474
{
534475
if (substr($gid, 0, strlen(self::PI_PREFIX)) != self::PI_PREFIX) {
535-
throw new Exception(
536-
"PI group GID doesn't have the correct prefix.",
537-
);
476+
throw new Exception("PI group GID doesn't have the correct prefix.");
538477
}
539478
return substr($gid, strlen(self::PI_PREFIX));
540479
}

0 commit comments

Comments
 (0)