Bugzilla – Attachment 109163 Details for
Bug 22343
Add configuration options for SMTP servers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22343: Add CRUD page for SMTP servers
Bug-22343-Add-CRUD-page-for-SMTP-servers.patch (text/plain), 28.74 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-08-26 12:33:46 UTC
(
hide
)
Description:
Bug 22343: Add CRUD page for SMTP servers
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-08-26 12:33:46 UTC
Size:
28.74 KB
patch
obsolete
>From 9a756ccddda53c3768dfc7ee5a95c147b1a8768a Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 29 Jul 2020 17:35:50 -0300 >Subject: [PATCH] Bug 22343: Add CRUD page for SMTP servers > >This patch introduces a way to define SMTP servers either globally or >per-library. > >To test: >1. Apply this patch >2. Find the SMTP servers entry in the admin page >3. Play with adding/removing SMTP servers >=> SUCCESS: All works as expected >4. Sign off :-D >--- > admin/smtp_servers.pl | 182 +++++++++ > .../prog/en/includes/admin-menu.inc | 5 +- > .../prog/en/includes/permissions.inc | 5 + > .../prog/en/modules/admin/admin-home.tt | 6 +- > .../prog/en/modules/admin/smtp_servers.tt | 382 ++++++++++++++++++ > 5 files changed, 578 insertions(+), 2 deletions(-) > create mode 100755 admin/smtp_servers.pl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/admin/smtp_servers.tt > >diff --git a/admin/smtp_servers.pl b/admin/smtp_servers.pl >new file mode 100755 >index 0000000000..9dff83d0a5 >--- /dev/null >+++ b/admin/smtp_servers.pl >@@ -0,0 +1,182 @@ >+#!/usr/bin/perl >+ >+# Copyright 2020 Theke Solutions >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use CGI qw ( -utf8 ); >+use Scalar::Util qw(blessed); >+use Try::Tiny; >+ >+use C4::Auth qw(get_template_and_user); >+use C4::Output qw(output_html_with_http_headers); >+ >+use Koha::Libraries; >+use Koha::SMTP::Servers; >+ >+my $input = CGI->new; >+my $op = $input->param('op') || 'list'; >+ >+my ( $template, $borrowernumber, $cookie ) = get_template_and_user( >+ { template_name => "admin/smtp_servers.tt", >+ query => $input, >+ type => "intranet", >+ flagsrequired => { parameters => 'manage_smtp_servers' }, >+ } >+); >+ >+my @messages; >+ >+if ( $op eq 'add' ) { >+ >+ my $name = $input->param('smtp_name'); >+ my $host = $input->param('smtp_host'); >+ my $port = $input->param('smtp_port') || 25; >+ my $timeout = $input->param('smtp_timeout') || 120; >+ my $ssl_mode = $input->param('smtp_ssl_mode'); >+ my $user_name = $input->param('smtp_user_name') || undef; >+ my $password = $input->param('smtp_password') || undef; >+ my $debug = ( scalar $input->param('smtp_debug_mode') ) ? 1 : 0; >+ >+ try { >+ Koha::SMTP::Server->new( >+ { >+ name => $name, >+ host => $host, >+ port => $port, >+ timeout => $timeout, >+ ssl_mode => $ssl_mode, >+ user_name => $user_name, >+ password => $password, >+ debug => $debug, >+ } >+ )->store; >+ >+ push @messages, { type => 'message', code => 'success_on_insert' }; >+ } >+ catch { >+ if ( blessed $_ and $_->isa('Koha::Exceptions::Object::DuplicateID') ) { >+ push @messages, >+ { >+ type => 'alert', >+ code => 'error_on_insert', >+ reason => 'duplicate_id' >+ }; >+ } >+ }; >+ >+ # list servers after adding >+ $op = 'list'; >+} >+elsif ( $op eq 'edit_form' ) { >+ my $smtp_server_id = $input->param('smtp_server_id'); >+ my $smtp_server; >+ >+ $smtp_server = Koha::SMTP::Servers->find($smtp_server_id) >+ unless !$smtp_server_id; >+ >+ if ( $smtp_server ) { >+ $template->param( >+ smtp_server => $smtp_server >+ ); >+ } >+ else { >+ push @messages, >+ { >+ type => 'alert', >+ code => 'error_on_edit', >+ reason => 'invalid_id' >+ }; >+ } >+} >+elsif ( $op eq 'edit_save' ) { >+ >+ my $smtp_server_id = $input->param('smtp_server_id'); >+ my $smtp_server; >+ >+ $smtp_server = Koha::SMTP::Servers->find($smtp_server_id) >+ unless !$smtp_server_id; >+ >+ if ( $smtp_server ) { >+ >+ my $name = $input->param('smtp_name'); >+ my $host = $input->param('smtp_host'); >+ my $port = $input->param('smtp_port') || 25; >+ my $timeout = $input->param('smtp_timeout') || 120; >+ my $ssl_mode = $input->param('smtp_ssl_mode'); >+ my $user_name = $input->param('smtp_user_name') || undef; >+ my $password = $input->param('smtp_password') || undef; >+ my $debug = ( scalar $input->param('smtp_debug_mode') ) ? 1 : 0; >+ >+ try { >+ $smtp_server->password( $password ) >+ if $password; >+ >+ $smtp_server->set( >+ { >+ name => $name, >+ host => $host, >+ port => $port, >+ timeout => $timeout, >+ ssl_mode => $ssl_mode, >+ user_name => $user_name, >+ debug => $debug >+ } >+ )->store; >+ >+ push @messages, >+ { >+ type => 'message', >+ code => 'success_on_update' >+ }; >+ } >+ catch { >+ push @messages, >+ { >+ type => 'alert', >+ code => 'error_on_update' >+ }; >+ }; >+ >+ # list servers after adding >+ $op = 'list'; >+ } >+ else { >+ push @messages, >+ { >+ type => 'alert', >+ code => 'error_on_update', >+ reason => 'invalid_id' >+ }; >+ } >+} >+ >+if ( $op eq 'list' ) { >+ my $smtp_servers = Koha::SMTP::Servers->search; >+ $template->param( >+ servers_count => $smtp_servers->count, >+ default_config => $smtp_servers->default_setting >+ ); >+} >+ >+$template->param( >+ op => $op, >+ messages => \@messages, >+); >+ >+output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >index 8f95f3ee05..44d1f4cc0e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >@@ -123,12 +123,15 @@ > </ul> > [% END %] > >- [% IF ( CAN_user_parameters_manage_search_targets || CAN_user_parameters_manage_didyoumean || CAN_user_parameters_manage_column_config || CAN_user_parameters_manage_audio_alerts || ( CAN_user_parameters_manage_sms_providers && Koha.Preference('SMSSendDriver') == 'Email' ) || CAN_user_parameters_manage_usage_stats || CAN_user_parameters_manage_additional_fields || ( Koha.Preference('EnableAdvancedCatalogingEditor') && CAN_user_parameters_manage_keyboard_shortcuts ) ) %] >+ [% IF ( CAN_user_parameters_manage_smtp_servers || CAN_user_parameters_manage_search_targets || CAN_user_parameters_manage_didyoumean || CAN_user_parameters_manage_column_config || CAN_user_parameters_manage_audio_alerts || ( CAN_user_parameters_manage_sms_providers && Koha.Preference('SMSSendDriver') == 'Email' ) || CAN_user_parameters_manage_usage_stats || CAN_user_parameters_manage_additional_fields || ( Koha.Preference('EnableAdvancedCatalogingEditor') && CAN_user_parameters_manage_keyboard_shortcuts ) ) %] > <h5>Additional parameters</h5> > <ul> > [% IF ( CAN_user_parameters_manage_search_targets ) %] > <li><a href="/cgi-bin/koha/admin/z3950servers.pl">Z39.50/SRU servers</a></li> > [% END %] >+ [% IF ( CAN_user_parameters_manage_smtp_servers ) %] >+ <li><a href="/cgi-bin/koha/admin/smtp_servers.pl">SMTP servers</a></li> >+ [% END %] > [% IF ( CAN_user_parameters_manage_didyoumean ) %] > <li><a href="/cgi-bin/koha/admin/didyoumean.pl">Did you mean?</a></li> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc >index 79b6560193..03a9e67d8e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc >@@ -220,6 +220,11 @@ > Manage Did you mean? configuration > </span> > <span class="permissioncode">([% name | html %])</span> >+ [%- CASE 'manage_smtp_servers' -%] >+ <span class="sub_permission manage_manage_smtp_servers_subpermission"> >+ Manage SMTP servers >+ </span> >+ <span class="permissioncode">([% name | html %])</span> > [%- CASE 'manage_column_config' -%] > <span class="sub_permission manage_column_config_subpermission"> > Manage column configuration >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >index 0c02f258ab..1f084358fb 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >@@ -199,7 +199,7 @@ > </dl> > [% END %] > >- [% IF ( ( CAN_user_parameters_manage_search_targets || CAN_user_parameters_manage_didyoumean || CAN_user_parameters_manage_column_config || CAN_user_parameters_manage_audio_alerts || CAN_user_parameters_manage_sms_providers && Koha.Preference('SMSSendDriver') == 'Email' ) || CAN_user_parameters_manage_usage_stats || CAN_user_parameters_manage_additional_fields || CAN_user_parameters_manage_mana || (Koha.Preference('EnableAdvancedCatalogingEditor') && CAN_user_parameters_manage_keyboard_shortcuts) ) %] >+ [% IF ( ( CAN_user_parameters_manage_smtp_servers || CAN_user_parameters_manage_search_targets || CAN_user_parameters_manage_didyoumean || CAN_user_parameters_manage_column_config || CAN_user_parameters_manage_audio_alerts || CAN_user_parameters_manage_sms_providers && Koha.Preference('SMSSendDriver') == 'Email' ) || CAN_user_parameters_manage_usage_stats || CAN_user_parameters_manage_additional_fields || CAN_user_parameters_manage_mana || (Koha.Preference('EnableAdvancedCatalogingEditor') && CAN_user_parameters_manage_keyboard_shortcuts) ) %] > <h3>Additional parameters</h3> > <dl> > <!-- <dt><a href="/cgi-bin/koha/admin/printers.pl">Network Printers</a></dt> >@@ -208,6 +208,10 @@ > <dt><a href="/cgi-bin/koha/admin/z3950servers.pl">Z39.50/SRU servers</a></dt> > <dd>Define which external servers to query for MARC data.</dd> > [% END %] >+ [% IF ( CAN_user_parameters_manage_smtp_servers ) %] >+ <dt><a href="/cgi-bin/koha/admin/smtp_servers.pl">SMTP servers</a></dt> >+ <dd>Define which SMTP servers to use.</dd> >+ [% END %] > [% IF ( CAN_user_parameters_manage_didyoumean ) %] > <dt><a href="/cgi-bin/koha/admin/didyoumean.pl">Did you mean?</a></dt> > <dd>Choose which plugins to use to suggest searches to patrons and staff.</dd> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smtp_servers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smtp_servers.tt >new file mode 100644 >index 0000000000..1d5813f8bf >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smtp_servers.tt >@@ -0,0 +1,382 @@ >+[% USE raw %] >+[% USE Asset %] >+[% SET footerjs = 1 %] >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › >+Administration › >+SMTP servers >+[% IF op == 'add_form' %] >+ › New SMTP server >+[% ELSIF op == 'edit_form' %] >+ › Edit SMTP server >+[% END %] >+</title> >+[% INCLUDE 'doc-head-close.inc' %] >+</head> >+ >+<body id="admin_smtp_servers" class="admin"> >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'prefs-admin-search.inc' %] >+ >+<div id="breadcrumbs"> >+ <a href="/cgi-bin/koha/mainpage.pl">Home</a> › >+ <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> › >+ <a href="/cgi-bin/koha/admin/smtp_servers.pl">SMTP servers</a> >+[% IF op == 'add_form' %] >+ › <span> New</span> >+[% ELSIF op == 'edit_form' %] >+ › <span> Edit</span> >+[% END %] >+</div> >+ >+<div class="main container-fluid"> >+ <div class="row"> >+ <div class="col-sm-10 col-sm-push-2"> >+ <main> >+ >+[% FOREACH m IN messages %] >+ <div class="dialog [% m.type | html %]" id="smtp_action_result_dialog"> >+ [% SWITCH m.code %] >+ [% CASE 'error_on_update' %] >+ An error occurred trying to open the server for editing. The passed id is invalid. >+ [% CASE 'error_on_insert' %] >+ An error occurred when adding the server. The library already has an SMTP server set. >+ [% CASE 'success_on_update' %] >+ Server updated successfully. >+ [% CASE 'success_on_insert' %] >+ Server added successfully. >+ [% CASE %] >+ [% m.code | html %] >+ [% END %] >+ </div> >+[% END %] >+ >+ <div class="dialog message" id="smtp_delete_success" style="display: none;"></div> >+ <div class="dialog alert" id="smtp_delete_error" style="display: none;"></div> >+ >+[% IF op == 'add_form' %] >+ <h3>New SMTP server</h3> >+ <form action="/cgi-bin/koha/admin/smtp_servers.pl" id="add" name="add" class="validated" method="post"> >+ <input type="hidden" name="op" value="add" /> >+ <fieldset class="rows"> >+ <ol> >+ <li> >+ <label for="smtp_name" class="required">Name: </label> >+ <input type="text" name="smtp_name" id="smtp_name" size="60" class="required" required="required" /> >+ <span class="required">Required</span> >+ </li> >+ </ol> >+ </fieldset> >+ >+ <fieldset class="rows"> >+ <ol> >+ <li> >+ <label for="smtp_host">Host: </label> >+ <input type="text" name="smtp_host" id="smtp_host" size="60" class="required"/> >+ <span class="required">Required</span> >+ </li> >+ <li> >+ <label for="smtp_port">Port: </label> >+ <input type="text" inputmode="numeric" pattern="[0-9]*" value="25" name="smtp_port" id="smtp_port" size="20" class="required"/> >+ <span class="required">Required</span> >+ </li> >+ <li> >+ <label for="smtp_timeout">Timeout (seconds): </label> >+ <input type="text" inputmode="numeric" pattern="[0-9]*" value="120" name="smtp_timeout" id="smtp_timeout" size="20" /> >+ </li> >+ <li> >+ <label for="smtp_ssl_mode">SSL: </label> >+ <select name="smtp_ssl_mode" id="smtp_ssl_mode"> >+ <option value="disabled" selected="selected">Disabled</option> >+ <option value="ssl">SSL</option> >+ <option value="starttls">STARTTLS</option> >+ </select> >+ </li> >+ <li> >+ <label for="smtp_user_name">User name: </label> >+ <input type="text" name="smtp_user_name" id="smtp_user_name" size="60" /> >+ </li> >+ <li> >+ <label for="smtp_password">Password: </label> >+ <input type="password" name="smtp_password" id="smtp_password" size="60" /> >+ </li> >+ <li> >+ <label for="smtp_debug_mode">Debug mode: </label> >+ <select name="smtp_debug_mode" id="smtp_debug_mode"> >+ <option value="1">Enabled</option> >+ <option value="0" selected="selected">Disabled</option> >+ </select> >+ </li> >+ </ol> >+ </fieldset> >+ <fieldset class="action"> >+ <input type="submit" value="Submit" /> >+ <a class="cancel" href="/cgi-bin/koha/admin/smtp_servers.pl">Cancel</a> >+ </fieldset> >+ </form> >+[% END %] >+ >+[% IF op == 'edit_form' %] >+ <h3>Edit SMTP server</h3> >+ <form action="/cgi-bin/koha/admin/smtp_servers.pl" id="edit_save" name="edit_save" class="validated" method="post"> >+ <input type="hidden" name="op" value="edit_save" /> >+ <input type="hidden" name="smtp_server_id" value="[%- smtp_server.id | html -%]" /> >+ <fieldset class="rows"> >+ <ol> >+ <li> >+ <label for="smtp_name" class="required">Name: </label> >+ <input type="text" name="smtp_name" id="smtp_name" size="60" class="required" required="required" value="[%- smtp_server.name | html -%]"/> >+ <span class="required">Required</span> >+ </li> >+ </ol> >+ </fieldset> >+ >+ <fieldset class="rows"> >+ <ol> >+ <li> >+ <label for="smtp_host">Host: </label> >+ <input type="text" name="smtp_host" id="smtp_host" size="60" class="required" value="[%- smtp_server.host | html -%]"/> >+ <span class="required">Required</span> >+ </li> >+ <li> >+ <label for="smtp_port">Port: </label> >+ <input type="text" inputmode="numeric" pattern="[0-9]*" name="smtp_port" id="smtp_port" size="20" class="required" value="[%- smtp_server.port | html -%]"/> >+ <span class="required">Required</span> >+ </li> >+ <li> >+ <label for="smtp_timeout">Timeout (seconds): </label> >+ <input type="text" inputmode="numeric" pattern="[0-9]*" name="smtp_timeout" id="smtp_timeout" size="20" value="[%- smtp_server.timeout | html -%]"/> >+ </li> >+ <li> >+ <label for="smtp_ssl_mode">SSL: </label> >+ <select name="smtp_ssl_mode" id="smtp_ssl_mode"> >+ [%- IF smtp_server.ssl_mode == 'disabled' -%] >+ <option value="disabled" selected="selected">Disabled</option> >+ <option value="ssl">SSL</option> >+ <option value="starttls">STARTTLS</option> >+ [%- ELSIF smtp_server.ssl_mode == 'ssl' -%] >+ <option value="disabled">Disabled</option> >+ <option value="ssl" selected="selected">SSL</option> >+ <option value="starttls">STARTTLS</option> >+ [%- ELSE -%] >+ <option value="disabled">Disabled</option> >+ <option value="ssl">SSL</option> >+ <option value="starttls" selected="selected">STARTTLS</option> >+ [%- END -%] >+ </select> >+ </li> >+ <li> >+ <label for="smtp_user_name">User name: </label> >+ <input type="text" name="smtp_user_name" id="smtp_user_name" size="60" value="[%- smtp_server.user_name | html -%]"/> >+ </li> >+ <li> >+ <label for="smtp_password">Password: </label> >+ <input type="password" name="smtp_password" id="smtp_password" size="60" value="[%- smtp_server.password | html -%]"/> >+ </li> >+ <li> >+ <label for="smtp_debug_mode">Debug mode: </label> >+ <select name="smtp_debug_mode" id="smtp_debug_mode"> >+ [%- IF smtp_server.debug == 1 -%] >+ <option value="1" selected="selected">Enabled</option> >+ <option value="0">Disabled</option> >+ [%- ELSE -%] >+ <option value="1">Enabled</option> >+ <option value="0" selected="selected">Disabled</option> >+ [%- END -%] >+ </select> >+ </li> >+ </ol> >+ </fieldset> >+ <fieldset class="action"> >+ <input type="submit" value="Submit" /> >+ <a class="cancel" href="/cgi-bin/koha/admin/smtp_servers.pl">Cancel</a> >+ </fieldset> >+ </form> >+[% END %] >+ >+[% IF op == 'list' %] >+ >+ <div id="toolbar" class="btn-toolbar"> >+ <a class="btn btn-default" id="new_smtp_server" href="/cgi-bin/koha/admin/smtp_servers.pl?op=add_form"><i class="fa fa-plus"></i> New SMTP server</a> >+ </div> >+ >+ <h3>SMTP servers</h3> >+ >+ <div class="dialog message" id="default_server_message"> >+ <p>Default configuration:</p> >+ >+ <ul> >+ <li><strong>Host</strong>: [%- default_config.host | html -%]</li> >+ <li><strong>Port</strong>: [%- default_config.port | html -%]</li> >+ <li><strong>Timeout (secs)</strong>: [%- default_config.timeout | html -%]</li> >+ <li><strong>SSL</strong>: [%- IF default_config.ssl_mode == 'disabled' -%]Disabled[%- ELSIF default_config.ssl_mode == 'ssl' -%]SSL[%- ELSE -%]STARTTLS[%- END -%]</li> >+ <li><strong>Debug mode</strong>: [%- IF default_config.debug -%]Yes[%- ELSE -%]No[%- END -%]</li> >+ </ul> >+ </div> >+ >+ [% IF servers_count > 0 %] >+ <table id="smtp_servers"> >+ <thead> >+ <tr> >+ <th>Name</th> >+ <th>Host</th> >+ <th>Port</th> >+ <th>Timeout (secs)</th> >+ <th>SSL</th> >+ <th>Authenticated</th> >+ <th data-class-name="actions">Actions</th> >+ </tr> >+ </thead> >+ </table> >+ [% END %] >+[% END %] >+ >+ <div id="delete_confirm_modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="delete_confirm_modal_label" aria-hidden="true"> >+ <div class="modal-dialog"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">Ã</button> >+ <h3 id="delete_confirm_modal_label">Delete server</h3> >+ </div> >+ <div class="modal-body"> >+ <div id="delete_confirm_dialog"></div> >+ </div> >+ <div class="modal-footer"> >+ <a href="#" class="btn btn-default" id="delete_confirm_modal_button" role="button" data-toggle="modal">Delete</a> >+ <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button> >+ </div> >+ </div> <!-- /.modal-content --> >+ </div> <!-- /.modal-dialog --> >+ </div> <!-- #delete_confirm_modal --> >+ >+ </main> >+ </div> <!-- /.col-sm-10.col-sm-push-2 --> >+ >+ <div class="col-sm-2 col-sm-pull-10"> >+ <aside> >+ [% INCLUDE 'admin-menu.inc' %] >+ </aside> >+ </div> <!-- /.col-sm-2.col-sm-pull-10 --> >+ </div> <!-- /.row --> >+ >+ >+[% MACRO jsinclude BLOCK %] >+ [% Asset.js("js/admin-menu.js") | $raw %] >+ [% INCLUDE 'datatables.inc' %] >+ <script> >+ $(document).ready(function() { >+ >+ var smtp_servers_url = '/api/v1/config/smtp_servers'; >+ window.smtp_servers = $("#smtp_servers").api({ >+ "ajax": { >+ "url": smtp_servers_url >+ }, >+ 'language': { >+ 'emptyTable': '<div class="dialog message">'+_("There are no SMTP servers defined.")+'</div>' >+ }, >+ "columnDefs": [ { >+ "targets": [0,1], >+ "render": function (data, type, row, meta) { >+ if ( type == 'display' ) { >+ if ( data != null ) { >+ return data.escapeHtml(); >+ } >+ else { >+ return "Default"; >+ } >+ } >+ return data; >+ } >+ } ], >+ "columns": [ >+ { >+ "data": "name", >+ "searchable": true, >+ "orderable": true >+ }, >+ { >+ "data": "host", >+ "searchable": true, >+ "orderable": true >+ }, >+ { >+ "data": "port", >+ "searchable": true, >+ "orderable": false >+ }, >+ { >+ "data": "timeout", >+ "searchable": true, >+ "orderable": false >+ }, >+ { >+ "data": "ssl_mode", >+ "render": function (data, type, row, meta) { >+ if (data == 'disabled') { >+ return _("Disabled"); >+ } >+ else if (data == 'ssl') { >+ return _("SSL"); >+ } >+ else { >+ return _("STARTTLS"); >+ } >+ }, >+ "searchable": false, >+ "orderable": false >+ }, >+ { >+ "data": function( row, type, val, meta ) { >+ if ( row.user_name != null ) { >+ return _("Yes"); >+ } >+ else { >+ return _("No"); >+ } >+ }, >+ "searchable": false, >+ "orderable": false >+ }, >+ { >+ "data": function( row, type, val, meta ) { >+ var result = '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/admin/smtp_servers.pl?op=edit_form&smtp_server_id='+ encodeURIComponent(row.smtp_server_id) +'"><i class="fa fa-pencil" aria-hidden="true"></i> '+_("Edit")+'</a>'+"\n"; >+ result += '<a class="btn btn-default btn-xs delete_server" role="button" href="#" data-toggle="modal" data-target="#delete_confirm_modal" data-smtp-server-id="'+ encodeURIComponent(row.smtp_server_id) +'" data-smtp-server-name="'+ encodeURIComponent(row.name.escapeHtml()) +'"><i class="fa fa-trash" aria-hidden="true"></i>'+_("Delete")+'</a>'; >+ return result; >+ }, >+ "searchable": false, >+ "orderable": false >+ } >+ ] >+ }); >+ >+ $('#smtp_servers').on( "click", '.delete_server', function () { >+ var smtp_server_id = $(this).data('smtp-server-id'); >+ var smtp_server_name = decodeURIComponent($(this).data('smtp-server-name')); >+ >+ $("#delete_confirm_dialog").html( >+ _("You are about to delete the '%s' SMTP server.").format(smtp_server_name) >+ ); >+ >+ $("#delete_confirm_modal_button").on( "click", function () { >+ $.ajax({ >+ method: "DELETE", >+ url: "/api/v1/config/smtp_servers/"+smtp_server_id >+ }).success(function() { >+ $("#delete_confirm_modal").modal('hide'); >+ window.smtp_servers.api().ajax.reload(function (data) { >+ if (data.recordsTotal == 0) { >+ $("#smtp_servers_wrapper").hide(); >+ } >+ $("#smtp_action_result_dialog").hide(); >+ $("#smtp_delete_success").html(_("Server '%s' deleted successfully.").format(smtp_server_name)).show(); >+ }); >+ }).error(function () { >+ $("#smtp_delete_error").html(_("Error deleting server '%s'. Check the logs.").format(smtp_server_name)).show(); >+ }); >+ }); >+ }); >+ }); >+ </script> >+[% END %] >+ >+[% INCLUDE 'intranet-bottom.inc' %] >-- >2.28.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 22343
:
107598
|
107599
|
107600
|
107601
|
107602
|
107603
|
107604
|
107605
|
107987
|
107988
|
107989
|
107990
|
107991
|
107992
|
107993
|
107994
|
107995
|
107996
|
107997
|
107998
|
107999
|
108009
|
108107
|
108108
|
108109
|
108110
|
108111
|
108112
|
108113
|
108114
|
108115
|
108116
|
108117
|
108118
|
108119
|
108131
|
108132
|
108133
|
108134
|
108135
|
108136
|
108137
|
108138
|
108139
|
108140
|
108141
|
108142
|
108143
|
108529
|
108537
|
108538
|
108539
|
108540
|
108541
|
108542
|
108543
|
108544
|
108545
|
108546
|
108547
|
108548
|
108549
|
108609
|
108638
|
108642
|
108643
|
108644
|
108645
|
108646
|
108647
|
108648
|
108649
|
108650
|
108651
|
108652
|
108653
|
108654
|
108655
|
108656
|
108715
|
108716
|
109003
|
109004
|
109005
|
109006
|
109007
|
109008
|
109009
|
109010
|
109011
|
109012
|
109013
|
109014
|
109015
|
109016
|
109017
|
109018
|
109155
|
109156
|
109157
|
109158
|
109159
|
109160
|
109161
|
109162
|
109163
|
109164
|
109165
|
109166
|
109167
|
109168
|
109169
|
109170
|
109601
|
109602
|
109603
|
109604
|
109605
|
109606
|
109607
|
109608
|
109609
|
109610
|
109611
|
109612
|
109613
|
109614
|
109615
|
109616
|
109723
|
109724
|
109725
|
109726
|
109727
|
109728
|
109729
|
109730
|
109731
|
109732
|
109733
|
109734
|
109735
|
109736
|
109737
|
109738
|
109739
|
109740
|
109787
|
109788
|
111048
|
111087
|
111088
|
111089
|
111090
|
111154
|
111165
|
111166
|
111175
|
111176
|
111213
|
111215
|
111216
|
111442
|
111482
|
113240
|
113827
|
113847