line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# E2::E2Node |
2
|
|
|
|
|
|
|
# Jose M. Weeks |
3
|
|
|
|
|
|
|
# 03 July 2003 |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# See bottom for pod documentation. |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package E2::E2Node; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
24770
|
use 5.006; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
87
|
|
10
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
76
|
|
|
2
|
|
|
|
|
71
|
|
11
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
17
|
|
|
2
|
|
|
|
|
62
|
|
12
|
2
|
|
|
2
|
|
9
|
use Carp; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
184
|
|
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
624
|
use E2::Node; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
80
|
|
15
|
2
|
|
|
2
|
|
1173
|
use E2::Writeup; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
8696
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our @ISA = "E2::Node"; |
18
|
|
|
|
|
|
|
our $VERSION = "0.33"; |
19
|
|
|
|
|
|
|
our $DEBUG; *DEBUG = *E2::Interface::DEBUG; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Prototypes |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new; |
24
|
|
|
|
|
|
|
sub clear; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub has_mine; |
27
|
|
|
|
|
|
|
sub is_locked; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub list_writeups; |
30
|
|
|
|
|
|
|
sub list_softlinks; |
31
|
|
|
|
|
|
|
sub list_firmlinks; |
32
|
|
|
|
|
|
|
sub list_sametitles; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub get_writeup; |
35
|
|
|
|
|
|
|
sub get_writeup_by_author; |
36
|
|
|
|
|
|
|
sub get_my_writeup; |
37
|
|
|
|
|
|
|
sub get_writeup_number; |
38
|
|
|
|
|
|
|
sub get_writeup_count; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub vote; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub add_writeup; |
43
|
|
|
|
|
|
|
sub create; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Private |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub type_as_string; |
48
|
|
|
|
|
|
|
sub twig_handlers; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Object Methods |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub new { |
53
|
1
|
|
|
1
|
1
|
150
|
my $arg = shift; |
54
|
1
|
|
33
|
|
|
8
|
my $class = ref( $arg ) || $arg; |
55
|
1
|
|
|
|
|
11
|
my $self = $class->SUPER::new(); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# See clear for the other members of $self |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
3
|
$self->clear; |
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
2
|
return $self; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub clear { |
65
|
3
|
50
|
|
3
|
1
|
16
|
my $self = shift or croak "Usage: clear E2E2NODE"; |
66
|
|
|
|
|
|
|
|
67
|
3
|
50
|
|
|
|
8
|
warn "E2::E2Node::clear\n" if $DEBUG > 1; |
68
|
|
|
|
|
|
|
|
69
|
3
|
|
|
|
|
4
|
@{ $self->{writeups} } = (); # Array to hold writeups in currently |
|
3
|
|
|
|
|
8
|
|
70
|
|
|
|
|
|
|
# loaded node. See E2::Writeup. |
71
|
|
|
|
|
|
|
|
72
|
3
|
|
|
|
|
5
|
$self->{locked} = undef; # soft locked |
73
|
|
|
|
|
|
|
|
74
|
3
|
|
|
|
|
5
|
$self->{next} = 0; # Next writeup to return |
75
|
3
|
|
|
|
|
6
|
$self->{mine} = undef; # My writeup in this node. |
76
|
|
|
|
|
|
|
|
77
|
3
|
|
|
|
|
4
|
@{ $self->{firmlinks} } = (); # List of firmlinks |
|
3
|
|
|
|
|
7
|
|
78
|
3
|
|
|
|
|
4
|
@{ $self->{softlinks} } = (); # List of softlinks |
|
3
|
|
|
|
|
4
|
|
79
|
3
|
|
|
|
|
5
|
@{ $self->{sametitles}} = (); # List of sametitles |
|
3
|
|
|
|
|
6
|
|
80
|
|
|
|
|
|
|
# The preceding three return hashrefs |
81
|
|
|
|
|
|
|
# with the following keys: |
82
|
|
|
|
|
|
|
# o title |
83
|
|
|
|
|
|
|
# o id |
84
|
|
|
|
|
|
|
# sametitles has this as well: |
85
|
|
|
|
|
|
|
# o type |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# Now clear parent |
88
|
|
|
|
|
|
|
|
89
|
3
|
|
|
|
|
13
|
return $self->SUPER::clear; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub has_mine { |
93
|
0
|
0
|
|
0
|
1
|
0
|
my $self = shift or croak "Usage: has_mine E2E2NODE"; |
94
|
|
|
|
|
|
|
|
95
|
0
|
0
|
|
|
|
0
|
if(!$self->node_id) { return undef; } # No node loaded |
|
0
|
|
|
|
|
0
|
|
96
|
|
|
|
|
|
|
|
97
|
0
|
0
|
|
|
|
0
|
if( defined( $self->{mine} ) ) { |
98
|
0
|
|
|
|
|
0
|
return 1; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
0
|
return 0; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub is_locked { |
105
|
0
|
0
|
|
0
|
1
|
0
|
my $self = shift or croak "Usage: is_locked E2E2NODE"; |
106
|
|
|
|
|
|
|
|
107
|
0
|
0
|
|
|
|
0
|
if( !$self->node_id ) { return undef; } |
|
0
|
|
|
|
|
0
|
|
108
|
|
|
|
|
|
|
|
109
|
0
|
0
|
|
|
|
0
|
if( $self->{locked} ) { return 1; } |
|
0
|
|
|
|
|
0
|
|
110
|
0
|
|
|
|
|
0
|
else { return 0; } |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub list_softlinks { |
114
|
0
|
0
|
|
0
|
1
|
0
|
my $self = shift or croak "Usage: list_softlinks E2NODE"; |
115
|
|
|
|
|
|
|
|
116
|
0
|
0
|
|
|
|
0
|
return undef if !$self->node_id; |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
0
|
return @{ $self->{softlinks} }; |
|
0
|
|
|
|
|
0
|
|
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub list_firmlinks { |
122
|
0
|
0
|
|
0
|
1
|
0
|
my $self = shift or croak "Usage: list_firmlinks E2NODE"; |
123
|
|
|
|
|
|
|
|
124
|
0
|
0
|
|
|
|
0
|
return undef if !$self->node_id; |
125
|
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
0
|
return @{ $self->{firmlinks} }; |
|
0
|
|
|
|
|
0
|
|
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub list_sametitles { |
130
|
0
|
0
|
|
0
|
1
|
0
|
my $self = shift or croak "Usage: list_sametitles E2NODE"; |
131
|
|
|
|
|
|
|
|
132
|
0
|
0
|
|
|
|
0
|
return undef if !$self->node_id; |
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
0
|
return @{ $self->{sametitles} }; |
|
0
|
|
|
|
|
0
|
|
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub twig_handlers { |
138
|
1
|
50
|
|
1
|
0
|
4
|
my $self = shift or croak "Usage: twig_handlers E2E2NODE"; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
return ( |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
'node/nodelock' => sub { |
143
|
0
|
|
|
0
|
|
0
|
(my $a, my $b) = @_; |
144
|
0
|
|
|
|
|
0
|
$self->{locked} = $b->text; |
145
|
0
|
0
|
|
|
|
0
|
if( $self->{locked} eq "" ) { |
146
|
0
|
|
|
|
|
0
|
$self->{locked} = undef; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
}, |
149
|
|
|
|
|
|
|
'node/writeup' => sub { |
150
|
0
|
|
|
0
|
|
0
|
(my $a, my $b) = @_; |
151
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
0
|
my $wu = new E2::Writeup; |
153
|
0
|
|
|
|
|
0
|
$wu->clone( $self ); |
154
|
0
|
|
|
|
|
0
|
$wu->parse( $b ); |
155
|
|
|
|
|
|
|
|
156
|
0
|
|
|
|
|
0
|
my $name = $self->this_username; |
157
|
0
|
|
|
|
|
0
|
my $uid = $self->this_user_id; |
158
|
|
|
|
|
|
|
|
159
|
0
|
0
|
0
|
|
|
0
|
if( $self->logged_in && |
|
|
0
|
|
|
|
|
|
160
|
|
|
|
|
|
|
($uid ? $uid == $wu->author_id : |
161
|
|
|
|
|
|
|
lc($name) eq lc($wu->author)) ) { |
162
|
0
|
|
|
|
|
0
|
$self->{mine} = @{ $self->{writeups} }; |
|
0
|
|
|
|
|
0
|
|
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
0
|
push @{ $self->{writeups} }, $wu; |
|
0
|
|
|
|
|
0
|
|
166
|
|
|
|
|
|
|
}, |
167
|
|
|
|
|
|
|
'node/softlinks/e2link' => sub { |
168
|
0
|
|
|
0
|
|
0
|
(my $a, my $b) = @_; |
169
|
0
|
|
|
|
|
0
|
push @{ $self->{softlinks} }, { |
|
0
|
|
|
|
|
0
|
|
170
|
|
|
|
|
|
|
title => $b->text, |
171
|
|
|
|
|
|
|
id => $b->{att}->{node_id} |
172
|
|
|
|
|
|
|
}; |
173
|
|
|
|
|
|
|
}, |
174
|
|
|
|
|
|
|
'node/firmlinks/e2link' => sub { |
175
|
0
|
|
|
0
|
|
0
|
(my $a, my $b) = @_; |
176
|
0
|
|
|
|
|
0
|
push @{ $self->{firmlinks} }, { |
|
0
|
|
|
|
|
0
|
|
177
|
|
|
|
|
|
|
title => $b->text, |
178
|
|
|
|
|
|
|
id => $b->{att}->{node_id} |
179
|
|
|
|
|
|
|
}; |
180
|
|
|
|
|
|
|
}, |
181
|
|
|
|
|
|
|
'node/sametitles/nodesuggest' => sub { |
182
|
0
|
|
|
0
|
|
0
|
(my $a, my $b) = @_; |
183
|
0
|
|
|
|
|
0
|
my $c = $b->first_child( 'e2link' ); |
184
|
0
|
|
|
|
|
0
|
push @{ $self->{sametitles} }, { |
|
0
|
|
|
|
|
0
|
|
185
|
|
|
|
|
|
|
title => $c->text, |
186
|
|
|
|
|
|
|
type => $b->{att}->{type}, |
187
|
|
|
|
|
|
|
id => $c->{att}->{node_id} |
188
|
|
|
|
|
|
|
}; |
189
|
|
|
|
|
|
|
} |
190
|
1
|
|
|
|
|
20
|
); |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub type_as_string { |
194
|
1
|
|
|
1
|
0
|
7
|
return 'e2node'; |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub list_writeups { |
198
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or croak "Usage: list_writeups E2E2NODE"; |
199
|
|
|
|
|
|
|
|
200
|
0
|
0
|
|
|
|
|
return undef if !$self->exists; |
201
|
0
|
|
|
|
|
|
return @{ $self->{writeups} }; |
|
0
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
sub get_writeup { |
205
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or croak "Usage: get_writeup E2E2NODE [ , NUM ]"; |
206
|
0
|
|
|
|
|
|
my $num = shift; |
207
|
|
|
|
|
|
|
|
208
|
0
|
0
|
|
|
|
|
if( $num ) { |
209
|
0
|
|
|
|
|
|
$self->{next} = $num; |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
0
|
|
|
|
|
|
return $self->{writeups}[ $self->{next}++ ]; |
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
sub get_writeup_by_author { |
216
|
0
|
0
|
|
0
|
1
|
|
my $self = shift |
217
|
|
|
|
|
|
|
or croak "Usage: get_writeup_by_author E2E2NODE, AUTHOR"; |
218
|
0
|
0
|
|
|
|
|
my $author = shift |
219
|
|
|
|
|
|
|
or croak "Usage: get_writeup_by_author E2E2NODE, AUTHOR"; |
220
|
|
|
|
|
|
|
|
221
|
0
|
0
|
|
|
|
|
if( !$self->node_id ) { return undef; } |
|
0
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
|
223
|
0
|
|
|
|
|
|
for( my $i = 0; $i < @{ $self->{writeups} }; $i++ ) { |
|
0
|
|
|
|
|
|
|
224
|
0
|
0
|
|
|
|
|
if( lc($author) eq |
225
|
|
|
|
|
|
|
lc($self->{writeups}[$i]->author) ) { |
226
|
0
|
|
|
|
|
|
return $self->{writeups}[$i]; |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
0
|
|
|
|
|
|
return 0; |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
sub get_my_writeup { |
234
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or croak "Usage: get_my_writeup E2E2NODE"; |
235
|
0
|
|
|
|
|
|
my $i = $self->{mine}; |
236
|
|
|
|
|
|
|
|
237
|
0
|
0
|
|
|
|
|
if( ! defined $i ) { return undef; } |
|
0
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
|
239
|
0
|
|
|
|
|
|
return $self->{writeups}[$i]; |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
sub get_writeup_number { |
243
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or croak "Usage: get_writeup_number E2E2NODE"; |
244
|
|
|
|
|
|
|
|
245
|
0
|
0
|
|
|
|
|
if( !$self->node_id ) { return undef; } |
|
0
|
|
|
|
|
|
|
246
|
0
|
|
|
|
|
|
return $self->{next}; |
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
sub get_writeup_count { |
250
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or croak "Usage: get_writeup_count E2E2NODE"; |
251
|
|
|
|
|
|
|
|
252
|
0
|
0
|
|
|
|
|
if( !$self->node_id ) { return undef; } |
|
0
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
|
254
|
0
|
|
|
|
|
|
return $$self->{writeups}; |
255
|
|
|
|
|
|
|
} |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
sub create { |
258
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or croak "Usage: create E2E2NODE, TITLE"; |
259
|
0
|
0
|
|
|
|
|
my $title = shift or croak "Usage: create E2E2NODE, TITLE"; |
260
|
|
|
|
|
|
|
|
261
|
0
|
0
|
|
|
|
|
warn "E2::E2Node::create\n" if $DEBUG > 1; |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
# Make sure we have username & user_id |
264
|
|
|
|
|
|
|
|
265
|
0
|
0
|
|
|
|
|
if( !$self->logged_in ) { |
266
|
0
|
0
|
|
|
|
|
warn "Unable to create node: not logged in" if $DEBUG; |
267
|
0
|
|
|
|
|
|
return undef; |
268
|
|
|
|
|
|
|
} |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
return $self->thread_then( |
271
|
|
|
|
|
|
|
[ |
272
|
|
|
|
|
|
|
\&E2::Interface::process_request, |
273
|
|
|
|
|
|
|
$self, |
274
|
|
|
|
|
|
|
node => $title, |
275
|
|
|
|
|
|
|
op => "new", |
276
|
|
|
|
|
|
|
type => "e2node", |
277
|
|
|
|
|
|
|
displaytype => "xmltrue", |
278
|
|
|
|
|
|
|
e2node_createdby_user => $self->{user_id} |
279
|
|
|
|
|
|
|
], |
280
|
|
|
|
|
|
|
sub { |
281
|
|
|
|
|
|
|
|
282
|
0
|
|
|
0
|
|
|
my $r = shift; |
283
|
0
|
0
|
|
|
|
|
if( !$r =~ /
|
284
|
0
|
|
|
|
|
|
croak "Invalid document"; |
285
|
|
|
|
|
|
|
} |
286
|
|
|
|
|
|
|
|
287
|
0
|
|
|
|
|
|
$self->load_from_xml( $r ); |
288
|
|
|
|
|
|
|
|
289
|
0
|
|
|
|
|
|
return $self->exists; |
290
|
0
|
|
|
|
|
|
}); |
291
|
|
|
|
|
|
|
} |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
# FIXME: Allow multiple votes/replies/etc. in one request. |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
sub vote { |
296
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or croak "Usage: vote E2E2NODE, NODE_ID => VOTE [ , NODE_ID2 = VOTE2 [ , ... ] ]"; |
297
|
0
|
0
|
|
|
|
|
my %list = @_ or croak "Usage: vote E2E2NODE, NODE_ID => VOTE [ , NODE_ID2 = VOTE2 [ , ... ] ]"; |
298
|
|
|
|
|
|
|
|
299
|
0
|
0
|
|
|
|
|
warn "E2::E2Node::vote\n" if $DEBUG > 1; |
300
|
|
|
|
|
|
|
|
301
|
0
|
0
|
|
|
|
|
if( !$self->logged_in ) { |
302
|
0
|
0
|
|
|
|
|
warn "Unable to vote: not logged in" if $DEBUG; |
303
|
0
|
|
|
|
|
|
return undef; |
304
|
|
|
|
|
|
|
} |
305
|
|
|
|
|
|
|
|
306
|
0
|
|
|
|
|
|
my %params = ( node_id => $self->{node_id}, |
307
|
|
|
|
|
|
|
op => "vote", |
308
|
|
|
|
|
|
|
displaytype => "xmltrue"); |
309
|
|
|
|
|
|
|
|
310
|
0
|
|
|
|
|
|
foreach( keys %list ) { |
311
|
0
|
|
|
|
|
|
my $v = $list{$_}; |
312
|
|
|
|
|
|
|
|
313
|
0
|
0
|
0
|
|
|
|
if( $v != 1 && $v != -1 ) { next; } |
|
0
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
|
315
|
0
|
|
|
|
|
|
$params{ "vote__$_" } = $v; |
316
|
|
|
|
|
|
|
} |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
return $self->thread_then( |
319
|
|
|
|
|
|
|
[ |
320
|
|
|
|
|
|
|
\&E2::Interface::process_request, |
321
|
|
|
|
|
|
|
$self, |
322
|
|
|
|
|
|
|
%params |
323
|
|
|
|
|
|
|
], |
324
|
|
|
|
|
|
|
sub { |
325
|
0
|
|
|
0
|
|
|
my $r = shift; |
326
|
|
|
|
|
|
|
|
327
|
0
|
0
|
|
|
|
|
if( !($r =~ /
|
328
|
0
|
|
|
|
|
|
croak 'Invalid document'; |
329
|
|
|
|
|
|
|
} |
330
|
|
|
|
|
|
|
|
331
|
0
|
|
|
|
|
|
return $self->load_from_xml( $r ); |
332
|
0
|
|
|
|
|
|
}); |
333
|
|
|
|
|
|
|
} |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
sub add_writeup { |
336
|
0
|
0
|
|
0
|
1
|
|
my $self = shift |
337
|
|
|
|
|
|
|
or croak "Usage: add_writeup E2E2NODE, TEXT, TYPE [ , NODISPLAY ]"; |
338
|
0
|
0
|
|
|
|
|
my $text = shift |
339
|
|
|
|
|
|
|
or croak "Usage: add_writeup E2E2NODE, TEXT, TYPE [ , NODISPLAY ]"; |
340
|
0
|
0
|
|
|
|
|
my $type = shift |
341
|
|
|
|
|
|
|
or croak "Usage: add_writeup E2E2NODE, TEXT, TYPE [ , NODISPLAY ]"; |
342
|
0
|
|
|
|
|
|
my $nodisplay = shift; |
343
|
|
|
|
|
|
|
|
344
|
0
|
0
|
|
|
|
|
warn "E2::E2Node::add_writeup\n" if $DEBUG > 1; |
345
|
|
|
|
|
|
|
|
346
|
0
|
0
|
|
|
|
|
if( !$self->logged_in ) { |
347
|
0
|
0
|
|
|
|
|
warn "Unable to add writeup: not logged in" if $DEBUG; |
348
|
0
|
|
|
|
|
|
return undef; |
349
|
|
|
|
|
|
|
} |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
return $self->thread_then( |
352
|
|
|
|
|
|
|
[ |
353
|
|
|
|
|
|
|
\&E2::Interface::process_request, |
354
|
|
|
|
|
|
|
$self, |
355
|
|
|
|
|
|
|
node => "new writeup", |
356
|
|
|
|
|
|
|
op => "new", |
357
|
|
|
|
|
|
|
type => "writeup", |
358
|
|
|
|
|
|
|
node => $self->{node_id}, # Why two "node" params? |
359
|
|
|
|
|
|
|
writeup_notnew => $nodisplay, # dunno.... |
360
|
|
|
|
|
|
|
writeup_doctext => $text, |
361
|
|
|
|
|
|
|
writeup_parent_e2node => $self->{node_id}, |
362
|
|
|
|
|
|
|
writeuptype => $type |
363
|
|
|
|
|
|
|
], |
364
|
|
|
|
|
|
|
sub { |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
# FIXME - Add code to test for success. |
367
|
|
|
|
|
|
|
|
368
|
0
|
|
|
0
|
|
|
return 1; |
369
|
0
|
|
|
|
|
|
}); |
370
|
|
|
|
|
|
|
} |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
1; |
373
|
|
|
|
|
|
|
__END__ |