From f0c7611262b3948e72e8a18a036569a78f3b51f2 Mon Sep 17 00:00:00 2001 From: "wurblzap%gmail.com" <> Date: Fri, 14 Jul 2006 03:07:57 +0000 Subject: Bug 69000: Permit a stored query to be marked "shared" and accessible by other users. Patch by Marc Schumann , r=vladd, a=myk --- editusers.cgi | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'editusers.cgi') diff --git a/editusers.cgi b/editusers.cgi index facb46600..9a4bfd5c0 100755 --- a/editusers.cgi +++ b/editusers.cgi @@ -460,9 +460,18 @@ if ($action eq 'search') { $vars->{'longdescs'} = $dbh->selectrow_array( 'SELECT COUNT(*) FROM longdescs WHERE who = ?', undef, $otherUserID); - $vars->{'namedqueries'} = $dbh->selectrow_array( - 'SELECT COUNT(*) FROM namedqueries WHERE userid = ?', - undef, $otherUserID); + $vars->{'namedqueries'} = $dbh->selectcol_arrayref( + 'SELECT id FROM namedqueries WHERE userid = ?', + undef, + $otherUserID); + if (@{$vars->{'namedqueries'}}) { + $vars->{'namedquery_group_map'} = $dbh->selectrow_array( + 'SELECT COUNT(*) FROM namedquery_group_map WHERE namedquery_id IN' . + ' (' . join(', ', @{$vars->{'namedqueries'}}) . ')'); + } + else { + $vars->{'namedquery_group_map'} = 0; + } $vars->{'profile_setting'} = $dbh->selectrow_array( 'SELECT COUNT(*) FROM profile_setting WHERE user_id = ?', undef, $otherUserID); @@ -525,6 +534,8 @@ if ($action eq 'search') { 'flagtypes READ', 'cc WRITE', 'namedqueries WRITE', + 'namedqueries_link_in_footer WRITE', + 'namedquery_group_map WRITE', 'tokens WRITE', 'votes WRITE', 'watch WRITE', @@ -545,6 +556,12 @@ if ($action eq 'search') { Bugzilla->logout_user($otherUser); + # Get the named query list so we can delete namedquery_group_map entries. + my $namedqueries_as_string = join(', ', $dbh->selectcol_arrayref( + 'SELECT id FROM namedqueries WHERE userid = ?', + undef, + $otherUserID)); + # Get the timestamp for LogActivityEntry. my $timestamp = $dbh->selectrow_array('SELECT NOW()'); @@ -589,6 +606,12 @@ if ($action eq 'search') { $otherUserID); $dbh->do('DELETE FROM logincookies WHERE userid = ?', undef, $otherUserID); $dbh->do('DELETE FROM namedqueries WHERE userid = ?', undef, $otherUserID); + $dbh->do('DELETE FROM namedqueries_link_in_footer WHERE user_id = ?', undef, + $otherUserID); + if ($namedqueries_as_string) { + $dbh->do('DELETE FROM namedquery_group_map WHERE namedquery_id IN ' . + "($namedqueries_as_string)"); + } $dbh->do('DELETE FROM profile_setting WHERE user_id = ?', undef, $otherUserID); $dbh->do('DELETE FROM profiles_activity WHERE userid = ? OR who = ?', undef, -- cgit v1.2.3-24-g4f1b