From eac17c0469a8e2b84b58f33b8f8aeb2f2addc2a9 Mon Sep 17 00:00:00 2001 From: "cyeh%bluemartini.com" <> Date: Thu, 22 Jun 2000 02:03:45 +0000 Subject: Checkin for Bug 42851 'Use listbox with input for CC management on bug form' contributed by dave@intrec.com (Dave Miller) --- Bugzilla/RelationSet.pm | 37 +++++++++++++++++++++++ RelationSet.pm | 37 +++++++++++++++++++++++ bug_form.pl | 78 ++++++++++++++++++++++++++++++++----------------- process_bug.cgi | 13 ++++++--- 4 files changed, 134 insertions(+), 31 deletions(-) diff --git a/Bugzilla/RelationSet.pm b/Bugzilla/RelationSet.pm index 92e2158f2..b5cae289c 100644 --- a/Bugzilla/RelationSet.pm +++ b/Bugzilla/RelationSet.pm @@ -18,6 +18,7 @@ # # Contributor(s): Dan Mosedale # Terry Weissman +# Dave Miller # This object models a set of relations between one item and a group # of other items. An example is the set of relations between one bug @@ -179,6 +180,42 @@ sub mergeFromString { } } +# remove a set in string form from this set +# +sub removeItemsInString { + ($#_ == 1) || confess("invalid number of arguments"); + my $self = shift(); + + # do the merge + # + foreach my $person (split(/[ ,]/, shift())) { + if ($person ne "") { + my $dbid = &::DBNameToIdAndCheck($person); + if (exists $$self{$dbid}) { + delete $$self{$dbid}; + } + } + } +} + +# remove a set in array form from this set +# +sub removeItemsInArray { + ($#_ > 0) || confess("invalid number of arguments"); + my $self = shift(); + + # do the merge + # + while (my $person = shift()) { + if ($person ne "") { + my $dbid = &::DBNameToIdAndCheck($person); + if (exists $$self{$dbid}) { + delete $$self{$dbid}; + } + } + } +} + # return the number of elements in this set # sub size { diff --git a/RelationSet.pm b/RelationSet.pm index 92e2158f2..b5cae289c 100644 --- a/RelationSet.pm +++ b/RelationSet.pm @@ -18,6 +18,7 @@ # # Contributor(s): Dan Mosedale # Terry Weissman +# Dave Miller # This object models a set of relations between one item and a group # of other items. An example is the set of relations between one bug @@ -179,6 +180,42 @@ sub mergeFromString { } } +# remove a set in string form from this set +# +sub removeItemsInString { + ($#_ == 1) || confess("invalid number of arguments"); + my $self = shift(); + + # do the merge + # + foreach my $person (split(/[ ,]/, shift())) { + if ($person ne "") { + my $dbid = &::DBNameToIdAndCheck($person); + if (exists $$self{$dbid}) { + delete $$self{$dbid}; + } + } + } +} + +# remove a set in array form from this set +# +sub removeItemsInArray { + ($#_ > 0) || confess("invalid number of arguments"); + my $self = shift(); + + # do the merge + # + while (my $person = shift()) { + if ($person ne "") { + my $dbid = &::DBNameToIdAndCheck($person); + if (exists $$self{$dbid}) { + delete $$self{$dbid}; + } + } + } +} + # return the number of elements in this set # sub size { diff --git a/bug_form.pl b/bug_form.pl index 1263957c7..5f6a77cea 100644 --- a/bug_form.pl +++ b/bug_form.pl @@ -18,6 +18,7 @@ # Rights Reserved. # # Contributor(s): Terry Weissman +# Dave Miller use diagnostics; use strict; @@ -151,9 +152,16 @@ my $component_popup = make_options($::components{$bug{'product'}}, my $ccSet = new RelationSet; $ccSet->mergeFromDB("select who from cc where bug_id=$id"); -my $cc_element = ''; - +my @ccList = $ccSet->toArrayOfStrings(); +my $cc_element = ""; +if (scalar(@ccList) > 0) { + $cc_element = "
\n" . + "Remove selected CCs
\n"; +} my $URL = $bug{'bug_file_loc'}; @@ -169,40 +177,55 @@ print " + - - - + + + + - + " + + + + + + + + + + + + + + - - - + + + - - - + + - "; + + "; if (Param("usetargetmilestone")) { my $url = ""; @@ -220,8 +243,9 @@ if (Param("usetargetmilestone")) { "; -} + " + "; +} else { print ""; } print " "; @@ -234,7 +258,7 @@ if (Param("useqacontact")) { "; } @@ -242,11 +266,11 @@ if (Param("useqacontact")) { print " @@ -256,10 +280,10 @@ if (Param("usestatuswhiteboard")) { print " "; } @@ -276,7 +300,7 @@ if (@::legal_keywords) { print qq{ + }; } @@ -292,7 +316,7 @@ while (MoreSQLData()) { $desc = value_quote($desc); print qq{}; } -print "
Bug#:$bug{'bug_id'}  Platform: Version:
 Reporter:$bug{'reporter'}
Product:   OS: Reporter:$bug{'reporter'}
 Add CC:
Component: Version: Cc: $cc_element
Status: $bug{'bug_status'}  Priority: Cc: $cc_element
 
Resolution: $bug{'resolution'}  Severity: Component:
 
Assigned To: $bug{'assigned_to'}$bug{'assigned_to'}   
$URL - +
Summary: - +
Status Whiteboard: - +
Keywords: -
$date$desc
Create a new attachment (proposed patch, testcase, etc.)
\n"; +print "Create a new attachment (proposed patch, testcase, etc.)\n"; sub EmitDependList { diff --git a/process_bug.cgi b/process_bug.cgi index 8b1226b3a..7665c1eda 100755 --- a/process_bug.cgi +++ b/process_bug.cgi @@ -20,6 +20,7 @@ # # Contributor(s): Terry Weissman # Dan Mosedale +# Dave Miller use diagnostics; use strict; @@ -391,10 +392,14 @@ my $origCcString; # form of the data it gets from $::FORM{'cc'}, so anything bogus from a # security standpoint should trigger an abort there. # -if (defined $::FORM{'cc'} && defined $::FORM{'id'}) { +if (defined $::FORM{'newcc'} && defined $::FORM{'id'}) { $origCcSet->mergeFromDB("select who from cc where bug_id = $::FORM{'id'}"); + $formCcSet->mergeFromDB("select who from cc where bug_id = $::FORM{'id'}"); $origCcString = $origCcSet->toString(); # cache a copy of the string vers - $formCcSet->mergeFromString($::FORM{'cc'}); + if ((exists $::FORM{'removecc'}) && (exists $::FORM{'cc'})) { + $formCcSet->removeItemsInArray(@{$::MFORM{'cc'}}); + } + $formCcSet->mergeFromString($::FORM{'newcc'}); } if ( Param('strictvaluechecks') ) { @@ -789,7 +794,7 @@ The changes made were: AppendComment($id, $::FORM{'who'}, $::FORM{'comment'}); } - if (defined $::FORM{'cc'} && defined $::FORM{'id'} + if (defined $::FORM{'newcc'} && defined $::FORM{'id'} && ! $origCcSet->isEqual($formCcSet) ) { # update the database to look like the form @@ -802,7 +807,7 @@ The changes made were: my $col = GetFieldID('cc'); my $origq = SqlQuote($origCcString); - my $newq = SqlQuote($::FORM{'cc'}); + my $newq = SqlQuote($formCcSet->toString()); SendSQL("INSERT INTO bugs_activity " . "(bug_id,who,bug_when,fieldid,oldvalue,newvalue) VALUES " . "($id,$whoid,'$timestamp',$col,$origq,$newq)"); -- cgit v1.2.3-24-g4f1b