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 changing the properties of a
9
# topic.
10
 
11
package Codestriker::Action::SubmitEditTopicMetrics;
12
 
13
use strict;
14
 
15
use Codestriker::Model::Topic;
16
 
17
# Attempt to change the topic's state, or to delete it.
18
sub process($$$) {
19
    my ($type, $http_input, $http_response) = @_;
20
 
21
    my $query = $http_response->get_query();
22
 
23
    # Check that the appropriate fields have been filled in.
24
    my $topicid = $http_input->get('topic');
25
    my $mode = $http_input->get('mode');
26
    my $version = $http_input->get('version');
27
    my $email = $http_input->get('email');
28
 
29
    my $topic = Codestriker::Model::Topic->new($topicid);    
30
    my $metrics = $topic->get_metrics();
31
    my $feedback = "";
32
    my @topic_metric = @{$http_input->get('topic_metric')};
33
 
34
    $feedback .= $metrics->verify_topic_metrics(@topic_metric);
35
 
36
    $metrics->set_topic_metrics(@topic_metric);
37
 
38
    $metrics->set_user_metric($topic->{author},
39
			      @{$http_input->{author_metric}});
40
 
41
    my @reviewer_list = $topic->get_metrics()->get_list_of_topic_participants();
42
 
43
    # Remove the author from the list just in case somebody put themselves
44
    # in twice.
45
    @reviewer_list = grep { $_ ne $topic->{author} } @reviewer_list;
46
 
47
    for (my $userindex = 0; $userindex < scalar(@reviewer_list); ++$userindex) {
48
 
49
	if (defined($http_input->get("reviewer_metric,$userindex"))) {
50
	    my @usermetrics = @{$http_input->get("reviewer_metric,$userindex")};
51
 
52
	$feedback .= $metrics->verify_user_metrics($reviewer_list[$userindex],
53
						   @usermetrics);
54
	$metrics->set_user_metric($reviewer_list[$userindex], @usermetrics);
55
	}
56
    }
57
 
58
    my @author_metrics = @{$http_input->get('author_metric')};
59
    $feedback .= $metrics->verify_user_metrics($topic->{author},
60
					       @author_metrics);
61
    $metrics->set_user_metric($topic->{author}, @author_metrics);
62
    $metrics->store();
63
 
64
    if ( $feedback eq "")
65
    {
66
        $feedback = "Topic metrics successfully updated.";
67
    }
68
 
69
    # The feedback var is not html escaped in the template, so it must be done directly
70
    # with HTML::Entities::encode if needed.    
71
    $http_input->{feedback} = $feedback;
72
 
73
    # Go to the view topic metrics screen.
74
    Codestriker::Action::ViewTopicInfo->process($http_input, $http_response);
75
}
76
 
77
1;