add support for multiple email addresses in the requester and requestee fields in the request queue

NEW
Unassigned

Status

()

--
enhancement
16 years ago
12 years ago

People

(Reporter: asa, Unassigned)

Tracking

Details

Attachments

(1 attachment)

(Reporter)

Description

16 years ago
It would be nice to be able to generate a request queue for several different
requestees or requesters. Implementing support for a comma or space separated
list of email addresses in the Requester and Requestee fields on the request
queue page would accomplish this.
Created attachment 184864 [details] [diff] [review]
patch-v-1-0

Patch which implements the enhancement.

The solution is the following:
 * if one requester/requestee is provided everything works as before
 * if more than one requester/requestee is provided they are converted to IN
(R1, R2, ...) list
For separation of requester/requestee one can use any \s separator as well as a
comma.

On low-level the solution is that instead of "login_name = 'XXXX'" a
"login_name in ('X1','X2','X3',...)" is used.
Attachment #184864 - Flags: review?(LpSolit)
Note: the patch-v-1-0 (attachment 184864 [details] [diff] [review]) has been prepared against release 2.18.1.

Comment 3

14 years ago
Comment on attachment 184864 [details] [diff] [review]
patch-v-1-0

>-        push(@criteria, "requesters.login_name = " . SqlQuote($cgi->param('requester')));
>-        push(@excluded_columns, 'requester') unless $cgi->param('do_union');
>+    	# change all requester delimiters to a single space
>+	my $requester_criteria = "";
>+	my $requester_list = $cgi->param('requester');
>+    	$requester_list =~ s/[\s,]+/ /g;
>+	my @requester_list_array= split(" ", $requester_list);
>+	foreach my $requester_list_element (@requester_list_array) {
>+		$requester_criteria = $requester_criteria . SqlQuote($requester_list_element) . ",";
>+	}
>+	# strip trailing comma
>+    	$requester_criteria=~ s/,$/ /;
>+        push(@criteria,  "requesters.login_name IN (" .$requester_criteria.")");
>+	if (@requester_list_array==1)
>+	{
>+	    push(@excluded_columns, 'requester') unless $cgi->param('do_union');
>+	}

It's much simpler than that! Steps are:

1. First convert $cgi->param('requester') to a list using commas and spaces as
delimiters:
   my @requesters = split(/[,\s]/, $cgi->param('requester'));

2. These values have to be detainted and SQL-quoted:
   @requesters = map($dbh->quote($_), @requesters); <- I'm lazy; I only did the
SQL-quoted part.

3. Convert the SQL query to accept several requesters, *IF* there is at least
one requester found, else your SQL query will crash. In other words, ignore
$cgi->param('requester') if there is no requester found:
   push(@criteria, "requesters.login_name IN (" . join(",", @requesters) .
")");

4. Don't forget to show the 'requester' column if more than one requester is
given.


>-        push(@criteria, "requestees.login_name = " .
>-            SqlQuote($cgi->param('requestee')));
>-        push(@excluded_columns, 'requestee') unless $cgi->param('do_union');
>+    	# change all requestee delimiters to a single space
>+	my $requestee_criteria = "";
>+	my $requestee_list = $cgi->param('requestee');
>+    	$requestee_list =~ s/[\s,]+/ /g;
>+	my @requestee_list_array= split(" ", $requestee_list);
>+	foreach my $requestee_list_element (@requestee_list_array) {
>+		$requestee_criteria = $requestee_criteria . SqlQuote($requestee_list_element) . ",";
>+	}
>+	# strip trailing comma
>+    	$requestee_criteria=~ s/,$/ /;
>+        push(@criteria,  "requestees.login_name IN (" .$requestee_criteria.")");
>+	if (@requestee_list_array==1)
>+	{
>+    	    push(@excluded_columns, 'requestee') unless $cgi->param('do_union');
>+	}

The same process applies here.

Don't forget to write the patch using the latest CVS version of requests.cgi as
it will not be taken for the 2.18 branch.
Attachment #184864 - Flags: review?(LpSolit) → review-

Updated

13 years ago
QA Contact: mattyt-bugzilla → default-qa

Updated

12 years ago
Assignee: myk → attach-and-request
You need to log in before you can comment on or make changes to this bug.