blib/lib/Keystone/Resolver/DB/Site.pm untested

filter: Statementstmt 0.0% 0 / 39 Branchbran n/a Conditioncond 0.0% 0 / 10 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 75 CC 1 SCAR 6.9
CC
1
Cov
0%
table
2.0
fields
2.0
create_session
2.0
CRAP 2.0
1 # $Id: Site.pm,v 1.4 2007-05-29 17:16:31 mike Exp $
2  
3 package Keystone::Resolver::DB::Site;
4  
5 use strict;
6 use warnings;
7 use Keystone::Resolver::DB::Object;
8  
9 use vars qw(@ISA);
10 @ISA = qw(Keystone::Resolver::DB::Object);
11  
12  
13 sub table { "site" }
14 sub fields { (id => undef,
15 tag => undef,
16 name => undef,
17 bg_colour => undef,
18 email_address => undef,
19 ) }
20  
21  
22 # ----------------------------------------------------------------------------
23 # Application logic below this fold
24  
25 sub create_session {
26 my $this = shift();
27  
28 return Keystone::Resolver::DB::Session->create($this->db(),
29 site_id => $this->id());
30 }
31  
32  
33 sub session1 {
34 my $this = shift();
35 return $this->db()->session1(@_, site_id => $this->id());
36 }
37  
38  
39 sub user1 {
40 my $this = shift();
41 return $this->db()->user1(@_, site_id => $this->id());
42 }
43  
44  
45 sub add_user {
46 my $this = shift();
47 my(%data) = @_;
48  
49 return create Keystone::Resolver::DB::User($this->db(), %data,
50 site_id => $this->id());
51 }
52  
53  
54 sub search {
55 my $this = shift();
56 my $findclass = shift();
57  
58 return new Keystone::Resolver::ResultSet($this, $findclass, @_);
59 }
60  
61  
62 sub send_email {
63 use Net::SMTP;
64  
65 my $this = shift();
66 my($to, $subject, $text) = @_;
67  
68 my $from = $this->email_address();
69 my $data = "From: $from\nTo: $to\nSubject: $subject\n\n$text";
70 my $smtp = new Net::SMTP("localhost", Hello => "resolver.indexdata.com")
71 or die "can't make SMTP object";
72 $smtp->mail($from) or die "can't send email from $from";
73 $smtp->to($to) or die "can't use SMTP recipient '$to'";
74 $smtp->data($data) or die "can't email data to '$to'";
75 $smtp->quit() or die "can't send email to '$to'";
76 }
77  
78  
79 1;