summaryrefslogtreecommitdiff
path: root/fml/lib/FML/CGI/TicketSystem.pm
blob: e21bb8629eae3624541ced7db3da9392b0b57334 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#-*- 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::CGI::TicketSystem;
use strict;
use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD);
use Carp;
use CGI qw/:standard/; # load standard CGI routines
use FML::Process::CGI;

@ISA = qw(FML::Process::CGI Exporter);


=head1 NAME

FML::CGI::TicketSystem - CGI details to control ticket system

=head1 SYNOPSIS

    $ticket = new FML::CGI::TicketSystem;
    $ticket->new();
    $ticket->run();

See L<FML::Process::Flow> for flow methods details.

=head1 DESCRIPTION

C<NOT YET IMPLEMENTED>.

=head2 CLASS HIERARCHY

C<FML::CGI::TicketSystem> is a subclass of C<FML::Process::CGI>.

             FML::Process::Kernel
                       |
                       A
             FML::Process::CGI
                       |
                       A
            -----------------------
           |           |           |
           A           A           A
     FML::CGI::TicketSystem


=head1 METHODS

Almost methods are forwarded to C<FML::Process::CGI> base class.

=head2 C<run()>

main method.

=cut

# See CGI.pm for more details
sub run
{
    my ($curproc, $args) = @_;

    use FileHandle;
    my ($rfd, $wfd) = FileHandle::pipe;
    $args->{ fd }   = $wfd;
    my $ticket = $curproc->_load_ticket_model_module($args);

    print start_html('ticket system interface'), "\n";

    print "<PRE>\n";


    my $argv     = $args->{ ARGV };
    $argv->[ 0 ] = 'list';

    # my $tid = $ticket->get_id_list($curproc, $args);
    # for (@$tid) { print "|| $_\n";}

    $ticket->show_summary($curproc, $args);
    close($wfd);
    while (<$rfd>) { print STDOUT " | $_";}


    print "</PRE>\n";

    print "\n";
    print end_html;
    print "\n";
}


sub _load_ticket_model_module
{
    my ($curproc, $args) = @_;
    my $config = $curproc->{ config };
    my $model  = $config->{ ticket_model };
    my $pkg    = "FML::Ticket::Model::";

    if ($model eq 'toymodel') {
	$pkg .= $model;
    }
    else {
	Log("ticket: unknown model");
	return;
    }

    # fake use() to do "use FML::Ticket::$model;"
    eval qq{ require $pkg; $pkg->import();};
    unless ($@) {
	return $pkg->new($curproc, $args);
    }
    else {
	Log($@);
    }
}


=head1 SEE ALSO

L<CGI>,
L<FML::Process::CGI>
and 
L<FML::Process::Flow>

=head1 AUTHOR

Ken'ichi Fukamachi

=head1 COPYRIGHT

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. 

=head1 HISTORY

FML::CGI::TicketSystem appeared in fml5 mailing list driver package.
See C<http://www.fml.org/> for more details.

=cut


1;