-
Notifications
You must be signed in to change notification settings - Fork 11
phpstan for webroot #426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
phpstan for webroot #426
Changes from all commits
76e804f
d85050b
002605f
e9238b5
7157cb2
1e69c6d
518d978
790fb00
414372f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,36 +12,37 @@ | |
| UnityHTTPD::forbidden("not an admin"); | ||
| } | ||
|
|
||
| $getUserFromPost = function () { | ||
| global $LDAP, $SQL, $MAILER, $WEBHOOK; | ||
| return new UnityUser(UnityHTTPD::getPostData("uid"), $LDAP, $SQL, $MAILER, $WEBHOOK); | ||
| }; | ||
|
|
||
| if ($_SERVER["REQUEST_METHOD"] == "POST") { | ||
| UnityHTTPD::validatePostCSRFToken(); | ||
| if (isset($_POST["uid"])) { | ||
| $form_user = new UnityUser($_POST["uid"], $LDAP, $SQL, $MAILER, $WEBHOOK); | ||
| } | ||
|
|
||
| switch ($_POST["form_type"]) { | ||
| case "req": | ||
| $form_user = $getUserFromPost(); | ||
|
Comment on lines
+15
to
+24
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PHPStan complains that |
||
| if ($_POST["action"] == "Approve") { | ||
| $group = $form_user->getPIGroup(); | ||
| $group->approveGroup($OPERATOR); | ||
| } elseif ($_POST["action"] == "Deny") { | ||
| $group = $form_user->getPIGroup(); | ||
| $group->denyGroup($OPERATOR); | ||
simonLeary42 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| break; | ||
| case "reqChild": | ||
| $form_user = $getUserFromPost(); | ||
| $parent_group = new UnityGroup($_POST["pi"], $LDAP, $SQL, $MAILER, $WEBHOOK); | ||
simonLeary42 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if ($_POST["action"] == "Approve") { | ||
| $parent_group->approveUser($form_user); | ||
| } elseif ($_POST["action"] == "Deny") { | ||
| $parent_group->denyUser($form_user); | ||
simonLeary42 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| break; | ||
| case "remUserChild": | ||
| $form_user = $getUserFromPost(); | ||
| $parent = new UnityGroup($_POST["pi"], $LDAP, $SQL, $MAILER, $WEBHOOK); | ||
simonLeary42 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| $parent->removeUser($form_user); | ||
|
|
||
| break; | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,29 +6,30 @@ | |
| use UnityWebPortal\lib\UnityGroup; | ||
| use UnityWebPortal\lib\UnityHTTPD; | ||
|
|
||
| $getPIGroupFromPost = function () { | ||
| global $LDAP, $SQL, $MAILER, $WEBHOOK; | ||
| $gid_or_mail = UnityHTTPD::getPostData("pi"); | ||
| if (substr($gid_or_mail, 0, 3) !== "pi_" && str_contains($gid_or_mail, "@")) { | ||
| try { | ||
| $gid_or_mail = UnityGroup::ownerMail2GID($gid_or_mail); | ||
| } catch (EntryNotFoundException) { | ||
| // oh well, we tried | ||
| } | ||
| } | ||
| $pi_group = new UnityGroup($gid_or_mail, $LDAP, $SQL, $MAILER, $WEBHOOK); | ||
| if (!$pi_group->exists()) { | ||
| UnityHTTPD::messageError("This PI Doesn't Exist", $gid_or_mail); | ||
| UnityHTTPD::redirect(); | ||
| } | ||
| return $pi_group; | ||
| }; | ||
|
|
||
| if ($_SERVER["REQUEST_METHOD"] == "POST") { | ||
| UnityHTTPD::validatePostCSRFToken(); | ||
| if (isset($_POST["form_type"])) { | ||
| if (isset($_POST["pi"])) { | ||
| $pi_groupname = $_POST["pi"]; | ||
| if (substr($pi_groupname, 0, 3) !== "pi_" && str_contains($pi_groupname, "@")) { | ||
| try { | ||
| $pi_groupname = UnityGroup::ownerMail2GID($pi_groupname); | ||
| } catch (EntryNotFoundException) { | ||
| } | ||
| } | ||
| $pi_account = new UnityGroup($pi_groupname, $LDAP, $SQL, $MAILER, $WEBHOOK); | ||
| if (!$pi_account->exists()) { | ||
| UnityHTTPD::messageError( | ||
| "Invalid Group Membership Request", | ||
| "This PI doesn't exist" | ||
| ); | ||
| UnityHTTPD::redirect(); | ||
| } | ||
| } | ||
|
|
||
| switch ($_POST["form_type"]) { | ||
| case "addPIform": | ||
| $pi_account = $getPIGroupFromPost(); | ||
| if (!isset($_POST["tos"]) || $_POST["tos"] != "agree") { | ||
| UnityHTTPD::badRequest("user did not agree to terms of service"); | ||
| } | ||
|
|
@@ -50,15 +51,17 @@ | |
| } | ||
| $pi_account->newUserRequest($USER); | ||
| UnityHTTPD::redirect(); | ||
| break; | ||
| break; /** @phpstan-ignore deadCode.unreachable */ | ||
simonLeary42 marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
53
to
+54
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PHP Code Sniffer requires a |
||
| case "removePIForm": | ||
| $pi_account = $getPIGroupFromPost(); | ||
| $pi_account->removeUser($USER); | ||
| UnityHTTPD::redirect(); | ||
| break; | ||
| break; /** @phpstan-ignore deadCode.unreachable */ | ||
simonLeary42 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| case "cancelPIForm": | ||
| $pi_account = $getPIGroupFromPost(); | ||
| $pi_account->cancelGroupJoinRequest($USER); | ||
| UnityHTTPD::redirect(); | ||
| break; | ||
| break; /** @phpstan-ignore deadCode.unreachable */ | ||
simonLeary42 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.