Commit 630116a9 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 303704: Eliminate deprecated Bugzilla::DB routines from editgroups.cgi -…

Bug 303704: Eliminate deprecated Bugzilla::DB routines from editgroups.cgi - Patch by Frédéric Buclin <LpSolit@gmail.com> r=joel a=justdave
parent 25c00ad2
...@@ -41,7 +41,7 @@ use vars qw($template $vars); ...@@ -41,7 +41,7 @@ use vars qw($template $vars);
Bugzilla->login(LOGIN_REQUIRED); Bugzilla->login(LOGIN_REQUIRED);
print Bugzilla->cgi->header(); print $cgi->header();
UserInGroup("creategroups") UserInGroup("creategroups")
|| ThrowUserError("auth_failure", {group => "creategroups", || ThrowUserError("auth_failure", {group => "creategroups",
...@@ -148,13 +148,14 @@ sub CheckGroupRegexp { ...@@ -148,13 +148,14 @@ sub CheckGroupRegexp {
unless ($action) { unless ($action) {
my @groups; my @groups;
SendSQL("SELECT id,name,description,userregexp,isactive,isbuggroup " . my $group_list =
"FROM groups " . $dbh->selectall_arrayref('SELECT id, name, description,
"ORDER BY isbuggroup, name"); userregexp, isactive, isbuggroup
FROM groups
ORDER BY isbuggroup, name');
while (MoreSQLData()) { foreach (@$group_list) {
my ($id, $name, $description, $regexp, $isactive, $isbuggroup) my ($id, $name, $description, $regexp, $isactive, $isbuggroup) = @$_;
= FetchSQLData();
my $group = {}; my $group = {};
$group->{'id'} = $id; $group->{'id'} = $id;
$group->{'name'} = $name; $group->{'name'} = $name;
...@@ -168,7 +169,7 @@ unless ($action) { ...@@ -168,7 +169,7 @@ unless ($action) {
$vars->{'groups'} = \@groups; $vars->{'groups'} = \@groups;
print Bugzilla->cgi->header(); print $cgi->header();
$template->process("admin/groups/list.html.tmpl", $vars) $template->process("admin/groups/list.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
...@@ -195,29 +196,34 @@ if ($action eq 'changeform') { ...@@ -195,29 +196,34 @@ if ($action eq 'changeform') {
# this one # this one
my @groups; my @groups;
SendSQL("SELECT groups.id, groups.name, groups.description," . my $group_list =
" CASE WHEN group_group_map.member_id IS NOT NULL THEN 1 ELSE 0 END," . $dbh->selectall_arrayref('SELECT groups.id, groups.name, groups.description,
" CASE WHEN B.member_id IS NOT NULL THEN 1 ELSE 0 END," . CASE WHEN group_group_map.member_id IS NOT NULL
" CASE WHEN C.member_id IS NOT NULL THEN 1 ELSE 0 END" . THEN 1 ELSE 0 END,
" FROM groups" . CASE WHEN B.member_id IS NOT NULL
" LEFT JOIN group_group_map" . THEN 1 ELSE 0 END,
" ON group_group_map.member_id = groups.id" . CASE WHEN C.member_id IS NOT NULL
" AND group_group_map.grantor_id = $group_id" . THEN 1 ELSE 0 END
" AND group_group_map.grant_type = " . GROUP_MEMBERSHIP . FROM groups
" LEFT JOIN group_group_map as B" . LEFT JOIN group_group_map
" ON B.member_id = groups.id" . ON group_group_map.member_id = groups.id
" AND B.grantor_id = $group_id" . AND group_group_map.grantor_id = ?
" AND B.grant_type = " . GROUP_BLESS . AND group_group_map.grant_type = ?
" LEFT JOIN group_group_map as C" . LEFT JOIN group_group_map as B
" ON C.member_id = groups.id" . ON B.member_id = groups.id
" AND C.grantor_id = $group_id" . AND B.grantor_id = ?
" AND C.grant_type = " . GROUP_VISIBLE . AND B.grant_type = ?
" ORDER by name"); LEFT JOIN group_group_map as C
ON C.member_id = groups.id
while (MoreSQLData()) { AND C.grantor_id = ?
my ($grpid, $grpnam, $grpdesc, $grpmember, $blessmember, $membercansee) AND C.grant_type = ?
= FetchSQLData(); ORDER by name',
undef, ($group_id, GROUP_MEMBERSHIP,
$group_id, GROUP_BLESS,
$group_id, GROUP_VISIBLE));
foreach (@$group_list) {
my ($grpid, $grpnam, $grpdesc, $grpmember, $blessmember, $membercansee) = @$_;
my $group = {}; my $group = {};
$group->{'grpid'} = $grpid; $group->{'grpid'} = $grpid;
$group->{'grpnam'} = $grpnam; $group->{'grpnam'} = $grpnam;
...@@ -236,7 +242,7 @@ if ($action eq 'changeform') { ...@@ -236,7 +242,7 @@ if ($action eq 'changeform') {
$vars->{'isbuggroup'} = $isbuggroup; $vars->{'isbuggroup'} = $isbuggroup;
$vars->{'groups'} = \@groups; $vars->{'groups'} = \@groups;
print Bugzilla->cgi->header(); print $cgi->header();
$template->process("admin/groups/edit.html.tmpl", $vars) $template->process("admin/groups/edit.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
...@@ -250,7 +256,7 @@ if ($action eq 'changeform') { ...@@ -250,7 +256,7 @@ if ($action eq 'changeform') {
# #
if ($action eq 'add') { if ($action eq 'add') {
print Bugzilla->cgi->header(); print $cgi->header();
$template->process("admin/groups/create.html.tmpl", $vars) $template->process("admin/groups/create.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
...@@ -273,37 +279,35 @@ if ($action eq 'new') { ...@@ -273,37 +279,35 @@ if ($action eq 'new') {
my $isactive = $cgi->param('isactive') ? 1 : 0; my $isactive = $cgi->param('isactive') ? 1 : 0;
# Add the new group # Add the new group
SendSQL("INSERT INTO groups ( " . $dbh->do('INSERT INTO groups
"name, description, isbuggroup, userregexp, isactive, last_changed " . (name, description, isbuggroup,
" ) VALUES ( " . userregexp, isactive, last_changed)
SqlQuote($name) . ", " . VALUES (?, ?, 1, ?, ?, NOW())',
SqlQuote($desc) . ", " . undef, ($name, $desc, $regexp, $isactive));
"1," .
SqlQuote($regexp) . ", " .
$isactive . ", NOW())" );
my $gid = $dbh->bz_last_key('groups', 'id'); my $gid = $dbh->bz_last_key('groups', 'id');
my $admin = GroupNameToId('admin'); my $admin = GroupNameToId('admin');
# Since we created a new group, give the "admin" group all privileges # Since we created a new group, give the "admin" group all privileges
# initially. # initially.
SendSQL("INSERT INTO group_group_map (member_id, grantor_id, grant_type) my $sth = $dbh->prepare('INSERT INTO group_group_map
VALUES ($admin, $gid, " . GROUP_MEMBERSHIP . ")"); (member_id, grantor_id, grant_type)
SendSQL("INSERT INTO group_group_map (member_id, grantor_id, grant_type) VALUES (?, ?, ?)');
VALUES ($admin, $gid, " . GROUP_BLESS . ")");
SendSQL("INSERT INTO group_group_map (member_id, grantor_id, grant_type) $sth->execute($admin, $gid, GROUP_MEMBERSHIP);
VALUES ($admin, $gid, " . GROUP_VISIBLE . ")"); $sth->execute($admin, $gid, GROUP_BLESS);
$sth->execute($admin, $gid, GROUP_VISIBLE);
# Permit all existing products to use the new group if makeproductgroups. # Permit all existing products to use the new group if makeproductgroups.
if ($cgi->param('insertnew')) { if ($cgi->param('insertnew')) {
SendSQL("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)
"SELECT $gid, products.id, 0, " . SELECT ?, products.id, 0, ?, ?, 0 FROM products',
CONTROLMAPSHOWN . ", " . undef, ($gid, CONTROLMAPSHOWN, CONTROLMAPNA));
CONTROLMAPNA . ", 0 " .
"FROM products");
} }
RederiveRegexp($regexp, $gid); RederiveRegexp($regexp, $gid);
print Bugzilla->cgi->header(); print $cgi->header();
$template->process("admin/groups/created.html.tmpl", $vars) $template->process("admin/groups/created.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
exit; exit;
...@@ -327,38 +331,24 @@ if ($action eq 'del') { ...@@ -327,38 +331,24 @@ if ($action eq 'del') {
ThrowUserError("system_group_not_deletable", { name => $name }); ThrowUserError("system_group_not_deletable", { name => $name });
} }
my $hasusers = 0; my $hasusers = $dbh->selectrow_array('SELECT 1 FROM user_group_map
SendSQL("SELECT user_id FROM user_group_map WHERE group_id = ? AND isbless = 0 ' .
WHERE group_id = $gid AND isbless = 0"); $dbh->sql_limit(1),
if (FetchOneColumn()) { undef, $gid) || 0;
$hasusers = 1;
}
my $hasbugs = 0;
my $buglist = "0";
SendSQL("SELECT bug_id FROM bug_group_map WHERE group_id = $gid");
if (MoreSQLData()) { my $bug_ids = $dbh->selectcol_arrayref('SELECT bug_id FROM bug_group_map
$hasbugs = 1; WHERE group_id = ?', undef, $gid);
while (MoreSQLData()) { my $hasbugs = scalar(@$bug_ids) ? 1 : 0;
my ($bug) = FetchSQLData(); my $buglist = join(',', @$bug_ids);
$buglist .= "," . $bug;
}
}
my $hasproduct = 0; my $hasproduct = get_product_id($name) ? 1 : 0;
SendSQL("SELECT name FROM products WHERE name=" . SqlQuote($name));
if (MoreSQLData()) {
$hasproduct = 1;
}
my $hasflags = 0; my $hasflags = $dbh->selectrow_array('SELECT 1 FROM flagtypes
SendSQL("SELECT id FROM flagtypes WHERE grant_group_id = ?
WHERE grant_group_id = $gid OR request_group_id = $gid"); OR request_group_id = ? ' .
if (FetchOneColumn()) { $dbh->sql_limit(1),
$hasflags = 1; undef, ($gid, $gid)) || 0;
}
$vars->{'gid'} = $gid; $vars->{'gid'} = $gid;
$vars->{'name'} = $name; $vars->{'name'} = $name;
...@@ -369,7 +359,7 @@ if ($action eq 'del') { ...@@ -369,7 +359,7 @@ if ($action eq 'del') {
$vars->{'hasflags'} = $hasflags; $vars->{'hasflags'} = $hasflags;
$vars->{'buglist'} = $buglist; $vars->{'buglist'} = $buglist;
print Bugzilla->cgi->header(); print $cgi->header();
$template->process("admin/groups/delete.html.tmpl", $vars) $template->process("admin/groups/delete.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
...@@ -394,53 +384,62 @@ if ($action eq 'delete') { ...@@ -394,53 +384,62 @@ if ($action eq 'delete') {
my $cantdelete = 0; my $cantdelete = 0;
SendSQL("SELECT user_id FROM user_group_map my $hasusers = $dbh->selectrow_array('SELECT 1 FROM user_group_map
WHERE group_id = $gid AND isbless = 0"); WHERE group_id = ? AND isbless = 0 ' .
if (FetchOneColumn()) { $dbh->sql_limit(1),
if (!defined $cgi->param('removeusers')) { undef, $gid) || 0;
$cantdelete = 1; if ($hasusers && !defined $cgi->param('removeusers')) {
} $cantdelete = 1;
} }
SendSQL("SELECT bug_id FROM bug_group_map WHERE group_id = $gid");
if (FetchOneColumn()) { my $hasbugs = $dbh->selectrow_array('SELECT 1 FROM bug_group_map
if (!defined $cgi->param('removebugs')) { WHERE group_id = ? ' .
$cantdelete = 1; $dbh->sql_limit(1),
} undef, $gid) || 0;
if ($hasbugs && !defined $cgi->param('removebugs')) {
$cantdelete = 1;
} }
SendSQL("SELECT name FROM products WHERE name=" . SqlQuote($name));
if (FetchOneColumn()) { if (get_product_id($name) && !defined $cgi->param('unbind')) {
if (!defined $cgi->param('unbind')) { $cantdelete = 1;
$cantdelete = 1;
}
} }
SendSQL("SELECT id FROM flagtypes
WHERE grant_group_id = $gid OR request_group_id = $gid"); my $hasflags = $dbh->selectrow_array('SELECT 1 FROM flagtypes
if (FetchOneColumn()) { WHERE grant_group_id = ?
if (!defined $cgi->param('removeflags')) { OR request_group_id = ? ' .
$cantdelete = 1; $dbh->sql_limit(1),
} undef, ($gid, $gid)) || 0;
if ($hasflags && !defined $cgi->param('removeflags')) {
$cantdelete = 1;
} }
if (!$cantdelete) { if (!$cantdelete) {
SendSQL("UPDATE flagtypes SET grant_group_id = NULL $dbh->do('UPDATE flagtypes SET grant_group_id = ?
WHERE grant_group_id = $gid"); WHERE grant_group_id = ?',
SendSQL("UPDATE flagtypes SET request_group_id = NULL undef, (undef, $gid));
WHERE request_group_id = $gid"); $dbh->do('UPDATE flagtypes SET request_group_id = ?
SendSQL("DELETE FROM user_group_map WHERE group_id = $gid"); WHERE request_group_id = ?',
SendSQL("DELETE FROM group_group_map WHERE grantor_id = $gid"); undef, (undef, $gid));
SendSQL("DELETE FROM bug_group_map WHERE group_id = $gid"); $dbh->do('DELETE FROM user_group_map WHERE group_id = ?',
SendSQL("DELETE FROM group_control_map WHERE group_id = $gid"); undef, $gid);
SendSQL("DELETE FROM whine_schedules WHERE " . $dbh->do('DELETE FROM group_group_map WHERE grantor_id = ?',
"mailto_type = " . MAILTO_GROUP . " " . undef, $gid);
"AND mailto = $gid"); $dbh->do('DELETE FROM bug_group_map WHERE group_id = ?',
SendSQL("DELETE FROM groups WHERE id = $gid"); undef, $gid);
$dbh->do('DELETE FROM group_control_map WHERE group_id = ?',
undef, $gid);
$dbh->do('DELETE FROM whine_schedules
WHERE mailto_type = ? AND mailto = ?',
undef, (MAILTO_GROUP, $gid));
$dbh->do('DELETE FROM groups WHERE id = ?',
undef, $gid);
} }
$vars->{'gid'} = $gid; $vars->{'gid'} = $gid;
$vars->{'name'} = $name; $vars->{'name'} = $name;
$vars->{'cantdelete'} = $cantdelete; $vars->{'cantdelete'} = $cantdelete;
print Bugzilla->cgi->header(); print $cgi->header();
$template->process("admin/groups/deleted.html.tmpl", $vars) $template->process("admin/groups/deleted.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
...@@ -474,7 +473,7 @@ if ($action eq 'postchanges') { ...@@ -474,7 +473,7 @@ if ($action eq 'postchanges') {
$vars->{'regexp'} = $regexp; $vars->{'regexp'} = $regexp;
} }
print Bugzilla->cgi->header(); print $cgi->header();
$template->process("admin/groups/change.html.tmpl", $vars) $template->process("admin/groups/change.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
exit; exit;
...@@ -487,19 +486,20 @@ if (($action eq 'remove_all_regexp') || ($action eq 'remove_all')) { ...@@ -487,19 +486,20 @@ if (($action eq 'remove_all_regexp') || ($action eq 'remove_all')) {
my $gid = CheckGroupID($cgi->param('group')); my $gid = CheckGroupID($cgi->param('group'));
my $sth = $dbh->prepare("SELECT name, userregexp FROM groups my ($name, $regexp) =
WHERE id = ?"); $dbh->selectrow_array('SELECT name, userregexp FROM groups
$sth->execute($gid); WHERE id = ?', undef, $gid);
my ($name, $regexp) = $sth->fetchrow_array();
$dbh->bz_lock_tables('groups WRITE', 'profiles READ', $dbh->bz_lock_tables('groups WRITE', 'profiles READ',
'user_group_map WRITE'); 'user_group_map WRITE');
$sth = $dbh->prepare("SELECT user_group_map.user_id, profiles.login_name
FROM user_group_map my $sth = $dbh->prepare("SELECT user_group_map.user_id, profiles.login_name
INNER JOIN profiles FROM user_group_map
ON user_group_map.user_id = profiles.userid INNER JOIN profiles
WHERE user_group_map.group_id = ? ON user_group_map.user_id = profiles.userid
AND grant_type = ? WHERE user_group_map.group_id = ?
AND isbless = 0"); AND grant_type = ?
AND isbless = 0");
$sth->execute($gid, GRANT_DIRECT); $sth->execute($gid, GRANT_DIRECT);
my @users; my @users;
...@@ -507,11 +507,12 @@ if (($action eq 'remove_all_regexp') || ($action eq 'remove_all')) { ...@@ -507,11 +507,12 @@ if (($action eq 'remove_all_regexp') || ($action eq 'remove_all')) {
WHERE user_id = ? WHERE user_id = ?
AND isbless = 0 AND isbless = 0
AND group_id = ?"); AND group_id = ?");
while ( my ($userid, $userlogin) = $sth->fetchrow_array() ) { while ( my ($userid, $userlogin) = $sth->fetchrow_array() ) {
if ((($regexp =~ /\S/) && ($userlogin =~ m/$regexp/i)) if ((($regexp =~ /\S/) && ($userlogin =~ m/$regexp/i))
|| ($action eq 'remove_all')) || ($action eq 'remove_all'))
{ {
$sth2->execute($userid,$gid); $sth2->execute($userid, $gid);
my $user = {}; my $user = {};
$user->{'login'} = $userlogin; $user->{'login'} = $userlogin;
...@@ -519,10 +520,8 @@ if (($action eq 'remove_all_regexp') || ($action eq 'remove_all')) { ...@@ -519,10 +520,8 @@ if (($action eq 'remove_all_regexp') || ($action eq 'remove_all')) {
} }
} }
$sth = $dbh->prepare("UPDATE groups $dbh->do('UPDATE groups SET last_changed = NOW()
SET last_changed = NOW() WHERE id = ?', undef, $gid);
WHERE id = ?");
$sth->execute($gid);
$dbh->bz_unlock_tables(); $dbh->bz_unlock_tables();
$vars->{'users'} = \@users; $vars->{'users'} = \@users;
...@@ -531,7 +530,7 @@ if (($action eq 'remove_all_regexp') || ($action eq 'remove_all')) { ...@@ -531,7 +530,7 @@ if (($action eq 'remove_all_regexp') || ($action eq 'remove_all')) {
$vars->{'remove_all'} = ($action eq 'remove_all'); $vars->{'remove_all'} = ($action eq 'remove_all');
$vars->{'gid'} = $gid; $vars->{'gid'} = $gid;
print Bugzilla->cgi->header(); print $cgi->header();
$template->process("admin/groups/remove.html.tmpl", $vars) $template->process("admin/groups/remove.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
...@@ -550,7 +549,6 @@ ThrowCodeError("action_unrecognized", $vars); ...@@ -550,7 +549,6 @@ ThrowCodeError("action_unrecognized", $vars);
sub doGroupChanges { sub doGroupChanges {
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my $sth;
$dbh->bz_lock_tables('groups WRITE', 'group_group_map WRITE', $dbh->bz_lock_tables('groups WRITE', 'group_group_map WRITE',
'user_group_map WRITE', 'profiles READ', 'user_group_map WRITE', 'profiles READ',
...@@ -563,8 +561,8 @@ sub doGroupChanges { ...@@ -563,8 +561,8 @@ sub doGroupChanges {
# The name and the description of system groups cannot be edited. # The name and the description of system groups cannot be edited.
# We then need to know if the group being edited is a system group. # We then need to know if the group being edited is a system group.
SendSQL("SELECT isbuggroup FROM groups WHERE id = $gid"); my $isbuggroup = $dbh->selectrow_array('SELECT isbuggroup FROM groups
my ($isbuggroup) = FetchSQLData(); WHERE id = ?', undef, $gid);
my $name; my $name;
my $desc; my $desc;
my $isactive; my $isactive;
...@@ -583,27 +581,36 @@ sub doGroupChanges { ...@@ -583,27 +581,36 @@ sub doGroupChanges {
if ($name ne $cgi->param('oldname')) { if ($name ne $cgi->param('oldname')) {
$chgs = 1; $chgs = 1;
$sth = $dbh->do("UPDATE groups SET name = ? WHERE id = ?", $dbh->do('UPDATE groups SET name = ? WHERE id = ?',
undef, $name, $gid); undef, ($name, $gid));
} }
if ($desc ne $cgi->param('olddesc')) { if ($desc ne $cgi->param('olddesc')) {
$chgs = 1; $chgs = 1;
$sth = $dbh->do("UPDATE groups SET description = ? WHERE id = ?", $dbh->do('UPDATE groups SET description = ? WHERE id = ?',
undef, $desc, $gid); undef, ($desc, $gid));
} }
if ($isactive ne $cgi->param('oldisactive')) { if ($isactive ne $cgi->param('oldisactive')) {
$chgs = 1; $chgs = 1;
$sth = $dbh->do("UPDATE groups SET isactive = ? WHERE id = ?", $dbh->do('UPDATE groups SET isactive = ? WHERE id = ?',
undef, $isactive, $gid); undef, ($isactive, $gid));
} }
} }
if ($regexp ne $cgi->param('oldregexp')) { if ($regexp ne $cgi->param('oldregexp')) {
$chgs = 1; $chgs = 1;
$sth = $dbh->do("UPDATE groups SET userregexp = ? WHERE id = ?", $dbh->do('UPDATE groups SET userregexp = ? WHERE id = ?',
undef, $regexp, $gid); undef, ($regexp, $gid));
RederiveRegexp($regexp, $gid); RederiveRegexp($regexp, $gid);
} }
my $sthInsert = $dbh->prepare('INSERT INTO group_group_map
(member_id, grantor_id, grant_type)
VALUES (?, ?, ?)');
my $sthDelete = $dbh->prepare('DELETE FROM group_group_map
WHERE member_id = ?
AND grantor_id = ?
AND grant_type = ?');
foreach my $b (grep {/^oldgrp-\d*$/} $cgi->param()) { foreach my $b (grep {/^oldgrp-\d*$/} $cgi->param()) {
if (defined($cgi->param($b))) { if (defined($cgi->param($b))) {
$b =~ /^oldgrp-(\d+)$/; $b =~ /^oldgrp-(\d+)$/;
...@@ -612,13 +619,9 @@ sub doGroupChanges { ...@@ -612,13 +619,9 @@ sub doGroupChanges {
if (($v != $gid) && ($cgi->param("oldgrp-$v") != $grp)) { if (($v != $gid) && ($cgi->param("oldgrp-$v") != $grp)) {
$chgs = 1; $chgs = 1;
if ($grp != 0) { if ($grp != 0) {
SendSQL("INSERT INTO group_group_map $sthInsert->execute($v, $gid, GROUP_MEMBERSHIP);
(member_id, grantor_id, grant_type)
VALUES ($v, $gid," . GROUP_MEMBERSHIP . ")");
} else { } else {
SendSQL("DELETE FROM group_group_map $sthDelete->execute($v, $gid, GROUP_MEMBERSHIP);
WHERE member_id = $v AND grantor_id = $gid
AND grant_type = " . GROUP_MEMBERSHIP);
} }
} }
...@@ -627,13 +630,9 @@ sub doGroupChanges { ...@@ -627,13 +630,9 @@ sub doGroupChanges {
if ((defined $oldbless) and ($oldbless != $bless)) { if ((defined $oldbless) and ($oldbless != $bless)) {
$chgs = 1; $chgs = 1;
if ($bless != 0) { if ($bless != 0) {
SendSQL("INSERT INTO group_group_map $sthInsert->execute($v, $gid, GROUP_BLESS);
(member_id, grantor_id, grant_type)
VALUES ($v, $gid," . GROUP_BLESS . ")");
} else { } else {
SendSQL("DELETE FROM group_group_map $sthDelete->execute($v, $gid, GROUP_BLESS);
WHERE member_id = $v AND grantor_id = $gid
AND grant_type = " . GROUP_BLESS);
} }
} }
...@@ -642,22 +641,19 @@ sub doGroupChanges { ...@@ -642,22 +641,19 @@ sub doGroupChanges {
&& ($cgi->param("oldcansee-$v") != $cansee)) { && ($cgi->param("oldcansee-$v") != $cansee)) {
$chgs = 1; $chgs = 1;
if ($cansee != 0) { if ($cansee != 0) {
SendSQL("INSERT INTO group_group_map $sthInsert->execute($v, $gid, GROUP_VISIBLE);
(member_id, grantor_id, grant_type)
VALUES ($v, $gid," . GROUP_VISIBLE . ")");
} else { } else {
SendSQL("DELETE FROM group_group_map $sthDelete->execute($v, $gid, GROUP_VISIBLE);
WHERE member_id = $v AND grantor_id = $gid
AND grant_type = " . GROUP_VISIBLE);
} }
} }
} }
} }
if ($chgs) { if ($chgs) {
# mark the changes # mark the changes
SendSQL("UPDATE groups SET last_changed = NOW() WHERE id = $gid"); $dbh->do('UPDATE groups SET last_changed = NOW()
WHERE id = ?', undef, $gid);
} }
$dbh->bz_unlock_tables(); $dbh->bz_unlock_tables();
return $gid, $chgs, $name, $regexp; return $gid, $chgs, $name, $regexp;
......
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