Subversion Repositories DevTools

Rev

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 a new project.
9
 
10
package Codestriker::Action::SubmitNewProject;
11
 
12
use strict;
13
 
14
use Codestriker;
15
use Codestriker::Model::Project;
16
use Codestriker::Action::ListProjects;
17
use Codestriker::Action::CreateProject;
18
 
19
# If the input is valid, create the appropriate project into the database.
20
sub process($$$) {
21
    my ($type, $http_input, $http_response) = @_;
22
 
23
    # Check if this operation is allowed.
24
    if (Codestriker->projects_disabled()) {
25
	$http_response->error("This function has been disabled");
26
    }
27
 
28
    my $query = $http_response->get_query();
29
 
30
    # Check that the appropriate fields have been filled in.
31
    my $project_name = $http_input->get('project_name');
32
    my $project_description = $http_input->get('project_description');
33
 
34
    my $feedback = "";
35
 
36
    if ($project_name eq "") {
37
	$feedback .= "No project name was entered.\n";
38
    }
39
    if ($project_description eq "") {
40
	$feedback .= "No project description was entered.\n";
41
    }
42
 
43
    # Try to create the project in the model.
44
    if ($feedback eq "") {
45
	my $rc =
46
	    Codestriker::Model::Project->create($project_name,
47
						$project_description);
48
 
49
	if ($rc == $Codestriker::DUPLICATE_PROJECT_NAME) {
50
	    $feedback .=
51
		"Project with name \"$project_name\" already exists.\n";
52
	}
53
    }
54
 
55
    # If there was a problem, direct control back to the create project
56
    # screen, otherwise go to the project list screen.
57
    if ($feedback ne "") {
58
	$http_input->{feedback} = $feedback;
59
	Codestriker::Action::CreateProject->process($http_input,
60
						    $http_response);
61
    } else {
62
	$http_input->{feedback} = "Project created.\n";
63
	Codestriker::Action::ListProjects->process($http_input,
64
						   $http_response);
65
    }
66
}
67
 
68
1;