From e3587ddf94ba742beabdaa8a68023f8ee0234b58 Mon Sep 17 00:00:00 2001 From: eric Date: Sun, 6 Mar 2005 21:44:56 +0000 Subject: started working on pkgedit for comments --- support/schema/aur-schema.sql | 2 ++ support/schema/dummy-data.sql.bz2 | Bin 1884846 -> 1882935 bytes support/schema/gendummydata.py | 4 +-- web/html/packages.php | 3 -- web/html/pkgedit.php | 48 ++++++++++++++++++++++++++ web/html/pkgmgmnt.php | 19 ----------- web/lang/pkgfuncs_po.inc | 30 ++++++++++++++++ web/lib/pkgfuncs.inc | 70 +++++++++++++++++++++++++++++++++++--- 8 files changed, 148 insertions(+), 28 deletions(-) create mode 100644 web/html/pkgedit.php delete mode 100644 web/html/pkgmgmnt.php diff --git a/support/schema/aur-schema.sql b/support/schema/aur-schema.sql index c2cd08b..2d70dae 100644 --- a/support/schema/aur-schema.sql +++ b/support/schema/aur-schema.sql @@ -187,9 +187,11 @@ CREATE TABLE PackageComments ( UsersID INTEGER UNSIGNED NOT NULL, Comments TEXT NOT NULl DEFAULT '', CommentTS BIGINT UNSIGNED NOT NULL DEFAULT 0, + DelUsersID INTEGER UNSIGNED NOT NULL DEFAULT 0, INDEX (UsersID), INDEX (PackageID), FOREIGN KEY (UsersID) REFERENCES Users(ID) ON DELETE CASCADE, + FOREIGN KEY (DelUsersID) REFERENCES Users(ID) ON DELETE CASCADE, FOREIGN KEY (PackageID) REFERENCES Packages(ID) ON DELETE CASCADE ); diff --git a/support/schema/dummy-data.sql.bz2 b/support/schema/dummy-data.sql.bz2 index cf1c87a..e342e28 100644 Binary files a/support/schema/dummy-data.sql.bz2 and b/support/schema/dummy-data.sql.bz2 differ diff --git a/support/schema/gendummydata.py b/support/schema/gendummydata.py index fd82bea..9915f58 100755 --- a/support/schema/gendummydata.py +++ b/support/schema/gendummydata.py @@ -267,9 +267,9 @@ for p in seen_pkgs.keys(): # num_comments = random.randrange(PKG_CMNTS[0], PKG_CMNTS[1]) for i in range(0, num_comments): - fortune = esc(commands.getoutput(FORTUNE_CMD).replace("'","").replace("\n"," ")) + fortune = esc(commands.getoutput(FORTUNE_CMD).replace("'","")) now = NOW + random.randrange(400, 86400*3) - s = "INSERT INTO PackageComments (PackageID, UsersID, Comments, CommentTS) VALUES (%d, %d, '%s', %d);\n" % (seen_pkgs[p], uuid, fortune, now) + s = "INSERT INTO PackageComments (PackageID, UsersID, Comments, CommentTS) VALUES (%d, %d, '%s', %d);\n" % (seen_pkgs[p], genUID(), fortune, now) out.write(s) if location_id == 1: # Unsupported - just a PKGBUILD and maybe other stuff diff --git a/web/html/packages.php b/web/html/packages.php index 823a4ca..a211b34 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -133,7 +133,6 @@ if (isset($_REQUEST["do_Flag"])) { $disown .= ", ".$pid; } } - $atype = account_from_sid($_COOKIE["AURSID"]); if ($atype == "Trusted User" || $atype == "Developer") { $field = "AURMaintainerUID"; } elseif ($atype == "User") { @@ -185,7 +184,6 @@ if (isset($_REQUEST["do_Flag"])) { $delete .= ", ".$pid; } } - $atype = account_from_sid($_COOKIE["AURSID"]); if ($atype == "Trusted User" || $atype == "Developer") { $field = "AURMaintainerUID"; } elseif ($atype == "User") { @@ -282,7 +280,6 @@ if (isset($_REQUEST["do_Flag"])) { $adopt .= ", ".$pid; } } - $atype = account_from_sid($_COOKIE["AURSID"]); if ($atype == "Trusted User" || $atype == "Developer") { $field = "AURMaintainerUID"; } elseif ($atype == "User") { diff --git a/web/html/pkgedit.php b/web/html/pkgedit.php new file mode 100644 index 0000000..974c3ad --- /dev/null +++ b/web/html/pkgedit.php @@ -0,0 +1,48 @@ +\n"; + print_r($_REQUEST); + print "\n"; +} + +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"; + } else { + + # Main script processing here... basic error checking done. + # + if ($_REQUEST["add_Comment"]) { + if ($_REQUEST["comment"]) { + } else { + } + } + + } +} + +html_footer("\$Id$"); # 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 +?> diff --git a/web/html/pkgmgmnt.php b/web/html/pkgmgmnt.php deleted file mode 100644 index 6c8cddd..0000000 --- a/web/html/pkgmgmnt.php +++ /dev/null @@ -1,19 +0,0 @@ -\n"; - -# NOTE: managing an orphaned package will automatically force adoption -# - - -html_footer("\$Id$"); -# vim: ts=2 sw=2 noet ft=php -?> diff --git a/web/lang/pkgfuncs_po.inc b/web/lang/pkgfuncs_po.inc index 33d109b..3d31523 100644 --- a/web/lang/pkgfuncs_po.inc +++ b/web/lang/pkgfuncs_po.inc @@ -11,6 +11,36 @@ include_once("translator.inc"); global $_t; +$_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. <--"; +# $_t["de"]["Category"] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["Add Comment"] = "Add Comment"; +# $_t["es"]["Category"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Category"] = "--> Traduction française ici. <--"; +# $_t["de"]["Category"] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["Comments"] = "Comments"; +# $_t["es"]["Category"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Category"] = "--> Traduction française ici. <--"; +# $_t["de"]["Category"] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["Sources"] = "Sources"; +# $_t["es"]["Category"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Category"] = "--> Traduction française ici. <--"; +# $_t["de"]["Category"] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["Dependencies"] = "Dependencies"; +# $_t["es"]["Category"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Category"] = "--> Traduction française ici. <--"; +# $_t["de"]["Category"] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["Package Details"] = "Package Details"; +# $_t["es"]["Category"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Category"] = "--> Traduction française ici. <--"; +# $_t["de"]["Category"] = "--> Deutsche Übersetzung hier. <--"; + $_t["en"]["Category"] = "Category"; # $_t["es"]["Category"] = "--> Traducción española aquí. <--"; # $_t["fr"]["Category"] = "--> Traduction française ici. <--"; diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index 0b451ce..f832111 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -148,6 +148,27 @@ function create_dummy($pname="", $sid="") { } +# grab package comments +# +function package_comments($pkgid=0) { + $comments = array(); + if ($pkgid) { + $dbh = db_connect(); + $q = "SELECT UserName, Comments, CommentTS "; + $q.= "FROM PackageComments, Users "; + $q.= "WHERE PackageComments.UsersID = Users.ID"; + $q.= " AND PackageID = ".mysql_escape_string($pkgid); + $q.= " AND DelUsersID = 0"; # only display non-deleted comments + $q.= " ORDER BY CommentTS ASC"; + $result = db_query($q, $dbh); + if (!$result) {return array();} + while ($row = mysql_fetch_assoc($result)) { + $comments[] = $row; + } + } + return $comments; +} + # grab package sources # function package_sources($pkgid=0) { @@ -217,7 +238,7 @@ function package_details($id=0) { print "\n"; print "\n"; print " \n"; + print "".__("Package Details")."\n"; print "\n"; print "\n"; print "
"; - print "Package Details
\n"; @@ -267,7 +288,7 @@ function package_details($id=0) { print " "; print ""; print "\n"; + print __("Dependencies")."\n"; print ""; + print "\n"; + + # Display package comments + # + $comments = package_comments($row["ID"]); + if (!empty($comments)) { + while (list($indx, $carr) = each($comments)) { + print "\n"; + print " \n"; + + print "\n"; + print " \n"; + print "\n"; + } + } + print "\n"; + print " \n"; + print "\n"; + print " "; print "\n"; print "
"; - print "Dependencies
"; $deps = package_dependencies($row["ID"]); # $deps[0] = array('id','name', 'dummy'); while (list($k, $darr) = each($deps)) { @@ -289,7 +310,7 @@ function package_details($id=0) { print " "; print ""; print "\n"; + print __("Sources")."\n"; print "\n"; print "
"; - print "Sources
"; $sources = package_sources($row["ID"]); # $sources[0] = 'src'; while (list($k, $src) = each($sources)) { @@ -302,12 +323,53 @@ function package_details($id=0) { else { //It is presumably an internal source - print "".$src."
\n"; + print "".$src."
\n"; } } print "
"; + print "
"; + print ""; + print "\n"; + print "\n"; + print "
"; + 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"]));
+					print "
\n"; + print "
\n"; + print "
"; + print "
"; + print "
\n"; + print "\n"; + print ""; + print "
\n"; + print "
\n"; -- cgit v1.2.3-70-g09d2