1 dump('entering OpenILS/data.js\n');
3 if (typeof OpenILS == 'undefined') OpenILS = {};
4 OpenILS.data = function () {
7 JSAN.use('util.error'); this.error = new util.error();
8 JSAN.use('util.network'); this.network = new util.network();
10 alert(location.href + '\nError in OpenILS.data constructor: ' + E);
17 OpenILS.data.prototype = {
25 'data_progress' : function(msg) {
27 var x = document.getElementById('data_progress');
29 x.appendChild( document.createTextNode( msg ) );
32 this.error.sdump('D_ERROR',msg + '\n' + E);
36 'init' : function (params) {
39 if (params && params.via == 'stash') {
40 this.stash_retrieve();
42 this.network_retrieve();
46 this.error.sdump('D_ERROR','Error in OpenILS.data.init('
47 +js2JSON(params)+'): ' + js2JSON(E) );
53 // This should be invoked only once per application, in a persistant window
54 'init_observer_functions' : function() {
56 var obj = this; // OpenILS.data
57 obj.observers = {}; //
58 obj.observers.id = 1; // Unique id for each observer function added
59 obj.observers.id2path = {}; // Lookup for full_path via observer id
60 obj.observers.cache = {}; // Observer funcs go in here
62 // For a given path, this executes all the registered observer funcs
63 obj.observers.dispatch = function(full_path, old_value, new_value) {
64 obj.error.sdump('D_OBSERVERS', 'entering observers.dispatch\nfull_path = ' + full_path + '\nold_value = ' + js2JSON(old_value) + '\nnew_value = ' + js2JSON(new_value) + '\n');
66 var path = full_path.split(/\./).pop();
67 for (var i in obj.observers.cache[full_path]) {
69 var o = obj.observers.cache[full_path][i];
70 if (typeof o.func == 'function') o.func(path, old_value, new_value);
72 obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.dispatch(): ' + js2JSON(E) );
76 obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.dispatch(): ' + js2JSON(E) );
80 // This registers an observer function for a given path
81 obj.observers.add = function(full_path, func) {
83 obj.error.sdump('D_OBSERVERS', 'entering observers.add\nfull_path = ' + full_path + '\nfunc = ' + func + '\n');
84 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
85 const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS");
86 var data_cache=new OpenILS( );
87 var stash = data_cache.wrappedJSObject.OpenILS.prototype.data;
89 var id = obj.observers.id++;
90 if (typeof obj.observers.cache[ full_path ] == 'undefined') obj.observers.cache[ full_path ] = {};
91 obj.observers.cache[ full_path ][ id ] = { 'func' : func, 'time_added' : new Date() };
92 obj.observers.id2path[ id ] = [ full_path ];
94 var path_list = full_path.split(/\./);
95 var observed_prop = path_list.pop();
97 // Convert soft path to object reference. Error if any but the last node is undefined
98 for (var i in path_list) stash = stash[ path_list[i] ];
102 // experiment with storing only json in cache to avoid the [ ] -> { '0' : .., '1' : .. } bug
104 if (stash[observed_prop] && getKeys( obj.observers.cache[ full_path ] ).length == 0) {
105 stash['_' + observed_prop] = js2JSON(stash[observed_prop]);
108 stash.__defineSetter__(observed_prop, function(x) { this['_'+observed_prop] = js2JSON(x); });
109 stash.__defineGetter__(observed_prop, function() { return JSON2js(this['_'+observed_prop]); });
114 function(p,old_value,new_value) {
115 obj.observers.dispatch(full_path,old_value,new_value);
122 obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.add(): ' + js2JSON(E) );
126 // This unregisters an observer function for a given observer id
127 obj.observers.remove = function(id) {
129 obj.error.sdump('D_OBSERVERS', 'entering observers.remove\nid = ' + id + '\n');
130 var path = obj.observers.id2path[ id ];
131 delete obj.observers.cache[ path ][ id ];
132 delete obj.observers.id2path[ id ];
134 obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.remove(): ' + js2JSON(E) );
138 // This purges observer functions for a given path
139 obj.observers.purge = function(full_path) {
140 obj.error.sdump('D_OBSERVERS', 'entering observers.purge\nfull_path = ' + full_path + '\n');
142 var remove_these = [];
143 for (var id in obj.observers.cache[ full_path ]) remove_these.push( id );
144 for (var id in remove_these) delete obj.observers.id2path[ id ];
145 delete obj.observers.cache[ full_path ];
147 obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.purge(): ' + js2JSON(E) );
151 obj.stash('observers'); // make this accessible globally
154 this.error.sdump('D_ERROR','Error in OpenILS.data.init_observer_functions(): ' + js2JSON(E) );
158 'stash' : function () {
160 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
161 const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS");
162 var data_cache=new OpenILS( );
163 for (var i = 0; i < arguments.length; i++) {
165 if (arguments[i] != 'hash' && arguments[i] != 'list') this.error.sdump('D_DATA_STASH','stashing ' + arguments[i] + ' : ' + this[arguments[i]] + (typeof this[arguments[i]] == 'object' ? ' = ' + (this[arguments[i]]) : '') + '\n');
166 } catch(F) { alert(F); }
167 data_cache.wrappedJSObject.OpenILS.prototype.data[arguments[i]] = this[arguments[i]];
170 this.error.sdump('D_ERROR','Error in OpenILS.data.stash(): ' + js2JSON(E) );
174 'lookup' : function(key,value) {
176 var obj = this; var found;
177 if (obj.hash[key] && obj.hash[key][value]) return obj.hash[key][value];
180 found = obj.network.simple_request('FM_ACPL_RETRIEVE_VIA_ID.authoritative',[ value ]);
182 default: return undefined; break;
184 if (typeof found.ilsevent != 'undefined') throw(found);
185 if (!obj.hash[key]) obj.hash[key] = {};
186 obj.hash[key][value] = found; obj.list[key].push( found ); obj.stash('hash','list');
189 this.error.sdump('D_ERROR','Error in OpenILS.data.lookup('+key+','+value+'): ' + js2JSON(E) );
194 '_debug_stash' : function() {
196 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
197 const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS");
198 var data_cache=new OpenILS( );
199 for (var i in data_cache.wrappedJSObject.OpenILS.prototype.data) {
200 dump('_debug_stash ' + i + '\n');
203 this.error.sdump('D_ERROR','Error in OpenILS.data._debug_stash(): ' + js2JSON(E) );
209 'pgt' : [ api.FM_PGT_RETRIEVE.app, api.FM_PGT_RETRIEVE.method, [], true ],
210 'cit' : [ api.FM_CIT_RETRIEVE.app, api.FM_CIT_RETRIEVE.method, [], true ],
211 'citm' : [ api.FM_CITM_RETRIEVE.app, api.FM_CITM_RETRIEVE.method, [], true ],
213 'cst' : [ api.FM_CST_RETRIEVE.app, api.FM_CST_RETRIEVE.method, [], true ],
216 'acpl' : [ api.FM_ACPL_RETRIEVE.app, api.FM_ACPL_RETRIEVE.method, [], true ],
218 'ccs' : [ api.FM_CCS_RETRIEVE.app, api.FM_CCS_RETRIEVE.method, [], true ],
219 'aou' : [ api.FM_AOU_RETRIEVE.app, api.FM_AOU_RETRIEVE.method, [], true ],
220 'aout' : [ api.FM_AOUT_RETRIEVE.app, api.FM_AOUT_RETRIEVE.method, [], true ],
221 'crahp' : [ api.FM_CRAHP_RETRIEVE.app, api.FM_CRAHP_RETRIEVE.method, [], true ]
224 'stash_retrieve' : function() {
226 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
227 const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS");
228 var data_cache=new OpenILS( );
229 var dc = data_cache.wrappedJSObject.OpenILS.prototype.data;
231 this.error.sdump('D_DATA_RETRIEVE','Retrieving ' + i + ' : ' + dc[i] + '\n');
234 if (typeof this.on_complete == 'function') {
239 this.error.sdump('D_ERROR','Error in OpenILS.data._debug_stash(): ' + js2JSON(E) );
243 'print_list_defaults' : function() {
245 //if (typeof obj.print_list_templates == 'undefined') {
247 obj.print_list_types = [
251 'offline_inhouse_use',
258 obj.print_list_templates = {
261 'header' : 'The following items have been examined:<hr/><ol>',
262 'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode%\r\n',
263 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n'
267 'header' : 'Transits:<hr/><ol>',
268 'line_item' : '<li>From: %transit_source% To: %transit_dest_lib%<br/>\r\nWhen: %transit_source_send_time%<br />\r\nBarcode: %transit_item_barcode% Title: %transit_item_title%<br/>\r\n',
269 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n'
273 'header' : 'Welcome to %LIBRARY%!<br/>\r\nYou have the following items:<hr/><ol>',
274 'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode% Due: %due_date%\r\n',
275 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\nYou were helped by %STAFF_FIRSTNAME%<br/>\r\n<br/>\r\n'
279 'header' : 'Welcome to %LIBRARY%!<br/>\r\nYou have renewed the following items:<hr/><ol>',
280 'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode% Due: %due_date%\r\n',
281 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\nYou were helped by %STAFF_FIRSTNAME%<br/>\r\n<br/>\r\n'
285 'header' : 'Welcome to %LIBRARY%!<br/>\r\nYou checked out the following items:<hr/><ol>',
286 'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode% Due: %due_date%\r\n',
287 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\nYou were helped by %STAFF_FIRSTNAME%<br/>\r\n<br/>\r\n'
289 'offline_checkout' : {
290 'type' : 'offline_checkout',
291 'header' : 'Patron %patron_barcode%<br/>\r\nYou checked out the following items:<hr/><ol>',
292 'line_item' : '<li>Barcode: %barcode%<br/>\r\nDue: %due_date%\r\n',
293 'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n'
297 'header' : 'You checked in the following items:<hr/><ol>',
298 'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode% Call Number: %call_number%\r\n',
299 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n'
303 'header' : 'Welcome to %LIBRARY%!<br/>A receipt of your transaction:<hr/> <table width="100%"> <tr> <td>Original Balance:</td> <td align="right">$%original_balance%</td> </tr> <tr> <td>Payment Method:</td> <td align="right">%payment_type%</td> </tr> <tr> <td>Payment Received:</td> <td align="right">$%payment_received%</td> </tr> <tr> <td>Payment Applied:</td> <td align="right">$%payment_applied%</td> </tr> <tr> <td>Billings Voided:</td> <td align="right">%voided_balance%</td> </tr> <tr> <td>Change Given:</td> <td align="right">$%change_given%</td> </tr> <tr> <td>New Balance:</td> <td align="right">$%new_balance%</td> </tr> </table> <p> Note: %note% </p> <p> Specific bills: <blockquote>',
304 'line_item' : 'Bill #%bill_id% %last_billing_type% Received: $%payment%<br />%barcode% %title%<br /><br />',
305 'footer' : '</blockquote> </p> <hr />%SHORTNAME% %TODAY_TRIM%<br/> <br/> '
307 'bills_historical' : {
309 'header' : 'Welcome to %LIBRARY%!<br/>You had the following bills:<hr/><ol>',
310 'line_item' : '<dt><b>Bill #%id%</b></dt> <dd> <table> <tr valign="top"><td>Date:</td><td>%xact_start%</td></tr> <tr valign="top"><td>Type:</td><td>%xact_type%</td></tr> <tr valign="top"><td>Last Billing:</td><td>%last_billing_type%<br/>%last_billing_note%</td></tr> <tr valign="top"><td>Total Billed:</td><td>$%total_owed%</td></tr> <tr valign="top"><td>Last Payment:</td><td>%last_payment_type%<br/>%last_payment_note%</td></tr> <tr valign="top"><td>Total Paid:</td><td>$%total_paid%</td></tr> <tr valign="top"><td><b>Balance:</b></td><td><b>$%balance_owed%</b></td></tr> </table><br/>',
311 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n'
315 'header' : 'Welcome to %LIBRARY%!<br/>You have the following bills:<hr/><ol>',
316 'line_item' : '<dt><b>Bill #%id%</b></dt> <dd> <table> <tr valign="top"><td>Date:</td><td>%xact_start%</td></tr> <tr valign="top"><td>Type:</td><td>%xact_type%</td></tr> <tr valign="top"><td>Last Billing:</td><td>%last_billing_type%<br/>%last_billing_note%</td></tr> <tr valign="top"><td>Total Billed:</td><td>$%total_owed%</td></tr> <tr valign="top"><td>Last Payment:</td><td>%last_payment_type%<br/>%last_payment_note%</td></tr> <tr valign="top"><td>Total Paid:</td><td>$%total_paid%</td></tr> <tr valign="top"><td><b>Balance:</b></td><td><b>$%balance_owed%</b></td></tr> </table><br/>',
317 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n'
319 'bills_main_view' : {
321 'header' : 'Welcome to %LIBRARY%!<br/>You have the following bills:<hr/><ol>',
322 'line_item' : '<dt><b>Bill #%id%</b> %title%</dt> <dd> <table width="100%"> <tr valign="top"><td>Date:</td><td>%xact_start%</td></tr> <tr valign="top"><td>Type:</td><td>%xact_type%</td></tr> <tr valign="top"><td>Last Billing:</td><td>%last_billing_type%<br/>%last_billing_note%</td></tr> <tr valign="top"><td>Total Billed:</td><td>$%total_owed%</td></tr> <tr valign="top"><td>Last Payment:</td><td>%last_payment_type%<br/>%last_payment_note%</td></tr> <tr valign="top"><td>Total Paid:</td><td>$%total_paid%</td></tr> <tr valign="top"><td><b>Balance:</b></td><td><b>$%balance_owed%</b></td></tr> </table><br/>',
323 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n'
325 'offline_checkin' : {
326 'type' : 'offline_checkin',
327 'header' : 'You checked in the following items:<hr/><ol>',
328 'line_item' : '<li>Barcode: %barcode%\r\n',
329 'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n'
332 'type' : 'offline_renew',
333 'header' : 'You renewed the following items:<hr/><ol>',
334 'line_item' : '<li>Barcode: %barcode%\r\n',
335 'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n'
337 'offline_inhouse_use' : {
338 'type' : 'offline_inhouse_use',
339 'header' : 'You marked the following in-house items used:<hr/><ol>',
340 'line_item' : '<li>Barcode: %barcode%\r\nUses: %count%',
341 'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n'
345 'header' : 'You marked the following in-house items used:<hr/><ol>',
346 'line_item' : '<li>Barcode: %barcode%\r\nUses: %uses%\r\n<br />%alert_message%',
347 'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n'
351 'header' : 'Welcome to %LIBRARY%!<br/>\r\nYou have the following titles on hold:<hr/><ol>',
352 'line_item' : '<li>%title%\r\n',
353 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\nYou were helped by %STAFF_FIRSTNAME%<br/>\r\n<br/>\r\n'
357 'header' : 'This item needs to be routed to <b>%route_to%</b>:<br/>\r\nBarcode: %item_barcode%<br/>\r\nTitle: %item_title%<br/>\r\n<br/>\r\n%hold_for_msg%<br/>\r\nBarcode: %PATRON_BARCODE%<br/>\r\nNotify by phone: %notify_by_phone%<br/>\r\nNotify by email: %notify_by_email%<br/>\r\n',
358 'line_item' : '%formatted_note%<br/>\r\n',
359 'footer' : '<br/>\r\nRequest date: %request_date%<br/>\r\nSlip Date: %TODAY_TRIM%<br/>\r\nPrinted by %STAFF_FIRSTNAME% at %SHORTNAME%<br/>\r\n<br/>\r\n'
363 'header' : 'This item needs to be routed to <b>%route_to%</b>:<br/>\r\n%route_to_org_fullname%<br/>\r\n%street1%<br/>\r\n%street2%<br/>\r\n%city_state_zip%<br/>\r\n<br/>\r\n',
364 'line_item' : 'Barcode: %item_barcode%<br/>\r\nTitle: %item_title%<br/>\r\nAuthor: %item_author%<br>\r\n<br/>\r\n',
365 'footer' : 'Slip Date: %TODAY_TRIM%<br/>\r\nPrinted by %STAFF_FIRSTNAME% at %SHORTNAME%<br/>\r\n<br/>\r\n'
367 'hold_transit_slip' : {
369 'header' : 'This item needs to be routed to <b>%route_to%</b>:<br/>\r\n%route_to_org_fullname%<br/>\r\n%street1%<br/>\r\n%street2%<br/>\r\n%city_state_zip%<br/>\r\n<br/>\r\nBarcode: %item_barcode%<br/>\r\nTitle: %item_title%<br/>\r\nAuthor: %item_author%<br>\r\n<br/>\r\n%hold_for_msg%<br/>\r\nBarcode: %PATRON_BARCODE%<br/>\r\nNotify by phone: %notify_by_phone%<br/>\r\nNotify by email: %notify_by_email%<br/>\r\n',
370 'line_item' : '%formatted_note%<br/>\r\n',
371 'footer' : '<br/>\r\nRequest date: %request_date%<br/>\r\nSlip Date: %TODAY_TRIM%<br/>\r\nPrinted by %STAFF_FIRSTNAME% at %SHORTNAME%<br/>\r\n<br/>\r\n'
375 obj.stash( 'print_list_templates', 'print_list_types' );
379 'network_retrieve' : function() {
380 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
384 JSAN.use('util.file'); var file = new util.file('print_list_templates');
385 obj.print_list_defaults();
386 obj.data_progress('Default print templates set. ');
387 if (file._file.exists()) {
389 var x = file.get_object();
392 obj.print_list_templates[i] = x[i];
394 obj.stash('print_list_templates');
395 obj.data_progress('Saved print templates retrieved from file. ');
403 JSAN.use('util.file'); var file = new util.file('global_font_adjust');
404 if (file._file.exists()) {
406 var x = file.get_object();
408 obj.global_font_adjust = x;
409 obj.stash('global_font_adjust');
410 obj.data_progress('Saved font settings retrieved from file. ');
418 JSAN.use('util.file'); var file = new util.file('no_sound');
419 if (file._file.exists()) {
421 var x = file.get_content();
424 obj.stash('no_sound');
425 obj.data_progress('Saved sound settings retrieved from file. ');
433 JSAN.use('util.file'); var file = new util.file('print_strategy');
434 if (file._file.exists()) {
436 var x = file.get_content();
438 obj.print_strategy = x;
439 obj.stash('print_strategy');
440 obj.data_progress('Print strategy retrieved from file. ');
448 JSAN.use('util.functional');
449 JSAN.use('util.fm_utils');
451 function gen_fm_retrieval_func(classname,data) {
452 var app = data[0]; var method = data[1]; var params = data[2]; var cacheable = data[3];
454 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
457 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
459 if (obj.list[classname].constructor.name == 'Array') {
460 obj.hash[classname] =
461 util.functional.convert_object_list_to_hash(
467 obj.error.sdump('D_ERROR',E + '\n');
473 var level = obj.error.sdump_levels.D_SES_RESULT;
474 if (classname == 'aou' || classname == 'my_aou')
475 obj.error.sdump_levels.D_SES_RESULT = false;
476 var robj = obj.network.request( app, method, params);
477 if (robj != null && typeof robj.ilsevent != 'undefined') {
478 obj.error.standard_unexpected_error_alert('The staff client failed to retrieve expected data from this call, "' + method + '"',robj);
481 obj.list[classname] = robj == null ? [] : robj;
482 obj.error.sdump_levels.D_SES_RESULT = level;
484 obj.data_progress('Retrieved list for ' + classname + ' objects. ');
487 // if cacheable, try offline
489 /* FIXME -- we're going to revisit caching and do it differently
491 var file = new util.file( classname );
492 obj.list[classname] = file.get_object(); file.close();
511 var robj = obj.network.simple_request('CIRC_MODIFIER_LIST',[]);
512 if (typeof robj.ilsevent != 'undefined') throw(robj);
513 obj.list.circ_modifier = robj;
514 obj.data_progress('Retrieved circ modifier list. ');
516 var error = 'Error: ' + js2JSON(E);
517 obj.error.sdump('D_ERROR',error);
525 var f = gen_fm_retrieval_func(
528 api.FM_CNAL_RETRIEVE.app,
529 api.FM_CNAL_RETRIEVE.method,
537 var error = 'Error: ' + js2JSON(E);
538 obj.error.sdump('D_ERROR',error);
546 var f = gen_fm_retrieval_func(
549 api.FM_CSP_PCRUD_SEARCH.app,
550 api.FM_CSP_PCRUD_SEARCH.method,
551 [ obj.session.key, {"id":{"!=":null}}, {"order_by":{"csp":"id"}} ],
558 var error = 'Error: ' + js2JSON(E);
559 obj.error.sdump('D_ERROR',error);
567 var f = gen_fm_retrieval_func(
570 api.FM_AHRCC_PCRUD_SEARCH.app,
571 api.FM_AHRCC_PCRUD_SEARCH.method,
572 [ obj.session.key, {"id":{"!=":null}}, {"order_by":{"ahrcc":"label"}} ],
579 var error = 'Error: ' + js2JSON(E);
580 obj.error.sdump('D_ERROR',error);
589 var f = gen_fm_retrieval_func(
592 api.FM_AU_RETRIEVE_VIA_SESSION.app,
593 api.FM_AU_RETRIEVE_VIA_SESSION.method,
601 var error = 'Error: ' + js2JSON(E);
602 obj.error.sdump('D_ERROR',error);
605 obj.list.au = [ obj.list.au ];
611 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
612 var f = gen_fm_retrieval_func(
615 api.FM_ASV_RETRIEVE_REQUIRED.app,
616 api.FM_ASV_RETRIEVE_REQUIRED.method,
622 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
625 var error = 'Error: ' + js2JSON(E);
626 obj.error.sdump('D_ERROR',error);
634 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
635 var f = gen_fm_retrieval_func(
638 api.FM_ASV_RETRIEVE.app,
639 api.FM_ASV_RETRIEVE.method,
645 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
648 var error = 'Error: ' + js2JSON(E);
649 obj.error.sdump('D_ERROR',error);
655 obj.error.sdump('D_DEBUG','_fm_objects = ' + js2JSON(this._fm_objects) + '\n');
657 for (var i in this._fm_objects) {
658 this.chain.push( gen_fm_retrieval_func(i,this._fm_objects[i]) );
661 // The previous org_tree call returned a tree, not a list or hash.
664 obj.tree.aou = obj.list.aou;
665 obj.list.aou = util.fm_utils.flatten_ou_branch( obj.tree.aou );
666 for (var i = 0; i < obj.list.aou.length; i++) {
667 var c = obj.list.aou[i].children();
671 if (a.shortname() < b.shortname()) return -1;
672 if (a.shortname() > b.shortname()) return 1;
676 obj.list.aou[i].children( c );
678 obj.list.aou = util.fm_utils.flatten_ou_branch( obj.tree.aou );
679 obj.hash.aou = util.functional.convert_object_list_to_hash( obj.list.aou );
683 // The previous pgt call returned a tree, not a list or hash.
686 obj.tree.pgt = obj.list.pgt;
687 obj.list.pgt = util.fm_utils.flatten_ou_branch( obj.tree.pgt );
688 obj.hash.pgt = util.functional.convert_object_list_to_hash( obj.list.pgt );
692 // Do these after we get the user object
697 var robj = obj.network.simple_request('FM_AOUS_RETRIEVE',[ obj.session.key, obj.list.au[0].ws_ou() ]);
698 if (typeof robj.ilsevent != 'undefined') throw(robj);
699 obj.hash.aous = robj;
700 obj.data_progress('Retrieved org unit settings. ');
702 var error = 'Error: ' + js2JSON(E);
703 obj.error.sdump('D_ERROR',error);
713 gen_fm_retrieval_func('my_aou',
715 api.FM_AOU_RETRIEVE_RELATED_VIA_SESSION.app,
716 api.FM_AOU_RETRIEVE_RELATED_VIA_SESSION.method,
717 [ obj.session.key, obj.list.au[0].ws_ou() ], /* use ws_ou and not home_ou */
728 gen_fm_retrieval_func( 'my_actsc',
730 api.FM_ACTSC_RETRIEVE_VIA_AOU.app,
731 api.FM_ACTSC_RETRIEVE_VIA_AOU.method,
732 [ obj.session.key, obj.list.au[0].ws_ou() ],
743 gen_fm_retrieval_func( 'my_asc',
745 api.FM_ASC_RETRIEVE_VIA_AOU.app,
746 api.FM_ASC_RETRIEVE_VIA_AOU.method,
747 [ obj.session.key, obj.list.au[0].ws_ou() ],
757 var f = gen_fm_retrieval_func(
760 api.FM_CNCT_RETRIEVE.app,
761 api.FM_CNCT_RETRIEVE.method,
762 [ obj.list.au[0].ws_ou() ],
769 var error = 'Error: ' + js2JSON(E);
770 obj.error.sdump('D_ERROR',error);
778 var f = gen_fm_retrieval_func(
781 api.FM_CNCT_RETRIEVE.app,
782 api.FM_CNCT_RETRIEVE.method,
783 [ obj.list.au[0].ws_ou() ],
790 var error = 'Error: ' + js2JSON(E);
791 obj.error.sdump('D_ERROR',error);
800 var f = gen_fm_retrieval_func(
803 api.FM_ACPL_RETRIEVE.app,
804 api.FM_ACPL_RETRIEVE.method,
805 [ obj.list.au[0].ws_ou() ],
812 var error = 'Error: ' + js2JSON(E);
813 obj.error.sdump('D_ERROR',error);
821 var f = gen_fm_retrieval_func(
824 api.FM_CBT_RETRIEVE.app,
825 api.FM_CBT_RETRIEVE.method,
826 [ obj.session.key, obj.list.au[0].ws_ou() ],
833 var error = 'Error: ' + js2JSON(E);
834 obj.error.sdump('D_ERROR',error);
840 if (typeof this.on_complete == 'function') {
842 this.chain.push( this.on_complete );
844 JSAN.use('util.exec'); this.exec = new util.exec();
845 this.exec.on_error = function(E) {
847 if (typeof obj.on_error == 'function') {
848 return obj.on_error(E); /* false breaks chain */
850 alert('oops: ' + E );
851 return false; /* break chain */
856 this.exec.chain( this.chain );
861 dump('exiting OpenILS/data.js\n');