/** * $Id$ * * PostCalendar::PostNuke Events Calendar Module * Copyright (C) 2002 The PostCalendar Team * http://postcalendar.tv * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * To read the license please read the docs/license.txt or visit * http://www.gnu.org/copyleft/gpl.html * */ function smarty_function_pc_view_select($args) { @define('_PC_FORM_TEMPLATE', true); $Date = postcalendar_getDate(); if (!isset($y)) { $y = substr($Date, 0, 4); } if (!isset($m)) { $m = substr($Date, 4, 2); } if (!isset($d)) { $d = substr($Date, 6, 2); } $tplview = pnVarCleanFromInput('tplview'); $viewtype = pnVarCleanFromInput('viewtype'); if (!isset($viewtype)) { $viewtype = _SETTING_DEFAULT_VIEW; } $modinfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__)); $mdir = pnVarPrepForOS($modinfo['directory']); unset($modinfo); $pcTemplate = pnVarPrepForOS(_SETTING_TEMPLATE); if (empty($pcTemplate)) { $pcTemplate = 'default'; } $viewlist = array(); $handle = opendir("modules/{$mdir}/pntemplates/{$pcTemplate}/views/{$viewtype}"); $hide_list = array('.', '..', 'CVS', 'index.html'); while ($f = readdir($handle)) { if (!in_array($f, $hide_list)) { $viewlist[] = $f; } } closedir($handle); unset($no_list); sort($viewlist); $tcount = count($viewlist); //$options = "<select id=\"tplview\" name=\"tplview\" class=\"$args[class]\">"; - pennfirm $options = "<select id=\"tplview\" name=\"viewtype\" class=\"{$args['class']}\">"; $selected = $tplview; for ($t = 0; $t < $tcount; $t++) { $id = str_replace('.html', '', $viewlist[$t]); $sel = $selected == $id ? 'selected' : ''; $options .= "<option value=\"{$id}\" {$sel} class=\"{$args['class']}\">{$id}</option>"; } $options .= '</select>'; if (!isset($args['label'])) { $args['label'] = _PC_TPL_VIEW_SUBMIT; } $submit = '<input type="submit" valign="middle" name="submit" value="' . $args['label'] . '" class="' . $args['class'] . '" />'; // build the form if ($t > 1) { echo $options, $submit; } }
function postcalendar_footer() { // lets get the module's information $modinfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__)); //$footer = "<p align=\"right\"><a href=\"http://www.postcalendar.tv\">PostCalendar v$modinfo[version]</a></p>"; $footer = ""; return $footer; }
function postcalendar_admin_categoryLimits($msg = '', $e = '', $args) { if (!PC_ACCESS_ADD) { return _POSTCALENDARNOAUTH; } extract($args); unset($args); $output = new pnHTML(); $output->SetInputMode(_PNH_VERBATIMINPUT); // set up Smarty $tpl = new pcSmarty(); $tpl->caching = false; $template_name = pnModGetVar(__POSTCALENDAR__, 'pcTemplate'); if (!isset($template_name)) { $template_name = 'default'; } if (!empty($e)) { $output->Text('<div style="padding:5px; border:1px solid red; background-color: pink;">'); $output->Text('<center><b>' . $e . '</b></center>'); $output->Text('</div><br />'); } if (!empty($msg)) { $output->Text('<div style="padding:5px; border:1px solid green; background-color: lightgreen;">'); $output->Text('<center><b>' . $msg . '</b></center>'); $output->Text('</div><br />'); } //================================================================= // Setup the correct config file path for the templates //================================================================= $modinfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__)); $modir = pnVarPrepForOS($modinfo['directory']); $modname = $modinfo['displayname']; //print_r($all_categories); unset($modinfo); $tpl->assign('action', pnModURL(__POSTCALENDAR__, 'admin', 'categoryLimitsUpdate')); //=============================================================== // Setup titles for smarty //=============================================================== $tpl->assign('_PC_LIMIT_TITLE', _PC_LIMIT_TITLE); $tpl->assign('StartTimeTitle', _PC_LIMIT_START_TIME); $tpl->assign('EndTimeTile', _PC_LIMIT_END_TIME); $tpl->assign('LimitHoursTitle', _PC_TIMED_DURATION_HOURS); $tpl->assign('LimitMinutesTitle', _PC_TIMED_DURATION_MINUTES); //============================================================= // Setup Vars for smarty //============================================================ $tpl->assign('mer_title', 'mer'); $mer = array('am', 'pm'); $tpl->assign_by_ref('mer', $mer); $tpl->assign('starttimeh', 'starttimeh'); $tpl->assign('starttimem', 'starttimem'); $tpl->assign('endtimeh', 'endtimeh'); $tpl->assign('endtimem', 'endtimem'); $tpl->assign('InputLimit', 'limit'); $tpl->assign('LimitTitle', _PC_LIMIT_TITLE); $tpl->assign('_PC_NEW_LIMIT_TITLE', _PC_NEW_LIMIT_TITLE); $tpl->assign('_PC_CAT_DELETE', _PC_CAT_DELETE); $tpl->assign('EndTimeTitle', _PC_LIMIT_END_TIME); $hour_array = array('00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '21', '21', '22', '23'); $min_array = array('00', '05', '10', '15', '20', '25', '30', '35', '40', '45', '50', '55'); $tpl->assign_by_ref('hour_array', $hour_array); $tpl->assign_by_ref('min_array', $min_array); $categories = pnModAPIFunc(__POSTCALENDAR__, 'user', 'getCategories'); // create translations of category names if applicable $sizeAllCat = count($categories); for ($m = 0; $m < $sizeAllCat; $m++) { $tempCategory = $categories[$m]["name"]; $categories[$m]["name"] = xl_appt_category($tempCategory); } $tpl->assign_by_ref('categories', $categories); $limits = pnModAPIFunc(__POSTCALENDAR__, 'user', 'getCategoryLimits'); $tpl->assign_by_ref('limits', $limits); $tpl->assign('BGCOLOR2', $GLOBALS['style']['BGCOLOR2']); $tpl->assign("catTitle", _PC_REP_CAT_TITLE_S); $tpl->assign("catid", "catid"); $form_submit = '<input type=hidden name="form_action" value="commit"/> ' . $authkey . '<input type="submit" name="submit" value="' . xl('go') . '">'; $tpl->assign('FormSubmit', $form_submit); $output->Text($tpl->fetch($template_name . '/admin/submit_category_limit.html')); $output->Text(postcalendar_footer()); return $output->GetOutput(); }
function __construct() { $theme = pnUserGetTheme(); $osTheme = pnVarPrepForOS($theme); pnThemeLoad($theme); global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5, $bgcolor6, $textcolor1, $textcolor2; // call constructor parent::__construct(); // gather module information $pcModInfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__)); $pcDir = pnVarPrepForOS($pcModInfo['directory']); $pcDisplayName = $pcModInfo['displayname']; unset($pcModInfo); // setup up pcSmarty configs $this->compile_check = true; $this->force_compile = false; $this->debugging = false; $this->template_dir = "modules/{$pcDir}/pntemplates"; array_push($this->plugins_dir, "modules/{$pcDir}/pnincludes/Smarty/plugins"); array_push($this->plugins_dir, "modules/{$pcDir}/plugins"); $this->compile_dir = "modules/{$pcDir}/pntemplates/compiled"; $this->cache_dir = "modules/{$pcDir}/pntemplates/cache"; $this->caching = _SETTING_USE_CACHE; $this->cache_lifetime = _SETTING_CACHE_LIFETIME; $this->left_delimiter = '[-'; $this->right_delimiter = '-]'; //============================================================ // checks for safe mode // i think it's safe to say we can do this automagically now //============================================================ $safe_mode = ini_get('safe_mode'); $safe_mode_gid = ini_get('safe_mode_gid'); $open_basedir = ini_get('open_basedir'); $use_safe_mode = (bool) $safe_mode || (bool) $safe_mode_gid || !empty($open_basedir); if ($use_safe_mode) { $this->use_sub_dirs = false; } else { $this->use_sub_dirs = true; } unset($use_safe_mode, $safe_mode, $safe_mode_gid, $open_basedir); $this->autoload_filters = array('output' => array('trimwhitespace')); $lang = pnUserGetLang(); $func = pnVarCleanFromInput('func'); $print = pnVarCleanFromInput('print'); // assign theme globals $this->assign_by_ref('BGCOLOR1', $bgcolor1); $this->assign_by_ref('BGCOLOR2', $bgcolor2); $this->assign_by_ref('BGCOLOR3', $bgcolor3); $this->assign_by_ref('BGCOLOR4', $bgcolor4); $this->assign_by_ref('BGCOLOR5', $bgcolor5); $this->assign_by_ref('BGCOLOR6', $bgcolor6); $this->assign_by_ref('TEXTCOLOR1', $textcolor1); $this->assign_by_ref('TEXTCOLOR2', $textcolor2); $this->assign_by_ref('USER_LANG', $lang); $this->assign_by_ref('FUNCTION', $func); $this->assign('PRINT_VIEW', $print); $this->assign('USE_POPUPS', _SETTING_USE_POPUPS); $this->assign('USE_TOPICS', _SETTING_DISPLAY_TOPICS); $this->assign('USE_INT_DATES', _SETTING_USE_INT_DATES); $this->assign('OPEN_NEW_WINDOW', _SETTING_OPEN_NEW_WINDOW); $this->assign('EVENT_DATE_FORMAT', _SETTING_DATE_FORMAT); $this->assign('HIGHLIGHT_COLOR', _SETTING_DAY_HICOLOR); $this->assign('24HOUR_TIME', _SETTING_TIME_24HOUR); $this->assign_by_ref('MODULE_NAME', $pcDisplayName); $this->assign_by_ref('MODULE_DIR', $pcDir); $this->assign('ACCESS_NONE', PC_ACCESS_NONE); $this->assign('ACCESS_OVERVIEW', PC_ACCESS_OVERVIEW); $this->assign('ACCESS_READ', PC_ACCESS_READ); $this->assign('ACCESS_COMMENT', PC_ACCESS_COMMENT); $this->assign('ACCESS_MODERATE', PC_ACCESS_MODERATE); $this->assign('ACCESS_EDIT', PC_ACCESS_EDIT); $this->assign('ACCESS_ADD', PC_ACCESS_ADD); $this->assign('ACCESS_DELETE', PC_ACCESS_DELETE); $this->assign('ACCESS_ADMIN', PC_ACCESS_ADMIN); //================================================================= // Find out what Template we're using //================================================================= $template_name = _SETTING_TEMPLATE; if (!isset($template_name)) { $template_name = 'default'; } //================================================================= // Find out what Template View to use //================================================================= $template_view = pnVarCleanFromInput('tplview'); if (!isset($template_view)) { $template_view = 'default'; } $this->config_dir = "modules/{$pcDir}/pntemplates/{$template_name}/config/"; $this->assign_by_ref('TPL_NAME', $template_name); $this->assign_by_ref('TPL_VIEW', $template_view); $this->assign('TPL_IMAGE_PATH', $GLOBALS['rootdir'] . "/main/calendar/modules/{$pcDir}/pntemplates/{$template_name}/images"); $this->assign('TPL_ROOTDIR', $GLOBALS['rootdir']); $this->assign('TPL_STYLE_PATH', "modules/{$pcDir}/pntemplates/{$template_name}/style"); $this->assign('THEME_PATH', "themes/{$osTheme}"); }
/** * display block */ function postcalendar_calendarblock_display($blockinfo) { // You supposed to be here? if (!pnSecAuthAction(0, 'PostCalendar:calendarblock:', "{$blockinfo['title']}::", ACCESS_OVERVIEW)) { return false; } // find out what view we're using $template_view = pnVarCleanFromInput('tplview'); if (!isset($template_view)) { $template_view = 'default'; } // find out what template we're using $template_name = _SETTING_TEMPLATE; if (!isset($template_name) || empty($template_name)) { $template_name = 'default'; } // What is today's correct date $Date =& postcalendar_getDate(); // Get variables from content block $vars = unserialize($blockinfo['content']); $showcalendar = $vars['pcbshowcalendar']; $showevents = $vars['pcbeventoverview']; $eventslimit = $vars['pcbeventslimit']; $nextevents = $vars['pcbnextevents']; $pcbshowsslinks = $vars['pcbshowsslinks']; $pcbeventsrange = $vars['pcbeventsrange']; // Let's setup the info to build this sucka! $the_year = substr($Date, 0, 4); $the_month = substr($Date, 4, 2); $the_day = substr($Date, 6, 2); $uid = pnUserGetVar('uid'); $cacheid1 = $cacheid2 = $cacheid3 = ''; $theme = pnUserGetTheme(); pnThemeLoad($theme); global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5; global $textcolor1, $textcolor2; // 20021125 - rraymond :: we have to do this to make it work with envolution $pcModInfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__)); $pcDir = pnVarPrepForOS($pcModInfo['directory']); require_once "modules/{$pcDir}/pnincludes/Smarty/Config_File.class.php"; unset($pcModInfo); // set up Smarty $tpl =& new pcSmarty(); // setup the Smarty cache id $templates_cached = true; if ($showcalendar) { $cacheid1 = md5($Date . 'M' . $template_view . $template_name . $showcalendar . $showevents . $nextevents . $uid . $theme); if (!$tpl->is_cached($template_name . '/views/calendarblock/month_view.html', $cacheid1)) { $templates_cached = false; } } if ($showevents) { $cacheid2 = md5($Date . 'T' . $template_view . $template_name . $showcalendar . $showevents . $nextevents . $uid . $theme); if (!$tpl->is_cached($template_name . '/views/calendarblock/todays_events.html', $cacheid2)) { $templates_cached = false; } } if ($nextevents) { $cacheid3 = md5($Date . 'U' . $template_view . $template_name . $showcalendar . $showevents . $nextevents . $uid . $theme); if (!$tpl->is_cached($template_name . '/views/calendarblock/upcoming_events.html', $cacheid3)) { $templates_cached = false; } } // start the output container $output = pnModAPIFunc(__POSTCALENDAR__, 'user', 'pageSetup'); // if one of the templates is not cached, we need to run the following if (!$templates_cached) { // set up the next and previous months to move to $prev_month = Date_Calc::beginOfPrevMonth(1, $the_month, $the_year, '%Y%m%d'); $next_month = Date_Calc::beginOfNextMonth(1, $the_month, $the_year, '%Y%m%d'); $last_day = Date_Calc::daysInMonth($the_month, $the_year); $pc_prev = pnModURL(__POSTCALENDAR__, 'user', 'view', array('tplview' => $template_view, 'viewtype' => 'month', 'Date' => $prev_month)); $pc_next = pnModURL(__POSTCALENDAR__, 'user', 'view', array('tplview' => $template_view, 'viewtype' => 'month', 'Date' => $next_month)); $pc_month_name = pnModAPIFunc(__POSTCALENDAR__, 'user', 'getmonthname', array('Date' => mktime(0, 0, 0, $the_month, $the_day, $the_year))); $month_link_url = pnModURL(__POSTCALENDAR__, 'user', 'view', array('tplview' => $template_view, 'viewtype' => 'month', 'Date' => date('Ymd', mktime(0, 0, 0, $the_month, 1, $the_year)))); $month_link_text = $pc_month_name . ' ' . $the_year; //******************************************************************* // Here we get the events for the current month view //******************************************************************* $day_of_week = 1; $pc_month_names = array(_CALJAN, _CALFEB, _CALMAR, _CALAPR, _CALMAY, _CALJUN, _CALJUL, _CALAUG, _CALSEP, _CALOCT, _CALNOV, _CALDEC); $pc_short_day_names = array(_CALSUNDAYSHORT, _CALMONDAYSHORT, _CALTUESDAYSHORT, _CALWEDNESDAYSHORT, _CALTHURSDAYSHORT, _CALFRIDAYSHORT, _CALSATURDAYSHORT); $pc_long_day_names = array(_CALSUNDAY, _CALMONDAY, _CALTUESDAY, _CALWEDNESDAY, _CALTHURSDAY, _CALFRIDAY, _CALSATURDAY); switch (_SETTING_FIRST_DAY_WEEK) { case _IS_MONDAY: $pc_array_pos = 1; $first_day = date('w', mktime(0, 0, 0, $the_month, 0, $the_year)); $end_dow = date('w', mktime(0, 0, 0, $the_month, $last_day, $the_year)); if ($end_dow != 0) { $the_last_day = $last_day + (7 - $end_dow); } else { $the_last_day = $last_day; } break; case _IS_SATURDAY: $pc_array_pos = 6; $first_day = date('w', mktime(0, 0, 0, $the_month, 2, $the_year)); $end_dow = date('w', mktime(0, 0, 0, $the_month, $last_day, $the_year)); if ($end_dow == 6) { $the_last_day = $last_day + 6; } elseif ($end_dow != 5) { $the_last_day = $last_day + (5 - $end_dow); } else { $the_last_day = $last_day; } break; case _IS_SUNDAY: default: $pc_array_pos = 0; $first_day = date('w', mktime(0, 0, 0, $the_month, 1, $the_year)); $end_dow = date('w', mktime(0, 0, 0, $the_month, $last_day, $the_year)); if ($end_dow != 6) { $the_last_day = $last_day + (6 - $end_dow); } else { $the_last_day = $last_day; } break; } $month_view_start = date('Y-m-d', mktime(0, 0, 0, $the_month, 1, $the_year)); $month_view_end = date('Y-m-t', mktime(0, 0, 0, $the_month, 1, $the_year)); $today_date = postcalendar_today('%Y-%m-%d'); $starting_date = date('m/d/Y', mktime(0, 0, 0, $the_month, 1 - $first_day, $the_year)); $ending_date = date('m/t/Y', mktime(0, 0, 0, $the_month + $pcbeventsrange, 1, $the_year)); $eventsByDate =& pnModAPIFunc(__POSTCALENDAR__, 'user', 'pcGetEvents', array('start' => $starting_date, 'end' => $ending_date)); $calendarView = Date_Calc::getCalendarMonth($the_month, $the_year, '%Y-%m-%d'); $sdaynames = array(); $numDays = count($pc_short_day_names); for ($i = 0; $i < $numDays; $i++) { if ($pc_array_pos >= $numDays) { $pc_array_pos = 0; } array_push($sdaynames, $pc_short_day_names[$pc_array_pos]); $pc_array_pos++; } $daynames = array(); $numDays = count($pc_long_day_names); for ($i = 0; $i < $numDays; $i++) { if ($pc_array_pos >= $numDays) { $pc_array_pos = 0; } array_push($daynames, $pc_long_day_names[$pc_array_pos]); $pc_array_pos++; } $dates = array(); while ($starting_date <= $ending_date) { array_push($dates, $starting_date); list($m, $d, $y) = explode('/', $starting_date); $starting_date = Date_Calc::nextDay($d, $m, $y, '%m/%d/%Y'); } $categories =& pnModAPIFunc(__POSTCALENDAR__, 'user', 'getCategories'); if (isset($calendarView)) { $tpl->assign_by_ref('CAL_FORMAT', $calendarView); } $tpl->assign_by_ref('A_MONTH_NAMES', $pc_month_names); $tpl->assign_by_ref('A_LONG_DAY_NAMES', $pc_long_day_names); $tpl->assign_by_ref('A_SHORT_DAY_NAMES', $pc_short_day_names); $tpl->assign_by_ref('S_LONG_DAY_NAMES', $daynames); $tpl->assign_by_ref('S_SHORT_DAY_NAMES', $sdaynames); $tpl->assign_by_ref('A_EVENTS', $eventsByDate); $tpl->assign_by_ref('A_CATEGORY', $categories); $tpl->assign_by_ref('PREV_MONTH_URL', $pc_prev); $tpl->assign_by_ref('NEXT_MONTH_URL', $pc_next); $tpl->assign_by_ref('MONTH_START_DATE', $month_view_start); $tpl->assign_by_ref('MONTH_END_DATE', $month_view_end); $tpl->assign_by_ref('TODAY_DATE', $today_date); $tpl->assign_by_ref('DATE', $Date); $tpl->assign_by_ref('DISPLAY_LIMIT', $eventslimit); $tpl->assign('TODAYS_EVENTS_TITLE', _PC_TODAYS_EVENTS); $tpl->assign('UPCOMING_EVENTS_TITLE', _PC_UPCOMING_EVENTS); $tpl->assign('NO_EVENTS', _PC_BLOCK_NO_EVENTS); } if ($showcalendar) { // we need to create a unique ID for caching purposes $output .= $tpl->fetch($template_name . '/views/calendarblock/month_view.html', $cacheid1); } if ($showevents) { if ($showcalendar) { $tpl->assign('SHOW_TITLE', 1); } else { $tpl->assign('SHOW_TITLE', 0); } // we need to create a unique ID for caching purposes $output .= $tpl->fetch($template_name . '/views/calendarblock/todays_events.html', $cacheid2); } if ($nextevents) { if ($showcalendar || $showevents) { $tpl->assign('SHOW_TITLE', 1); } else { $tpl->assign('SHOW_TITLE', 0); } // we need to create a unique ID for caching purposes $output .= $tpl->fetch($template_name . '/views/calendarblock/upcoming_events.html', $cacheid3); } if ($pcbshowsslinks) { $output .= '<br /><br />'; $submit_event_url = pnModURL(__POSTCALENDAR__, 'user', 'submit'); $search_event_url = pnModURL(__POSTCALENDAR__, 'user', 'search'); $output .= '<center>'; if (PC_ACCESS_ADD) { $output .= '[ <a href="' . $submit_event_url . '">' . _PC_SUBMIT_EVENT . '</a> ] '; } $output .= '[ <a href="' . $search_event_url . '">' . _PC_SEARCH_EVENT . '</a> ]'; $output .= '</center>'; } // Populate block info and pass to theme $blockinfo['content'] = $output; return themesideblock($blockinfo); }
/** * pnModLangLoad * loads the language files for a module * * @author Mark West * @link http://www.markwest.me.uk * @param modname - name of the module * @param type - type of the language file to load e.g. user, admin * @param api - load api lang file or gui lang file */ function pnModLangLoad($modname, $type = 'user', $api = false) { // define input, all numbers and booleans to strings $modname = isset($modname) ? (string) $modname : ''; // validate if (!pnVarValidate($modname, 'mod')) { return false; } // get the module info $modinfo = isset($modname) ? pnModGetInfo(pnModGetIDFromName($modname)) : false; if (!$modinfo) { return false; } // create variables for the OS preped version of the directory list($osdirectory, $ostype) = pnVarPrepForOS($modinfo['directory'], $type); $defaultlang = pnConfigGetVar('language'); if (empty($defaultlang)) { $defaultlang = 'eng'; } $osapi = ''; if ($api) { $osapi = 'api'; } $currentlang = pnUserGetLang(); if (file_exists("modules/{$osdirectory}/pnlang/{$currentlang}/{$ostype}{$osapi}.php")) { include_once "modules/{$osdirectory}/pnlang/" . pnVarPrepForOS($currentlang) . "/{$ostype}{$osapi}.php"; } elseif (file_exists("modules/{$osdirectory}/pnlang/{$defaultlang}/{$ostype}{$osapi}.php")) { include_once "modules/{$osdirectory}/pnlang/" . pnVarPrepForOS($defaultlang) . "/{$ostype}{$osapi}.php"; } return; }
if (empty($module)) { // call for admin.php without module parameter pnRedirect(pnModURL('Admin', 'admin', 'adminpanel')); exit; } else { if (!pnModAvailable($module) || !pnSecAuthAction(0, "{$module}::", '::', ACCESS_EDIT)) { // call for an unavailable module - either not available or not authorized header('HTTP/1.0 403 Access Denied'); include 'header.php'; echo 'Module <strong>' . pnVarPrepForDisplay($module) . '</strong> not available'; include 'footer.php'; exit; } } // get the module information $modinfo = pnModGetInfo(pnModGetIDFromName($module)); if ($modinfo['type'] == 2 || $modinfo['type'] == 3) { // Redirect to new style admin panel pnRedirect(pnModURL($module, 'admin')); exit; } if (!file_exists($adminfile = 'modules/' . pnVarPrepForOS($modinfo['directory']) . '/admin.php')) { // Module claims to be old-style, but no admin.php present - quit here header('HTTP/1.0 404 Not Found'); include 'header.php'; echo 'Wrong call for Adminfunction in Module <strong>' . pnVarPrepForDisplay($module) . '</strong>'; include 'footer.php'; exit; } /** * old style module administration
/** * Loads the required manual for module */ function modules_get_manual() { $currentlang = pnSessionGetVar('lang'); $language = pnConfigGetVar('language'); if (!isset($GLOBALS['ModName'])) { $modname = pnModGetName(); } else { $modname = $GLOBALS['ModName']; } $modinfo = pnModGetInfo(pnModGetIDFromName($modname)); if (file_exists('modules/' . pnVarPrepForOS($modinfo['directory']) . '/lang/' . pnVarPrepForOS($currentlang) . '/manual.html')) { $hlpfile = 'modules/' . pnVarPrepForOS($modinfo['directory']) . '/lang/' . pnVarPrepForOS($currentlang) . '/manual.html'; } elseif (!empty($language)) { if (file_exists('modules/' . pnVarPrepForOS($modinfo['directory']) . '/lang/' . pnVarPrepForOS($language) . '/manual.html')) { $hlpfile = 'modules/' . pnVarPrepForOS($modinfo['directory']) . '/lang/' . pnVarPrepForOS($language) . '/manual.html'; } } else { $hlpfile = 'modules/' . pnVarPrepForOS($modinfo['directory']) . '/lang/eng/manual.html'; } return; }
/** * upgrade a module */ function modules_adminapi_upgrade($args) { // 20021216 fixed the fix : larsneo (thx to cmgrote and jojodee) // Get arguments from argument array extract($args); // Argument check if (!isset($mid) || !is_numeric($mid)) { pnSessionSetVar('errormsg', _MODARGSERROR); return false; } // Get module information $modinfo = pnModGetInfo($mid); if (empty($modinfo)) { pnSessionSetVar('errormsg', _MODNOSUCHMOD); return false; } // Get module database info pnModDBInfoLoad($modinfo['name'], $modinfo['directory']); // Module upgrade function $osdir = pnVarPrepForOS($modinfo['directory']); @(include "modules/{$osdir}/pninit.php"); $func = $modinfo['name'] . '_upgrade'; if (function_exists($func)) { if ($func($modinfo['version']) != true) { return false; } } // Update state of module if (!modules_adminapi_setstate(array('mid' => $mid, 'state' => _PNMODULE_STATE_INACTIVE))) { return false; } // BEGIN bugfix (561802) - cmgrote // Get the new version information... $modversion['version'] = '0'; @(include "modules/{$modinfo['directory']}/Version.php"); @(include "modules/{$modinfo['directory']}/pnversion.php"); $version = $modversion['version']; // Note the changes in the database... list($dbconn) = pnDBGetConn(); $pntable = pnDBGetTables(); $modulestable = $pntable['modules']; $modulescolumn =& $pntable['modules_column']; $sql = "UPDATE {$modulestable}\n\t\t\tSET {$modulescolumn['version']} = '" . pnVarPrepForStore($modversion['version']) . "',\n\t\t\t\t{$modulescolumn['admin_capable']} = '" . pnVarPrepForStore($modversion['admin']) . "',\n\t\t\t\t{$modulescolumn['description']} = '" . pnVarPrepForStore($modversion['description']) . "'\n\t\t\tWHERE {$modulescolumn['id']} = " . pnVarPrepForStore($mid); $dbconn->Execute($sql); // END bugfix (561802) - cmgrote // Message pnSessionSetVar('errormsg', _MODULESAPIUPGRADED); // Success return true; }
/** * $Id$ * * PostCalendar::PostNuke Events Calendar Module * Copyright (C) 2002 The PostCalendar Team * http://postcalendar.tv * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * To read the license please read the docs/license.txt or visit * http://www.gnu.org/copyleft/gpl.html * */ function smarty_function_pc_filter($args, &$smarty) { extract($args); unset($args); if (empty($type)) { $smarty->trigger_error("pc_filter: missing 'type' parameter"); return; } $Date = postcalendar_getDate(); if (!isset($y)) { $y = substr($Date, 0, 4); } if (!isset($m)) { $m = substr($Date, 4, 2); } if (!isset($d)) { $d = substr($Date, 6, 2); } $tplview = pnVarCleanFromInput('tplview'); $viewtype = pnVarCleanFromInput('viewtype'); $pc_username = pnVarCleanFromInput('pc_username'); if (!isset($viewtype)) { $viewtype = _SETTING_DEFAULT_VIEW; } $types = explode(',', $type); $output = new pnHTML(); $output->SetOutputMode(_PNH_RETURNOUTPUT); $modinfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__)); $mdir = pnVarPrepForOS($modinfo['directory']); unset($modinfo); $pcTemplate = pnVarPrepForOS(_SETTING_TEMPLATE); if (empty($pcTemplate)) { $pcTemplate = 'default'; } list($dbconn) = pnDBGetConn(); $pntable = pnDBGetTables(); //================================================================ // build the username filter pulldown //================================================================ if (in_array('user', $types)) { @define('_PC_FORM_USERNAME', true); $sql = "SELECT DISTINCT users.username, users.lname, users.fname\n\t \t\t\tFROM {$pntable['postcalendar_events']}, users where users.id=pc_aid\n\t\t\t\tORDER BY pc_aid"; $result = $dbconn->Execute($sql); if ($result !== false) { $useroptions = "<select multiple='multiple' size='3' name=\"pc_username[]\" class=\"{$class}\">"; $useroptions .= "<option value=\"\" class=\"{$class}\">" . _PC_FILTER_USERS . "</option>"; $selected = $pc_username == '__PC_ALL__' ? 'selected="selected"' : ''; $useroptions .= "<option value=\"__PC_ALL__\" class=\"{$class}\" {$selected}>" . _PC_FILTER_USERS_ALL . "</option>"; for (; !$result->EOF; $result->MoveNext()) { $sel = $pc_username == $result->fields[0] ? 'selected="selected"' : ''; $useroptions .= "<option value=\"" . $result->fields[0] . "\" {$sel} class=\"{$class}\">" . $result->fields[1] . ", " . $result->fields[2] . "</option>"; } $useroptions .= '</select>'; $result->Close(); } } //================================================================ // build the category filter pulldown //================================================================ if (in_array('category', $types)) { @define('_PC_FORM_CATEGORY', true); $category = pnVarCleanFromInput('pc_category'); $categories = pnModAPIFunc(__POSTCALENDAR__, 'user', 'getCategories'); $catoptions = "<select name=\"pc_category\" class=\"{$class}\">"; $catoptions .= "<option value=\"\" class=\"{$class}\">" . _PC_FILTER_CATEGORY . "</option>"; foreach ($categories as $c) { $sel = $category == $c['id'] ? 'selected="selected"' : ''; $catoptions .= "<option value=\"{$c['id']}\" {$sel} class=\"{$class}\">" . xl_appt_category($c[name]) . "</option>"; } $catoptions .= '</select>'; } //================================================================ // build the topic filter pulldown //================================================================ if (in_array('topic', $types) && _SETTING_DISPLAY_TOPICS) { @define('_PC_FORM_TOPIC', true); $topic = pnVarCleanFromInput('pc_topic'); $topics = pnModAPIFunc(__POSTCALENDAR__, 'user', 'getTopics'); $topoptions = "<select name=\"pc_topic\" class=\"{$class}\">"; $topoptions .= "<option value=\"\" class=\"{$class}\">" . _PC_FILTER_TOPIC . "</option>"; foreach ($topics as $t) { $sel = $topic == $t['id'] ? 'selected="selected"' : ''; $topoptions .= "<option value=\"{$t['id']}\" {$sel} class=\"{$class}\">{$t['text']}</option>"; } $topoptions .= '</select>'; } else { $topoptions = ''; } //================================================================ // build it in the correct order //================================================================ if (!isset($label)) { $label = _PC_TPL_VIEW_SUBMIT; } $submit = "<input type=\"submit\" valign=\"middle\" name=\"submit\" value=\"{$label}\" class=\"{$class}\" />"; $orderArray = array('user' => $useroptions, 'category' => $catoptions, 'topic' => $topoptions, 'jump' => $submit); if (isset($order)) { $newOrder = array(); $order = explode(',', $order); foreach ($order as $tmp_order) { array_push($newOrder, $orderArray[$tmp_order]); } foreach ($orderArray as $key => $old_order) { if (!in_array($key, $newOrder)) { array_push($newOrder, $orderArray[$old_order]); } } $order = $newOrder; } else { $order = $orderArray; } foreach ($order as $element) { echo $element; } if (!in_array('user', $types)) { echo $output->FormHidden('pc_username', $pc_username); } }
/** * load a block * @param the module name * @param the name of the block */ function pnBlockLoad($modname, $block) { global $blocks_modules; static $loaded = array(); if (isset($loaded["{$modname}{$block}"])) { return true; } if (empty($modname) || $modname == 'Core') { $modname = 'Core'; $moddir = 'includes/blocks'; $langdir = 'includes/language/blocks'; } else { $modinfo = pnModGetInfo(pnModGetIdFromName($modname)); $moddir = 'modules/' . pnVarPrepForOS($modinfo['directory']) . '/pnblocks'; $langdir = 'modules/' . pnVarPrepForOS($modinfo['directory']) . '/pnlang'; } // Load the block $incfile = $block . ".php"; $filepath = $moddir . '/' . pnVarPrepForOS($incfile); if (!file_exists($filepath)) { return false; } include_once $filepath; $loaded["{$modname}{$block}"] = 1; // Load the block language files $currentlangfile = $langdir . '/' . pnVarPrepForOS(pnUserGetLang()) . '/' . pnVarPrepForOS($incfile); $defaultlangfile = $langdir . '/' . pnVarPrepForOS(pnConfigGetVar('language')) . '/' . pnVarPrepForOS($incfile); if (file_exists($currentlangfile)) { include $currentlangfile; } elseif (file_exists($defaultlangfile)) { include "{$defaultlangfile}"; } // Initialise block if required (new-style) $initfunc = "{$modname}_{$block}block_init"; if (function_exists($initfunc)) { $initfunc(); } return true; }
/** * $Id$ * * PostCalendar::PostNuke Events Calendar Module * Copyright (C) 2002 The PostCalendar Team * http://postcalendar.tv * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * To read the license please read the docs/license.txt or visit * http://www.gnu.org/copyleft/gpl.html * */ function smarty_function_pc_url($args) { //print "<br />args<br />"; //print_r($args); //print "<br />args<br />"; extract($args); unset($args); if (!isset($action)) { $action = _SETTING_DEFAULT_VIEW; } if (empty($print)) { $print = false; } else { $print = true; } $starth = ""; if ($setdeftime == 1) { $starth = date("H"); } $ampm = 1; if ($starth >= 12) { $ampm = 2; } $template_view = pnVarCleanFromInput('tplview'); $viewtype = strtolower(pnVarCleanFromInput('viewtype')); // pnVarCleanFromInput('pc_username'); //(CHEMED) replaced by the code below //(CHEMED) Facility filtering $pc_username = $_SESSION['pc_username']; $pc_facility = $_SESSION['pc_facility']; //END (CHEMED) $category = pnVarCleanFromInput('pc_category'); $topic = pnVarCleanFromInput('pc_topic'); $popup = pnVarCleanFromInput('popup'); if (!isset($date)) { $Date = postcalendar_getDate(); } else { $Date = $date; } // some extra cleanup if necessary $Date = str_replace('-', '', $Date); $pcModInfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__)); $pcDir = pnVarPrepForOS($pcModInfo['directory']); switch ($action) { case 'submit': if (!empty($starth)) { $link = pnModURL(__POSTCALENDAR__, 'user', 'submit', array('tplview' => $template_view, 'Date' => $Date, 'event_starttimeh' => $starth, 'event_startampm' => $ampm)); } else { $link = pnModURL(__POSTCALENDAR__, 'user', 'submit', array('tplview' => $template_view, 'Date' => $Date)); } break; case 'submit-admin': $link = pnModURL(__POSTCALENDAR__, 'admin', 'submit', array('tplview' => $template_view, 'Date' => $Date)); break; case 'search': $link = pnModURL(__POSTCALENDAR__, 'user', 'search'); break; case 'day': $link = pnModURL(__POSTCALENDAR__, 'user', 'view', array('tplview' => $template_view, 'viewtype' => 'day', 'Date' => $Date, 'pc_facility' => $pc_facility, 'pc_username' => $pc_username, 'pc_category' => $category, 'pc_topic' => $topic, 'print' => $print), $localpath); break; case 'week': $link = pnModURL(__POSTCALENDAR__, 'user', 'view', array('tplview' => $template_view, 'viewtype' => 'week', 'Date' => $Date, 'pc_facility' => $pc_facility, 'pc_username' => $pc_username, 'pc_category' => $category, 'pc_topic' => $topic, 'print' => $print)); break; case 'month': $link = pnModURL(__POSTCALENDAR__, 'user', 'view', array('tplview' => $template_view, 'viewtype' => 'month', 'Date' => $Date, 'pc_facility' => $pc_facility, 'pc_username' => $pc_username, 'pc_category' => $category, 'pc_topic' => $topic, 'print' => $print)); break; case 'year': $link = pnModURL(__POSTCALENDAR__, 'user', 'view', array('tplview' => $template_view, 'viewtype' => 'year', 'Date' => $Date, 'pc_facility' => $pc_facility, 'pc_username' => $pc_username, 'pc_category' => $category, 'pc_topic' => $topic, 'print' => $print)); break; case 'detail': if (isset($eid)) { if (_SETTING_OPEN_NEW_WINDOW && !$popup) { $link = "javascript:opencal({$eid},'{$Date}');"; } else { $link = pnModURL(__POSTCALENDAR__, 'user', 'view', array('Date' => $Date, 'tplview' => $template_view, 'viewtype' => 'details', 'eid' => $eid, 'print' => $print), $localpath); } } else { $link = ''; } break; } if ($print) { $link .= '" target="_blank"'; } elseif (_SETTING_OPEN_NEW_WINDOW && $viewtype == 'details') { $link .= '" target="csCalendar"'; } echo $link; }
/** * add a plugins dir to _plugin_dir array * * This function takes module name and adds two path two the plugins_dir array * when existing * * @param string $module well known module name * @access private */ function _add_plugins_dir($module) { $modinfo = pnModGetInfo(pnModGetIDFromName($module)); $modpath = $modinfo['type'] == 3 ? 'system' : 'modules'; $mod_plugs = "{$modpath}/{$modinfo['directory']}/pntemplates/plugins"; if (file_exists($mod_plugs)) { array_push($this->plugins_dir, $mod_plugs); } // uncomment for .8 until modtype=3 for system modules is implemented $modpath = 'system'; $mod_plugs = "{$modpath}/{$modinfo['directory']}/pntemplates/plugins"; if (file_exists($mod_plugs)) { array_push($this->plugins_dir, $mod_plugs); } }
exit; } elseif (function_exists($function_main)) { $function_main($_REQUEST); exit; } else { // die("error : user_execute($file,$function_op)"); pnRedirect('index.php'); return true; } } // when we are here, the call is the result of an action // requested by a (legacy) Your_Account plugin. // Get all user modules... $usermods = pnModGetUserMods(); // since the your account module does't have index.php/pnuser.php it // won't be listed as user_capable hence we need to manually add it to // our result set. [markwest] $usermods[] = pnModGetInfo(pnModGetIDFromName('Your_Account')); // ...and run the requested action (specified by $op) foreach ($usermods as $usermod) { if (@is_dir($dir = 'modules/' . $usermod['directory'] . '/user/case/')) { $casedir = opendir($dir); while ($func = readdir($casedir)) { if (eregi('^case.', $func)) { $ModName = $usermod['name']; include $dir . pnVarPrepForOS($func); } } closedir($casedir); } }
function postcalendar_user_submit($args) { // We need at least ADD permission to submit an event if (!(bool) PC_ACCESS_ADD) { return _POSTCALENDARNOAUTH; } $output = new pnHTML(); $output->SetInputMode(_PNH_VERBATIMINPUT); // get the theme globals :: is there a better way to do this? pnThemeLoad(pnUserGetTheme()); global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5, $textcolor1, $textcolor2; // $category = pnVarCleanFromInput('event_category'); $category = pnVarCleanFromInput('category'); if (!empty($category)) { $category = unserialize(base64_decode($category)); //print_r($category); } else { //print_r($_POST); $cat = $_POST['category']; $category = unserialize(base64_decode($cat)); //print_r($category); } //print_r($category); // echo("<!-- Here is the argument array: -->\n"); // foreach ($args as $tmpkey => $tmpval) { // debugging // echo("<!-- $tmpkey => '$tmpval' -->\n"); // } extract($args); $Date =& postcalendar_getDate(); $year = substr($Date, 0, 4); $month = substr($Date, 4, 2); $day = substr($Date, 6, 2); // basic event information $event_desc = pnVarCleanFromInput('event_desc'); $event_category = pnVarCleanFromInput('event_category'); $event_subject = pnVarCleanFromInput('event_subject'); $event_sharing = pnVarCleanFromInput('event_sharing'); $event_topic = pnVarCleanFromInput('event_topic'); //id of the user the event is for $event_userid = pnVarCleanFromInput('event_userid'); if (!is_numeric($event_userid)) { $event_userid = 0; } $event_pid = pnVarCleanFromInput('event_pid'); if (!is_numeric($event_pid)) { $event_pid = ""; } // event start information $event_startmonth = pnVarCleanFromInput('event_startmonth'); $event_startday = pnVarCleanFromInput('event_startday'); $event_startyear = pnVarCleanFromInput('event_startyear'); $event_starttimeh = pnVarCleanFromInput('event_starttimeh'); $event_starttimem = pnVarCleanFromInput('event_starttimem'); $event_startampm = pnVarCleanFromInput('event_startampm'); // location data $event_location = pnVarCleanFromInput('event_location'); $event_street1 = pnVarCleanFromInput('event_street1'); $event_street2 = pnVarCleanFromInput('event_street2'); $event_city = pnVarCleanFromInput('event_city'); $event_state = pnVarCleanFromInput('event_state'); $event_postal = pnVarCleanFromInput('event_postal'); $event_location_info = serialize(compact('event_location', 'event_street1', 'event_street2', 'event_city', 'event_state', 'event_postal')); // contact data $event_contname = pnVarCleanFromInput('event_contname'); $event_conttel = pnVarCleanFromInput('event_conttel'); $event_contemail = pnVarCleanFromInput('event_contemail'); $event_website = pnVarCleanFromInput('event_website'); $event_fee = pnVarCleanFromInput('event_fee'); $event_patient_name = pnVarCleanFromInput('patient_name'); // event repeating data if (is_array($category)) { //$event_subject = $event_desc = $category['desc']; $event_category = $category['id']; $event_duration = $category['event_duration']; //seconds of the event $event_dur_hours = $event_duration / (60 * 60); //seconds divided by 60 seconds * 60 minutes $event_dur_minutes = $event_duration % (60 * 60) / 60; $event_repeat = $category['event_repeat']; $event_repeat_freq = $category['event_repeat_freq']; $event_repeat_freq_type = $category['event_repeat_freq_type']; $event_repeat_on_num = $category['event_repeat_on_num']; $event_repeat_on_day = $category['event_repeat_on_day']; $event_repeat_on_freq = $category['event_repeat_on_freq']; $event_recurrspec = serialize(compact('event_repeat_freq', 'event_repeat_freq_type', 'event_repeat_on_num', 'event_repeat_on_day', 'event_repeat_on_freq')); // event end information $multiple = $category['end_date_freq'] . " "; switch ($category['end_date_type']) { case REPEAT_EVERY_DAY: case REPEAT_EVERY_WORK_DAY: //end date is in days $multiple .= "days"; break; case REPEAT_EVERY_WEEK: //end date is in weeks $multiple .= "weeks"; break; case REPEAT_EVERY_MONTH: //end date is in months $multiple .= "months"; break; case REPEAT_EVERY_YEAR: //end date is in years $multiple .= "years"; break; } $edate = strtotime(pnVarCleanFromInput('Date')); $event_startmonth = date("m", $edate); $event_startday = date("d", $edate); $event_startyear = date("Y", $edate); $event_enddate = strtotime(pnVarCleanFromInput('Date') . " + " . $multiple); $event_endmonth = date("m", $event_enddate); $event_endday = date("d", $event_enddate); $event_endyear = date("Y", $event_enddate); $event_endtype = $category['end_date_flag']; // I'm pretty sure this was a bug since 'event_all_day' appears nowhere // else in the code, but it's hard to tell WTF is going on. // $event_allday = $category['event_all_day']; $event_allday = $category['all_day']; } else { $event_dur_hours = pnVarCleanFromInput('event_dur_hours'); $event_dur_minutes = pnVarCleanFromInput('event_dur_minutes'); $event_duration = 60 * 60 * $event_dur_hours + 60 * $event_dur_minutes; $event_repeat = pnVarCleanFromInput('event_repeat'); $event_repeat_freq = pnVarCleanFromInput('event_repeat_freq'); $event_repeat_freq_type = pnVarCleanFromInput('event_repeat_freq_type'); $event_repeat_on_num = pnVarCleanFromInput('event_repeat_on_num'); $event_repeat_on_day = pnVarCleanFromInput('event_repeat_on_day'); $event_repeat_on_freq = pnVarCleanFromInput('event_repeat_on_freq'); $event_recurrspec = serialize(compact('event_repeat_freq', 'event_repeat_freq_type', 'event_repeat_on_num', 'event_repeat_on_day', 'event_repeat_on_freq')); // event end information $event_endmonth = pnVarCleanFromInput('event_endmonth'); $event_endday = pnVarCleanFromInput('event_endday'); $event_endyear = pnVarCleanFromInput('event_endyear'); $event_endtype = pnVarCleanFromInput('event_endtype'); $event_allday = pnVarCleanFromInput('event_allday'); } // Added by Rod: if ($event_allday) { $event_starttimeh = 0; $event_starttimem = 0; $event_startampm = 1; $event_dur_hours = 24; $event_dur_minutes = 0; $event_duration = 60 * 60 * $event_dur_hours; } $form_action = pnVarCleanFromInput('form_action'); $pc_html_or_text = pnVarCleanFromInput('pc_html_or_text'); $pc_event_id = pnVarCleanFromInput('pc_event_id'); $data_loaded = pnVarCleanFromInput('data_loaded'); $is_update = pnVarCleanFromInput('is_update'); $authid = pnVarCleanFromInput('authid'); //pennfirm uname matchup future fix //if(pnUserLoggedIn()) { $uname = pnUserGetVar('uname'); } //else { $uname = pnConfigGetVar('anonymous'); } $uname = $_SESSION['authUser']; if (!isset($event_repeat)) { $event_repeat = 0; } if (!isset($pc_event_id) || empty($pc_event_id) || $data_loaded) { // lets wrap all the data into array for passing to submit and preview functions $eventdata = compact('event_subject', 'event_desc', 'event_sharing', 'event_category', 'event_topic', 'event_startmonth', 'event_startday', 'event_startyear', 'event_starttimeh', 'event_starttimem', 'event_startampm', 'event_endmonth', 'event_endday', 'event_endyear', 'event_endtype', 'event_dur_hours', 'event_dur_minutes', 'event_duration', 'event_allday', 'event_location', 'event_street1', 'event_street2', 'event_city', 'event_state', 'event_postal', 'event_location_info', 'event_contname', 'event_conttel', 'event_contemail', 'event_website', 'event_fee', 'event_repeat', 'event_repeat_freq', 'event_repeat_freq_type', 'event_repeat_on_num', 'event_repeat_on_day', 'event_repeat_on_freq', 'event_recurrspec', 'uname', "event_userid", "event_pid", 'Date', 'year', 'month', 'day', 'pc_html_or_text', 'event_patient_name', 'event_pid'); $eventdata['is_update'] = $is_update; $eventdata['pc_event_id'] = $pc_event_id; $eventdata['data_loaded'] = true; $eventdata['category'] = base64_encode(serialize($category)); } else { $event =& postcalendar_userapi_pcGetEventDetails($pc_event_id); //echo "uname is:$uname other name is: ".$event['uname'] . "<br />"; if ($uname != $event['uname']) { if (!validateGroupStatus($uname, getUsername($event['uname']))) { return _PC_CAN_NOT_EDIT; } } $eventdata['event_subject'] = $event['title']; $eventdata['event_desc'] = $event['hometext']; $eventdata['event_sharing'] = $event['sharing']; $eventdata['event_category'] = $event['catid']; $eventdata['event_topic'] = $event['topic']; $eventdata['event_startmonth'] = substr($event['eventDate'], 5, 2); $eventdata['event_startday'] = substr($event['eventDate'], 8, 2); $eventdata['event_startyear'] = substr($event['eventDate'], 0, 4); $eventdata['event_starttimeh'] = substr($event['startTime'], 0, 2); $eventdata['event_starttimem'] = substr($event['startTime'], 3, 2); $eventdata['event_startampm'] = $eventdata['event_starttimeh'] < 12 ? 1 : 2; //1 is am , 2 is pm $eventdata['event_endmonth'] = substr($event['endDate'], 5, 2); $eventdata['event_endday'] = substr($event['endDate'], 8, 2); $eventdata['event_endyear'] = substr($event['endDate'], 0, 4); $eventdata['event_endtype'] = $event['endDate'] == '0000-00-00' ? '0' : '1'; $eventdata['event_dur_hours'] = $event['duration_hours']; $eventdata['event_dur_minutes'] = $event['duration_minutes']; $eventdata['event_duration'] = $event['duration']; $eventdata['event_allday'] = $event['alldayevent']; $loc_data = unserialize($event['location']); $eventdata['event_location'] = $loc_data['event_location']; $eventdata['event_street1'] = $loc_data['event_street1']; $eventdata['event_street2'] = $loc_data['event_street2']; $eventdata['event_city'] = $loc_data['event_city']; $eventdata['event_state'] = $loc_data['event_state']; $eventdata['event_postal'] = $loc_data['event_postal']; $eventdata['event_location_info'] = $loc_data; $eventdata['event_contname'] = $event['contname']; $eventdata['event_conttel'] = $event['conttel']; $eventdata['event_contemail'] = $event['contemail']; $eventdata['event_website'] = $event['website']; $eventdata['event_fee'] = $event['fee']; $eventdata['event_repeat'] = $event['recurrtype']; $rspecs = unserialize($event['recurrspec']); $eventdata['event_repeat_freq'] = $rspecs['event_repeat_freq']; $eventdata['event_repeat_freq_type'] = $rspecs['event_repeat_freq_type']; $eventdata['event_repeat_on_num'] = $rspecs['event_repeat_on_num']; $eventdata['event_repeat_on_day'] = $rspecs['event_repeat_on_day']; $eventdata['event_repeat_on_freq'] = $rspecs['event_repeat_on_freq']; $eventdata['event_recurrspec'] = $rspecs; $eventdata['uname'] = $uname; $eventdata['event_userid'] = $event['event_userid']; $eventdata['event_pid'] = $event['pid']; $eventdata['event_aid'] = $event['aid']; $eventdata['Date'] = $Date; $eventdata['year'] = $year; $eventdata['month'] = $month; $eventdata['day'] = $day; $eventdata['is_update'] = true; $eventdata['pc_event_id'] = $pc_event_id; $event_data['patient_name'] = $event_patient_name; $eventdata['data_loaded'] = true; $eventdata['pc_html_or_text'] = $pc_html_or_text; $eventdata['category'] = base64_encode(serialize($category)); } // lets get the module's information $modinfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__)); $categories = pnModAPIFunc(__POSTCALENDAR__, 'user', 'getCategories'); $output->tabindex = 1; //================================================================ // ERROR CHECKING //================================================================ // removed event_desc as a required_var $required_vars = array('event_subject'); $required_name = array(_PC_EVENT_TITLE, _PC_EVENT_DESC); $error_msg = ''; $output->SetOutputMode(_PNH_RETURNOUTPUT); $reqCount = count($required_vars); //print_r($eventdata); for ($r = 0; $r < $reqCount; $r++) { if (empty(${$required_vars}[$r]) || !preg_match('/\\S/i', ${$required_vars}[$r])) { $error_msg .= $output->Text('<b>' . $required_name[$r] . '</b> ' . _PC_SUBMIT_ERROR4); $error_msg .= $output->Linebreak(); } } unset($reqCount); // check repeating frequencies if ($event_repeat == REPEAT) { //can't have a repeating event that doesnt have an end date if ($event_endtype == 0) { $error_msg .= $output->Text("Repeating events must have an end date set."); $error_msg .= $output->Linebreak(); } if (!isset($event_repeat_freq) || $event_repeat_freq < 1 || empty($event_repeat_freq)) { $error_msg .= $output->Text(_PC_SUBMIT_ERROR5); $error_msg .= $output->Linebreak(); } elseif (!is_numeric($event_repeat_freq)) { $error_msg .= $output->Text(_PC_SUBMIT_ERROR6); $error_msg .= $output->Linebreak(); } } elseif ($event_repeat == REPEAT_ON) { //can't have a repeating event that doesnt have an end date if ($event_endtype == 0) { $error_msg .= $output->Text("Repeating events must have an end date set."); $error_msg .= $output->Linebreak(); } if (!isset($event_repeat_on_freq) || $event_repeat_on_freq < 1 || empty($event_repeat_on_freq)) { $error_msg .= $output->Text(_PC_SUBMIT_ERROR5); $error_msg .= $output->Linebreak(); } elseif (!is_numeric($event_repeat_on_freq)) { $error_msg .= $output->Text(_PC_SUBMIT_ERROR6); $error_msg .= $output->Linebreak(); } } // check date validity if (_SETTING_TIME_24HOUR) { $startTime = $event_starttimeh . ':' . $event_starttimem; $endTime = $event_endtimeh . ':' . $event_endtimem; } else { if ($event_startampm == _AM_VAL) { $event_starttimeh = $event_starttimeh == 12 ? '00' : $event_starttimeh; } else { $event_starttimeh = $event_starttimeh != 12 ? $event_starttimeh += 12 : $event_starttimeh; } $startTime = $event_starttimeh . ':' . $event_starttimem; } $sdate = strtotime($event_startyear . '-' . $event_startmonth . '-' . $event_startday); $edate = strtotime($event_endyear . '-' . $event_endmonth . '-' . $event_endday); $tdate = strtotime(date('Y-m-d')); if ($edate < $sdate && $event_endtype == 1) { $error_msg .= $output->Text(_PC_SUBMIT_ERROR1); $error_msg .= $output->Linebreak(); } if (!checkdate($event_startmonth, $event_startday, $event_startyear)) { $error_msg .= $output->Text(_PC_SUBMIT_ERROR2 . " '{$event_startyear}-{$event_startmonth}-{$event_startday}'"); $error_msg .= $output->Linebreak(); } if (!checkdate($event_endmonth, $event_endday, $event_endyear)) { $error_msg .= $output->Text(_PC_SUBMIT_ERROR3 . " '{$event_endyear}-{$event_endmonth}-{$event_endday}'"); $error_msg .= $output->Linebreak(); } //check limit on category if (($ret = checkCategoryLimits($eventdata)) != null) { $error_msg .= $output->Text("This category has a limit of {$ret['limit']} between {$ret['start']} and {$ret['end']} which you have exceeded."); $error_msg .= $output->Linebreak(); //$output->Text(pnModAPIFunc('PostCalendar','user','buildSubmitForm',$eventdata)); //return $output->GetOutput(); } //echo "fa: " . $form_action . " double_book: " . pnVarCleanFromInput("double_book") . " update: " . $eventdata['is_update'] . " em: " . $error_msg; //event collision check if ($form_action == "commit" && pnVarCleanFromInput("double_book") != 1 && !$eventdata['is_update'] && empty($error_msg)) { //check on new shceduling events(in or out of office) to make sure that //you don't have more than one set per day //event category 1 is in office, event category 2 is out of office if ($eventdata['event_category'] == 2 || $eventdata['event_category'] == 3) { $searchargs = array(); $searchargs['start'] = $eventdata['event_startmonth'] . "/" . $eventdata['event_startday'] . "/" . $eventdata['event_startyear']; $searchargs['end'] = $eventdata['event_endmonth'] . "/" . $eventdata['event_endday'] . "/" . $eventdata['event_endyear']; $searchargs['provider_id'] = $eventdata['event_userid']; //faFLag uses pcgeteventsfa, which can search on provider $searchargs['faFlag'] = true; $searchargs['s_keywords'] = " (a.pc_catid = 2 OR a.pc_catid = 3) "; //print_r($searchargs); $eventsByDate =& postcalendar_userapi_pcGetEvents($searchargs); $ekey = md5($event_data['subject'] . date("U") . rand(0, 1000)); $oldstatus = $eventdata['event_status']; $oldtitle = $eventdata['event_subject']; $old_patient_name = $eventdata['patient_name']; $old_dur_hours = $eventdata['event_dur_hours']; $old_dur_min = $eventdata['event_dur_minutes']; $old_duration = $eventdata['event_duration']; $eventdata['event_subject'] = mysql_real_escape_string($ekey); $eventdata['event_status'] = _EVENT_TEMPORARY; if (!pnModAPIFunc(__POSTCALENDAR__, 'user', 'submitEvent', $eventdata)) { $error_msg .= $output->Text('<center><div style="padding:5px; border:1px solid red; background-color: pink;">'); $error_msg .= $output->Text("<b>The system was unable to check you event for conflicts with other events because there was a problem with your database.</b><br />"); $error_msg .= $output->Text('</div></center>'); $error_msg .= $output->Linebreak(); $error_msg .= $output->Text($dbconn->ErrorMsg()); } $searchargs['s_keywords'] = " (a.pc_catid = 2 OR a.pc_catid = 3) AND a.pc_title = '" . $eventdata['event_subject'] . "' "; $searchargs['event_status'] = _EVENT_TEMPORARY; $submitEventByDate =& postcalendar_userapi_pcGetEvents($searchargs); if (!delete_event($ekey)) { $error_msg .= $output->Text('<center><div style="padding:5px; border:1px solid red; background-color: pink;">'); $error_msg .= $output->Text("<b>The system was unable to delete a temporary record it created, this may have left the database in an inconsistent state.</b><br />"); $error_msg .= $output->Text('</div></center>'); $error_msg .= $output->Linebreak(); $error_msg .= $output->Text($dbconn->ErrorMsg()); } $eventdata['event_status'] = $oldstatus; $eventdata['event_subject'] = $oldtitle; $eventdata['patient_name '] = $old_patient_name; $eventdata['event_dur_hours'] = $old_dur_hour; $eventdata['event_dur_minutes'] = $old_dur_min; foreach ($submitEventByDate as $date => $newevent) { if (count($eventsByDate[$date]) > 0 && count($newevent) > 0) { foreach ($eventsByDate[$date] as $con_event) { if ($con_event['catid'] == $newevent[0]['catid']) { $error_msg .= $output->Text('There is a conflict on ' . $date . ' with event ' . $con_event['title']); $error_msg .= $output->Linebreak(); } } } } /*echo "<br /><br />"; print_r($eventsByDate); echo "<br /><br />"; print_r($submitEventByDate);*/ } $colls = checkEventCollision($eventdata); if (count($colls) > 0) { foreach ($colls as $coll) { $error_msg .= $output->Text("Event Collides with: " . $coll['title'] . " at " . date("g:i a", strtotime($coll['startTime'])) . "<br />"); $error_msg .= $output->Linebreak(); } $error_msg .= $output->Text("Submit again to \"Double Book\" <br />To change values click back in your browser."); $error_msg .= $output->Linebreak(); // the following line will display "DOUBLE BOOKED" if when adding an event there is a collistion with anothe appointment //$eventdata['event_subject'] = "DOUBLE BOOKED " . $eventdata['event_subject']; $eventdata['double_book'] = 1; } } $output->SetOutputMode(_PNH_KEEPOUTPUT); if ($form_action == 'preview') { //================================================================ // Preview the event //================================================================ // check authid if (!pnSecConfirmAuthKey()) { return _NO_DIRECT_ACCESS; } if (!empty($error_msg)) { $preview = false; $output->Text('<table border="0" width="100%" cellpadding="1" cellspacing="0"><tr><td bgcolor="red">'); $output->Text('<table border="0" width="100%" cellpadding="1" cellspacing="0"><tr><td bgcolor="pink">'); $output->Text('<center><b>' . _PC_SUBMIT_ERROR . '</b></center>'); $output->Linebreak(); $output->Text($error_msg); $output->Text('</td></td></table>'); $output->Text('</td></td></table>'); $output->Linebreak(2); } else { $output->Text(pnModAPIFunc(__POSTCALENDAR__, 'user', 'eventPreview', $eventdata)); $output->Linebreak(); } } elseif ($form_action == 'commit') { //================================================================ // Enter the event into the DB //================================================================ if (!empty($error_msg)) { if (!pnSecConfirmAuthKey(true)) { return _NO_DIRECT_ACCESS; } } else { if (!pnSecConfirmAuthKey()) { return _NO_DIRECT_ACCESS; } } if (!empty($error_msg)) { $preview = false; $output->Text('<table border="0" width="100%" cellpadding="1" cellspacing="0"><tr><td bgcolor="red">'); $output->Text('<table border="0" width="100%" cellpadding="1" cellspacing="0"><tr><td bgcolor="pink">'); $output->Text('<center><b>' . _PC_SUBMIT_ERROR . '</b></center>'); $output->Linebreak(); $output->Text($error_msg); $output->Text('</td></td></table>'); $output->Text('</td></td></table>'); $output->Linebreak(2); } else { if (!pnModAPIFunc(__POSTCALENDAR__, 'user', 'submitEvent', $eventdata)) { $output->Text('<center><div style="padding:5px; border:1px solid red; background-color: pink;">'); $output->Text("<b>" . _PC_EVENT_SUBMISSION_FAILED . "</b>"); $output->Text('</div></center>'); $output->Linebreak(); $output->Text($dbconn->ErrorMsg()); } else { // clear the Smarty cache $tpl = new pcSmarty(); $tpl->clear_all_cache(); $output->Text('<center><div style="padding:5px; border:1px solid green; background-color: lightgreen;">'); if ($is_update) { $output->Text("<b>" . _PC_EVENT_EDIT_SUCCESS . "</b>"); } else { $output->Text("<b>" . _PC_EVENT_SUBMISSION_SUCCESS . "</b>"); } $output->Text('</div></center>'); $output->Linebreak(); // clear the form vars $event_subject = $event_desc = $event_sharing = $event_category = $event_topic = $event_startmonth = $event_startday = $event_startyear = $event_starttimeh = $event_starttimem = $event_startampm = $event_endmonth = $event_endday = $event_endyear = $event_endtype = $event_dur_hours = $event_dur_minutes = $event_duration = $event_allday = $event_location = $event_street1 = $event_street2 = $event_city = $event_state = $event_postal = $event_location_info = $event_contname = $event_conttel = $event_contemail = $event_website = $event_fee = $event_repeat = $event_repeat_freq = $event_repeat_freq_type = $event_repeat_on_num = $event_repeat_on_day = $event_repeat_on_freq = $event_recurrspec = $uname = $Date = $year = $month = $day = $pc_html_or_text = $event_patient_name = $evnet_pid = null; $is_update = false; $pc_event_id = 0; //$_SESSION['category'] = ""; // lets wrap all the data into array for passing to submit and preview functions $eventdata = compact('event_subject', 'event_desc', 'event_sharing', 'event_category', 'event_topic', 'event_startmonth', 'event_startday', 'event_startyear', 'event_starttimeh', 'event_starttimem', 'event_startampm', 'event_endmonth', 'event_endday', 'event_endyear', 'event_endtype', 'event_dur_hours', 'event_dur_minutes', 'event_duration', 'event_allday', 'event_location', 'event_street1', 'event_street2', 'event_city', 'event_state', 'event_postal', 'event_location_info', 'event_contname', 'event_conttel', 'event_contemail', 'event_website', 'event_fee', 'event_repeat', 'event_repeat_freq', 'event_repeat_freq_type', 'event_repeat_on_num', 'event_repeat_on_day', 'event_repeat_on_freq', 'event_recurrspec', 'uname', 'Date', 'year', 'month', 'day', 'pc_html_or_text', 'is_update', 'pc_event_id', 'event_patient_name'); //if no using the no_nav format then show form again after submit if (pnVarCleanFromInput("no_nav") == 1) { return $output->GetOutput(); } } } } $output->Text(pnModAPIFunc('PostCalendar', 'user', 'buildSubmitForm', $eventdata)); return $output->GetOutput(); }
/** * load a block * * @param string $modname module name * @param string $block name of the block * @return bool true on successful load, false otherwise */ function pnBlockLoad($modname, $block) { static $loaded = array(); if (empty($modname) || $modname == 'Core' || $modname == 'Blocks') { $modname = 'Core'; $moddir = 'includes/blocks'; $langdir = 'includes/language/blocks'; } else { $modinfo = pnModGetInfo(pnModGetIdFromName($modname)); $moddir = 'modules/' . pnVarPrepForOS($modinfo['directory']) . '/pnblocks'; $langdir = 'modules/' . pnVarPrepForOS($modinfo['directory']) . '/pnlang'; } if (isset($loaded["{$modname}/{$block}"])) { return true; } // Load the block $incfile = $block . '.php'; $filepath = $moddir . '/' . pnVarPrepForOS($incfile); if (!file_exists($filepath)) { return false; } include_once $filepath; $loaded["{$modname}/{$block}"] = 1; // Load the block language files $currentlangfile = $langdir . '/' . pnVarPrepForOS(pnUserGetLang()) . '/' . pnVarPrepForOS($incfile); $defaultlangfile = $langdir . '/' . pnVarPrepForOS(pnConfigGetVar('language')) . '/' . pnVarPrepForOS($incfile); if (file_exists($currentlangfile)) { include $currentlangfile; } elseif (file_exists($defaultlangfile)) { include $defaultlangfile; } // get the block info $infofunc = "{$modname}_{$block}block_info"; if (function_exists($infofunc)) { $blocks_modules[$block] = $infofunc(); } // set the module and keys for the new block $blocks_modules[$block]['bkey'] = $block; if (!isset($blocks_modules[$block]['module'])) { $blocks_modules[$block]['module'] = $modname; } $blocks_modules[$block]['mid'] = pnModGetIDFromName($blocks_modules[$block]['module']); // merge the blockinfo in the global list of blocks if (!isset($GLOBALS['blocks_modules'])) { $GLOBALS['blocks_modules'] = array(); } $GLOBALS['blocks_modules'][$blocks_modules[$block]['mid']][$block] = $blocks_modules[$block]; // Initialise block if required (new-style) $initfunc = "{$modname}_{$block}block_init"; if (function_exists($initfunc)) { $initfunc(); } return true; }
* but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * To read the license please read the docs/license.txt or visit * http://www.gnu.org/copyleft/gpl.html * */ //========================================================================= // Require utility classes //========================================================================= $pcModInfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__)); $pcDir = pnVarPrepForOS($pcModInfo['directory']); require_once "modules/{$pcDir}/common.api.php"; unset($pcModInfo, $pcDir); function postcalendar_adminapi_buildHourSelect($args) { extract($args); $time24hours = pnModGetVar(__POSTCALENDAR__, 'time24hours'); if (!isset($hour)) { $hour = $time24hours ? date('H') : date('h'); } $output = new pnHTML(); $output->SetInputMode(_PNH_VERBATIMINPUT); $options = array(); if ($time24hours) { for ($i = 0; $i < 24; $i++) {
/** * confirm an authorisation key is valid * <br /> * See description of <code>pnSecGenAuthKey</code> for information on * this function * * @public * @return bool true if the key is valid, false if it is not */ function pnSecConfirmAuthKey() { list($module, $authid) = pnVarCleanFromInput('module', 'authid'); // get the module info $modinfo = pnModGetInfo(pnModGetIDFromName($module)); // Regenerate static part of key $partkey = pnSessionGetVar('rand') . strtolower($modinfo['name']); // Not using time-sensitive keys for the moment // // Key life is 5 minutes, so search backwards and forwards 5 // // minutes to see if there is a match anywhere // for ($i=-5; $i<=5; $i++) { // $testdate = mktime(date('G'), date('i')+$i, 0, date('m') , date('d'), date('Y')); // $testauthid = md5($partkey . date('YmdGi', $testdate)); // if ($testauthid == $authid) { // // Match // // We've used up the current random // // number, make up a new one // srand((double)microtime()*1000000); // pnSessionSetVar('rand', rand()); // return true; // } // } if (md5($partkey) == $authid) { // Match - generate new random number for next key and leave happy srand((double) microtime() * 1000000); pnSessionSetVar('rand', rand()); return true; } // Not found, assume invalid return false; }
/** * postcalendar_userapi_buildView * * Builds the calendar display * @param string $Date mm/dd/yyyy format (we should use timestamps) * @return string generated html output * @access public */ function postcalendar_userapi_buildView($args) { $print = pnVarCleanFromInput('print'); $show_days = pnVarCleanFromInput('show_days'); extract($args); unset($args); $schedule_start = $GLOBALS[schedule_start]; $schedule_end = $GLOBALS[schedule_end]; // $times is an array of associative arrays, where each sub-array // has keys 'hour', 'minute' and 'mer'. // $times = array(); // For each hour in the schedule... // for ($blocknum = $schedule_start; $blocknum <= $schedule_end; $blocknum++) { $mer = $blocknum >= 12 ? 'pm' : 'am'; // $minute is an array of time slot strings within this hour. $minute = array('00'); for ($minutes = $GLOBALS['calendar_interval']; $minutes <= 60; $minutes += $GLOBALS['calendar_interval']) { if ($minutes <= '9') { $under_ten = "0" . $minutes; array_push($minute, "{$under_ten}"); } else { if ($minutes >= '60') { break; } else { array_push($minute, "{$minutes}"); } } } foreach ($minute as $m) { array_push($times, array("hour" => $blocknum, "minute" => $m, "mer" => $mer)); } } //================================================================= // get the module's information //================================================================= $modinfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__)); $pcDir = $modinfo['directory']; unset($modinfo); //================================================================= // grab the for post variable //================================================================= // $pc_username = pnVarCleanFromInput('pc_username'); $pc_username = $_SESSION['pc_username']; // from Michael Brinson 2006-09-19 $category = pnVarCleanFromInput('pc_category'); $topic = pnVarCleanFromInput('pc_topic'); //================================================================= // set the correct date //================================================================= $Date = postcalendar_getDate(); //================================================================= // get the current view //================================================================= if (!isset($viewtype)) { $viewtype = 'month'; } //================================================================= // Find out what Template we're using //================================================================= $template_name = _SETTING_TEMPLATE; if (!isset($template_name)) { $template_name = 'default'; } //================================================================= // Find out what Template View to use //================================================================= $template_view = pnVarCleanFromInput('tplview'); if (!isset($template_view)) { $template_view = 'default'; } //================================================================= // See if the template view exists //================================================================= if (!file_exists("modules/{$pcDir}/pntemplates/{$template_name}/views/{$viewtype}/{$template_view}.html")) { $template_view_load = 'default'; } else { $template_view_load = pnVarPrepForOS($template_view); } //================================================================= // Grab the current theme information //================================================================= pnThemeLoad(pnUserGetTheme()); global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5, $bgcolor6, $textcolor1, $textcolor2; //================================================================= // Insert necessary JavaScript into the page //================================================================= $output = pnModAPIFunc(__POSTCALENDAR__, 'user', 'pageSetup'); //================================================================= // Setup Smarty Template Engine //================================================================= $tpl = new pcSmarty(); //if(!$tpl->is_cached("$template_name/views/$viewtype/$template_view_load.html",$cacheid)) { //diable caching completely if (true) { //================================================================= // Let's just finish setting things up //================================================================= $the_year = substr($Date, 0, 4); $the_month = substr($Date, 4, 2); $the_day = substr($Date, 6, 2); $last_day = Date_Calc::daysInMonth($the_month, $the_year); //================================================================= // populate the template object with information for // Month Names, Long Day Names and Short Day Names // as translated in the language files // (may be adding more here soon - based on need) //================================================================= $pc_month_names = array(_CALJAN, _CALFEB, _CALMAR, _CALAPR, _CALMAY, _CALJUN, _CALJUL, _CALAUG, _CALSEP, _CALOCT, _CALNOV, _CALDEC); $pc_short_day_names = array(_CALSUNDAYSHORT, _CALMONDAYSHORT, _CALTUESDAYSHORT, _CALWEDNESDAYSHORT, _CALTHURSDAYSHORT, _CALFRIDAYSHORT, _CALSATURDAYSHORT); $pc_long_day_names = array(_CALSUNDAY, _CALMONDAY, _CALTUESDAY, _CALWEDNESDAY, _CALTHURSDAY, _CALFRIDAY, _CALSATURDAY); //================================================================= // here we need to set up some information for later // variable creation. This helps us establish the correct // date ranges for each view. There may be a better way // to handle all this, but my brain hurts, so your comments // are very appreciated and welcomed. //================================================================= switch (_SETTING_FIRST_DAY_WEEK) { case _IS_MONDAY: $pc_array_pos = 1; $first_day = date('w', mktime(0, 0, 0, $the_month, 0, $the_year)); $week_day = date('w', mktime(0, 0, 0, $the_month, $the_day - 1, $the_year)); $end_dow = date('w', mktime(0, 0, 0, $the_month, $last_day, $the_year)); if ($end_dow != 0) { $the_last_day = $last_day + (7 - $end_dow); } else { $the_last_day = $last_day; } break; case _IS_SATURDAY: $pc_array_pos = 6; $first_day = date('w', mktime(0, 0, 0, $the_month, 2, $the_year)); $week_day = date('w', mktime(0, 0, 0, $the_month, $the_day + 1, $the_year)); $end_dow = date('w', mktime(0, 0, 0, $the_month, $last_day, $the_year)); if ($end_dow == 6) { $the_last_day = $last_day + 6; } elseif ($end_dow != 5) { $the_last_day = $last_day + (5 - $end_dow); } else { $the_last_day = $last_day; } break; case _IS_SUNDAY: default: $pc_array_pos = 0; $first_day = date('w', mktime(0, 0, 0, $the_month, 1, $the_year)); $week_day = date('w', mktime(0, 0, 0, $the_month, $the_day, $the_year)); $end_dow = date('w', mktime(0, 0, 0, $the_month, $last_day, $the_year)); if ($end_dow != 6) { $the_last_day = $last_day + (6 - $end_dow); } else { $the_last_day = $last_day; } break; } // passing the times array to the tpl the times array is for the days schedule $tpl->assign_by_ref("times", $times); // load the table width to the template // $tpl->assign("day_td_width",$GLOBALS['day_view_td_width']); //================================================================= // Week View is a bit of a pain in the ass, so we need to // do some extra setup for that view. This section will // find the correct starting and ending dates for a given // seven day period, based on the day of the week the // calendar is setup to run under (Sunday, Saturday, Monday) //================================================================= $first_day_of_week = sprintf('%02d', $the_day - $week_day); $week_first_day = date('m/d/Y', mktime(0, 0, 0, $the_month, $first_day_of_week, $the_year)); list($week_first_day_month, $week_first_day_date, $week_first_day_year) = explode('/', $week_first_day); $week_first_day_month_name = pnModAPIFunc(__POSTCALENDAR__, 'user', 'getmonthname', array('Date' => mktime(0, 0, 0, $week_first_day_month, $week_first_day_date, $week_first_day_year))); $week_last_day = date('m/d/Y', mktime(0, 0, 0, $the_month, $first_day_of_week + 6, $the_year)); list($week_last_day_month, $week_last_day_date, $week_last_day_year) = explode('/', $week_last_day); $week_last_day_month_name = pnModAPIFunc(__POSTCALENDAR__, 'user', 'getmonthname', array('Date' => mktime(0, 0, 0, $week_last_day_month, $week_last_day_date, $week_last_day_year))); $week_view_start = date('Y-m-d', mktime(0, 0, 0, $the_month, $first_day_of_week, $the_year)); $week_view_end = date('Y-m-d', mktime(0, 0, 0, $the_month, $first_day_of_week + 6, $the_year)); //================================================================= // Setup some information so we know the actual month's dates // also get today's date for later use and highlighting //================================================================= $month_view_start = date('Y-m-d', mktime(0, 0, 0, $the_month, 1, $the_year)); $month_view_end = date('Y-m-t', mktime(0, 0, 0, $the_month, 1, $the_year)); $today_date = postcalendar_today('%Y-%m-%d'); //================================================================= // Setup the starting and ending date ranges for pcGetEvents() //================================================================= switch ($viewtype) { case 'day': $starting_date = date('m/d/Y', mktime(0, 0, 0, $the_month, $the_day, $the_year)); $ending_date = date('m/d/Y', mktime(0, 0, 0, $the_month, $the_day, $the_year)); break; case 'week': $starting_date = "{$week_first_day_month}/{$week_first_day_date}/{$week_first_day_year}"; $ending_date = "{$week_last_day_month}/{$week_last_day_date}/{$week_last_day_year}"; $calendarView = Date_Calc::getCalendarWeek($week_first_day_date, $week_first_day_month, $week_first_day_year, '%Y-%m-%d'); break; case 'month': $starting_date = date('m/d/Y', mktime(0, 0, 0, $the_month, 1 - $first_day, $the_year)); $ending_date = date('m/d/Y', mktime(0, 0, 0, $the_month, $the_last_day, $the_year)); $calendarView = Date_Calc::getCalendarMonth($the_month, $the_year, '%Y-%m-%d'); break; case 'year': $starting_date = date('m/d/Y', mktime(0, 0, 0, 1, 1, $the_year)); $ending_date = date('m/d/Y', mktime(0, 0, 0, 1, 1, $the_year + 1)); $calendarView = Date_Calc::getCalendarYear($the_year, '%Y-%m-%d'); break; } //================================================================= // Identify the Providers whose schedules we should load //================================================================= //================================== //FACILITY FILTERING (CHEMED) if ($_SESSION['pc_facility']) { $provinfo = getProviderInfo('%', true, $_SESSION['pc_facility']); } else { $provinfo = getProviderInfo(); } //EOS FACILITY FILTERING (CHEMED) //================================== $single = array(); $provIDs = array(); // array of numeric provider IDs // filter the display on the requested username, the provinfo array is // used to build columns in the week view. foreach ($provinfo as $provider) { if (is_array($pc_username)) { foreach ($pc_username as $uname) { if (!empty($pc_username) && $provider['username'] == $uname) { array_push($single, $provider); array_push($provIDs, $provider['id']); } } } else { if (!empty($pc_username) && $provider['username'] == $pc_username) { array_push($single, $provider); array_push($provIDs, $provider['id']); } } } if ($single != null) { $provinfo = $single; } //================================================================= // Load the events //================================================================= if ($viewtype != 'year') { $eventsByDate =& postcalendar_userapi_pcGetEvents(array('start' => $starting_date, 'end' => $ending_date, 'viewtype' => $viewtype, 'provider_id' => $provIDs)); } else { $eventsByDate = array(); } //================================================================= // Create an array with the day names in the correct order //================================================================= $daynames = array(); $numDays = count($pc_long_day_names); for ($i = 0; $i < $numDays; $i++) { if ($pc_array_pos >= $numDays) { $pc_array_pos = 0; } array_push($daynames, $pc_long_day_names[$pc_array_pos]); $pc_array_pos++; } unset($numDays); $sdaynames = array(); $numDays = count($pc_short_day_names); for ($i = 0; $i < $numDays; $i++) { if ($pc_array_pos >= $numDays) { $pc_array_pos = 0; } array_push($sdaynames, $pc_short_day_names[$pc_array_pos]); $pc_array_pos++; } unset($numDays); //================================================================= // Prepare some values for the template //================================================================= $prev_month = Date_Calc::beginOfPrevMonth(1, $the_month, $the_year, '%Y%m%d'); $next_month = Date_Calc::beginOfNextMonth(1, $the_month, $the_year, '%Y%m%d'); $pc_prev = pnModURL(__POSTCALENDAR__, 'user', 'view', array('tplview' => $template_view, 'viewtype' => 'month', 'Date' => $prev_month, 'pc_username' => $pc_username, 'pc_category' => $category, 'pc_topic' => $topic)); $pc_next = pnModURL(__POSTCALENDAR__, 'user', 'view', array('tplview' => $template_view, 'viewtype' => 'month', 'Date' => $next_month, 'pc_username' => $pc_username, 'pc_category' => $category, 'pc_topic' => $topic)); $prev_day = Date_Calc::prevDay($the_day, $the_month, $the_year, '%Y%m%d'); $next_day = Date_Calc::nextDay($the_day, $the_month, $the_year, '%Y%m%d'); $pc_prev_day = pnModURL(__POSTCALENDAR__, 'user', 'view', array('tplview' => $template_view, 'viewtype' => 'day', 'Date' => $prev_day, 'pc_username' => $pc_username, 'pc_category' => $category, 'pc_topic' => $topic)); $pc_next_day = pnModURL(__POSTCALENDAR__, 'user', 'view', array('tplview' => $template_view, 'viewtype' => 'day', 'Date' => $next_day, 'pc_username' => $pc_username, 'pc_category' => $category, 'pc_topic' => $topic)); $prev_week = date('Ymd', mktime(0, 0, 0, $week_first_day_month, $week_first_day_date - 7, $week_first_day_year)); $next_week = date('Ymd', mktime(0, 0, 0, $week_last_day_month, $week_last_day_date + 1, $week_last_day_year)); $pc_prev_week = pnModURL(__POSTCALENDAR__, 'user', 'view', array('viewtype' => 'week', 'Date' => $prev_week, 'pc_username' => $pc_username, 'pc_category' => $category, 'pc_topic' => $topic)); $pc_next_week = pnModURL(__POSTCALENDAR__, 'user', 'view', array('viewtype' => 'week', 'Date' => $next_week, 'pc_username' => $pc_username, 'pc_category' => $category, 'pc_topic' => $topic)); $prev_year = date('Ymd', mktime(0, 0, 0, 1, 1, $the_year - 1)); $next_year = date('Ymd', mktime(0, 0, 0, 1, 1, $the_year + 1)); $pc_prev_year = pnModURL(__POSTCALENDAR__, 'user', 'view', array('viewtype' => 'year', 'Date' => $prev_year, 'pc_username' => $pc_username, 'pc_category' => $category, 'pc_topic' => $topic)); $pc_next_year = pnModURL(__POSTCALENDAR__, 'user', 'view', array('viewtype' => 'year', 'Date' => $next_year, 'pc_username' => $pc_username, 'pc_category' => $category, 'pc_topic' => $topic)); //================================================================= // Populate the template //================================================================= $all_categories = pnModAPIFunc(__POSTCALENDAR__, 'user', 'getCategories'); if (isset($calendarView)) { $tpl->assign_by_ref('CAL_FORMAT', $calendarView); } if ($viewtype == "week") { $last_blocks = array(); foreach ($eventsByDate as $cdate => $day) { $tblock = array_reverse($day['blocks']); $last_blocks[$cdate] = count($tblock) - 1; for ($i = 0; $i < count($tblock); $i++) { if (!empty($tblock[$i])) { $last_blocks[$cdate] = count($tblock) - $i; break; } } } $tpl->assign("last_blocks", $last_blocks); } $tpl->assign('STYLE', $GLOBALS['style']); $tpl->assign('show_days', $show_days); //$provinfo[count($provinfo) +1] = array("id" => "","lname" => "Other"); $tpl->assign_by_ref('providers', $provinfo); if (pnVarCleanFromInput("show_days") != 1) { $tpl->assign('showdaysurl', "index.php?" . $_SERVER['QUERY_STRING'] . "&show_days=1"); } $tpl->assign('interval', $GLOBALS['calendar_interval']); $tpl->assign_by_ref('VIEW_TYPE', $viewtype); $tpl->assign_by_ref('A_MONTH_NAMES', $pc_month_names); $tpl->assign_by_ref('A_LONG_DAY_NAMES', $pc_long_day_names); $tpl->assign_by_ref('A_SHORT_DAY_NAMES', $pc_short_day_names); $tpl->assign_by_ref('S_LONG_DAY_NAMES', $daynames); $tpl->assign_by_ref('S_SHORT_DAY_NAMES', $sdaynames); $tpl->assign_by_ref('A_EVENTS', $eventsByDate); $tpl->assign_by_ref('A_CATEGORY', $all_categories); $tpl->assign_by_ref('PREV_MONTH_URL', $pc_prev); $tpl->assign_by_ref('NEXT_MONTH_URL', $pc_next); $tpl->assign_by_ref('PREV_DAY_URL', $pc_prev_day); $tpl->assign_by_ref('NEXT_DAY_URL', $pc_next_day); $tpl->assign_by_ref('PREV_WEEK_URL', $pc_prev_week); $tpl->assign_by_ref('NEXT_WEEK_URL', $pc_next_week); $tpl->assign_by_ref('PREV_YEAR_URL', $pc_prev_year); $tpl->assign_by_ref('NEXT_YEAR_URL', $pc_next_year); $tpl->assign_by_ref('WEEK_START_DATE', $week_view_start); $tpl->assign_by_ref('WEEK_END_DATE', $week_view_end); $tpl->assign_by_ref('MONTH_START_DATE', $month_view_start); $tpl->assign_by_ref('MONTH_END_DATE', $month_view_end); $tpl->assign_by_ref('TODAY_DATE', $today_date); $tpl->assign_by_ref('DATE', $Date); $tpl->assign('SCHEDULE_BASE_URL', pnModURL(__POSTCALENDAR__, 'user', 'submit')); $tpl->assign_by_ref('intervals', $intervals); } //================================================================= // Parse the template //================================================================= $template = "{$template_name}/views/{$viewtype}/{$template_view_load}.html"; if (!$print) { $output .= "\n\n<!-- START POSTCALENDAR OUTPUT [-: HTTP://POSTCALENDAR.TV :-] -->\n\n"; $output .= $tpl->fetch($template, $cacheid); // cache id $output .= "\n\n<!-- END POSTCALENDAR OUTPUT [-: HTTP://POSTCALENDAR.TV :-] -->\n\n"; } else { $theme = pnUserGetTheme(); echo "<html><head>"; echo "<LINK REL=\"StyleSheet\" HREF=\"themes/{$theme}/style/styleNN.css\" TYPE=\"text/css\">\n\n\n"; echo "<style type=\"text/css\">\n"; echo "@import url(\"themes/{$theme}/style/style.css\"); "; echo "</style>\n"; echo "</head><body>\n"; echo $output; $tpl->display($template, $cacheid); echo postcalendar_footer(); echo "\n</body></html>"; session_write_close(); exit; } //================================================================= // Return the output //================================================================= return $output; }
/** * get the user's theme * <br /> * This function will return the current theme for the user. * Order of theme priority: * - page-specific * - category * - user * - system * * @public * @return string the name of the user's theme **/ function pnUserGetTheme() { static $theme; if (isset($theme)) { return $theme; } // Page-specific theme $pagetheme = pnVarCleanFromInput('theme'); if (!empty($pagetheme)) { $themeinfo = pnThemeInfo($pagetheme); if ($themeinfo && $themeinfo['active']) { $theme = $pagetheme; return $pagetheme; } } // set a new theme for the user $pagetheme = pnVarCleanFromInput('newtheme'); if (!empty($pagetheme) && !pnConfigGetVar('theme_change')) { $themeinfo = pnThemeInfo($pagetheme); if ($themeinfo && $themeinfo['active']) { if (pnUserLoggedIn()) { $uid = pnUserGetVar('uid'); $dbconn =& pnDBGetConn(true); $pntable =& pnDBGetTables(); $column =& $pntable['users_column']; $sql = "UPDATE {$pntable['users']}\n SET {$column['theme']}='" . pnVarPrepForStore($pagetheme) . "'\n WHERE {$column['uid']}='" . pnVarPrepForStore($uid) . "'"; $dbconn->Execute($sql); } else { pnSessionSetVar('theme', $pagetheme); } $theme = $pagetheme; return $pagetheme; } } // eugenio themeover 20020413 // override the theme per category or story // precedence is story over category override list($sid, $file) = pnVarCleanFromInput('sid', 'file'); if (pnModGetName() == 'News' && (!empty($sid) || strtolower($file) == 'article')) { $modinfo = pnModGetInfo(pnModGetIDFromName('News')); include_once 'modules/' . $modinfo['directory'] . '/funcs.php'; $pntable =& pnDBGetTables(); $results = getArticles("{$pntable['stories_column']['sid']}='" . (int) pnVarPrepForStore($sid) . "'", "", ""); if (is_array($results) && count($results) > 0) { $info = genArticleInfo($results[0]); $themeinfo = pnThemeInfo($info['catthemeoverride']); if ($themeinfo && $themeinfo['active']) { $theme = $info['catthemeoverride']; return $theme; } $themeinfo = pnThemeInfo($info['themeoverride']); if ($themeinfo && $themeinfo['active']) { $theme = $info['themeoverride']; return $theme; } } } // User theme if (!pnConfigGetVar('theme_change')) { if (pnUserLoggedIn()) { $usertheme = pnUserGetVar('theme'); } else { $usertheme = pnSessionGetVar('theme'); } $themeinfo = pnThemeInfo($usertheme); if ($themeinfo && $themeinfo['active']) { $theme = $usertheme; return $usertheme; } } // default site theme $defaulttheme = pnConfigGetVar('Default_Theme'); $themeinfo = pnThemeInfo($defaulttheme); if ($themeinfo && $themeinfo['active']) { $theme = $defaulttheme; return $theme; } return false; }
/** * Upgrades an old install of PostCalendar * * This function is used to upgrade an old version * of PostCalendar. It is accessed via the PostNuke * Admin interface and should not be called directly. * * @return boolean true/false * @param string $oldversion Version we're upgrading * @access public * @author Roger Raymond <*****@*****.**> * @copyright The PostCalendar Team 2002 */ function postcalendar_upgrade($oldversion) { /** * Until PostNuke fixes the bugs * with the module upgrade we are * going to have to do it ourselves. * * Please do not use the Modules admin * to upgrade PostCalendar. Use the * link provided in the PostCalendar * Admin section. */ $pcModInfo = pnModGetInfo(pnModGetIDFromName(__POSTCALENDAR__)); $pcDir = pnVarPrepForOS($pcModInfo['directory']); list($dbconn) = pnDBGetConn(); $pntable = pnDBGetTables(); $events_table = $pntable['postcalendar_events']; $cat_table = $pntable['postcalendar_categories']; switch ($oldversion) { case '3.0': case '3.01': case '3.02': case '3.03': case '3.04': // we need the Date_Calc class require_once "modules/{$pcDir}/pnincludes/Date/Calc.php"; // Update PostCalendar Variables pnModSetVar(__POSTCALENDAR__, 'pcTime24Hours', pnModGetVar(__POSTCALENDAR__, 'time24hours')); pnModSetVar(__POSTCALENDAR__, 'pcEventsOpenInNewWindow', pnModGetVar(__POSTCALENDAR__, 'eventsopeninnewwindow')); pnModSetVar(__POSTCALENDAR__, 'pcUseInternationalDates', pnModGetVar(__POSTCALENDAR__, 'useinternationaldates')); pnModSetVar(__POSTCALENDAR__, 'pcFirstDayOfWeek', pnModGetVar(__POSTCALENDAR__, 'firstdayofweek')); pnModSetVar(__POSTCALENDAR__, 'pcDayHighlightColor', pnModGetVar(__POSTCALENDAR__, 'dayhighlightcolor')); pnModSetVar(__POSTCALENDAR__, 'pcUsePopups', pnModGetVar(__POSTCALENDAR__, 'usepopups')); pnModSetVar(__POSTCALENDAR__, 'pcDisplayTopics', pnModGetVar(__POSTCALENDAR__, 'displaytopics')); pnModSetVar(__POSTCALENDAR__, 'pcAllowDirectSubmit', '0'); pnModSetVar(__POSTCALENDAR__, 'pcListHowManyEvents', pnModGetVar(__POSTCALENDAR__, 'listhowmanyevents')); pnModSetVar(__POSTCALENDAR__, 'pcTimeIncrement', '15'); pnModSetVar(__POSTCALENDAR__, 'pcAllowSiteWide', '0'); pnModSetVar(__POSTCALENDAR__, 'pcAllowUserCalendar', '1'); pnModSetVar(__POSTCALENDAR__, 'pcEventDateFormat', '%Y-%m-%d'); pnModSetVar(__POSTCALENDAR__, 'pcTemplate', 'default'); pnModSetVar(__POSTCALENDAR__, 'pcUseCache', '1'); pnModSetVar(__POSTCALENDAR__, 'pcCacheLifetime', '3600'); pnModSetVar(__POSTCALENDAR__, 'pcDefaultView', 'month'); pnModSetVar(__POSTCALENDAR__, 'pcSafeMode', '0'); // alter the events table and change some old columns $sql = "ALTER TABLE {$events_table}\n ADD pc_catid int(11) default '0' NOT NULL,\n\t\t\t\t\tADD pc_duration bigint(20) default '0' NOT NULL,\n ADD pc_sharing int(11) default '0' NOT NULL,\n ADD pc_language varchar(30) default '',\n\t\t\t\t\tCHANGE pc_eid pc_eid int(11) unsigned NOT NULL auto_increment,\n CHANGE pc_location pc_location text,\n CHANGE pc_conttel pc_conttel varchar(50),\n CHANGE pc_contname pc_contname varchar(150),\n CHANGE pc_contemail pc_contemail varchar(255),\n CHANGE pc_website pc_website varchar(255),\n CHANGE pc_fee pc_fee varchar(50),\n CHANGE pc_recurrspec pc_recurrspec text default ''\n "; $dbconn->Execute($sql); if ($dbconn->ErrorNo() != 0) { die('event table alter error : ' . $dbconn->ErrorMsg()); return false; } // create the new categories table $sql = "CREATE TABLE {$cat_table} (\n pc_catid int(11) unsigned NOT NULL auto_increment,\n pc_catname varchar(100) NOT NULL default 'Undefined',\n pc_catcolor varchar(50) NOT NULL default '#EEEEEE',\n pc_catdesc text default '',\n PRIMARY KEY(pc_catid)\n )"; $dbconn->Execute($sql); if ($dbconn->ErrorNo() != 0) { die('cat table create error : ' . $dbconn->ErrorMsg()); return false; } // insert the current hardcoded categories into the new categories table $category1 = pnVarPrepForStore(pnModGetVar(__POSTCALENDAR__, 'category1')); $category2 = pnVarPrepForStore(pnModGetVar(__POSTCALENDAR__, 'category2')); $category3 = pnVarPrepForStore(pnModGetVar(__POSTCALENDAR__, 'category3')); $category4 = pnVarPrepForStore(pnModGetVar(__POSTCALENDAR__, 'category4')); $category5 = pnVarPrepForStore(pnModGetVar(__POSTCALENDAR__, 'category5')); $inserts = array("INSERT INTO {$cat_table} (pc_catid,pc_catname,pc_catcolor) VALUES ('1','{$category1}','#EEEEEE')", "INSERT INTO {$cat_table} (pc_catid,pc_catname,pc_catcolor) VALUES ('2','{$category2}','#00ff00')", "INSERT INTO {$cat_table} (pc_catid,pc_catname,pc_catcolor) VALUES ('3','{$category3}','#0000ff')", "INSERT INTO {$cat_table} (pc_catid,pc_catname,pc_catcolor) VALUES ('4','{$category4}','#ffffff')", "INSERT INTO {$cat_table} (pc_catid,pc_catname,pc_catcolor) VALUES ('5','{$category5}','#ffcc00')"); foreach ($inserts as $insert) { $dbconn->Execute($insert); if ($dbconn->ErrorNo() != 0) { die('cat table insert error : ' . $dbconn->ErrorMsg()); return false; } } // update the current events to reflect the category system change $updates = array("UPDATE {$events_table} SET pc_catid = 1 WHERE pc_barcolor = 'r' ", "UPDATE {$events_table} SET pc_catid = 2 WHERE pc_barcolor = 'g' ", "UPDATE {$events_table} SET pc_catid = 3 WHERE pc_barcolor = 'b' ", "UPDATE {$events_table} SET pc_catid = 4 WHERE pc_barcolor = 'w' ", "UPDATE {$events_table} SET pc_catid = 5 WHERE pc_barcolor = 'y' "); foreach ($updates as $update) { $dbconn->Execute($update); if ($dbconn->ErrorNo() != 0) { die('event table update error : ' . $dbconn->ErrorMsg()); return false; } } // alter the events table and drop the old barcolor column $sql = "ALTER TABLE {$events_table} DROP pc_barcolor"; $dbconn->Execute($sql); if ($dbconn->ErrorNo() != 0) { die('cat table alter error : ' . $dbconn->ErrorMsg()); return false; } // remove the old vars as they are no longer needed pnModDelVar(__POSTCALENDAR__, 'category1'); pnModDelVar(__POSTCALENDAR__, 'category2'); pnModDelVar(__POSTCALENDAR__, 'category3'); pnModDelVar(__POSTCALENDAR__, 'category4'); pnModDelVar(__POSTCALENDAR__, 'category5'); pnModDelVar(__POSTCALENDAR__, 'time24hours'); pnModDelVar(__POSTCALENDAR__, 'eventsopeninnewwindow'); pnModDelVar(__POSTCALENDAR__, 'useinternationaldates'); pnModDelVar(__POSTCALENDAR__, 'firstdayofweek'); pnModDelVar(__POSTCALENDAR__, 'dayhighlightcolor'); pnModDelVar(__POSTCALENDAR__, 'displaytopics'); pnModDelVar(__POSTCALENDAR__, 'usepopups'); pnModDelVar(__POSTCALENDAR__, 'listhowmanyevents'); pnModDelVar(__POSTCALENDAR__, 'allowdirectsubmit'); pnModDelVar(__POSTCALENDAR__, 'showeventsinyear'); //====================================================== // now, ideally, we will convert old events to the new // style. this consists of reconfiguring the repeating // events vars. // // we need to establish the current repeating // conditions and convert them to the new system //====================================================== // old repeating defines //====================================================== @define('_EVENT_NONE', -1); @define('_EVENT_DAILY', 0); @define('_EVENT_WEEKLY', 1); @define('_EVENT_MONTHLY', 2); @define('_EVENT_YEARLY', 3); @define('_RECUR_SAME_DAY', 0); @define('_RECUR_SAME_DATE', 1); //====================================================== // new repeating defines // $recurrspec['event_repeat'] //====================================================== @define('NO_REPEAT', 0); @define('REPEAT', 1); @define('REPEAT_ON', 2); //====================================================== // $recurrspec['event_repeat_freq'] //====================================================== @define('REPEAT_EVERY', 1); @define('REPEAT_EVERY_OTHER', 2); @define('REPEAT_EVERY_THIRD', 3); @define('REPEAT_EVERY_FOURTH', 4); //====================================================== // $recurrspec['event_repeat_freq_type'] //====================================================== @define('REPEAT_EVERY_DAY', 0); @define('REPEAT_EVERY_WEEK', 1); @define('REPEAT_EVERY_MONTH', 2); @define('REPEAT_EVERY_YEAR', 3); //====================================================== // $recurrspec['event_repeat_on_num'] //====================================================== @define('REPEAT_ON_1ST', 1); @define('REPEAT_ON_2ND', 2); @define('REPEAT_ON_3RD', 3); @define('REPEAT_ON_4TH', 4); @define('REPEAT_ON_LAST', 5); //====================================================== // $recurrspec['event_repeat_on_day'] //====================================================== @define('REPEAT_ON_SUN', 0); @define('REPEAT_ON_MON', 1); @define('REPEAT_ON_TUE', 2); @define('REPEAT_ON_WED', 3); @define('REPEAT_ON_THU', 4); @define('REPEAT_ON_FRI', 5); @define('REPEAT_ON_SAT', 6); //====================================================== // $recurrspec['event_repeat_on_freq'] //====================================================== @define('REPEAT_ON_MONTH', 1); @define('REPEAT_ON_2MONTH', 2); @define('REPEAT_ON_3MONTH', 3); @define('REPEAT_ON_4MONTH', 4); @define('REPEAT_ON_6MONTH', 6); @define('REPEAT_ON_YEAR', 12); //====================================================== // Set Sharing Paramaters //====================================================== @define('SHARING_PRIVATE', 0); @define('SHARING_PUBLIC', 1); @define('SHARING_BUSY', 2); @define('SHARING_GLOBAL', 3); //====================================================== // Here's some psuedo-code for the conversion // // if _EVENT_NONE // $rtype = NO_REPEAT // $rspec = 0 for all; // $duration = endTime - startTime // // if _EVENT_DAILY // $rtype = REPEAT // $rspec = REPEAT_EVERY|REPEAT_EVERY_DAY // $duration = endTime - startTime // // if _EVENT_WEEKLY // $rtype = REPEAT // $rspec = REPEAT_EVERY|REPEAT_EVERY_WEEK // $duration = endTime - startTime // // if _EVENT_MONTHLY // if _RECUR_SAME_DAY // $rtype = REPEAT_ON // $rspec = REPEAT_ON_NUM|REPEAT_ON_DAY|REPEAT_ON_FREQ // if _RECUR_SAME_DATE // $rtype = REPEAT // $rspec = REPEAT_EVERY|REPEAT_EVERY_MONTH // $duration = endTime - startTime // // if _EVENT_YEARLY // if _RECUR_SAME_DAY // $rtype = REPEAT_ON // $rspec = REPEAT_ON_NUM|REPEAT_ON_DAY|REPEAT_ON_FREQ // if _RECUR_SAME_DATE // $rtype = REPEAT // $rspec = REPEAT_EVERY|REPEAT_EVERY_YEAR // $duration = endTime - startTime //====================================================== // attempt reconfiguration //====================================================== $sql = "SELECT pc_eid, pc_eventDate, pc_startTime, pc_endTime, pc_recurrtype, pc_recurrfreq\n FROM {$events_table}"; $result = $dbconn->Execute($sql); if ($dbconn->ErrorNo() != 0) { die($dbconn->ErrorMsg()); return false; } if (!isset($result)) { return false; } // grab the results and start the conversion for (; !$result->EOF; $result->MoveNext()) { $recurrspec = array(); list($eid, $eventdate, $start, $end, $rtype, $rfreq) = $result->fields; if ($rtype == null) { $rtype = _EVENT_NONE; } switch ($rtype) { case _EVENT_NONE: $recurrtype = NO_REPEAT; $recurrspec['event_repeat_freq'] = 0; $recurrspec['event_repeat_freq_type'] = 0; $recurrspec['event_repeat_on_num'] = 0; $recurrspec['event_repeat_on_day'] = 0; $recurrspec['event_repeat_on_freq'] = 0; break; case _EVENT_DAILY: $recurrtype = REPEAT; $recurrspec['event_repeat_freq'] = REPEAT_EVERY; $recurrspec['event_repeat_freq_type'] = REPEAT_EVERY_DAY; $recurrspec['event_repeat_on_num'] = 0; $recurrspec['event_repeat_on_day'] = 0; $recurrspec['event_repeat_on_freq'] = 0; break; case _EVENT_WEEKLY: $recurrtype = REPEAT; $recurrspec['event_repeat_freq'] = REPEAT_EVERY; $recurrspec['event_repeat_freq_type'] = REPEAT_EVERY_WEEK; $recurrspec['event_repeat_on_num'] = 0; $recurrspec['event_repeat_on_day'] = 0; $recurrspec['event_repeat_on_freq'] = 0; break; case _EVENT_MONTHLY: if ($rfreq == _RECUR_SAME_DATE) { $recurrtype = REPEAT; $recurrspec['event_repeat_freq'] = REPEAT_EVERY; $recurrspec['event_repeat_freq_type'] = REPEAT_EVERY_MONTH; $recurrspec['event_repeat_on_num'] = 0; $recurrspec['event_repeat_on_day'] = 0; $recurrspec['event_repeat_on_freq'] = 0; } elseif ($rfreq == _RECUR_SAME_DAY) { $recurrtype = REPEAT_ON; list($y, $m, $d) = explode('-', $eventdate); $recurrspec['event_repeat_freq'] = 0; $recurrspec['event_repeat_freq_type'] = 0; // event day of week $edow = Date_Calc::dayOfWeek($d, $m, $y); // date of first event day of week $firstDay = Date_Calc::NWeekdayOfMonth(1, $edow, $m, $y, '%Y-%m-%d'); // find difference between 1st day and event day list($y2, $m2, $d2) = explode('-', $firstDay); $diff = Date_Calc::dateDiff($d, $m, $y, $d2, $m2, $y2); // assuming $diff is going to be a multiple of 7 if ($diff > 0) { $diff /= 7; } if ($diff > REPEAT_ON_4TH) { $diff = REPEAT_ON_LAST; } $recurrspec['event_repeat_on_num'] = $diff; $recurrspec['event_repeat_on_day'] = $edow; $recurrspec['event_repeat_on_freq'] = REPEAT_ON_MONTH; } break; case _EVENT_YEARLY: if ($rfreq == _RECUR_SAME_DATE) { $recurrtype = REPEAT; $recurrspec['event_repeat_freq'] = REPEAT_EVERY; $recurrspec['event_repeat_freq_type'] = REPEAT_EVERY_YEAR; $recurrspec['event_repeat_on_num'] = 0; $recurrspec['event_repeat_on_day'] = 0; $recurrspec['event_repeat_on_freq'] = 0; } elseif ($rfreq == _RECUR_SAME_DAY) { $recurrtype = REPEAT_ON; list($y, $m, $d) = explode('-', $eventdate); $recurrspec['event_repeat_freq'] = 0; $recurrspec['event_repeat_freq_type'] = 0; // event day of week $edow = Date_Calc::dayOfWeek($d, $m, $y); // date of first event day of week $firstDay = Date_Calc::NWeekdayOfMonth(1, $edow, $m, $y, '%Y-%m-%d'); // find difference between 1st day and event day list($y2, $m2, $d2) = explode('-', $firstDay); $diff = Date_Calc::dateDiff($d, $m, $y, $d2, $m2, $y2); // assuming $diff is going to be a multiple of 7 if ($diff > 0) { $diff /= 7; } if ($diff > REPEAT_ON_4TH) { $diff = REPEAT_ON_LAST; } $recurrspec['event_repeat_on_num'] = $diff; $recurrspec['event_repeat_on_day'] = $edow; $recurrspec['event_repeat_on_freq'] = REPEAT_ON_YEAR; } break; } // ok, figure out the event's duration list($sh, $sm, $ss) = explode(':', $start); list($eh, $em, $es) = explode(':', $end); $stime = mktime($sh, $sm, $ss, 1, 1, 1970); // if the ending hour is less than the starting hour // assume that the event spans to the next day if ($eh < $sh) { $etime = mktime($eh, $em, $es, 1, 2, 1970); } else { $etime = mktime($eh, $em, $es, 1, 1, 1970); } $duration = $etime - $stime; // prep the vars for the sql statement $eid = pnVarPrepForStore($eid); $recurrtype = pnVarPrepForStore($recurrtype); $recurrspec = pnVarPrepForStore(serialize($recurrspec)); // create our sql statement $updatesql = "UPDATE {$events_table} SET \n pc_aid = '0',\n\t\t\t\t\t\t\t pc_recurrtype = {$recurrtype},\n pc_recurrspec = '{$recurrspec}',\n pc_duration = {$duration},\n\t\t\t\t\t\t\t pc_sharing = " . SHARING_GLOBAL . "\n WHERE pc_eid = {$eid}"; // execute our sql statement $dbconn->Execute($updatesql); if ($dbconn->ErrorNo() != 0) { die($dbconn->ErrorMsg()); return false; } // next event please } // all done, proceed with next upgrade step if available/necessary return postcalendar_upgrade('3.1'); break; case '3.1': case '3.1.1': case '3.1.2': case '3.1.3': case '3.1.4': return postcalendar_upgrade('3.9.0'); break; case '3.9.0': case '3.9.1': case '3.9.2': // ading pcSafeMode pnModSetVar(__POSTCALENDAR__, 'pcSafeMode', '0'); return postcalendar_upgrade('3.9.3'); break; case '3.9.3': case '3.9.3.1': // adding indexes $sql = "ALTER TABLE {$events_table} \n\t\t\t\t\tADD INDEX basic_event (pc_catid,pc_aid,pc_eventDate,pc_endDate,pc_eventstatus,pc_sharing,pc_topic)"; $dbconn->Execute($sql); if ($dbconn->ErrorNo() != 0) { die($dbconn->ErrorMsg()); return false; } // adding indexes $sql = "ALTER TABLE {$cat_table} \n\t\t\t\t\tADD INDEX basic_cat (pc_catname, pc_catcolor)"; $dbconn->Execute($sql); if ($dbconn->ErrorNo() != 0) { die($dbconn->ErrorMsg()); return false; } return postcalendar_upgrade('3.9.4'); break; case '3.9.4': case '3.9.5': case '3.9.6': case '3.9.7': return postcalendar_upgrade('3.9.8'); break; case '3.9.8': pnModDelVar(__POSTCALENDAR__, 'pcSafeMode'); pnModSetVar(__POSTCALENDAR__, 'pcNotifyAdmin', '0'); pnModSetVar(__POSTCALENDAR__, 'pcNotifyEmail', pnConfigGetVar('adminmail')); break; case '3.9.9': break; } // if we get this far - load the userapi and clear the cache if (!pnModAPILoad(__POSTCALENDAR__, 'user')) { return false; } $tpl =& new pcSmarty(); $tpl->clear_all_cache(); $tpl->clear_compiled_tpl(); return true; }