line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MojoMojo::Controller::Comment; |
2
|
|
|
|
|
|
|
|
3
|
35
|
|
|
35
|
|
16417
|
use strict; |
|
35
|
|
|
|
|
89
|
|
|
35
|
|
|
|
|
1081
|
|
4
|
|
|
|
|
|
|
|
5
|
35
|
|
|
35
|
|
187
|
use parent 'Catalyst::Controller::HTML::FormFu'; |
|
35
|
|
|
|
|
148
|
|
|
35
|
|
|
|
|
247
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
MojoMojo::Controller::Comment - MojoMojo Comment controller |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
See L<MojoMojo> |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Controller for Page comments. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 METHODS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head2 comment |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
display comments for embedding in a page |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub comment : Global FormConfig { |
26
|
2
|
|
|
2
|
|
1051137
|
my ( $self, $c ) = @_; |
27
|
2
|
|
|
|
|
12
|
my $form=$c->stash->{form}; |
28
|
2
|
|
|
|
|
116
|
$c->stash->{template} = 'comment.tt'; |
29
|
|
|
|
|
|
|
|
30
|
2
|
50
|
33
|
|
|
114
|
if ( $c->stash->{user} && $form->submitted_and_valid) { |
31
|
|
|
|
|
|
|
$c->model("DBIC::Comment")->create( |
32
|
|
|
|
|
|
|
{ |
33
|
|
|
|
|
|
|
page => $c->stash->{page}->id, |
34
|
|
|
|
|
|
|
poster => $c->stash->{user}->id, |
35
|
0
|
|
|
|
|
0
|
posted => DateTime->now(), |
36
|
|
|
|
|
|
|
body => scalar $c->req->param('body'), |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
$c->stash->{comments} = |
41
|
|
|
|
|
|
|
$c->model("DBIC::Comment") |
42
|
2
|
|
|
|
|
123
|
->search( { page => $c->stash->{page}->id }, { order_by => 'posted' } ); |
43
|
35
|
|
|
35
|
|
7087
|
} |
|
35
|
|
|
|
|
83
|
|
|
35
|
|
|
|
|
202
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 login ( .comment/login ) |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Inline login for comments. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub login : Local { |
52
|
1
|
|
|
1
|
1
|
1142
|
my ( $self, $c ) = @_; |
53
|
1
|
|
|
|
|
6
|
$c->stash->{template} = 'comment/post.tt'; |
54
|
1
|
|
|
|
|
57
|
$c->forward('/user/login'); |
55
|
1
|
50
|
|
|
|
680
|
if ( $c->stash->{fail} ) { |
56
|
0
|
|
|
|
|
0
|
$c->stash->{template} = 'comment/login.tt'; |
57
|
|
|
|
|
|
|
} |
58
|
35
|
|
|
35
|
|
425449
|
} |
|
35
|
|
|
|
|
99
|
|
|
35
|
|
|
|
|
175
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 remove ( .comment/remove ) |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Remove comments, provided user can edit the page the comment is on. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub remove : Local { |
67
|
0
|
|
|
0
|
1
|
|
my ( $self, $c, $comment ) = @_; |
68
|
0
|
0
|
|
|
|
|
if ( $comment = $c->model("DBIC::Comment")->find($comment) ) { |
69
|
0
|
0
|
0
|
|
|
|
if ( $comment->page->id == $c->stash->{page}->id |
70
|
|
|
|
|
|
|
&& $c->stash->{user}->can_edit( $comment->page->path ) ) |
71
|
|
|
|
|
|
|
{ |
72
|
0
|
|
|
|
|
|
$comment->delete(); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
0
|
|
|
|
|
|
$c->forward('/page/view'); |
76
|
|
|
|
|
|
|
|
77
|
35
|
|
|
35
|
|
35045
|
} |
|
35
|
|
|
|
|
81
|
|
|
35
|
|
|
|
|
158
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 AUTHOR |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Marcus Ramberg <mramberg@cpan.org> |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 LICENSE |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This library is free software. You can redistribute it and/or modify |
86
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |