Commit 1a3c26e6 authored by bugreport%peshkin.net's avatar bugreport%peshkin.net

Bug 185760: New group system doesn't upgrade transparently if usebuggroups = 0

r=justdave a=justdave
parent 3154b337
...@@ -3472,47 +3472,44 @@ if (TableExists("attachstatuses") && TableExists("attachstatusdefs")) { ...@@ -3472,47 +3472,44 @@ if (TableExists("attachstatuses") && TableExists("attachstatusdefs")) {
# 2002-11-24 - bugreport@peshkin.net - bug 147275 # 2002-11-24 - bugreport@peshkin.net - bug 147275
# #
if (Param('makeproductgroups')) { # If group_control_map is empty, backward-compatbility
# If makeproductgroups is enabled and group_control_map is empty, # usebuggroups-equivalent records should be created.
# backward-compatbility usebuggroups-equivalent records should my $entry = Param('useentrygroupdefault');
# be created. $sth = $dbh->prepare("SELECT COUNT(*) FROM group_control_map");
my $entry = Param('useentrygroupdefault'); $sth->execute();
$sth = $dbh->prepare("SELECT COUNT(*) FROM group_control_map"); my ($mapcnt) = $sth->fetchrow_array();
if ($mapcnt == 0) {
# Initially populate group_control_map.
# First, get all the existing products and their groups.
$sth = $dbh->prepare("SELECT groups.id, products.id, groups.name, " .
"products.name FROM groups, products " .
"WHERE isbuggroup != 0 AND isactive != 0");
$sth->execute(); $sth->execute();
my ($mapcnt) = $sth->fetchrow_array(); while (my ($groupid, $productid, $groupname, $productname)
if ($mapcnt == 0) { = $sth->fetchrow_array()) {
# Initially populate group_control_map. if ($groupname eq $productname) {
# First, get all the existing products and their groups. # Product and group have same name.
$sth = $dbh->prepare("SELECT groups.id, products.id, groups.name, " . $dbh->do("INSERT INTO group_control_map " .
"products.name FROM groups, products " . "(group_id, product_id, entry, membercontrol, " .
"WHERE isbuggroup != 0 AND isactive != 0"); "othercontrol, canedit) " .
$sth->execute(); "VALUES ($groupid, $productid, $entry, " .
while (my ($groupid, $productid, $groupname, $productname) CONTROLMAPDEFAULT . ", " .
= $sth->fetchrow_array()) { CONTROLMAPNA . ", 0)");
if ($groupname eq $productname) { } else {
# Product and group have same name. # See if this group is a product group at all.
my $sth2 = $dbh->prepare("SELECT id FROM products WHERE name = " .
$dbh->quote($groupname));
$sth2->execute();
my ($id) = $sth2->fetchrow_array();
if (!$id) {
# If there is no product with the same name as this
# group, then it is permitted for all products.
$dbh->do("INSERT INTO group_control_map " . $dbh->do("INSERT INTO group_control_map " .
"(group_id, product_id, entry, membercontrol, " . "(group_id, product_id, entry, membercontrol, " .
"othercontrol, canedit) " . "othercontrol, canedit) " .
"VALUES ($groupid, $productid, $entry, " . "VALUES ($groupid, $productid, 0, " .
CONTROLMAPDEFAULT . ", " . CONTROLMAPSHOWN . ", " .
CONTROLMAPNA . ", 0)"); CONTROLMAPNA . ", 0)");
} else {
# See if this group is a product group at all.
my $sth2 = $dbh->prepare("SELECT id FROM products WHERE name = " .
$dbh->quote($groupname));
$sth2->execute();
my ($id) = $sth2->fetchrow_array();
if (!$id) {
# If there is no product with the same name as this
# group, then it is permitted for all products.
$dbh->do("INSERT INTO group_control_map " .
"(group_id, product_id, entry, membercontrol, " .
"othercontrol, canedit) " .
"VALUES ($groupid, $productid, 0, " .
CONTROLMAPSHOWN . ", " .
CONTROLMAPNA . ", 0)");
}
} }
} }
} }
......
Markdown is supported
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