summaryrefslogtreecommitdiff
path: root/fml
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-01-26 14:47:26 +0000
committerfukachan <fukachan>2001-01-26 14:47:26 +0000
commitd09522b4d0bc650fe51968b0b66af95402d6cfea (patch)
tree446d9204b1f3c80d66692ac6ff447b1d2509e5e4 /fml
parent9ae7246222d5594888f6eb01bd82fe21986dc49d (diff)
downloadfml8-d09522b4d0bc650fe51968b0b66af95402d6cfea.tar.gz
fml8-d09522b4d0bc650fe51968b0b66af95402d6cfea.tar.bz2
fml8-d09522b4d0bc650fe51968b0b66af95402d6cfea.zip
change ticket system constructor argument
enable fmlticket works to show ticket list
Diffstat (limited to 'fml')
-rw-r--r--fml/lib/FML/Process/Distribute.pm2
-rw-r--r--fml/lib/FML/Process/TicketSystem.pm167
-rw-r--r--fml/lib/FML/Ticket/Model/toymodel.pm40
3 files changed, 49 insertions, 160 deletions
diff --git a/fml/lib/FML/Process/Distribute.pm b/fml/lib/FML/Process/Distribute.pm
index 4af62c64..a8dd4522 100644
--- a/fml/lib/FML/Process/Distribute.pm
+++ b/fml/lib/FML/Process/Distribute.pm
@@ -212,7 +212,7 @@ sub _ticket_check
# fake use() to do "use FML::Ticket::$model;"
eval qq{ require $pkg; $pkg->import();};
unless ($@) {
- my $ticket = $pkg->new;
+ my $ticket = $pkg->new($curproc, $args);
$ticket->assign($curproc, $args);
$ticket->update_status($curproc, $args);
$ticket->update_db($curproc, $args);
diff --git a/fml/lib/FML/Process/TicketSystem.pm b/fml/lib/FML/Process/TicketSystem.pm
index 8712364d..6486b372 100644
--- a/fml/lib/FML/Process/TicketSystem.pm
+++ b/fml/lib/FML/Process/TicketSystem.pm
@@ -30,171 +30,25 @@ sub new
}
+# dummy
sub prepare
{
- my ($self, $args) = @_;
- $self->SUPER::prepare($args);
+ ;
}
-
sub run
{
my ($curproc, $args) = @_;
- $curproc->verify_sender_credential();
-
$curproc->lock();
{
- # user credential
- my $cred = $curproc->{ credential };
-
- # Q: the mail sender is a ML member?
- if ($cred->is_member) {
- # A: If so, we try to distribute this article.
- _distribute( $curproc );
- }
+ $curproc->_ticket_list_up($args);
}
$curproc->unlock();
}
-sub finish
-{
- my ($curproc, $args) = @_;
-
- $curproc->inform_reply_messages();
-}
-
-
-# $article->header_rewrite;
-# $article->increment_id;
-# $article->spool;
-# distribute( $article );
-sub _distribute
-{
- my ($curproc, $args) = @_;
- my $config = $curproc->{ config };
-
- # XXX $ah is "article handler" object.
- # XXX $ah != $curproc->{ article } (which is just a key)
- # XXX $curproc->{ article } is prepared as a side effect.
- my $ah = $curproc->_prepare_article($args);
-
- # get sequence number
- my $id = $ah->increment_id;
-
- # ticket system checks the message before header rewritings.
- $curproc->_ticket_check($args) if $config->yes('use_ticket');
-
- # header operations
- # XXX we need $curproc->{ article }, which is prepared above.
- $curproc->_header_rewrite({ id => $id });
-
- # spool in the article before delivery
- $ah->spool_in($id);
-
- # delivery starts !
- $curproc->_deliver_article($args);
-}
-
-
-sub _prepare_article
-{
- my ($curproc, $args) = @_;
-
- # create aritcle to distribute
- use FML::Article;
-
- # Side Effects: $article->{ curproc } = $curproc;
- return new FML::Article $curproc;
-}
-
-
-sub _header_rewrite
-{
- my ($curproc, $args) = @_;
-
- my $config = $curproc->{ config };
- my $header = $curproc->{ article }->{ header };
- my $rules = $curproc->{ config }->{ header_rewrite_rules };
- my $id = $args->{ id };
-
- for my $rule (split(/\s+/, $rules)) {
- Log("_header_rewrite( $rule )") if $config->yes('debug');
-
- if ($rule eq 'rewrite_subject_tag') {
- $header->rewrite_subject_tag($config, { id => $id } );
- }
-
- if ($rule eq 'rewrite_reply_to') {
- $header->rewrite_reply_to($config);
- }
-
- if ($rule eq 'add_software_info') {
- $header->add_software_info($config, { id => $id } );
- }
-
- if ($rule eq 'add_fml_ml_name') {
- $header->add_fml_ml_name($config, { id => $id } );
- }
-
- if ($rule eq 'add_fml_article_id') {
- $header->add_fml_article_id($config, { id => $id } );
- }
-
- if ($rule eq 'add_x_sequence') {
- $header->add_x_sequence($config, {
- name => $config->{ address_for_post },
- id => $id,
- });
- }
-
- if ($rule eq 'add_rfc2369') {
- $header->add_rfc2369($config, {
- id => $id,
- mode => 'distribute',
- });
- }
- }
-}
-
-
-sub _deliver_article
-{
- my ($curproc, $args) = @_;
-
- my $config = $curproc->{ config }; # FML::Config object
- my $body = $curproc->{ article }->{ body }; # MailingList::Messages
- my $header = $curproc->{ article }->{ header };# FML::Header
-
- # distribute article
- use MailingList::Delivery;
-
- my $fp = sub { Log(@_);}; # pointer to the log function
- my $sfp = sub { my ($s) = @_; print $s; print "\n" if $s !~ /\n$/o;};
- my $service = new MailingList::Delivery {
- log_function => $fp,
- smtp_log_function => $sfp,
- socket_timeout => 2, # XXX 2 for debug but 10 by default
- };
- if ($service->error) { Log($service->error); return;}
-
- $service->deliver(
- {
- 'mta' => $config->{'mta'},
-
- 'smtp_sender' => 'rudo',
- 'recipient_maps' => $config->{recipient_maps},
- 'recipient_limit' => $config->{recipient_limit},
-
- 'header' => $header,
- 'body' => $body,
- });
- if ($service->error) { Log($service->error); return;}
-}
-
-
-sub _ticket_check
+sub _ticket_list_up
{
my ($curproc, $args) = @_;
my $config = $curproc->{ config };
@@ -212,10 +66,8 @@ sub _ticket_check
# fake use() to do "use FML::Ticket::$model;"
eval qq{ require $pkg; $pkg->import();};
unless ($@) {
- my $ticket = $pkg->new;
- $ticket->assign($curproc, $args);
- $ticket->update_status($curproc, $args);
- $ticket->update_cache($curproc, $args);
+ my $ticket = $pkg->new($curproc, $args);
+ $ticket->list_up($curproc, $args);
}
else {
Log($@);
@@ -223,6 +75,13 @@ sub _ticket_check
}
+sub AUTOLOAD
+{
+ my ($curproc, $args) = @_;
+ ;
+}
+
+
=head1 NAME
distribute -- fml5 article distributer program.
diff --git a/fml/lib/FML/Ticket/Model/toymodel.pm b/fml/lib/FML/Ticket/Model/toymodel.pm
index d68637fc..f37788b8 100644
--- a/fml/lib/FML/Ticket/Model/toymodel.pm
+++ b/fml/lib/FML/Ticket/Model/toymodel.pm
@@ -22,9 +22,17 @@ require Exporter;
sub new
{
- my ($self) = @_;
+ my ($self, $curproc, $args) = @_;
my ($type) = ref($self) || $self;
my $me = {};
+ bless $me, $type;
+
+ # initialize directory for DB files for further work
+ my $config = $curproc->{ config };
+ my $ml_name = $config->{ ml_name };
+ $me->{ _db_dir } = $config->{ ticket_db_dir } ."/". $ml_name;
+ $me->_init_ticket_db_dir($curproc, $args) || do { return undef;};
+
return bless $me, $type;
}
@@ -88,10 +96,6 @@ sub update_db
my $config = $curproc->{ config };
my $ml_name = $config->{ ml_name };
- # initialize directory for DB files for further work
- $self->{ _db_dir } = $config->{ ticket_db_dir } ."/". $ml_name;
- $self->_init_ticket_db_dir($curproc, $args) || do { return undef;};
-
# save $ticke_id et.al. in db_dir/
$self->_update_db($curproc, $args);
}
@@ -187,6 +191,32 @@ sub _update_db
}
+sub list_up
+{
+ my ($self, $curproc, $args) = @_;
+ my $config = $curproc->{ config };
+ my $pcb = $curproc->{ pcb };
+ my $ml_name = $config->{ ml_name };
+
+ $self->_open_db($curproc, $args);
+
+ # prepare hash table tied to db_dir/*db's
+ my $rh_ticket_id = $self->{ _hash_table }->{ _ticket_id };
+ my $rh_date = $self->{ _hash_table }->{ _date };
+ my $rh_status = $self->{ _hash_table }->{ _status };
+ my $rh_articles = $self->{ _hash_table }->{ _articles };
+
+ my ($tid, $status) = ();
+ while (($tid, $status) = each %$rh_status) {
+ my ($aid) = split(/\s+/, $rh_articles->{ $tid });
+ printf "%5s %-20s %s\n",
+ $status, $tid, $rh_articles->{ $tid },
+ }
+
+ $self->_close_db($curproc, $args);
+}
+
+
sub _open_db
{
my ($self, $curproc, $args) = @_;