function deleteGroup($id) { $group = findGroupById($id); if (!isset($group)) { return; } $odbc = odbcConnect(); $stmt = odbc_prepare($odbc, "DELETE FROM group_members WHERE group_id = ?"); $rs = odbc_execute($stmt, array($id)); if (!$rs) { odbc_close($odbc); return false; } $stmt = odbc_prepare($odbc, "DELETE FROM org_members WHERE member_type = 'group' and member_id = ?"); $rs = odbc_execute($stmt, array($id)); if (!$rs) { odbc_close($odbc); return false; } $stmt = odbc_prepare($odbc, "DELETE FROM groups WHERE id = ?"); $rs = odbc_execute($stmt, array($id)); odbc_close($odbc); return $rs; }
<?php include "adminapi.php"; $id = $_GET['id']; if (!isset($_POST["id"])) { if (!isset($_GET["id"])) { return header("Location: index.php"); } } else { $rs = deleteGroup($id); if ($rs == true) { header("Location: index.php"); } } $form = findGroupById($id); $pageTitle = "Deleting Group: {$form['name']}"; $pageInfo = ""; $submitPage = $_SERVER["REQUEST_URI"]; $submitLabel = "Delete Group"; include 'header.php'; ?> <body id="edit_organization" class="organizations"> <?php make_navbar('Groups'); ?> <div id="body" class="wrap"> <h3><?php echo $pageTitle; ?> </h3> <form name="viewGroupForm" method="post" action="<?php