3 @define
('__POSTCALENDAR__', 'PostCalendar');
7 * PostCalendar::PostNuke Events Calendar Module
8 * Copyright (C) 2002 The PostCalendar Team
9 * http://postcalendar.tv
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 * To read the license please read the docs/license.txt or visit
26 * http://www.gnu.org/copyleft/gpl.html
30 use OpenEMR\Common\Acl\AclMain
;
31 use OpenEMR\Common\Acl\AclExtended
;
32 use OpenEMR\Core\Header
;
33 use OpenEMR\Events\Core\ScriptFilterEvent
;
34 use OpenEMR\Events\Core\StyleFilterEvent
;
36 //=========================================================================
37 // Load the API Functions
38 //=========================================================================
39 pnModAPILoad(__POSTCALENDAR__
, 'admin');
41 function postcalendar_admin_modifyconfig($msg = '', $showMenu = true)
43 $output = new pnHTML();
45 $output->SetInputMode(_PNH_VERBATIMINPUT
);
47 $header = "<html><head><title>" . xlt("Calendar") . "</title>";
48 $header .= Header
::setupHeader('', false) . '</head><body>';
50 $output->Text($header);
53 $output->Text(postcalendar_adminmenu("clearCache"));
54 $output -> Text('<div class="alert alert-success mx-1 text-center" role="alert">');
55 $output->Text("<b>$msg</b>");
56 $output -> Text('</div>');
59 $output->Text(postcalendar_adminmenu(""));
63 $output->Text("</body></html>");
65 return $output->GetOutput();
68 function postcalendar_admin_categoriesConfirm()
70 $output = new pnHTML();
71 $output->SetInputMode(_PNH_VERBATIMINPUT
);
76 $header .= Header
::setupHeader('', false) . '</head><body><div class="container">';
77 $output->Text($header);
78 $output->Text(postcalendar_adminmenu("category"));
79 list($id, $del, $name, $constantid, $value_cat_type, $desc, $color,
80 $event_repeat, $event_repeat_freq,
81 $event_repeat_freq_type, $event_repeat_on_num,
82 $event_repeat_on_day, $event_repeat_on_freq, $durationh, $durationm,
83 $end_date_flag, $end_date_type, $end_date_freq, $end_all_day, $active, $sequence, $aco,
84 $newname, $newconstantid, $newdesc, $newcolor, $new_event_repeat, $new_event_repeat_freq,
85 $new_event_repeat_freq_type, $new_event_repeat_on_num, $new_event_repeat_on_day,
86 $new_event_repeat_on_freq, $new_durationh, $new_durationm, $new_limitid, $new_end_date_flag,
87 $new_end_date_type, $new_end_date_freq, $new_end_all_day, $new_value_cat_type, $newactive, $newsequence, $newaco
88 ) = pnVarCleanFromInput(
98 'event_repeat_freq_type',
99 'event_repeat_on_num',
100 'event_repeat_on_day',
101 'event_repeat_on_freq',
116 'newevent_repeat_freq',
117 'newevent_repeat_freq_type',
118 'newevent_repeat_on_num',
119 'newevent_repeat_on_day',
120 'newevent_repeat_on_freq',
134 foreach ($name as $i => $item) {
136 $output->Text(postcalendar_admin_categories($msg, "Category Names must contain a value!"));
137 return $output->GetOutput();
139 if (empty($constantid[$i])) {
140 $output->Text(postcalendar_admin_categories($msg, "Category Identifiers must contain a value!"));
141 return $output->GetOutput();
143 $tmp = $constantid[$i];
144 if (strpos(trim($tmp), ' ')) {
145 $output->Text(postcalendar_admin_categories($msg, "Category Identifiers must be one word!"));
146 return $output->GetOutput();
149 if (strlen($tmp) != 7 ||
$tmp[0] != "#") {
150 $e = $tmp . " size " . strlen($tmp) . " at 0 " . $tmp[0];
151 $output->Text(postcalendar_admin_categories($msg, "You entered an invalid color(USE Pick) $e!"));
152 return $output->GetOutput();
155 foreach ($durationh as $i => $val) {
157 !is_numeric($durationh[$i]) ||
!is_numeric($durationm[$i]) ||
158 !is_numeric($event_repeat_freq[$i]) ||
159 !is_numeric($event_repeat_on_freq[$i]) ||
!is_numeric($end_date_freq[$i])
161 $output->Text(postcalendar_admin_categories(
163 " Hours, Minutes and recurrence values must be numeric!"
165 return $output->GetOutput();
168 if (!empty($newnam)) {
170 !is_numeric($new_durationh) ||
171 !is_numeric($new_durationm) ||
172 !is_numeric($new_event_repeat_freq) ||
173 !is_numeric($new_event_repeat_on_freq) ||
174 !is_numeric($new_end_date_freq)
176 $output->Text(postcalendar_admin_categories($msg, "Hours, Minutes and recurrence values must be numeric!"));
177 return $output->GetOutput();
180 $new_duration = ($new_durationh * (60 * 60)) +
($new_durationm * 60);
181 $event_recurrspec = serialize(compact(
183 'event_repeat_freq_type',
184 'event_repeat_on_num',
185 'event_repeat_on_day',
186 'event_repeat_on_freq'
188 $new_event_recurrspec = serialize(compact(
189 'new_event_repeat_freq',
190 'new_event_repeat_freq_type',
191 'new_event_repeat_on_num',
192 'new_event_repeat_on_day',
193 'new_event_repeat_on_freq'
195 if (is_array($del)) {
196 $dels = implode(',', $del);
197 $delText = _PC_DELETE_CATS
. $dels . '.';
199 $output->FormStart(pnModURL(__POSTCALENDAR__
, 'admin', 'categoriesUpdate'));
200 $output->Text(_PC_ARE_YOU_SURE
);
201 $output->Linebreak(2);
203 if (isset($delText)) {
204 $output->FormHidden('dels', $dels);
205 $output->Text($delText);
206 $output->Linebreak();
208 if (!empty($newname)) {
209 if (empty($newconstantid)) {
210 $output->Text(postcalendar_admin_categories($msg, "Category Identifiers must contain a value!"));
211 return $output->GetOutput();
213 if (strpos(trim($newconstantid), ' ')) {
214 $output->Text(postcalendar_admin_categories($msg, "Category Identifiers must be one word!"));
215 return $output->GetOutput();
217 $output->FormHidden('newname', $newname);
218 $output->FormHidden('newconstantid', $newconstantid);
219 $output->FormHidden('newdesc', $newdesc);
220 $output->FormHidden('newvalue_cat_type', $new_value_cat_type);
221 $output->FormHidden('newcolor', $newcolor);
222 $output->FormHidden('newevent_repeat', $new_event_repeat);
223 $output->FormHidden('newevent_recurrfreq', $new_event_repeat_freq);
224 $output->FormHidden('newevent_recurrspec', $new_event_recurrspec);
225 $output->FormHidden('newduration', $new_duration);
226 $output->FormHidden('newlimitid', $new_limitid);
227 $output->FormHidden('newend_date_flag', $new_end_date_flag);
228 $output->FormHidden('newend_date_type', $new_end_date_type);
229 $output->FormHidden('newend_date_freq', $new_end_date_freq);
230 $output->FormHidden('newend_all_day', $new_end_all_day);
231 $output->FormHidden("newactive", $newactive);
232 $output->FormHidden("newsequence", $newsequence);
233 $output->FormHidden("newaco", $newaco);
234 $output->Text(_PC_ADD_CAT
. text($newname) . '.');
235 $output->Linebreak();
237 $output->Text(_PC_MODIFY_CATS
);
238 $output->FormHidden('id', serialize($id));
239 $output->FormHidden('del', serialize($del));
240 $output->FormHidden('name', serialize($name));
241 $output->FormHidden('constantid', serialize($constantid));
242 $output->FormHidden('desc', serialize($desc));
243 $output->FormHidden('value_cat_type', serialize($value_cat_type));
244 $output->FormHidden('color', serialize($color));
245 $output->FormHidden('event_repeat', serialize($event_repeat));
246 $output->FormHidden('event_recurrspec', $event_recurrspec);
247 $output->FormHidden('durationh', serialize($durationh));
248 $output->FormHidden('durationm', serialize($durationm));
249 $output->FormHidden('end_date_flag', serialize($end_date_flag));
250 $output->FormHidden('end_date_type', serialize($end_date_type));
251 $output->FormHidden('end_date_freq', serialize($end_date_freq));
252 $output->FormHidden('end_all_day', serialize($end_all_day));
253 $output->FormHidden("active", serialize($active));
254 $output->FormHidden("sequence", serialize($sequence));
255 $output->FormHidden("aco", serialize($aco));
256 $output->Linebreak();
257 $output->FormSubmit(_PC_CATS_CONFIRM
);
259 return $output->GetOutput();
262 function postcalendar_admin_categoriesUpdate()
264 $output = new pnHTML();
265 $output->SetInputMode(_PNH_VERBATIMINPUT
);
267 list($dbconn) = pnDBGetConn();
268 $pntable = pnDBGetTables();
270 list($id,$del,$name,$constantid,$value_cat_type,$desc,$color,
271 $event_repeat_array,$event_recurrspec_array,$dels,$durationh,$durationm,
272 $end_date_flag,$end_date_type,$end_date_freq,$end_all_day,$active,$sequence,$aco,$newname,$newconstantid,$newdesc,$newcolor,
273 $new_event_repeat,$new_event_recurrspec,$new_event_recurrfreq,
274 $new_duration,$new_dailylimitid,$new_end_date_flag,$new_end_date_type,
275 $new_end_date_freq,$new_end_all_day,$new_value_cat_type,$newactive,$newsequence,$newaco
276 ) = pnVarCleanFromInput(
301 'newevent_recurrspec',
302 'newevent_recurrfreq',
315 $id = unserialize($id, ['allowed_classes' => false]);
316 $del = unserialize($del, ['allowed_classes' => false]);
317 $name = unserialize($name, ['allowed_classes' => false]);
318 $constantid = unserialize($constantid, ['allowed_classes' => false]);
319 $value_cat_type = unserialize($value_cat_type, ['allowed_classes' => false]);
320 $desc = unserialize($desc, ['allowed_classes' => false]);
321 $color = unserialize($color, ['allowed_classes' => false]);
322 $event_repeat_array = unserialize($event_repeat_array, ['allowed_classes' => false]);
323 $event_recurrspec_array = unserialize($event_recurrspec_array, ['allowed_classes' => false]);
324 $durationh = unserialize($durationh, ['allowed_classes' => false]);
325 $durationm = unserialize($durationm, ['allowed_classes' => false]);
326 $end_date_flag = unserialize($end_date_flag, ['allowed_classes' => false]);
327 $end_date_type = unserialize($end_date_type, ['allowed_classes' => false]);
328 $end_date_freq = unserialize($end_date_freq, ['allowed_classes' => false]);
329 $end_all_day = unserialize($end_all_day, ['allowed_classes' => false]);
330 $active = unserialize($active, ['allowed_classes' => false]);
331 $sequence = unserialize($sequence, ['allowed_classes' => false]);
332 $aco = unserialize($aco, ['allowed_classes' => false]);
336 foreach ($id as $k => $i) {
340 foreach ($del as $d) {
349 $event_repeat_freq = $event_recurrspec_array['event_repeat_freq'][$i];
350 $event_repeat_freq_type = $event_recurrspec_array['event_repeat_freq_type'][$i];
351 $event_repeat_on_num = $event_recurrspec_array['event_repeat_on_num'][$i];
352 $event_repeat_on_day = $event_recurrspec_array['event_repeat_on_day'][$i];
353 $event_repeat_on_freq = $event_recurrspec_array['event_repeat_on_freq'][$i];
355 $recurrspec = serialize(compact(
357 'event_repeat_freq_type',
358 'event_repeat_on_num',
359 'event_repeat_on_day',
360 'event_repeat_on_freq'
363 $dur = ( ($durationh[$i] * (60 * 60)) +
($durationm[$i] * 60));
365 $update_sql = "UPDATE $pntable[postcalendar_categories]
366 SET pc_catname='" . pnVarPrepForStore($name[$k]) . "',
367 pc_constant_id='" . trim(pnVarPrepForStore($constantid[$k])) . "',
368 pc_catdesc='" . trim(pnVarPrepForStore($desc[$k])) . "',
369 pc_cattype='" . trim(pnVarPrepForStore($value_cat_type[$k])) . "',
370 pc_catcolor='" . pnVarPrepForStore($color[$k]) . "',
371 pc_recurrtype='" . pnVarPrepForStore($event_repeat_array[$i]) . "',
372 pc_recurrspec='" . pnVarPrepForStore($recurrspec) . "',
373 pc_duration='" . pnVarPrepForStore($dur) . "',
374 pc_end_date_flag='" . pnVarPrepForStore($end_date_flag[$i]) . "',
375 pc_end_date_type='" . pnVarPrepForStore($end_date_type[$i]) . "',
376 pc_end_date_freq='" . pnVarPrepForStore($end_date_freq[$i]) . "',
377 pc_end_all_day='" . pnVarPrepForStore($end_all_day[$i]) . "',
378 pc_active ='" . pnVarPrepForStore($active[$i]) . "',
379 pc_seq = '" . pnVarPrepForStore($sequence[$k]) . "',
380 aco_spec = '" . pnVarPrepForStore($aco[$k]) . "'
381 WHERE pc_catid = '" . pnVarPrepForStore($i) . "'";
383 array_push($updates, $update_sql);
391 $delete = "DELETE FROM $pntable[postcalendar_categories] WHERE pc_catid IN ($dels)";
393 if (!pnModAPIFunc(__POSTCALENDAR__
, 'admin', 'updateCategories', array('updates' => $updates))) {
394 $e .= 'UPDATE FAILED';
397 if (!pnModAPIFunc(__POSTCALENDAR__
, 'admin', 'deleteCategories', array('delete' => $delete))) {
398 $e .= 'DELETE FAILED';
401 if (isset($newname)) {
402 $unpacked = unserialize($new_event_recurrspec, ['allowed_classes' => false]);
403 unset($new_event_recurrspec);
404 $new_event_recurrspec['event_repeat_freq'] = $unpacked['new_event_repeat_freq'];
405 $new_event_recurrspec['event_repeat_freq_type'] = $unpacked['new_event_repeat_freq_type'];
406 $new_event_recurrspec['event_repeat_on_num'] = $unpacked['new_event_repeat_on_num'];
407 $new_event_recurrspec['event_repeat_on_day'] = $unpacked['new_event_repeat_on_day'];
408 $new_event_recurrspec['event_repeat_on_freq'] = $unpacked['new_event_repeat_on_freq'];
409 $new_event_recurrspec = serialize($new_event_recurrspec);
416 array('name' => $newname,'constantid' => $newconstantid,'desc' => $newdesc,'value_cat_type' => $new_value_cat_type,'color' => $newcolor,'active' => $newactive,'sequence' => $newsequence, 'aco' => $newaco,
417 'repeat' => $new_event_repeat,'spec' => $new_event_recurrspec,
418 'recurrfreq' => $new_recurrfreq,'duration' => $new_duration,'limitid' => $new_dailylimitid,
419 'end_date_flag' => $new_end_date_flag,'end_date_type' => $new_end_date_flag,
420 'end_date_freq' => $new_end_date_freq,
421 'end_all_day' => $new_end_all_day)
424 $e .= 'INSERT FAILED';
431 $output->Text(postcalendar_admin_categories($msg, $e));
432 return $output->GetOutput();
436 * Creates a new category
438 function postcalendar_admin_categories($msg = '', $e = '', $args = array())
443 $output = new pnHTML();
444 $output->SetInputMode(_PNH_VERBATIMINPUT
);
446 $tpl = new pcSmarty();
447 $tpl->caching
= false;
449 $template_name = pnModGetVar(__POSTCALENDAR__
, 'pcTemplate');
451 if (!isset($template_name)) {
452 $template_name = 'default';
455 $output->Text(postcalendar_adminmenu("category"));
458 $output -> Text('<div class="alert alert-danger mx-1" role="alert">');
459 $output->Text('<span class="text-center font-weight-bold">' . text($e) . '</span>');
460 $output -> Text('</div><br />');
464 $output -> Text('<div class="alert alert-success mx-1" role="alert">');
465 $output->Text('<span class="text-center font-weight-bold">' . text($msg) . '</span>');
466 $output -> Text('</div><br />');
469 //=================================================================
470 // Setup the correct config file path for the templates
471 //=================================================================
472 $modinfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__
));
473 $modir = pnVarPrepForOS($modinfo['directory']);
474 $modname = $modinfo['displayname'];
475 $all_categories = pnModAPIFunc(__POSTCALENDAR__
, 'user', 'getCategories');
476 //print_r($all_categories);
478 $tpl->config_dir
= "modules/$modir/pntemplates/$template_name/config/";
480 //=================================================================
482 //=================================================================
484 // create translations if applicable
485 if (($GLOBALS['translate_appt_categories']) && ($_SESSION['language_choice'] > 1)) {
486 $sizeAllCat = count($all_categories);
487 for ($m = 0; $m < $sizeAllCat; $m++
) {
488 $tempCategory = $all_categories[$m]["name"];
489 $tempDescription = $all_categories[$m]["desc"];
490 $all_categories[$m]["nameTranslate"] = xl($tempCategory);
491 $all_categories[$m]["descTranslate"] = xl($tempDescription);
494 $scriptFilterEvent = new ScriptFilterEvent('pnadmin.php');
495 $scriptFilterEvent->setContextArgument('viewtype', 'admin');
496 $calendarScripts = $GLOBALS['kernel']->getEventDispatcher()->dispatch($scriptFilterEvent, ScriptFilterEvent
::EVENT_NAME
);
498 $styleFilterEvent = new StyleFilterEvent('pnadmin.php');
499 $styleFilterEvent->setContextArgument('viewtype', 'admin');
500 $calendarStyles = $GLOBALS['kernel']->getEventDispatcher()->dispatch($styleFilterEvent, StyleFilterEvent
::EVENT_NAME
);
502 $tpl->assign('globals', $GLOBALS);
503 $tpl->assign('HEADER_SCRIPTS', $calendarScripts->getScripts());
504 $tpl->assign('HEADER_STYLES', $calendarStyles->getStyles());
505 $tpl->assign_by_ref('TPL_NAME', $template_name);
506 $tpl->assign('FUNCTION', pnVarCleanFromInput('func'));
507 $tpl->assign_by_ref('ModuleName', $modname);
508 $tpl->assign_by_ref('ModuleDirectory', $modir);
509 $tpl->assign_by_ref('all_categories', $all_categories);
511 $tpl->assign('pcDir', $modir);
512 $tpl->assign('action', pnModURL(__POSTCALENDAR__
, 'admin', 'categoriesConfirm'));
513 $tpl->assign('adminmenu', postcalendar_adminmenu("category"));
514 $tpl->assign('BGCOLOR2', $GLOBALS['style']['BGCOLOR2']);
515 $tpl->assign('css_header', $GLOBALS['css_header']);
516 $tpl->assign('_PC_REP_CAT_TITLE_S', _PC_REP_CAT_TITLE_S
);
517 $tpl->assign('_PC_NEW_CAT_TITLE_S', _PC_NEW_CAT_TITLE_S
);
518 $tpl->assign('_PC_CAT_NAME', _PC_CAT_NAME
);
519 $tpl->assign('_PC_CAT_CONSTANT_ID', _PC_CAT_CONSTANT_ID
);
520 $tpl->assign('_PC_CAT_TYPE', _PC_CAT_TYPE
);
521 $tpl->assign('_PC_CAT_NAME_XL', _PC_CAT_NAME_XL
);
522 $tpl->assign('_PC_CAT_DESC', _PC_CAT_DESC
);
523 $tpl->assign('_PC_CAT_DESC_XL', _PC_CAT_DESC_XL
);
524 $tpl->assign('_PC_CAT_COLOR', _PC_CAT_COLOR
);
525 $tpl->assign('_PC_CAT_DELETE', _PC_CAT_DELETE
);
526 $tpl->assign('_PC_CAT_DUR', _PC_CAT_DUR
);
527 $tpl->assign('_PC_COLOR_PICK_TITLE', _PC_COLOR_PICK_TITLE
);
528 $tpl->assign('_EDIT_PC_CONFIG_CATDETAILS', _EDIT_PC_CONFIG_CATDETAILS
);
529 $tpl->assign("_PC_ACTIVE", _PC_ACTIVE
);
530 $tpl->assign("_PC_SEQ", _PC_SEQ
);
531 $tpl->assign("_ACO", _ACO
);
532 //=================================================================
533 // Repeating Information
534 //=================================================================
535 $tpl->assign('RepeatingHeader', _PC_REPEATING_HEADER
);
536 $tpl->assign('NoRepeatTitle', _PC_NO_REPEAT
);
537 $tpl->assign('RepeatTitle', _PC_REPEAT
);
538 $tpl->assign('RepeatOnTitle', _PC_REPEAT_ON
);
539 $tpl->assign('OfTheMonthTitle', _PC_OF_THE_MONTH
);
540 $tpl->assign('EndDateTitle', _PC_END_DATE
);
541 $tpl->assign('NoEndDateTitle', _PC_NO_END
);
542 $tpl->assign('REP_CAT_TITLE', _PC_REP_CAT_TITLE
);
543 $tpl->assign('NEW_CAT_TITLE', _PC_NEW_CAT_TITLE
);
544 $tpl->assign('InputNoRepeat', 'event_repeat');
545 $tpl->assign('ValueNoRepeat', '0');
546 $tpl->assign('SelectedNoRepeat', (int) $event_repeat == 0 ?
'checked' : '');
547 $tpl->assign('InputRepeat', 'event_repeat');
548 $tpl->assign('ValueRepeat', '1');
549 $tpl->assign('SelectedRepeat', (int) $event_repeat == 1 ?
'checked' : '');
553 $in = array(_PC_EVERY
,_PC_EVERY_OTHER
,_PC_EVERY_THIRD
,_PC_EVERY_FOURTH
);
554 $keys = array(REPEAT_EVERY
,REPEAT_EVERY_OTHER
,REPEAT_EVERY_THIRD
,REPEAT_EVERY_FOURTH
);
555 $repeat_freq = array();
556 foreach ($in as $k => $v) {
557 array_push($repeat_freq, array('value' => $keys[$k],
558 'selected' => ($keys[$k] == $event_repeat_freq ?
'selected' : ''),
561 $tpl->assign('InputRepeatFreq', 'event_repeat_freq');
562 if (empty($event_repeat_freq) ||
$event_repeat_freq < 1) {
563 $event_repeat_freq = 1;
565 $tpl->assign('InputRepeatFreqVal', $event_repeat_freq);
566 $tpl->assign('repeat_freq', $event_repeat_freq);
569 $in = array(_PC_EVERY_DAY
,_PC_EVERY_WORKDAY
,_PC_EVERY_WEEK
,_PC_EVERY_MONTH
,_PC_EVERY_YEAR
);
570 $keys = array(REPEAT_EVERY_DAY
,REPEAT_EVERY_WORK_DAY
,REPEAT_EVERY_WEEK
,REPEAT_EVERY_MONTH
,REPEAT_EVERY_YEAR
);
571 $repeat_freq_type = array();
572 foreach ($in as $k => $v) {
573 array_push($repeat_freq_type, array('value' => $keys[$k],
574 'selected' => ($keys[$k] == $event_repeat_freq_type ?
'selected' : ''),
577 $tpl->assign('InputRepeatFreqType', 'event_repeat_freq_type');
578 $tpl->assign('InuptRepeatFreq', '' . 'event_repeat_freq');
579 $tpl->assign('repeat_freq_type', $repeat_freq_type);
581 $tpl->assign('InputRepeatOn', 'event_repeat');
582 $tpl->assign('ValueRepeatOn', '2');
583 $tpl->assign('SelectedRepeatOn', (int) $event_repeat == 2 ?
'checked' : '');
586 $tpl->assign('InputAllDay', 'end_all_day');
587 $tpl->assign('ValueAllDay', '1');
588 $tpl->assign('ValueAllDayNo', '0');
589 $tpl->assign('ALL_DAY_CAT_TITLE', _PC_ALL_DAY_CAT_TITLE
);
590 $tpl->assign('ALL_DAY_CAT_YES', _PC_ALL_DAY_CAT_YES
);
591 $tpl->assign('ALL_DAY_CAT_NO', _PC_ALL_DAY_CAT_NO
);
594 // End date gather date start
596 $tpl->assign('InputEndDateFreq', 'end_date_freq');
597 $tpl->assign('InputEndOn', 'end_date_flag');
598 $tpl->assign('InputEndDateFreqType', 'end_date_type');
599 $tpl->assign('ValueNoEnd', '0');
600 $tpl->assign('ValueEnd', '1');
602 if (empty($end_date_type)) {
603 $end_date_type = array();
605 foreach ($in as $k => $v) {
606 array_push($end_date_type, array('value' => $keys[$k],
607 'selected' => ($keys[$k] == $end_date_type ?
'selected' : ''),
613 // End date gather date end
617 $in = array(_PC_EVERY_1ST
,_PC_EVERY_2ND
,_PC_EVERY_3RD
,_PC_EVERY_4TH
,_PC_EVERY_LAST
);
618 $keys = array(REPEAT_ON_1ST
,REPEAT_ON_2ND
,REPEAT_ON_3RD
,REPEAT_ON_4TH
,REPEAT_ON_LAST
);
619 $repeat_on_num = array();
620 foreach ($in as $k => $v) {
621 array_push($repeat_on_num, array('value' => $keys[$k],
622 'selected' => ($keys[$k] == $event_repeat_on_num ?
'selected' : ''),
625 $tpl->assign('InputRepeatOnNum', 'event_repeat_on_num');
626 $tpl->assign('repeat_on_num', $repeat_on_num);
629 $in = array(_PC_EVERY_SUN
,_PC_EVERY_MON
,_PC_EVERY_TUE
,_PC_EVERY_WED
,_PC_EVERY_THU
,_PC_EVERY_FRI
,_PC_EVERY_SAT
);
630 $keys = array(REPEAT_ON_SUN
,REPEAT_ON_MON
,REPEAT_ON_TUE
,REPEAT_ON_WED
,REPEAT_ON_THU
,REPEAT_ON_FRI
,REPEAT_ON_SAT
);
631 $repeat_on_day = array();
632 foreach ($in as $k => $v) {
633 array_push($repeat_on_day, array('value' => $keys[$k],
634 'selected' => ($keys[$k] == $event_repeat_on_day ?
'selected' : ''),
637 $tpl->assign('InputRepeatOnDay', 'event_repeat_on_day');
638 $tpl->assign('repeat_on_day', $repeat_on_day);
641 $in = array(_PC_CAT_PATIENT
,_PC_CAT_PROVIDER
,_PC_CAT_CLINIC
,_PC_CAT_THERAPY_GROUP
);
642 $keys = array(TYPE_ON_PATIENT
,TYPE_ON_PROVIDER
,TYPE_ON_CLINIC
,TYPE_ON_THERAPY_GROUP
);
644 foreach ($in as $k => $v) {
645 array_push($cat_type, array('value' => $keys[$k],
646 'selected' => ($keys[$k] == $value_cat_type ?
'selected' : ''),
649 $tpl->assign('InputCatType', 'value_cat_type');
650 $tpl->assign('cat_type', $cat_type);
653 $in = array(_PC_OF_EVERY_MONTH
,_PC_OF_EVERY_2MONTH
,_PC_OF_EVERY_3MONTH
,_PC_OF_EVERY_4MONTH
,_PC_OF_EVERY_6MONTH
,_PC_OF_EVERY_YEAR
);
654 $keys = array(REPEAT_ON_MONTH
,REPEAT_ON_2MONTH
,REPEAT_ON_3MONTH
,REPEAT_ON_4MONTH
,REPEAT_ON_6MONTH
,REPEAT_ON_YEAR
);
655 $repeat_on_freq = array();
656 foreach ($in as $k => $v) {
657 array_push($repeat_on_freq, array('value' => $keys[$k],
658 'selected' => ($keys[$k] == $event_repeat_on_freq ?
'selected' : ''),
661 $tpl->assign('InputRepeatOnFreq', 'event_repeat_on_freq');
662 if (empty($event_repeat_on_freq) ||
$event_repeat_on_freq < 1) {
663 $event_repeat_on_freq = 1;
665 $tpl->assign('InputRepeatOnFreqVal', $event_repeat_on_freq);
666 $tpl->assign('repeat_on_freq', $repeat_on_freq);
667 $tpl->assign('MonthsTitle', _PC_MONTHS
);
668 $tpl->assign('DurationHourTitle', _PC_DURATION_HOUR
);
669 $tpl->assign('DurationMinTitle', _PC_DURATION_MIN
);
670 $tpl->assign('InputDurationHour', "durationh");
671 $tpl->assign('InputDurationMin', "durationm");
672 $tpl->assign('ActiveTitleYes', xl('Yes'));
673 $tpl->assign('ActiveTitleNo', xl('No'));
675 // Added ACO for each category
676 $tpl->assign('InputACO', 'aco');
677 $acoList = AclExtended
::genAcoArray();
678 $tpl->assign('ACO_List', $acoList);
680 $output->SetOutputMode(_PNH_RETURNOUTPUT
);
681 $output->SetOutputMode(_PNH_KEEPOUTPUT
);
683 $form_hidden = "<input type=\"hidden\" name=\"is_update\" value=\"" . attr($is_update) . "\" />";
684 $form_hidden .= "<input type=\"hidden\" name=\"pc_event_id\" value=\"" . attr($pc_event_id) . "\" />";
685 if (isset($data_loaded)) {
686 $form_hidden .= "<input type=\"hidden\" name=\"data_loaded\" value=\"" . attr($data_loaded) . "\" />";
687 $tpl->assign('FormHidden', $form_hidden);
689 $form_submit = '<input type=hidden name="form_action" value="commit"/>
690 ' . text($authkey) . '<input class="btn btn-primary" type="submit" name="submit" value="' . xla('Save') . '">';
691 $tpl->assign('FormSubmit', $form_submit);
693 $output->Text($tpl->fetch($template_name . '/admin/submit_category.html'));
694 $output->Text(postcalendar_footer());
695 return $output->GetOutput();
699 * Main administration menu
701 function postcalendar_adminmenu($menuItem)
703 global $bgcolor1, $bgcolor2;
705 @define
('_AM_VAL', 1);
706 @define
('_PM_VAL', 2);
708 @define
('_EVENT_APPROVED', 1);
709 @define
('_EVENT_QUEUED', 0);
710 @define
('_EVENT_HIDDEN', -1);
712 $categoryURL = pnModURL(__POSTCALENDAR__
, 'admin', 'categories');
713 $cacheURL = pnModURL(__POSTCALENDAR__
, 'admin', 'clearCache');
714 $systemURL = pnModURL(__POSTCALENDAR__
, 'admin', 'testSystem');
716 $categoryText = text(_EDIT_PC_CONFIG_CATEGORIES
);
717 $cacheText = text(_PC_CLEAR_CACHE
);
718 $systemText = text(_PC_TEST_SYSTEM
);
720 $output = " <div class='container mt-3 mb-3'><ul class='nav nav-pills'>";
722 if ($menuItem === "clearCache") {
724 <li class="nav-item">
725 <a class="nav-link active" href="$cacheURL">$cacheText</a>
727 <li class="nav-item">
728 <a class="nav-link" href="$categoryURL">$categoryText</a>
731 } elseif ($menuItem === "testSystem") {
733 <li class="nav-item">
734 <a class="nav-link" href="$cacheURL">$cacheText</a>
736 <li class="nav-item">
737 <a class="nav-link" href="$categoryURL">$categoryText</a>
740 } elseif ($menuItem === "category") {
742 <li class="nav-item">
743 <a class="nav-link" href="$cacheURL">$cacheText</a>
745 <li class="nav-item">
746 <a class="nav-link active" href="$categoryURL">$categoryText</a>
751 <li class="nav-item">
752 <a class="nav-link" href="$cacheURL">$cacheText</a>
754 <li class="nav-item">
755 <a class="nav-link" href="$categoryURL">$categoryText</a>
759 $output .= "</ul></div>";
760 // Return the output that has been generated by this function
764 function postcalendar_admin_clearCache()
766 $tpl = new pcSmarty();
767 //fmg: check that both subdirs to be cleared first exist and are writeable
770 if (!file_exists($tpl->compile_dir
)) {
771 $spec_err .= "Error: folder '" . text($tpl->compile_dir
) . "' doesn't exist!<br />";
772 } elseif (!is_writeable($tpl->compile_dir
)) {
773 $spec_err .= "Error: folder '" . text($tpl->compile_dir
) . "' not writeable!<br />";
776 //note: we don't abort on error... like before.
777 $tpl->clear_all_cache();
778 $tpl->clear_compiled_tpl();
780 return postcalendar_admin_modifyconfig('<div class="text-center">' . $spec_err . text(_PC_CACHE_CLEARED
) . '</div>');
783 function postcalendar_admin_testSystem()
785 $modinfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__
));
786 $pcDir = pnVarPrepForOS($modinfo['directory']);
787 $version = $modinfo['version'];
790 $tpl = new pcSmarty();
793 $__SERVER =& $_SERVER;
796 if (defined('_PN_VERSION_NUM')) {
797 $pnVersion = _PN_VERSION_NUM
;
799 $pnVersion = pnConfigGetVar('Version_Num');
802 array_push($infos, array('CMS Version', $pnVersion));
803 array_push($infos, array('Sitename', pnConfigGetVar('sitename')));
804 array_push($infos, array('url', pnGetBaseURL()));
805 array_push($infos, array('PHP Version', phpversion()));
806 if ((bool) ini_get('safe_mode')) {
811 array_push($infos, array('PHP safe_mode', $safe_mode));
812 if ((bool) ini_get('safe_mode_gid')) {
813 $safe_mode_gid = "On";
815 $safe_mode_gid = "Off";
817 array_push($infos, array('PHP safe_mode_gid', $safe_mode_gid));
818 $base_dir = ini_get('open_basedir');
819 if (!empty($base_dir)) {
820 $open_basedir = "$base_dir";
822 $open_basedir = "NULL";
824 array_push($infos, array('PHP open_basedir', $open_basedir));
825 array_push($infos, array('SAPI', php_sapi_name()));
826 array_push($infos, array('OS', php_uname()));
827 array_push($infos, array('WebServer', $__SERVER['SERVER_SOFTWARE']));
828 array_push($infos, array('Module dir', "modules/$pcDir"));
830 $modversion = array();
831 include "modules/$pcDir/pnversion.php";
834 if ($modversion['version'] != $version) {
835 $error = '<br /><div class="text-danger">';
836 $error .= "new version $modversion[version] installed but not updated!";
839 array_push($infos, array('Module version', $version . " $error"));
840 array_push($infos, array('smarty version', $tpl->_version
));
841 array_push($infos, array('smarty location', SMARTY_DIR
));
842 array_push($infos, array('smarty template dir', $tpl->template_dir
));
844 $info = $tpl->compile_dir
;
846 if (!file_exists($tpl->compile_dir
)) {
847 $error .= " compile dir doesn't exist! [" . text($tpl->compile_dir
) . "]<br />";
849 // dir exists -> check if it's writeable
850 if (!is_writeable($tpl->compile_dir
)) {
851 $error .= " compile dir not writeable! [" . text($tpl->compile_dir
) . "]<br />";
854 if (strlen($error) > 0) {
855 $info .= "<br /><div class='text-danger'>$error</div>";
857 array_push($infos, array('smarty compile dir', $info));
859 if (AclMain
::aclCheckCore('admin', 'super')) {
860 $header = "<head><title>" . xlt("Diagnostics") . "</title></head><body>";
862 $output .= '<div class="container mt-3"><div class="row"><div class="col-sm-12"><div class="clearfix">';
863 $output .= '<h2>' . xlt('Diagnostics') . '</h2>';
864 $output .= '</div></div></div>';
865 $output .= '<div class="table-responsive"><table class="table table-bordered table-striped"><thead>';
866 $output .= '<tr><th>' . xlt('Name') . '</th><th>' . xlt('Value') . '</th></tr></thead>';
867 foreach ($infos as $info) {
868 $output .= '<tr><td><b>' . pnVarPrepHTMLDisplay($info[0]) . '</b></td>';
869 $output .= '<td>' . pnVarPrepHTMLDisplay($info[1]) . '</td></tr>';
871 $output .= '</table></div></div>';
872 $output .= '<br /><br />';
873 $output .= postcalendar_admin_modifyconfig('', false);
874 $output .= "</body></html>";
877 die(xlt("Not Authorized"));