Пример #1
0
function display_calendar($main_template, $nb_days = 0, $start = 0, $fid = '')
{
    global $db, $cache, $config, $user, $template, $images, $lang, $bbcode, $tree;
    static $handler;
    if (empty($handler)) {
        $handler = 1;
    } else {
        $handler++;
    }
    $day_of_week = array($lang['datetime']['Sunday'], $lang['datetime']['Monday'], $lang['datetime']['Tuesday'], $lang['datetime']['Wednesday'], $lang['datetime']['Thursday'], $lang['datetime']['Friday'], $lang['datetime']['Saturday']);
    $months = array(' ------------ ', $lang['datetime']['January'], $lang['datetime']['February'], $lang['datetime']['March'], $lang['datetime']['April'], $lang['datetime']['May'], $lang['datetime']['June'], $lang['datetime']['July'], $lang['datetime']['August'], $lang['datetime']['September'], $lang['datetime']['October'], $lang['datetime']['November'], $lang['datetime']['December']);
    // get some parameter
    $first_day_of_week = isset($config['calendar_week_start']) ? intval($config['calendar_week_start']) : 1;
    $nb_row_per_cell = isset($config['calendar_nb_row']) ? intval($config['calendar_nb_row']) : 5;
    // get the start date - calendar doesn't go before 1971
    $cur_date = empty($start) || intval(gmdate('Y', $start)) < 1971 ? cal_date(time(), $config['board_timezone']) : $start;
    $cur_date = gmmktime(0, 0, 0, intval(gmdate('m', $cur_date)), intval(gmdate('d', $cur_date)), intval(gmdate('Y', $cur_date)));
    $cur_month = 0;
    $cur_day = 0;
    // the full month is displayed
    if (empty($nb_days)) {
        // set indicator
        $full_month = true;
        // set the start day on the start of the month
        $start_date = gmmktime(0, 0, 0, intval(gmdate('m', $cur_date)), 01, intval(gmdate('Y', $cur_date)));
        // get the day number set as start of the display
        $cfg_week_day_start = $first_day_of_week;
        // get the number of blank cells
        $start_inc = intval(gmdate('w', $start_date)) - $cfg_week_day_start;
        if ($start_inc < 0) {
            $start_inc = 7 + $start_inc;
        }
        // Used to adjust birthdays SQL
        $cur_month = intval(gmdate('n', $cur_date));
        // get the end date
        $year = intval(gmdate('Y', $start_date));
        $month = intval(gmdate('m', $start_date)) + 1;
        if ($month > 12) {
            $year++;
            $month = 1;
        }
        $end_date = gmmktime(0, 0, 0, $month, 01, $year);
        // set the number of cells per line
        $nb_cells = 7;
        // get the number of rows
        $nb_rows = intval(($start_inc + intval(($end_date - $start_date) / 86400)) / $nb_cells) + 1;
    } else {
        // set indicator
        $full_month = false;
        // set the start date to the day before the date selected
        $start_date = gmmktime(0, 0, 0, gmdate('m', $cur_date), gmdate('d', $cur_date) - 1, gmdate('Y', $cur_date));
        // get the day number set as start of the week
        $cfg_week_day_start = intval(gmdate('w', $start_date));
        // get the numbe of blank cells
        $start_inc = 0;
        // get the end date
        $end_date = gmmktime(0, 0, 0, gmdate('m', $start_date), gmdate('d', $start_date) + $nb_days, gmdate('Y', $start_date));
        // set the number of cells per line
        $nb_cells = $nb_days;
        // set the number of rows
        $nb_rows = 1;
    }
    // Ok, let's get the various events :)
    $events = array();
    $number = 0;
    // topics
    get_event_topics($events, $number, $start_date, $end_date, false, 0, -1, $fid);
    $pages_array = array('calendar.' . PHP_EXT, CMS_PAGE_FORUM, CMS_PAGE_VIEWFORUM);
    //$current_page = $_SERVER['SCRIPT_NAME'];
    $current_page = basename($_SERVER['SCRIPT_NAME']);
    // No limits in calendar
    $day_end = 0;
    $birthdays_limit = 0;
    if ($current_page != 'calendar.' . PHP_EXT) {
        // Limit total birthdays in forum and viewforum... in large could take forever!
        $birthdays_limit = 50;
        // We are not in calendar, so we can force date to today!!!
        $cur_time = time() + 3600 * $config['board_timezone'];
        $cur_month = intval(gmdate('n', $cur_time));
        $cur_day = intval(gmdate('j', $cur_time));
        // Force one week walk forward...
        $days_walk_forward = 7;
        $day_end = intval(gmdate('j', $cur_time + $days_walk_forward * 86400));
    }
    if ($config['calendar_birthday'] == true && in_array(strtolower($current_page), $pages_array)) {
        // get_birthdays(&$events, &$number, $start_date, $end_date, $year = 0, $year_lt = false, $month = 0, $day = 0, $day_end = 0, $limit = 0, $show_inactive = false)
        get_birthdays($events, $number, $start_date, $end_date, 0, false, $cur_month, $cur_day, $day_end, $birthdays_limit, false);
    }
    /*
    for ($i = 0; $i < sizeof($pages_array); $i++)
    {
    	if (strpos(strtolower($current_page), strtolower($pages_array[$i])) !== false)
    	{
    		get_birthdays($events, $number, $start_date, $end_date);
    	}
    }
    */
    // And now display them
    // build a list per date
    $map = array();
    for ($i = 0; $i < sizeof($events); $i++) {
        $event_time = $events[$i]['event_calendar_time'];
        // adjust the event period to the start of day
        $event_time_end = $event_time + $events[$i]['event_calendar_duration'];
        $event_end = gmmktime(0, 0, 0, intval(gmdate('m', $event_time_end)), intval(gmdate('d', $event_time_end)), intval(gmdate('Y', $event_time_end)));
        $event_start = gmmktime(0, 0, 0, intval(gmdate('m', $event_time)), intval(gmdate('d', $event_time)), intval(gmdate('Y', $event_time)));
        if ($event_start < $start_date) {
            $event_start = $start_date;
        }
        if ($event_end > $end_date) {
            $event_end = $end_date;
        }
        // search a free day map offset in the start day
        $event_id = $events[$i]['event_id'];
        $offset_date = $event_start;
        $map_offset = sizeof($map[$event_start]);
        $found = false;
        for ($k = 0; $k < sizeof($map[$event_start]) && !$found; $k++) {
            if ($map[$event_start][$k] == -1) {
                $found = true;
                $map_offset = $k;
            }
        }
        // mark the offset as used for the whole event period
        $offset_date = $event_start;
        while ($offset_date <= $event_end) {
            for ($l = sizeof($map[$offset_date]); $l <= $map_offset; $l++) {
                $map[$offset_date][$l] = -1;
            }
            $map[$offset_date][$map_offset] = $i;
            $offset_date = gmmktime(0, 0, 0, gmdate('m', $offset_date), gmdate('d', $offset_date) + 1, gmdate('Y', $offset_date));
        }
    }
    // template
    $template->set_filenames(array('_calendar_body' . $handler => 'calendar_box.tpl'));
    // buid select list for month
    $month = intval(gmdate('m', $start_date));
    $s_month = '<select name="start_month" onchange="forms[\'f_calendar\'].submit();">';
    for ($i = 1; $i < sizeof($months); $i++) {
        $selected = $month == $i ? ' selected="selected"' : '';
        $s_month .= '<option value="' . $i . '"' . $selected . '>' . $months[$i] . '</option>';
    }
    $s_month .= '</select>';
    // buid select list for year
    $year = intval(gmdate('Y', $start_date));
    $s_year = '<select name="start_year" onchange="forms[\'f_calendar\'].submit();">';
    for ($i = 1971; $i < 2070; $i++) {
        $selected = $year == $i ? ' selected="selected"' : '';
        $s_year .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
    }
    $s_year .= '</select>';
    // build a forum select list
    $s_forum_list = '<select name="selected_id" onchange="forms[\'f_calendar\'].submit();">' . get_tree_option($fid) . '</select>';
    // header
    $config['calendar_display_open'] = false;
    $template->assign_vars(array('UP_ARROW' => $images['cal_up_arrow'], 'DOWN_ARROW' => $images['cal_down_arrow'], 'UP_ARROW2' => $images['arrow_up'], 'DOWN_ARROW2' => $images['arrow_down'], 'TOGGLE_ICON' => $config['calendar_display_open'] == false ? $images['cal_up_arrow'] : $images['cal_down_arrow'], 'TOGGLE_ICON2' => $config['calendar_display_open'] == false ? $images['arrow_up'] : $images['arrow_down'], 'TOGGLE_STATUS' => $config['calendar_display_open'] == false ? 'none' : ''));
    $prec = gmdate('Ym', $start_date) > 197101 ? gmdate('Ymd', gmmktime(0, 0, 0, gmdate('m', $start_date) - 1, 01, gmdate('Y', $start_date))) : gmdate('Ymd', $start_date);
    $next = gmdate('Ymd', gmmktime(0, 0, 0, gmdate('m', $start_date) + 1, 01, gmdate('Y', $start_date)));
    $template->assign_block_vars('_calendar_box', array('L_CALENDAR' => '<a href="' . append_sid(IP_ROOT_PATH . 'calendar.' . PHP_EXT . '?start=' . gmdate('Ymd', cal_date(time(), $config['board_timezone']))) . '"><img src="' . $images['icon_calendar'] . '" hspace="3" style="vertical-align: top;" alt="' . $lang['Calendar_event'] . '" /></a>' . $lang['Calendar'], 'L_CALENDAR_TXT' => $lang['Calendar'], 'SPAN_ALL' => $nb_cells, 'S_MONTH' => $s_month, 'S_YEAR' => $s_year, 'S_FORUM_LIST' => $s_forum_list, 'L_GO' => $lang['Go'], 'ACTION' => append_sid(IP_ROOT_PATH . 'calendar.' . PHP_EXT), 'U_PREC' => append_sid('calendar.' . PHP_EXT . '?start=' . $prec . '&amp;fid=' . $fid), 'U_NEXT' => append_sid('calendar.' . PHP_EXT . '?start=' . $next . '&amp;fid=' . $fid)));
    if ($full_month) {
        $template->assign_block_vars('_calendar_box.switch_full_month', array());
        $offset = $cfg_week_day_start;
        for ($j = 0; $j < $nb_cells; $j++) {
            if ($offset >= sizeof($day_of_week)) {
                $offset = 0;
            }
            $template->assign_block_vars('_calendar_box.switch_full_month._cell', array('WIDTH' => floor(100 / $nb_cells), 'L_DAY' => $day_of_week[$offset]));
            $offset++;
        }
    } else {
        $template->assign_block_vars('_calendar_box.switch_full_month_no', array());
    }
    // display
    $offset_date = gmmktime(0, 0, 0, gmdate('m', $start_date), gmdate('d', $start_date) - $start_inc, gmdate('Y', $start_date));
    for ($i = 0; $i < $nb_rows; $i++) {
        $template->assign_block_vars('_calendar_box._row', array());
        for ($j = 0; $j < $nb_cells; $j++) {
            $span = 1;
            // date less than start
            if (intval(gmdate('Ymd', $offset_date)) < intval(gmdate('Ymd', $start_date))) {
                // compute the cell to span
                $span = $start_inc;
                $j = $start_inc - 1;
                $offset_date = gmmktime(0, 0, 0, gmdate('m', $start_date), gmdate('d', $start_date) - 1, gmdate('Y', $start_date));
            }
            // date greater than last
            if (intval(gmdate('Ymd', $offset_date)) >= intval(gmdate('Ymd', $end_date))) {
                // compute the cell to span
                $span = $nb_cells - $j;
                $j = $nb_cells;
            }
            $format = intval(gmdate('Ymd', $offset_date)) == intval(gmdate('Ymd', cal_date(time(), $config['board_timezone']))) ? '<b>%s</b>' : '%s';
            $template->assign_block_vars('_calendar_box._row._cell', array('WIDTH' => floor(100 / $nb_cells), 'SPAN' => $span, 'DATE' => sprintf($format, date_dsp(($full_month ? '' : 'D ') . $lang['DATE_FORMAT_CALENDAR'], $offset_date)), 'U_DATE' => append_sid(IP_ROOT_PATH . 'calendar_scheduler.' . PHP_EXT . '?d=' . $offset_date . '&amp;fid=' . $fid)));
            // blank cells
            if (intval(gmdate('Ymd', $offset_date)) >= intval(gmdate('Ymd', $start_date)) && intval(gmdate('Ymd', $offset_date)) < intval(gmdate('Ymd', $end_date))) {
                $template->assign_block_vars('_calendar_box._row._cell.switch_filled', array('EVENT_DATE' => $offset_date, 'TOGGLE_STATUS' => 'none', 'TOGGLE_ICON' => $images['arrow_down']));
                // send events
                $more = false;
                $over = sizeof($map[$offset_date]) > $nb_row_per_cell;
                for ($k = 0; $k < sizeof($map[$offset_date]); $k++) {
                    // we are just over the limit
                    if ($over && $k == $nb_row_per_cell) {
                        $more = true;
                        $template->assign_block_vars('_calendar_box._row._cell.switch_filled._event._more_header', array());
                    }
                    $ind = $map[$offset_date][$k];
                    $template->assign_block_vars('_calendar_box._row._cell.switch_filled._event', array('U_EVENT' => $events[$ind]['event_link'], 'EVENT_TYPE' => $events[$ind]['event_type_icon'], 'EVENT_TITLE' => $events[$ind]['event_short_title'], 'EVENT_CLASS' => $events[$ind]['event_txt_class'], 'EVENT_MESSAGE' => str_replace(array('"'), array('&quot;'), addslashes($events[$ind]['event_message']))));
                    $flag = $over && $k == $nb_row_per_cell - 1;
                    if ($ind > -1) {
                        $template->assign_block_vars('_calendar_box._row._cell.switch_filled._event.switch_event', array());
                        if ($flag) {
                            $template->assign_block_vars('_calendar_box._row._cell.switch_filled._event.switch_event._more', array());
                        } else {
                            $template->assign_block_vars('_calendar_box._row._cell.switch_filled._event.switch_event._more_no', array());
                        }
                    } else {
                        $template->assign_block_vars('_calendar_box._row._cell.switch_filled._event.switch_event_no', array());
                        if ($flag) {
                            $template->assign_block_vars('_calendar_box._row._cell.switch_filled._event.switch_event_no._more', array());
                        } else {
                            $template->assign_block_vars('_calendar_box._row._cell.switch_filled._event.switch_event_no._more_no', array());
                        }
                    }
                    if ($k == sizeof($map[$offset_date]) - 1 && $more) {
                        $template->assign_block_vars('_calendar_box._row._cell.switch_filled._event._more_footer', array());
                    }
                }
            } else {
                $template->assign_block_vars('_calendar_box._row._cell.switch_filled_no', array());
            }
            $offset_date = gmmktime(0, 0, 0, gmdate('m', $offset_date), gmdate('d', $offset_date) + 1, gmdate('Y', $offset_date));
        }
    }
    // fill the main template
    $template->assign_var_from_handle($main_template, '_calendar_body' . $handler);
}
Пример #2
0
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
// End session management
// some constants
$set_of_months = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
$set_of_days = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
// get parameters
// date
$date = 0;
if (isset($_POST['date']) || isset($_GET['d'])) {
    $date = isset($_POST['date']) ? intval($_POST['date']) : intval($_GET['d']);
}
if ($date <= 0) {
    $date = cal_date(time(), $config['board_timezone']);
}
// date per jumpbox
$start_month = intval($_POST['start_month']);
$start_year = intval($_POST['start_year']);
if (!empty($start_month) && !empty($start_year)) {
    $day = 01;
    if (!empty($date)) {
        $day = gmdate('d', $date);
    }
    $date = gmmktime(0, 0, 0, $start_month, $day, $start_year);
}
// mode
$mode = request_var('mode', '', true);
$mode = check_var_value($mode, array('hour'));
// start
function pcp_output_age($field_name, $view_userdata, $map_name = '')
{
    global $board_config, $phpbb_root_path, $phpEx, $lang, $images, $userdata;
    global $values_list, $tables_linked, $classes_fields, $user_maps, $user_fields;
    // use user_birthday
    $pm_display = pcp_get_class_check('pm', $view_userdata);
    $txt = '';
    $img = '';
    $res = '';
    if (!empty($view_userdata['user_birthday']) && $view_userdata['user_id'] != ANONYMOUS) {
        $temp_url = $pm_display ? append_sid("./privmsg.{$phpEx}?mode=post&amp;" . POST_USERS_URL . '=' . $view_userdata['user_id']) : '';
        $img = intval(substr($view_userdata['user_birthday'], 4, 4)) == date('md', cal_date(time(), $board_config['board_timezone'])) ? $pm_display ? '<a href="' . $temp_url . '"><img src="' . $images['icon_birthday'] . '" border="0" alt="' . $lang['Happy_birthday'] . '" title="' . $lang['Happy_birthday'] . '" /></a>' : '<img src="' . $images['icon_birthday'] . '" border="0" alt="' . $lang['Happy_birthday'] . '" title="' . $lang['Happy_birthday'] . '" />' : '';
        $txt = date('Y', cal_date(time(), $board_config['board_timezone'])) - intval(substr($view_userdata['user_birthday'], 0, 4));
        if (intval(substr($view_userdata['user_birthday'], 4, 4)) > date('md', cal_date(time(), $board_config['board_timezone']))) {
            $txt--;
        }
        if ($txt < 0) {
            $txt = '';
            $img = '';
        }
        // result
        $res = pcp_output_format($field_name, $txt, $img, $map_name);
    }
    return $res;
}
Пример #4
0
            $txtclass = get_user_level_class($row['user_level'], 'genmed', $row);
            if ($row['user_allow_viewonline'] != YES) {
                $row['username'] = '******' . $row['username'] . '</i>';
            }
            $temp_url = append_sid("profile.{$phpEx}?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $row['user_id']);
            $row['username'] = '******' . $temp_url . '"	class="' . $txtclass . '">' . $row['username'] . '</a>';
            // add to the user list
            $res .= $res != '' ? ',	' : '';
            $res .= $row['username'];
        }
    }
    return $res;
}
// send	happy birthday list
if (defined('SHOW_ONLINE') && $userdata['session_logged_in']) {
    $birthday_fellows = get_birthday_list(cal_date(time(), $board_config['board_timezone']));
    if (!empty($birthday_fellows)) {
        $template->assign_block_vars('switch_happy_birthday', array());
    }
    $template->assign_vars(array('HAPPY_BIRTHDAY_IMG' => $images['Happy_birthday'], 'L_HAPPY_BIRTHDAY' => $lang['Happy_birthday'], 'HAPPY_BIRTHDAY_FELLOWS' => $birthday_fellows));
}
//-- fin mod : profile cp --------------------------------------------------------------------------
//
// START - Blocks
//
if (empty($gen_simple_header) && !defined('HAS_DIED')) {
    $sql = "SELECT lid,\tview, groups FROM " . BLOCKS_LAYOUT_TABLE . " WHERE\tname = '" . $layout . "'";
    if (!($layout_result = $db->sql_query($sql))) {
        message_die(CRITICAL_ERROR, "Could not query portal\tlayout information", "", __LINE__, __FILE__, $sql);
    }
    $layout_row = $db->sql_fetchrow($layout_result);
 function box_buddy_list($friend = false, $yours = false, $tpl = '')
 {
     global $db, $template, $lang, $images, $phpEx, $board_config;
     global $s_hidden_fields, $s_pagination_fields;
     global $HTTP_POST_VARS, $HTTP_GET_VARS;
     global $userdata, $view_userdata;
     global $admin_level, $level_prior;
     global $sub_template_key_image, $sub_templates;
     global $tree;
     $list_title = '??';
     if ($friend && $yours) {
         $list_title = $lang['Friend_list'];
     } else {
         if ($friend && !$yours) {
             $list_title = $lang['Friend_list_of'];
         } else {
             if (!$friend && $yours) {
                 $list_title = $lang['Ignore_list'];
             } else {
                 $list_title = $lang['Ignore_list_of'];
             }
         }
     }
     // floor time for active
     $floor = time() - 300;
     // check the buddy list type
     $view_user_id = $view_userdata['user_id'];
     if ($yours) {
         $sql_your_id = "b.user_id = {$view_user_id}";
         $sql_listed_ids = "u.user_id = b.buddy_id";
     } else {
         $sql_your_id = "b.buddy_id={$view_user_id}";
         $sql_listed_ids = "u.user_id=b.user_id";
     }
     if ($friend) {
         $sql_friend = "b.buddy_ignore=0";
     } else {
         $sql_friend = "b.buddy_ignore=1";
     }
     // online
     $sql = "SELECT b.*, u.user_id AS user_user_id, u.*\n\t\t\t\tFROM " . BUDDYS_TABLE . " b, " . USERS_TABLE . " u\n\t\t\t\tWHERE {$sql_listed_ids}\n\t\t\t\t\tAND {$sql_your_id}\n\t\t\t\t\tAND {$sql_friend}\n\t\t\t\tORDER BY username";
     if (!($result = $db->sql_query($sql))) {
         message_die(GENERAL_ERROR, 'Could not obtain Buddy online list information', '', __LINE__, __FILE__, $sql);
     }
     // read buddy rows
     $offlines = array();
     while ($row = $db->sql_fetchrow($result)) {
         $row['online'] = intval($row['user_session_time']) >= $floor;
         if ($row['online']) {
             $buddy_rowset[] = $row;
         } else {
             $offlines[] = $row;
         }
     }
     // re-add offlines
     for ($i = 0; $i < count($offlines); $i++) {
         $buddy_rowset[] = $offlines[$i];
     }
     // save template state
     $sav_tpl = $template->_tpldata;
     // init
     if (empty($tpl)) {
         $tpl = './profilcp/buddy_box';
     }
     // choose template
     $template->set_filenames(array($tpl => $tpl . '.tpl'));
     // constants
     $template->assign_vars(array('L_LIST_NAME' => $list_title, 'NOBODY' => $lang['Nobody']));
     if (empty($buddy_rowset)) {
         $template->assign_block_vars('nobody', array());
     }
     // list
     for ($i = 0; $i < count($buddy_rowset); $i++) {
         $w_user_id = $buddy_rowset[$i]['user_user_id'];
         if ($last_status != $buddy_rowset[$i]['online'] || $i == 0) {
             $template->assign_block_vars('online', array('L_ONLINE' => $buddy_rowset[$i]['online'] ? $lang['Online'] : $lang['Offline']));
         }
         $last_status = $buddy_rowset[$i]['online'];
         // birthday
         $real_display = $userdata['user_allow_real'] && $buddy_rowset[$i]['user_allow_real'] && ($buddy_rowset[$i]['user_viewreal'] == YES || $buddy_rowset[$i]['user_viewreal'] == FRIEND_ONLY && $friend);
         $birthday_img = '';
         if ($real_display) {
             $temp_url = append_sid("privmsg.{$phpEx}?mode=post&amp;" . POST_USERS_URL . "={$w_user_id}");
             $birthday_img = intval(substr($buddy_rowset[$i]['user_birthday'], 4, 4)) == date('md', cal_date(time(), $board_config['board_timezone'])) ? '<a href="' . $temp_url . '"><img src="' . $images['icon_birthday'] . '" border="0" alt="' . $lang['Happy_birthday'] . '" title="' . $lang['Happy_birthday'] . '" /></a>' : '';
         }
         $template->assign_block_vars('online.buddy', array('VISIBLE_IMG' => $buddy_rowset[$i]['buddy_visible'] ? $images['icon_visible'] : $images['icon_not_visible'], 'VISIBLE' => $buddy_rowset[$i]['buddy_visible'] ? $lang['Always_visible'] : $lang['Not_always_visible'], 'USERNAME' => $buddy_rowset[$i]['username'], 'U_PROFILE' => append_sid("profile.{$phpEx}?mode=viewprofile&amp;" . POST_USERS_URL . "={$w_user_id}"), 'BIRTHDAY' => $birthday_img));
         if ($friend && $yours) {
             $template->assign_block_vars('online.buddy.visible', array());
         }
     }
     // transfert to a var
     $template->assign_var_from_handle('_box', $tpl);
     $res = $template->_tpldata['.'][0]['_box'];
     // restore template saved state
     $template->_tpldata = $sav_tpl;
     return $res;
 }
Пример #6
0
    }
}
if (empty($start_date) || $start_date <= 0) {
    $start_date = gmmktime(0, 0, 0, intval(create_date('m', cal_date(time(), $config['board_timezone']))), intval(create_date('d', cal_date(time(), $config['board_timezone']))), intval(create_date('Y', cal_date(time(), $config['board_timezone']))));
}
// get the forum id selected
$fid = '';
if (isset($_POST['selected_id']) || isset($_GET['fid'])) {
    $fid = isset($_POST['selected_id']) ? $_POST['selected_id'] : $_GET['fid'];
    if ($fid != 'Root') {
        $type = substr($fid, 0, 1);
        $id = intval(substr($fid, 1));
        if (!in_array($type, array(POST_FORUM_URL, POST_CAT_URL))) {
            $type = POST_CAT_URL;
            $id = 0;
        }
        $fid = $type . $id;
        if ($fid == POST_CAT_URL . '0') {
            $fid = 'Root';
        }
    }
}
$calendar_start_date = create_date('F Y', cal_date($start_date, $config['board_timezone']));
// Header
$template->assign_vars(array('L_CALENDAR' => $lang['Calendar'], 'L_CALENDAR_START_DATE' => $calendar_start_date, 'U_CALENDAR' => append_sid('calendar.' . PHP_EXT)));
display_calendar('CALENDAR_MONTH', 0, $start_date, $fid);
// system
$s_hidden_fields = '';
$nav_separator = empty($nav_separator) ? empty($lang['Nav_Separator']) ? '&nbsp;&raquo;&nbsp;' : $lang['Nav_Separator'] : $nav_separator;
$template->assign_vars(array('NAV_SEPARATOR' => $nav_separator, 'S_ACTION' => append_sid('calendar.' . PHP_EXT), 'S_HIDDEN_FIELDS' => $s_hidden_fields));
full_page_generation('calendar_body.tpl', $lang['Calendar'], '', '');
Пример #7
0
function pcp_output($field_name, $view_userdata, $map_name = '', $legend_only = false)
{
    global $board_config, $phpbb_root_path, $phpEx, $lang, $images, $userdata;
    global $values_list, $tables_linked, $classes_fields, $user_maps, $user_fields;
    $res = '';
    // no field, exit
    if (empty($field_name)) {
        return '';
    }
    // fix user id
    $user_id = $userdata['user_id'];
    if (!$userdata['session_logged_in']) {
        $user_id = ANONYMOUS;
    }
    // values overwritten in maps
    if (!empty($user_maps[$map_name]['fields'][$field_name])) {
        @reset($user_maps[$map_name]['fields'][$field_name]);
        while (list($field_def, $field_def_value) = @each($user_maps[$map_name]['fields'][$field_name])) {
            $user_fields[$field_name][$field_def] = $field_def_value;
        }
    }
    // get field def
    $field_data = array();
    if (isset($user_fields[$field_name])) {
        $field_data = $user_fields[$field_name];
    }
    // default values
    if (empty($field_data['lang_key'])) {
        $field_data['lang_key'] = ucfirst($field_name);
    }
    if (empty($field_data['class'])) {
        $field_data['class'] = 'generic';
    }
    if (empty($field_data['type'])) {
        $field_data['type'] = 'VARCHAR';
    }
    // legend only
    if ($legend_only) {
        return mods_settings_get_lang($field_data['lang_key']);
    }
    // get class def
    $class_data = array();
    if (isset($classes_fields[$field_data['class']])) {
        $class_data = $classes_fields[$field_data['class']];
    }
    // check the data classes
    if (!pcp_get_class_check($field_data['class'], $view_userdata)) {
        return '';
    }
    // process special display
    if (!empty($field_data['dsp_func'])) {
        $func = $field_data['dsp_func'];
        $res = function_exists($func) ? $func($field_name, $view_userdata, $map_name) : $lang['PCP_err_field_dsp_func_unknown'];
    } else {
        // value
        $txt = '';
        $img = '';
        $lnk = $field_data['link'];
        $res = '';
        $constant_link = $field_data['lnk'] && !isset($view_userdata[$field_name]) && ($field_data['txt'] && !empty($field_data['title']) || $field_data['img'] && !empty($field_data['image']));
        if ($view_userdata['user_id'] != ANONYMOUS && (!empty($view_userdata[$field_name]) || $field_data['leg'] && !$field_data['txt'] && !$field_data['img'] || $constant_link)) {
            $title = isset($field_data['title']) ? mods_settings_get_lang($field_data['title']) : $view_userdata[$field_name];
            $alt = mods_settings_get_lang($field_data['lang_key']);
            switch ($field_data['type']) {
                case 'DATE':
                    $txt = !empty($view_userdata[$field_name]) ? create_date($lang['DATE_FORMAT'], $view_userdata[$field_name], $userdata['user_timezone']) : '';
                    $img .= isset($images[$field_data['image']]) ? '<img src="' . $images[$field_data['image']] . '" border="0" alt="' . $alt . '" title="' . $title . '" />' : '';
                    break;
                case 'DATETIME':
                    $txt = !empty($view_userdata[$field_name]) ? create_date($userdata['user_dateformat'], $view_userdata[$field_name], $userdata['user_timezone']) : '';
                    $img .= isset($images[$field_data['image']]) ? '<img src="' . $images[$field_data['image']] . '" border="0" alt="' . $alt . '" title="' . $title . '" />' : '';
                    break;
                case 'BIRTHDAY':
                    $pm_display = pcp_get_class_check('pm', $view_userdata);
                    if (!empty($view_userdata[$field_name])) {
                        $temp_url = $pm_display ? append_sid("./privmsg.{$phpEx}?mode=post&amp;" . POST_USERS_URL . '=' . $view_userdata['user_id']) : '';
                        $txt = create_birthday_date($lang['DATE_FORMAT'], $view_userdata[$field_name], $userdata['user_timezone']);
                        $img = intval(substr($view_userdata[$field_name], 4, 4)) == date('md', cal_date(time(), $board_config['board_timezone'])) ? $pm_display ? '<a href="' . $temp_url . '"><img src="' . $images['icon_birthday'] . '" border="0" align="absbottom" alt="' . $lang['Happy_birthday'] . '" title="' . $lang['Happy_birthday'] . '" /></a>' : '<img src="' . $images['icon_birthday'] . '" border="0" align="absbottom" alt="' . $lang['Happy_birthday'] . '" title="' . $lang['Happy_birthday'] . '" />' : '';
                    }
                    break;
                default:
                    $txt = $view_userdata[$field_name];
                    if ($field_data['lnk'] && !isset($view_userdata[$field_name])) {
                        $txt = $title;
                    }
                    $img .= isset($images[$field_data['image']]) ? '<img src="' . $images[$field_data['image']] . '" border="0" alt="' . $alt . '" title="' . $title . '" />' : '';
                    break;
            }
            // res
            $res = pcp_output_format($field_name, $txt, $img, $map_name, $lnk, $view_userdata);
        }
    }
    return $res;
}