Line 0
Link Here
|
0 |
- |
1 |
[% USE raw %] |
|
|
2 |
[% USE Asset %] |
3 |
[% SET footerjs = 1 %] |
4 |
[% INCLUDE 'doc-head-open.inc' %] |
5 |
<title>Koha › |
6 |
Administration › |
7 |
SMTP servers |
8 |
[% IF op == 'add_form' %] |
9 |
› New SMTP server |
10 |
[% ELSIF op == 'edit_form' %] |
11 |
› Edit SMTP server |
12 |
[% END %] |
13 |
</title> |
14 |
[% INCLUDE 'doc-head-close.inc' %] |
15 |
</head> |
16 |
|
17 |
<body id="admin_smtp_servers" class="admin"> |
18 |
[% INCLUDE 'header.inc' %] |
19 |
[% INCLUDE 'prefs-admin-search.inc' %] |
20 |
|
21 |
<div id="breadcrumbs"> |
22 |
<a href="/cgi-bin/koha/mainpage.pl">Home</a> › |
23 |
<a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> › |
24 |
<a href="/cgi-bin/koha/admin/smtp_servers.pl">SMTP servers</a> |
25 |
[% IF op == 'add_form' %] |
26 |
› <span> New</span> |
27 |
[% ELSIF op == 'edit_form' %] |
28 |
› <span> Edit</span> |
29 |
[% END %] |
30 |
</div> |
31 |
|
32 |
<div class="main container-fluid"> |
33 |
<div class="row"> |
34 |
<div class="col-sm-10 col-sm-push-2"> |
35 |
<main> |
36 |
|
37 |
[% FOREACH m IN messages %] |
38 |
<div class="dialog [% m.type | html %]" id="smtp_action_result_dialog"> |
39 |
[% SWITCH m.code %] |
40 |
[% CASE 'error_on_update' %] |
41 |
An error occurred trying to open the server for editing. The passed id is invalid. |
42 |
[% CASE 'error_on_insert' %] |
43 |
An error occurred when adding the server. The library already has an SMTP server set. |
44 |
[% CASE 'success_on_update' %] |
45 |
Server updated successfully. |
46 |
[% CASE 'success_on_insert' %] |
47 |
Server added successfully. |
48 |
[% CASE %] |
49 |
[% m.code | html %] |
50 |
[% END %] |
51 |
</div> |
52 |
[% END %] |
53 |
|
54 |
<div class="dialog message" id="smtp_delete_success" style="display: none;"></div> |
55 |
<div class="dialog alert" id="smtp_delete_error" style="display: none;"></div> |
56 |
|
57 |
[% IF op == 'add_form' %] |
58 |
<h3>New SMTP server</h3> |
59 |
<form action="/cgi-bin/koha/admin/smtp_servers.pl" id="add" name="add" class="validated" method="post"> |
60 |
<input type="hidden" name="op" value="add" /> |
61 |
<fieldset class="rows"> |
62 |
<ol> |
63 |
<li> |
64 |
<label for="smtp_name" class="required">Name: </label> |
65 |
<input type="text" name="smtp_name" id="smtp_name" size="60" class="required" required="required" /> |
66 |
<span class="required">Required</span> |
67 |
</li> |
68 |
</ol> |
69 |
</fieldset> |
70 |
|
71 |
<fieldset class="rows"> |
72 |
<ol> |
73 |
<li> |
74 |
<label for="smtp_host">Host: </label> |
75 |
<input type="text" name="smtp_host" id="smtp_host" size="60" class="required"/> |
76 |
<span class="required">Required</span> |
77 |
</li> |
78 |
<li> |
79 |
<label for="smtp_port">Port: </label> |
80 |
<input type="text" inputmode="numeric" pattern="[0-9]*" value="25" name="smtp_port" id="smtp_port" size="20" class="required"/> |
81 |
<span class="required">Required</span> |
82 |
</li> |
83 |
<li> |
84 |
<label for="smtp_timeout">Timeout (seconds): </label> |
85 |
<input type="text" inputmode="numeric" pattern="[0-9]*" value="120" name="smtp_timeout" id="smtp_timeout" size="20" /> |
86 |
</li> |
87 |
<li> |
88 |
<label for="smtp_ssl_mode">SSL: </label> |
89 |
<select name="smtp_ssl_mode" id="smtp_ssl_mode"> |
90 |
<option value="disabled" selected="selected">Disabled</option> |
91 |
<option value="ssl">SSL</option> |
92 |
<option value="starttls">STARTTLS</option> |
93 |
</select> |
94 |
</li> |
95 |
<li> |
96 |
<label for="smtp_user_name">User name: </label> |
97 |
<input type="text" name="smtp_user_name" id="smtp_user_name" size="60" /> |
98 |
</li> |
99 |
<li> |
100 |
<label for="smtp_password">Password: </label> |
101 |
<input type="password" name="smtp_password" id="smtp_password" size="60" /> |
102 |
</li> |
103 |
<li> |
104 |
<label for="smtp_debug_mode">Debug mode: </label> |
105 |
<select name="smtp_debug_mode" id="smtp_debug_mode"> |
106 |
<option value="1">Enabled</option> |
107 |
<option value="0" selected="selected">Disabled</option> |
108 |
</select> |
109 |
</li> |
110 |
</ol> |
111 |
</fieldset> |
112 |
<fieldset class="action"> |
113 |
<input type="submit" value="Submit" /> |
114 |
<a class="cancel" href="/cgi-bin/koha/admin/smtp_servers.pl">Cancel</a> |
115 |
</fieldset> |
116 |
</form> |
117 |
[% END %] |
118 |
|
119 |
[% IF op == 'edit_form' %] |
120 |
<h3>Edit SMTP server</h3> |
121 |
<form action="/cgi-bin/koha/admin/smtp_servers.pl" id="edit_save" name="edit_save" class="validated" method="post"> |
122 |
<input type="hidden" name="op" value="edit_save" /> |
123 |
<input type="hidden" name="smtp_server_id" value="[%- smtp_server.id | html -%]" /> |
124 |
<fieldset class="rows"> |
125 |
<ol> |
126 |
<li> |
127 |
<label for="smtp_name" class="required">Name: </label> |
128 |
<input type="text" name="smtp_name" id="smtp_name" size="60" class="required" required="required" value="[%- smtp_server.name | html -%]"/> |
129 |
<span class="required">Required</span> |
130 |
</li> |
131 |
</ol> |
132 |
</fieldset> |
133 |
|
134 |
<fieldset class="rows"> |
135 |
<ol> |
136 |
<li> |
137 |
<label for="smtp_host">Host: </label> |
138 |
<input type="text" name="smtp_host" id="smtp_host" size="60" class="required" value="[%- smtp_server.host | html -%]"/> |
139 |
<span class="required">Required</span> |
140 |
</li> |
141 |
<li> |
142 |
<label for="smtp_port">Port: </label> |
143 |
<input type="text" inputmode="numeric" pattern="[0-9]*" name="smtp_port" id="smtp_port" size="20" class="required" value="[%- smtp_server.port | html -%]"/> |
144 |
<span class="required">Required</span> |
145 |
</li> |
146 |
<li> |
147 |
<label for="smtp_timeout">Timeout (seconds): </label> |
148 |
<input type="text" inputmode="numeric" pattern="[0-9]*" name="smtp_timeout" id="smtp_timeout" size="20" value="[%- smtp_server.timeout | html -%]"/> |
149 |
</li> |
150 |
<li> |
151 |
<label for="smtp_ssl_mode">SSL: </label> |
152 |
<select name="smtp_ssl_mode" id="smtp_ssl_mode"> |
153 |
[%- IF smtp_server.ssl_mode == 'disabled' -%] |
154 |
<option value="disabled" selected="selected">Disabled</option> |
155 |
<option value="ssl">SSL</option> |
156 |
<option value="starttls">STARTTLS</option> |
157 |
[%- ELSIF smtp_server.ssl_mode == 'ssl' -%] |
158 |
<option value="disabled">Disabled</option> |
159 |
<option value="ssl" selected="selected">SSL</option> |
160 |
<option value="starttls">STARTTLS</option> |
161 |
[%- ELSE -%] |
162 |
<option value="disabled">Disabled</option> |
163 |
<option value="ssl">SSL</option> |
164 |
<option value="starttls" selected="selected">STARTTLS</option> |
165 |
[%- END -%] |
166 |
</select> |
167 |
</li> |
168 |
<li> |
169 |
<label for="smtp_user_name">User name: </label> |
170 |
<input type="text" name="smtp_user_name" id="smtp_user_name" size="60" value="[%- smtp_server.user_name | html -%]"/> |
171 |
</li> |
172 |
<li> |
173 |
<label for="smtp_password">Password: </label> |
174 |
<input type="password" name="smtp_password" id="smtp_password" size="60" value="[%- smtp_server.password | html -%]"/> |
175 |
</li> |
176 |
<li> |
177 |
<label for="smtp_debug_mode">Debug mode: </label> |
178 |
<select name="smtp_debug_mode" id="smtp_debug_mode"> |
179 |
[%- IF smtp_server.debug == 1 -%] |
180 |
<option value="1" selected="selected">Enabled</option> |
181 |
<option value="0">Disabled</option> |
182 |
[%- ELSE -%] |
183 |
<option value="1">Enabled</option> |
184 |
<option value="0" selected="selected">Disabled</option> |
185 |
[%- END -%] |
186 |
</select> |
187 |
</li> |
188 |
</ol> |
189 |
</fieldset> |
190 |
<fieldset class="action"> |
191 |
<input type="submit" value="Submit" /> |
192 |
<a class="cancel" href="/cgi-bin/koha/admin/smtp_servers.pl">Cancel</a> |
193 |
</fieldset> |
194 |
</form> |
195 |
[% END %] |
196 |
|
197 |
[% IF op == 'list' %] |
198 |
|
199 |
<div id="toolbar" class="btn-toolbar"> |
200 |
<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> |
201 |
</div> |
202 |
|
203 |
<h3>SMTP servers</h3> |
204 |
|
205 |
<div class="dialog message" id="default_server_message"> |
206 |
<p>Default configuration:</p> |
207 |
|
208 |
<ul> |
209 |
<li><strong>Host</strong>: [%- default_config.host | html -%]</li> |
210 |
<li><strong>Port</strong>: [%- default_config.port | html -%]</li> |
211 |
<li><strong>Timeout (secs)</strong>: [%- default_config.timeout | html -%]</li> |
212 |
<li><strong>SSL</strong>: [%- IF default_config.ssl_mode == 'disabled' -%]Disabled[%- ELSIF default_config.ssl_mode == 'ssl' -%]SSL[%- ELSE -%]STARTTLS[%- END -%]</li> |
213 |
<li><strong>Debug mode</strong>: [%- IF default_config.debug -%]Yes[%- ELSE -%]No[%- END -%]</li> |
214 |
</ul> |
215 |
</div> |
216 |
|
217 |
[% IF servers_count > 0 %] |
218 |
<table id="smtp_servers"> |
219 |
<thead> |
220 |
<tr> |
221 |
<th>Name</th> |
222 |
<th>Host</th> |
223 |
<th>Port</th> |
224 |
<th>Timeout (secs)</th> |
225 |
<th>SSL</th> |
226 |
<th>Authenticated</th> |
227 |
<th data-class-name="actions">Actions</th> |
228 |
</tr> |
229 |
</thead> |
230 |
</table> |
231 |
[% END %] |
232 |
[% END %] |
233 |
|
234 |
<div id="delete_confirm_modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="delete_confirm_modal_label" aria-hidden="true"> |
235 |
<div class="modal-dialog"> |
236 |
<div class="modal-content"> |
237 |
<div class="modal-header"> |
238 |
<button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button> |
239 |
<h3 id="delete_confirm_modal_label">Delete server</h3> |
240 |
</div> |
241 |
<div class="modal-body"> |
242 |
<div id="delete_confirm_dialog"></div> |
243 |
</div> |
244 |
<div class="modal-footer"> |
245 |
<a href="#" class="btn btn-default" id="delete_confirm_modal_button" role="button" data-toggle="modal">Delete</a> |
246 |
<button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button> |
247 |
</div> |
248 |
</div> <!-- /.modal-content --> |
249 |
</div> <!-- /.modal-dialog --> |
250 |
</div> <!-- #delete_confirm_modal --> |
251 |
|
252 |
</main> |
253 |
</div> <!-- /.col-sm-10.col-sm-push-2 --> |
254 |
|
255 |
<div class="col-sm-2 col-sm-pull-10"> |
256 |
<aside> |
257 |
[% INCLUDE 'admin-menu.inc' %] |
258 |
</aside> |
259 |
</div> <!-- /.col-sm-2.col-sm-pull-10 --> |
260 |
</div> <!-- /.row --> |
261 |
|
262 |
|
263 |
[% MACRO jsinclude BLOCK %] |
264 |
[% Asset.js("js/admin-menu.js") | $raw %] |
265 |
[% INCLUDE 'datatables.inc' %] |
266 |
<script> |
267 |
$(document).ready(function() { |
268 |
|
269 |
var smtp_servers_url = '/api/v1/config/smtp_servers'; |
270 |
window.smtp_servers = $("#smtp_servers").api({ |
271 |
"ajax": { |
272 |
"url": smtp_servers_url |
273 |
}, |
274 |
'language': { |
275 |
'emptyTable': '<div class="dialog message">'+_("There are no SMTP servers defined.")+'</div>' |
276 |
}, |
277 |
"columnDefs": [ { |
278 |
"targets": [0,1], |
279 |
"render": function (data, type, row, meta) { |
280 |
if ( type == 'display' ) { |
281 |
if ( data != null ) { |
282 |
return data.escapeHtml(); |
283 |
} |
284 |
else { |
285 |
return "Default"; |
286 |
} |
287 |
} |
288 |
return data; |
289 |
} |
290 |
} ], |
291 |
"columns": [ |
292 |
{ |
293 |
"data": "name", |
294 |
"searchable": true, |
295 |
"orderable": true |
296 |
}, |
297 |
{ |
298 |
"data": "host", |
299 |
"searchable": true, |
300 |
"orderable": true |
301 |
}, |
302 |
{ |
303 |
"data": "port", |
304 |
"searchable": true, |
305 |
"orderable": false |
306 |
}, |
307 |
{ |
308 |
"data": "timeout", |
309 |
"searchable": true, |
310 |
"orderable": false |
311 |
}, |
312 |
{ |
313 |
"data": "ssl_mode", |
314 |
"render": function (data, type, row, meta) { |
315 |
if (data == 'disabled') { |
316 |
return _("Disabled"); |
317 |
} |
318 |
else if (data == 'ssl') { |
319 |
return _("SSL"); |
320 |
} |
321 |
else { |
322 |
return _("STARTTLS"); |
323 |
} |
324 |
}, |
325 |
"searchable": false, |
326 |
"orderable": false |
327 |
}, |
328 |
{ |
329 |
"data": function( row, type, val, meta ) { |
330 |
if ( row.user_name != null ) { |
331 |
return _("Yes"); |
332 |
} |
333 |
else { |
334 |
return _("No"); |
335 |
} |
336 |
}, |
337 |
"searchable": false, |
338 |
"orderable": false |
339 |
}, |
340 |
{ |
341 |
"data": function( row, type, val, meta ) { |
342 |
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"; |
343 |
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>'; |
344 |
return result; |
345 |
}, |
346 |
"searchable": false, |
347 |
"orderable": false |
348 |
} |
349 |
] |
350 |
}); |
351 |
|
352 |
$('#smtp_servers').on( "click", '.delete_server', function () { |
353 |
var smtp_server_id = $(this).data('smtp-server-id'); |
354 |
var smtp_server_name = decodeURIComponent($(this).data('smtp-server-name')); |
355 |
|
356 |
$("#delete_confirm_dialog").html( |
357 |
_("You are about to delete the '%s' SMTP server.").format(smtp_server_name) |
358 |
); |
359 |
|
360 |
$("#delete_confirm_modal_button").on( "click", function () { |
361 |
$.ajax({ |
362 |
method: "DELETE", |
363 |
url: "/api/v1/config/smtp_servers/"+smtp_server_id |
364 |
}).success(function() { |
365 |
$("#delete_confirm_modal").modal('hide'); |
366 |
window.smtp_servers.api().ajax.reload(function (data) { |
367 |
if (data.recordsTotal == 0) { |
368 |
$("#smtp_servers_wrapper").hide(); |
369 |
} |
370 |
$("#smtp_action_result_dialog").hide(); |
371 |
$("#smtp_delete_success").html(_("Server '%s' deleted successfully.").format(smtp_server_name)).show(); |
372 |
}); |
373 |
}).error(function () { |
374 |
$("#smtp_delete_error").html(_("Error deleting server '%s'. Check the logs.").format(smtp_server_name)).show(); |
375 |
}); |
376 |
}); |
377 |
}); |
378 |
}); |
379 |
</script> |
380 |
[% END %] |
381 |
|
382 |
[% INCLUDE 'intranet-bottom.inc' %] |