Skip to content

remove disband PI #207

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

Merged
merged 3 commits into from
Apr 25, 2025
Merged
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
82 changes: 41 additions & 41 deletions resources/lib/UnityGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,47 +198,47 @@ public function denyGroup($operator = null, $send_mail = true)
}
}

/**
* This method will delete the group, either by admin action or PI action
*/
public function removeGroup($send_mail = true)
{
// remove any pending requests
// this will silently fail if the request doesn't exist (which is what we want)
$this->SQL->removeRequests($this->pi_uid);

// we don't need to do anything extra if the group is already deleted
if (!$this->exists()) {
return;
}

// first, we must record the users in the group currently
$users = $this->getGroupMembers();

// now we delete the ldap entry
$ldapPiGroupEntry = $this->getLDAPPiGroup();
if ($ldapPiGroupEntry->exists()) {
if (!$ldapPiGroupEntry->delete()) {
throw new Exception("Unable to delete PI ldap group");
}

$this->REDIS->removeCacheArray("sorted_groups", "", $this->getPIUID());
foreach ($users as $user) {
$this->REDIS->removeCacheArray($user->getUID(), "groups", $this->getPIUID());
}
}

// send email to every user of the now deleted PI group
if ($send_mail) {
foreach ($users as $user) {
$this->MAILER->sendMail(
$user->getMail(),
"group_disband",
array("group_name" => $this->pi_uid)
);
}
}
}
// /**
// * This method will delete the group, either by admin action or PI action
// */
// public function removeGroup($send_mail = true)
// {
// // remove any pending requests
// // this will silently fail if the request doesn't exist (which is what we want)
// $this->SQL->removeRequests($this->pi_uid);

// // we don't need to do anything extra if the group is already deleted
// if (!$this->exists()) {
// return;
// }

// // first, we must record the users in the group currently
// $users = $this->getGroupMembers();

// // now we delete the ldap entry
// $ldapPiGroupEntry = $this->getLDAPPiGroup();
// if ($ldapPiGroupEntry->exists()) {
// if (!$ldapPiGroupEntry->delete()) {
// throw new Exception("Unable to delete PI ldap group");
// }

// $this->REDIS->removeCacheArray("sorted_groups", "", $this->getPIUID());
// foreach ($users as $user) {
// $this->REDIS->removeCacheArray($user->getUID(), "groups", $this->getPIUID());
// }
// }

// // send email to every user of the now deleted PI group
// if ($send_mail) {
// foreach ($users as $user) {
// $this->MAILER->sendMail(
// $user->getMail(),
// "group_disband",
// array("group_name" => $this->pi_uid)
// );
// }
// }
// }

/**
* This method is executed when a user is approved to join the group (either by admin or the group owner)
Expand Down
14 changes: 0 additions & 14 deletions webroot/admin/pi-mgmt.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@
$group->denyGroup($OPERATOR);
}

break;
case "remGroup":
$remGroup = new UnityGroup($_POST["pi"], $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK);
$remGroup->removeGroup();

break;
case "reqChild":
$parent_group = new UnityGroup($_POST["pi"], $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK);
Expand Down Expand Up @@ -128,15 +123,6 @@
" " . $pi_user->getLastname() . "</td>";
echo "<td>" . $pi_group->getPIUID() . "</td>";
echo "<td><a href='mailto:" . $pi_user->getMail() . "'>" . $pi_user->getMail() . "</a></td>";
echo "<td>";
echo
"<form action='' method='POST'
onsubmit='return confirm(\"Are you sure you want to remove " . $pi_group->getPIUID() . "?\")'>
<input type='hidden' name='form_name' value='remGroup'>
<input type='hidden' name='pi' value='" . $pi_group->getPIUID() . "'>
<input type='submit' value='Remove'>
</form>";
echo "</td>";
echo "</tr>";
}
?>
Expand Down
15 changes: 0 additions & 15 deletions webroot/panel/pi.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@
// remove user button clicked
$group->removeUser($form_user);

break;
case "disband":
$group->removeGroup();
UnitySite::redirect($CONFIG["site"]["prefix"] . "/panel/account.php");

break;
}
}
Expand Down Expand Up @@ -110,17 +105,7 @@
}

echo "</table>";

echo "<h5>Danger Zone</h5>";

echo
"<form action='' method='POST' onsubmit='return confirm(\"Are you sure you want to disband your PI group?\")'>
<input type='hidden' name='form_name' value='disband'>
<input type='submit' value='Disband PI Account'>
</form>
";
?>
</table>

<?php
include $LOC_FOOTER;
Loading