View | Details | Raw Unified | Return to bug 26595
Collapse All | Expand All

(-)a/Koha/Library.pm (-17 lines)
Lines 115-137 sub smtp_server { Link Here
115
    return $self;
115
    return $self;
116
}
116
}
117
117
118
=head3 smtp_server_info
119
120
Returns the SMTP server info for the library, or 'system_default' if it is the system default.
121
122
=cut
123
124
sub smtp_server_info {
125
    my ($self) = @_;
126
127
    my $smtp_server = $self->smtp_server;
128
129
    return { name => 'system_default' }
130
        if $smtp_server->is_system_default;
131
132
    return { name => $smtp_server->name, smtp_server_id => $smtp_server->id };
133
}
134
135
=head3 inbound_email_address
118
=head3 inbound_email_address
136
119
137
  my $to_email = Koha::Library->inbound_email_address;
120
  my $to_email = Koha::Library->inbound_email_address;
(-)a/admin/columns_settings.yml (-1 / +1 lines)
Lines 260-266 modules: Link Here
260
            -
260
            -
261
              columnname: is_pickup_location
261
              columnname: is_pickup_location
262
            -
262
            -
263
              columnname: smtp_server_info
263
              columnname: smtp_server
264
            -
264
            -
265
              columnname: actions
265
              columnname: actions
266
              cannot_be_toggled: 1
266
              cannot_be_toggled: 1
(-)a/api/v1/swagger/definitions/library.json (-13 / +3 lines)
Lines 84-102 Link Here
84
        "type": "boolean",
84
        "type": "boolean",
85
        "description": "If the library can act as a pickup location"
85
        "description": "If the library can act as a pickup location"
86
    },
86
    },
87
    "smtp_server_info": {
87
    "smtp_server": {
88
        "type": "object",
88
        "type": ["object", "null"],
89
        "properties": {
89
        "description": "The library effective SMTP server"
90
          "name": {
91
            "description": "SMTP server name. 'system_default' if no SMTP server is assigned",
92
            "type": "string"
93
          },
94
          "smtp_server_id": {
95
            "description": "Internal identifier for the SMTP server",
96
            "type": ["integer", "null"]
97
          }
98
        },
99
        "description": "The library effective SMTP server information."
100
    }
90
    }
101
  },
91
  },
102
  "additionalProperties": false,
92
  "additionalProperties": false,
(-)a/api/v1/swagger/paths/libraries.json (-2 / +2 lines)
Lines 180-186 Link Here
180
        }
180
        }
181
      },
181
      },
182
      "x-koha-embed": [
182
      "x-koha-embed": [
183
        "smtp_server_info"
183
        "smtp_server"
184
      ]
184
      ]
185
    },
185
    },
186
    "post": {
186
    "post": {
Lines 289-295 Link Here
289
        }
289
        }
290
      },
290
      },
291
      "x-koha-embed": [
291
      "x-koha-embed": [
292
        "smtp_server_info"
292
        "smtp_server"
293
      ]
293
      ]
294
    },
294
    },
295
    "put": {
295
    "put": {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt (-5 / +5 lines)
Lines 244-250 Link Here
244
                "ajax": {
244
                "ajax": {
245
                    "url": libraries_url
245
                    "url": libraries_url
246
                },
246
                },
247
                'embed': [ 'smtp_server_info' ],
247
                'embed': [ 'smtp_server' ],
248
                'emptyTable': '<div class="dialog message">'+_("There are no libraries defined.")+' <a href="/cgi-bin/koha/admin/branches.pl?op=add_form">'+_("Start defining libraries")+'</a>.</div>',
248
                'emptyTable': '<div class="dialog message">'+_("There are no libraries defined.")+' <a href="/cgi-bin/koha/admin/branches.pl?op=add_form">'+_("Start defining libraries")+'</a>.</div>',
249
                "columnDefs": [ {
249
                "columnDefs": [ {
250
                    "targets": [0,1,3,4,6,8,9,10,11,12,13,14,15],
250
                    "targets": [0,1,3,4,6,8,9,10,11,12,13,14,15],
Lines 319-331 Link Here
319
                        }
319
                        }
320
                    },
320
                    },
321
                    {
321
                    {
322
                        "data": "smtp_server_info",
322
                        "data": "smtp_server",
323
                        "render": function( data, type, row, meta ) {
323
                        "render": function( data, type, row, meta ) {
324
                            if ( data.name == 'system_default' ) {
324
                            if ( data.smtp_server_id ) {
325
                                return _("Default");
325
                                return '<a href="/cgi-bin/koha/admin/smtp_servers.pl?op=edit_form&smtp_server_id='+encodeURIComponent(data.smtp_server_id)+'">'+data.name.escapeHtml()+'</a>';
326
                            }
326
                            }
327
                            else {
327
                            else {
328
                                return '<a href="/cgi-bin/koha/admin/smtp_servers.pl?op=edit_form&smtp_server_id='+encodeURIComponent(data.smtp_server_id)+'">'+data.name.escapeHtml()+'</a>';
328
                                return _("Default");
329
                            }
329
                            }
330
                        },
330
                        },
331
                        "searchable": false,
331
                        "searchable": false,
(-)a/t/db_dependent/Koha/Library.t (-21 / +1 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 2;
22
use Test::More tests => 1;
23
23
24
use Koha::Database;
24
use Koha::Database;
25
use Koha::SMTP::Servers;
25
use Koha::SMTP::Servers;
Lines 93-114 subtest 'smtp_server() tests' => sub { Link Here
93
93
94
    $schema->storage->txn_rollback;
94
    $schema->storage->txn_rollback;
95
};
95
};
96
97
subtest 'smtp_server_info() tests' => sub {
98
99
    plan tests => 2;
100
101
    $schema->storage->txn_begin;
102
103
    my $library     = $builder->build_object({ class => 'Koha::Libraries' });
104
    my $smtp_server = $builder->build_object({ class => 'Koha::SMTP::Servers' });
105
106
    # No SMTP server assigned to library, return system default
107
    is_deeply( $library->smtp_server_info, { name => 'system_default' }, 'System default is returned' );
108
109
    # Assign an SMTP server
110
    $library->smtp_server({ smtp_server => $smtp_server });
111
    is_deeply( $library->smtp_server_info, { name => $smtp_server->name, smtp_server_id => $smtp_server->id }, 'The right information is returned when SMTP server is assigned' );
112
113
    $schema->storage->txn_rollback;
114
};
115
- 

Return to bug 26595