summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreric <eric>2005-03-20 18:54:20 +0000
committereric <eric>2005-03-20 18:54:20 +0000
commit7fccb8b634118a2f4f92220b194dc74273b15957 (patch)
tree4b55e81a25f3005abaf3cd7cdc5b0de8316a541f
parent9d69979bb9e8498ac1ac6b4d08fb6b3ba9042cdc (diff)
added comments/category editing, and closed #2280
-rw-r--r--support/schema/aur-schema.sql2
-rw-r--r--web/html/images/x.pngbin0 -> 725 bytes
-rw-r--r--web/html/pkgedit.php131
-rw-r--r--web/html/pkgsubmit.php7
-rw-r--r--web/lang/pkgedit_po.inc79
-rw-r--r--web/lang/pkgfuncs_po.inc20
-rw-r--r--web/lang/submit_po.inc4
-rw-r--r--web/lib/pkgfuncs.inc52
8 files changed, 275 insertions, 20 deletions
diff --git a/support/schema/aur-schema.sql b/support/schema/aur-schema.sql
index 2d70dae..0656f0e 100644
--- a/support/schema/aur-schema.sql
+++ b/support/schema/aur-schema.sql
@@ -183,11 +183,13 @@ CREATE TABLE PackageContents (
-- Record comments for packages
--
CREATE TABLE PackageComments (
+ ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
PackageID INTEGER UNSIGNED NOT NULL,
UsersID INTEGER UNSIGNED NOT NULL,
Comments TEXT NOT NULl DEFAULT '',
CommentTS BIGINT UNSIGNED NOT NULL DEFAULT 0,
DelUsersID INTEGER UNSIGNED NOT NULL DEFAULT 0,
+ PRIMARY KEY (ID),
INDEX (UsersID),
INDEX (PackageID),
FOREIGN KEY (UsersID) REFERENCES Users(ID) ON DELETE CASCADE,
diff --git a/web/html/images/x.png b/web/html/images/x.png
new file mode 100644
index 0000000..a85e169
--- /dev/null
+++ b/web/html/images/x.png
Binary files 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 @@
<?
include("aur.inc"); # access AUR common functions
include("pkgfuncs.inc"); # use some form of this for i18n support
+include("pkgedit_po.inc"); # i18n translations for this script
set_lang(); # this sets up the visitor's language
check_sid(); # see if they're still logged in
html_header(); # print out the HTML header
-
+$svn_idstr = "\$Id$";
$DBUG = 0;
if ($DBUG) {
@@ -13,36 +14,142 @@ if ($DBUG) {
print "</pre>\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 "<br />\n";
-} else {
- if (!$_REQUEST["ID"]) {
- print __("Missing package ID.");
- print "<br />\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 "<br />\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.")."<br />\n";
+ } else {
+ print __("You are not allowed to delete this comment.")."<br />\n";
+ }
} else {
+ print __("Missing comment ID.")."<br />\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.")."<br />&nbsp;<br />\n";
+ pkgdetails_link($_REQUEST["ID"]);
+
+ } else {
+ # Prompt visitor for comment
+ #
+ print "<form action='/pkgedit.php' method='post'>\n";
+ print "<input type='hidden' name='add_Comment' value='1'>\n";
+ print "<input type='hidden' name='ID' value=\"".$_REQUEST["ID"]."\">\n";
+ print __("Enter your comment below.")."<br />&nbsp;<br />\n";
+ print "<textarea name='comment' rows='10' cols='50'></textarea>\n";
+ print "<br />&nbsp;<br />\n";
+ print "<input type='submit' value=\"".__("Submit")."\">\n";
+ print "<input type='reset' value=\"".__("Reset")."\">\n";
+ print "</form>\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.")."<br />\n";
+
+ } else {
+ print __("Invalid category ID.")."<br />\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 "<form action='/pkgedit.php' method='post'>\n";
+ print "<input type='hidden' name='change_Category' value='1'>\n";
+ print "<input type='hidden' name='ID' value=\"".$_REQUEST["ID"]."\">\n";
+ print __("Select new category").":&nbsp;\n";
+ print "<select name='category_id'>\n";
+ while (list($id,$cat) = each($cat_array)) {
+ print "<option value='".$id."'";
+ if ($id == $catid[0]) {
+ print " selected";
}
+ print "> ".$cat."</option>\n";
}
+ print "</select>\n";
+ print "<br />&nbsp;<br />\n";
+ print "<input type='submit' value=\"".__("Submit")."\">\n";
+ print "<input type='reset' value=\"".__("Reset")."\">\n";
+ print "</form>\n";
}
+ html_footer($svn_idstr);
+ exit();
}
-html_footer("\$Id$"); # Use the $Id$ keyword
+print __("You've found a bug if you see this....")."<br />\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 "<br />\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 @@
+<?
+# INSTRUCTIONS TO TRANSLATORS
+#
+# This file contains the i18n translations for a subset of the
+# Arch Linux User-community Repository (AUR). This is a PHP
+# script, and as such, you MUST pay great attention to the syntax.
+# If your text contains any double-quotes ("), you MUST escape
+# them with the backslash character (\).
+#
+
+include_once("translator.inc");
+global $_t;
+
+$_t["en"]["You must be logged in before you can edit package information."] = "You must be logged in before you can edit package information.";
+# $_t["es"]["Category"] = "--> 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 = "<a href='/packages.php?do_Details=1&ID=".intval($id)."'>";
+ print __("Go back to %hpackage details view%h.",
+ array($url_data, "</a>"));
+ print "\n<br />\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 "</tr>\n";
print "<tr>\n";
print " <td colspan='2'><span class='f3'>";
- print $row["Location"]." :: ".$row["Category"]."</span></td>";
+ $edit_cat = "<a href='/pkgedit.php?change_Category=1&ID=";
+ $edit_cat .= intval($_REQUEST["ID"])."'>".$row["Category"]."</a>";
+ $edit_cat .= " &nbsp;<span class='fix'>(";
+ $edit_cat .= __("change category").")</span>";
+ print $row["Location"]." :: ".$edit_cat."</span></td>";
print "</tr>\n";
print "<tr>\n";
print " <td colspan='2'><span class='f3'>".__("Maintainer").": ";
@@ -344,10 +383,15 @@ function package_details($id=0) {
print " <td valign='top' style='padding-right: 10' colspan='2'>";
print "<table class='boxSoft' width='100%'>";
print "<tr><td class='boxSoftTitle'><span class='f3'>";
+ $durl = "<a href='/pkgedit.php?del_Comment=1";
+ $durl.= "&comment_id=".$carr["ID"]."&ID=".$row["ID"];
+ $durl.= "'><img src='/images/x.png' border='0'";
+ $durl.= " alt=\"".__("Delete comment")."\"></a>";
+ print $durl . "&nbsp;&nbsp;";
print __("Comment by: %h%s%h on %h%s%h",
array("<b>",$carr["UserName"],"</b>",
"<i>",date("Ymd [H:i:s]",$carr["CommentTS"]),"</i>"));
- print "</span></td></tr>\n";
+ print "</span>";
print "<tr><td class='boxSoft'>";
print "<pre>\n";
print str_replace('"',"&quot;", 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 "</span></span></td>\n";