| |
|
Line 11
|
Parallel
|
Line 11
|
Parallel
|
| 11 |
|
11 |
|
| 12 |
use strict; |
12 |
use strict; |
| 13 |
|
13 |
|
|
|
14 |
use HTML::Entities (); |
| 14 |
use Codestriker::Model::Comment; |
15 |
use Codestriker::Model::Comment; |
| 15 |
use Codestriker::Model::File; |
16 |
use Codestriker::Model::File; |
| 16 |
use Codestriker::Model::Topic; |
17 |
use Codestriker::Model::Topic; |
| |
| |
|
Line 72
|
Parallel
|
Line 73
|
Parallel
|
| 72 |
# Tell the listener classes that a comment has just been created. |
73 |
# Tell the listener classes that a comment has just been created. |
| 73 |
my $listener_response = |
74 |
my $listener_response = |
| 74 |
Codestriker::TopicListeners::Manager::comment_create($topic, $comment); |
75 |
Codestriker::TopicListeners::Manager::comment_create($topic, $comment); |
| 75 |
if ( $listener_response ne '') { |
|
|
| 76 |
$http_response->error($listener_response); |
|
|
| 77 |
} |
|
|
| 78 |
|
76 |
|
| 79 |
if (defined $format && $format eq "xml") { |
77 |
if (defined $format && $format eq "xml") { |
|
|
78 |
my $response = $listener_response ne '' ? $listener_response : 'OK'; |
|
|
79 |
|
| 80 |
print $query->header(-content_type=>'text/xml'); |
80 |
print $query->header(-content_type=>'text/xml'); |
| 81 |
print "<?xml version=\"1.0\" encoding=\"UTF-8\" " . |
81 |
print "<?xml version=\"1.0\" encoding=\"UTF-8\" " . |
| 82 |
"standalone=\"yes\"?>\n"; |
82 |
"standalone=\"yes\"?>\n"; |
| 83 |
print "<response><method>submitnewcomment</method>" . |
83 |
print "<response><method>submitnewcomment</method>" . |
| 84 |
"<result>OK</result></response>\n"; |
84 |
"<result>" . HTML::Entities::encode($response) . |
|
|
85 |
"</result></response>\n"; |
|
} else { |
86 |
} else { |
|
|
87 |
$http_response->error($listener_response) if $listener_response ne ''; |
| 86 |
# Display a simple screen indicating that the comment has been |
88 |
# Display a simple screen indicating that the comment has been |
| 87 |
# registered. Clicking the Close button simply dismisses the |
89 |
# registered. Clicking the Close button simply dismisses the |
| 88 |
# edit popup. Leaving it # up will ensure the next editing |
90 |
# edit popup. Leaving it # up will ensure the next editing |
| |
| |
|
Line 73
|
Parallel
|
Line 73
|
Parallel
|
| 73 |
"The topic was created with the following files:\n\n" . |
73 |
"The topic was created with the following files:\n\n" . |
| 74 |
join("\n",@filenames); |
74 |
join("\n",@filenames); |
| 75 |
|
75 |
|
| 76 |
$self->_send_topic_email($topic, 1, "Created", 1, $from, $to, $cc, $bcc, |
76 |
return $self->_send_topic_email($topic, 1, "Created", 1, $from, $to, $cc, |
| 77 |
$notes); |
77 |
$bcc, $notes); |
| 78 |
|
|
|
| 79 |
return ''; |
|
|
| 80 |
} |
78 |
} |
| 81 |
|
79 |
|
| 82 |
sub topic_changed($$$$) { |
80 |
sub topic_changed($$$$) { |
| |
| |
|
Line 157
|
Parallel
|
Line 155
|
Parallel
|
| 157 |
my @to_list = keys( %handled_addresses ); |
155 |
my @to_list = keys( %handled_addresses ); |
| 158 |
|
156 |
|
| 159 |
if ( @to_list ) { |
157 |
if ( @to_list ) { |
|
$self->send_topic_changed_email($user_that_made_the_change, |
158 |
return $self->send_topic_changed_email($user_that_made_the_change, |
| 161 |
$topic_orig, $topic,@to_list); |
159 |
$topic_orig, $topic,@to_list); |
| 162 |
} |
160 |
} |
| 163 |
|
161 |
|
| 164 |
return ''; |
162 |
return ''; |
| 165 |
} |
163 |
} |
| |
| |
|
Line 396
|
Parallel
|
Line 394
|
Parallel
|
| 396 |
if ( $Codestriker::email_send_options->{comments_sent_to_topic_author} || |
394 |
if ( $Codestriker::email_send_options->{comments_sent_to_topic_author} || |
| 397 |
$comment->{cc} ne "") |
395 |
$comment->{cc} ne "") |
| 398 |
{ |
396 |
{ |
| 399 |
if (!$self->doit(0, $comment->{topicid}, $from, $to, |
397 |
return $self->doit(0, $comment->{topicid}, $from, $to, |
| 400 |
join(', ',@cc_recipients), $bcc, |
398 |
join(', ',@cc_recipients), $bcc, |
| 401 |
$subject, $body)) { |
399 |
$subject, $body); |
| 402 |
return "Failed to send topic creation email"; |
|
|
| 403 |
} |
|
|
| 404 |
} |
400 |
} |
| 405 |
|
401 |
|
| 406 |
return ''; |
402 |
return ''; |
| |
| |
|
Line 432
|
Parallel
|
Line 428
|
Parallel
|
| 432 |
$self->doit($new, $topic->{topicid}, $from, $to, $cc, $bcc, $subject, $body); |
428 |
$self->doit($new, $topic->{topicid}, $from, $to, $cc, $bcc, $subject, $body); |
| 433 |
} |
429 |
} |
| 434 |
|
430 |
|
| 435 |
# Send an email with the specified data. Return false if the mail can't be |
431 |
# Send an email with the specified data. Return a non-empty message if the |
| 436 |
# successfully delivered, true otherwise. |
432 |
# mail can't be successfully delivered, empty string otherwise. |
| 437 |
sub doit($$$$$$$$$) { |
433 |
sub doit($$$$$$$$$) { |
| 438 |
my ($type, $new, $topicid, $from, $to, $cc, $bcc, $subject, $body) = @_; |
434 |
my ($type, $new, $topicid, $from, $to, $cc, $bcc, $subject, $body) = @_; |
| 439 |
|
435 |
|
| 440 |
return 1 if ($DEVNULL_EMAIL); |
436 |
return '' if ($DEVNULL_EMAIL); |
| 441 |
|
437 |
|
| 442 |
my $smtp = Net::SMTP->new($Codestriker::mailhost); |
438 |
my $smtp = Net::SMTP->new($Codestriker::mailhost); |
| 443 |
defined $smtp || die "Unable to connect to mail server: $!"; |
439 |
defined $smtp || return "Unable to connect to mail server: $!"; |
| 444 |
|
440 |
|
| 445 |
$smtp->mail($from); |
441 |
$smtp->mail($from); |
| 446 |
$smtp->ok() || die "Couldn't set sender to \"$from\" $!, " . |
442 |
$smtp->ok() || return "Couldn't set sender to \"$from\" $!, " . |
| 447 |
$smtp->message(); |
443 |
$smtp->message(); |
| 448 |
|
444 |
|
| 449 |
# $to has to be defined. |
445 |
# $to has to be defined. |
| |
| |
|
Line 454
|
Parallel
|
Line 450
|
Parallel
|
| 454 |
for (my $i = 0; $i <= $#receiver; $i++) { |
450 |
for (my $i = 0; $i <= $#receiver; $i++) { |
| 455 |
if ($receiver[$i] ne "") { |
451 |
if ($receiver[$i] ne "") { |
| 456 |
$smtp->recipient($receiver[$i]); |
452 |
$smtp->recipient($receiver[$i]); |
| 457 |
$smtp->ok() || die "Couldn't send email to \"$receiver[$i]\" $!, " . |
453 |
$smtp->ok() || return "Couldn't send email to \"$receiver[$i]\" $!, " . |
| 458 |
$smtp->message(); |
454 |
$smtp->message(); |
| 459 |
} else { |
455 |
} else { |
| 460 |
# Can't track down why, but sometimes an empty email address |
456 |
# Can't track down why, but sometimes an empty email address |
| |
| |
|
Line 486
|
Parallel
|
Line 482
|
Parallel
|
| 486 |
$smtp->datasend("\n"); |
482 |
$smtp->datasend("\n"); |
| 487 |
$smtp->datasend($body); |
483 |
$smtp->datasend($body); |
| 488 |
$smtp->dataend(); |
484 |
$smtp->dataend(); |
| 489 |
$smtp->ok() || die "Couldn't send email $!, " . smtp->message(); |
485 |
$smtp->ok() || return "Couldn't send email $!, " . smtp->message(); |
| 490 |
|
486 |
|
| 491 |
$smtp->quit(); |
487 |
$smtp->quit(); |
| 492 |
$smtp->ok() || die "Couldn't send email $!, " . smtp->message(); |
488 |
$smtp->ok() || return "Couldn't send email $!, " . smtp->message(); |
| 493 |
|
489 |
|
| 494 |
return 1; |
490 |
return ''; |
| 495 |
} |
491 |
} |
| 496 |
|
492 |
|
| 497 |
1; |
493 |
1; |
| |