Skip to content
Snippets Groups Projects
Commit d09963d3 authored by Robert Anderson's avatar Robert Anderson
Browse files

Added some group support for WiSPs: add

Fixed delete WiSP user to delete group associations
parent a18420bb
No related branches found
No related tags found
No related merge requests found
......@@ -55,6 +55,36 @@ if (!isset($_POST['frmaction'])) {
<td class="entrytitle">Password</td>
<td><input type="password" name="user_password" /></td>
</tr>
<tr>
<td class="entrytitle">Group</td>
<td>
<select name="user_group">
<option selected="selected" value="NULL">No group</option>
<?php
$sql = "
SELECT
ID, Name
FROM
${DB_TABLE_PREFIX}groups
ORDER BY
Name
DESC
";
$res = $db->query($sql);
# If there are any result rows, list items
if ($res->rowCount() > 0) {
while ($row = $res->fetchObject()) {
?>
<option value="<?php echo $row->id; ?>"><?php echo $row->name; ?></option>
<?php
}
}
?>
</select>
</td>
</tr>
<tr>
<td><div></div><td>
</tr>
......@@ -203,6 +233,32 @@ if (isset($_POST['frmaction']) && $_POST['frmaction'] == "insert") {
}
if ($res !== FALSE) {
if ($_POST['user_group'] !== "NULL") {
# Insert user group
$stmt = $db->prepare("
INSERT INTO
${DB_TABLE_PREFIX}users_to_groups (UserID,GroupID)
VALUES
($userID,?)
");
$res = $stmt->execute(array($_POST['user_group']));
if ($res !== FALSE) {
?>
<div class="notice">Added user to group</div>
<?php
} else {
?>
<div class="warning">Failed to add user to group</div>
<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
<?php
}
}
}
if ($res !== FALSE) {
# Insert IP Address
$stmt = $db->prepare("
......
......@@ -80,31 +80,41 @@ if (isset($_POST['frmaction']) && $_POST['frmaction'] == "delete") {
# Delete user attributes
$res = $db->exec("DELETE FROM user_attributes WHERE UserID = ".$db->quote($_POST['user_id']));
if ($res !== FALSE) {
# Delete from users
$res = $db->exec("DELETE FROM users WHERE ID = ".$db->quote($_POST['user_id']));
# Delete group associations
$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}users_to_groups WHERE UserID = ".$db->quote($_POST['user_id']));
if ($res !== FALSE) {
# Delete from users
$res = $db->exec("DELETE FROM users WHERE ID = ".$db->quote($_POST['user_id']));
if ($res !== FALSE) {
?>
<div class="notice">User with ID: <?php print_r($_POST['user_id']); ?> deleted!</div>
<div class="notice">User with ID: <?php print_r($_POST['user_id']); ?> deleted!</div>
<?php
$db->commit();
$db->commit();
} else {
?>
<div class="warning">Failed to delete user!</div>
<div class="warning"><?php print_r($res->errorInfo()); ?></div>
<?php
$db->rollback();
}
} else {
?>
<div class="warning">Failed to delete user!</div>
<div class="warning"><?php print_r($db->errorInfo()); ?></div>
<div class="warning">Failed to remove group associations</div>
<div class="warning"><?php print_r($res->errorInfo()); ?></div>
<?php
$db->rollback();
}
} else {
?>
<div class="warning">Failed to delete user!</div>
<div class="warning"><?php print_r($db->errorInfo()); ?></div>
<div class="warning">Failed to delete user attributes</div>
<div class="warning"><?php print_r($res->errorInfo()); ?></div>
<?php
$db->rollback();
}
} else {
?>
<div class="warning">Failed to delete user!</div>
<div class="warning"><?php print_r($db->errorInfo()); ?></div>
<div class="warning">Failed to delete user data</div>
<div class="warning"><?php print_r($res->errorInfo()); ?></div>
<?php
$db->rollback();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment