From 7fccb8b634118a2f4f92220b194dc74273b15957 Mon Sep 17 00:00:00 2001 From: eric Date: Sun, 20 Mar 2005 18:54:20 +0000 Subject: added comments/category editing, and closed #2280 --- web/html/images/x.png | Bin 0 -> 725 bytes web/html/pkgedit.php | 131 ++++++++++++++++++++++++++++++++++++++++++----- web/html/pkgsubmit.php | 7 ++- web/lang/pkgedit_po.inc | 79 ++++++++++++++++++++++++++++ web/lang/pkgfuncs_po.inc | 20 ++++++++ web/lang/submit_po.inc | 4 +- web/lib/pkgfuncs.inc | 52 +++++++++++++++++-- 7 files changed, 273 insertions(+), 20 deletions(-) create mode 100644 web/html/images/x.png create mode 100644 web/lang/pkgedit_po.inc (limited to 'web') diff --git a/web/html/images/x.png b/web/html/images/x.png new file mode 100644 index 0000000..a85e169 Binary files /dev/null and b/web/html/images/x.png differ diff --git a/web/html/pkgedit.php b/web/html/pkgedit.php index 974c3ad..6a3f9ff 100644 --- a/web/html/pkgedit.php +++ b/web/html/pkgedit.php @@ -1,10 +1,11 @@ \n"; } +# Make sure this visitor is logged in +# if (isset($_COOKIE["AURSID"])) { $atype = account_from_sid($_COOKIE["AURSID"]); } else { $atype = ""; } - if (!$atype) { print __("You must be logged in before you can edit package information."); print "
\n"; -} else { - if (!$_REQUEST["ID"]) { - print __("Missing package ID."); - print "
\n"; + html_footer($svn_idstr); + exit(); +} + +# Must know what package to operate on throughout this entire script +# +if (!$_REQUEST["ID"]) { + print __("Missing package ID."); + print "
\n"; + html_footer($svn_idstr); +} + + +# Delete a comment for this package +# +if ($_REQUEST["del_Comment"]) { + if ($_REQUEST["comment_id"]) { + if (canDeleteComment($_REQUEST["comment_id"], $atype, $_COOKIE["AURSID"])) { + $dbh = db_connect(); + $uid = uid_from_sid($_COOKIE["AURSID"]); + $q = "UPDATE PackageComments "; + $q.= "SET DelUsersID = ".$uid." "; + $q.= "WHERE ID = ".intval($_REQUEST["comment_id"]); + db_query($q, $dbh); + print __("Comment has been deleted.")."
\n"; + } else { + print __("You are not allowed to delete this comment.")."
\n"; + } } else { + print __("Missing comment ID.")."
\n"; + } + pkgdetails_link($_REQUEST["ID"]); + html_footer($svn_idstr); + exit(); +} - # Main script processing here... basic error checking done. +# Add a comment to this package +# +if ($_REQUEST["add_Comment"]) { + if ($_REQUEST["comment"]) { + # Insert the comment # - if ($_REQUEST["add_Comment"]) { - if ($_REQUEST["comment"]) { - } else { + $dbh = db_connect(); + $q = "INSERT INTO PackageComments "; + $q.= "(PackageID, UsersID, Comments, CommentTS) VALUES ("; + $q.= intval($_REQUEST["ID"]).", ".uid_from_sid($_COOKIE["AURSID"]) . ", "; + $q.= "'".mysql_escape_string($_REQUEST["comment"])."', "; + $q.= "UNIX_TIMESTAMP())"; + db_query($q, $dbh); + print __("Comment has been added.")."
 
\n"; + pkgdetails_link($_REQUEST["ID"]); + + } else { + # Prompt visitor for comment + # + print "
\n"; + print "\n"; + print "\n"; + print __("Enter your comment below.")."
 
\n"; + print "\n"; + print "
 
\n"; + print "\n"; + print "\n"; + print "
\n"; + } + html_footer($svn_idstr); + exit(); +} + +# Change package category +# +if ($_REQUEST["change_Category"]) { + $cat_array = pkgCategories(); + $dbh = db_connect(); + + if ($_REQUEST["category_id"]) { + # Try and set the requested category_id + # + if (array_key_exists($_REQUEST["category_id"], $cat_array)) { + $q = "UPDATE Packages SET CategoryID = ".intval($_REQUEST["category_id"]); + $q.= " WHERE ID = ".intval($_REQUEST["ID"]); + db_query($q, $dbh); + print __("Package category updated.")."
\n"; + + } else { + print __("Invalid category ID.")."
\n"; + } + pkgdetails_link($_REQUEST["ID"]); + + } else { + # Prompt visitor for new category_id + # + $q = "SELECT CategoryID FROM Packages WHERE ID = ".intval($_REQUEST["ID"]); + $result = db_query($q, $dbh); + if ($result != NULL) { + $catid = mysql_fetch_row($result); + } + print "
\n"; + print "\n"; + print "\n"; + print __("Select new category").": \n"; + print "\n"; + print "
 
\n"; + print "\n"; + print "\n"; + print "
\n"; } + html_footer($svn_idstr); + exit(); } -html_footer("\$Id$"); # Use the $Id$ keyword +print __("You've found a bug if you see this....")."
\n"; + +html_footer($svn_idstr); # Use the $Id$ keyword # NOTE: when checking in a new file, use # 'svn propset svn:keywords "Id" filename.php' # to tell svn to expand the "Id" keyword. -# vim: ts=2 sw=2 et ft=php +# vim: ts=2 sw=2 noet ft=php ?> diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index d679704..bd635f4 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -239,7 +239,10 @@ if ($_COOKIE["AURSID"]) { $seen_build_function = 1; } } - if ($seen_build_function) {break;} + # XXX: closes bug #2280? Might as well let the loop complete rather + # than break after the build() function. + # + #if ($seen_build_function) {break;} } # some error checking on PKGBUILD contents - just make sure each @@ -534,7 +537,7 @@ if ($_COOKIE["AURSID"]) { print "
\n"; } } else { - print __("Package upload successful"); + print __("Package upload successful."); } } else { diff --git a/web/lang/pkgedit_po.inc b/web/lang/pkgedit_po.inc new file mode 100644 index 0000000..fb51cb6 --- /dev/null +++ b/web/lang/pkgedit_po.inc @@ -0,0 +1,79 @@ + Traducción española aquí. <--"; +# $_t["fr"]["Category"] = "--> Traduction française ici. <--"; +# $_t["de"]["Category"] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["Missing package ID."] = "Missing package ID."; +# $_t["es"]["Category"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Category"] = "--> Traduction française ici. <--"; +# $_t["de"]["Category"] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["Comment has been deleted."] = "Comment has been deleted."; +# $_t["es"]["Category"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Category"] = "--> Traduction française ici. <--"; +# $_t["de"]["Category"] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["You are not allowed to delete this comment."] = "You are not allowed to delete this comment."; +# $_t["es"]["Category"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Category"] = "--> Traduction française ici. <--"; +# $_t["de"]["Category"] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["Missing comment ID."] = "Missing comment ID."; +# $_t["es"]["Category"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Category"] = "--> Traduction française ici. <--"; +# $_t["de"]["Category"] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["Comment has been added."] = "Comment has been added."; +# $_t["es"]["Category"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Category"] = "--> Traduction française ici. <--"; +# $_t["de"]["Category"] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["Enter your comment below."] = "Enter your comment below."; +# $_t["es"]["Category"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Category"] = "--> Traduction française ici. <--"; +# $_t["de"]["Category"] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["Submit"] = "Submit"; +# $_t["es"]["Category"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Category"] = "--> Traduction française ici. <--"; +# $_t["de"]["Category"] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["Reset"] = "Reset"; +# $_t["es"]["Category"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Category"] = "--> Traduction française ici. <--"; +# $_t["de"]["Category"] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["Package category updated."] = "Package category updated."; +# $_t["es"]["Category"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Category"] = "--> Traduction française ici. <--"; +# $_t["de"]["Category"] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["Invalid category ID."] = "Invalid category ID."; +# $_t["es"]["Category"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Category"] = "--> Traduction française ici. <--"; +# $_t["de"]["Category"] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["Select new category"] = "Select new category"; +# $_t["es"]["Category"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Category"] = "--> Traduction française ici. <--"; +# $_t["de"]["Category"] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["You've found a bug if you see this...."] = "You've found a bug if you see this...."; +# $_t["es"]["Category"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Category"] = "--> Traduction française ici. <--"; +# $_t["de"]["Category"] = "--> Deutsche Übersetzung hier. <--"; + +?> diff --git a/web/lang/pkgfuncs_po.inc b/web/lang/pkgfuncs_po.inc index 2d0b069..2910009 100644 --- a/web/lang/pkgfuncs_po.inc +++ b/web/lang/pkgfuncs_po.inc @@ -11,6 +11,26 @@ include_once("translator.inc"); global $_t; +$_t["en"]["Go back to %hpackage details view%h."] = "Go back to %hpackage details view%h."; +# $_t["es"]["Category"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Category"] = "--> Traduction française ici. <--"; +# $_t["de"]["Category"] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["None"] = "None"; +# $_t["es"]["Category"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Category"] = "--> Traduction française ici. <--"; +# $_t["de"]["Category"] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["change category"] = "change category"; +# $_t["es"]["Category"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Category"] = "--> Traduction française ici. <--"; +# $_t["de"]["Category"] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["Delete comment"] = "Delete comment"; +# $_t["es"]["Category"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Category"] = "--> Traduction française ici. <--"; +# $_t["de"]["Category"] = "--> Deutsche Übersetzung hier. <--"; + $_t["en"]["Comment by: %h%s%h on %h%s%h"] = "Comment by: %h%s%h on %h%s%h"; # $_t["es"]["Category"] = "--> Traducción española aquí. <--"; # $_t["fr"]["Category"] = "--> Traduction française ici. <--"; diff --git a/web/lang/submit_po.inc b/web/lang/submit_po.inc index 88acd50..c21482a 100644 --- a/web/lang/submit_po.inc +++ b/web/lang/submit_po.inc @@ -196,9 +196,9 @@ $_t["en"]["You must supply a comment for this upload/change."] = "You must suppl # $_t["fr"]["You must supply a comment for this upload/change."] = "--> Traduction française ici. <--"; # $_t["de"]["You must supply a comment for this upload/change."] = "--> Deutsche Übersetzung hier. <--"; -$_t["en"]["Package upload successful"] = "Package upload successful"; +$_t["en"]["Package upload successful."] = "Package upload successful."; # $_t["es"]["Package upload successful"] = "--> Traducción española aquí. <--"; # $_t["fr"]["Package upload successful"] = "--> Traduction française ici. <--"; # $_t["de"]["Package upload successful"] = "--> Deutsche Übersetzung hier. <--"; -?> \ No newline at end of file +?> diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index 00831de..a72b5f5 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -6,6 +6,17 @@ include_once("pkgfuncs_po.inc"); $pkgsearch_vars = array("O", "L", "C", "K", "SB", "PP", "do_MyPackages"); +# print out the 'return to package details' link +# +function pkgdetails_link($id=0) { + $url_data = ""; + print __("Go back to %hpackage details view%h.", + array($url_data, "")); + print "\n
\n"; + return; +} + + # print out the 'return to search results' link # function pkgsearch_results_link() { @@ -28,6 +39,30 @@ function pkgsearch_results_link() { return; } +# Make sure this visitor can delete the requested package comment +# They can delete if they were the comment submitter, or if they are a TU/Dev +# +function canDeleteComment($comment_id=0, $atype="", $SID="") { + if ($atype == "Trusted User" || $atype == "Developer") { + # A TU/Dev can delete any comment + # + return TRUE; + } + $uid = uid_from_sid($SID); + $dbh = db_connect(); + $q = "SELECT COUNT(ID) AS CNT "; + $q.= "FROM PackageComments "; + $q.= "WHERE ID = " . intval($comment_id); + $q.= " AND UsersID = " . $uid; + $result = db_query($q, $dbh); + if ($result != NULL) { + $row = mysql_fetch_assoc($result); + if ($row['CNT'] > 0) { + return TRUE; + } + } + return FALSE; +} # see if this Users.ID can manage the package # @@ -154,7 +189,7 @@ function package_comments($pkgid=0) { $comments = array(); if ($pkgid) { $dbh = db_connect(); - $q = "SELECT UserName, Comments, CommentTS "; + $q = "SELECT PackageComments.ID, UserName, Comments, CommentTS "; $q.= "FROM PackageComments, Users "; $q.= "WHERE PackageComments.UsersID = Users.ID"; $q.= " AND PackageID = ".mysql_escape_string($pkgid); @@ -261,7 +296,11 @@ function package_details($id=0) { print "\n"; print "\n"; print " "; - print $row["Location"]." :: ".$row["Category"].""; + $edit_cat = "".$row["Category"].""; + $edit_cat .= "  ("; + $edit_cat .= __("change category").")"; + print $row["Location"]." :: ".$edit_cat.""; print "\n"; print "\n"; print " ".__("Maintainer").": "; @@ -344,10 +383,15 @@ function package_details($id=0) { print " "; print ""; print "\n"; + print ""; print "\n"; -- cgit v1.2.3-70-g09d2
"; + $durl = ""; + print $durl . "  "; print __("Comment by: %h%s%h on %h%s%h", array("",$carr["UserName"],"", "",date("Ymd [H:i:s]",$carr["CommentTS"]),"")); - print "
"; print "
\n";
 					print str_replace('"',""", stripslashes($carr["Comments"]));
@@ -783,7 +827,7 @@ function pkg_search_page($SID="") {
 			} elseif (isset($tus[$row["MaintainerUID"]])) {
 				print $tus[$row["MaintainerUID"]]["Username"];
 			} else {
-				print "None";
+				print __("None");
 				$managed = 0;
 			}
 			print "