From f15c700ad2ed2f5512a5574ab29f85c4848039e4 Mon Sep 17 00:00:00 2001 From: Mark Weiman Date: Mon, 5 Feb 2018 21:54:56 -0500 Subject: Add capability for co-maintainers to disown packages Implements FS#53832. Signed-off-by: Mark Weiman Signed-off-by: Lukas Fleischer --- web/html/pkgbase.php | 3 +++ web/html/pkgdisown.php | 13 ++++++++++--- web/lib/pkgbasefuncs.inc.php | 12 ++++++++++-- web/template/pkgbase_actions.php | 2 +- 4 files changed, 24 insertions(+), 6 deletions(-) (limited to 'web') diff --git a/web/html/pkgbase.php b/web/html/pkgbase.php index 03b0eee4..cf9a6c60 100644 --- a/web/html/pkgbase.php +++ b/web/html/pkgbase.php @@ -60,6 +60,9 @@ if (check_token()) { $output = __("The selected packages have not been disowned, check the confirmation checkbox."); $ret = false; } + } elseif (current_action("do_DisownComaintainer")) { + $uid = uid_from_sid($_COOKIE["AURSID"]); + list($ret, $output) = pkgbase_remove_comaintainer($base_id, $uid); } elseif (current_action("do_Vote")) { list($ret, $output) = pkgbase_vote($ids, true); } elseif (current_action("do_UnVote")) { diff --git a/web/html/pkgdisown.php b/web/html/pkgdisown.php index 4b04e85e..8da08cfe 100644 --- a/web/html/pkgdisown.php +++ b/web/html/pkgdisown.php @@ -7,10 +7,13 @@ include_once("pkgfuncs.inc.php"); html_header(__("Disown Package")); +$action = "do_Disown"; + $maintainer_uids = array(pkgbase_maintainer_uid($base_id)); $comaintainers = pkgbase_get_comaintainers($base_id); +$comaintainer_uids = pkgbase_get_comaintainer_uids(array($base_id)); -if (has_credential(CRED_PKGBASE_DISOWN, $maintainer_uids)): ?> +if (has_credential(CRED_PKGBASE_DISOWN, array_merge($maintainer_uids, $comaintainer_uids))): ?>

:

@@ -23,7 +26,11 @@ if (has_credential(CRED_PKGBASE_DISOWN, $maintainer_uids)): ?>

- 0 && !has_credential(CRED_PKGBASE_DISOWN)): ?> + + + + 0 && !has_credential(CRED_PKGBASE_DISOWN)): ?> ', $comaintainers[0], ''); ?> @@ -40,7 +47,7 @@ if (has_credential(CRED_PKGBASE_DISOWN, $maintainer_uids)): ?>

" />

+

" />

diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php index ff1bc901..16f95dac 100644 --- a/web/lib/pkgbasefuncs.inc.php +++ b/web/lib/pkgbasefuncs.inc.php @@ -1158,11 +1158,12 @@ function pkgbase_get_comaintainer_uids($base_ids) { * * @param int $base_id The package base ID to update the co-maintainers of * @param array $users Array of co-maintainer user names + * @param boolean $override Override credential check if true * * @return array Tuple of success/failure indicator and error message */ -function pkgbase_set_comaintainers($base_id, $users) { - if (!has_credential(CRED_PKGBASE_EDIT_COMAINTAINERS, array(pkgbase_maintainer_uid($base_id)))) { +function pkgbase_set_comaintainers($base_id, $users, $override=false) { + if (!$override && !has_credential(CRED_PKGBASE_EDIT_COMAINTAINERS, array(pkgbase_maintainer_uid($base_id)))) { return array(false, __("You are not allowed to manage co-maintainers of this package base.")); } @@ -1213,3 +1214,10 @@ function pkgbase_set_comaintainers($base_id, $users) { return array(true, __("The package base co-maintainers have been updated.")); } + +function pkgbase_remove_comaintainer($base_id, $uid) { + $uname = username_from_id($uid); + $names = pkgbase_get_comaintainers($base_id); + $names = array_diff($names, array($uname)); + return pkgbase_set_comaintainers($base_id, $names, true); +} diff --git a/web/template/pkgbase_actions.php b/web/template/pkgbase_actions.php index d3f05921..5eee5478 100644 --- a/web/template/pkgbase_actions.php +++ b/web/template/pkgbase_actions.php @@ -41,7 +41,7 @@
  • - +
  • -- cgit v1.2.3-24-g4f1b