[aur-dev] [PATCH] Set up redirects for all actions
No more useless "congratulations you've done this" pages Shit is SO cash! Signed-off-by: Callan Barrett <wizzomafizzo@gmail.com> --- TODO | 2 - web/html/packages.php | 192 +++++++++++++------------------------------------ 2 files changed, 49 insertions(+), 145 deletions(-) diff --git a/TODO b/TODO index d71efb8..fb64960 100644 --- a/TODO +++ b/TODO @@ -11,8 +11,6 @@ Todo List deciphering of those insane variables * Rename those insane variables (the url variables on the search page), probably make them more verbose and actually relate to what they are -* Set up redirects for useless pages (like the "you've done action to X" - package pages), FS#10674, FS#3542 * Add support for the license field in tupkg scripts, FS#8138 * Add confirmation for TUs deleting packages, FS#6515 * Ownership of packages should turn notify on (adopt, create, etc.), FS#10480 diff --git a/web/html/packages.php b/web/html/packages.php index 453f095..62f822b 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -62,6 +62,12 @@ if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) { @mail(' ', "AUR Out-of-date Notification for ".$row['Name'], $body, $headers); } } + + if ($_POST['action'] == "do_Flag") { + header("Location: packages.php"); + } else { + header("Location: packages.php?ID=" . $_POST['ID']); + } } } elseif ($_POST['action'] == "do_UnFlag" || isset($_POST['do_UnFlag'])) { if ($atype && !empty($ids)) { @@ -81,6 +87,12 @@ if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) { $q = "UPDATE Packages SET OutOfDate = 0 "; $q.= "WHERE ID IN (" . $unflag . ")"; db_query($q, $dbh); + + if ($_POST['action'] == "do_UnFlag") { + header("Location: packages.php"); + } else { + header("Location: packages.php?ID=" . $_POST['ID']); + } } } elseif ($_POST['action'] == "do_Disown" || isset($_POST['do_Disown'])) { if ($atype && !empty($ids)) { @@ -107,6 +119,12 @@ if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) { $q.= "AND ".$field." = ".uid_from_sid($_COOKIE["AURSID"]); } db_query($q, $dbh); + + if ($_POST['action'] == "do_Disown") { + header("Location: packages.php"); + } else { + header("Location: packages.php?ID=" . $_POST['ID']); + } } } elseif ($_POST['action'] == "do_Delete" || isset($_POST['do_Delete'])) { if ($atype && !empty($ids)) { @@ -169,6 +187,8 @@ if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) { $q = "DELETE FROM CommentNotify WHERE PkgID = " . $id; $result = db_query($q, $dbh); } + + header("Location: packages.php"); } } elseif ($_POST['action'] == "do_Adopt" || isset($_POST['do_Adopt'])) { if ($atype && !empty($ids)) { @@ -200,6 +220,12 @@ if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) { $q.= " AND LocationID = 2"; } db_query($q, $dbh); + + if ($_POST['action'] == "do_Adopt") { + header("Location: packages.php"); + } else { + header("Location: packages.php?ID=" . $_POST['ID']); + } } } elseif ($_POST['action'] == "do_Vote" || isset($_POST['do_Vote'])) { if ($atype && !empty($ids)) { @@ -239,9 +265,15 @@ if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) { $q = "UPDATE Users SET LastVoted = UNIX_TIMESTAMP() "; $q.= "WHERE ID = ".$uid; db_query($q, $dbh); + + if ($_POST['action'] == "do_Vote") { + header("Location: packages.php"); + } else { + header("Location: packages.php?ID=" . $_POST['ID']); + } } } elseif ($_POST['action'] == "do_UnVote" || isset($_POST['do_UnVote'])) { - if (!$atype && !empty($ids)) { + if ($atype && !empty($ids)) { $dbh = db_connect(); $my_votes = pkgvotes_from_sid($_COOKIE["AURSID"]); $uid = uid_from_sid($_COOKIE["AURSID"]); @@ -270,6 +302,12 @@ if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) { $q = "DELETE FROM PackageVotes WHERE UsersID = ".$uid." "; $q.= "AND PackageID IN (".$unvote_ids.")"; db_query($q, $dbh); + + if ($_POST['action'] == "do_UnVote") { + header("Location: packages.php"); + } else { + header("Location: packages.php?ID=" . $_POST['ID']); + } } } elseif ($_POST['action'] == "do_Notify" || isset($_POST['do_Notify'])) { if ($atype && !empty($ids)) { @@ -294,6 +332,14 @@ if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) { db_query($q, $dbh); } } + + # I'm /pretty/ sure this is necessary because I can't just reference + # the first element of the array. + if ($_POST['action'] == "do_Notify") { + header("Location: packages.php"); + } else { + header("Location: packages.php?ID=" . $_POST['ID']); + } } } @@ -314,156 +360,16 @@ if (isset($_GET['ID'])) { html_header($title); # determine what button the visitor clicked -# Output - get rid of this soon -if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) { - if (!$atype) { - print __("You must be logged in before you can flag packages."); - print "<br />\n"; - } else { - if (!empty($ids)) { - print "<p>\n"; - print __("The selected packages have been flagged out-of-date."); - print "</p>\n"; - } else { - print "<p>\n"; - print __("You did not select any packages to flag."); - print "</p>\n"; - } - } -} elseif ($_POST['action'] == "do_UnFlag" || isset($_POST['do_UnFlag'])) { - if (!$atype) { - print __("You must be logged in before you can unflag packages."); - print "<br />\n"; - } else { - if (!empty($ids)) { - print "<p>\n"; - print __("The selected packages have been unflagged."); - print "</p>\n"; - } else { - print "<p>\n"; - print __("You did not select any packages to unflag."); - print "</p>\n"; - } - } -} elseif ($_POST['action'] == "do_Disown" || isset($_POST['do_Disown'])) { - if (!$atype) { - print __("You must be logged in before you can disown packages."); - print "<br />\n"; - } else { - if (!empty($ids)) { - print "<p>\n"; - print __("The selected packages have been disowned."); - print "</p>\n"; - } else { - print "<p>\n"; - print __("You did not select any packages to disown."); - print "</p>\n"; - } - } -} elseif ($_POST['action'] == "do_Delete" || isset($_POST['do_Delete'])) { - if (!$atype) { - print __("You must be logged in before you can disown packages."); - print "<br />\n"; - } else { - if (!empty($ids)) { - if (!empty($ids_to_delete)) { - print "<p>\n"; - print __("The selected packages have been deleted."); - print "</p>\n"; - } else { - print "<p>\n"; - print __("None of the selected packages could be deleted."); - print "</p>\n"; - } - } else { - print "<p>\n"; - print __("You did not select any packages to delete."); - print "</p>\n"; - } - } -} elseif ($_POST['action'] == "do_Adopt" || isset($_POST['do_Adopt'])) { - if (!$atype) { - print __("You must be logged in before you can adopt packages."); - print "<br />\n"; - } else { - if (!empty($ids)) { - print "<p>\n"; - print __("The selected packages have been adopted."); - print "</p>\n"; - } else { - print "<p>\n"; - print __("You did not select any packages to adopt."); - print "</p>\n"; - } - } -} elseif ($_POST['action'] == "do_Vote" || isset($_POST['do_Vote'])) { - if (!$atype) { - print __("You must be logged in before you can vote for packages."); - print "<br />\n"; - } else { - if (!empty($ids)) { - print "<p>\n"; - print __("Your votes have been cast for the selected packages."); - print "</p>\n"; - - } else { - print "<p>\n"; - print __("You did not select any packages to vote for."); - print "</p>\n"; - } - } -} elseif ($_POST['action'] == "do_UnVote" || isset($_POST['do_UnVote'])) { - if (!$atype) { - print __("You must be logged in before you can un-vote for packages."); - print "<br />\n"; - } else { - if (!empty($ids)) { - print "<p>\n"; - print __("Your votes have been removed from the selected packages."); - print "</p>\n"; - } else { - print "<p>\n"; - print __("You did not select any packages to un-vote for."); - print "</p>\n"; - } - } -} elseif (isset($_GET["ID"])) { +# Output +if (isset($_GET["ID"])) { if (!intval($_GET["ID"])) { print __("Error trying to retrieve package details.")."<br />\n"; } else { package_details($_GET["ID"], $_COOKIE["AURSID"]); } -} elseif ($_POST['action'] == "do_Notify" || isset($_POST['do_Notify'])) { - if (!$atype) { - print __("You must be logged in before you can get notifications on comments."); - print "<br />\n"; - } else { - if (!empty($ids)) { - foreach ($ids as $pid => $v) { - if (!$notifypackages) { - print '<p>'; - print __("You have been added to the comment notification list for %s.", - array("<b>" . $pkgname . "</b>")); - print '<br /></p>'; - } else { - print '<p>'; - print __("You have been removed from the comment notification list for %s.", - array("<b>" . $pkgname . "</b>")); - print '<br /></p>'; - } - } - } else { - print '<p>'; - print __("Couldn't add to notification list."); - print '<br /></p>'; - } - } } else { # Just do a search. pkg_search_page($_COOKIE["AURSID"]); - } html_footer(AUR_VERSION); - -?> -- 1.5.5.3
On Mon, Sep 29, 2008 at 04:14:04AM +0800, Callan Barrett wrote:
No more useless "congratulations you've done this" pages
Shit is SO cash!
I still think feedback from the app is nice so I think the messages should just be printed on the page directed to.
On Mon, Sep 29, 2008 at 5:53 AM, Loui <louipc.ist@gmail.com> wrote:
On Mon, Sep 29, 2008 at 04:14:04AM +0800, Callan Barrett wrote:
No more useless "congratulations you've done this" pages
Shit is SO cash!
I still think feedback from the app is nice so I think the messages should just be printed on the page directed to.
Yeah, sure. That sounds good. I'll take a crack at it today. -- Callan Barrett
Disregard this patch too. -- Callan Barrett
participants (2)
-
Callan Barrett
-
Loui