Code: Select all
function calendar_display_mini_month()
{
global $auth, $db, $user, $config, $template, $date, $available_etype_colors, $available_etype_images, $available_etype_display_names, $month_sel_code, $day_sel_code, $year_sel_code, $mode_sel_code;
global $phpEx, $phpbb_root_path;
init_calendar_data();
init_view_selection_code("month");
// data of akt. month
$time = getdate(time());
//create next and prev links
set_date_prev_next( "month" );
$calling_page = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF'];
$mini_prev_link = append_sid($calling_page, "calM=".$date['prev_month']."&calY=".$date['prev_year']);
$mini_next_link = append_sid($calling_page, "calM=".$date['next_month']."&calY=".$date['next_year']);
//find the first day of the week
$first_day_of_week = get_calendar_config_value("first_day_of_week", 0);
get_weekday_names_mini( $first_day_of_week, $sunday, $monday, $tuesday, $wednesday, $thursday, $friday, $saturday );
//get the first day of the month
$date['num'] = "01";
$date['fday'] = get_fday( $date['num'], $date['month_no'], $date['year'], $first_day_of_week );
$number_days = gmdate("t", gmmktime( 0,0,0,$date['month_no'], $date['day'], $date['year']));
//$mini_calendar_header_txt = $user->lang['MONTH_OF'] . sprintf($user->lang['LOCAL_DATE_FORMAT'], $user->lang['datetime'][$date['month']], $date['day'], $date['year'] );
$mini_calendar_header_txt = $user->lang['datetime'][$date['month']] . ' - ' . $date['year'];
$subject_limit = get_calendar_config_value("display_truncated_name", 0);
// Is the user able to view ANY events?
$user_can_view_events = false;
if ( $auth->acl_get('u_calendar_view_events') )
{
$user_can_view_events = true;
/* find the group options here so we do not have to look them up again for each day */
$group_options = get_sql_group_options($user->data['user_id']);
}
$counter = 0;
for ($j = 1; $j < $number_days+1; $j++, $counter++)
{
// if it is the first week
if ($j == 1)
{
// find how many place holders we need before day 1
if ($date['fday'] < 7)
{
$date['fday'] = $date['fday']+1;
for ($i = 1; $i < $date['fday']; $i++, $counter++)
{
// create dummy days (place holders)
if( $i == 1 )
{
$mini_calendar_days['START_WEEK'] = true;
}
else
{
$mini_calendar_days['START_WEEK'] = false;
}
$mini_calendar_days['END_WEEK'] = false;
$mini_calendar_days['HEADER_CLASS'] = 'bg3';
$mini_calendar_days['DAY_CLASS'] = 'bg2';
$mini_calendar_days['NUMBER'] = 0;
$mini_calendar_days['DUMMY_DAY'] = true;
$mini_calendar_days['ADD_LINK'] = '';
$mini_calendar_days['BIRTHDAYS'] = '';
$template->assign_block_vars('mini_calendar_days', $mini_calendar_days);
}
}
}
// start creating the data for the real days
$mini_calendar_days['START_WEEK'] = false;
$mini_calendar_days['END_WEEK'] = false;
$mini_calendar_days['DUMMY_DAY'] = false;
$mini_calendar_days['HEADER_CLASS'] = 'bg3';
$mini_calendar_days['DAY_CLASS'] = 'bg2';
$mini_calendar_days['NUMBER'] = 0;
$mini_calendar_days['ADD_LINK'] = '';
$mini_calendar_days['BIRTHDAYS'] = '';
$mini_calendar_days['WRITE_BOLD'] = 100;
if($counter % 7 == 0)
{
$mini_calendar_days['START_WEEK'] = true;
}
if($counter % 7 == 6 )
{
$mini_calendar_days['END_WEEK'] = true;
}
$mini_calendar_days['NUMBER'] = $j;
if( $auth->acl_get('u_calendar_create_events') )
{
$mini_calendar_days['ADD_LINK'] = append_sid("{$phpbb_root_path}calendarpost.$phpEx", "mode=post&calD=".$j."&calM=".$date['month_no']."&calY=".$date['year']);
}
$mini_calendar_days['DAY_VIEW_URL'] = append_sid("{$phpbb_root_path}calendar.$phpEx", "view=day&calD=".$j."&calM=".$date['month_no']."&calY=".$date['year']);
$mini_calendar_days['WEEK_VIEW_URL'] = append_sid("{$phpbb_root_path}calendar.$phpEx", "view=week&calD=".$j."&calM=".$date['month_no']."&calY=".$date['year']);
//highlight selected day
if( $j == $date['day'] && $date["month_no"] == $time["mon"])
{
$mini_calendar_days['DAY_CLASS'] = 'bg4';
}
//highlight current day
$test_start_hi_time = mktime( 0,0,0,$date['month_no'], $j, $date['year']) + date('Z');
$test_end_hi_time = $test_start_hi_time + 86399;
$test_hi_time = time() + $user->timezone + $user->dst;
if( ($test_start_hi_time <= $test_hi_time) &&
($test_end_hi_time >= $test_hi_time))
{
$mini_calendar_days['HEADER_CLASS'] = 'bg3';
$mini_calendar_days['DAY_CLASS'] = 'bg4';
}
/*
if ( $user_can_view_events && $auth->acl_get('u_viewprofile') )
{
// find birthdays
$mini_calendar_days['BIRTHDAYS'] = generate_birthday_list( $j, $date['month_no'], $date['year'] );
}
*/
$arrayOfDays[] = $mini_calendar_days;
}
if ( $user_can_view_events )
{
if($time["mon"] == $date["month_no"]) $day = $date['day']; else $day = 1;
// startDate = first Day of viewed month
$start_temp_date = gmmktime( 0,0,0,$date['month_no'], $day, $date['year']);
$end_temp_date = $start_temp_date + 2678400;
// find all day events that are still taking place
$sort_timestamp_cutoff = $start_temp_date - 86400+1;
// don't list events that are more than 1 year in the future
$sql = 'SELECT * FROM ' . CALENDAR_EVENTS_TABLE . '
WHERE ( (event_access_level = 2) OR
(event_access_level = 0 AND poster_id = '.$db->sql_escape($user->data['user_id']).' ) OR
(event_access_level = 1 AND ('.$db->sql_escape($group_options).') ) ) AND
((( event_start_time >= '.$db->sql_escape($start_temp_date).' AND event_start_time <= '.$db->sql_escape($end_temp_date).' ) OR
( event_end_time > '.$db->sql_escape($start_temp_date).' AND event_end_time <= '.$db->sql_escape($end_temp_date).' ) OR
( event_start_time < '.$db->sql_escape($start_temp_date).' AND event_end_time > '.$db->sql_escape($end_temp_date)." )) OR (sort_timestamp > ".$db->sql_escape($sort_timestamp_cutoff)." AND event_all_day = 1) ) ORDER BY sort_timestamp ASC";
// find next 5 events
$result = $db->sql_query_limit($sql, 5, 0);
// $result = $monthEventResult;
while ($row = $db->sql_fetchrow($result))
{
$dayOfEvent = getdate($row["sort_timestamp"]);
$event_output['COLOR'] = $available_etype_colors[$row['etype_id']];
$event_output['IMAGE'] = $available_etype_images[$row['etype_id']];
$event_output['EVENT_URL'] = append_sid("{$phpbb_root_path}calendar.$phpEx", "view=event&calEid=".$row['event_id']);
$event_output['NUMBER'] = $dayOfEvent["mday"].".".$dayOfEvent["mon"].".";
$event_output['DAY_VIEW_URL'] = append_sid("{$phpbb_root_path}calendar.$phpEx", "view=day&calD=".$dayOfEvent["mday"]."&calM=".$dayOfEvent["mon"]."&calY=".$dayOfEvent["year"]);
$event_output['WEEK_VIEW_URL'] = append_sid("{$phpbb_root_path}calendar.$phpEx", "view=week&calD=".$dayOfEvent["mday"]."&calM=".$dayOfEvent["mon"]."&calY=".$dayOfEvent["year"]);
if($date["month_no"] == $dayOfEvent["mon"]) {
$arrayOfDays[$dayOfEvent["mday"]-1]["WRITE_BOLD"] = "bold";
}
// if the event was created by this user
// display it in bold
if( $user->data['user_id'] == $row['poster_id'] )
{
$event_output['DISPLAY_BOLD'] = true;
}
else
{
$event_output['DISPLAY_BOLD'] = false;
}
$event_output['ETYPE_DISPLAY_NAME'] = $available_etype_display_names[$row['etype_id']];
$event_output['EVENT_SUBJECT'] = censor_text($row['event_subject']);
if( $subject_limit > 0 )
{
if(utf8_strlen($event_output['EVENT_SUBJECT']) > $subject_limit)
{
$event_output['EVENT_SUBJECT'] = truncate_string($event_output['EVENT_SUBJECT'], $subject_limit) . '...';
}
}
$template->assign_block_vars('events', $event_output);
}
$db->sql_freeresult($result);
}
for($a=0;$a<count($arrayOfDays);$a++) {
if(!empty($arrayOfDays[$a]["NUMBER"])) {
$template->assign_block_vars('mini_calendar_days', $arrayOfDays[$a]);
}
}
$counter--;
$dummy_end_day_count = 6 - ($counter % 7);
for ($i = 1; $i <= $dummy_end_day_count; $i++)
{
// create dummy days (place holders)
$mini_calendar_days['START_WEEK'] = false;
if( $i == $dummy_end_day_count )
{
$mini_calendar_days['END_WEEK'] = true;
}
else
{
$mini_calendar_days['END_WEEK'] = false;
}
$mini_calendar_days['HEADER_CLASS'] = '';
$mini_calendar_days['DAY_CLASS'] = '';
$mini_calendar_days['NUMBER'] = 0;
$mini_calendar_days['DUMMY_DAY'] = true;
$mini_calendar_days['ADD_LINK'] = '';
$mini_calendar_days['BIRTHDAYS'] = '';
$template->assign_block_vars('mini_calendar_days', $mini_calendar_days);
}
// A typical usage for sending your variables to your template.
$template->assign_vars(array(
'CALENDAR_HEADER_MINI' => $mini_calendar_header_txt,
'DAY_IMG' => $user->img('button_calendar_day', 'DAY'),
'WEEK_IMG' => $user->img('button_calendar_week', 'WEEK'),
'CALENDAR_PREV_MINI' => '<a href=\''.$mini_prev_link.'\'><img src="' . $phpbb_root_path . 'styles/' . $user->theme['theme_path'] . '/theme/images/portal/mini_cal_icon_left_arrow.png' . '" title="' . $user->lang['View_previous_month'] . '" height="16" width="16" alt="<<" /></a>',
'CALENDAR_NEXT_MINI' => '<a href=\''.$mini_next_link.'\'><img src="' . $phpbb_root_path . 'styles/' . $user->theme['theme_path'] . '/theme/images/portal/mini_cal_icon_right_arrow.png' . '" title="' . $user->lang['View_next_month'] . '" height="16" width="16" alt=">>" /></a>',
'CALENDAR_VIEW_OPTIONS' => $mode_sel_code.' '.$month_sel_code.' '.$day_sel_code.' '.$year_sel_code,
'SUNDAY_MINI' => $sunday,
'MONDAY_MINI' => $monday,
'TUESDAY_MINI' => $tuesday,
'WEDNESDAY_MINI' => $wednesday,
'THURSDAY_MINI' => $thursday,
'FRIDAY_MINI' => $friday,
'SATURDAY_MINI' => $saturday,
'S_POST_ACTION_MINI' => append_sid("{$phpbb_root_path}calendar.$phpEx" ),
));
}
I hope you understand my english and could use these modifications.