|
7 | 7 | use UnityWebPortal\lib\UnityHTTPD; |
8 | 8 |
|
9 | 9 | if ($_SERVER["REQUEST_METHOD"] == "POST") { |
10 | | - $modalErrors = array(); |
11 | | - |
12 | 10 | if (isset($_POST["form_type"])) { |
13 | 11 | if (isset($_POST["pi"])) { |
14 | 12 | $pi_groupname = $_POST["pi"]; |
|
20 | 18 | } |
21 | 19 | $pi_account = new UnityGroup($pi_groupname, $LDAP, $SQL, $MAILER, $WEBHOOK); |
22 | 20 | if (!$pi_account->exists()) { |
23 | | - array_push($modalErrors, "This PI doesn't exist"); |
| 21 | + UnityHTTPD::messageBad("Invalid Group Membership Request", "This PI doesn't exist"); |
| 22 | + UnityHTTPD::redirect(); |
24 | 23 | } |
25 | 24 | } |
26 | 25 |
|
|
31 | 30 | } |
32 | 31 | if ($pi_account->exists()) { |
33 | 32 | if ($pi_account->requestExists($USER)) { |
34 | | - array_push($modalErrors, "You've already requested this"); |
| 33 | + UnityHTTPD::messageBad( |
| 34 | + "Invalid Group Membership Request", |
| 35 | + "You've already requested this" |
| 36 | + ); |
| 37 | + UnityHTTPD::redirect(); |
35 | 38 | } |
36 | 39 | if ($pi_account->memberExists($USER)) { |
37 | | - array_push($modalErrors, "You're already in this PI group"); |
| 40 | + UnityHTTPD::messageBad( |
| 41 | + "Invalid Group Membership Request", |
| 42 | + "You're already in this PI group" |
| 43 | + ); |
| 44 | + UnityHTTPD::redirect(); |
38 | 45 | } |
39 | 46 | } |
40 | | - if (empty($modalErrors)) { |
41 | | - $pi_account->newUserRequest($USER); |
42 | | - } |
| 47 | + $pi_account->newUserRequest($USER); |
| 48 | + UnityHTTPD::messageGood("Group Membership Request Submitted", ""); |
| 49 | + UnityHTTPD::redirect(); |
43 | 50 | break; |
44 | 51 | case "removePIForm": |
45 | 52 | $pi_account->removeUser($USER); |
| 53 | + UnityHTTPD::messageGood("Group Membership Removed", ""); |
| 54 | + UnityHTTPD::redirect(); |
46 | 55 | break; |
47 | 56 | case "cancelPIForm": |
48 | 57 | $pi_account->cancelGroupJoinRequest($USER); |
| 58 | + UnityHTTPD::messageGood("Group Membership Request Cancelled", ""); |
| 59 | + UnityHTTPD::redirect(); |
49 | 60 | break; |
50 | 61 | } |
51 | 62 | } |
52 | | - $_SESSION['MODAL_ERRORS'] = $modalErrors; |
53 | | -} else { |
54 | | - if (isset($_SESSION['MODAL_ERRORS'])) { |
55 | | - $modalErrors = $_SESSION['MODAL_ERRORS']; |
56 | | - $_SESSION['MODAL_ERRORS'] = array(); // Forget after shown |
57 | | - } |
58 | 63 | } |
59 | 64 |
|
60 | 65 |
|
|
178 | 183 | openModal("Add New PI", "<?php echo CONFIG["site"]["prefix"]; ?>/panel/modal/new_pi.php"); |
179 | 184 | }); |
180 | 185 |
|
181 | | - <?php |
182 | | - // This is here to re-open the modal if there are errors |
183 | | - if (isset($modalErrors) && is_array($modalErrors) && count($modalErrors) > 0) { |
184 | | - $errorHTML = ""; |
185 | | - foreach ($modalErrors as $error) { |
186 | | - $errorHTML .= "<span>" . htmlentities($error) . "</span>"; |
187 | | - } |
188 | | - |
189 | | - echo "openModal('Add New PI', '" . CONFIG["site"]["prefix"] . "/panel/modal/new_pi.php');"; |
190 | | - } |
191 | | - ?> |
192 | | - |
193 | 186 | // tables.js uses ajax_url to populate expandable tables |
194 | 187 | var ajax_url = "<?php echo CONFIG["site"]["prefix"]; ?>/panel/ajax/get_group_members.php?gid="; |
195 | 188 | </script> |
|
0 commit comments