The Third Reminders email bug fix - contributed by arnabnaha
[openemr.git] / interface / main / calendar / index.php
blob686e34cdee571ce7a9f43b84a4ed6f72645212b5
1 <?php
2 // File: $Id$ $Name$
3 // ----------------------------------------------------------------------
4 // POST-NUKE Content Management System
5 // Copyright (C) 2001 by the Post-Nuke Development Team.
6 // http://www.postnuke.com/
7 // ----------------------------------------------------------------------
8 // Based on:
9 // PHP-NUKE Web Portal System - http://phpnuke.org/
10 // Thatware - http://thatware.org/
11 // ----------------------------------------------------------------------
12 // LICENSE
14 // This program is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU General Public License (GPL)
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
24 // To read the license please visit http://www.gnu.org/copyleft/gpl.html
25 // ----------------------------------------------------------------------
26 // Original Author of this file: Francisco Burzi
27 // Purpose of this file: Directs to the start page as defined in config.php
28 // ----------------------------------------------------------------------
30 // include base api
32 //$ignoreAuth = true;
33 include_once("../../globals.php");
34 include_once("$srcdir/calendar.inc");
35 include_once("$srcdir/patient.inc");
36 include "includes/pnre.inc.php";
37 include 'includes/pnAPI.php';
39 // From Michael Brinson 2006-09-19:
40 if (isset($_POST['pc_username'])) $_SESSION['pc_username'] = $_POST['pc_username'];
42 //(CHEMED) Facility filter
43 if (isset($_POST['all_users'])) $_SESSION['pc_username'] = $_POST['all_users'];
45 // bug fix to allow default selection of a provider
46 // added 'if..POST' check -- JRM
47 if (isset($_REQUEST['pc_username']) && $_REQUEST['pc_username']) $_SESSION['pc_username'] = $_REQUEST['pc_username'];
49 // (CHEMED) Get the width of vieport
50 if (isset($_GET['framewidth'])) $_SESSION['pc_framewidth'] = $_GET['framewidth'];
52 // FACILITY FILTERING (lemonsoftware) (CHEMED)
53 $_SESSION['pc_facility'] = 0;
55 /*********************************************************************
56 if ($_POST['pc_facility']) $_SESSION['pc_facility'] = $_POST['pc_facility'];
57 *********************************************************************/
58 if (isset($_COOKIE['pc_facility']) && $GLOBALS['set_facility_cookie']) $_SESSION['pc_facility'] = $_COOKIE['pc_facility'];
59 // override the cookie if the user doesn't have access to that facility any more
60 if ($_SESSION['userauthorized'] != 1 && $GLOBALS['restrict_user_facility']) {
61 $facilities = getUserFacilities($_SESSION['authId']);
62 // use the first facility the user has access to, unless...
63 $_SESSION['pc_facility'] = $facilities[0]['id'];
64 // if the cookie is in the users' facilities, use that.
65 foreach ($facilities as $facrow) {
66 if (($facrow['id'] == $_COOKIE['pc_facility']) && $GLOBALS['set_facility_cookie'])
67 $_SESSION['pc_facility'] = $_COOKIE['pc_facility'];
70 if (isset($_POST['pc_facility'])) $_SESSION['pc_facility'] = $_POST['pc_facility'];
71 /********************************************************************/
73 if (isset($_GET['pc_facility'])) $_SESSION['pc_facility'] = $_GET['pc_facility'];
74 if ($GLOBALS['set_facility_cookie'] && ($_SESSION['pc_facility'] > 0)) setcookie("pc_facility", $_SESSION['pc_facility'], time() + (3600 * 365));
76 // Simplifying by just using request variable instead of checking for both post and get - KHY
77 if (isset($_REQUEST['viewtype'])) $_SESSION['viewtype'] = $_REQUEST['viewtype'];
82 //if (empty($_GET['no_nav'])) {
83 // $_SESSION['last_calendar_page'] = $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'];
84 //}
86 print_r($_POST);
87 print_r($_GET);
88 print_r($_SESSION);
89 die;
91 //print_r($_SESSION);
92 // start PN
93 pnInit();
95 // Get variables
96 list($module,
97 $func,
98 $op,
99 $name,
100 $file,
101 $type,) = pnVarCleanFromInput('module',
102 'func',
103 'op',
104 'name',
105 'file',
106 'type');
108 // Defaults for variables
109 if (isset($catid)) { pnVarCleanFromInput('catid'); }
111 // check requested module and set to start module if not present
112 if (empty($name)) {
113 $name = pnConfigGetVar('startpage');
114 // fixed for the new style of loading modules and set start page for them [class007]
115 if (empty($module)) { $module = $name; }
118 // get module information
119 $modinfo = pnModGetInfo(pnModGetIDFromName($module));
121 if ($modinfo['type'] == 2)
123 // New-new style of loading modules
124 if (empty($type)) { $type = 'user'; }
125 if (empty($func)) { $func="main"; }
127 // it should be $module not $name [class007]
128 if (pnModAvailable($module)) {
129 if (pnModLoad($module, $type)) {
130 // Run the function
131 $return = pnModFunc($module, $type, $func);
132 } else {
133 $return = false;
135 } else {
136 $return = false;
139 // Sort out return of function. Can be
140 // true - finished
141 // false - display error msg
142 // text - return information
143 if ((empty($return)) || ($return == false)) {
144 // Failed to load the module
145 $output = new pnHTML();
146 $output->StartPage();
147 $output->Text('Failed to load module ' . $module .' ( At function: "'.$func.'" )');
148 $output->EndPage();
149 $output->PrintPage();
150 exit;
151 } elseif (strlen($return) > 1) {
152 // Text
153 $output = new pnHTML();
154 //$output->StartPage();
155 $output->SetInputMode(_PNH_VERBATIMINPUT);
156 $output->Text($return);
157 $output->SetInputMode(_PNH_PARSEINPUT);
158 //$output->EndPage();
159 $output->PrintPage();
160 } else {
161 // duh?
164 exit;
165 } else {
166 // Old-old style of loading modules
167 if (empty($op)) {
168 $op = "modload";
170 if (empty($file)) {
171 $file="index";
174 include 'includes/legacy.php';
175 switch ($op) {
176 case 'modload':
178 define("LOADED_AS_MODULE","1");
179 // added for the module/system seperation [class007]
180 if (file_exists('modules/' . pnVarPrepForOS($name) . '/' . pnVarPrepForOS($file) . '.php')) {
181 include 'modules/' . pnVarPrepForOS($name) . '/' . pnVarPrepForOS($file) . '.php';
182 } else {
183 // Failed to load the module
184 $output = new pnHTML();
185 //$output->StartPage();
186 $output->Text('Failed to load module ' . $module);
187 $output->EndPage();
188 $output->PrintPage();
189 exit;
191 break;
192 default:
193 // Failed to load the module
194 $output = new pnHTML();
195 //$output->StartPage();
196 $output->Text('Sorry, you cannot access this file directly...');
197 $output->EndPage();
198 $output->PrintPage();
199 break;