|
Lines 54-64
if ( $op eq 'add' ) {
Link Here
|
| 54 |
my $debug = ( scalar $input->param('smtp_debug_mode') ) ? 1 : 0; |
54 |
my $debug = ( scalar $input->param('smtp_debug_mode') ) ? 1 : 0; |
| 55 |
my $is_default = ( scalar $input->param('smtp_default') ) ? 1 : 0; |
55 |
my $is_default = ( scalar $input->param('smtp_default') ) ? 1 : 0; |
| 56 |
|
56 |
|
| 57 |
my $schema = Koha::Database->new->schema; |
|
|
| 58 |
try { |
57 |
try { |
| 59 |
$schema->storage->txn_begin; |
|
|
| 60 |
|
| 61 |
Koha::SMTP::Servers->search->update({ is_default => 0 }) if $is_default; |
| 62 |
|
58 |
|
| 63 |
Koha::SMTP::Server->new( |
59 |
Koha::SMTP::Server->new( |
| 64 |
{ |
60 |
{ |
|
Lines 75-84
if ( $op eq 'add' ) {
Link Here
|
| 75 |
)->store; |
71 |
)->store; |
| 76 |
|
72 |
|
| 77 |
push @messages, { type => 'message', code => 'success_on_insert' }; |
73 |
push @messages, { type => 'message', code => 'success_on_insert' }; |
| 78 |
$schema->storage->txn_commit; |
|
|
| 79 |
} |
74 |
} |
| 80 |
catch { |
75 |
catch { |
| 81 |
$schema->storage->txn_rollback; |
|
|
| 82 |
if ( blessed $_ and $_->isa('Koha::Exceptions::Object::DuplicateID') ) { |
76 |
if ( blessed $_ and $_->isa('Koha::Exceptions::Object::DuplicateID') ) { |
| 83 |
push @messages, |
77 |
push @messages, |
| 84 |
{ |
78 |
{ |
|
Lines 133-144
elsif ( $op eq 'edit_save' ) {
Link Here
|
| 133 |
my $debug = ( scalar $input->param('smtp_debug_mode') ) ? 1 : 0; |
127 |
my $debug = ( scalar $input->param('smtp_debug_mode') ) ? 1 : 0; |
| 134 |
my $is_default = ( scalar $input->param('smtp_default') ) ? 1 : 0; |
128 |
my $is_default = ( scalar $input->param('smtp_default') ) ? 1 : 0; |
| 135 |
|
129 |
|
| 136 |
my $schema = Koha::Database->new->schema; |
|
|
| 137 |
|
| 138 |
try { |
130 |
try { |
| 139 |
$schema->storage->txn_begin; |
|
|
| 140 |
|
| 141 |
Koha::SMTP::Servers->search->update({ is_default => 0 }) if $is_default; |
| 142 |
|
131 |
|
| 143 |
$smtp_server->password( $password ) |
132 |
$smtp_server->password( $password ) |
| 144 |
if defined $password and $password ne '****' |
133 |
if defined $password and $password ne '****' |
|
Lines 162-171
elsif ( $op eq 'edit_save' ) {
Link Here
|
| 162 |
type => 'message', |
151 |
type => 'message', |
| 163 |
code => 'success_on_update' |
152 |
code => 'success_on_update' |
| 164 |
}; |
153 |
}; |
| 165 |
$schema->storage->txn_commit; |
|
|
| 166 |
} |
154 |
} |
| 167 |
catch { |
155 |
catch { |
| 168 |
$schema->storage->txn_rollback; |
|
|
| 169 |
push @messages, |
156 |
push @messages, |
| 170 |
{ |
157 |
{ |
| 171 |
type => 'alert', |
158 |
type => 'alert', |