mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 09:43:03 +00:00
added comments/category editing, and closed #2280
This commit is contained in:
parent
9d69979bb9
commit
7fccb8b634
8 changed files with 282 additions and 27 deletions
BIN
web/html/images/x.png
Normal file
BIN
web/html/images/x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 725 B |
|
@ -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";
|
||||
} else {
|
||||
|
||||
# Main script processing here... basic error checking done.
|
||||
#
|
||||
if ($_REQUEST["add_Comment"]) {
|
||||
if ($_REQUEST["comment"]) {
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
html_footer($svn_idstr);
|
||||
exit();
|
||||
}
|
||||
|
||||
html_footer("\$Id$"); # Use the $Id$ keyword
|
||||
# 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();
|
||||
}
|
||||
|
||||
# Add a comment to this package
|
||||
#
|
||||
if ($_REQUEST["add_Comment"]) {
|
||||
if ($_REQUEST["comment"]) {
|
||||
# Insert the comment
|
||||
#
|
||||
$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 /> <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 /> <br />\n";
|
||||
print "<textarea name='comment' rows='10' cols='50'></textarea>\n";
|
||||
print "<br /> <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").": \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 /> <br />\n";
|
||||
print "<input type='submit' value=\"".__("Submit")."\">\n";
|
||||
print "<input type='reset' value=\"".__("Reset")."\">\n";
|
||||
print "</form>\n";
|
||||
|
||||
}
|
||||
html_footer($svn_idstr);
|
||||
exit();
|
||||
}
|
||||
|
||||
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
|
||||
?>
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue