Bug 35650: (follow-up) Other cases found
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / identity_provider_domains.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Branches %]
4 [% USE Categories %]
5 [% PROCESS 'i18n.inc' %]
6 [% SET footerjs = 1 %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>[% FILTER collapse %]
9     [% IF op == 'add_form' %]
10         [% t("New identity provider domain") | html %] &rsaquo;
11     [% ELSIF op == 'edit_form' %]
12         [% tx("Modify identity provider domain '{domain}'", {domain = identity_provider_domain.domain}) | html %] &rsaquo;
13     [% END %]
14     [% tx("Identity provider domains for '{identity_provider_code}'", {identity_provider_code = identity_provider_code}) | html %] &rsaquo;
15     [% t("Identity providers") | html %] &rsaquo;
16     [% t("Administration") | html %] &rsaquo;
17     [% t("Koha") | html %]
18 [% END %]</title>
19 [% INCLUDE 'doc-head-close.inc' %]
20 </head>
21
22 <body id="admin_identity_provider_domains" class="admin">
23 [% INCLUDE 'header.inc' %]
24 [% INCLUDE 'prefs-admin-search.inc' %]
25
26 [% WRAPPER 'sub-header.inc' %]
27     [% WRAPPER breadcrumbs %]
28         [% WRAPPER breadcrumb_item %]
29             <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
30         [% END %]
31
32         [% WRAPPER breadcrumb_item %]
33             <a href="/cgi-bin/koha/admin/identity_providers.pl">Identity providers</a>
34         [% END %]
35
36         [% IF op == 'add_form' %]
37             [% WRAPPER breadcrumb_item %]
38                 <a href="/cgi-bin/koha/admin/identity_providers.pl?domain_ops=1&amp;identity_provider_id=[%- identity_provider_id | uri -%]">[% tx("Domains for '{identity_provider_code}'", {identity_provider_code = identity_provider_code}) | html %]</a>
39             [% END %]
40             [% WRAPPER breadcrumb_item bc_active= 1 %]
41                 <span>New identity provider domain</span>
42             [% END %]
43
44         [% ELSIF op == 'edit_form' %]
45             [% WRAPPER breadcrumb_item %]
46                 <a href="/cgi-bin/koha/admin/identity_providers.pl?domain_ops=1&amp;identity_provider_id=[%- identity_provider_id | uri -%]">[% tx("Domains for '{identity_provider_code}'", {identity_provider_code = identity_provider_code}) | html %]</a>
47             [% END %]
48             [% WRAPPER breadcrumb_item bc_active= 1 %]
49                 [% tx("Modify identity provider domain '{domain}'", {domain = identity_provider_domain.domain}) | html %]
50             [% END %]
51
52         [% ELSE %]
53             [% WRAPPER breadcrumb_item bc_active= 1 %]
54                 <span>[% tx("Domains for '{identity_provider_code}'", {identity_provider_code = identity_provider_code}) | html %]</span>
55             [% END %]
56         [% END %]
57     [% END #/ WRAPPER breadcrumbs %]
58 [% END #/ WRAPPER sub-header.inc %]
59
60 <div class="main container-fluid">
61     <div class="row">
62         <div class="col-sm-10 col-sm-push-2">
63             <main>
64
65 [% FOREACH m IN messages %]
66     <div class="dialog [% m.type | html %]" id="identity_provider_domain_action_result_dialog">
67         [% SWITCH m.code %]
68         [% CASE 'error_on_update' %]
69             <span>An error occurred trying to open the identity provider domain for editing. The passed ID is invalid.</span>
70         [% CASE 'error_on_insert' %]
71             <span>An error occurred when adding a new identity provider domain. Check the logs for details.</span>
72         [% CASE 'success_on_update' %]
73             <span>Identity provider domain updated successfully.</span>
74         [% CASE 'success_on_insert' %]
75             <span>Identity provider domain added successfully.</span>
76         [% CASE %]
77             <span>[% m.code | html %]</span>
78         [% END %]
79     </div>
80 [% END %]
81
82     <div class="dialog message" id="identity_provider_domain_delete_success" style="display: none;"></div>
83     <div class="dialog alert"   id="identity_provider_domain_delete_error"   style="display: none;"></div>
84
85 [% IF op == 'add_form' %]
86     <h1>[% tx("New identity provider domain for '{identity_provider_code}'", {identity_provider_code = identity_provider_code}) | html %]</h1>
87
88         <form action="/cgi-bin/koha/admin/identity_providers.pl" id="add" name="add" class="validated" method="post">
89             <input type="hidden" name="op" value="add" />
90             <input type="hidden" name="domain_ops" value="1" />
91             <input type="hidden" name="identity_provider_id" value="[%- identity_provider_id | html -%]" />
92             <fieldset class="rows">
93                 <ol>
94                     <li>
95                         <label for="domain">Domain: </label>
96                         <input type="text" name="domain" id="domain" size="60" />
97                         <div class="hint">Email domain to match this rule. <button class="more btn btn-ligth" data-target="domain"><i class="fa fa-caret-down"></i> More</button></div>
98                         <div class="hint more-domain" style="display: none">
99                             <p>If this field is empty, or '*' any email domain will match this rule.</p>
100                             <p>You may enter a wildcard at the beginning of the domain. For example, the domain '*library.com' will match 'students.library.com' but will also match 'otherlibrary.com'</p>
101                             <p>Exact matches have precedence over wildcard ones, so 'library.com' domain will take precedence over '*library.com' when the email is 'somebody@library.com'</p>
102                             <p>The same way, the longest match will take precedence over the shorter one, so '*teacher.university.com' will take precedence over '*.university.com' if the email is 'user@math.teacher.university.com'</p>
103                         </div>
104                     </li>
105                     <li>
106                         <label for="update_on_auth">Update on login: </label>
107                         <select name="update_on_auth" id="update_on_auth">
108                             <option value="1">Update</option>
109                             <option value="0" selected="selected">Don't update</option>
110                         </select>
111                         <span>user data on login</span>
112                     </li>
113                     <li>
114                         <label for="auto_register">Auto register: </label>
115                         <select name="auto_register" id="auto_register">
116                             <option value="1">Allow</option>
117                             <option value="0" selected="selected">Don't allow</option>
118                         </select>
119                         <span>users to auto register on login</span>
120                     </li>
121                     <li>
122                         <label for="default_library_id">Default library: </label>
123                         <select id="default_library_id" name="default_library_id">
124                             <option value="">None</option>
125                             [% PROCESS options_for_libraries libraries => Branches.all( unfiltered => 1, do_not_select_my_library => 1 ) %]
126                         </select>
127                         <div class="hint">Use this library for the patron on auto register</div>
128                     </li>
129                     <li>
130                         <label for="default_category_id">Default category: </label>
131                         [% SET categories = Categories.all() %]
132                         <select name="default_category_id" id="default_category_id">
133                             <option value="">None</option>
134                             [% FOREACH category IN categories %]
135                                 <option value="[% category.categorycode | html %]">[% category.description | html %]</option>
136                             [% END %]
137                         </select>
138                         <div class="hint">Use this category for the patron on auto register</div>
139                     </li>
140                     <li>
141                         <label for="allow_opac">Allow OPAC: </label>
142                         <select name="allow_opac" id="allow_opac">
143                             <option value="1" selected="selected">Allow</option>
144                             <option value="0">Don't allow</option>
145                         </select>
146                         <span>OPAC users from this domain to login with this identity provider.</span>
147                     </li>
148                     <li>
149                         <label for="allow_staff">Allow staff: </label>
150                         <select name="allow_staff" id="allow_staff">
151                             <option value="1">Allow</option>
152                             <option value="0" selected="selected">Don't allow</option>
153                         </select>
154                         <span>of this domain to login with this identity provider</span>
155                     </li>
156                 </ol>
157             </fieldset>
158             <fieldset class="action">
159                 <input type="submit" value="Submit" />
160                 <a class="cancel" href="/cgi-bin/koha/admin/identity_providers.pl?domain_ops=1&amp;identity_provider_id=[%- identity_provider_id | html -%]">Cancel</a>
161             </fieldset>
162         </form>
163
164 [% END %]
165
166 [% IF op == 'edit_form' %]
167     <h1>[% tx("Modify identity provider domain '{domain}'", {domain = identity_provider_domain.domain}) | html %]</h1>
168
169         <form action="/cgi-bin/koha/admin/identity_providers.pl" id="edit_save" name="edit_save" class="validated" method="post">
170             <input type="hidden" name="op" value="edit_save" />
171             <input type="hidden" name="domain_ops" value="1" />
172             <input type="hidden" name="identity_provider_id" value="[%- identity_provider_id | html -%]" />
173             <input type="hidden" name="identity_provider_domain_id" value="[%- identity_provider_domain.identity_provider_domain_id | html -%]" />
174             <fieldset class="rows">
175                 <ol>
176                     <li>
177                         <label for="domain">Domain: </label>
178                         <input type="text" name="domain" id="domain" size="60" value="[%- identity_provider_domain.domain | html -%]"/>
179                         <div class="hint">Email domain to match this rule. <button class="more btn btn-ligth" data-target="domain"><i class="fa fa-caret-down"></i> More</button></div>
180                         <div class="hint more-domain" style="display: none">
181                             <p>If this field is empty, or '*' any email domain will match this rule.</p>
182                             <p>You may enter a wildcard at the beginning of the domain. For example, the domain '*library.com' will match 'students.library.com' but will also match 'otherlibrary.com'</p>
183                             <p>Exact matches have precedence over asterix ones, so 'library.com' will take precedence over '*library.com' when the email is 'somebody@library.com'</p>
184                             <p>The same way, the longest match will take precedence over the shorter one, so '*teacher.university.com' will take precedence over '*.university.com' if the email is 'user@math.teacher.university.com'</p>
185                         </div>
186                     </li>
187                     <li>
188                         <label for="update_on_auth">Update on login: </label>
189                         <select name="update_on_auth" id="update_on_auth">
190                         [% IF identity_provider_domain.update_on_auth == "1" %]
191                             <option value="1" selected="selected">Update</option>
192                             <option value="0">Don't update</option>
193                         [% ELSE %]
194                             <option value="1">Update</option>
195                             <option value="0" selected="selected">Don't update</option>
196                         [% END %]
197                         </select>
198                         <span>user data on login</span>
199                     </li>
200                     <li>
201                         <label for="auto_register">Auto register: </label>
202                         <select name="auto_register" id="auto_register">
203                         [% IF identity_provider_domain.auto_register == "1" %]
204                             <option value="1" selected="selected">Allow</option>
205                             <option value="0">Don't allow</option>
206                         [% ELSE %]
207                             <option value="1">Allow</option>
208                             <option value="0" selected="selected">Don't allow</option>
209                         [% END %]
210                         </select>
211                         <span>users to auto register on login</span>
212                     </li>
213                     <li>
214                         <label for="default_library_id">Default library: </label>
215                         <select id="default_library_id" name="default_library_id">
216                             <option value="">None</option>
217                             [% PROCESS options_for_libraries libraries => Branches.all( selected => identity_provider_domain.default_library_id, unfiltered => 1, do_not_select_my_library => 1 ) %]
218                         </select>
219                         <div class="hint">Use this library for the patron on auto register</div>
220                     </li>
221                     <li>
222                         <label for="default_category_id">Default category: </label>
223                         [% SET categories = Categories.all() %]
224                         <select name="default_category_id" id="default_category_id">
225                             <option value="">None</option>
226                             [% FOREACH category IN categories %]
227                                 [% IF category.categorycode == identity_provider_domain.default_category_id %]
228                                     <option value="[% category.categorycode | html %]" selected="selected">[% category.description | html %]</option>
229                                 [% ELSE %]
230                                     <option value="[% category.categorycode | html %]">[% category.description | html %]</option>
231                                 [% END %]
232                             [% END %]
233                         </select>
234                         <div class="hint">Use this category for the patron on auto register</div>
235                     </li>
236                     <li>
237                         <label for="allow_opac">Allow OPAC: </label>
238                         <select name="allow_opac" id="allow_opac">
239                         [% IF identity_provider_domain.allow_opac == "1" %]
240                             <option value="1" selected="selected">Allow</option>
241                             <option value="0">Don't allow</option>
242                         [% ELSE %]
243                             <option value="1">Allow</option>
244                             <option value="0" selected="selected">Don't allow</option>
245                         [% END %]
246                         </select>
247                         <span>OPAC users of this domain to login with this identity provider</span>
248                     </li>
249                     <li>
250                         <label for="allow_staff">Allow staff: </label>
251                         <select name="allow_staff" id="allow_staff">
252                         [% IF identity_provider_domain.allow_staff == "1" %]
253                             <option value="1" selected="selected">Allow</option>
254                             <option value="0">Don't allow</option>
255                         [% ELSE %]
256                             <option value="1">Allow</option>
257                             <option value="0" selected="selected">Don't allow</option>
258                         [% END %]
259                         </select>
260                         <span>staff users of this domain to login with this identity provider</span>
261                     </li>
262                 </ol>
263             </fieldset>
264             <fieldset class="action">
265                 <input type="submit" value="Submit" />
266                 <a class="cancel" href="/cgi-bin/koha/admin/identity_providers.pl?domain_ops=1&amp;identity_provider_id=[%- identity_provider_id | html -%]">Cancel</a>
267             </fieldset>
268         </form>
269
270 [% END %]
271
272 [% IF op == 'list' %]
273
274     <div id="toolbar" class="btn-toolbar">
275         <a class="btn btn-default" id="new_identity_provider_domain" href="/cgi-bin/koha/admin/identity_providers.pl?domain_ops=1&amp;identity_provider_id=[%- identity_provider_id | html -%]&amp;op=add_form"><i class="fa fa-plus"></i> New identity provider domain</a>
276     </div>
277
278     <h1>[% tx("Identity provider domains for '{identity_provider_code}'", {identity_provider_code = identity_provider_code}) | html %]</h1>
279     <div class="page-section">
280         <table id="identity_provider_domains">
281             <thead>
282                 <tr>
283                     <th>Domain</th>
284                     <th>Update on login</th>
285                     <th>Auto register</th>
286                     <th>Default library</th>
287                     <th>Default category</th>
288                     <th>Allow OPAC</th>
289                     <th>Allow staff</th>
290                     <th data-class-name="actions noExport">Actions</th>
291                 </tr>
292             </thead>
293         </table>
294     </div>
295 [% END %]
296
297             <div id="delete_confirm_modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="delete_confirm_modal_label" aria-hidden="true">
298                 <div class="modal-dialog">
299                     <div class="modal-content">
300                         <div class="modal-header">
301                             <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
302                             <h3 id="delete_confirm_modal_label">Confirm deletion of identity provider domain</h3>
303                         </div>
304                         <div class="modal-body">
305                             <div id="delete_confirm_dialog"></div>
306                         </div>
307                         <div class="modal-footer">
308                             <a href="#" class="btn btn-default" id="delete_confirm_modal_button" role="button" data-toggle="modal">Delete</a>
309                             <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
310                         </div>
311                     </div> <!-- /.modal-content -->
312                 </div> <!-- /.modal-dialog -->
313             </div> <!-- #delete_confirm_modal -->
314
315             </main>
316         </div> <!-- /.col-sm-10.col-sm-push-2 -->
317
318         <div class="col-sm-2 col-sm-pull-10">
319             <aside>
320                 [% INCLUDE 'admin-menu.inc' %]
321             </aside>
322         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
323      </div> <!-- /.row -->
324
325
326 [% MACRO jsinclude BLOCK %]
327     [% Asset.js("js/admin-menu.js") | $raw %]
328     [% INCLUDE 'datatables.inc' %]
329     <script>
330         $(document).ready(function() {
331
332             var identity_provider_domains_url = '/api/v1/auth/identity_providers/[%- identity_provider_id | html -%]/domains';
333             [% SET categories = Categories.all() %]
334             var categories = {
335             [% FOREACH category IN categories %]
336                 "[% category.categorycode | html %]": "[% category.description | html %]",
337             [% END %]
338             };
339             [% SET libraries = Branches.all() %]
340             var libraries = {
341             [% FOREACH library IN libraries %]
342                 "[% library.branchcode | html %]": "[% library.branchname | html %]",
343             [% END %]
344             };
345             window.identity_provider_domains = $("#identity_provider_domains").kohaTable({
346                 "ajax": {
347                     "url": identity_provider_domains_url
348                 },
349                 'language': {
350                     'emptyTable': '<div class="dialog message">'+_("There are no identity provider domains defined.")+'</div>'
351                 },
352                 "columnDefs": [ {
353                     "targets": [1],
354                     "render": function (data, type, row, meta) {
355                         if ( type == 'display' ) {
356                             if ( data != null ) {
357                                 return data.escapeHtml();
358                             }
359                             else {
360                                 return "";
361                             }
362                         }
363                         return data;
364                     }
365                 } ],
366                 "columns": [
367                     {
368                         "data": "domain",
369                         "searchable": true,
370                         "orderable": true,
371                         "render": function(data, type, row, meta) {
372                             if ( data != null ) {
373                                 return data.escapeHtml();
374                             }
375                             else {
376                                 return "*";
377                             }
378                         }
379                     },
380                     {
381                         "data": function( row, type, val, meta ) {
382                             if (row.update_on_auth) {
383                                 return _("Yes");
384                             } else {
385                                 return _("No");
386                             }
387                         },
388                         "searchable": true,
389                         "orderable": true
390                     },
391                     {
392                         "data": function( row, type, val, meta ) {
393                             if (row.auto_register) {
394                                 return _("Yes");
395                             } else {
396                                 return _("No");
397                             }
398                         },
399                         "searchable": true,
400                         "orderable": true
401                     },
402                     {
403                         "data": function( row, type, val, meta ) {
404                             return libraries[row.default_library_id] || "";
405                         },
406                         "searchable": true,
407                         "orderable": true
408                     },
409                     {
410                         "data": function( row, type, val, meta ) {
411                             return categories[row.default_category_id] || "";
412                         },
413                         "searchable": true,
414                         "orderable": true
415                     },
416                     {
417                         "data": function( row, type, val, meta ) {
418                             if (row.allow_opac) {
419                                 return _("Yes");
420                             } else {
421                                 return _("No");
422                             }
423                         },
424                         "searchable": true,
425                         "orderable": true
426                     },
427                     {
428                         "data": function( row, type, val, meta ) {
429                             if (row.allow_staff) {
430                                 return _("Yes");
431                             } else {
432                                 return _("No");
433                             }
434                         },
435                         "searchable": true,
436                         "orderable": true
437                     },
438                     {
439                         "data": function( row, type, val, meta ) {
440                             var result = '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/admin/identity_providers.pl?domain_ops=1&amp;identity_provider_id=[%- identity_provider_id | html -%]&amp;op=edit_form&amp;identity_provider_domain_id='+ encodeURIComponent(row.identity_provider_domain_id) +'"><i class="fa-solid fa-pencil" aria-hidden="true"></i> '+_("Edit")+'</a>'+"\n";
441                             result += '<a class="btn btn-default btn-xs delete_identity_provider_domain" role="button" href="#" data-toggle="modal" data-target="#delete_confirm_modal" data-auth-provider-domain-id="'+ encodeURIComponent(row.identity_provider_domain_id) +'" data-auth-provider-domain="'+ encodeURIComponent((row.domain || '').escapeHtml()) +'"><i class="fa fa-trash-can" aria-hidden="true"></i> '+_("Delete")+'</a>';
442                             return result;
443                         },
444                         "searchable": false,
445                         "orderable": false
446                     }
447                 ],
448                 createdRow: function (row, data, dataIndex) {
449                     if ( data.debug ) {
450                         $(row).addClass('debug');
451                     }
452                 },
453             });
454
455             $('#identity_provider_domains').on( "click", '.delete_identity_provider_domain', function () {
456                 var identity_provider_domain_id   = $(this).data('auth-provider-domain-id');
457                 var identity_provider_domain = decodeURIComponent($(this).data('auth-provider-domain'));
458
459                 $("#delete_confirm_dialog").html(
460                     _("You are about to delete the '%s' identity provider domain.").format(identity_provider_domain)
461                 );
462                 $("#delete_confirm_modal_button").data('auth-provider-domain-id', identity_provider_domain_id);
463                 $("#delete_confirm_modal_button").data('auth-provider-domain', identity_provider_domain);
464             });
465
466             $("#delete_confirm_modal_button").on( "click", function () {
467
468                 var identity_provider_domain_id   = $(this).data('auth-provider-domain-id');
469                 var identity_provider_domain = $(this).data('auth-provider-domain');
470
471                 $.ajax({
472                     method: "DELETE",
473                     url: identity_provider_domains_url+"/"+identity_provider_domain_id
474                 }).success(function() {
475                     window.identity_provider_domains.api().ajax.reload(function (data) {
476                         $("#smtp_action_result_dialog").hide();
477                         $("#smtp_delete_success").html(_("Server '%s' deleted successfully.").format(identity_provider_domain)).show();
478                     });
479                 }).fail(function () {
480                     $("#smtp_delete_error").html(_("Error deleting server '%s'. Check the logs for details.").format(identity_provider_domain)).show();
481                 }).done(function () {
482                     $("#delete_confirm_modal").modal('hide');
483                 });
484             });
485
486             $('button.more').on('click', function(event) {
487                 event.preventDefault();
488                 var target = $(this).hide().data('target');
489                 $('.more-'+target).show();
490             });
491         });
492     </script>
493 [% END %]
494
495 [% INCLUDE 'intranet-bottom.inc' %]