forked from LibreHealthIO/lh-ehr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrestoreSession.php
76 lines (74 loc) · 2.94 KB
/
restoreSession.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// login.php makes sure the session ID captured here is different for each
// new login. We maintain it here because most browsers do not have separate
// cookie storage for different top-level windows. This function should be
// called just prior to invoking any server script that requires correct
// session data. onclick="top.restoreSession()" usually does the job.
//
var oemr_session_name = '<?php echo session_name(); ?>';
var oemr_session_id = '<?php echo session_id(); ?>';
var oemr_dialog_close_msg = '<?php echo xl('OK to close this other popup window?'); ?>';
//
function restoreSession() {
<?php if (!empty($GLOBALS['restore_sessions'])) { ?>
var ca = document.cookie.split('; ');
for (var i = 0; i < ca.length; ++i) {
var c = ca[i].split('=');
if (c[0] == oemr_session_name && c[1] != oemr_session_id) {
<?php if ($GLOBALS['restore_sessions'] == 2) { ?>
alert('Changing session ID from\n"' + c[1] + '" to\n"' + oemr_session_id + '"');
<?php } ?>
document.cookie = oemr_session_name + '=' + oemr_session_id + '; path=/';
}
}
<?php } ?>
return true;
}
// Pages that have a Print button or link should call this to initialize it for logging.
// This is done at page load time in case we want to hide or disable the element.
// The second argument, if present, specifies a log message to be used instead of logging
// the entire document and will always prevent hiding of the button or link.
//
function printLogSetup(elem, logdata) {
if (elem == null) return;
var doc = elem.ownerDocument;
var win = doc.defaultView || doc.parentWindow;
if (typeof(logdata) == 'undefined') logdata = null;
<?php if ($GLOBALS['gbl_print_log_option'] == 1) { ?>
if (logdata == null) {
elem.style.display = 'none';
return;
}
<?php } ?>
win.printlogdata = logdata;
elem.onclick = function () {
// This is a function definition and variables here will be evaluated when the function executes.
top.printLogPrint(this);
}
}
// Pages that would otherwise call window.print() at load time should call this instead
// to support print logging. In this case the passed argument is normally the window,
// and data to log, if specified, should be in the caller's window.printlogdata.
// If no log data is specified and the global option to hide the print feature is set,
// then no printing is done and the function returns false.
//
function printLogPrint(elem) {
var win = elem;
if (elem.ownerDocument) {
var doc = elem.ownerDocument;
win = doc.defaultView || doc.parentWindow;
}
<?php if ($GLOBALS['gbl_print_log_option'] == 1) { ?>
// Returning false means we didn't print.
if (!win.printlogdata) return false;
<?php } ?>
if (win.printlog_before_print) win.printlog_before_print();
win.print();
<?php if (!empty($GLOBALS['gbl_print_log_option'])) { ?>
comments = win.printlogdata || win.document.body.innerHTML;
top.restoreSession();
$.post("<?php echo $GLOBALS['webroot']; ?>/library/ajax/log_print_action_ajax.php",
{ comments: comments }
);
<?php } ?>
return true;
}