Commit 91e6b5cb authored by Lukas Fleischer's avatar Lukas Fleischer
Browse files

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: default avatarLukas Fleischer <archlinux@cryptocrack.de>
parent 959c61a7
......@@ -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,
......
......@@ -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,
......
......@@ -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']);
}
......
......@@ -39,8 +39,11 @@ if ($atype == "Trusted User" || $atype == "Developer"): ?>
<input type="hidden" name="IDs[<?= $base_id ?>]" value="1" />
<input type="hidden" name="ID" value="<?= $base_id ?>" />
<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
<?php if (isset($_GET['via'])): ?>
<input type="hidden" name="via" value="<?= intval($_GET['via']) ?>" />
<?php endif; ?>
<p><label for="merge_Into" ><?= __("Merge into:") ?></label>
<input type="text" id="merge_Into" name="merge_Into" /></p>
<input type="text" id="merge_Into" name="merge_Into" value="<?= isset($_GET['into']) ? $_GET['into'] : '' ?>" /></p>
<p><input type="checkbox" name="confirm_Delete" value="1" />
<?= __("Confirm package merge") ?></p>
<p><input type="submit" class="button" name="do_Delete" value="<?= __("Merge") ?>" /></p>
......
......@@ -90,11 +90,30 @@ if (!isset($base_id)) {
<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
<p>
<label for="id_type"><?= __("Request type") ?>:</label>
<select name="type" id="id_type">
<select name="type" id="id_type" onchange="showHideMergeSection()">
<option value="deletion"><?= __('Deletion') ?></option>
<option value="merge"><?= __('Merge') ?></option>
<option value="orphan"><?= __('Orphan') ?></option>
</select>
</p>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
function showHideMergeSection() {
if ($('#id_type').val() == 'merge') {
$('#merge_section').show();
} else {
$('#merge_section').hide();
}
}
$(document).ready(function() {
showHideMergeSection();
});
</script>
<p id="merge_section">
<label for="id_merge_into"><?= __("Merge into") ?>:</label>
<input type="text" name="merge_into" id="id_merge_into" />
</p>
<p>
<label for="id_comments"><?= __("Comments") ?>:</label>
<textarea name="comments" id="id_comments" rows="5" cols="50"></textarea>
......
......@@ -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);
/*
......
......@@ -36,7 +36,11 @@
<?php else: ?>
<td><?= htmlspecialchars($row["Name"]) ?></td>
<?php endif; ?>
<?php if ($row['Type'] == 'merge'): ?>
<td><?= htmlspecialchars(ucfirst($row['Type']), ENT_QUOTES); ?> (<?= htmlspecialchars(ucfirst($row['MergeInto']), ENT_QUOTES); ?>)</td>
<?php else: ?>
<td><?= htmlspecialchars(ucfirst($row['Type']), ENT_QUOTES); ?></td>
<?php endif; ?>
<td class="wrap"><?= htmlspecialchars($row['Comments'], ENT_QUOTES); ?></td>
<td>
<a href="<?= get_uri('/account/') . htmlspecialchars($row['User'], ENT_QUOTES) ?>" title="<?= __('View account information for %s', htmlspecialchars($row['User'])) ?>"><?= htmlspecialchars($row['User']) ?></a>
......@@ -47,6 +51,8 @@
<?php if ($row['BaseID']): ?>
<?php if ($row['Type'] == 'deletion'): ?>
<a href="<?= get_pkgbase_uri($row['Name']) ?>delete/?via=<?= intval($row['ID']) ?>"><?= __('Accept') ?></a>
<?php elseif ($row['Type'] == 'merge'): ?>
<a href="<?= get_pkgbase_uri($row['Name']) ?>merge/?into=<?= urlencode($row['MergeInto']) ?>&via=<?= intval($row['ID']) ?>"><?= __('Accept') ?></a>
<?php elseif ($row['Type'] == 'orphan'): ?>
<form action="<?= get_pkgbase_uri($row['Name']) . 'disown/'; ?>" method="post">
<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment