From ae26c9ce2a0bfe6ed0f5282f08cb672364de1c19 Mon Sep 17 00:00:00 2001 From: eric Date: Fri, 2 Jul 2004 12:47:16 +0000 Subject: baby steps --- web/html/logout.php | 1 + web/html/pkgsearch.php | 15 +------ web/lang/pkgfuncs_po.inc | 25 +++++++++++ web/lang/search_po.inc | 15 +++++++ web/lib/aur.inc | 3 +- web/lib/pkgfuncs.inc | 109 ++++++++++++++++++++++++++++++++++------------- 6 files changed, 123 insertions(+), 45 deletions(-) diff --git a/web/html/logout.php b/web/html/logout.php index a25da7c..26d6166 100644 --- a/web/html/logout.php +++ b/web/html/logout.php @@ -12,6 +12,7 @@ if (isset($_COOKIE["AURSID"])) { $dbh = db_connect(); db_query($q, $dbh); setcookie("AURSID", "", time() - (60*60*24*30), "/"); + setcookie("AURLANG", "", time() - (60*60*24*30), "/"); } html_header(); # print out the HTML header diff --git a/web/html/pkgsearch.php b/web/html/pkgsearch.php index 445e776..6524b51 100644 --- a/web/html/pkgsearch.php +++ b/web/html/pkgsearch.php @@ -8,22 +8,9 @@ html_header(); # print out the HTML header # define variables used during pkgsearch # -$pkgsearch_vars = array("O", "L", "C", "K", "SB", "PP"); +$pkgsearch_vars = array("O", "L", "C", "K", "SB", "PP", "do_MyPackages"); -function pkgsearch_results_link() { - global $pkgsearch_vars; - - print "Go back to search results.
\n"; - return; -} - - # get login privileges # if (isset($_COOKIE["AURSID"])) { diff --git a/web/lang/pkgfuncs_po.inc b/web/lang/pkgfuncs_po.inc index cd96ecb..72a239b 100644 --- a/web/lang/pkgfuncs_po.inc +++ b/web/lang/pkgfuncs_po.inc @@ -116,4 +116,29 @@ $_t["en"]["Vote"] = "Vote"; # $_t["fr"]["Vote"] = "--> Traduction française ici. <--"; # $_t["de"]["Vote"] = "--> Deutsche Übersetzung hier. <--"; +$_t["en"]["Error retrieving package details."] = "Error retrieving package details."; +# $_t["es"]["Error retrieving package details."] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Error retrieving package details."] = "--> Traduction française ici. <--"; +# $_t["de"]["Error retrieving package details."] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["Package details could not be found."] = "Package details could not be found."; +# $_t["es"]["Package details could not be found."] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Package details could not be found."] = "--> Traduction française ici. <--"; +# $_t["de"]["Package details could not be found."] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["Error retrieving package list."] = "Error retrieving package list."; +# $_t["es"]["Error retrieving package list."] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Error retrieving package list."] = "--> Traduction française ici. <--"; +# $_t["de"]["Error retrieving package list."] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["Go back to %hsearch results%h."] = "Go back to %hsearch results%h."; +# $_t["es"]["Go back to %hsearch results%h."] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Go back to %hsearch results%h."] = "--> Traduction française ici. <--"; +# $_t["de"]["Go back to %hsearch results%h."] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["Manage"] = "Manage"; +# $_t["es"]["Manage"] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Manage"] = "--> Traduction française ici. <--"; +# $_t["de"]["Manage"] = "--> Deutsche Übersetzung hier. <--"; + ?> \ No newline at end of file diff --git a/web/lang/search_po.inc b/web/lang/search_po.inc index 01527c4..6714b85 100644 --- a/web/lang/search_po.inc +++ b/web/lang/search_po.inc @@ -36,4 +36,19 @@ $_t["en"]["You do not have access to adopt packages."] = "You do not have access # $_t["fr"]["You do not have access to adopt packages."] = "--> Traduction française ici. <--"; # $_t["de"]["You do not have access to adopt packages."] = "--> Deutsche Übersetzung hier. <--"; +$_t["en"]["You must be logged in before you can disown packages."] = "You must be logged in before you can disown packages."; +# $_t["es"]["You must be logged in before you can disown packages."] = "--> Traducción española aquí. <--"; +# $_t["fr"]["You must be logged in before you can disown packages."] = "--> Traduction française ici. <--"; +# $_t["de"]["You must be logged in before you can disown packages."] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["Error trying to retrieve package details."] = "Error trying to retrieve package details."; +# $_t["es"]["Error trying to retrieve package details."] = "--> Traducción española aquí. <--"; +# $_t["fr"]["Error trying to retrieve package details."] = "--> Traduction française ici. <--"; +# $_t["de"]["Error trying to retrieve package details."] = "--> Deutsche Übersetzung hier. <--"; + +$_t["en"]["You must be logged in before you can adopt packages."] = "You must be logged in before you can adopt packages."; +# $_t["es"]["You must be logged in before you can adopt packages."] = "--> Traducción española aquí. <--"; +# $_t["fr"]["You must be logged in before you can adopt packages."] = "--> Traduction française ici. <--"; +# $_t["de"]["You must be logged in before you can adopt packages."] = "--> Deutsche Übersetzung hier. <--"; + ?> \ No newline at end of file diff --git a/web/lib/aur.inc b/web/lib/aur.inc index bdec643..26e538a 100644 --- a/web/lib/aur.inc +++ b/web/lib/aur.inc @@ -365,7 +365,8 @@ function html_header() { # XXX Can I scale a PNG like this? # - print "\n"; + print "\n"; print " "; print "ArchLinux User-community Repository
"; diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index 15dd2d6..ae30657 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -1,6 +1,49 @@ "; + print __("Go back to %hsearch results%h.", + array($url_data, "")); + + return; +} + + +# see if this Users.ID can manage the package +# +function canManagePackage($uid=0,$AURMUID=0, $MUID=0, $SUID=0, $managed=0) { + if (!$uid) {return 0;} + + # The uid of the TU/Dev that manages the package + # + if ($uid == $AURMUID) {return 1;} + + # If the package isn't maintained by a TU/Dev, is this the user-maintainer? + # + if ($uid == $MUID && !$managed) {return 1;} + + # If the package isn't maintained by a TU/Dev, is this the user-submitter? + # + if ($uid == $SUID && !$managed) {return 1;} + + # otherwise, no right to manage this package + # + return 0; +} + # grab the current list of PackageCategories # function pkgCategories() { @@ -197,21 +240,22 @@ function pkg_search_page($SID="") { # determine paging variables # - isset($_REQUEST["PP"]) ? $PP = intval($_REQUEST["PP"]) : $PP = 25; + $_REQUEST["PP"] ? $PP = intval($_REQUEST["PP"]) : $PP = 25; if ($PP < 25) {$PP = 25;} if ($PP > 100) {$PP = 100;} - isset($_REQUEST["O"]) ? $O = intval($_REQUEST["O"]) : $O = 0; - if (isset($_REQUEST["do_More"])) { + $_REQUEST["O"] ? $O = intval($_REQUEST["O"]) : $O = 0; + if ($_REQUEST["do_More"]) { $O += $PP; - } elseif (isset($_REQUEST["do_Less"])) { + } elseif ($_REQUEST["do_Less"]) { $O -= $PP; } if ($O < 0) { $O = 0; } - if (isset($_REQUEST["do_Search"]) || isset($_REQUEST["do_MyPackages"])) { + if ($_REQUEST["do_Search"]) { # reset the offset to zero if they hit Go/My Packages # + $_REQUEST["do_MyPackages"] = 0; $O = 0; } @@ -341,11 +385,11 @@ function pkg_search_page($SID="") { # $q.= "ON Packages.ID = PackageVotes.PackageID "; $q = "SELECT * FROM Packages "; $has_where = 0; - if (isset($_REQUEST["L"]) && intval($_REQUEST["L"])) { + if (intval($_REQUEST["L"])) { $q.= "WHERE LocationID = ".intval($_REQUEST["L"])." "; $has_where = 1; } - if (isset($_REQUEST["C"]) && intval($_REQUEST["C"])) { + if (intval($_REQUEST["C"])) { if (!$has_where) { $q.= "WHERE CategoryID = ".intval($_REQUEST["C"])." "; $has_where = 1; @@ -363,18 +407,18 @@ function pkg_search_page($SID="") { $q.= "Description LIKE '%".mysql_escape_string($K)."%') "; } } - if (isset($_REQUEST["do_MyPackages"]) && $SID) { + if ($_REQUEST["do_MyPackages"] && $SID) { # list packages that the user is a AUR Maintainer of, or if it the # vistior is a registered user, if they are the Maintainer. # if ($myuid) { if (!$has_where) { $q.= "WHERE (AURMaintainerUID = ".$myuid." OR "; - $q.= "MaintainerUID = " . $myuid.") "; + $q.= "MaintainerUID = ".$myuid." OR SubmitterUID = ".$myuid.") "; $has_where = 1; } else { $q.= "AND (AURMaintainerUID = ".$myuid." OR "; - $q.= "MaintainerUID = " . $myuid.") "; + $q.= "MaintainerUID = ".$myuid." OR SubmitterUID = ".$myuid.") "; } } } @@ -394,10 +438,10 @@ function pkg_search_page($SID="") { break; } $q.= "LIMIT ".$O.", ".$PP; - #print $q."
\n"; - #print "
\n";
-	#print_r($_REQUEST);
-	#print "
\n"; + print $q."
\n"; + print "
\n";
+	print_r($_REQUEST);
+	print "
\n"; $result = db_query($q, $dbh); if (!$result) { @@ -502,41 +546,43 @@ function pkg_search_page($SID="") { print " "; print $cats[$row["CategoryID"]]."\n"; print " "; - $details_url = "".$row["Name"]; - $details_url.= "-".$row["Version"].""; - print $details_url."\n"; + reset($pkgsearch_vars); + $url.= "'>".$row["Name"]; + $url.= "-".$row["Version"].""; + print $url."\n"; print " "; print "   ".$row["NumVotes"]."\n"; print " "; print $row["Description"]."\n"; print " "; - $not_managed = 0; + + # print the package manager, also determine if it is managed + # + $managed = 1; if (isset($devs[$row["AURMaintainerUID"]])) { print $devs[$row["AURMaintainerUID"]]["Username"]; } elseif (isset($tus[$row["AURMaintainerUID"]])) { print $tus[$row["AURMaintainerUID"]]["Username"]; } else { print "None"; - $not_managed = 1; + $managed = 0; } print "\n"; - if ($myuid == $row["AURMaintainerUID"] || $not_managed || - ($myuid == $row["MaintainerUID"] && $not_managed)) { - # Only allow TUs/Devs to manage packages, or if it is a regular - # user and the package has not been adopted by a TU/Dev, then the - # regular user (most likely the submitter) can manage it. - # + + # print the managed link if applicable + # + if (canManagePackage($myuid, $row["AURMaintainerUID"], + $row["MaintainerUID"], $row["SubmitterUID"], $managed)) { $manage_url = "Manage"; print " "; @@ -553,6 +599,9 @@ function pkg_search_page($SID="") { print "\n"; print "\n"; print "\n"; + if ($_REQUEST["do_MyPackages"]) { + print "\n"; + } print "\n"; print "\n"; -- cgit v1.2.3-70-g09d2