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