summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2015-05-22 19:38:38 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2015-05-22 21:14:26 +0200
commitdd3eb28a8cb35aeb8a069f3a20e5eb5fd348de62 (patch)
treec8891478528fe8e33eeaf7d20ac3dac942d1353c
parentc6e09def2b75762128f432130556ec6121fd8b8c (diff)
downloadaurweb-dd3eb28a8cb35aeb8a069f3a20e5eb5fd348de62.tar.xz
Update co-maintainer list when promoting a user
When a user disowns a package and promotes a co-maintainer, remove that new maintainer from the list of package co-maintainers. Since only the package maintainer can manage co-maintainers, this must happen before the actual disown operation. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
-rw-r--r--web/lib/pkgbasefuncs.inc.php33
1 files changed, 20 insertions, 13 deletions
diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php
index 5b8b52f..327b7f9 100644
--- a/web/lib/pkgbasefuncs.inc.php
+++ b/web/lib/pkgbasefuncs.inc.php
@@ -629,32 +629,39 @@ function pkgbase_adopt ($base_ids, $action=true, $via) {
}
}
- $q = "UPDATE PackageBases ";
+ /* Adopt or disown the package. */
if ($action) {
+ $q = "UPDATE PackageBases ";
$q.= "SET MaintainerUID = $uid ";
+ $q.= "WHERE ID IN (" . implode(",", $base_ids) . ") ";
+ $dbh->exec($q);
} else {
- $q.= "SET MaintainerUID = NULL ";
- }
- $q.= "WHERE ID IN (" . implode(",", $base_ids) . ") ";
- $dbh->exec($q);
-
- /* Update package co-maintainers when disowning a package. */
- if (!$action) {
+ /* Update the co-maintainer list when disowning a package. */
if (has_credential(CRED_PKGBASE_DISOWN)) {
foreach ($base_ids as $base_id) {
- pkgbase_set_comaintainers($base_id, "");
+ pkgbase_set_comaintainers($base_id, array());
}
+
+ $q = "UPDATE PackageBases ";
+ $q.= "SET MaintainerUID = NULL ";
+ $q.= "WHERE ID IN (" . implode(",", $base_ids) . ") ";
+ $dbh->exec($q);
} else {
foreach ($base_ids as $base_id) {
$comaintainers = pkgbase_get_comaintainers($base_id);
if (count($comaintainers) > 0) {
$uid = uid_from_username($comaintainers[0]);
- $q = "UPDATE PackageBases ";
- $q.= "SET MaintainerUID = " . $uid . " ";
- $q.= "WHERE ID = " . $base_id;
- $dbh->exec($q);
+ $comaintainers = array_diff($comaintainers, array($comaintainers[0]));
+ pkgbase_set_comaintainers($base_id, $comaintainers);
+ } else {
+ $uid = "NULL";
}
+
+ $q = "UPDATE PackageBases ";
+ $q.= "SET MaintainerUID = " . $uid . " ";
+ $q.= "WHERE ID = " . $base_id;
+ $dbh->exec($q);
}
}
}