[aur-dev] [PATCH 1/2] Move package base flagging to a separate form
Show a separate confirmation page when flagging a package out-of-date. Implements FS#44967. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- web/html/index.php | 4 ++-- web/html/pkgflag.php | 44 ++++++++++++++++++++++++++++++++++++++++ web/template/pkgbase_actions.php | 2 +- 3 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 web/html/pkgflag.php diff --git a/web/html/index.php b/web/html/index.php index 7068d76..ec99bb7 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -68,8 +68,8 @@ if (!empty($tokens[1]) && '/' . $tokens[1] == get_pkg_route()) { $_POST['do_UnNotify'] = __('UnNotify'); break; case "flag": - $_POST['do_Flag'] = __('Flag'); - break; + include('pkgflag.php'); + return; case "unflag": $_POST['do_UnFlag'] = __('UnFlag'); break; diff --git a/web/html/pkgflag.php b/web/html/pkgflag.php new file mode 100644 index 0000000..9d86909 --- /dev/null +++ b/web/html/pkgflag.php @@ -0,0 +1,44 @@ +<?php + +set_include_path(get_include_path() . PATH_SEPARATOR . '../lib'); + +include_once("aur.inc.php"); +include_once("pkgfuncs.inc.php"); + +set_lang(); +check_sid(); + +html_header(__("Flag Package Out-Of-Date")); + +if (has_credential(CRED_PKGBASE_FLAG)): ?> +<div class="box"> + <h2><?= __('Flag Package Out-Of-Date: %s', htmlspecialchars($pkgbase_name)) ?></h2> + <p> + <?= __('Use this form to flag the package base %s%s%s and the following packages out-of-date: ', + '<strong>', htmlspecialchars($pkgbase_name), '</strong>'); ?> + </p> + <ul> + <?php foreach(pkgbase_get_pkgnames($base_id) as $pkgname): ?> + <li><?= htmlspecialchars($pkgname) ?></li> + <?php endforeach; ?> + </ul> + <p> + <?= __('Please do %snot%s use this form to report bugs. Use the package comments instead.', + '<strong>', '</strong>'); ?> + </p> + <form action="<?= get_uri('/pkgbase/'); ?>" method="post"> + <fieldset> + <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']) ?>" /> + <p><input type="submit" class="button" name="do_Flag" value="<?= __("Flag") ?>" /></p> + </fieldset> + </form> +</div> + +<?php +else: + print __("Only registered users can flag packages out-of-date."); +endif; + +html_footer(AURWEB_VERSION); diff --git a/web/template/pkgbase_actions.php b/web/template/pkgbase_actions.php index dea348e..198f7ab 100644 --- a/web/template/pkgbase_actions.php +++ b/web/template/pkgbase_actions.php @@ -10,7 +10,7 @@ <li><a href="https://wiki.archlinux.org/index.php/Special:Search?search=<?= urlencode($row['Name']) ?>"><?= __('Search wiki') ?></a></li> <li><span class="flagged"><?php if ($row["OutOfDateTS"] !== NULL) { echo __('Flagged out-of-date')." (${out_of_date_time})"; } ?></span></li> <?php if ($row["OutOfDateTS"] === NULL): ?> - <li><?= html_action_form($base_uri . 'flag/', "do_Flag", __('Flag package out-of-date')) ?></li> + <li><?= html_action_link($base_uri . 'flag/', __('Flag package out-of-date')) ?></li> <?php elseif (($row["OutOfDateTS"] !== NULL) && has_credential(CRED_PKGBASE_UNFLAG, $unflaggers)): ?> <li><?= html_action_form($base_uri . 'unflag/', "do_UnFlag", __('Unflag package')) ?></li> <?php endif; ?> -- 2.5.1
Implements FS#42827. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- schema/aur-schema.sql | 1 + scripts/notify.py | 5 +++-- upgrading/4.1.0.txt | 7 ++++--- web/html/pkgbase.php | 7 ++++++- web/html/pkgflag.php | 5 +++++ web/lib/pkgbasefuncs.inc.php | 14 ++++++++------ 6 files changed, 27 insertions(+), 12 deletions(-) diff --git a/schema/aur-schema.sql b/schema/aur-schema.sql index 9556b20..ff137dc 100644 --- a/schema/aur-schema.sql +++ b/schema/aur-schema.sql @@ -82,6 +82,7 @@ CREATE TABLE PackageBases ( NumVotes INTEGER UNSIGNED NOT NULL DEFAULT 0, Popularity DECIMAL(10,6) UNSIGNED NOT NULL DEFAULT 0, OutOfDateTS BIGINT UNSIGNED NULL DEFAULT NULL, + FlaggerComment VARCHAR(255) NOT NULL, SubmittedTS BIGINT UNSIGNED NOT NULL, ModifiedTS BIGINT UNSIGNED NOT NULL, FlaggerUID BIGINT UNSIGNED NULL DEFAULT NULL, -- who flagged the package out-of-date? diff --git a/scripts/notify.py b/scripts/notify.py index 8be3a70..55b2911 100755 --- a/scripts/notify.py +++ b/scripts/notify.py @@ -139,14 +139,15 @@ def flag(cur, uid, pkgbase_id): user = username_from_id(cur, uid) pkgbase = pkgbase_from_id(cur, pkgbase_id) to = [get_maintainer_email(cur, pkgbase_id)] + text = sys.stdin.read() user_uri = aur_location + '/account/' + user + '/' pkgbase_uri = aur_location + '/pkgbase/' + pkgbase + '/' subject = 'AUR Out-of-date Notification for %s' % (pkgbase) - body = 'Your package %s [1] has been flagged out-of-date by %s [2]. ' % \ + body = 'Your package %s [1] has been flagged out-of-date by %s [2]:' % \ (pkgbase, user) - body += '\n\n' + body += '\n\n' + text + '\n\n' body += '[1] ' + pkgbase_uri + '\n' body += '[2] ' + user_uri diff --git a/upgrading/4.1.0.txt b/upgrading/4.1.0.txt index c0bf573..e9545ff 100644 --- a/upgrading/4.1.0.txt +++ b/upgrading/4.1.0.txt @@ -8,10 +8,11 @@ ALTER TABLE PackageComments ADD FOREIGN KEY (EditedUsersID) REFERENCES Users(ID) ON DELETE SET NULL; ---- -2. Add a field to store the ID of the last user who flagged a package -out-of-date: +2. Add fields to store the ID and comment of the last user who flagged a +package out-of-date: ---- ALTER TABLE PackageBases - ADD COLUMN FlaggerUID BIGINT UNSIGNED NULL DEFAULT NULL; + ADD COLUMN FlaggerUID BIGINT UNSIGNED NULL DEFAULT NULL, + ADD COLUMN FlaggerComment VARCHAR(255) NOT NULL; ---- diff --git a/web/html/pkgbase.php b/web/html/pkgbase.php index bc32e43..a241c74 100644 --- a/web/html/pkgbase.php +++ b/web/html/pkgbase.php @@ -49,7 +49,12 @@ $output = ""; $fragment = ""; if (check_token()) { if (current_action("do_Flag")) { - list($ret, $output) = pkgbase_flag($ids); + if (strlen($_POST['comments']) >= 3) { + list($ret, $output) = pkgbase_flag($ids, $_POST['comments']); + } else { + $output = __("The selected packages have not been flagged, please enter a comment."); + $ret = false; + } } elseif (current_action("do_UnFlag")) { list($ret, $output) = pkgbase_unflag($ids); } elseif (current_action("do_Adopt")) { diff --git a/web/html/pkgflag.php b/web/html/pkgflag.php index 9d86909..bfe89e0 100644 --- a/web/html/pkgflag.php +++ b/web/html/pkgflag.php @@ -25,12 +25,17 @@ if (has_credential(CRED_PKGBASE_FLAG)): ?> <p> <?= __('Please do %snot%s use this form to report bugs. Use the package comments instead.', '<strong>', '</strong>'); ?> + <?= __('Enter details on why the package is out-of-date below, preferably including links to the release announcement or the new release tarball.'); ?> </p> <form action="<?= get_uri('/pkgbase/'); ?>" method="post"> <fieldset> <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']) ?>" /> + <p> + <label for="id_comments"><?= __("Comments") ?>:</label> + <textarea name="comments" id="id_comments" rows="5" cols="50"></textarea> + </p> <p><input type="submit" class="button" name="do_Flag" value="<?= __("Flag") ?>" /></p> </fieldset> </form> diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php index 24d3393..799f1da 100644 --- a/web/lib/pkgbasefuncs.inc.php +++ b/web/lib/pkgbasefuncs.inc.php @@ -316,10 +316,11 @@ function pkgbase_maintainer_uids($base_ids) { * Flag package(s) as out-of-date * * @param array $base_ids Array of package base IDs to flag/unflag + * @param string $comment The comment to add * * @return array Tuple of success/failure indicator and error message */ -function pkgbase_flag($base_ids) { +function pkgbase_flag($base_ids, $comment) { if (!has_credential(CRED_PKGBASE_FLAG)) { return array(false, __("You must be logged in before you can flag packages.")); } @@ -332,14 +333,15 @@ function pkgbase_flag($base_ids) { $uid = uid_from_sid($_COOKIE['AURSID']); $dbh = DB::connect(); - $q = "UPDATE PackageBases SET"; - $q.= " OutOfDateTS = UNIX_TIMESTAMP(), FlaggerUID = " . $uid; - $q.= " WHERE ID IN (" . implode(",", $base_ids) . ")"; - $q.= " AND OutOfDateTS IS NULL"; + $q = "UPDATE PackageBases SET "; + $q.= "OutOfDateTS = UNIX_TIMESTAMP(), FlaggerUID = " . $uid . ", "; + $q.= "FlaggerComment = " . $dbh->quote($comment) . " "; + $q.= "WHERE ID IN (" . implode(",", $base_ids) . ") "; + $q.= "AND OutOfDateTS IS NULL"; $dbh->exec($q); foreach ($base_ids as $base_id) { - notify(array('flag', $uid, $base_id)); + notify(array('flag', $uid, $base_id), $comment); } return array(true, __("The selected packages have been flagged out-of-date.")); -- 2.5.1
participants (1)
-
Lukas Fleischer