|
9 | 9 | $errors = array();
|
10 | 10 |
|
11 | 11 | if (isset($_POST["form_name"])) {
|
| 12 | + $ok = true; |
12 | 13 | if (isset($_POST["pi"])) {
|
13 | 14 | $pi_account = new UnityGroup(trim($_POST["pi"]), $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK);
|
14 | 15 | if (!$pi_account->exists()) {
|
15 |
| - // "\'" instead of "'", otherwise it will close a single quote used to place the message |
16 |
| - array_push($modalErrors, "This PI doesn\'t exist"); |
| 16 | + $SITE->alert("This PI doesn't exist"); |
| 17 | + $ok = false; |
17 | 18 | }
|
18 | 19 | }
|
19 | 20 |
|
|
23 | 24 | // existing PI request
|
24 | 25 |
|
25 | 26 | if ($pi_account->requestExists($USER)) {
|
26 |
| - array_push($modalErrors, "You\'ve already requested this"); |
| 27 | + $SITE->alert("You\'ve already requested this"); |
| 28 | + $ok = false; |
27 | 29 | }
|
28 | 30 |
|
29 | 31 | if ($pi_account->userExists($USER)) {
|
30 |
| - array_push($modalErrors, "You\'re already in this PI group"); |
| 32 | + $SITE->alert("You\'re already in this PI group"); |
| 33 | + $ok = false; |
31 | 34 | }
|
32 | 35 |
|
33 | 36 | // Add row to sql
|
34 |
| - if (empty($modalErrors)) { |
| 37 | + if ($ok) { |
35 | 38 | $pi_account->newUserRequest($USER);
|
36 | 39 | }
|
37 | 40 | break;
|
|
145 | 148 | openModal("Add New PI", "<?php echo $CONFIG["site"]["prefix"]; ?>/panel/modal/new_pi.php");
|
146 | 149 | });
|
147 | 150 |
|
148 |
| - <?php |
149 |
| - // This is here to re-open the modal if there are errors |
150 |
| - if (isset($modalErrors) && is_array($modalErrors) && count($modalErrors) > 0) { |
151 |
| - $errorHTML = ""; |
152 |
| - foreach ($modalErrors as $error) { |
153 |
| - $errorHTML .= "<span>$error</span>"; |
154 |
| - } |
155 |
| - |
156 |
| - echo "openModal('Add New PI', '" . |
157 |
| - $CONFIG["site"]["prefix"] . "/panel/modal/new_pi.php', '" . $errorHTML . "');"; |
158 |
| - } |
159 |
| - ?> |
160 |
| - |
161 | 151 | var ajax_url = "<?php echo $CONFIG["site"]["prefix"]; ?>/panel/ajax/get_group_members.php?pi_uid=";
|
162 | 152 | </script>
|
163 | 153 |
|
|
0 commit comments