Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1293 dpurdie 1
###############################################################################
2
# Codestriker: Copyright (c) 2001, 2002 David Sitsky.  All rights reserved.
3
# sits@users.sourceforge.net
4
#
5
# This program is free software; you can redistribute it and modify it under
6
# the terms of the GPL.
7
 
8
# Action object for handling the submission of topic search.
9
 
10
package Codestriker::Action::SubmitSearch;
11
 
12
use strict;
13
 
14
# If the input is valid, redirect the user to the appropriate topic view
15
# screen.
16
sub process($$$) {
17
    my ($type, $http_input, $http_response) = @_;
18
 
19
    my $query = $http_response->get_query();
20
 
21
    # Check that the appropriate fields have been filled in.
22
    my $sauthor = $http_input->get('sauthor') || "";
23
    my $sreviewer = $http_input->get('sreviewer') || "";
24
    my $scc = $http_input->get('scc') || "";
25
    my $sbugid = $http_input->get('sbugid') || "";
26
    my $stext = $http_input->get('stext') || "";
27
 
28
    # Process the text search checkboxes.
29
    my @text_group = $query->param('text_group');
30
    my $search_title = 0;
31
    my $search_description = 0;
32
    my $search_comments = 0;
33
    my $search_body = 0;
34
    my $search_filename = 0;
35
    if ($stext ne "") {
36
	for (my $i = 0; $i <= $#text_group; $i++) {
37
	    if ($text_group[$i] eq "title") {
38
		$search_title = 1;
39
	    } elsif ($text_group[$i] eq "description") {
40
		$search_description = 1;
41
	    } elsif ($text_group[$i] eq "comment") {
42
		$search_comments = 1;
43
	    } elsif ($text_group[$i] eq "body") {
44
		$search_body = 1;
45
	    } elsif ($text_group[$i] eq "filename") {
46
		$search_filename = 1;
47
	    }
48
	}
49
    }
50
 
51
    # Process the state multi-popup.
52
    my @state_group = $query->param('state_group');
53
    my @stateids;
54
    for (my $i = 0; $i <= $#state_group; $i++) {
55
	if ($state_group[$i] eq "Any") {
56
	    # No need to encode anything in the URL.
57
	    @stateids = ();
58
	    last;
59
	}
60
	for (my $j = 0; $j <= $#Codestriker::topic_states; $j++) {
61
	    if ($state_group[$i] eq $Codestriker::topic_states[$j]) {
62
		push @stateids, $j;
63
		    last;
64
	    }
65
	}
66
    }
67
 
68
    # Process the project multi-popup.
69
    my @project_group = $query->param('project_group');
70
    my @projectids;
71
    for (my $i = 0; $i <= $#project_group; $i++) {
72
	if ($project_group[$i] == -1) {
73
	    # No need to encode anything in the URL.
74
	    @projectids = ();
75
	    last;
76
	}
77
	push @projectids, $project_group[$i];
78
    }
79
 
80
    # Redirect the user to the list topics page.
81
    my $url_builder = Codestriker::Http::UrlBuilder->new($query);
82
    my $redirect_url =
83
	$url_builder->list_topics_url($sauthor, $sreviewer, $scc, $sbugid,
84
				      $stext, $search_title,
85
				      $search_description, $search_comments,
86
				      $search_body, $search_filename,
87
				      \@stateids, \@projectids);
88
 
89
    print $query->redirect(-URI=>$redirect_url);
90
}
91
 
92
1;