diff --git a/web/html/index.php b/web/html/index.php index e79955ec..fe74857c 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -20,6 +20,22 @@ if (!empty($tokens[1]) && '/' . $tokens[1] == get_pkg_route()) { include "./404.php"; return; } + } + + include get_route('/' . $tokens[1]); +} elseif (!empty($tokens[1]) && '/' . $tokens[1] == get_pkgbase_route()) { + if (!empty($tokens[2])) { + /* TODO: Create a proper data structure to pass variables from + * the routing framework to the individual pages instead of + * initializing arbitrary variables here. */ + $pkgbase_name = $tokens[2]; + $base_id = pkgbase_from_name($pkgbase_name); + + if (!$base_id) { + header("HTTP/1.0 404 Not Found"); + include "./404.php"; + return; + } if (!empty($tokens[3])) { /* TODO: Remove support for legacy URIs and move these @@ -65,23 +81,7 @@ if (!empty($tokens[1]) && '/' . $tokens[1] == get_pkg_route()) { return; } - $_POST['IDs'] = array(pkgid_from_name($tokens[2]) => '1'); - } - } - - include get_route('/' . $tokens[1]); -} elseif (!empty($tokens[1]) && '/' . $tokens[1] == get_pkgbase_route()) { - if (!empty($tokens[2])) { - /* TODO: Create a proper data structure to pass variables from - * the routing framework to the individual pages instead of - * initializing arbitrary variables here. */ - $pkgbase_name = $tokens[2]; - $base_id = pkgbase_from_name($pkgbase_name); - - if (!$base_id) { - header("HTTP/1.0 404 Not Found"); - include "./404.php"; - return; + $_POST['IDs'] = array(pkgbase_from_name($tokens[2]) => '1'); } } diff --git a/web/html/packages.php b/web/html/packages.php index d9c3a860..876e2c07 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -42,77 +42,6 @@ if (isset($_COOKIE["AURSID"])) { $atype = ""; } -# Grab the list of Package IDs to be operated on -$ids = array(); -if (isset($_POST['IDs'])) { - foreach ($_POST['IDs'] as $id => $i) { - $id = intval($id); - if ($id > 0) { - $ids[] = $id; - } - } -} - -# Determine what action to do -$ret = false; -$output = ""; -if (check_token()) { - if (current_action("do_Flag")) { - list($ret, $output) = pkg_flag($atype, $ids); - } elseif (current_action("do_UnFlag")) { - list($ret, $output) = pkg_unflag($atype, $ids); - } elseif (current_action("do_Adopt")) { - list($ret, $output) = pkg_adopt($atype, $ids, true); - } elseif (current_action("do_Disown")) { - list($ret, $output) = pkg_adopt($atype, $ids, false); - } elseif (current_action("do_Vote")) { - list($ret, $output) = pkg_vote($atype, $ids, true); - } elseif (current_action("do_UnVote")) { - list($ret, $output) = pkg_vote($atype, $ids, false); - } elseif (current_action("do_Delete")) { - if (isset($_POST['confirm_Delete'])) { - if (!isset($_POST['merge_Into']) || empty($_POST['merge_Into'])) { - list($ret, $output) = pkg_delete($atype, pkgbase_from_pkgid($ids), NULL); - unset($_GET['ID']); - } - else { - $merge_base_id = pkgbase_from_name($_POST['merge_Into']); - if ($merge_base_id) { - list($ret, $output) = pkg_delete($atype, pkgbase_from_pkgid($ids), $merge_base_id); - unset($_GET['ID']); - } - else { - $output = __("Cannot find package to merge votes and comments into."); - } - } - } - else { - $output = __("The selected packages have not been deleted, check the confirmation checkbox."); - } - } elseif (current_action("do_Notify")) { - list($ret, $output) = pkg_notify($atype, $ids); - } elseif (current_action("do_UnNotify")) { - list($ret, $output) = pkg_notify($atype, $ids, false); - } elseif (current_action("do_DeleteComment")) { - list($ret, $output) = pkg_delete_comment($atype); - } elseif (current_action("do_ChangeCategory")) { - list($ret, $output) = pkg_change_category($pkgid, $atype); - } - - if (isset($_REQUEST['comment'])) { - $uid = uid_from_sid($_COOKIE["AURSID"]); - add_package_comment($pkgid, $uid, $_REQUEST['comment']); - $ret = true; - } - - if ($ret) { - /* Redirect back to package page on success. */ - header('Location: ' . get_pkg_uri($pkgname)); - exit(); - } -} - -# Get package details after package actions have been attempted, FS#34508 $details = array(); if (isset($pkgname)) { $details = get_package_details($pkgid); @@ -121,10 +50,6 @@ if (isset($pkgname)) { html_header($title, $details); ?> - -

- - $i) { + $id = intval($id); + if ($id > 0) { + $ids[] = $id; + } + } +} + +/* Perform package base actions. */ +$ret = false; +$output = ""; +if (check_token()) { + if (current_action("do_Flag")) { + list($ret, $output) = pkg_flag($atype, $ids); + } elseif (current_action("do_UnFlag")) { + list($ret, $output) = pkg_unflag($atype, $ids); + } elseif (current_action("do_Adopt")) { + list($ret, $output) = pkg_adopt($atype, $ids, true); + } elseif (current_action("do_Disown")) { + list($ret, $output) = pkg_adopt($atype, $ids, false); + } elseif (current_action("do_Vote")) { + list($ret, $output) = pkg_vote($atype, $ids, true); + } elseif (current_action("do_UnVote")) { + list($ret, $output) = pkg_vote($atype, $ids, false); + } elseif (current_action("do_Delete")) { + if (isset($_POST['confirm_Delete'])) { + if (!isset($_POST['merge_Into']) || empty($_POST['merge_Into'])) { + list($ret, $output) = pkg_delete($atype, $ids, NULL); + unset($_GET['ID']); + } + else { + $merge_base_id = pkgbase_from_name($_POST['merge_Into']); + if ($merge_base_id) { + list($ret, $output) = pkg_delete($atype, $ids, $merge_base_id); + unset($_GET['ID']); + } + else { + $output = __("Cannot find package to merge votes and comments into."); + } + } + } + else { + $output = __("The selected packages have not been deleted, check the confirmation checkbox."); + } + } elseif (current_action("do_Notify")) { + list($ret, $output) = pkg_notify($atype, $ids); + } elseif (current_action("do_UnNotify")) { + list($ret, $output) = pkg_notify($atype, $ids, false); + } elseif (current_action("do_DeleteComment")) { + list($ret, $output) = pkg_delete_comment($atype); + } elseif (current_action("do_ChangeCategory")) { + list($ret, $output) = pkg_change_category($base_id, $atype); + } + + if (isset($_REQUEST['comment'])) { + $uid = uid_from_sid($_COOKIE["AURSID"]); + add_package_comment($base_id, $uid, $_REQUEST['comment']); + $ret = true; + } + + if ($ret) { + if (isset($base_id)) { + /* Redirect back to package base page on success. */ + header('Location: ' . get_pkgbase_uri($pkgbase_name)); + exit(); + } else { + /* Redirect back to package search page. */ + header('Location: ' . get_pkg_route()); + exit(); + } + } +} + $details = get_pkgbase_details($base_id); html_header($title, $details); ?> + +

+ +
-

+

', htmlspecialchars($pkgname), ''); ?> + '', htmlspecialchars($pkgbase_name), ''); ?>

-
+
- - + +

diff --git a/web/html/pkgmerge.php b/web/html/pkgmerge.php index 834d0c91..9ffd5e74 100644 --- a/web/html/pkgmerge.php +++ b/web/html/pkgmerge.php @@ -18,18 +18,18 @@ if (isset($_COOKIE["AURSID"])) { if ($atype == "Trusted User" || $atype == "Developer"): ?>
-

+

', htmlspecialchars($pkgname), ''); ?> + '', htmlspecialchars($pkgbase_name), ''); ?>

- +
- - + +

diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php index a63ee6fd..4e37d2f4 100644 --- a/web/lib/pkgfuncs.inc.php +++ b/web/lib/pkgfuncs.inc.php @@ -500,6 +500,9 @@ function display_package_details($id=0, $row, $SID="") { print "

" . $row['error'] . "

\n"; } else { + $base_id = pkgbase_from_pkgid($id); + $pkgbase_name = pkgbase_name_from_id($base_id); + include('pkg_details.php'); if ($SID) { @@ -507,7 +510,6 @@ function display_package_details($id=0, $row, $SID="") { include('pkg_comment_form.php'); } - $base_id = pkgbase_from_pkgid($id); $comments = package_comments($base_id); if (!empty($comments)) { include('pkg_comments.php'); @@ -536,6 +538,8 @@ function display_pkgbase_details($base_id, $row, $SID="") { print "

" . $row['error'] . "

\n"; } else { + $pkgbase_name = pkgbase_name_from_id($base_id); + include('pkgbase_details.php'); if ($SID) { @@ -641,7 +645,8 @@ function pkg_search_page($SID="") { $q_select .= "Users.Username AS Maintainer, PackageCategories.Category, Packages.Name, Packages.Version, Packages.Description, - PackageBases.NumVotes, Packages.ID, PackageBases.OutOfDateTS "; + PackageBases.NumVotes, Packages.ID, Packages.PackageBaseID, + PackageBases.OutOfDateTS "; $q_from = "FROM Packages LEFT JOIN PackageBases ON (PackageBases.ID = Packages.PackageBaseID) @@ -941,20 +946,19 @@ function pkgbase_maintainer_uid($base_id) { * * @global string $AUR_LOCATION The AUR's URL used for notification e-mails * @param string $atype Account type, output of account_from_sid - * @param array $ids Array of package IDs to flag/unflag + * @param array $base_ids Array of package base IDs to flag/unflag * * @return array Tuple of success/failure indicator and error message */ -function pkg_flag($atype, $ids) { +function pkg_flag($atype, $base_ids) { global $AUR_LOCATION; if (!$atype) { return array(false, __("You must be logged in before you can flag packages.")); } - $ids = sanitize_ids($ids); - $base_ids = pkgbase_from_pkgid($ids); - if (empty($ids)) { + $base_ids = pkgbase_from_pkgid($base_ids); + if (empty($base_ids)) { return array(false, __("You did not select any packages to flag.")); } @@ -972,10 +976,10 @@ function pkg_flag($atype, $ids) { $f_name = username_from_sid($_COOKIE['AURSID']); $f_email = email_from_sid($_COOKIE['AURSID']); $f_uid = uid_from_sid($_COOKIE['AURSID']); - $q = "SELECT Packages.Name, Users.Email, Packages.ID "; - $q.= "FROM Packages, Users "; - $q.= "WHERE Packages.ID IN (" . implode(",", $ids) .") "; - $q.= "AND Users.ID = Packages.MaintainerUID "; + $q = "SELECT PackageBases.Name, Users.Email "; + $q.= "FROM PackageBases, Users "; + $q.= "WHERE PackageBases.ID IN (" . implode(",", $base_ids) .") "; + $q.= "AND Users.ID = PackageBases.MaintainerUID "; $q.= "AND Users.ID != " . $f_uid; $result = $dbh->query($q); if ($result) { @@ -1000,18 +1004,17 @@ function pkg_flag($atype, $ids) { * Unflag package(s) as out-of-date * * @param string $atype Account type, output of account_from_sid - * @param array $ids Array of package IDs to flag/unflag + * @param array $base_ids Array of package base IDs to flag/unflag * * @return array Tuple of success/failure indicator and error message */ -function pkg_unflag($atype, $ids) { +function pkg_unflag($atype, $base_ids) { if (!$atype) { return array(false, __("You must be logged in before you can unflag packages.")); } - $ids = sanitize_ids($ids); - $base_ids = pkgbase_from_pkgid($ids); - if (empty($ids)) { + $base_ids = pkgbase_from_pkgid($base_ids); + if (empty($base_ids)) { return array(false, __("You did not select any packages to unflag.")); } @@ -1144,12 +1147,12 @@ function pkg_delete ($atype, $base_ids, $merge_base_id) { * Adopt or disown packages * * @param string $atype Account type, output of account_from_sid - * @param array $ids Array of package IDs to adopt/disown + * @param array $base_ids Array of package base IDs to adopt/disown * @param bool $action Adopts if true, disowns if false. Adopts by default * * @return array Tuple of success/failure indicator and error message */ -function pkg_adopt ($atype, $ids, $action=true) { +function pkg_adopt ($atype, $base_ids, $action=true) { if (!$atype) { if ($action) { return array(false, __("You must be logged in before you can adopt packages.")); @@ -1158,9 +1161,8 @@ function pkg_adopt ($atype, $ids, $action=true) { } } - $pkg_ids = sanitize_ids($ids); - $ids = pkgbase_from_pkgid($pkg_ids); - if (empty($ids)) { + $base_ids = sanitize_ids($base_ids); + if (empty($base_ids)) { if ($action) { return array(false, __("You did not select any packages to adopt.")); } else { @@ -1180,7 +1182,7 @@ function pkg_adopt ($atype, $ids, $action=true) { } $q.= "SET $field = $user "; - $q.= "WHERE ID IN (" . implode(",", $ids) . ") "; + $q.= "WHERE ID IN (" . implode(",", $base_ids) . ") "; if ($action && $atype == "User") { /* Regular users may only adopt orphan packages. */ @@ -1203,12 +1205,12 @@ function pkg_adopt ($atype, $ids, $action=true) { * Vote and un-vote for packages * * @param string $atype Account type, output of account_from_sid - * @param array $ids Array of package IDs to vote/un-vote + * @param array $base_ids Array of package base IDs to vote/un-vote * @param bool $action Votes if true, un-votes if false. Votes by default * * @return array Tuple of success/failure indicator and error message */ -function pkg_vote ($atype, $ids, $action=true) { +function pkg_vote ($atype, $base_ids, $action=true) { if (!$atype) { if ($action) { return array(false, __("You must be logged in before you can vote for packages.")); @@ -1217,9 +1219,8 @@ function pkg_vote ($atype, $ids, $action=true) { } } - $ids = sanitize_ids($ids); - $base_ids = pkgbase_from_pkgid($ids); - if (empty($ids)) { + $base_ids = sanitize_ids($base_ids); + if (empty($base_ids)) { if ($action) { return array(false, __("You did not select any packages to vote for.")); } else { @@ -1360,18 +1361,17 @@ function user_notify($uid, $base_id) { * Toggle notification of packages * * @param string $atype Account type, output of account_from_sid - * @param array $ids Array of package IDs to toggle, formatted as $package_id + * @param array $base_ids Array of package base IDs to toggle * * @return array Tuple of success/failure indicator and error message */ -function pkg_notify ($atype, $ids, $action=true) { +function pkg_notify ($atype, $base_ids, $action=true) { if (!$atype) { return; } - $ids = sanitize_ids($ids); - $base_ids = pkgbase_from_pkgid($ids); - if (empty($ids)) { + $base_ids = sanitize_ids($base_ids); + if (empty($base_ids)) { return array(false, __("Couldn't add to notification list.")); } diff --git a/web/template/pkg_comment_form.php b/web/template/pkg_comment_form.php index 8e74fe64..8a74dc13 100644 --- a/web/template/pkg_comment_form.php +++ b/web/template/pkg_comment_form.php @@ -1,6 +1,6 @@

- +
- +

diff --git a/web/template/pkg_comments.php b/web/template/pkg_comments.php index 820ba6e2..1f47bb3e 100644 --- a/web/template/pkg_comments.php +++ b/web/template/pkg_comments.php @@ -2,11 +2,10 @@ $uid = uid_from_sid($SID); $base_id = pkgbase_from_pkgid($row['ID']); $count = package_comments_count($base_id); -$pkgname = $row['Name']; ?>

- +

@@ -16,7 +15,7 @@ $pkgname = $row['Name']; endif; ?>

- +
@@ -49,7 +48,7 @@ $pkgname = $row['Name']; 10 && !isset($_GET['comments'])): ?>

- +

diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php index d4e4e4ed..5268d3b4 100644 --- a/web/template/pkg_details.php +++ b/web/template/pkg_details.php @@ -20,7 +20,7 @@ $updated_time = ($row["ModifiedTS"] == 0) ? $msg : gmdate("Y-m-d H:i", intval($r $submitted_time = ($row["SubmittedTS"] == 0) ? $msg : gmdate("Y-m-d H:i", intval($row["SubmittedTS"])); $out_of_date_time = ($row["OutOfDateTS"] == 0) ? $msg : gmdate("Y-m-d", intval($row["OutOfDateTS"])); -$urlpath = URL_DIR . substr($row['Name'], 0, 2) . "/" . $row['Name']; +$urlpath = URL_DIR . substr($row['BaseName'], 0, 2) . "/" . $row['BaseName']; $deps = package_dependencies($row["ID"]); $requiredby = package_required($row["Name"]); @@ -35,12 +35,12 @@ $sources = package_sources($row["ID"]);

  • -
  • +
  • - +
  • @@ -48,7 +48,7 @@ $sources = package_sources($row["ID"]);
  • -
    +
    @@ -56,14 +56,14 @@ $sources = package_sources($row["ID"]);
  • -
    +
  • -
    +
    @@ -71,28 +71,28 @@ $sources = package_sources($row["ID"]);
  • -
    +
  • -
    +
  • -
  • -
  • +
  • +
  • -
    +
    @@ -100,7 +100,7 @@ $sources = package_sources($row["ID"]);
  • -
    +
    @@ -130,7 +130,7 @@ if ($SID && ($uid == $row["MaintainerUID"] || ($atype == "Developer" || $atype == "Trusted User"))): ?> -
    +
    @@ -196,9 +196,9 @@ if ($row["MaintainerUID"]): - + - + diff --git a/web/template/pkg_search_results.php b/web/template/pkg_search_results.php index 16f574af..c9da5f9a 100644 --- a/web/template/pkg_search_results.php +++ b/web/template/pkg_search_results.php @@ -28,7 +28,7 @@ if (!$result): ?>
    - + @@ -52,7 +52,7 @@ if (!$result): ?> - + diff --git a/web/template/pkgbase_details.php b/web/template/pkgbase_details.php index a77ecd39..8da23c43 100644 --- a/web/template/pkgbase_details.php +++ b/web/template/pkgbase_details.php @@ -30,12 +30,12 @@ $pkgs = pkgbase_get_pkgnames($base_id);

    • -
    • +
    • - + @@ -43,7 +43,7 @@ $pkgs = pkgbase_get_pkgnames($base_id);
    • -
      + @@ -51,14 +51,14 @@ $pkgs = pkgbase_get_pkgnames($base_id);
    • -
      +
    • -
      + @@ -66,28 +66,28 @@ $pkgs = pkgbase_get_pkgnames($base_id);
    • -
      +
    • -
      +
    • -
    • -
    • +
    • +
    • -
      + @@ -95,7 +95,7 @@ $pkgs = pkgbase_get_pkgnames($base_id);
    • -
      + @@ -113,7 +113,7 @@ if ($SID && ($uid == $row["MaintainerUID"] || ($atype == "Developer" || $atype == "Trusted User"))): ?>
    - +
    ]" value="1" />]" value="1" /> "> -
    +
    @@ -175,7 +175,7 @@ if ($row["MaintainerUID"]):