line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kwiki::BroadcastMessage; |
2
|
1
|
|
|
1
|
|
1141
|
use Kwiki::Plugin -Base; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use mixin 'Kwiki::Installer'; |
4
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
const class_id => 'broadcast_message'; |
7
|
|
|
|
|
|
|
const cgi_class => 'Kwiki::BroadcastMessage::CGI'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub register { |
10
|
|
|
|
|
|
|
my $register = shift; |
11
|
|
|
|
|
|
|
$register->add( |
12
|
|
|
|
|
|
|
status => 'broadcast_message', |
13
|
|
|
|
|
|
|
template => 'broadcast_message.html' |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
$register->add( action => 'broadcast_message'); |
16
|
|
|
|
|
|
|
$register->add( action => 'broadcast_message_add'); |
17
|
|
|
|
|
|
|
$register->add( |
18
|
|
|
|
|
|
|
toolbar => 'broadcast_message_button', |
19
|
|
|
|
|
|
|
template => 'broadcast_message_button.html' |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub html { |
24
|
|
|
|
|
|
|
my $ret; |
25
|
|
|
|
|
|
|
my $messages = $self->fetch_messages; |
26
|
|
|
|
|
|
|
for(@$messages) { |
27
|
|
|
|
|
|
|
$ret .= qq{ $_ }; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
return $ret; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub broadcast_message { |
33
|
|
|
|
|
|
|
$self->render_screen(screen_title => "Broadcast..."); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub broadcast_message_add { |
37
|
|
|
|
|
|
|
if($self->cgi->broadcast_message_delete) { |
38
|
|
|
|
|
|
|
$self->store_message(''); |
39
|
|
|
|
|
|
|
} else { |
40
|
|
|
|
|
|
|
$self->store_message($self->cgi->message); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
$self->redirect($self->hub->config->main_page); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub message_db { |
46
|
|
|
|
|
|
|
io->catfile($self->plugin_directory,"messages"); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub store_message { |
50
|
|
|
|
|
|
|
$self->message_db->print($_[0]); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub fetch_messages { |
54
|
|
|
|
|
|
|
return [ @{$self->message_db} ]; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
package Kwiki::BroadcastMessage::CGI; |
58
|
|
|
|
|
|
|
use base 'Kwiki::CGI'; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
cgi 'user_name'; |
61
|
|
|
|
|
|
|
cgi 'message' => -utf8; |
62
|
|
|
|
|
|
|
cgi 'broadcast_message_delete'; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
package Kwiki::BroadcastMessage; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__DATA__ |