Highway to PSR2
[openemr.git] / interface / main / calendar / modules / PostCalendar / plugins / function.pc_url.php
blob0003b33b4b1355f46059c5958bc9c453d74e4d08
1 <?php
2 /**
3 * $Id$
5 * PostCalendar::PostNuke Events Calendar Module
6 * Copyright (C) 2002 The PostCalendar Team
7 * http://postcalendar.tv
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * To read the license please read the docs/license.txt or visit
24 * http://www.gnu.org/copyleft/gpl.html
27 function smarty_function_pc_url($args)
30 //print "<br />args<br />";
31 //print_r($args);
32 //print "<br />args<br />";
33 extract($args);
34 unset($args);
36 if (!isset($action)) {
37 $action = _SETTING_DEFAULT_VIEW;
40 if (empty($print)) {
41 $print = false;
42 } else {
43 $print = true;
46 $starth = "";
47 if ($setdeftime == 1) {
48 $starth = date("H");
51 $ampm = 1;
52 if ($starth >= 12) {
53 $ampm= 2;
56 $template_view = pnVarCleanFromInput('tplview');
57 $viewtype = strtolower(pnVarCleanFromInput('viewtype'));
58 // pnVarCleanFromInput('pc_username'); //(CHEMED) replaced by the code below
59 //(CHEMED) Facility filtering
60 $pc_username = $_SESSION['pc_username'];
61 $pc_facility = $_SESSION['pc_facility'];
62 //END (CHEMED)
64 $category = pnVarCleanFromInput('pc_category');
65 $topic = pnVarCleanFromInput('pc_topic');
66 $popup = pnVarCleanFromInput('popup');
67 if (!isset($date)) {
68 $Date = postcalendar_getDate();
69 } else {
70 $Date = $date;
73 // some extra cleanup if necessary
74 $Date = str_replace('-', '', $Date);
76 $pcModInfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__));
77 $pcDir = pnVarPrepForOS($pcModInfo['directory']);
79 switch ($action) {
80 case 'submit':
81 if (!empty($starth)) {
82 $link = pnModURL(__POSTCALENDAR__, 'user', 'submit', array('tplview'=>$template_view,'Date'=>$Date, 'event_starttimeh' => $starth, 'event_startampm' => $ampm));
83 } else {
84 $link = pnModURL(__POSTCALENDAR__, 'user', 'submit', array('tplview'=>$template_view,'Date'=>$Date));
86 break;
88 case 'submit-admin':
89 $link = pnModURL(__POSTCALENDAR__, 'admin', 'submit', array('tplview'=>$template_view,'Date'=>$Date));
90 break;
92 case 'search':
93 $link = pnModURL(__POSTCALENDAR__, 'user', 'search');
94 break;
96 case 'day':
97 $link = pnModURL(__POSTCALENDAR__, 'user', 'view', array('tplview'=>$template_view,
98 'viewtype'=>'day',
99 'Date'=>$Date,
100 'pc_facility'=>$pc_facility,
101 'pc_username'=>$pc_username,
102 'pc_category'=>$category,
103 'pc_topic'=>$topic,
104 'print'=>$print), $localpath);
105 break;
107 case 'week':
108 $link = pnModURL(__POSTCALENDAR__, 'user', 'view', array('tplview'=>$template_view,
109 'viewtype'=>'week',
110 'Date'=>$Date,
111 'pc_facility'=>$pc_facility,
112 'pc_username'=>$pc_username,
113 'pc_category'=>$category,
114 'pc_topic'=>$topic,
115 'print'=>$print));
116 break;
118 case 'month':
119 $link = pnModURL(__POSTCALENDAR__, 'user', 'view', array('tplview'=>$template_view,
120 'viewtype'=>'month',
121 'Date'=>$Date,
122 'pc_facility'=>$pc_facility,
123 'pc_username'=>$pc_username,
124 'pc_category'=>$category,
125 'pc_topic'=>$topic,
126 'print'=>$print));
127 break;
129 case 'year':
130 $link = pnModURL(__POSTCALENDAR__, 'user', 'view', array('tplview'=>$template_view,
131 'viewtype'=>'year',
132 'Date'=>$Date,
133 'pc_facility'=>$pc_facility,
134 'pc_username'=>$pc_username,
135 'pc_category'=>$category,
136 'pc_topic'=>$topic,
137 'print'=>$print));
138 break;
140 case 'detail':
141 if (isset($eid)) {
142 if (_SETTING_OPEN_NEW_WINDOW && !$popup) {
143 $link = "javascript:opencal($eid,'$Date');";
144 } else {
145 $link = pnModURL(__POSTCALENDAR__, 'user', 'view', array('Date'=>$Date,
146 'tplview'=>$template_view,
147 'viewtype'=>'details',
148 'eid'=>$eid,
149 'print'=>$print), $localpath);
151 } else {
152 $link = '';
154 break;
157 if ($print) {
158 $link .= '" target="_blank"';
159 } elseif (_SETTING_OPEN_NEW_WINDOW && $viewtype == 'details') {
160 $link .= '" target="csCalendar"';
163 echo $link;