Bug 30237: Reference new WELCOME notice
[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;
47     my $smtp_config = C4::Context->config('smtp_server');
48
49     if ( $smtp_config ) {
50         $default = Koha::SMTP::Server->new( $smtp_config );
51     }
52     else {
53         $default = Koha::SMTP::Server->new( $self->default_setting );
54     }
55
56     $default->{_is_system_default} = 1;
57     return $default;
58 }
59
60 =head2 Internal methods
61
62 =head3 _type
63
64 Return type of object, relating to Schema ResultSet
65
66 =cut
67
68 sub _type {
69     return 'SmtpServer';
70 }
71
72 =head3 default_setting
73
74     my $hash = Koha::SMTP::Servers::default_setting;
75
76 Returns the default setting that is to be used when no user-defined default
77 SMTP server is provided
78
79 =cut
80
81 sub default_setting {
82     return {
83         name       => 'localhost',
84         host       => 'localhost',
85         port       => 25,
86         timeout    => 120,
87         ssl_mode  => 'disabled',
88         user_name  => undef,
89         password   => undef,
90         debug      => 0
91     };
92 }
93
94 =head3 object_class
95
96 Return object class
97
98 =cut
99
100 sub object_class {
101     return 'Koha::SMTP::Server';
102 }
103
104 1;