File Coverage

blib/lib/FTN/Database/Forum.pm
Criterion Covered Total %
statement 38 38 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 4 4 100.0
total 49 49 100.0


line stmt bran cond sub pod time code
1             package FTN::Database::Forum;
2              
3 2     2   4381 use warnings;
  2         2  
  2         53  
4 2     2   6 use strict;
  2         2  
  2         33  
5 2     2   4 use Carp qw( croak );
  2         2  
  2         392  
6              
7             =head1 NAME
8              
9             FTN::Database::Forum - Fidonet/FTN Message Forum SQL Database operations.
10              
11             =head1 VERSION
12              
13             Version 0.40
14              
15             =cut
16              
17             our $VERSION = '0.40';
18              
19             =head1 DESCRIPTION
20              
21             FTN::Database::Forum is a Perl module containing common forum (message conference)
22             related functions for Fidonet/FTN Forum related processing on a Forum table in an
23             SQL Database, including one that defines the fields for such a Forum table. The SQL
24             database engine is one for which a DBD module exists, defaulting to SQLite.
25              
26             =head1 EXPORT
27              
28             The following functions are available in this module: define_forum_table(),
29             define_areasbbs_table(), ftnmsg_index_fields(), and ftnareas_index_fields().
30              
31             =head1 FUNCTIONS
32              
33             =head2 define_forum_table
34              
35             Syntax: $fields = define_forum_table();
36              
37             This function returns a string that contains the SQL which defines a
38             message conference/forum table for use in an SQL database being used
39             for Fidonet/FTN processing,
40              
41             Except for the I field, which is defined in the create_ftn_table
42             subroutine itself, the defined fields are as follows:
43              
44             =cut
45              
46             sub define_forum_table {
47              
48 1     1 1 1814 my $table_fields = '';
49              
50             =over 4
51              
52             =item ftscdate
53              
54             The I field is used to contain a string indicating the date of the
55             FTN message. It can contain up to 20 characters and defaults to an empty string.
56              
57             =cut
58              
59 1         2 $table_fields = "ftscdate VARCHAR(20) DEFAULT '' NOT NULL, ";
60              
61             =item datetime
62              
63             The I field is used to contain date and time that the FTN message was
64             added to the forum table.
65              
66             =cut
67              
68 1         2 $table_fields .= "datetime TIMESTAMP(14) DEFAULT '' NOT NULL, ";
69              
70             =item fromnode
71              
72             The I field is used to contain the FTN node number that the message is
73             from. It can contain up to 72 characters and defaults to an empty string.
74              
75             =cut
76              
77 1         1 $table_fields .= "fromnode CHAR(72) DEFAULT '' NOT NULL, ";
78              
79             =item tonode
80              
81             The I field is used to contain the FTN node number that the message is
82             to. It can contain up to 72 characters and defaults to an empty string.
83              
84             =cut
85              
86 1         1 $table_fields .= "tonode CHAR(72) DEFAULT '' NOT NULL, ";
87              
88             =item fromname
89              
90             The I field is used to contain the name of whom the FTN message is from.
91             It can contain up to 36 characters and defaults to an empty string.
92              
93             =cut
94              
95 1         1 $table_fields .= "fromname VARCHAR(36) DEFAULT ' ' NOT NULL, ";
96              
97             =item toname
98              
99             The I field is used to contain the name of whom the FTN message is to.
100             It can contain up to 36 characters and defaults to an empty string.
101              
102             =cut
103              
104 1         1 $table_fields .= "toname VARCHAR(36) DEFAULT ' ' NOT NULL, ";
105              
106             =item subject
107              
108             The I field is used to contain the subject for the FTN message. It can
109             contain up to 72 characters and defaults to an empty string.
110              
111             =cut
112              
113 1         1 $table_fields .= "subject VARCHAR(72) DEFAULT '' NOT NULL, ";
114              
115             =item attrib
116              
117             The I field is used to contain the set of attribues from the FTN
118             message. Defaults to none of them being set. Defaults to being defined
119             as an integer.
120              
121             =cut
122              
123             # The Attributes information comes from a two byte, 16 bit integer.
124             # In a mysql database it could be defined as follows:
125             # $table_fields .= "attrib SET('Private', 'Crash', 'Recd', 'Sent',";
126             # $table_fields .= "'FileAttached', 'InTransit', 'Orphan', 'KillSent', ";
127             # $table_fields .= "'Local', 'HoldForPickup', 'unused', 'FileRequest', ";
128             # $table_fields .= "'ReturnREceiptRequest', 'IsReturnReceiptRequest', ";
129             # $table_fields .= "'AuditRequest', 'FileUpdateReq') DEFAULT '' NOT NULL, ";
130              
131             # Others apparently do notso for now, default to defining it as an integer
132 1         1 $table_fields .= "attrib Integer DEFAULT '' NOT NULL, ";
133              
134             =item msgid
135              
136             The I field is used to contain the FTN message ID. Defaults to an empty
137             string.
138              
139             =cut
140              
141 1         1 $table_fields .= "msgid VARCHAR(72) DEFAULT '' NOT NULL, ";
142              
143             =item replyid
144              
145             The I field is used to contain the FTN message reply ID. Defaults to
146             an empty string.
147              
148             =cut
149              
150 1         1 $table_fields .= "replyid VARCHAR(72) DEFAULT '' NOT NULL, ";
151              
152             =item body
153              
154             The required I field is used to contain the body of the FTN messages and
155             defaults to an empty string.
156              
157             =cut
158              
159 1         1 $table_fields .= "body MEDIUMBLOG DEFAULT '' NOT NULL, ";
160              
161             =item ctrlinfo
162              
163             The I field is used to contain the FTN control information for the
164             message being stored in the table. Defaults to an empty string.
165              
166             =back
167              
168             =cut
169              
170 1         1 $table_fields .= "ctrlinfo BLOB DEFAULT ''";
171              
172 1         2 return($table_fields);
173              
174             }
175              
176              
177             =head2 define_areasbbs_table
178              
179             Syntax: $fields = define_areasbbs_table();
180              
181             This function returns a string that contains the SQL which defines an
182             areasbbs table for use in an SQL database being used for Fidonet/FTN
183             to track message/forum or file echo processing.
184              
185             Except for the I field, which is defined in the create_ftn_table
186             subroutine itself, the defined fields are as follows:
187              
188             =cut
189              
190             sub define_areasbbs_table {
191              
192 1     1 1 1 my $table_fields = '';
193              
194             =over 4
195              
196             =item areaname
197              
198             The I field is used to contain a string indicating the distribution
199             name of the FTN message or file area. It can contain up to 32 characters and
200             defaults to an empty string.
201              
202             =cut
203              
204 1         1 $table_fields = "areaname VARCHAR(32) DEFAULT '' NOT NULL, ";
205              
206             =item bbsname
207              
208             The I field is used to contain a string indicating the name of the FTN
209             message or file area as it is referenced in the database. It can contain up to
210             32 characters and defaults to an empty string.
211              
212             =cut
213              
214 1         3 $table_fields .= "bbsname VARCHAR(32) DEFAULT '' NOT NULL, ";
215              
216             =item description
217              
218             The I field is used to contain the description of the message or
219             file area. It can contain up to 32 characters and defaults to an empty string.
220              
221             =cut
222              
223 1         1 $table_fields .= "description VARCHAR(32) DEFAULT '' NOT NULL, ";
224              
225             =item prinode
226              
227             The I field is used to contain the primary FTN node number for the
228             system that the area is on. It can contain up to 72 characters and defaults
229             to an empty string.
230              
231             =cut
232              
233 1         1 $table_fields .= "prinode CHAR(72) DEFAULT '' NOT NULL, ";
234              
235             =item uplink
236              
237             The I field is used to contain the FTN node number that the system
238             obtains the area from. It can contain up to 72 characters and defaults to
239             an empty string.
240              
241             =cut
242              
243 1         1 $table_fields .= "uplink CHAR(72) DEFAULT '' NOT NULL, ";
244              
245             =item domain
246              
247             The I field is used to contain the name of FTN domain in which
248             the area is distributed. It can contain up to 8 characters and defaults
249             to an empty string.
250              
251             =cut
252              
253 1         2 $table_fields .= "domain VARCHAR(8) DEFAULT ' ' NOT NULL, ";
254              
255             =item maxmsgs
256              
257             The I field is used to indicate the maximum number of messages that
258             should be kept in this message/forum area. Defaults to the number zero.
259              
260             =cut
261              
262 1         0 $table_fields .= "maxmsgs MEDIUMINT DEFAULT '0' NOT NULL, ";
263              
264             =item maxdays
265              
266             The I field is used to indicate the maximum number of days that messages
267             should be kept for in this message/forum area. Defaults to the number zero.
268              
269             =cut
270              
271 1         2 $table_fields .= "maxdays MEDIUMINT DEFAULT '0' NOT NULL, ";
272              
273             =item type
274              
275             The I field is used to indicate what type of FTN message/forum area this
276             is. Can be an I, for local; an I, for netmail, or an I, for local.
277             Defaults to an I. (Message/Forum areas only.)
278              
279             =back
280              
281             =cut
282              
283 1         1 $table_fields .= "type CHAR(1) DEFAULT 'L'";
284              
285 1         1 return($table_fields);
286              
287             }
288              
289             =head2 ftnmsg_index_fields
290              
291             Syntax: $fields = ftnmsg_index_fields();
292              
293             This is a function that returns a string containing a comma separated list of
294             the fields that are intended for use in creating the ftnmsg database index.
295             The index contains the following fields: msgid and replyid.
296              
297             =cut
298              
299             sub ftnmsg_index_fields {
300              
301 1     1 1 2 my $field_list = 'msgid,replyid';
302              
303 1         2 return($field_list);
304              
305             }
306              
307             =head2 ftnareas_index_fields
308              
309             Syntax: $fields = ftnareas_index_fields();
310              
311             This is a function that returns a string containing a comma separated list of
312             the fields that are intended for use in creating the ftnareas database index.
313             The index contains the following fields: areaname and bbsname.
314              
315             =cut
316              
317             sub ftnareas_index_fields {
318              
319 1     1 1 2 my $field_list = 'areaname,bbsname';
320              
321 1         1 return($field_list);
322              
323             }
324              
325             =head1 EXAMPLES
326              
327             An example of opening an FTN database, then creating a forum table,
328             loading data to it, then creating an index on it, and then closing
329             the database connection:
330              
331             use FTN::Database;
332             use FTN::Database::Forum;
333              
334             my $db_handle = open_ftn_database(\%db_option);
335             $fields = define_forum_table();
336             create_ftn_table($db_handle, $table_name, $fields);
337             ... (Load data to forum table)
338             ftnmsg_index_tables($db_handle, $table_name);
339             close_ftn_database($db_handle);
340              
341              
342             =head1 AUTHOR
343              
344             Robert James Clay, C<< >>
345              
346              
347             =head1 BUGS
348              
349             Please report any bugs or feature requests via the web interface at
350             L. I will be
351             notified, and then you'll automatically be notified of progress on
352             your bug as I make changes.
353              
354             Note that you can also report any bugs or feature requests to
355             C, or through the web interface at
356             L;
357             however, the FTN-Database Issue tracker at the SourceForge project
358             is preferred.
359              
360             =head1 SUPPORT
361              
362             You can find documentation for this module with the perldoc command.
363              
364             perldoc FTN::Database::Forum
365              
366              
367             You can also look for information at:
368              
369             =over 4
370              
371             =item * FTN::Database issue tracker
372              
373             L
374              
375             =item * RT: CPAN's request tracker
376              
377             L
378              
379             =item * Search CPAN
380              
381             L
382              
383             =back
384              
385             =head1 CREDITS
386              
387             The message/forum and areasbbs table definitions were originally derived from
388             the bbsdbpl scripts areatable.pl and areasbbsadm.pl available at the FTN Perl
389             project at SourceForge: L
390              
391              
392             =head1 SEE ALSO
393              
394             L, L
395              
396             =head1 COPYRIGHT & LICENSE
397              
398             Copyright 2001-2004,2013 Robert James Clay, all rights reserved.
399              
400             This program is free software; you can redistribute it and/or modify it
401             under the same terms as Perl itself.
402              
403              
404             =cut
405              
406             1; # End of FTN::Database::Forum