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