From 2c29039785090232bd7cc9e3e60669c1f80d38dd Mon Sep 17 00:00:00 2001 From: dbs Date: Fri, 17 Apr 2009 20:09:02 +0000 Subject: [PATCH] Basic cut at permissions and patron groups for Conifer git-svn-id: svn://svn.open-ils.org/ILS-Contrib/conifer/trunk@352 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- tools/migration-scripts/patron_groups.sql | 86 +++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 tools/migration-scripts/patron_groups.sql diff --git a/tools/migration-scripts/patron_groups.sql b/tools/migration-scripts/patron_groups.sql new file mode 100644 index 0000000000..198614a373 --- /dev/null +++ b/tools/migration-scripts/patron_groups.sql @@ -0,0 +1,86 @@ +BEGIN; + +-- Set up patron groups and permissions + +INSERT INTO permission.grp_tree (name, parent, usergroup, perm_interval, description, application_perm) VALUES ('Faculty', 2, 't', '1 year', 'Faculty', 'group_application.user.patron'); +INSERT INTO permission.grp_tree (name, parent, usergroup, perm_interval, description, application_perm) VALUES ('Graduate', 2, 't', '1 year', 'Graduate', 'group_application.user.patron'); +INSERT INTO permission.grp_tree (name, parent, usergroup, perm_interval, description, application_perm) VALUES ('Undergraduate', 2, 't', '1 year', 'Undergraduate', 'group_application.user.patron'); +INSERT INTO permission.grp_tree (name, parent, usergroup, perm_interval, description, application_perm) VALUES ('Readers', 2, 't', '1 year', 'Readers', 'group_application.user.patron'); + +-- (11 = Faculty, 12 = Graduate, 13 = Undergraduate, 14 = Reader) + +INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) + SELECT 11, perm, depth, grantable FROM permission.grp_perm_map + WHERE grp = 2; + +INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) + SELECT 12, perm, depth, grantable FROM permission.grp_perm_map + WHERE grp = 2; + +INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) + SELECT 13, perm, depth, grantable FROM permission.grp_perm_map + WHERE grp = 2; + +INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable) + SELECT 14, perm, depth, grantable FROM permission.grp_perm_map + WHERE grp = 2; + +-- Not really necessary, unless you want to restrict the ability to add +INSERT INTO permission.perm_list (code, description) VALUES + ('group_application.user.patron.faculty', 'Allow a user to add/remove users to/from the "Faculty" group'), + ('group_application.user.patron.grad', 'Allow a user to add/remove users to/from the "Graduate students" group'), + ('group_application.user.patron.undergrad', 'Allow a user to add/remove users to/from the "Undergraduate students" group'); + +-- Give circulators the ability to abort transits +-- ABORT_TRANSIT = perm 111, ABORT_REMOTE_TRANSIT = perm 112 +INSERT INTO permission.grp_perm_map (grp, perm, depth) + VALUES (5, 111, 2), (5, 112, 2); + +-- Enable all staff to cancel holds +INSERT INTO permission.grp_perm_map (grp, perm, depth) + VALUES (3, 114, 0); + +-- Enable cataloguers to import bib records +-- Cataloguer profile group = 4 +-- Depth (how much of the org_tree does the user have this permission +over) = 0 (the whole thing) +INSERT INTO permission.grp_perm_map (grp, depth, perm) + SELECT 4, 0, id from permission.perm_list + WHERE code LIKE '%IMPORT%' AND id NOT IN ( + SELECT perm FROM permission.grp_perm_map + WHERE grp = 4 + ) +; + +-- Grant ability to merge bib records to cataloguers +INSERT INTO permission.grp_perm_map (grp, perm, depth) + VALUES (4, 230, 0); + +-- Grant ability to delete bib records to cataloguers +INSERT INTO permission.grp_perm_map (grp, perm, depth) + VALUES (4, 153, 0); + +-- Grant ability to add, delete, or update closing dates +INSERT INTO permission.grp_perm_map (grp, perm, depth) + VALUES (10, 117, 1), (10, 116, 1), (10, 118, 1); + +-- Restrict visibility of patrons to staff in related institutions +UPDATE permission.grp_perm_map SET depth = 2 + WHERE grp = 3 AND perm = 31; + +-- New circ rules, to match our JavaScript +INSERT INTO config.rule_circ_duration (name, extended, normal, shrt, max_renewals) + VALUES ('120_days_2_renew', '120 days', '120 days', '120 days', 2), + ('3_weeks_2_renew', '3 weeks', '3 weeks', '3 weeks', 2); + +-- Give local system administrators any permissions other staff have +INSERT INTO permission.grp_perm_map (grp, depth, perm) + SELECT DISTINCT 10, 2, perm + FROM permission.grp_perm_map + WHERE grp IN (3, 4, 5) AND perm NOT IN ( + SELECT perm + FROM permission.grp_perm_map + WHERE grp = 10 + ) +; +COMMIT; -- 2.11.0