minor improvement to tabs style
[openemr.git] / interface / globals.php
blob22ed2e01909a3f4504298356f02888494e489aac
1 <?php
3 // Checks if the server's PHP version is compatible with OpenEMR:
4 require_once(dirname(__FILE__) . "/../common/compatibility/Checker.php");
6 use OpenEMR\Checker;
7 use Dotenv\Dotenv;
9 $response = Checker::checkPhpVersion();
10 if ($response !== true) {
11 die($response);
14 // Default values for optional variables that are allowed to be set by callers.
16 // Unless specified explicitly, apply Auth functions
17 if (!isset($ignoreAuth)) {
18 $ignoreAuth = false;
20 // Unless specified explicitly, caller is not offsite_portal and Auth is required
21 if (!isset($ignoreAuth_offsite_portal)) {
22 $ignoreAuth_offsite_portal = false;
24 // Same for onsite
25 if (!isset($ignoreAuth_onsite_portal_two)) {
26 $ignoreAuth_onsite_portal_two = false;
29 // Is this windows or non-windows? Create a boolean definition.
30 if (!defined('IS_WINDOWS')) {
31 define('IS_WINDOWS', (stripos(PHP_OS, 'WIN') === 0));
34 // Some important php.ini overrides. Defaults for these values are often
35 // too small. You might choose to adjust them further.
37 ini_set('session.gc_maxlifetime', '14400');
39 // The webserver_root and web_root are now automatically collected.
40 // If not working, can set manually below.
41 // Auto collect the full absolute directory path for openemr.
42 $webserver_root = dirname(dirname(__FILE__));
43 if (IS_WINDOWS) {
44 //convert windows path separators
45 $webserver_root = str_replace("\\", "/", $webserver_root);
47 // Collect the apache server document root (and convert to windows slashes, if needed)
48 $server_document_root = realpath($_SERVER['DOCUMENT_ROOT']);
49 if (IS_WINDOWS) {
50 //convert windows path separators
51 $server_document_root = str_replace("\\", "/", $server_document_root);
53 // Auto collect the relative html path, i.e. what you would type into the web
54 // browser after the server address to get to OpenEMR.
55 // This removes the leading portion of $webserver_root that it has in common with the web server's document
56 // root and assigns the result to $web_root. In addition to the common case where $webserver_root is
57 // /var/www/openemr and document root is /var/www, this also handles the case where document root is
58 // /var/www/html and there is an Apache "Alias" command that directs /openemr to /var/www/openemr.
59 $web_root = substr($webserver_root, strspn($webserver_root ^ $server_document_root, "\0"));
60 // Ensure web_root starts with a path separator
61 if (preg_match("/^[^\/]/", $web_root)) {
62 $web_root = "/".$web_root;
64 // The webserver_root and web_root are now automatically collected in
65 // real time per above code. If above is not working, can uncomment and
66 // set manually here:
67 // $webserver_root = "/var/www/openemr";
68 // $web_root = "/openemr";
71 // This is the directory that contains site-specific data. Change this
72 // only if you have some reason to.
73 $GLOBALS['OE_SITES_BASE'] = "$webserver_root/sites";
75 // The session name names a cookie stored in the browser.
76 // Now that restore_session() is implemented in javaScript, session IDs are
77 // effectively saved in the top level browser window and there is no longer
78 // any need to change the session name for different OpenEMR instances.
79 // On 4/8/17, added cookie_path to improve security when using different
80 // OpenEMR instances on same server to prevent session conflicts; also
81 // modified interface/login/login.php and library/restoreSession.php to be
82 // consistent with this.
83 ini_set('session.cookie_path', $web_root ? $web_root : '/');
84 session_name("OpenEMR");
86 session_start();
88 // Set the site ID if required. This must be done before any database
89 // access is attempted.
90 if (empty($_SESSION['site_id']) || !empty($_GET['site'])) {
91 if (!empty($_GET['site'])) {
92 $tmp = $_GET['site'];
93 } else {
94 if (empty($ignoreAuth)) {
95 die("Site ID is missing from session data!");
97 $tmp = $_SERVER['HTTP_HOST'];
98 if (!is_dir($GLOBALS['OE_SITES_BASE'] . "/$tmp")) {
99 $tmp = "default";
102 if (empty($tmp) || preg_match('/[^A-Za-z0-9\\-.]/', $tmp)) {
103 die("Site ID '". htmlspecialchars($tmp, ENT_NOQUOTES) . "' contains invalid characters.");
105 if (isset($_SESSION['site_id']) && ($_SESSION['site_id'] != $tmp)) {
106 // This is to prevent using session to penetrate other OpenEMR instances within same multisite module
107 session_unset(); // clear session, clean logout
108 if (isset($landingpage) && !empty($landingpage)) {
109 // OpenEMR Patient Portal use
110 header('Location: index.php?site='.$tmp);
111 } else {
112 // Main OpenEMR use
113 header('Location: ../login/login.php?site='.$tmp); // Assuming in the interface/main directory
115 exit;
117 if (!isset($_SESSION['site_id']) || $_SESSION['site_id'] != $tmp) {
118 $_SESSION['site_id'] = $tmp;
119 //error_log("Session site ID has been set to '$tmp'"); // debugging
123 // Set the site-specific directory path.
124 $GLOBALS['OE_SITE_DIR'] = $GLOBALS['OE_SITES_BASE'] . "/" . $_SESSION['site_id'];
126 // Set a site-specific uri root path.
127 $GLOBALS['OE_SITE_WEBROOT'] = $web_root . "/sites/" . $_SESSION['site_id'];
129 require_once($GLOBALS['OE_SITE_DIR'] . "/config.php");
131 // Collecting the utf8 disable flag from the sqlconf.php file in order
132 // to set the correct html encoding. utf8 vs iso-8859-1. If flag is set
133 // then set to iso-8859-1.
134 require_once(dirname(__FILE__) . "/../library/sqlconf.php");
135 if (!$disable_utf8_flag) {
136 ini_set('default_charset', 'utf-8');
137 $HTML_CHARSET = "UTF-8";
138 mb_internal_encoding('UTF-8');
139 } else {
140 ini_set('default_charset', 'iso-8859-1');
141 $HTML_CHARSET = "ISO-8859-1";
142 mb_internal_encoding('ISO-8859-1');
145 // Root directory, relative to the webserver root:
146 $GLOBALS['rootdir'] = "$web_root/interface";
147 $rootdir = $GLOBALS['rootdir'];
148 // Absolute path to the source code include and headers file directory (Full path):
149 $GLOBALS['srcdir'] = "$webserver_root/library";
150 // Absolute path to the location of documentroot directory for use with include statements:
151 $GLOBALS['fileroot'] = "$webserver_root";
152 // Absolute path to the location of interface directory for use with include statements:
153 $include_root = "$webserver_root/interface";
154 // Absolute path to the location of documentroot directory for use with include statements:
155 $GLOBALS['webroot'] = $web_root;
157 // Static assets directory, relative to the webserver root.
158 // (it is very likely that this path will be changed in the future))
159 $GLOBALS['assets_static_relative'] = "$web_root/public/assets";
161 // Relative images directory, relative to the webserver root.
162 $GLOBALS['images_static_relative'] = "$web_root/public/images";
164 // Static images directory, absolute to the webserver root.
165 $GLOBALS['images_static_absolute'] = "$webserver_root/public/images";
167 //Composer vendor directory, absolute to the webserver root.
168 $GLOBALS['vendor_dir'] = "$webserver_root/vendor";
169 $GLOBALS['fonts_dir'] = "{$web_root}/public/fonts";
170 $GLOBALS['template_dir'] = $GLOBALS['fileroot'] . "/templates/";
171 $GLOBALS['incdir'] = $include_root;
172 // Location of the login screen file
173 $GLOBALS['login_screen'] = $GLOBALS['rootdir'] . "/login_screen.php";
175 // Variable set for Eligibility Verification [EDI-271] path
176 $GLOBALS['edi_271_file_path'] = $GLOBALS['OE_SITE_DIR'] . "/edi/";
178 // Check necessary writeable paths exist for mPDF tool
179 if (is_dir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/')) {
180 if (! is_dir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/ttfontdata/')) {
181 mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/ttfontdata/', 0755);
183 if (! is_dir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/pdf_tmp/')) {
184 mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/pdf_tmp/', 0755);
186 } else {
187 mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/ttfontdata/', 0755, true);
188 mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/pdf_tmp/', 0755);
190 // Safe bet support directories exist, define them.
191 define("_MPDF_TEMP_PATH", $GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/pdf_tmp/');
192 define("_MPDF_TTFONTDATAPATH", $GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/ttfontdata/');
194 // Includes composer autoload
195 // Note this also brings in following library files:
196 // library/htmlspecialchars.inc.php - Include convenience functions with shorter names than "htmlspecialchars" (for security)
197 // library/formdata.inc.php - Include sanitization/checking functions (for security)
198 // library/sanitize.inc.php - Include sanitization/checking functions (for security)
199 // library/date_functions.php - Includes functions for date internationalization
200 // library/validation/validate_core.php - Includes functions for page validation
201 // library/translation.inc.php - Includes translation functions
202 require_once $GLOBALS['vendor_dir'] ."/autoload.php";
205 * @var Dotenv Allow a `.env` file to be read in and applied as $_SERVER variables.
207 * This allows to define a "development" environment which can then load up
208 * different variables and reporting/debugging functionality. Should be used in
209 * development only, not for production
211 * @link http://open-emr.org/wiki/index.php/Dotenv_Usage
213 if (file_exists("{$webserver_root}/.env")) {
214 $dotenv = new Dotenv($webserver_root);
215 $dotenv->load();
218 // @TODO This needs to be broken out to it's own function, but for time's sake
219 // @TODO putting it here until we land on a good place. RD 2017-05-02
221 $twigOptions = [
222 'debug' => false,
225 $twigLoader = new Twig_Loader_Filesystem();
226 $twigEnv = new Twig_Environment($twigLoader, $twigOptions);
228 if (array_key_exists('debug', $twigOptions) && $twigOptions['debug'] == true) {
229 $twigEnv->addExtension(new Twig_Extension_Debug());
231 $twigEnv->addGlobal('assets_dir', $GLOBALS['assets_static_relative']);
232 $twigEnv->addGlobal('srcdir', $GLOBALS['srcdir']);
233 $twigEnv->addGlobal('rootdir', $GLOBALS['rootdir']);
234 $twigEnv->addFilter(new Twig_SimpleFilter('translate', function ($string) {
235 return xl($string);
236 }));
238 /** Twig_Loader */
239 $GLOBALS['twigLoader'] = $twigLoader;
240 /** Twig_Environment */
241 $GLOBALS['twig'] = $twigEnv;
243 // This will open the openemr mysql connection.
244 require_once (dirname(__FILE__) . "/../library/sql.inc");
246 // Include the version file
247 require_once (dirname(__FILE__) . "/../version.php");
249 // The logging level for common/logging/logger.php
250 // Value can be TRACE, DEBUG, INFO, WARN, ERROR, or OFF:
251 // - DEBUG/INFO are great for development
252 // - INFO/WARN/ERROR are great for production
253 // - TRACE is useful when debugging hard to spot bugs
254 $GLOBALS["log_level"] = "OFF";
256 // Should Doctrine make use of connection pooling? Database connection pooling is a method
257 // used to keep database connections open so they can be reused by others. (The only reason
258 // to not use connection pooling is if your server has limited resources.)
259 $GLOBALS["doctrine_connection_pooling"] = true;
261 // Defaults for specific applications.
262 $GLOBALS['weight_loss_clinic'] = false;
263 $GLOBALS['ippf_specific'] = false;
265 // Defaults for drugs and products.
266 $GLOBALS['inhouse_pharmacy'] = false;
267 $GLOBALS['sell_non_drug_products'] = 0;
269 $glrow = sqlQuery("SHOW TABLES LIKE 'globals'");
270 if (!empty($glrow)) {
271 // Collect user specific settings from user_settings table.
273 $gl_user = array();
274 // Collect the user id first
275 $temp_authuserid = '';
276 if (!empty($_SESSION['authUserID'])) {
277 //Set the user id from the session variable
278 $temp_authuserid = $_SESSION['authUserID'];
279 } else {
280 if (!empty($_POST['authUser'])) {
281 $temp_sql_ret = sqlQuery("SELECT `id` FROM `users` WHERE `username` = ?", array($_POST['authUser']));
282 if (!empty($temp_sql_ret['id'])) {
283 //Set the user id from the login variable
284 $temp_authuserid = $temp_sql_ret['id'];
288 if (!empty($temp_authuserid)) {
289 $glres_user = sqlStatement(
290 "SELECT `setting_label`, `setting_value` " .
291 "FROM `user_settings` " .
292 "WHERE `setting_user` = ? " .
293 "AND `setting_label` LIKE 'global:%'",
294 array($temp_authuserid)
296 for ($iter=0; $row=sqlFetchArray($glres_user); $iter++) {
297 //remove global_ prefix from label
298 $row['setting_label'] = substr($row['setting_label'], 7);
299 $gl_user[$iter]=$row;
302 // Set global parameters from the database globals table.
303 // Some parameters require custom handling.
305 $GLOBALS['language_menu_show'] = array();
306 $glres = sqlStatement(
307 "SELECT gl_name, gl_index, gl_value FROM globals " .
308 "ORDER BY gl_name, gl_index"
310 while ($glrow = sqlFetchArray($glres)) {
311 $gl_name = $glrow['gl_name'];
312 $gl_value = $glrow['gl_value'];
313 // Adjust for user specific settings
314 if (!empty($gl_user)) {
315 foreach ($gl_user as $setting) {
316 if ($gl_name == $setting['setting_label']) {
317 $gl_value = $setting['setting_value'];
321 if ($gl_name == 'language_menu_other') {
322 $GLOBALS['language_menu_show'][] = $gl_value;
323 } elseif ($gl_name == 'css_header') {
324 $GLOBALS[$gl_name] = $rootdir.'/themes/'.$gl_value.'?v='.$v_js_includes;
325 $temp_css_theme_name = $gl_value;
326 } elseif ($gl_name == 'weekend_days') {
327 $GLOBALS[$gl_name] = explode(',', $gl_value);
328 } elseif ($gl_name == 'specific_application') {
329 if ($gl_value == '2') {
330 $GLOBALS['ippf_specific'] = true;
331 } elseif ($gl_value == '3') {
332 $GLOBALS['weight_loss_clinic'] = true;
334 } elseif ($gl_name == 'inhouse_pharmacy') {
335 if ($gl_value) {
336 $GLOBALS['inhouse_pharmacy'] = true;
338 if ($gl_value == '2') {
339 $GLOBALS['sell_non_drug_products'] = 1;
340 } elseif ($gl_value == '3') {
341 $GLOBALS['sell_non_drug_products'] = 2;
343 } elseif ($gl_name == 'gbl_time_zone') {
344 // The default PHP time zone is set here if it was specified, and is used
345 // as source data for the MySQL time zone here and in some other places
346 // where MySQL connections are opened.
347 if ($gl_value) {
348 date_default_timezone_set($gl_value);
350 // Synchronize MySQL time zone with PHP time zone.
351 sqlStatement("SET time_zone = ?", array((new DateTime())->format("P")));
352 } else {
353 $GLOBALS[$gl_name] = $gl_value;
356 // Language cleanup stuff.
357 $GLOBALS['language_menu_login'] = false;
358 if ((count($GLOBALS['language_menu_show']) >= 1) || $GLOBALS['language_menu_showall']) {
359 $GLOBALS['language_menu_login'] = true;
362 // Added this $GLOBALS['concurrent_layout'] set to 3 in order to support legacy forms
363 // that may use this; note this global has been removed from the standard codebase.
364 $GLOBALS['concurrent_layout'] = 3;
366 // Additional logic to override theme name.
367 // For RTL languages we substitute the theme name with the name of RTL-adapted CSS file.
368 $rtl_override = false;
369 if (isset( $_SESSION['language_direction'] )) {
370 if ($_SESSION['language_direction'] == 'rtl' &&
371 !strpos($GLOBALS['css_header'], 'rtl') ) {
372 // the $css_header_value is set above
373 $rtl_override = true;
375 } elseif (isset( $_SESSION['language_choice'] )) {
376 //this will support the onsite patient portal which will have a language choice but not yet a set language direction
377 $_SESSION['language_direction'] = getLanguageDir($_SESSION['language_choice']);
378 if ($_SESSION['language_direction'] == 'rtl' &&
379 !strpos($GLOBALS['css_header'], 'rtl')) {
380 // the $css_header_value is set above
381 $rtl_override = true;
383 } else {
384 //$_SESSION['language_direction'] is not set, so will use the default language
385 $default_lang_id = sqlQuery('SELECT lang_id FROM lang_languages WHERE lang_description = ?', array($GLOBALS['language_default']));
387 if (getLanguageDir($default_lang_id['lang_id']) === 'rtl' && !strpos($GLOBALS['css_header'], 'rtl')) {
388 // @todo eliminate 1 SQL query
389 $rtl_override = true;
394 // change theme name, if the override file exists.
395 if ($rtl_override) {
396 // the $css_header_value is set above
397 $new_theme = 'rtl_' . $temp_css_theme_name;
399 // Check file existance
400 if (file_exists($include_root.'/themes/'.$new_theme)) {
401 $GLOBALS['css_header'] = $rootdir.'/themes/'.$new_theme.'?v='.$v_js_includes;
402 } else {
403 // throw a warning if rtl'ed file does not exist.
404 error_log("Missing theme file ".text($include_root).'/themes/'.text($new_theme));
407 unset( $temp_css_theme_name, $new_theme,$rtl_override);
408 // end of RTL section
411 // End of globals table processing.
412 } else {
413 // Temporary stuff to handle the case where the globals table does not
414 // exist yet. This will happen in sql_upgrade.php on upgrading to the
415 // first release containing this table.
416 $GLOBALS['language_menu_login'] = true;
417 $GLOBALS['language_menu_showall'] = true;
418 $GLOBALS['language_menu_show'] = array('English (Standard)','Swedish');
419 $GLOBALS['language_default'] = "English (Standard)";
420 $GLOBALS['translate_layout'] = true;
421 $GLOBALS['translate_lists'] = true;
422 $GLOBALS['translate_gacl_groups'] = true;
423 $GLOBALS['translate_form_titles'] = true;
424 $GLOBALS['translate_document_categories'] = true;
425 $GLOBALS['translate_appt_categories'] = true;
426 $timeout = 7200;
427 $openemr_name = 'OpenEMR';
428 $css_header = "$rootdir/themes/style_default.css";
429 $GLOBALS['css_header'] = $css_header;
430 $GLOBALS['schedule_start'] = 8;
431 $GLOBALS['schedule_end'] = 17;
432 $GLOBALS['calendar_interval'] = 15;
433 $GLOBALS['phone_country_code'] = '1';
434 $GLOBALS['disable_non_default_groups'] = true;
435 $GLOBALS['ippf_specific'] = false;
438 // If >0 this will enforce a separate PHP session for each top-level
439 // browser window. You must log in separately for each. This is not
440 // thoroughly tested yet and some browsers might have trouble with it,
441 // so make it 0 if you must. Alternatively, you can set it to 2 to be
442 // notified when the session ID changes.
443 $GLOBALS['restore_sessions'] = 1; // 0=no, 1=yes, 2=yes+debug
445 // Theme definition. All this stuff should be moved to CSS.
447 $top_bg_line = ' bgcolor="#dddddd" ';
448 $GLOBALS['style']['BGCOLOR2'] = "#dddddd";
449 $bottom_bg_line = $top_bg_line;
450 $title_bg_line = ' bgcolor="#bbbbbb" ';
451 $nav_bg_line = ' bgcolor="#94d6e7" ';
452 $login_filler_line = ' bgcolor="#f7f0d5" ';
453 $logocode = "<img class='img-responsive center-block' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/login_logo.gif'>";
454 // optimal size for the tiny logo is height 43 width 86 px
455 // inside the open emr they will be auto reduced
456 $tinylogocode1 = "<img class='tinylogopng' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/logo_1.png'>";
457 $tinylogocode2 = "<img class='tinylogopng' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/logo_2.png'>";
459 $linepic = "$rootdir/pic/repeat_vline9.gif";
460 $table_bg = ' bgcolor="#cccccc" ';
461 $GLOBALS['style']['BGCOLOR1'] = "#cccccc";
462 $GLOBALS['style']['TEXTCOLOR11'] = "#222222";
463 $GLOBALS['style']['HIGHLIGHTCOLOR'] = "#dddddd";
464 $GLOBALS['style']['BOTTOM_BG_LINE'] = $bottom_bg_line;
465 // The height in pixels of the Logo bar at the top of the login page:
466 $GLOBALS['logoBarHeight'] = 110;
467 // The height in pixels of the Navigation bar:
468 $GLOBALS['navBarHeight'] = 22;
469 // The height in pixels of the Title bar:
470 $GLOBALS['titleBarHeight'] = 40;
472 // The assistant word, MORE printed next to titles that can be clicked:
473 // Note this label gets translated here via the xl function
474 // -if you don't want it translated, then strip the xl function away
475 $tmore = xl('(More)');
476 // The assistant word, BACK printed next to titles that return to previous screens:
477 // Note this label gets translated here via the xl function
478 // -if you don't want it translated, then strip the xl function away
479 $tback = xl('(Back)');
481 // This is the idle logout function:
482 // if a page has not been refreshed within this many seconds, the interface
483 // will return to the login page
484 if (!empty($special_timeout)) {
485 $timeout = intval($special_timeout);
488 $versionService = new \services\VersionService();
489 $version = $versionService->fetch();
491 if (!empty($version)) {
492 //Version tag
493 $patch_appending = "";
494 //Collected below function call to a variable, since unable to directly include
495 // function calls within empty() in php versions < 5.5 .
496 $version_getrealpatch = $version->getRealPatch();
497 if (($version->getRealPatch() != '0') && (!(empty($version_getrealpatch)))) {
498 $patch_appending = " (".$version->getRealPatch().")";
501 $openemr_version = $version->getMajor() . "." . $version->getMinor() . "." . $version->getPatch();
502 $openemr_version .= $version->getTag() . $patch_appending;
503 } else {
504 $openemr_version = xl('Unknown version');
507 $srcdir = $GLOBALS['srcdir'];
508 $login_screen = $GLOBALS['login_screen'];
509 $GLOBALS['css_header'] = $css_header;
510 $GLOBALS['backpic'] = $backpic;
512 // 1 = send email message to given id for Emergency Login user activation,
513 // else 0.
514 $GLOBALS['Emergency_Login_email'] = empty($GLOBALS['Emergency_Login_email_id']) ? 0 : 1;
516 //set include_de_identification to enable De-identification (currently de-identification works fine only with linux machines)
517 //Run de_identification_upgrade.php script to upgrade OpenEMR database to include procedures,
518 //functions, tables for de-identification(Mysql root user and password is required for successful
519 //execution of the de-identification upgrade script)
520 $GLOBALS['include_de_identification']=0;
521 // Include the authentication module code here, but the rule is
522 // if the file has the word "login" in the source code file name,
523 // don't include the authentication module - we do this to avoid
524 // include loops.
526 if (($ignoreAuth_offsite_portal === true) && ($GLOBALS['portal_offsite_enable'] == 1)) {
527 $ignoreAuth = true;
528 } elseif (($ignoreAuth_onsite_portal_two === true) && ($GLOBALS['portal_onsite_two_enable'] == 1)) {
529 $ignoreAuth = true;
531 if (!$ignoreAuth) {
532 include_once("$srcdir/auth.inc");
536 // This is the background color to apply to form fields that are searchable.
537 // Currently it is applicable only to the "Search or Add Patient" form.
538 $GLOBALS['layout_search_color'] = '#ffff55';
540 //EMAIL SETTINGS
541 $SMTP_Auth = !empty($GLOBALS['SMTP_USER']);
544 //module configurations
545 $GLOBALS['baseModDir'] = "interface/modules/"; //default path of modules
546 $GLOBALS['customModDir'] = "custom_modules"; //non zend modules
547 $GLOBALS['zendModDir'] = "zend_modules"; //zend modules
549 // Don't change anything below this line. ////////////////////////////
551 $encounter = empty($_SESSION['encounter']) ? 0 : $_SESSION['encounter'];
553 if (!empty($_GET['pid']) && empty($_SESSION['pid'])) {
554 $_SESSION['pid'] = $_GET['pid'];
555 } elseif (!empty($_POST['pid']) && empty($_SESSION['pid'])) {
556 $_SESSION['pid'] = $_POST['pid'];
558 $pid = empty($_SESSION['pid']) ? 0 : $_SESSION['pid'];
559 $userauthorized = empty($_SESSION['userauthorized']) ? 0 : $_SESSION['userauthorized'];
560 $groupname = empty($_SESSION['authProvider']) ? 0 : $_SESSION['authProvider'];
562 //This is crucial for therapy groups and patients mechanisms to work together properly
563 $attendant_type = (empty($pid) && isset($_SESSION['therapy_group'])) ? 'gid' : 'pid';
564 $therapy_group = (empty($pid) && isset($_SESSION['therapy_group'])) ? $_SESSION['therapy_group'] : 0;
566 // global interface function to format text length using ellipses
567 function strterm($string, $length)
569 if (strlen($string) >= ($length-3)) {
570 return substr($string, 0, $length-3) . "...";
571 } else {
572 return $string;
576 // Override temporary_files_dir if PHP >= 5.2.1.
577 if (version_compare(phpversion(), "5.2.1", ">=")) {
578 $GLOBALS['temporary_files_dir'] = rtrim(sys_get_temp_dir(), '/');
581 // turn off PHP compatibility warnings
582 ini_set("session.bug_compat_warn", "off");