OSDN Git Service

(no commit message)
[fswiki/sandbox.git] / kgsoft / plugin / bugtrack.pm
1 ##########################################################################################
2 #
3 # ¥¹¥Ñ¥à¥Õ¥£¥ë¥¿¡¼¥×¥é¥°¥¤¥ó¡Ê³Ø½¬µ¡Ç½Ìµ¤·ÈÇ¡Ë
4 #¡Êbugtrack¥×¥é¥°¥¤¥ó¤Î¥ª¡¼¥Ð¡¼¥é¥¤¥É¡Ë
5 #
6 ##########################################################################################
7 use strict;
8
9 use plugin::bugtrack::BugTrackHandler;
10
11 # plugin::bugtrack::BugTrackHandler¤Îdo_action¥á¥½¥Ã¥É¤ÎÃÖ¤­´¹¤¨
12 package plugin::bugtrack::BugTrackHandler;
13
14 sub do_action {
15         my $self = shift;
16         my $wiki = shift;
17         my $cgi = $wiki->get_CGI;
18         
19         my $project  = $cgi->param("project");
20         my $name     = $cgi->param("name");
21         my $category = $cgi->param("category");
22         my $priority = $cgi->param("priority");
23         my $status   = $cgi->param("status");
24         my $content  = $cgi->param("content");
25         my $subject  = $cgi->param("subject");
26         my $time     = time();
27         
28         if($name eq ""){
29                 return $wiki->error("̾Á°¤¬ÆþÎϤµ¤ì¤Æ¤¤¤Þ¤»¤ó¡£");
30         } elsif($subject eq ""){
31                 return $wiki->error("¥µ¥Þ¥ê¤¬ÆþÎϤµ¤ì¤Æ¤¤¤Þ¤»¤ó¡£");
32         } elsif($content eq ""){
33                 return $wiki->error("¥Ð¥°ÆâÍƤ¬ÆþÎϤµ¤ì¤Æ¤¤¤Þ¤»¤ó¡£");
34         }
35         
36         # post_name¤È¤¤¤¦¥­¡¼¤Ç¥¯¥Ã¥­¡¼¤ò¥»¥Ã¥È¤¹¤ë
37         my $path   = &Util::cookie_path($wiki);
38         my $cookie = $cgi->cookie(-name=>'post_name',-value=>$name,-expires=>'+1M',-path=>$path);
39         print "Set-Cookie: ",$cookie->as_string,"\n";
40         
41 #--------------------------------------------------------------------------------------------------
42   if($content){
43     unless(&plugin::_ex_spam_filter_light::Install::judgment_text($content)){
44       my $time = Util::format_date(time());
45       my $file = $wiki->config('log_dir')."/spam_bugtrack.txt";
46       if(open(SPAM_LOG, ">>$file")){
47         print SPAM_LOG "-" x 70 . "\n";
48         print SPAM_LOG "$project:$name:$category:$priority:$status:$time\n";
49         print SPAM_LOG "-" x 70 . "\n";
50         print SPAM_LOG "$content\n";
51         close(SPAM_LOG);
52       }
53       my $error_message = $wiki->error("Åê¹Æ¤µ¤ì¤¿Ê¸¾Ï¤Ï¥¹¥Ñ¥à¥á¥Ã¥»¡¼¥¸¤ÈȽÄꤵ¤ì¤Þ¤·¤¿¡£\n");
54       $subject = Util::escapeHTML($subject);
55       $content = Util::escapeHTML($content);
56       $content =~ s/\n/<br>/g;
57       $error_message .= "<p>\n";
58       $error_message .= "<div>Åê¹Æ¤µ¤ì¤¿Ê¸¾Ï¡§</div>\n";
59       $error_message .= "<div>¡ãÅê¹Æ¼Ô¡ä$name</div>\n";
60       $error_message .= "<div>¡ã¥«¥Æ¥´¥ê¡ä$category</div>\n";
61       $error_message .= "<div>¡ãÍ¥ÀèÅÙ¡ä$priority</div>\n";
62       $error_message .= "<div>¡ã¾õÂÖ¡ä$status</div>\n";
63       $error_message .= "<div>¡ãÆü»þ¡ä$time</div>\n";
64       $error_message .= "<div>¡ãËÜʸ¡ä</div>\n";
65       $error_message .= "<div>$content</div>\n";
66       $error_message .= "</p>\n";
67       return $error_message;
68     }
69   }
70 #--------------------------------------------------------------------------------------------------
71
72         # ¥Õ¥©¡¼¥Þ¥Ã¥È¥×¥é¥°¥¤¥ó¤Ø¤ÎÂбþ
73         my $format = $wiki->get_edit_format();
74         $name     = $wiki->convert_to_fswiki($name    ,$format,1);
75         $category = $wiki->convert_to_fswiki($category,$format,1);
76         $priority = $wiki->convert_to_fswiki($priority,$format,1);
77         $status   = $wiki->convert_to_fswiki($status  ,$format,1);
78         $content  = $wiki->convert_to_fswiki($content ,$format);
79         
80         my $page = $self->make_pagename($wiki,$project);
81         
82         $content = "!!!$subject\n".
83                    "*Åê¹Æ¼Ô¡§ $name\n".
84                    "*¥«¥Æ¥´¥ê¡§ $category\n".
85                    "*Í¥ÀèÅÙ¡§ $priority\n".
86                    "*¾õÂÖ¡§ $status\n".
87                    "*Æü»þ¡§ ".Util::format_date($time)."\n".
88                    "{{bugstate}}\n".
89                    "!!ÆâÍÆ\n".$content."\n".
90                    "!!¥³¥á¥ó¥È\n{{comment}}";
91         
92         $wiki->save_page($page,$content);
93         $wiki->redirect($page);
94 }
95
96 1;