mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Add capability for co-maintainers to disown packages
Implements FS#53832. Signed-off-by: Mark Weiman <mark.weiman@markzz.com> Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
parent
27654afadb
commit
f15c700ad2
4 changed files with 24 additions and 6 deletions
|
@ -60,6 +60,9 @@ if (check_token()) {
|
||||||
$output = __("The selected packages have not been disowned, check the confirmation checkbox.");
|
$output = __("The selected packages have not been disowned, check the confirmation checkbox.");
|
||||||
$ret = false;
|
$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")) {
|
} elseif (current_action("do_Vote")) {
|
||||||
list($ret, $output) = pkgbase_vote($ids, true);
|
list($ret, $output) = pkgbase_vote($ids, true);
|
||||||
} elseif (current_action("do_UnVote")) {
|
} elseif (current_action("do_UnVote")) {
|
||||||
|
|
|
@ -7,10 +7,13 @@ include_once("pkgfuncs.inc.php");
|
||||||
|
|
||||||
html_header(__("Disown Package"));
|
html_header(__("Disown Package"));
|
||||||
|
|
||||||
|
$action = "do_Disown";
|
||||||
|
|
||||||
$maintainer_uids = array(pkgbase_maintainer_uid($base_id));
|
$maintainer_uids = array(pkgbase_maintainer_uid($base_id));
|
||||||
$comaintainers = pkgbase_get_comaintainers($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))): ?>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<h2><?= __('Disown Package') ?>: <?= htmlspecialchars($pkgbase_name) ?></h2>
|
<h2><?= __('Disown Package') ?>: <?= htmlspecialchars($pkgbase_name) ?></h2>
|
||||||
<p>
|
<p>
|
||||||
|
@ -23,7 +26,11 @@ if (has_credential(CRED_PKGBASE_DISOWN, $maintainer_uids)): ?>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</ul>
|
</ul>
|
||||||
<p>
|
<p>
|
||||||
<?php if (count($comaintainers) > 0 && !has_credential(CRED_PKGBASE_DISOWN)): ?>
|
|
||||||
|
<?php if (in_array(uid_from_sid($_COOKIE["AURSID"]), $comaintainer_uids) && !has_credential(CRED_PKGBASE_DISOWN)):
|
||||||
|
$action = "do_DisownComaintainer"; ?>
|
||||||
|
<?= __("By selecting the checkbox, you confirm that you want to no longer be a package co-maintainer.") ?>
|
||||||
|
<?php elseif (count($comaintainers) > 0 && !has_credential(CRED_PKGBASE_DISOWN)): ?>
|
||||||
<?= __('By selecting the checkbox, you confirm that you want to disown the package and transfer ownership to %s%s%s.',
|
<?= __('By selecting the checkbox, you confirm that you want to disown the package and transfer ownership to %s%s%s.',
|
||||||
'<strong>', $comaintainers[0], '</strong>'); ?>
|
'<strong>', $comaintainers[0], '</strong>'); ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
@ -40,7 +47,7 @@ if (has_credential(CRED_PKGBASE_DISOWN, $maintainer_uids)): ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<p><label class="confirmation"><input type="checkbox" name="confirm" value="1" />
|
<p><label class="confirmation"><input type="checkbox" name="confirm" value="1" />
|
||||||
<?= __("Confirm to disown the package") ?></label</p>
|
<?= __("Confirm to disown the package") ?></label</p>
|
||||||
<p><input type="submit" class="button" name="do_Disown" value="<?= __("Disown") ?>" /></p>
|
<p><input type="submit" class="button" name="<?= $action ?>" value="<?= __("Disown") ?>" /></p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -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 int $base_id The package base ID to update the co-maintainers of
|
||||||
* @param array $users Array of co-maintainer user names
|
* @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
|
* @return array Tuple of success/failure indicator and error message
|
||||||
*/
|
*/
|
||||||
function pkgbase_set_comaintainers($base_id, $users) {
|
function pkgbase_set_comaintainers($base_id, $users, $override=false) {
|
||||||
if (!has_credential(CRED_PKGBASE_EDIT_COMAINTAINERS, array(pkgbase_maintainer_uid($base_id)))) {
|
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."));
|
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."));
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
<?php if ($uid && $row["MaintainerUID"] === NULL): ?>
|
<?php if ($uid && $row["MaintainerUID"] === NULL): ?>
|
||||||
<li><?= html_action_form($base_uri . 'adopt/', "do_Adopt", __('Adopt Package')) ?></li>
|
<li><?= html_action_form($base_uri . 'adopt/', "do_Adopt", __('Adopt Package')) ?></li>
|
||||||
<?php elseif (has_credential(CRED_PKGBASE_DISOWN, array($row["MaintainerUID"]))): ?>
|
<?php elseif (has_credential(CRED_PKGBASE_DISOWN, array_merge(array($row["MaintainerUID"]), pkgbase_get_comaintainer_uids(array($base_id))))): ?>
|
||||||
<li><?= html_action_form($base_uri . 'disown/', "do_Disown", __('Disown Package')) ?></li>
|
<li><?= html_action_form($base_uri . 'disown/', "do_Disown", __('Disown Package')) ?></li>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
Loading…
Add table
Reference in a new issue