[aur-dev] [PATCH] Remove "success" pages after package actions

Callan Barrett wizzomafizzo at gmail.com
Sat Oct 4 18:33:28 EDT 2008


Now displays a success message header and the previous page (if possible)

Signed-off-by: Callan Barrett <wizzomafizzo at gmail.com>
---
 web/html/packages.php |   49 +++++++++++++++++++++----------------------------
 web/lib/pkgfuncs.inc  |    4 ++--
 2 files changed, 23 insertions(+), 30 deletions(-)

diff --git a/web/html/packages.php b/web/html/packages.php
index 3e56a49..95d5354 100644
--- a/web/html/packages.php
+++ b/web/html/packages.php
@@ -32,42 +32,35 @@ if (isset($_POST['IDs'])) {
 	}
 }
 
-html_header($title);
-
-# Determine what action to do
+$msg = "";
 if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) {
-	print "<p>";
-	print pkg_flag($atype, $ids, True);
-	print "</p>";
+	$msg = pkg_flag($atype, $ids, True);
 } elseif ($_POST['action'] == "do_UnFlag" || isset($_POST['do_UnFlag'])) {
-	print "<p>";
-	print pkg_flag($atype, $ids, False);
-	print "</p>";
+	$msg = pkg_flag($atype, $ids, False);
 } elseif ($_POST['action'] == "do_Adopt" || isset($_POST['do_Adopt'])) {
-	print "<p>";
-	print pkg_adopt($atype, $ids, True);
-	print "</p>";
+	$msg = pkg_adopt($atype, $ids, True);
 } elseif ($_POST['action'] == "do_Disown" || isset($_POST['do_Disown'])) {
-	print "<p>";
-	print pkg_adopt($atype, $ids, False);
-	print "</p>";
+	$msg = pkg_adopt($atype, $ids, False);
 } elseif ($_POST['action'] == "do_Vote" || isset($_POST['do_Vote'])) {
-	print "<p>";
-	print pkg_vote($atype, $ids, True);
-	print "</p>";
+	$msg = pkg_vote($atype, $ids, True);
 } elseif ($_POST['action'] == "do_UnVote" || isset($_POST['do_UnVote'])) {
-	print "<p>";
-	print pkg_vote($atype, $ids, False);
-	print "</p>";
+	$msg = pkg_vote($atype, $ids, False);
 } elseif ($_POST['action'] == "do_Delete" || isset($_POST['do_Delete'])) {
-	print "<p>";
-	print pkg_delete($atype, $ids);
-	print "</p>";
+	$msg = pkg_delete($atype, $ids);
+	unset($_GET['ID']);
 } elseif ($_POST['action'] == "do_Notify" || isset($_POST['do_Notify'])) {
-	print "<p>";
-	print pkg_notify($atype, $ids);
-	print "</p>";
-} elseif (isset($_GET["ID"])) {
+	$msg = pkg_notify($atype, $ids);
+}
+
+html_header($title);
+
+if (!empty($msg)):
+?>
+<div style="text-align: center"><span class="green"><?php print $msg ?></span></div><br />
+<?php
+endif;
+
+if (isset($_GET["ID"])) {
 	if (!is_numeric($_GET["ID"])) {
 		print __("Error trying to retrieve package details.") . "<br />";	
 	} else {
diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc
index b793360..30c17ff 100644
--- a/web/lib/pkgfuncs.inc
+++ b/web/lib/pkgfuncs.inc
@@ -476,7 +476,7 @@ function package_details($id=0, $SID="") {
                 echo "<div class=\"pgbox\">\n";
                 echo "  <div class=\"pgboxtitle\"><span class=\"f3\">".__("Actions")."</span></div>\n";
                 echo "  <div class=\"pgboxbody\">\n";
-                echo "    <form action='/packages.php' method='post'>\n";
+                echo "    <form action='/packages.php?ID=" . $row['ID'] . "' method='post'>\n";
 				echo "      <input type='hidden' name='IDs[".$row["ID"]."]' value='1'>\n";
 				echo "      <input type='hidden' name='ID' value='".$row["ID"]."'>\n";
 				# Voting Button
@@ -769,7 +769,7 @@ function pkg_search_page($SID="") {
     $result = db_query($q, $dbh);
     $total = mysql_result(db_query('SELECT FOUND_ROWS() AS Total', $dbh), 0);
 
-    print "<form action='/packages.php' method='post'>\n";
+    print "<form action='/packages.php?" . $_SERVER['QUERY_STRING'] . "' method='post'>\n";
     print "<center>\n";
     print "<table cellspacing='3' class='boxSoft'>\n";
     print "<tr>\n";
-- 
1.6.0.2




More information about the aur-dev mailing list