5 [% PROCESS 'permissions.inc' %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Koha › Patrons › Set permissions for [% patron.surname | html %], [% patron.firstname | html %]</title>
8 [% Asset.css("css/treeview/jquery.treeview.css") | $raw %]
9 [% INCLUDE 'doc-head-close.inc' %]
12 <body id="pat_member-flags" class="pat">
13 [% INCLUDE 'header.inc' %]
14 [% INCLUDE 'patron-search.inc' %]
16 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> › Set permissions for [% patron.surname | html %], [% patron.firstname | html %]</div>
18 <div id="doc3" class="yui-t2">
23 [% INCLUDE 'members-toolbar.inc' %]
25 <form method="post" action="/cgi-bin/koha/members/member-flags.pl">
26 <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
27 <input type="hidden" name="member" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
28 <input type="hidden" name="newflags" value="1" />
29 <h1>Set permissions for [% patron.surname | html %], [% patron.firstname | html %]</h1>
30 <!-- <ul id="permissionstree"><li class="root">All privileges<ul> -->
31 <ul id="permissionstree" class="treeview-grey">
32 <!-- <li class="folder-close">One level down<ul> -->
33 [% FOREACH loo IN loop %]
34 [% IF ( loo.expand ) %]
39 [% IF ( loo.checked ) %]
40 [% IF disable_superlibrarian_privs && loo.bit == 0 %]
41 <input type="checkbox" disabled="disabled" class="flag parent superlib" id="flag-[% loo.bit | html %]_disabled" name="flag" value="[% loo.flag | html %]" checked="checked" title="The system preference ProtectSuperlibrarianPrivileges is enabled" />
42 <input type="hidden" id="flag-[% loo.bit | html %]" name="flag" value="[% loo.flag | html %]" >
44 <input type="checkbox" class="flag parent" id="flag-[% loo.bit | html %]" name="flag" value="[% loo.flag | html %]" checked="checked" />
47 [% IF disable_superlibrarian_privs && loo.bit == 0 %]
48 <input type="checkbox" disabled="disabled" class="flag parent" id="flag-[% loo.bit | html %]_disabled" name="flag" value="[% loo.flag | html %]" title="The system preference ProtectSuperlibrarianPrivileges is enabled" />
50 <input type="checkbox" class="flag parent" id="flag-[% loo.bit | html %]" name="flag" value="[% loo.flag | html %]" />
53 <label class="permissioncode" for="flag-[% loo.bit | html %]">[% loo.flag | html %]</label>
54 <span class="permissiondesc">[% PROCESS main_permissions name=loo.flag %]</span>
55 [% IF ( loo.sub_perm_loop ) %]
56 <ul id="flag-[% loo.bit | html %]-children">
57 [% FOREACH sub_perm_loo IN loo.sub_perm_loop %]
59 [% IF ( sub_perm_loo.checked ) %]
60 <input type="checkbox" class="flag child" id="[% sub_perm_loo.id | html %]" name="flag" value="[% sub_perm_loo.perm | html %]" checked="checked" />
62 <input type="checkbox" class="flag child" id="[% sub_perm_loo.id | html %]" name="flag" value="[% sub_perm_loo.perm | html %]" />
64 <label class="permissioncode" for="[% sub_perm_loo.id | html %]">[% sub_perm_loo.code | html %]</label>
65 <span class="permissiondesc">[% PROCESS sub_permissions name=sub_perm_loo.code %]</span>
75 <!-- </ul></li></ul> -->
78 <fieldset class="action"><input type="submit" value="Save" /> <a class="cancel" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a></fieldset>
85 [% INCLUDE 'circ-menu.inc' %]
89 [% MACRO jsinclude BLOCK %]
90 [% INCLUDE 'str/members-menu.inc' %]
91 [% Asset.js("js/members-menu.js") | $raw %]
92 [% Asset.js("lib/jquery/plugins/jquery.treeview.pack.js") | $raw %]
94 <script type="text/javascript">
95 $(document).ready(function() {
96 $("#permissionstree").treeview({animated: "fast", collapsed: true});
98 // Enforce Superlibrarian Privilege Mutual Exclusivity
99 if( $('input[id="flag-0"]:checked').length || $(".superlib:checked").length ){
100 if ($('input[name="flag"]:checked').length > 1){
101 alert(_("Inconsistency detected! The superlibrarian privilege is mutually exclusive of other privileges, as it includes them all. This patron's privileges will now be reset to include only superlibrarian."));
104 $('input[name="flag"]').each(function() {
105 if($(this).attr('id') != "flag-0" && !$(this).hasClass('superlib') ){
106 $(this).prop('disabled', true);
107 $(this).prop('checked', false);
112 $('input#flag-0').click(function() {
113 if( $('input[id="flag-0"]:checked').length || $(".superlib:checked").length ){
114 $('input[name="flag"]').each(function() {
115 if($(this).attr('id') != "flag-0" && !$(this).hasClass('superlib') ){
116 $(this).prop('disabled', true);
117 $(this).prop('checked', false);
122 $('input[name="flag"]').each(function() {
123 $(this).prop('disabled', false);
128 $(".flag").on("change",function(){
129 if( $(this).hasClass("parent") ){
130 toggleChildren(this);
138 // manage checking/unchecking parent permissions
139 var originalChildStates = {}; /* keep track of subpermission checkbox values
140 so that user can recover from accidentally
141 toggling a parent/module permission */
142 function selectChildren(parentInput) {
143 var childListId = parentInput.id + '-children';
144 var list = document.getElementById(childListId);
147 var inputs = list.getElementsByTagName('input');
148 for (var i = 0; i < inputs.length; i++) {
149 if (inputs[i].type == 'checkbox') {
150 children.push(inputs[i]);
157 function toggleChildren(parentInput) {
158 var children = selectChildren(parentInput);
159 if (children.length == 0) {
162 var checked = parentInput.checked;
163 if (checked && parentInput.parentNode.className == 'expandable') {
164 /* expand the tree */
165 $(".hitarea", parentInput.parentNode).click();
167 for (var i = 0; i < children.length; i++) {
169 originalChildStates[children[i].id] = children[i].checked;
170 children[i].checked = checked;
172 if (children[i].id in originalChildStates) {
173 children[i].checked = originalChildStates[children[i].id];
175 children[i].checked = checked;
181 function toggleParent(childInput) {
182 originalChildStates[childInput.id] = childInput.checked;
183 if (childInput.checked) {
186 var parentId = childInput.parentNode.parentNode.id.replace(/-children$/, '');;
187 var parentInput = document.getElementById(parentId);
189 parentInput.checked = false;
196 [% INCLUDE 'intranet-bottom.inc' %]