|
4 | 4 |
|
5 | 5 | use UnityWebPortal\lib\UnitySite; |
6 | 6 | use UnityWebPortal\lib\UnityGroup; |
| 7 | +use UnityWebPortal\lib\UnitySQL; |
7 | 8 |
|
8 | | -require_once $LOC_HEADER; |
9 | 9 | if ($USER->exists()) { |
10 | | - UnitySite::redirect($CONFIG["site"]["prefix"] . "/panel/index.php"); // Redirect if account already exists |
| 10 | + UnitySite::redirect($CONFIG["site"]["prefix"] . "/panel/index.php"); |
11 | 11 | } |
12 | 12 |
|
13 | 13 | $pending_requests = $SQL->getRequestsByUser($USER->getUID()); |
14 | 14 |
|
15 | 15 | if ($_SERVER["REQUEST_METHOD"] == "POST") { |
16 | | - $errors = array(); |
17 | | - |
18 | | - if (!isset($_POST["eula"]) || $_POST["eula"] != "agree") { |
19 | | - // checkbox was not checked |
20 | | - array_push($errors, "Accepting the EULA is required"); |
21 | | - } |
22 | | - |
23 | | - if ($_POST["new_user_sel"] == "not_pi") { |
24 | | - $form_group = new UnityGroup($_POST["pi"], $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK); |
25 | | - if (!$form_group->exists()) { |
26 | | - array_push($errors, "The selected PI does not exist"); |
| 16 | + if (isset($_POST["new_user_sel"])) { |
| 17 | + if (!isset($_POST["eula"]) || $_POST["eula"] != "agree") { |
| 18 | + UnitySite::badRequest("user did not agree to EULA"); |
| 19 | + } |
| 20 | + if ($_POST["new_user_sel"] == "not_pi") { |
| 21 | + $form_group = new UnityGroup($_POST["pi"], $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK); |
| 22 | + if (!$form_group->exists()) { |
| 23 | + UnitySite::badRequest("The selected PI does not exist"); |
| 24 | + } |
| 25 | + $form_group->newUserRequest($USER); |
27 | 26 | } |
28 | | - } |
29 | | - // Request Account Form was Submitted |
30 | | - if (count($errors) == 0) { |
31 | 27 | if ($_POST["new_user_sel"] == "pi") { |
32 | | - if (!isset($_POST["chk_pi"]) || $_POST["chk_pi"] != "agree") { |
33 | | - // checkbox was not checked |
34 | | - array_push($errors, "Please confirm you have read the account policy guidelines."); |
| 28 | + if (!isset($_POST["confirm_pi"]) || $_POST["confirm_pi"] != "agree") { |
| 29 | + UnitySite::badRequest("user did not agree to account policy"); |
35 | 30 | } |
36 | | - // requesting a PI account |
37 | 31 | $USER->getPIGroup()->requestGroup($SEND_PIMESG_TO_ADMINS); |
38 | | - } elseif ($_POST["new_user_sel"] == "not_pi") { |
39 | | - $form_group->newUserRequest($USER); |
40 | 32 | } |
41 | 33 | } |
42 | | - UnitySite::redirect($_SERVER['PHP_SELF']); |
43 | | -} |
44 | | - |
45 | | -if (isset($_GET['cancel']) && count($pending_requests) > 0) { |
46 | | - foreach ($pending_requests as $request) { |
47 | | - if ($request["request_for"] == "admin") { |
48 | | - // cancel PI request |
49 | | - $USER->getPIGroup()->cancelGroupRequest(); |
50 | | - } else { |
51 | | - $pi_group = new UnityGroup($request["request_for"], $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK); |
52 | | - $pi_group->cancelGroupJoinRequest($user=$USER); |
| 34 | + elseif (isset($_POST["cancel"])) { |
| 35 | + foreach ($pending_requests as $request) { |
| 36 | + if ($request["request_for"] == "admin") { |
| 37 | + $USER->getPIGroup()->cancelGroupRequest(); |
| 38 | + } else { |
| 39 | + $pi_group = new UnityGroup($request["request_for"], $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK); |
| 40 | + $pi_group->cancelGroupJoinRequest($user=$USER); |
| 41 | + } |
53 | 42 | } |
| 43 | + } else { |
| 44 | + UnitySite::badRequest("neither 'new_user_sel' or 'cancel' are set!"); |
54 | 45 | } |
55 | 46 | UnitySite::redirect($_SERVER['PHP_SELF']); |
56 | 47 | } |
57 | | - |
| 48 | +require_once $LOC_HEADER; |
58 | 49 | ?> |
59 | 50 |
|
60 | 51 | <h1>Request Account</h1> |
|
63 | 54 | <?php if (count($pending_requests) > 0) : ?> |
64 | 55 | <p>You have pending account activation requests:</p> |
65 | 56 | <?php foreach ($pending_requests as $request) : ?> |
| 57 | + <ul><li> |
66 | 58 | <?php |
67 | | - $pi_uid = $request["request_for"]; |
68 | | - if ($pi_uid == "admin") { |
69 | | - echo "<p>Requesting a PI account</p>"; |
70 | | - echo "<p>You will receive an email when your account has been approved.</p>"; |
71 | | - echo "<p>Email <a href=\"mailto:{$CONFIG['mail']['support']}\">{$CONFIG['mail']['support_name']}</a>"; |
72 | | - echo " if you have not heard back in one business day. </p>"; |
| 59 | + $pi_uid = $request["request_for"]; |
| 60 | + if ($pi_uid == UnitySQL::REQUEST_BECOME_PI) { |
| 61 | + $group_uid = $USER->getPIGroup()->getPIUID(); |
| 62 | + echo "<p>Ownership of PI Account/Group: <code>$group_uid</code> </p>"; |
73 | 63 | } else { |
74 | 64 | $owner_uid = UnityGroup::getUIDfromPIUID($pi_uid); |
75 | | - echo "<p>Joining existing group owned by " . $owner_uid . "</p>"; |
76 | | - echo "<p>You will receive an email when your account has been approved by the PI."; |
77 | | - echo "You may need to remind them.</p>"; |
| 65 | + echo "<p>Membership in PI Group owned by: <code>$owner_uid</code></p>"; |
78 | 66 | } |
79 | 67 | ?> |
80 | | - <a href="?cancel=true">Cancel Request</a> |
| 68 | + </li></ul> |
| 69 | + <hr> |
| 70 | + <p><strong>Requesting Ownership of PI Account/Group</strong></p> |
| 71 | + <p>You will receive an email when your account has been approved.</p> |
| 72 | + <p>Email <a href="mailto:<?php echo $CONFIG['mail']['support']; ?>"><?php echo $CONFIG['mail']['support_name']; ?></a> if you have not heard back in one business day. </p> |
| 73 | + <br> |
| 74 | + <p><strong>Requesting Membership in a PI Group</strong></p> |
| 75 | + <p>You will receive an email when your account has been approved by the PI.</p> |
| 76 | + <p>You may need to remind them.</p> |
| 77 | + <hr> |
| 78 | + <form action="" method="POST"> |
| 79 | + <input name="cancel" style='margin-top: 10px;' type='submit' value='Cancel Request'/> |
| 80 | + </form> |
81 | 81 | <?php endforeach; ?> |
82 | 82 | <?php else : ?> |
83 | 83 | <form id="newAccountForm" action="" method="POST"> |
|
116 | 116 |
|
117 | 117 | <br> |
118 | 118 | <input style='margin-top: 10px;' type='submit' value='Request Account'> |
119 | | - |
120 | | - <?php |
121 | | - if (isset($errors)) { |
122 | | - echo "<div class='message'>"; |
123 | | - foreach ($errors as $err) { |
124 | | - echo "<p class='message-failure'>" . $err . "</p>"; |
125 | | - } |
126 | | - echo "</div>"; |
127 | | - } |
128 | | - ?> |
129 | 119 | </form> |
130 | 120 | <?php endif; ?> |
131 | 121 |
|
|
0 commit comments