Portal Update Forum Request (#2068)
[openemr.git] / interface / globals.php
blob9dfc4df96b76837993d6d7fd0cda3330273bdf17
1 <?php
2 /**
3 * Default values for optional variables that are allowed to be set by callers.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
12 // Checks if the server's PHP version is compatible with OpenEMR:
13 require_once(dirname(__FILE__) . "/../common/compatibility/Checker.php");
15 use OpenEMR\Common\Checker;
16 use OpenEMR\Core\Kernel;
17 use Dotenv\Dotenv;
19 $response = Checker::checkPhpVersion();
20 if ($response !== true) {
21 die($response);
24 //This is to help debug the ssl mysql connection. This will send messages to php log to show if mysql connections have a cipher set up.
25 $GLOBALS['debug_ssl_mysql_connection'] = false;
27 // Unless specified explicitly, apply Auth functions
28 if (!isset($ignoreAuth)) {
29 $ignoreAuth = false;
32 // Unless specified explicitly, caller is not offsite_portal and Auth is required
33 if (!isset($ignoreAuth_offsite_portal)) {
34 $ignoreAuth_offsite_portal = false;
37 // Same for onsite
38 if (!isset($ignoreAuth_onsite_portal_two)) {
39 $ignoreAuth_onsite_portal_two = false;
42 // Is this windows or non-windows? Create a boolean definition.
43 if (!defined('IS_WINDOWS')) {
44 define('IS_WINDOWS', (stripos(PHP_OS, 'WIN') === 0));
47 // Some important php.ini overrides. Defaults for these values are often
48 // too small. You might choose to adjust them further.
50 ini_set('session.gc_maxlifetime', '14400');
52 // The webserver_root and web_root are now automatically collected.
53 // If not working, can set manually below.
54 // Auto collect the full absolute directory path for openemr.
55 $webserver_root = dirname(dirname(__FILE__));
56 if (IS_WINDOWS) {
57 //convert windows path separators
58 $webserver_root = str_replace("\\", "/", $webserver_root);
61 // Collect the apache server document root (and convert to windows slashes, if needed)
62 $server_document_root = realpath($_SERVER['DOCUMENT_ROOT']);
63 if (IS_WINDOWS) {
64 //convert windows path separators
65 $server_document_root = str_replace("\\", "/", $server_document_root);
68 // Auto collect the relative html path, i.e. what you would type into the web
69 // browser after the server address to get to OpenEMR.
70 // This removes the leading portion of $webserver_root that it has in common with the web server's document
71 // root and assigns the result to $web_root. In addition to the common case where $webserver_root is
72 // /var/www/openemr and document root is /var/www, this also handles the case where document root is
73 // /var/www/html and there is an Apache "Alias" command that directs /openemr to /var/www/openemr.
74 $web_root = substr($webserver_root, strspn($webserver_root ^ $server_document_root, "\0"));
75 // Ensure web_root starts with a path separator
76 if (preg_match("/^[^\/]/", $web_root)) {
77 $web_root = "/".$web_root;
80 // The webserver_root and web_root are now automatically collected in
81 // real time per above code. If above is not working, can uncomment and
82 // set manually here:
83 // $webserver_root = "/var/www/openemr";
84 // $web_root = "/openemr";
87 // This is the directory that contains site-specific data. Change this
88 // only if you have some reason to.
89 $GLOBALS['OE_SITES_BASE'] = "$webserver_root/sites";
91 // The session name names a cookie stored in the browser.
92 // Now that restore_session() is implemented in javaScript, session IDs are
93 // effectively saved in the top level browser window and there is no longer
94 // any need to change the session name for different OpenEMR instances.
95 // On 4/8/17, added cookie_path to improve security when using different
96 // OpenEMR instances on same server to prevent session conflicts; also
97 // modified interface/login/login.php and library/restoreSession.php to be
98 // consistent with this.
99 ini_set('session.cookie_path', $web_root ? $web_root : '/');
100 session_name("OpenEMR");
102 session_start();
104 // Set the site ID if required. This must be done before any database
105 // access is attempted.
106 if (empty($_SESSION['site_id']) || !empty($_GET['site'])) {
107 if (!empty($_GET['site'])) {
108 $tmp = $_GET['site'];
109 } else {
110 if (empty($ignoreAuth)) {
111 // mdsupport - Don't die if logout menu link is called from expired session.
112 // Eliminate this code when close method is available for session management.
113 if ((isset($_GET['auth'])) && ($_GET['auth'] == "logout")) {
114 $GLOBALS['login_screen'] = "login_screen.php";
115 $srcdir = "../library";
116 require_once("$srcdir/auth.inc");
118 die("Site ID is missing from session data!");
121 $tmp = $_SERVER['HTTP_HOST'];
122 if (!is_dir($GLOBALS['OE_SITES_BASE'] . "/$tmp")) {
123 $tmp = "default";
127 if (empty($tmp) || preg_match('/[^A-Za-z0-9\\-.]/', $tmp)) {
128 die("Site ID '". text($tmp) . "' contains invalid characters.");
131 if (isset($_SESSION['site_id']) && ($_SESSION['site_id'] != $tmp)) {
132 // This is to prevent using session to penetrate other OpenEMR instances within same multisite module
133 session_unset(); // clear session, clean logout
134 if (isset($landingpage) && !empty($landingpage)) {
135 // OpenEMR Patient Portal use
136 header('Location: index.php?site=' . urlencode($tmp));
137 } else {
138 // Main OpenEMR use
139 header('Location: ../login/login.php?site=' . urlencode($tmp)); // Assuming in the interface/main directory
142 exit;
145 if (!isset($_SESSION['site_id']) || $_SESSION['site_id'] != $tmp) {
146 $_SESSION['site_id'] = $tmp;
147 //error_log("Session site ID has been set to '$tmp'"); // debugging
151 // Set the site-specific directory path.
152 $GLOBALS['OE_SITE_DIR'] = $GLOBALS['OE_SITES_BASE'] . "/" . $_SESSION['site_id'];
154 // Set a site-specific uri root path.
155 $GLOBALS['OE_SITE_WEBROOT'] = $web_root . "/sites/" . $_SESSION['site_id'];
157 require_once($GLOBALS['OE_SITE_DIR'] . "/config.php");
159 // Collecting the utf8 disable flag from the sqlconf.php file in order
160 // to set the correct html encoding. utf8 vs iso-8859-1. If flag is set
161 // then set to iso-8859-1.
162 require_once(dirname(__FILE__) . "/../library/sqlconf.php");
163 if (!$disable_utf8_flag) {
164 ini_set('default_charset', 'utf-8');
165 $HTML_CHARSET = "UTF-8";
166 mb_internal_encoding('UTF-8');
167 } else {
168 ini_set('default_charset', 'iso-8859-1');
169 $HTML_CHARSET = "ISO-8859-1";
170 mb_internal_encoding('ISO-8859-1');
173 // Root directory, relative to the webserver root:
174 $GLOBALS['rootdir'] = "$web_root/interface";
175 $rootdir = $GLOBALS['rootdir'];
176 // Absolute path to the source code include and headers file directory (Full path):
177 $GLOBALS['srcdir'] = "$webserver_root/library";
178 // Absolute path to the location of documentroot directory for use with include statements:
179 $GLOBALS['fileroot'] = "$webserver_root";
180 // Absolute path to the location of interface directory for use with include statements:
181 $include_root = "$webserver_root/interface";
182 // Absolute path to the location of documentroot directory for use with include statements:
183 $GLOBALS['webroot'] = $web_root;
185 // Static assets directory, relative to the webserver root.
186 // (it is very likely that this path will be changed in the future))
187 $GLOBALS['assets_static_relative'] = "$web_root/public/assets";
189 // Relative images directory, relative to the webserver root.
190 $GLOBALS['images_static_relative'] = "$web_root/public/images";
192 // Static images directory, absolute to the webserver root.
193 $GLOBALS['images_static_absolute'] = "$webserver_root/public/images";
195 //Composer vendor directory, absolute to the webserver root.
196 $GLOBALS['vendor_dir'] = "$webserver_root/vendor";
197 $GLOBALS['fonts_dir'] = "{$web_root}/public/fonts";
198 $GLOBALS['template_dir'] = $GLOBALS['fileroot'] . "/templates/";
199 $GLOBALS['incdir'] = $include_root;
200 // Location of the login screen file
201 $GLOBALS['login_screen'] = $GLOBALS['rootdir'] . "/login_screen.php";
203 // Variable set for Eligibility Verification [EDI-271] path
204 $GLOBALS['edi_271_file_path'] = $GLOBALS['OE_SITE_DIR'] . "/edi/";
206 // Set and check that necessary writeable path exist for mPDF tool
207 $GLOBALS['MPDF_WRITE_DIR'] = $GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/pdf_tmp';
208 if (! is_dir($GLOBALS['MPDF_WRITE_DIR'])) {
209 mkdir($GLOBALS['MPDF_WRITE_DIR'], 0755, true);
212 // Includes composer autoload
213 // Note this also brings in following library files:
214 // library/htmlspecialchars.inc.php - Include convenience functions with shorter names than "htmlspecialchars" (for security)
215 // library/formdata.inc.php - Include sanitization/checking functions (for security)
216 // library/sanitize.inc.php - Include sanitization/checking functions (for security)
217 // library/formatting.inc.php - Includes functions for date/time internationalization and formatting
218 // library/date_functions.php - Includes functions for date internationalization
219 // library/validation/validate_core.php - Includes functions for page validation
220 // library/translation.inc.php - Includes translation functions
221 require_once $GLOBALS['vendor_dir'] ."/autoload.php";
223 // Set up csrf token
224 // This is done in cases where it is not yet set for the session
225 // (note this is permanently done for the session in the main_screen.php script)
226 if (empty($_SESSION['csrf_token'])) {
227 $_SESSION['csrf_token'] = createCsrfToken();
231 * @var Dotenv Allow a `.env` file to be read in and applied as $_SERVER variables.
233 * This allows to define a "development" environment which can then load up
234 * different variables and reporting/debugging functionality. Should be used in
235 * development only, not for production
237 * @link http://open-emr.org/wiki/index.php/Dotenv_Usage
239 if (file_exists("{$webserver_root}/.env")) {
240 $dotenv = new Dotenv($webserver_root);
241 $dotenv->load();
244 // @TODO This needs to be broken out to it's own function, but for time's sake
245 // @TODO putting it here until we land on a good place. RD 2017-05-02
247 $twigOptions = [
248 'debug' => false,
251 $twigLoader = new Twig_Loader_Filesystem();
252 $twigEnv = new Twig_Environment($twigLoader, $twigOptions);
254 if (array_key_exists('debug', $twigOptions) && $twigOptions['debug'] == true) {
255 $twigEnv->addExtension(new Twig_Extension_Debug());
258 $twigEnv->addGlobal('assets_dir', $GLOBALS['assets_static_relative']);
259 $twigEnv->addGlobal('srcdir', $GLOBALS['srcdir']);
260 $twigEnv->addGlobal('rootdir', $GLOBALS['rootdir']);
261 $twigEnv->addFilter(new Twig_SimpleFilter('translate', function ($string) {
262 return xl($string);
263 }));
265 /** Twig_Loader */
266 $GLOBALS['twigLoader'] = $twigLoader;
267 /** Twig_Environment */
268 $GLOBALS['twig'] = $twigEnv;
270 // This will open the openemr mysql connection.
271 require_once(dirname(__FILE__) . "/../library/sql.inc");
273 // Include the version file
274 require_once(dirname(__FILE__) . "/../version.php");
276 // The logging level for common/logging/logger.php
277 // Value can be TRACE, DEBUG, INFO, WARN, ERROR, or OFF:
278 // - DEBUG/INFO are great for development
279 // - INFO/WARN/ERROR are great for production
280 // - TRACE is useful when debugging hard to spot bugs
281 $GLOBALS["log_level"] = "OFF";
283 try {
284 /** @var Kernel */
285 $GLOBALS["kernel"] = new Kernel();
286 } catch (\Exception $e) {
287 error_log($e->getMessage());
288 die();
291 // Should Doctrine make use of connection pooling? Database connection pooling is a method
292 // used to keep database connections open so they can be reused by others. (The only reason
293 // to not use connection pooling is if your server has limited resources.)
294 $GLOBALS["doctrine_connection_pooling"] = true;
296 // Defaults for specific applications.
297 $GLOBALS['weight_loss_clinic'] = false;
298 $GLOBALS['ippf_specific'] = false;
300 // Defaults for drugs and products.
301 $GLOBALS['inhouse_pharmacy'] = false;
302 $GLOBALS['sell_non_drug_products'] = 0;
304 $glrow = sqlQuery("SHOW TABLES LIKE 'globals'");
305 if (!empty($glrow)) {
306 // Collect user specific settings from user_settings table.
308 $gl_user = array();
309 // Collect the user id first
310 $temp_authuserid = '';
311 if (!empty($_SESSION['authUserID'])) {
312 //Set the user id from the session variable
313 $temp_authuserid = $_SESSION['authUserID'];
314 } else {
315 if (!empty($_POST['authUser'])) {
316 $temp_sql_ret = sqlQuery("SELECT `id` FROM `users` WHERE `username` = ?", array($_POST['authUser']));
317 if (!empty($temp_sql_ret['id'])) {
318 //Set the user id from the login variable
319 $temp_authuserid = $temp_sql_ret['id'];
324 if (!empty($temp_authuserid)) {
325 $glres_user = sqlStatement(
326 "SELECT `setting_label`, `setting_value` " .
327 "FROM `user_settings` " .
328 "WHERE `setting_user` = ? " .
329 "AND `setting_label` LIKE 'global:%'",
330 array($temp_authuserid)
332 for ($iter=0; $row=sqlFetchArray($glres_user); $iter++) {
333 //remove global_ prefix from label
334 $row['setting_label'] = substr($row['setting_label'], 7);
335 $gl_user[$iter]=$row;
339 // Set global parameters from the database globals table.
340 // Some parameters require custom handling.
342 $GLOBALS['language_menu_show'] = array();
343 $glres = sqlStatement(
344 "SELECT gl_name, gl_index, gl_value FROM globals " .
345 "ORDER BY gl_name, gl_index"
347 while ($glrow = sqlFetchArray($glres)) {
348 $gl_name = $glrow['gl_name'];
349 $gl_value = $glrow['gl_value'];
350 // Adjust for user specific settings
351 if (!empty($gl_user)) {
352 foreach ($gl_user as $setting) {
353 if ($gl_name == $setting['setting_label']) {
354 $gl_value = $setting['setting_value'];
359 if ($gl_name == 'language_menu_other') {
360 $GLOBALS['language_menu_show'][] = $gl_value;
361 } elseif ($gl_name == 'css_header') {
362 //Escape css file name using 'attr' for security (prevent XSS).
363 $GLOBALS[$gl_name] = $web_root.'/public/themes/'.attr($gl_value).'?v='.$v_js_includes;
364 $css_header = $GLOBALS[$gl_name];
365 $temp_css_theme_name = $gl_value;
366 } elseif ($gl_name == 'weekend_days') {
367 $GLOBALS[$gl_name] = explode(',', $gl_value);
368 } elseif ($gl_name == 'specific_application') {
369 if ($gl_value == '2') {
370 $GLOBALS['ippf_specific'] = true;
371 } elseif ($gl_value == '3') {
372 $GLOBALS['weight_loss_clinic'] = true;
374 } elseif ($gl_name == 'inhouse_pharmacy') {
375 if ($gl_value) {
376 $GLOBALS['inhouse_pharmacy'] = true;
379 if ($gl_value == '2') {
380 $GLOBALS['sell_non_drug_products'] = 1;
381 } elseif ($gl_value == '3') {
382 $GLOBALS['sell_non_drug_products'] = 2;
384 } elseif ($gl_name == 'gbl_time_zone') {
385 // The default PHP time zone is set here if it was specified, and is used
386 // as source data for the MySQL time zone here and in some other places
387 // where MySQL connections are opened.
388 if ($gl_value) {
389 date_default_timezone_set($gl_value);
392 // Synchronize MySQL time zone with PHP time zone.
393 sqlStatement("SET time_zone = ?", array((new DateTime())->format("P")));
394 } else {
395 $GLOBALS[$gl_name] = $gl_value;
399 // Language cleanup stuff.
400 $GLOBALS['language_menu_login'] = false;
401 if ((count($GLOBALS['language_menu_show']) > 1) || $GLOBALS['language_menu_showall']) {
402 $GLOBALS['language_menu_login'] = true;
405 // Added this $GLOBALS['concurrent_layout'] set to 3 in order to support legacy forms
406 // that may use this; note this global has been removed from the standard codebase.
407 $GLOBALS['concurrent_layout'] = 3;
409 // Additional logic to override theme name.
410 // For RTL languages we substitute the theme name with the name of RTL-adapted CSS file.
411 $rtl_override = false;
412 if (isset($_SESSION['language_direction'])) {
413 if ($_SESSION['language_direction'] == 'rtl' &&
414 !strpos($GLOBALS['css_header'], 'rtl') ) {
415 // the $css_header_value is set above
416 $rtl_override = true;
418 } elseif (isset($_SESSION['language_choice'])) {
419 //this will support the onsite patient portal which will have a language choice but not yet a set language direction
420 $_SESSION['language_direction'] = getLanguageDir($_SESSION['language_choice']);
421 if ($_SESSION['language_direction'] == 'rtl' &&
422 !strpos($GLOBALS['css_header'], 'rtl')) {
423 // the $css_header_value is set above
424 $rtl_override = true;
426 } else {
427 //$_SESSION['language_direction'] is not set, so will use the default language
428 $default_lang_id = sqlQuery('SELECT lang_id FROM lang_languages WHERE lang_description = ?', array($GLOBALS['language_default']));
430 if (getLanguageDir($default_lang_id['lang_id']) === 'rtl' && !strpos($GLOBALS['css_header'], 'rtl')) {
431 // @todo eliminate 1 SQL query
432 $rtl_override = true;
437 // change theme name, if the override file exists.
438 if ($rtl_override) {
439 // the $css_header_value is set above
440 $new_theme = 'rtl_' . $temp_css_theme_name;
442 // Check file existance
443 if (file_exists($webserver_root.'/public/themes/'.$new_theme)) {
444 //Escape css file name using 'attr' for security (prevent XSS).
445 $GLOBALS['css_header'] = $web_root.'/public/themes/'.attr($new_theme).'?v='.$v_js_includes;
446 $css_header = $GLOBALS['css_header'];
447 } else {
448 // throw a warning if rtl'ed file does not exist.
449 error_log("Missing theme file ".text($webserver_root).'/public/themes/'.text($new_theme));
453 unset($temp_css_theme_name, $new_theme, $rtl_override);
454 // end of RTL section
457 // End of globals table processing.
458 } else {
459 // Temporary stuff to handle the case where the globals table does not
460 // exist yet. This will happen in sql_upgrade.php on upgrading to the
461 // first release containing this table.
462 $GLOBALS['language_menu_login'] = true;
463 $GLOBALS['language_menu_showall'] = true;
464 $GLOBALS['language_menu_show'] = array('English (Standard)','Swedish');
465 $GLOBALS['language_default'] = "English (Standard)";
466 $GLOBALS['translate_layout'] = true;
467 $GLOBALS['translate_lists'] = true;
468 $GLOBALS['translate_gacl_groups'] = true;
469 $GLOBALS['translate_form_titles'] = true;
470 $GLOBALS['translate_document_categories'] = true;
471 $GLOBALS['translate_appt_categories'] = true;
472 $timeout = 7200;
473 $openemr_name = 'OpenEMR';
474 $css_header = "$web_root/public/themes/style_default.css";
475 $GLOBALS['css_header'] = $css_header;
476 $GLOBALS['schedule_start'] = 8;
477 $GLOBALS['schedule_end'] = 17;
478 $GLOBALS['calendar_interval'] = 15;
479 $GLOBALS['phone_country_code'] = '1';
480 $GLOBALS['disable_non_default_groups'] = true;
481 $GLOBALS['ippf_specific'] = false;
484 // If >0 this will enforce a separate PHP session for each top-level
485 // browser window. You must log in separately for each. This is not
486 // thoroughly tested yet and some browsers might have trouble with it,
487 // so make it 0 if you must. Alternatively, you can set it to 2 to be
488 // notified when the session ID changes.
489 $GLOBALS['restore_sessions'] = 1; // 0=no, 1=yes, 2=yes+debug
491 // Theme definition. All this stuff should be moved to CSS.
493 $top_bg_line = ' bgcolor="#dddddd" ';
494 $GLOBALS['style']['BGCOLOR2'] = "#dddddd";
495 $logocode = "<img class='img-responsive center-block' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/login_logo.gif'>";
496 // optimal size for the tiny logo is height 43 width 86 px
497 // inside the open emr they will be auto reduced
498 $tinylogocode1 = "<img class='tinylogopng' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/logo_1.png'>";
499 $tinylogocode2 = "<img class='tinylogopng' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/logo_2.png'>";
501 $GLOBALS['style']['BGCOLOR1'] = "#cccccc";
502 // The height in pixels of the Title bar:
503 $GLOBALS['titleBarHeight'] = 50;
505 // The assistant word, MORE printed next to titles that can be clicked:
506 // Note this label gets translated here via the xl function
507 // -if you don't want it translated, then strip the xl function away
508 $tmore = xl('(More)');
509 // The assistant word, BACK printed next to titles that return to previous screens:
510 // Note this label gets translated here via the xl function
511 // -if you don't want it translated, then strip the xl function away
512 $tback = xl('(Back)');
514 // This is the idle logout function:
515 // if a page has not been refreshed within this many seconds, the interface
516 // will return to the login page
517 if (!empty($special_timeout)) {
518 $timeout = intval($special_timeout);
521 $versionService = new \OpenEMR\Services\VersionService();
522 $version = $versionService->fetch();
524 if (!empty($version)) {
525 //Version tag
526 $patch_appending = "";
527 //Collected below function call to a variable, since unable to directly include
528 // function calls within empty() in php versions < 5.5 .
529 $version_getrealpatch = $version->getRealPatch();
530 if (($version->getRealPatch() != '0') && (!(empty($version_getrealpatch)))) {
531 $patch_appending = " (".$version->getRealPatch().")";
534 $openemr_version = $version->getMajor() . "." . $version->getMinor() . "." . $version->getPatch();
535 $openemr_version .= $version->getTag() . $patch_appending;
536 } else {
537 $openemr_version = xl('Unknown version');
540 $srcdir = $GLOBALS['srcdir'];
541 $login_screen = $GLOBALS['login_screen'];
542 $GLOBALS['backpic'] = $backpic;
544 // 1 = send email message to given id for Emergency Login user activation,
545 // else 0.
546 $GLOBALS['Emergency_Login_email'] = empty($GLOBALS['Emergency_Login_email_id']) ? 0 : 1;
548 //set include_de_identification to enable De-identification (currently de-identification works fine only with linux machines)
549 //Run de_identification_upgrade.php script to upgrade OpenEMR database to include procedures,
550 //functions, tables for de-identification(Mysql root user and password is required for successful
551 //execution of the de-identification upgrade script)
552 $GLOBALS['include_de_identification']=0;
553 // Include the authentication module code here, but the rule is
554 // if the file has the word "login" in the source code file name,
555 // don't include the authentication module - we do this to avoid
556 // include loops.
558 if (($ignoreAuth_offsite_portal === true) && ($GLOBALS['portal_offsite_enable'] == 1)) {
559 $ignoreAuth = true;
560 } elseif (($ignoreAuth_onsite_portal_two === true) && ($GLOBALS['portal_onsite_two_enable'] == 1)) {
561 $ignoreAuth = true;
564 if (!$ignoreAuth) {
565 require_once("$srcdir/auth.inc");
569 // This is the background color to apply to form fields that are searchable.
570 // Currently it is applicable only to the "Search or Add Patient" form.
571 $GLOBALS['layout_search_color'] = '#ff9919';
573 //EMAIL SETTINGS
574 $SMTP_Auth = !empty($GLOBALS['SMTP_USER']);
577 //module configurations
578 $GLOBALS['baseModDir'] = "interface/modules/"; //default path of modules
579 $GLOBALS['customModDir'] = "custom_modules"; //non zend modules
580 $GLOBALS['zendModDir'] = "zend_modules"; //zend modules
582 // Don't change anything below this line. ////////////////////////////
584 $encounter = empty($_SESSION['encounter']) ? 0 : $_SESSION['encounter'];
586 if (!empty($_GET['pid']) && empty($_SESSION['pid'])) {
587 $_SESSION['pid'] = $_GET['pid'];
588 } elseif (!empty($_POST['pid']) && empty($_SESSION['pid'])) {
589 $_SESSION['pid'] = $_POST['pid'];
592 $pid = empty($_SESSION['pid']) ? 0 : $_SESSION['pid'];
593 $userauthorized = empty($_SESSION['userauthorized']) ? 0 : $_SESSION['userauthorized'];
594 $groupname = empty($_SESSION['authProvider']) ? 0 : $_SESSION['authProvider'];
596 //This is crucial for therapy groups and patients mechanisms to work together properly
597 $attendant_type = (empty($pid) && isset($_SESSION['therapy_group'])) ? 'gid' : 'pid';
598 $therapy_group = (empty($pid) && isset($_SESSION['therapy_group'])) ? $_SESSION['therapy_group'] : 0;
600 // global interface function to format text length using ellipses
601 function strterm($string, $length)
603 if (strlen($string) >= ($length-3)) {
604 return substr($string, 0, $length-3) . "...";
605 } else {
606 return $string;
610 // Override temporary_files_dir
611 $GLOBALS['temporary_files_dir'] = rtrim(sys_get_temp_dir(), '/');
613 // turn off PHP compatibility warnings
614 ini_set("session.bug_compat_warn", "off");