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/pkgedit.php | 131 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 119 insertions(+), 12 deletions(-) (limited to 'web/html/pkgedit.php') 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 ?> -- cgit v1.2.3-70-g09d2