Permission to control patron-collections-exempt
authorBill Erickson <berick@esilibrary.com>
Fri, 3 Jun 2011 13:27:26 +0000 (09:27 -0400)
committerBill Erickson <berick@esilibrary.com>
Fri, 3 Jun 2011 13:27:26 +0000 (09:27 -0400)
Adds a new permission 'UPDATE_PATRON_COLLECTIONS_EXEMPT' which controls
who can toggle the circ.collections.exempt user setting in the patron
registration interface.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/web/js/ui/default/actor/user/register.js

index 5e294f1..f33a9d3 100644 (file)
@@ -1426,7 +1426,9 @@ INSERT INTO permission.perm_list ( id, code, description ) VALUES
  ( 507, 'ABORT_TRANSIT_ON_LOST', oils_i18n_gettext(507,
     'Allows a user to abort a transit on a copy with status of LOST', 'ppl', 'description')),
  ( 508, 'ABORT_TRANSIT_ON_MISSING', oils_i18n_gettext(508,
-    'Allows a user to abort a transit on a copy with status of MISSING', 'ppl', 'description'));
+    'Allows a user to abort a transit on a copy with status of MISSING', 'ppl', 'description')),
+ ( 509, 'UPDATE_PATRON_COLLECTIONS_EXEMPT', oils_i18n_gettext(509,
+    'Allows a user to indicate that a patron is exempt from collections processing', 'ppl', 'description'));
 
 
 SELECT SETVAL('permission.perm_list_id_seq'::TEXT, 1000);
@@ -1911,6 +1913,7 @@ INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable)
                        'VIEW_CIRC_MATRIX_MATCHPOINT',
             'ABORT_TRANSIT_ON_LOST', 
             'ABORT_TRANSIT_ON_MISSING',
+            'UPDATE_PATRON_COLLECTIONS_EXEMPT',
                        'VIEW_HOLD_MATRIX_MATCHPOINT');
 
 INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable)
index 9369e7e..23201ed 100644 (file)
@@ -581,7 +581,23 @@ function uEditDrawSettingRow(tbody, dividerRow, template, stype) {
     var row = template.cloneNode(true);
     row.setAttribute('user_setting', stype.name());
     getByName(row, 'label').innerHTML = stype.label();
-    var cb = new dijit.form.CheckBox({scrollOnFocus:false}, getByName(row, 'widget'));
+    var cbArgs = {scrollOnFocus : false};
+
+    if(stype.name() == 'circ.collections.exempt') {
+        // Staff require a special permission to exempt a user from collections
+
+        var perm = fieldmapper.standardRequest(
+            ['open-ils.actor', 'open-ils.actor.user.has_work_perm_at'],
+            [openils.User.authtoken, 'UPDATE_PATRON_COLLECTIONS_EXEMPT']);
+
+        /* If and until we implement recalc-perms on a patron home-lib change, having the 
+         * perm at any org unit is sufficient.  This should be considered a gobal permission.
+         */
+        if(perm.length == 0) 
+            cbArgs.disabled = true;
+    }
+
+    var cb = new dijit.form.CheckBox(cbArgs, getByName(row, 'widget'));
     cb.attr('value', userSettings[stype.name()]);
     dojo.connect(cb, 'onChange', function(newVal) { userSettingsToUpdate[stype.name()] = newVal; });
     tbody.insertBefore(row, dividerRow.nextSibling);