contentWindow wrapper to get around security
authorpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 13 May 2007 19:19:01 +0000 (19:19 +0000)
committerpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 13 May 2007 19:19:01 +0000 (19:19 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_0@7298 dcc99617-32d9-48b4-a31d-7c20da2025e4

16 files changed:
Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js
Open-ILS/xul/staff_client/chrome/content/util/window.js
Open-ILS/xul/staff_client/server/admin/offline_manage_xacts.js
Open-ILS/xul/staff_client/server/admin/printer_settings.js
Open-ILS/xul/staff_client/server/cat/marc_new.xul
Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js
Open-ILS/xul/staff_client/server/cat/z3950.js
Open-ILS/xul/staff_client/server/circ/circ_summary.xul
Open-ILS/xul/staff_client/server/circ/copy_details.xul
Open-ILS/xul/staff_client/server/patron/bill_details.xul
Open-ILS/xul/staff_client/server/patron/bill_history.xul
Open-ILS/xul/staff_client/server/patron/display.js
Open-ILS/xul/staff_client/server/patron/display.xul
Open-ILS/xul/staff_client/server/patron/hold_notices.xul
Open-ILS/xul/staff_client/server/patron/info.xul
Open-ILS/xul/staff_client/server/patron/info_group.xul

index 290764d..9fc4d8c 100644 (file)
                }
        }
 
+       function get_contentWindow(frame) {
+               netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+               if (frame && frame.contentWindow) {
+                       if (typeof frame.contentWindow.wrappedJSObject != 'undefined') return frame.contentWindow.wrappedJSObject;
+                       return frame.contentWindow;
+               } else {
+                       return null;
+               }
+       }
+
        function update_modal_xulG(v) {
                try {
                        JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
index c7a73bf..a167d93 100644 (file)
@@ -98,8 +98,8 @@ util.window.prototype = {
                        return x;
                } else {
                        if (my_xulG) {
-                               if (w.contentWindow) {
-                                       w.contentWindow.xulG = my_xulG;
+                               if (get_contentWindow(w)) {
+                                       get_contentWindow(w).xulG = my_xulG;
                                } else {
                                        w.xulG = my_xulG;
                                }
index 9e3d4b4..73f856a 100644 (file)
@@ -566,7 +566,7 @@ admin.offline_manage_xacts.prototype = {
                                } 
                        }
                };
-               x.contentWindow.xulG = newG;
+               get_contentWindow(x).xulG = newG;
 
                } catch(E) {
                        obj.error.standard_unexpected_error_alert('Error uploading xacts',E);
index 7d9b6e6..fc60b49 100644 (file)
@@ -32,7 +32,7 @@ g.page_settings = function() {
 
 g.printer_settings = function() {
        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-       var w = document.getElementById('sample').contentWindow;
+       var w = get_contentWindow(document.getElementById('sample'));
        g.print.NSPrint(w ? w : window, false, {});
        g.print.save_settings();
 }
index 543563d..480d3b4 100644 (file)
                                                        };
                                                        $('marc_editor').setAttribute('src',url);
                                                        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-                                                       $('marc_editor').contentWindow.xulG = params;
+                                                       get_contentWindow($('marc_editor')).xulG = params;
 
                                                        /* hide template widgets */
                                                        $('actions').hidden = true;
index fb8c3ff..96af32c 100644 (file)
@@ -21,7 +21,7 @@ function my_init() {
 
                g.doc_id = xul_param('doc_id');
                document.getElementById('summary').setAttribute('src',urls.XUL_BIB_BRIEF); // + '?docid=' + window.escape(g.doc_id));
-               document.getElementById('summary').contentWindow.xulG = { 'docid' : g.doc_id };
+               get_contentWindow(document.getElementById('summary')).xulG = { 'docid' : g.doc_id };
 
                g.copy_shortcut = xul_param('copy_shortcut',{'JSON2js_if_cgi':true});
                g.error.sdump('D_ERROR','location.href = ' + location.href + '\n\ncopy_short cut = ' + g.copy_shortcut + '\n\nou_ids = ' + xul_param('ou_ids'));
index efa4f3d..ce55760 100644 (file)
@@ -122,7 +122,7 @@ cat.z3950.prototype = {
                                                                                n.setAttribute('toggle','1');
                                                                                n.setAttribute('label','Results View');
                                                                                netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-                                                                               var f = document.getElementById('marc_frame').contentWindow;
+                                                                               var f = get_contentWindow(document.getElementById('marc_frame'));
                                                                                f.xulG = { 'marcxml' : obj.results.records[ n.getAttribute('retrieve_id') ].marcxml };
                                                                                f.my_init();
                                                                                f.document.body.firstChild.focus();
index 00abb79..9b0988c 100644 (file)
@@ -61,9 +61,9 @@
                                if (typeof g.callnumber.ilsevent != 'undefined') throw(g.callnumber);
 
                                $('top').setAttribute('src',urls.XUL_BIB_BRIEF);// + '?docid=' + g.callnumber.record());
-                               $('top').contentWindow.xulG = { 'docid' : g.callnumber.record() };
+                               get_contentWindow($('top')).xulG = { 'docid' : g.callnumber.record() };
                                $('mid').setAttribute('src',urls.XUL_COPY_SUMMARY); // + '?copy_id=' + g.copy.id());
-                               $('mid').contentWindow.xulG = { 'copy_id' : g.copy.id() };
+                               get_contentWindow($('mid')).xulG = { 'copy_id' : g.copy.id() };
 
                                show_circs();
 
@@ -89,7 +89,7 @@
                                        iframe.setAttribute('flex','1');
                                        gb.appendChild(iframe);
                                        iframe.setAttribute('src', urls.XUL_CIRC_BRIEF); // + '?circ_id=' + g.circs[j].id() );
-                                       iframe.contentWindow.xulG = { 'circ_id' : g.circs[j].id() };
+                                       get_contentWindow(iframe).xulG = { 'circ_id' : g.circs[j].id() };
                                }
                        } catch(E) {
                                g.error.standard_unexpected_error_alert('error showing circs',E);
index 7a1d876..4f63c47 100644 (file)
                                //if (typeof g.callnumber.ilsevent != 'undefined') throw(g.callnumber);
 
                                $('top').setAttribute('src',urls.XUL_BIB_BRIEF); // + '?docid=' + g.callnumber.record());
-                               $('top').contentWindow.xulG = { 'docid' : g.callnumber.record() };
+                               get_contentWindow($('top')).xulG = { 'docid' : g.callnumber.record() };
                                //g.data.temp_copy = g.copy; g.data.stash('temp_copy'); 
                                //g.data.temp_callnumber = g.callnumber; g.data.stash('temp_callnumber'); 
                                $('item_summary').setAttribute('src',urls.XUL_COPY_SUMMARY);
-                               $('item_summary').contentWindow.xulG = { 'copy' : g.copy, 'callnumber' : g.callnumber };
+                               get_contentWindow($('item_summary')).xulG = { 'copy' : g.copy, 'callnumber' : g.callnumber };
 
                                $('r_last').disabled = true;
                                if (g.circ) {
                                        $('r_last').disabled = false;
                                        g.data.temp_circ = g.circ; g.data.stash('temp_circ');
                                        $('circ').setAttribute('src',urls.XUL_CIRC_BRIEF); // + '?no_border=1');
-                                       $('circ').contentWindow.xulG = { 'no_border' : 1 };
+                                       get_contentWindow($('circ')).xulG = { 'no_border' : 1 };
                                        if (g.circ.checkin_time()) {
                                                $('circ_caption').setAttribute('label','Last Circulation');
                                        } else {
index 43320d2..994922d 100644 (file)
 
                                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                                                $('copy_summary').setAttribute('src',urls.XUL_COPY_SUMMARY); // + '?copy_id=' + r_circ.target_copy());
-                                               $('copy_summary').contentWindow.xulG = { 'copy_id' : r_circ.target_copy() };
+                                               get_contentWindow($('copy_summary')).xulG = { 'copy_id' : r_circ.target_copy() };
                                                $('copy_summary').hidden=false;
 
                                                g.network.simple_request(
index a90c083..ac1df9f 100644 (file)
 
                                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                                                $('copy_summary').setAttribute('src',urls.XUL_COPY_SUMMARY); // + '?copy_id=' + r_circ.target_copy());
-                                               $('copy_summary').contentWindow.xulG = { 'copy_id' : r_circ.target_copy() };
+                                               get_contentWindow($('copy_summary')).xulG = { 'copy_id' : r_circ.target_copy() };
                                                $('copy_summary').hidden=false;
 
                                                g.network.simple_request(
index 1480e24..b1c6864 100644 (file)
@@ -67,7 +67,7 @@ patron.display.prototype = {
                                }
                        );
                        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-                       obj.checkout_window = frame.contentWindow;
+                       obj.checkout_window = get_contentWindow(frame);
                }
 
                JSAN.use('util.controller'); obj.controller = new util.controller();
@@ -167,7 +167,7 @@ patron.display.prototype = {
                                                                }
                                                        );
                                                        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-                                                       obj.items_window = frame.contentWindow;
+                                                       obj.items_window = get_contentWindow(frame);
                                                }
                                        ],
                                        'cmd_patron_edit' : [
@@ -307,7 +307,7 @@ patron.display.prototype = {
                                                                }
                                                        );
                                                        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-                                                       obj.bill_window = f.contentWindow;
+                                                       obj.bill_window = get_contentWindow(f);
                                                }
                                        ],
                                        'patron_name' : [
@@ -476,7 +476,7 @@ patron.display.prototype = {
                                }
                        );
                        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-                       obj.summary_window = frame.contentWindow;
+                       obj.summary_window = get_contentWindow(frame);
                } else {
                        obj.render_search_form(params);
                }
@@ -536,7 +536,7 @@ patron.display.prototype = {
                                                                                netscape.security.PrivilegeManager.enablePrivilege(
                                                                                        "UniversalXPConnect"
                                                                                );
-                                                                               obj.summary_window = frame.contentWindow;
+                                                                               obj.summary_window = get_contentWindow(frame);
                                                                                obj.patron = obj.summary_window.g.summary.patron;
                                                                                obj.controller.render('patron_name');
                                                                        }, 0
@@ -545,7 +545,7 @@ patron.display.prototype = {
                                                }
                                        );
                                        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-                                       obj.search_result = list_frame.contentWindow;
+                                       obj.search_result = get_contentWindow(list_frame);
                                }
                        };
 
@@ -560,7 +560,7 @@ patron.display.prototype = {
                                my_xulG
                        );
                        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-                       obj.search_window = form_frame.contentWindow;
+                       obj.search_window = get_contentWindow(form_frame);
                        obj._checkout_spawned = true;
        },
 
@@ -572,7 +572,7 @@ patron.display.prototype = {
                for (var i = 0; i < obj.right_deck.node.childNodes.length; i++) {
                        try {
                                var f = obj.right_deck.node.childNodes[i];
-                               var w = f.contentWindow;
+                               var w = get_contentWindow(f);
                                if (url) {
                                        if (w.location.href == url) w.refresh(true);
                                } else {
index 5a602cc..ddb75de 100644 (file)
                                        try {
                                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                                                var node = g.patron.right_deck.node.selectedPanel;
-                                               if (node && node.contentWindow && typeof node.contentWindow.default_focus == 'function') {
-                                                       node.contentWindow.default_focus();
+                                               if (node && get_contentWindow(node) && typeof get_contentWindow(node).default_focus == 'function') {
+                                                       get_contentWindow(node).default_focus();
                                                } else {
                                                        var node = g.patron.left_deck.node.selectedPanel;
-                                                       if (node && node.contentWindow && typeof node.contentWindow.default_focus == 'function') {
-                                                               node.contentWindow.default_focus();
+                                                       if (node && get_contentWindow(node) && typeof get_contentWindow(node).default_focus == 'function') {
+                                                               get_contentWindow(node).default_focus();
                                                        }
                                                }
                                        } catch(E) {
index 18d1bdd..5fe168a 100644 (file)
@@ -58,7 +58,7 @@
                                a_list_of_one();
 
                                document.getElementById('bib_brief').setAttribute('src',urls.XUL_BIB_BRIEF); // + '?docid=' + g.ahr.target());
-                               document.getElementById('bib_brief').contentWindow.xulG = { 'docid' : g.ahr.target() };
+                               get_contentWindow(document.getElementById('bib_brief')).xulG = { 'docid' : g.ahr.target() };
 
                                refresh();
 
index a7f18d4..7bf2d04 100644 (file)
 
                                try{
                                        $('notes_frame').setAttribute('src',urls.XUL_PATRON_INFO_NOTES); 
-                                       $('notes_frame').contentWindow.xulG = { 'patron_id' : g.patron_id };
+                                       get_contentWindow($('notes_frame')).xulG = 
+                                               { 'patron_id' : g.patron_id, 'url_prefix' : xulG.url_prefix, 'new_tab' : xulG.new_tab };
                                }catch(E){alert(E);}
                                try{
                                        $('stat_cats_frame').setAttribute('src',urls.XUL_PATRON_INFO_STAT_CATS);
-                                       $('stat_cats_frame').contentWindow.xulG = { 'patron_id' : g.patron_id };
+                                       get_contentWindow($('stat_cats_frame')).xulG = 
+                                               { 'patron_id' : g.patron_id, 'url_prefix' : xulG.url_prefix, 'new_tab' : xulG.new_tab };
                                }catch(E){alert(E);}
                                try{
                                        $('surveys_frame').setAttribute('src',urls.XUL_PATRON_INFO_SURVEYS);
-                                       $('surveys_frame').contentWindow.xulG = { 'patron_id' : g.patron_id };
+                                       get_contentWindow($('surveys_frame')).xulG = 
+                                               { 'patron_id' : g.patron_id, 'url_prefix' : xulG.url_prefix, 'new_tab' : xulG.new_tab };
                                }catch(E){alert(E);}
                                try{
                                        $('group_frame').setAttribute('src',urls.XUL_PATRON_INFO_GROUP);
-                                       $('group_frame').contentWindow.xulG = { 'patron_id' : g.patron_id };
+                                       get_contentWindow($('group_frame')).xulG = 
+                                               { 'patron_id' : g.patron_id, 'url_prefix' : xulG.url_prefix, 'new_tab' : xulG.new_tab };
                                }catch(E){alert(E);}
 
                        } catch(E) {
                function refresh() {
                        try {
                                netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-                               if ($('notes_frame').contentWindow && typeof $('notes_frame').contentWindow.refresh == 'function') {
-                                       $('notes_frame').contentWindow.refresh();
-                               }
-                               if ($('stat_cats_frame').contentWindow && typeof $('stat_cats_frame').contentWindow.refresh == 'function') {
-                                       $('stat_cats_frame').contentWindow.refresh();
-                               }
-                               if ($('surveys_frame').contentWindow && typeof $('surveys_frame').contentWindow.refresh == 'function') {
-                                       $('surveys_frame').contentWindow.refresh();
-                               }
-                               if ($('group_frame').contentWindow && typeof $('group_frame').contentWindow.refresh == 'function') {
-                                       $('group_frame').contentWindow.refresh();
+                               for (var i in [ 'notes_frame', 'stat_cats_frame', 'surveys_frame', 'group_frame' ]) {
+                                       if (get_contentWindow($(i)) && typeof get_contentWindow($(i)).refresh == 'function') {
+                                               get_contentWindow($(i)).refresh();
+                                       }
                                }
                        } catch(E) {
                                alert(E);
index cf5188a..1bc5700 100644 (file)
                                if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
                                        for (var i = 0; i < g.sel_list.length; i++) {   
                                                try {
-                                                       var url = urls.XUL_PATRON_DISPLAY 
-                                                               + '?id=' + window.escape( g.sel_list[i] );
+                                                       var url = urls.XUL_PATRON_DISPLAY// + '?id=' + window.escape( g.sel_list[i] );
                                                        window.xulG.new_tab(
-                                                               url, { 'tab_name' : 'Retrieving Patron..' }, {}
+                                                               url, 
+                                                               { 'tab_name' : 'Retrieving Patron..' }, 
+                                                               { 
+                                                                       'id' : g.sel_list[i],
+                                                                       'url_prefix' : xulG.url_prefix,
+                                                                       'new_tab' : xulG.new_tab,
+                                                               }
                                                        );
                                                } catch(E) {
                                                        g.error.standard_unexpected_error_alert('Failed to retrieve patron.',E);
                                        var loc = xulG.url_prefix( urls.XUL_REMOTE_BROWSER ); 
                                                //+ '?url=' + window.escape( urls.XUL_PATRON_EDIT + '?ses=' 
                                                //+ window.escape( ses() ) + '&clone=' + g.sel_list[i] );
-                                       xulG.new_tab(
+                                       if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') xulG.new_tab(
                                                loc, 
                                                {}, 
                                                { 
                                                        'show_print_button' : true , 
                                                        'tab_name' : 'Register Patron Clone for Group' ,
                                                        'passthru_content_params' : {
-                                                               'ses' : ses(,
+                                                               'ses' : ses(),
                                                                'clone' : g.sel_list[i],
                                                                'spawn_search' : spawn_search,
                                                                'spawn_editor' : spawn_editor,
                                passthru[i] = p[i];
                        }
                        var loc = xulG.url_prefix( urls.XUL_REMOTE_BROWSER ); // + '?url=' + window.escape( url );
-                       xulG.new_tab(
+                       if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') xulG.new_tab(
                                loc, 
                                {}, 
                                { 
                                g.error.sdump('D_TRACE', 'Editor would like to search for: ' + js2JSON(s) ); 
                                var loc = xulG.url_prefix(urls.XUL_PATRON_DISPLAY);
                                        //loc += '?doit=1&query=' + window.escape(js2JSON(s));
-                               xulG.new_tab( loc, {}, {'doit':1,'query':s} );
+                               if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') 
+                                       xulG.new_tab( loc, {}, {'doit':1,'query':s} );
                        } catch(E) {
                                g.error.standard_unexpected_error_alert('spawn search',E);
                        }