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 displaying a list of projects.
9
 
10
package Codestriker::Action::ListProjects;
11
 
12
use strict;
13
use Codestriker;
14
use Codestriker::Http::Template;
15
use Codestriker::Model::Project;
16
 
17
# List the projects in the system.
18
sub process($$$) {
19
    my ($type, $http_input, $http_response) = @_;
20
 
21
    # Check if this operation is allowed.
22
    if (Codestriker->projects_disabled()) {
23
	$http_response->error("This function has been disabled");
24
    }
25
 
26
    my $query = $http_response->get_query();
27
    my $feedback = $http_input->get('feedback');
28
 
29
    # Retrieve the project details.
30
    my @projects = Codestriker::Model::Project->list();
31
 
32
    # Display the data, with each prject title linked to edit project page.
33
    $http_response->generate_header(topic_title=>"Project List",
34
				    reload=>0, cache=>0);
35
 
36
    # Create the hash for the template variables.
37
    my $vars = {};
38
    $vars->{'feedback'} = $feedback;
39
 
40
    # Obtain a new URL builder object.
41
    my $url_builder = Codestriker::Http::UrlBuilder->new($query);
42
 
43
    # Go through all of the projects, and construct an edit_project URL.
44
    foreach my $project (@projects) {
45
	$project->{edit_url} = $url_builder->edit_project_url($project->{id});
46
	$project->{num_open_topics} =
47
	    Codestriker::Model::Project->num_open_topics($project->{id});
48
	$project->{open_topic_list_url} =
49
	    $url_builder->list_topics_url('', '', '', '', '', '', '', '', '',
50
					  '', [0], [$project->{id}], '');
51
	$project->{num_topics} =
52
	    Codestriker::Model::Project->num_topics($project->{id});
53
	$project->{topic_list_url} =
54
	    $url_builder->list_topics_url('', '', '', '', '', '', '', '', '',
55
					  '', undef, [$project->{id}], '');
56
    }
57
    $vars->{'projects'} = \@projects;
58
 
59
    $vars->{'create_project_url'} = $url_builder->create_project_url();
60
 
61
    # Send the data to the template for rendering.
62
    my $template = Codestriker::Http::Template->new("listprojects");
63
    $template->process($vars);
64
 
65
    $http_response->generate_footer();
66
}
67
 
68
1;