Example #1
0
/**
 * view items
 * This is a standard function to provide an overview of all of the items
 * available from the module.
 */
function postcalendar_user_view()
{
    if (!pnSecAuthAction(0, 'PostCalendar::', '::', ACCESS_OVERVIEW)) {
        return _POSTCALENDARNOAUTH;
    }
    // get the vars that were passed in
    list($Date, $print, $viewtype, $jumpday, $jumpmonth, $jumpyear) = pnVarCleanFromInput('Date', 'print', 'viewtype', 'jumpday', 'jumpmonth', 'jumpyear');
    $Date =& postcalendar_getDate();
    if (!isset($viewtype)) {
        $viewtype = _SETTING_DEFAULT_VIEW;
    }
    // added to allow the view & providers to remain as the user last saw it -- JRM
    if ($_SESSION['viewtype']) {
        $viewtype = $_SESSION['viewtype'];
    }
    if ($_SESSION['pc_username']) {
        $pc_username = $_SESSION['pc_username'];
    }
    return postcalendar_user_display(array('viewtype' => $viewtype, 'Date' => $Date, 'print' => $print)) . postcalendar_footer();
}
Example #2
0
function postcalendar_userapi_eventDetail($args, $admin = false)
{
    if (!(bool) PC_ACCESS_READ) {
        return _POSTCALENDARNOAUTH;
    }
    // get the theme globals :: is there a better way to do this?
    pnThemeLoad(pnUserGetTheme());
    global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5;
    global $textcolor1, $textcolor2;
    $popup = pnVarCleanFromInput('popup');
    extract($args);
    unset($args);
    if (!isset($cacheid)) {
        $cacheid = null;
    }
    if (!isset($eid)) {
        return false;
    }
    if (!isset($nopop)) {
        $nopop = false;
    }
    $uid = pnUserGetVar('uid');
    //=================================================================
    //  Find out what Template we're using
    //=================================================================
    $template_name = _SETTING_TEMPLATE;
    if (!isset($template_name)) {
        $template_name = 'default';
    }
    //=================================================================
    //  Setup Smarty Template Engine
    //=================================================================
    $tpl = new pcSmarty();
    if ($admin) {
        $template = $template_name . '/admin/details.html';
        $args['cacheid'] = '';
        $print = 0;
        $Date =& postcalendar_getDate();
        $tpl->caching = false;
    } else {
        $template = $template_name . '/user/details.html';
    }
    if (!$tpl->is_cached($template, $cacheid)) {
        // let's get the DB information
        list($dbconn) = pnDBGetConn();
        $pntable = pnDBGetTables();
        // get the event's information
        $event =& postcalendar_userapi_pcGetEventDetails($eid);
        // if the above is false, it's a private event for another user
        // we should not diplay this - so we just exit gracefully
        if ($event === false) {
            return false;
        }
        //=================================================================
        //  get event's topic information
        //=================================================================
        $topics_table = $pntable['topics'];
        $topics_column = $pntable['topics_column'];
        $topicsql = "SELECT {$topics_column['topictext']},{$topics_column['topicimage']}\n                     FROM {$topics_table}\n                     WHERE {$topics_column['topicid']} = {$event['topic']}\n                     LIMIT 1";
        $topic_result = $dbconn->Execute($topicsql);
        list($event['topictext'], $event['topicimg']) = $topic_result->fields;
        $location = unserialize($event['location']);
        $event['location'] = $location['event_location'];
        $event['street1'] = $location['event_street1'];
        $event['street2'] = $location['event_street2'];
        $event['city'] = $location['event_city'];
        $event['state'] = $location['event_state'];
        $event['postal'] = $location['event_postal'];
        $event['date'] = str_replace('-', '', $Date);
        //=================================================================
        //  populate the template
        //=================================================================
        if (!empty($event['location']) || !empty($event['street1']) || !empty($event['street2']) || !empty($event['city']) || !empty($event['state']) || !empty($event['postal'])) {
            $tpl->assign('LOCATION_INFO', true);
        } else {
            $tpl->assign('LOCATION_INFO', false);
        }
        if (!empty($event['contname']) || !empty($event['contemail']) || !empty($event['conttel']) || !empty($event['website'])) {
            $tpl->assign('CONTACT_INFO', true);
        } else {
            $tpl->assign('CONTACT_INFO', false);
        }
        $display_type = substr($event['hometext'], 0, 6);
        if ($display_type == ':text:') {
            $prepFunction = 'pcVarPrepForDisplay';
            $event['hometext'] = substr($event['hometext'], 6);
        } elseif ($display_type == ':html:') {
            $prepFunction = 'pcVarPrepHTMLDisplay';
            $event['hometext'] = substr($event['hometext'], 6);
        } else {
            $prepFunction = 'pcVarPrepHTMLDisplay';
        }
        unset($display_type);
        // prep the vars for output
        $event['title'] =& $prepFunction($event['title']);
        $event['hometext'] =& $prepFunction($event['hometext']);
        $event['desc'] =& $event['hometext'];
        $event['conttel'] =& $prepFunction($event['conttel']);
        $event['contname'] =& $prepFunction($event['contname']);
        $event['contemail'] =& $prepFunction($event['contemail']);
        $event['website'] =& $prepFunction(postcalendar_makeValidURL($event['website']));
        $event['fee'] =& $prepFunction($event['fee']);
        $event['location'] =& $prepFunction($event['location']);
        $event['street1'] =& $prepFunction($event['street1']);
        $event['street2'] =& $prepFunction($event['street2']);
        $event['city'] =& $prepFunction($event['city']);
        $event['state'] =& $prepFunction($event['state']);
        $event['postal'] =& $prepFunction($event['postal']);
        $tpl->assign_by_ref('A_EVENT', $event);
        //=================================================================
        //  populate the template $ADMIN_OPTIONS
        //=================================================================
        $target = '';
        if (_SETTING_OPEN_NEW_WINDOW) {
            $target = 'target="csCalendar"';
        }
        $admin_edit_url = $admin_delete_url = '';
        if (pnSecAuthAction(0, 'PostCalendar::', '::', ACCESS_ADMIN)) {
            $admin_edit_url = pnModURL(__POSTCALENDAR__, 'admin', 'submit', array('pc_event_id' => $eid));
            $admin_delete_url = pnModURL(__POSTCALENDAR__, 'admin', 'adminevents', array('action' => _ACTION_DELETE, 'pc_event_id' => $eid));
        }
        $user_edit_url = $user_delete_url = '';
        if (pnUserLoggedIn()) {
            $logged_in_uname = $_SESSION['authUser'];
        } else {
            $logged_in_uname = '';
        }
        $can_edit = false;
        if (pnSecAuthAction(0, 'PostCalendar::', '::', ACCESS_ADD) && validateGroupStatus($logged_in_uname, getUsername($event['uname']))) {
            $user_edit_url = pnModURL(__POSTCALENDAR__, 'user', 'submit', array('pc_event_id' => $eid));
            $user_delete_url = pnModURL(__POSTCALENDAR__, 'user', 'delete', array('pc_event_id' => $eid));
            $can_edit = true;
        }
        $tpl->assign('STYLE', $GLOBALS['style']);
        $tpl->assign_by_ref('ADMIN_TARGET', $target);
        $tpl->assign_by_ref('ADMIN_EDIT', $admin_edit_url);
        $tpl->assign_by_ref('ADMIN_DELETE', $admin_delete_url);
        $tpl->assign_by_ref('USER_TARGET', $target);
        $tpl->assign_by_ref('USER_EDIT', $user_edit_url);
        $tpl->assign_by_ref('USER_DELETE', $user_delete_url);
        $tpl->assign_by_ref('USER_CAN_EDIT', $can_edit);
    }
    //=================================================================
    //  Parse the template
    //=================================================================
    if ($popup != 1 && $print != 1) {
        $output = "\n\n<!-- START POSTCALENDAR OUTPUT [-: HTTP://POSTCALENDAR.TV :-] -->\n\n";
        $output .= $tpl->fetch($template, $cacheid);
        $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";
        $tpl->display($template, $cacheid);
        echo postcalendar_footer();
        echo "\n</body></html>";
        session_write_close();
        exit;
    }
    return $output;
}
Example #3
0
$uid = pnUserGetVar('uid');
$pc_username = pnVarCleanFromInput('pc_username');
$output =& new pnHTML();
$output->SetInputMode(_PNH_VERBATIMINPUT);
if (!pnModAPILoad('postcalendar', 'user')) {
    die('Could not load PostCalendar user API');
}
$theme = pnUserGetTheme();
if (!pnThemeLoad($theme)) {
    die('Could not load theme');
}
$output->Text('<html><head>');
$output->Text("<title>" . pnConfigGetVar('sitename') . ' :: ' . pnConfigGetVar('slogan') . "</title>\n");
$output->Text('<link rel="StyleSheet" href="themes/' . $theme . '/style/styleNN.css" type="text/css" />');
$output->Text('<style type="text/css">@import url("themes/' . $theme . '/style/style.css"); </style>');
$output->Text('</head>');
$output->Text('<body bgcolor="#ffffff">');
// setup our cache id
$cacheid = md5($Date . $viewtype . $tplview . _SETTING_TEMPLATE . $eid . $print . $uid . $pc_username . $theme);
// display the correct view
switch ($viewtype) {
    case 'details':
        $output->Text(pnModAPIFunc('PostCalendar', 'user', 'eventDetail', array('eid' => $eid, 'Date' => $Date, 'print' => $print, 'cacheid' => $cacheid)));
        break;
    default:
        $output->Text(pnModAPIFunc('postcalendar', 'user', 'buildView', array('Date' => $Date, 'viewtype' => $viewtype, 'cacheid' => $cacheid)));
        break;
}
$output->Text(postcalendar_footer());
$output->Text('</body></html>');
$output->PrintPage();
Example #4
0
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();
}
Example #5
0
/**
 *  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;
}