Bug 22343: Add classes for handling SMTP servers
[koha.git] / Koha / SMTP / Servers.pm
1 package Koha::SMTP::Servers;
2
3 # This file is part of Koha.
4 #
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18 use Modern::Perl;
19
20 use Koha::Database;
21 use Koha::Exceptions;
22
23 use Koha::SMTP::Server;
24
25 use base qw(Koha::Objects);
26
27 =head1 NAME
28
29 Koha::SMTP::Servers - Koha SMTP Server Object set class
30
31 =head1 API
32
33 =head2 Class methods
34
35 =head3 get_default
36
37     my $server = Koha::SMTP::Servers->new->get_default;
38
39 Returns the default I<Koha::SMTP::Server> object.
40
41 =cut
42
43 sub get_default {
44     my ($self) = @_;
45
46     my $default = Koha::SMTP::Server->new( $self->default_setting );
47     $default->{_is_system_default} = 1;
48     return $default;
49 }
50
51 =head2 Internal methods
52
53 =head3 _type
54
55 Return type of object, relating to Schema ResultSet
56
57 =cut
58
59 sub _type {
60     return 'SmtpServer';
61 }
62
63 =head3 default_setting
64
65     my $hash = Koha::SMTP::Servers::default_setting;
66
67 Returns the default setting that is to be used when no user-defined default
68 SMTP server is provided
69
70 =cut
71
72 sub default_setting {
73     return {
74         name       => 'localhost',
75         host       => 'localhost',
76         port       => 25,
77         timeout    => 120,
78         ssl_mode  => 'disabled',
79         user_name  => undef,
80         password   => undef,
81         debug      => 0
82     };
83 }
84
85 =head3 object_class
86
87 Return object class
88
89 =cut
90
91 sub object_class {
92     return 'Koha::SMTP::Server';
93 }
94
95 1;