From a18420bb3ab6d9532a391db0cfc839e0afe850cc Mon Sep 17 00:00:00 2001
From: Nigel Kukard <nkukard@lbsd.net>
Date: Thu, 30 Apr 2009 08:43:27 +0000
Subject: [PATCH] * Various cosmetic and error checking fixes

---
 webui/group-attribute-add.php    |  9 +--------
 webui/group-attribute-change.php | 27 ++++++++++-----------------
 webui/group-attribute-delete.php | 22 ++++++----------------
 3 files changed, 17 insertions(+), 41 deletions(-)

diff --git a/webui/group-attribute-add.php b/webui/group-attribute-add.php
index 594de6f2..d573fb8f 100644
--- a/webui/group-attribute-add.php
+++ b/webui/group-attribute-add.php
@@ -111,19 +111,12 @@ if (isset($_POST['frmaction']) && $_POST['frmaction'] == "add") {
 			$_POST['attr_operator'],
 			$_POST['attr_value'],
 		));
-		if ($res) {
-
+		if ($res !== FALSE) {
 ?>
-
 			<div class="notice">Attribute added</div>
-
 <?php
-
-			session_destroy();
 		} else {
-
 ?>
-
 			<div class="warning">Failed to add attribute</div>
 			<div class="warning"><?php print_r($stmt->errorInfo()) ?></div>
 
diff --git a/webui/group-attribute-change.php b/webui/group-attribute-change.php
index 163de686..86d2136d 100644
--- a/webui/group-attribute-change.php
+++ b/webui/group-attribute-change.php
@@ -157,45 +157,38 @@ if (isset($_POST['frmaction']) && $_POST['frmaction'] == "change") {
 		if (sizeof($updates) > 0) {
 			$updateStr = implode(', ',$updates);
 
-			$res = $db->exec("UPDATE ${DB_TABLE_PREFIX}group_attributes SET $updateStr WHERE ID = ".$db->quote($_POST['attr_id']));
+			$res = $db->exec("
+				UPDATE 
+					${DB_TABLE_PREFIX}group_attributes 
+				SET 
+					$updateStr 
+				WHERE 
+					ID = ".$db->quote($_POST['attr_id']."
+			"));
 			if ($res !== FALSE) {
-
 ?>
-
 				<div class="notice">Attribute updated</div>
-
 <?php
-
 			} else {
-
 ?>
-
 				<div class="warning">Error updating attribute</div>
 				<div class="warning"><?php print_r($db->errorInfo()) ?></div>
-
 <?php
-
 			}
 		# Warn
 		} else {
-
 ?>
-
 			<div class="warning">No attribute updates</div>
-
 <?php
-
 		}
+
 	# Warn
 	} else {
-
 ?>
-
 		<div class="error">No attribute data available</div>
-
 <?php
-
 	}
+
 } else {
 
 ?>
diff --git a/webui/group-attribute-delete.php b/webui/group-attribute-delete.php
index d857f0fc..e77ae3c4 100644
--- a/webui/group-attribute-delete.php
+++ b/webui/group-attribute-delete.php
@@ -76,45 +76,35 @@ if (isset($_POST['frmaction']) && $_POST['frmaction'] == "delete") {
 
 <?php
 
+	# Make sure we have the attribute ID set
 	if (isset($_POST['attr_id'])) {
+
+		# And make sure user confirmed
 		if (isset($_POST['confirm']) && $_POST['confirm'] == "yes") {
+
 			$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}group_attributes WHERE ID = ".$db->quote($_POST['attr_id']));
 			if ($res !== FALSE) {
-
 ?>
-
 				<div class="notice">Attribute with ID: <?php print_r($_POST['attr_id']);?> deleted</div>
-
 <?php
-
 			} else {
-
 ?>
-
 				<div class="warning">Error deleting attribute</div>
 				<div class="warning"><?php print_r($db->errorInfo()) ?></div>
-
 <?php
-
 			}
+
 		# Warn
 		} else {
-
 ?>
-
 			<div class="warning">Delete attribute aborted</div>
-
 <?php
-
 		}
-	} else {
 
+	} else {
 ?>
-
 		<div class="warning">Invocation error, no attribute ID selected</div>
-
 <?php
-
 	}
 }
 printFooter();
-- 
GitLab