Skip to content

Add ability to cancel requests for existing users #250

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions webroot/panel/account.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
}
}
break;
case "cancel_pi_request":
$USER->getPIGroup()->cancelGroupRequest();
break;
case "account_deletion_request":
$hasGroups = count($USER->getGroups()) > 0;
if ($hasGroups) {
Expand Down Expand Up @@ -126,9 +129,7 @@
action=''
method='POST'
id='piReq'
onsubmit='return confirm(\"Are you sure you want to request a PI account?\")'
>
<input type='hidden' name='form_type' value='pi_request'/>
";
if ($SQL->accDeletionRequestExists($USER->getUID())) {
echo "<input type='submit' value='Request PI Account' disabled />";
Comment on lines 129 to 135
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the form_type removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not removed, but moved. It's below on lines 149 and 152.

Expand All @@ -137,15 +138,21 @@
You cannot request PI Account while you have requested account deletion.
</label>
";
} elseif ($SQL->requestExists($USER->getUID())) {
echo "<input type='submit' value='Request PI Account' disabled />";
echo "
<label style='margin-left: 10px'>
Your request has been submitted and is currently pending
</label>
";
} else {
echo "<input type='submit' value='Request PI Account'/>";
if ($SQL->requestExists($USER->getUID())) {
$prompt = "onclick='return confirm(\"Are you sure you want to cancel this request?\")";
echo "<input type='submit' value='Cancel PI AccountRequest' $prompt'/>";
echo "
<label style='margin-left: 10px'>
Your request has been submitted and is currently pending
</label>
<input type='hidden' name='form_type' value='cancel_pi_request'/>
";
} else {
echo "<input type='hidden' name='form_type' value='pi_request'/>";
$prompt = "onclick='return confirm(\"Are you sure you want to request a PI account?\")";
echo "<input type='submit' value='Request PI Account' $prompt'/>";
}
}
echo "</form>";
}
Expand Down
13 changes: 12 additions & 1 deletion webroot/panel/groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
// Remove PI form
$pi_account->removeUser($USER);
break;
case "cancelPIForm":
// cancel Group Join
$pi_account->cancelGroupJoinRequest($USER);
UnitySite::redirect($CONFIG["site"]["prefix"] . "/panel/groups.php");
break;
}
}
}
Expand Down Expand Up @@ -74,7 +79,13 @@
echo "<td>" . $requested_account->getPIUID() . "</td>";
echo "<td><a href='mailto:" . $requested_owner->getMail() . "'>" . $requested_owner->getMail() . "</a></td>";
echo "<td>" . date("jS F, Y", strtotime($request['timestamp'])) . "</td>";
echo "<td></td>";
echo "<td>";
echo "<form action='' method='POST' id='cancelPI'>
<input type='hidden' name='pi' value='{$requested_account->getPIUID()}'>
<input type='hidden' name='form_type' value='cancelPIForm'>
<input name='cancel' style='margin-top: 10px;' type='submit' value='Cancel Request'/>
</form>";
echo "</td>";
echo "</tr>";
}
echo "</table>";
Expand Down