Code: Alles auswählen
<?php
#################################################################
## Mod Title:mycalendar Mod w/selected forum integration
## Mod Version: 2.2.7
## Author: marksten
## Author: mojavelinux <dan@mojavelinux.com>
## Description: Enables users to add events to the calendar
## through a chosen forum.
#################################################################
$phpbb_root_path = './';
define('IN_PHPBB', true);
include_once $phpbb_root_path . 'extension.inc';
include_once $phpbb_root_path . 'common.'.$phpEx;
include_once $phpbb_root_path . 'includes/bbcode.'.$phpEx;
// Start session management
$userdata = session_pagestart($user_ip, PAGE_MYCALENDAR);
init_userprefs($userdata);
$sqlmonat = 'SELECT MONTH(CURDATE()) as curmonat';
if( $resultmonat = $db->sql_query($sqlmonat) )
{
while ($monat = $db->sql_fetchrow($resultmonat))
{ $curmonat = $monat[curmonat]; }
}
$sql = 'SELECT DAYOFMONTH(CURDATE()) as curtag';
if( $result = $db->sql_query($sql) )
{
while ($row = $db->sql_fetchrow($result))
{ $curtag = $row[curtag]; }
}
$sqljahr = 'SELECT YEAR(CURDATE()) as curjahr';
if( $resultjahr = $db->sql_query($sqljahr) )
{
while ($jahr = $db->sql_fetchrow($resultjahr))
{ $curjahr = $jahr[curjahr]; }
}
$current_datum = $curjahr . '-' . $curmonat . '-' . sprintf('%02d', $curtag) . ' 00:00:00';
if( isset($HTTP_GET_VARS['monat']) || isset($HTTP_POST_VARS['monat']) )
{
$cal_monat = ( isset($HTTP_POST_VARS['monat']) ) ? intval($HTTP_POST_VARS['monat']) : intval($HTTP_GET_VARS['monat']);
}
else if( isset($HTTP_GET_VARS['month']) || isset($HTTP_POST_VARS['month']) )
{
$cal_monat = ( isset($HTTP_POST_VARS['month']) ) ? intval($HTTP_POST_VARS['month']) : intval($HTTP_GET_VARS['month']);
}
else
{
$cal_monat = $curmonat;
}
if( isset($HTTP_GET_VARS['jahr']) || isset($HTTP_POST_VARS['jahr']) )
{
$cal_jahr = ( isset($HTTP_POST_VARS['jahr']) ) ? intval($HTTP_POST_VARS['jahr']) : intval($HTTP_GET_VARS['jahr']);
}
else
{
$cal_jahr = $curjahr;
}
if( isset($HTTP_GET_VARS['tag']) || isset($HTTP_POST_VARS['tag']) )
{
$cal_tag = ( isset($HTTP_POST_VARS['tag']) ) ? intval($HTTP_POST_VARS['tag']) : intval($HTTP_GET_VARS['tag']);
}
else
{
$cal_tag = $curtag;
}
// determine the information for the current date
list($today['year'], $today['month'], $today['day']) = explode('-', create_date('Y-m-d', time(), $board_config['board_timezone']));
// get the month/year offset from the get variables, or else use first day of this month
if (isset($HTTP_GET_VARS['month']) && isset($HTTP_GET_VARS['year'])) {
$view_isodate = sprintf('%04d', $HTTP_GET_VARS['year']) . '-' . sprintf('%02d', $HTTP_GET_VARS['month']) . '-01 00:00:00';
}
// get the first day of the month as an isodate
else {
$view_isodate = $today['year'] . '-' . $today['month'] . '-01 00:00:00';
}
// setup the current view information
$query = "SELECT
MONTHNAME('$view_isodate') as monthName,
DATE_FORMAT('$view_isodate', '%m') as month,
DAYOFWEEK('$view_isodate') as cal_weekday,
YEAR('$view_isodate') as year,
DATE_FORMAT(CONCAT(YEAR('$view_isodate'), '-', MONTH('$view_isodate' + INTERVAL 1 MONTH), '-01') - INTERVAL 1 DAY, '%e') as numDays,
WEEKDAY('$view_isodate') as offset";
$result = $db->sql_query($query);
$monthView = $db->sql_fetchrow($result);
$monthView['monthName'] = $lang['datetime'][$monthView['monthName']];
$l_monat = "Events im ".$monthView['monthName']."</b>";
// [*] is this going to give us a negative number ever?? [*]
if (!$lang['Calendar_start_monday']) {
$monthView['offset']++;
}
// set the page title and include the page header
$page_title = $lang['View_calendar'];
include ($phpbb_root_path . 'includes/page_portal.'.$phpEx);
$template->set_filenames(array(
'body' => 'mycalendar_body2.tpl')
);
// prepare the loops for running through the calendar for the current month
$numRows = ceil(($monthView['numDays'] + $monthView['offset']) / 1);
$day = 1;
$weekday = $monthView['cal_weekday'];
$weekday = ( $weekday - 1 );
$eventStack = array();
$topicCache = array();
foreach(range(1, $numRows) as $row) {
$template->assign_block_vars('date_row', array());
foreach (range(1, 1) as $weekIndex) {
// we are before the first date
if ( ($row == 1 && $weekIndex <= $monthView['offset']) ) {
if ( $weekIndex == 1 ) {
$template->assign_block_vars('date_row.date_cell', array(
'BLANK_COLSPAN' => $monthView['offset'])
);
$template->assign_block_vars('date_row.date_cell.switch_blank_cells', array());
}
}
// we are after the last date
elseif ($day > $monthView['numDays']) {
if ($day == ($monthView['numDays'] + 1)) {
$template->assign_block_vars('date_row.date_cell', array(
'BLANK_COLSPAN' => ($row * 1) - ($monthView['numDays'] + $monthView['offset']))
);
$template->assign_block_vars('date_row.date_cell.switch_blank_cells', array());
// We have to now increment the day so that we don't repeat this cell
$day++;
}
}
// we are on a date
else {
if ( $weekday == '7' )
{ $weekday = '1'; }
else
{ $weekday++; }
$template->assign_block_vars('date_row.date_cell', array(
'TODAY_STYLE' => $today_style,
'DATE_CLASS' => ($row % 2) ? 'row2' : 'row3',
'DATE' => $day,
'WEEKDAY' => $lang['mini_cal']['f_day'][$weekday],
'MONTH' => $monthView['monthName'])
);
$template->assign_block_vars('date_row.date_cell.switch_date_cells', array());
// allow the template to handle how to treat the day
if ($today['day'] == $day && $today['month'] == $monthView['month'] && $today['year'] == $monthView['year']) {
$template->assign_block_vars('date_row.date_cell.switch_date_cells.switch_date_today', array());
}
else {
$template->assign_block_vars('date_row.date_cell.switch_date_cells.switch_date_otherday', array());
}
// set the isodate for our current mark in the calendar (padding day appropriately)
$current_isodate = $monthView['year'] . '-' . $monthView['month'] . '-' . sprintf('%02d', $day) . ' 00:00:00';
$query = "SELECT
c.*,
DAYOFWEEK(c.cal_date) as cal_weekday,
t.topic_title,
l.cat_id,
t.topic_views,
t.topic_replies,
f.forum_name,
f.auth_read,
(cal_interval_units = 'DAY' && cal_interval = 1 && '$current_isodate' = INTERVAL (cal_interval * (cal_repeat - 1)) DAY + cal_date) as block_end
FROM
" . MYCALENDAR_TABLE . " as c,
" . TOPICS_TABLE . " as t,
" . FORUMS_TABLE . " as f,
" . POSTS_TEXT_TABLE . " as pt
LEFT JOIN locations l ON l.location_name = c.location
WHERE
c.forum_id = f.forum_id
AND
c.topic_id = t.topic_id
AND
f.events_forum > 0
AND
pt.post_id = t.topic_first_post_id
AND
'$current_isodate' >= cal_date
AND
(
# If the repeat is forever just continue here
cal_repeat = 0
OR
(
# If the repeat is limited, then make sure we are not past the end
cal_repeat > 0
AND
(
(cal_interval_units = 'DAY' AND ('$current_isodate' <= INTERVAL (cal_interval * (cal_repeat - 1)) DAY + cal_date))
OR
(cal_interval_units = 'WEEK' AND ('$current_isodate' <= INTERVAL ((cal_interval * (cal_repeat - 1)) * 7) DAY + cal_date))
OR
(cal_interval_units = 'MONTH' AND ('$current_isodate' <= INTERVAL (cal_interval * (cal_repeat - 1)) MONTH + cal_date))
OR
(cal_interval_units = 'YEAR' AND ('$current_isodate' <= INTERVAL (cal_interval * (cal_repeat - 1)) YEAR + cal_date))
)
)
)
AND
(
(
cal_interval_units = 'DAY'
AND
(TO_DAYS('$current_isodate') - TO_DAYS(cal_date)) % cal_interval = 0
)
OR
(
cal_interval_units = 'WEEK'
AND
(TO_DAYS('$current_isodate') - TO_DAYS(cal_date)) % (7 * cal_interval) = 0
)
OR
(
cal_interval_units = 'MONTH'
AND
DAYOFMONTH(cal_date) = DAYOFMONTH('$current_isodate')
AND
PERIOD_DIFF(DATE_FORMAT('$current_isodate', '%Y%m'), DATE_FORMAT(cal_date, '%Y%m')) % cal_interval = 0
)
OR
(
cal_interval_units = 'YEAR'
AND
DATE_FORMAT(cal_date, '%m%d') = DATE_FORMAT('$current_isodate', '%m%d')
AND
(YEAR('$current_isodate') - YEAR(cal_date)) % cal_interval = 0
)
)
ORDER BY
cal_interval_units ASC,
cal_repeat DESC,
cal_date ASC";
if (!$result = $db->sql_query($query)) {
message_die(GENERAL_ERROR, 'Error querying dates for calendar.');
}
$numEvents = 0;
while ($topic = $db->sql_fetchrow($result)) {
$is_auth = array();
$is_auth = auth(AUTH_ALL, $topic['forum_id'], $userdata);
if ( $is_auth['auth_read'] ) {
$topic_id = $topic['topic_id'];
// prepare the first post text if it has not already been cached
if (!isset($topicCache[$topic_id])) {
$post_text = $topic['post_text'];
// if we are spilling over, reduce size...[!] should be configurable [!]
if (strlen($post_text) > 2) {
$post_text = substr($post_text, 0, 0) . 'Tip: Klicke auf den Event um alle Infos & Kommentare zu lesen';
}
$post_text = bbencode_second_pass($post_text, $topic['bbcode_uid']);
$post_text = smilies_pass($post_text);
$post_text = preg_replace("/[\n\r]{1,2}/", '<br />', $post_text);
// prepare the popup text, escaping quotes for javascript
$title_text = '<b>' . $lang['Topic'] . ':</b> ' . $topic['topic_title'] . '<br /><b>' . $lang['Forum'] . ':</b> <i>' . $topic['forum_name'] . '</i><br /><b>' . $lang['Views'] . ':</b> ' . $topic['topic_views'] . '<br /><b>' . $lang['Replies'] . ':</b> ' . $topic['topic_replies'];
// tack on the interval and repeat if this is a repeated event
if ($topic['cal_repeat'] != 1) {
$title_text .= '<br /><b>' . $lang['Calendar_interval'] . ':</b> ' . $topic['cal_interval'] . ' ' . (($topic['cal_interval'] == 1) ? $lang['interval'][strtolower($topic['cal_interval_units'])] : $lang['interval'][strtolower($topic['cal_interval_units']) . 's']). '<br /><b>' . $lang['Calendar_repeat'] . ':</b> ' . ($topic['cal_repeat'] ? $topic['cal_repeat'] . 'x' : 'always');
}
$title_text .= '<br />' . $post_text;
$title_text = str_replace('\'', '\\\'', htmlspecialchars($title_text));
// make the url for the topic
$topic_url = append_sid('viewtopic.php?topic_id=' . $topic_id);
$topicCache[$topic_id] = array(
'first_post' => $title_text,
'topic_url' => $topic_url,
);
}
// if we have a block event running (interval = 1 day) with this topic ID, then output our line
// if (isset($eventStack[$topic_id])) {
// $first_date = '';
// }
// else {
$topic_text = strlen($topic['topic_title']) > 137 ? substr($topic['topic_title'], 0, 137) . '...' : $topic['topic_title'];
$topic_text = "$topic_text<br>";
if ( !empty($topic['url']) )
{
$topic['url'] = "<a href=\"".$topic['url']."\" target=_blank><img src=/images/homepage.gif border=0></a>";
}
else
{ $topic['url'] = ''; }
if ( !empty($topic['cat_id']) )
{
$cal_location = "<a href=/cam/categories.php?cat_id=".$topic['cat_id'].">".$topic['location']."</a>";
}
else
{
$cal_location = $topic['location'];
}
if ( !empty($cal['location']) && $cal['location'] != 'sonstige')
{
$cal_location = "<a href=/cam/categories.php?cat_id=".$cal['cat_id']."><font color=#dddddd>".$cal['location']."</font></a> :: ";
}
$template->assign_block_vars('date_row.date_cell.switch_date_cells.date_event', array(
'U_EVENT' => $topic_text,
'C_LOCATION' => $cal_location, 'C_REPLIES' => $topic['topic_replies'],
'C_STADT' => $topic['stadt'],
'C_EINTRITT' => $topic['eintritt'],
'C_URL' => $topic['url'],
'C_URL_C' => "</a>"
)
);
// }
$numEvents++;
// Here I use a stack of sorts to keep track of block events which are
// still running...I sort the block start dates by date, so the overlaps
// will always appear in the same order...if a block ends while a lower block
// continues, I keep a place holder so that the line continues along the same
// path
// we are at the end of a block event
if ($topic['block_end']) {
unset($eventStack[$topic_id]);
}
// we place an entry in the event stack, key as the topic, value as the row
// number the event should fall in, for visual block events (interval = 1 day)
elseif (!isset($eventStack[$topic_id]) && $topic['cal_interval_units'] == 'DAY' && $topic['cal_interval'] == 1) {
$eventStack[$topic_id] = empty($eventStack) ? 0 : sizeof($eventStack);
}
}
}
// Increment the day
$day++;
}
}
}
if ($monthView['month'] == '12') {
$nextmonth = 1;
$nextyear = $monthView['year'] + 1;
}
else {
$nextmonth = sprintf('%02d', $monthView['month'] + 1);
$nextyear = $monthView['year'];
}
if ($monthView['month'] == '01') {
$previousmonth = '12';
$previousyear = $monthView['year'] - 1;
}
else {
$previousmonth = sprintf('%02d', $monthView['month'] - 1);
$previousyear = $monthView['year'];
}
// prepare images and links for month navigation
$url_prev_month = append_sid('events.' . $phpEx . "?month=$previousmonth&year=$previousyear");
$url_next_month = append_sid('events.' . $phpEx . "?month=$nextmonth&year=$nextyear");
$url_prev_year = append_sid('events.' . $phpEx . '?month=' . $monthView['month'] . '&year=' . ($monthView['year'] - 1));
$url_next_year = append_sid('events.' . $phpEx . '?month=' . $monthView['month'] . '&year=' . ($monthView['year'] + 1));
if ($lang['Calendar_start_monday']) {
$template->assign_block_vars('switch_sunday_end', array());
}
else {
$template->assign_block_vars('switch_sunday_beginning', array());
}
$template->assign_vars(array(
'L_SUNDAY' => $lang['datetime']['Sunday'],
'L_MONDAY' => $lang['datetime']['Monday'],
'L_TUESDAY' => $lang['datetime']['Tuesday'],
'L_WEDNESDAY' => $lang['datetime']['Wednesday'],
'L_THURSDAY' => $lang['datetime']['Thursday'],
'L_FRIDAY' => $lang['datetime']['Friday'],
'L_SATURDAY' => $lang['datetime']['Saturday'],
'L_CURRENT_MONTH' => $monthView['monthName'],
'L_CURRENT_YEAR' => $monthView['year'],
'I_PREV_MONTH' => $image_prev_month,
'I_NEXT_MONTH' => $image_next_month,
'U_PREV_MONTH' => $url_prev_month,
'U_NEXT_MONTH' => $url_next_month,
'I_PREV_YEAR' => $image_prev_year,
'I_NEXT_YEAR' => $image_next_year,
'U_PREV_YEAR' => $url_prev_year,
'U_NEXT_YEAR' => $url_next_year,
// Recent Topics
'L_RECENT_TOPICS' => $lang['Recent_topics'],
)
);
if ( $cal_monat == 1
|| $cal_monat == 3
|| $cal_monat == 5
|| $cal_monat == 7
|| $cal_monat == 8
|| $cal_monat == 10
|| $cal_monat == 12 )
{
$number_days = '31';
$cal_tage = '';
$i=0;
while ($i < $number_days)
{
$i++;
$cal_tage = "".$cal_tage." | <a href=#".$i.">".$i."</a>";
$template->assign_vars(array(
'L_MINI_KAL' => $cal_tage )
);
}
}
if ( $cal_monat == 4
|| $cal_monat == 6
|| $cal_monat == 9
|| $cal_monat == 11 )
{
$number_days = '30';
$cal_tage = '';
$i=0;
while ($i < $number_days)
{
$i++;
$cal_tage = "".$cal_tage." | <a href=#".$i.">".$i."</a>";
$template->assign_vars(array(
'L_MINI_KAL' => $cal_tage )
);
}
}
if ( $cal_monat == 2 )
{
$number_days = '28';
$cal_tage = '';
$i=0;
while ($i < $number_days)
{
$i++;
$cal_tage = "".$cal_tage." | <a href=#".$i.">".$i."</a>";
$template->assign_vars(array(
'L_MINI_KAL' => $cal_tage )
);
}
}
$sql = "SELECT SUM(t.topic_replies) as cal_topic_replies
FROM
" . MYCALENDAR_TABLE . " as c,
board_topics as t
WHERE c.topic_id = t.topic_id";
$result = mysql_query($sql);
while($array1=mysql_fetch_array($result))
{
$cal_topic_replies = $array1['cal_topic_replies'];
}
$sql = "SELECT COUNT(cal_date) as kommende_events
FROM
" . MYCALENDAR_TABLE . "
WHERE
'$current_datum' <= cal_date";
$result = mysql_query($sql);
while($array2=mysql_fetch_array($result)) {
$kommende_events = $array2['kommende_events'];
}
$sql = "SELECT COUNT(cal_date) as vergangene_events
FROM
" . MYCALENDAR_TABLE . "
WHERE
1";
$result = mysql_query($sql);
while($array3=mysql_fetch_array($result)) {
$vergangene_events = $array3['vergangene_events'];
}
$L_ALL_EVENTS_MORGEN = '<a href=event.php?type=detailed&monat=' . $curmonat . '&tag=' . ( $curtag + 1) . '&jahr=2003>Morgen (' . ( $curtag + 1) . '.' . $curmonat . '.)</a>';
$template->assign_vars(array(
'L_MONATSNAME' => $l_monat,
'KOMMENDE_EVENTS' => $kommende_events,
'VERGANGENE_EVENTS' => $vergangene_events,
'EVENT_COMMENTS' => $cal_topic_replies,
'L_CLUBBING' => '<a href=event.php?monat=' . $cal_monat . '&type=clubbing>Discos & Clubs</a>',
'L_EVENTS' => '<a href=event.php?monat=' . $cal_monat . '&type=party>off|location events</a>',
'L_ALL_EVENTS' => '<a href=event.php?monat=' . $cal_monat . '>Alle Events</a>',
'L_ALL_EVENTS_HEUTE' => '<a href=events.php#heute>Was geht heute (' . $curtag . '.' . $curmonat . '.)</a>',
'L_ALL_EVENTS_MORGEN' => $L_ALL_EVENTS_MORGEN,
'L_MINI_CAL_MONTH' => $lang['datetime'][$mini_cal->day[0][3]] . " " . $mini_cal->day[0][5],
'L_MINI_CAL_ADD_EVENT' => $lang['Mini_Cal_add_event'],
'L_MINI_CAL_CALENDAR' => $lang['Mini_Cal_calendar'],
'L_MINI_CAL_EVENTS' => $lang['Mini_Cal_events'],
'L_MINI_CAL_SUN' => $lang['mini_cal']['day'][1],
'L_MINI_CAL_MON' => $lang['mini_cal']['day'][2],
'L_MINI_CAL_TUE' => $lang['mini_cal']['day'][3],
'L_MINI_CAL_WED' => $lang['mini_cal']['day'][4],
'L_MINI_CAL_THU' => $lang['mini_cal']['day'][5],
'L_MINI_CAL_FRI' => $lang['mini_cal']['day'][6],
'L_MINI_CAL_SAT' => $lang['mini_cal']['day'][7],
'U_MINI_CAL_CALENDAR' => append_sid($phpbb_root_path . 'mycalendar.' . $phpEx),
'U_MINI_CAL_ADD_EVENT' => append_sid($phpbb_root_path . 'posting.' . $phpEx . '?mode=newtopic&f=' . MINI_CAL_EVENTS_FORUM ),
)
);
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>
das verwende ich grad.
müsst ihr halt an eure page anpassen. kp ob das so funkt...