File Coverage

blib/lib/Labyrinth/Plugin/Event/Types.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package Labyrinth::Plugin::Event::Types;
2              
3 3     3   14136 use warnings;
  3         6  
  3         122  
4 3     3   25 use strict;
  3         5  
  3         118  
5              
6 3     3   15 use vars qw($VERSION);
  3         5  
  3         184  
7             $VERSION = '1.09';
8              
9             =head1 NAME
10              
11             Labyrinth::Plugin::Event::Types - Event Type handler for the Labyrinth framework.
12              
13             =head1 DESCRIPTION
14              
15             Contains all the event type functionality for Labyrinth.
16              
17             This package can be overridden to extended to the event types available.
18              
19             =cut
20              
21             # -------------------------------------
22             # Library Modules
23              
24 3     3   16 use base qw(Labyrinth::Plugin::Base);
  3         4  
  3         2372  
25              
26             use Labyrinth::MLUtils;
27             use Labyrinth::Variables;
28              
29             # -------------------------------------
30             # Variables
31              
32             my %eventtypes;
33             our $AUTOLOAD;
34              
35             # -------------------------------------
36             # The Subs
37              
38             =head1 Pub INTERFACE METHODS
39              
40             =over 4
41              
42             =item SetType
43              
44             An AUTOLOADed method to set the event type. Note if the type does not exist
45             within the database, the value is set to 0.
46              
47             =item EventType
48              
49             Provides the name of a specified event type.
50              
51             =item EventTypeSelect
52              
53             Provides a dropdown list of event types available.
54              
55             =back
56              
57             =cut
58              
59             sub AUTOLOAD {
60             my $self = shift;
61             ref($self) or die "$self is not an object";
62              
63             my $name = $AUTOLOAD;
64             $name =~ s/.*://; # strip fully-qualified portion
65              
66             my ($type) = $name =~ /SetType(\d+)/;
67             if($type) {
68             my @rows = $dbi->GetQuery('hash','GetEventType',$type);
69             if(@rows) { $cgiparams{eventtypeid} = $type }
70             else { $cgiparams{eventtypeid} = 0 }
71             } else { $cgiparams{eventtypeid} = 0 }
72             }
73              
74             sub EventType {
75             my ($self,$type) = @_;
76              
77             unless(%eventtypes) {
78             my @rows = $dbi->GetQuery('hash','AllEventTypes');
79             $eventtypes{$_->{eventtypeid}} = $_->{eventtype} for(@rows);
80             }
81              
82             return $eventtypes{$type} || '';
83             }
84              
85             sub EventTypeSelect {
86             my ($self,$opt,$blank) = @_;
87             $blank ||= 0;
88              
89             unless(%eventtypes) {
90             my @rows = $dbi->GetQuery('hash','AllEventTypes');
91             $eventtypes{$_->{eventtypeid}} = $_->{eventtype} for(@rows);
92             }
93              
94             my @list = map { { 'id' => $_, 'value' => $eventtypes{$_} } } sort keys %eventtypes;
95             unshift @list, { id => 0, value => 'Select An Event Type' } if($blank == 1);
96             return DropDownRows($opt,'eventtypeid','id','value',@list);
97             }
98              
99             1;
100              
101             __END__