| 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 viewing of a topic's properties.
|
|
|
9 |
|
|
|
10 |
package Codestriker::Action::ViewTopicProperties;
|
|
|
11 |
|
|
|
12 |
use strict;
|
|
|
13 |
|
|
|
14 |
use Codestriker::Model::Topic;
|
|
|
15 |
use Codestriker::Model::Comment;
|
|
|
16 |
use Codestriker::Http::UrlBuilder;
|
|
|
17 |
use Codestriker::Http::Render;
|
|
|
18 |
use Codestriker::Repository::RepositoryFactory;
|
|
|
19 |
use HTML::Entities ();
|
|
|
20 |
|
|
|
21 |
# If the input is valid, display the topic.
|
|
|
22 |
sub process($$$) {
|
|
|
23 |
my ($type, $http_input, $http_response) = @_;
|
|
|
24 |
|
|
|
25 |
my $query = $http_response->get_query();
|
|
|
26 |
my $topicid = $http_input->get('topic');
|
|
|
27 |
my $mode = $http_input->get('mode');
|
|
|
28 |
my $tabwidth = $http_input->get('tabwidth');
|
|
|
29 |
my $email = $http_input->get('email');
|
|
|
30 |
my $feedback = $http_input->get('feedback');
|
|
|
31 |
|
|
|
32 |
if (Codestriker::Model::Topic::exists($topicid) == 0) {
|
|
|
33 |
# Topic no longer exists, most likely its been deleted.
|
|
|
34 |
$http_response->error("Topic no longer exists.");
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
# Retrieve the appropriate topic details.
|
|
|
38 |
my $topic = Codestriker::Model::Topic->new($topicid);
|
|
|
39 |
|
|
|
40 |
# Retrieve the comment details for this topic.
|
|
|
41 |
my @topic_comments = $topic->read_comments();
|
|
|
42 |
|
|
|
43 |
$http_response->generate_header(topic=>$topic,
|
|
|
44 |
topic_title=>"Topic Properties: $topic->{title}",
|
|
|
45 |
mode=>$mode, tabwidth=>$tabwidth,
|
|
|
46 |
reload=>0, cache=>1);
|
|
|
47 |
|
|
|
48 |
# Retrieve the repository object, if repository functionality is enabled.
|
|
|
49 |
my $repository;
|
|
|
50 |
if (scalar(@Codestriker::valid_repositories)) {
|
|
|
51 |
$repository =
|
|
|
52 |
Codestriker::Repository::RepositoryFactory->get($topic->{repository});
|
|
|
53 |
} else {
|
|
|
54 |
# Indicate not to activate any repository-related links.
|
|
|
55 |
$topic->{repository} = "";
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
# Create the hash for the template variables.
|
|
|
59 |
my $vars = {};
|
|
|
60 |
$vars->{'feedback'} = $feedback;
|
|
|
61 |
|
|
|
62 |
# Obtain a new URL builder object.
|
|
|
63 |
my $url_builder = Codestriker::Http::UrlBuilder->new($query);
|
|
|
64 |
|
|
|
65 |
Codestriker::Action::ViewTopic::ProcessTopicHeader($vars, $topic,
|
|
|
66 |
$url_builder);
|
|
|
67 |
|
|
|
68 |
my @projectids = ($topic->{project_id});
|
|
|
69 |
|
|
|
70 |
$vars->{'view_topic_url'} =
|
|
|
71 |
$url_builder->view_url($topicid, -1, $mode);
|
|
|
72 |
|
|
|
73 |
$vars->{'view_topicinfo_url'} = $url_builder->view_topicinfo_url($topicid);
|
|
|
74 |
$vars->{'view_comments_url'} = $url_builder->view_comments_url($topicid);
|
|
|
75 |
$vars->{'list_projects_url'} = $url_builder->list_projects_url();
|
|
|
76 |
|
|
|
77 |
# Display the "update" message if the topic state has been changed.
|
|
|
78 |
$vars->{'updated'} = $http_input->get('updated');
|
|
|
79 |
$vars->{'rc_ok'} = $Codestriker::OK;
|
|
|
80 |
$vars->{'rc_stale_version'} = $Codestriker::STALE_VERSION;
|
|
|
81 |
$vars->{'rc_invalid_topic'} = $Codestriker::INVALID_TOPIC;
|
|
|
82 |
|
|
|
83 |
# Store the bug id information, and any linking URLs.
|
|
|
84 |
$vars->{'bug_db'} = $Codestriker::bug_db;
|
|
|
85 |
$vars->{'bug_ids'} = $topic->{bug_ids};
|
|
|
86 |
if (defined $topic->{bug_ids} && $topic->{bug_ids} ne "" &&
|
|
|
87 |
defined $Codestriker::bugtracker) {
|
|
|
88 |
my @bug_id_array = split /[\s,]+/, $topic->{bug_ids};
|
|
|
89 |
$vars->{'bug_id_array'} = \@bug_id_array;
|
|
|
90 |
$vars->{'bugtracker'} = $Codestriker::bugtracker;
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
$vars->{'document_reviewers'} =
|
|
|
94 |
Codestriker->filter_email($topic->{reviewers});
|
|
|
95 |
|
|
|
96 |
# Indicate what repositories are available, and what the topic's
|
|
|
97 |
# repository is.
|
|
|
98 |
$vars->{'topic_repository'} = $Codestriker::repository_name_map->{$topic->{repository}};
|
|
|
99 |
$vars->{'repositories'} = \@Codestriker::valid_repository_names;
|
|
|
100 |
|
|
|
101 |
# Indicate what projects are available, and what the topic's project is.
|
|
|
102 |
my @projects = Codestriker::Model::Project->list();
|
|
|
103 |
$vars->{'projects'} = \@projects;
|
|
|
104 |
$vars->{'project_states'} = \@Codestriker::project_states;
|
|
|
105 |
$vars->{'projects_enabled'} = Codestriker->projects_disabled() ? 0 : 1;
|
|
|
106 |
$vars->{'topic_projectid'} = $topic->{project_id};
|
|
|
107 |
|
|
|
108 |
$vars->{'number_of_lines'} = $topic->get_topic_size_in_lines();
|
|
|
109 |
|
|
|
110 |
$vars->{'suggested_topic_size_lines'} =
|
|
|
111 |
$Codestriker::suggested_topic_size_lines eq "" ? 0 :
|
|
|
112 |
$Codestriker::suggested_topic_size_lines;
|
|
|
113 |
|
|
|
114 |
# Prepare the data for displaying the state update option.
|
|
|
115 |
# Make sure the old mode setting is no longer used.
|
|
|
116 |
if ((! defined $mode) || $mode == $Codestriker::NORMAL_MODE) {
|
|
|
117 |
$mode = $Codestriker::COLOURED_MODE;
|
|
|
118 |
}
|
|
|
119 |
$vars->{'mode'} = $mode;
|
|
|
120 |
$vars->{'topicid'} = $topic->{topicid};
|
|
|
121 |
$vars->{'topic_version'} = $topic->{version};
|
|
|
122 |
$vars->{'states'} = \@Codestriker::topic_states;
|
|
|
123 |
$vars->{'default_state'} = $topic->{topic_state};
|
|
|
124 |
$vars->{'description'} = $topic->{description};
|
|
|
125 |
$vars->{'start_tag'} = $topic->{start_tag};
|
|
|
126 |
$vars->{'end_tag'} = $topic->{end_tag};
|
|
|
127 |
$vars->{'module'} = $topic->{module};
|
|
|
128 |
|
|
|
129 |
my $template = Codestriker::Http::Template->new("viewtopicproperties");
|
|
|
130 |
$template->process($vars);
|
|
|
131 |
|
|
|
132 |
$http_response->generate_footer();
|
|
|
133 |
|
|
|
134 |
# Fire the topic listener to indicate that the user has viewed the topic.
|
|
|
135 |
Codestriker::TopicListeners::Manager::topic_viewed($email, $topic);
|
|
|
136 |
}
|
|
|
137 |
|
|
|
138 |
1;
|