backporting UI for user-lib-opt-in functionality
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 15 Aug 2007 21:50:30 +0000 (21:50 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 15 Aug 2007 21:50:30 +0000 (21:50 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_2@7683 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/server/main/gen_offline_widgets.xul
Open-ILS/xul/staff_client/server/patron/barcode_entry.xul

index c33a5f1..e5bbd79 100644 (file)
@@ -173,6 +173,9 @@ const api = {
        'MERGE_RECORDS' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.records.merge' },
        'PATRON_BARCODE_EXISTS' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.barcode.exists' },
        'RECALCULATE_STANDING_PENALTIES' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.penalties.update' },
+    'USER_ORG_UNIT_OPT_IN_FEATURE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.org_unit_opt_in.enabled' },
+    'USER_ORG_UNIT_OPT_IN_CHECK' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.org_unit_opt_in.check' },
+    'USER_ORG_UNIT_OPT_IN_CREATE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.org_unit_opt_in.create' },
 }
 
 const urls = {
index 2b936c0..5649b02 100644 (file)
@@ -19,7 +19,7 @@
 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
 
 <window id="gen_offline_menus_win" 
-       onload="try { gen_offline_menus_init(); } catch(E) { alert(E); }"
+       onload="try { my_init(); } catch(E) { alert(E); }"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
 
@@ -34,9 +34,8 @@
        <script>
        <![CDATA[
 
-               function gen_offline_menus_init() {
-
-                       netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+        function my_init() {
+            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
                        if (typeof JSAN == 'undefined') {
                                throw(
                        JSAN.use('util.error'); g.error = new util.error();
                        JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
                        JSAN.use('util.network'); g.network = new util.network();
+
+            gen_offline_menus_init();
+
+            var r = g.network.simple_request('USER_ORG_UNIT_OPT_IN_FEATURE',[]);
+            g.data.user_org_unit_opt_in_enabled = (r == "1" || r == 1);
+            g.data.stash('user_org_unit_opt_in_enabled');
+        }
+
+               function gen_offline_menus_init() {
+
+                       netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
                        JSAN.use('util.functional');
 
                        save_object('offline_ou_list', build_ou_list());
index 98b9821..8770745 100644 (file)
@@ -39,6 +39,8 @@
                                JSAN.use('util.error'); g.error = new util.error();
                                g.error.sdump('D_TRACE','my_init() for patron/barcode_entry.xul');
 
+                JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
+
                                var tb = document.getElementById('barcode_tb');
                                tb.addEventListener(
                                        'keypress',
                                                        return;
                                                }
 
-                                               sound.good();
-
-                                               spawn(barcode);
+                        if (g.data.user_org_unit_opt_in_enabled) {
+                            var r = net.simple_request('USER_ORG_UNIT_OPT_IN_CHECK',[ ses(), robj ]);
+                            if (typeof r.ilsevent != 'undefined') {
+                                throw(r);
+                            } else {
+    
+                                if (r == 0) {
+                                
+                                    JSAN.use('patron.util');
+                                    var parts = patron.util.retrieve_name_via_id( ses(), robj );
+    
+                                    if (0 != g.error.yns_alert(
+                                        'Does patron ' + parts[0] + ', ' + parts[1] + (parts[2] ? ' ' + parts[2] : '') + ' from ' + g.data.hash.aou[ parts[3] ].shortname() + ' consent to having their personal information shared with your library?',
+                                        'Patron/Library Opt-In Confirmation',
+                                        'Accept', 'Deny', null, 'Check here to confirm this message'
+                                        )
+                                    ) {
+                                        tb.select(); tb.focus();
+                                        return;
+                                    } else {
+                                        var c = net.simple_request('USER_ORG_UNIT_OPT_IN_CREATE',[ ses(), robj ]);
+                                        if (typeof c.ilsevent != 'undefined') throw(r);
+                                    }
+                                }
+    
+                                                   sound.good();
+                                                   spawn(barcode);
+                            }
+                        } else {
+                                                   sound.good();
+                                                   spawn(barcode);
+                        }
                                        }
                                );
                        } catch(E) {