diff options
| author | fukachan <fukachan> | 2001-01-23 12:09:40 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2001-01-23 12:09:40 +0000 |
| commit | 9f88c6ebedd0fe7fd0d289a62614dfcb9e20e86c (patch) | |
| tree | ea7e4aa88ae5aa2e4ad83b6281636548099c0da5 /fml | |
| parent | de8d634c8ccc451bc3a6953641366b2a33b588ff (diff) | |
| download | fml8-9f88c6ebedd0fe7fd0d289a62614dfcb9e20e86c.tar.gz fml8-9f88c6ebedd0fe7fd0d289a62614dfcb9e20e86c.tar.bz2 fml8-9f88c6ebedd0fe7fd0d289a62614dfcb9e20e86c.zip | |
modify a few definitions and files for the preparation of Ticket::** class
create FML::SequenceFile to increment id
Diffstat (limited to 'fml')
| -rw-r--r-- | fml/etc/default_config.cf.ja | 20 | ||||
| -rw-r--r-- | fml/etc/defaults/Configurations | 4 | ||||
| -rw-r--r-- | fml/lib/FML/Article.pm | 22 | ||||
| -rw-r--r-- | fml/lib/FML/SequenceFile.pm | 109 |
4 files changed, 135 insertions, 20 deletions
diff --git a/fml/etc/default_config.cf.ja b/fml/etc/default_config.cf.ja index 566d442f..432d82a9 100644 --- a/fml/etc/default_config.cf.ja +++ b/fml/etc/default_config.cf.ja @@ -51,8 +51,10 @@ header_rewrite_rules = rewrite_subject_tag add_fml_article_id add_x_sequence add_rfc2369 + append_ticket_tag_to_subject subject_tag_name = $ml_name + subject_tag = [%s:%05d] =head2 ロック @@ -81,7 +83,23 @@ use_spool = yes spool_dir = $ml_home_dir/spool spool_type = plane +# value: confirmation / ? +chaddr_type = confirmation ### -### default_config.cf file ends here. +### Section: Tickets / Trouble Tickets System +### + +# +ticket_model = toymodel + +# +subject_ticket_tag = [%s #%08d] + +# +ticket_sequence_file = $ml_home_dir/ticket.seq +=head1 hooks ### +### default_config.cf file ends here. +### fml 4.0's 現在の LOCAL_CONFIG で別れ目になる行 +### =cut diff --git a/fml/etc/defaults/Configurations b/fml/etc/defaults/Configurations index 178605e5..4478fc4e 100644 --- a/fml/etc/defaults/Configurations +++ b/fml/etc/defaults/Configurations @@ -5,6 +5,6 @@ header.cf lock.cf log.cf spool.cf -command.cf.ja -tickets.cf.ja +command.cf +tickets.cf __end__.cf diff --git a/fml/lib/FML/Article.pm b/fml/lib/FML/Article.pm index 5498cefd..bff09e11 100644 --- a/fml/lib/FML/Article.pm +++ b/fml/lib/FML/Article.pm @@ -67,25 +67,13 @@ sub increment_id my $curproc = $self->{ curproc }; my $config = $curproc->{ config }; my $seq_file = $config->{ sequence_file }; - my $id = 0; - use IO::File::Atomic; - my ($rh, $wh) = IO::File::Atomic->rw_open($seq_file); + use FML::SequenceFile; + my $sfh = new FML::SequenceFile { sequence_file => $seq_file }; + my $id = $sfh->increment_id; + if ($sfh->error) { Log( $sfh->error ); } - # read the current sequence number - if (defined $rh) { - $id = $rh->getline; - $rh->close; - } - - # increment $id. The incremented number is the current article ID. - $id++; - - # save $id - print $wh $id, "\n"; - $wh->close; - - # return value + # save $id in pcb (process control block) and return $id $curproc->{ pcb }->{ article }->{ id } = $id; $id; } diff --git a/fml/lib/FML/SequenceFile.pm b/fml/lib/FML/SequenceFile.pm new file mode 100644 index 00000000..01b4a696 --- /dev/null +++ b/fml/lib/FML/SequenceFile.pm @@ -0,0 +1,109 @@ +#-*- perl -*- +# +# Copyright (C) 2001 Ken'ichi Fukamachi +# All rights reserved. This program is free software; you can +# redistribute it and/or modify it under the same terms as Perl itself. +# +# $Id$ +# $FML$ +# + +package FML::SequenceFile; +use strict; +use vars qw(@ISA @EXPORT @EXPORT_OK); +use Carp; + +require Exporter; +@ISA = qw(Exporter); + + +sub new +{ + my ($self, $args) = @_; + my ($type) = ref($self) || $self; + my $me = {}; + $me->{ _sequence_file } = $args->{ sequence_file }; + return bless $me, $type; +} + + +sub increment_id +{ + my ($self, $file) = @_; + my $id = 0; + my $seq_file = $file || $self->{ _sequence_file }; + + unless ($seq_file) { + $self->error_is_why("the sequence file is not specified"); + return 0; + }; + + use IO::File::Atomic; + my ($rh, $wh) = IO::File::Atomic->rw_open($seq_file); + + # read the current sequence number + if (defined $rh) { + $id = $rh->getline; + $rh->close; + } + else { + $self->error_is_why("cannot open the sequence file"); + return 0; + } + + # increment $id. The incremented number is the current article ID. + $id++; + + # save $id + print $wh $id, "\n"; + $wh->close; + + $id; +} + + +sub error +{ + my ($self) = @_; + return $self->{ _error }; +} + + +sub error_is_why +{ + my ($self, $msg) = @_; + $self->{ _error } = $msg; +} + + +=head1 NAME + +FML::SequenceFile.pm - what is this + + +=head1 SYNOPSIS + +=head1 DESCRIPTION + +=head2 new + +=item Function() + + +=head1 AUTHOR + +=head1 COPYRIGHT + +Copyright (C) 2001 __YOUR_NAME__ + +All rights reserved. This program is free software; you can +redistribute it and/or modify it under the same terms as Perl itself. + +=head1 HISTORY + +FML::SequenceFile.pm appeared in fml5. + +=cut + + +1; |
