Skip to content
Snippets Groups Projects
Commit 114a91ea authored by Nigel Kukard's avatar Nigel Kukard
Browse files

* Commit of cosmetic and code cleanups and addition of extra error checking in groups

parent 643ca8af
No related branches found
No related tags found
No related merge requests found
......@@ -92,30 +92,19 @@ if (isset($_POST['frmaction']) && $_POST['frmaction'] == "add") {
$_POST['group_disabled'],
$_POST['group_comment'],
));
if ($res) {
if ($res !== FALSE) {
?>
<div class="notice">Group created</div>
<?php
} else {
?>
<div class="warning">Failed to create group</div>
<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
<?php
}
} else {
?>
<div class="warning">Group name cannot be empty!</div>
<?php
}
......
......@@ -79,37 +79,73 @@ if (isset($_POST['frmaction']) && $_POST['frmaction'] == "delete") {
$db->beginTransaction();
$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}users_to_groups WHERE GroupID = ".$db->quote($_POST['group_id']));
$res = $db->exec("
DELETE FROM
${DB_TABLE_PREFIX}users_to_groups
WHERE
GroupID = ".$db->quote($_POST['group_id'])."
");
if ($res !== FALSE) {
$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}group_attributes WHERE GroupID = ".$db->quote($_POST['group_id']));
?>
<div class="notice">User to group mappings removed</div>
<?php
} else {
?>
<div class="warning">Error removing user mappings from group</div>
<div class="warning"><?php print_r($db->errorInfo()) ?></div>
<?php
}
if ($res !== FALSE) {
$res = $db->exec("
DELETE FROM
${DB_TABLE_PREFIX}group_attributes
WHERE
GroupID = ".$db->quote($_POST['group_id'])."
");
if ($res !== FALSE) {
?>
<div class="notice">Group group attributes removed</div>
<?php
} else {
?>
<div class="warning">Error removing group attributes</div>
<div class="warning"><?php print_r($db->errorInfo()) ?></div>
<?php
}
}
if ($res !== FALSE) {
$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}groups WHERE ID = ".$db->quote($_POST['group_id']));
if ($res !== FALSE) {
?>
<div class="notice">Group deleted</div>
<?php
$db->commit();
} else {
?>
<div class="warning">Error deleting group</div>
<div class="warning"><?php print_r($db->errorInfo()) ?></div>
<?php
$db->rollback();
}
} else {
}
# Check if all is ok, if so, we can commit, else must rollback
if ($res !== FALSE) {
$db->commit();
?>
<div class="warning">Error deleting group</div>
<div class="warning"><?php print_r($db->errorInfo()) ?></div>
<div class="notice">Changes comitted.</div>
<?php
$db->rollback();
}
} else {
$db->rollback();
?>
<div class="warning">Error deleting group</div>
<div class="warning"><?php print_r($db->errorInfo()) ?></div>
<div class="notice">Changes reverted.</div>
<?php
$db->rollback();
}
} else {
?>
<div class="notice">Group not deleted, aborted by user</div>
......
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