From 91e6b5cb2f3d531ce40cd0331e2261d30766de47 Mon Sep 17 00:00:00 2001
From: Lukas Fleischer
Date: Wed, 25 Jun 2014 11:29:17 +0200
Subject: [PATCH] Add support for merge requests
This adds a new "Merge" category to the list of available request types
and also adds a new "Merge into" field that is hidden via JavaScript
when "Deletion" or "Orphan" is selected.
Signed-off-by: Lukas Fleischer
---
UPGRADING | 2 ++
schema/aur-schema.sql | 2 ++
web/html/pkgbase.php | 2 +-
web/html/pkgmerge.php | 5 ++++-
web/html/pkgreq.php | 21 ++++++++++++++++++++-
web/lib/pkgbasefuncs.inc.php | 11 +++++++----
web/template/pkgreq_results.php | 6 ++++++
7 files changed, 42 insertions(+), 7 deletions(-)
diff --git a/UPGRADING b/UPGRADING
index ceee6f5e..0e8edf0f 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -14,12 +14,14 @@ CREATE TABLE RequestTypes (
) ENGINE = InnoDB;
INSERT INTO RequestTypes VALUES (1, 'deletion');
INSERT INTO RequestTypes VALUES (2, 'orphan');
+INSERT INTO RequestTypes VALUES (3, 'merge');
CREATE TABLE PackageRequests (
ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
ReqTypeID TINYINT UNSIGNED NOT NULL,
PackageBaseID INTEGER UNSIGNED NULL,
PackageBaseName VARCHAR(255) NOT NULL,
+ MergeBaseName VARCHAR(255) NULL,
UsersID INTEGER UNSIGNED NULL DEFAULT NULL,
Comments TEXT NOT NULL DEFAULT '',
RequestTS BIGINT UNSIGNED NOT NULL DEFAULT 0,
diff --git a/schema/aur-schema.sql b/schema/aur-schema.sql
index 486beef5..1ec73855 100644
--- a/schema/aur-schema.sql
+++ b/schema/aur-schema.sql
@@ -297,6 +297,7 @@ CREATE TABLE RequestTypes (
) ENGINE = InnoDB;
INSERT INTO RequestTypes VALUES (1, 'deletion');
INSERT INTO RequestTypes VALUES (2, 'orphan');
+INSERT INTO RequestTypes VALUES (3, 'merge');
-- Package requests
--
@@ -305,6 +306,7 @@ CREATE TABLE PackageRequests (
ReqTypeID TINYINT UNSIGNED NOT NULL,
PackageBaseID INTEGER UNSIGNED NULL,
PackageBaseName VARCHAR(255) NOT NULL,
+ MergeBaseName VARCHAR(255) NULL,
UsersID INTEGER UNSIGNED NULL DEFAULT NULL,
Comments TEXT NOT NULL DEFAULT '',
RequestTS BIGINT UNSIGNED NOT NULL DEFAULT 0,
diff --git a/web/html/pkgbase.php b/web/html/pkgbase.php
index da88210b..0b0f6ef9 100644
--- a/web/html/pkgbase.php
+++ b/web/html/pkgbase.php
@@ -97,7 +97,7 @@ if (check_token()) {
} elseif (current_action("do_ChangeCategory")) {
list($ret, $output) = pkgbase_change_category($base_id, $atype);
} elseif (current_action("do_FileRequest")) {
- list($ret, $output) = pkgbase_file_request($ids, $_POST['type'], $_POST['comments']);
+ list($ret, $output) = pkgbase_file_request($ids, $_POST['type'], $_POST['merge_into'], $_POST['comments']);
} elseif (current_action("do_CloseRequest")) {
list($ret, $output) = pkgbase_close_request($_POST['reqid']);
}
diff --git a/web/html/pkgmerge.php b/web/html/pkgmerge.php
index dbc5eac6..ba3f7424 100644
--- a/web/html/pkgmerge.php
+++ b/web/html/pkgmerge.php
@@ -39,8 +39,11 @@ if ($atype == "Trusted User" || $atype == "Developer"): ?>
+
+
+
-
+
= __("Confirm package merge") ?>
" />
diff --git a/web/html/pkgreq.php b/web/html/pkgreq.php
index 05eeb51b..2b46b02b 100644
--- a/web/html/pkgreq.php
+++ b/web/html/pkgreq.php
@@ -90,11 +90,30 @@ if (!isset($base_id)) {
-
+
+
+
+
+
+
diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php
index 2444674f..68dd656c 100644
--- a/web/lib/pkgbasefuncs.inc.php
+++ b/web/lib/pkgbasefuncs.inc.php
@@ -984,6 +984,7 @@ function pkgbase_request_list() {
$q = "SELECT PackageRequests.ID, ";
$q.= "PackageRequests.PackageBaseID AS BaseID, ";
$q.= "PackageRequests.PackageBaseName AS Name, ";
+ $q.= "PackageRequests.MergeBaseName AS MergeInto, ";
$q.= "RequestTypes.Name AS Type, PackageRequests.Comments, ";
$q.= "Users.Username AS User, PackageRequests.RequestTS, ";
$q.= "PackageRequests.Status ";
@@ -1002,11 +1003,12 @@ function pkgbase_request_list() {
* @global string $AUR_REQUEST_ML The request notification mailing list
* @param string $ids The package base IDs to file the request against
* @param string $type The type of the request
+ * @param string $merge_into The target of a merge operation
* @param string $comments The comments to be added to the request
*
* @return void
*/
-function pkgbase_file_request($ids, $type, $comments) {
+function pkgbase_file_request($ids, $type, $merge_into, $comments) {
global $AUR_LOCATION;
global $AUR_REQUEST_ML;
@@ -1030,10 +1032,11 @@ function pkgbase_file_request($ids, $type, $comments) {
}
$q = "INSERT INTO PackageRequests ";
- $q.= "(ReqTypeID, PackageBaseID, PackageBaseName, UsersID, ";
- $q.= "Comments, RequestTS) VALUES (" . $type_id . ", ";
+ $q.= "(ReqTypeID, PackageBaseID, PackageBaseName, MergeBaseName, ";
+ $q.= "UsersID, Comments, RequestTS) VALUES (" . $type_id . ", ";
$q.= intval($base_id) . ", " . $dbh->quote($pkgbase_name) . ", ";
- $q.= $uid . ", " . $dbh->quote($comments) . ", UNIX_TIMESTAMP())";
+ $q.= $dbh->quote($merge_into) . ", " . $uid . ", ";
+ $q.= $dbh->quote($comments) . ", UNIX_TIMESTAMP())";
$dbh->exec($q);
/*
diff --git a/web/template/pkgreq_results.php b/web/template/pkgreq_results.php
index 8ab8351f..042cc3af 100644
--- a/web/template/pkgreq_results.php
+++ b/web/template/pkgreq_results.php
@@ -36,7 +36,11 @@
= htmlspecialchars($row["Name"]) ?> |
+
+ = htmlspecialchars(ucfirst($row['Type']), ENT_QUOTES); ?> (= htmlspecialchars(ucfirst($row['MergeInto']), ENT_QUOTES); ?>) |
+
= htmlspecialchars(ucfirst($row['Type']), ENT_QUOTES); ?> |
+
= htmlspecialchars($row['Comments'], ENT_QUOTES); ?> |
= htmlspecialchars($row['User']) ?>
@@ -47,6 +51,8 @@
= __('Accept') ?>
+
+ = __('Accept') ?>
|