############################################################## 
## MOD Title: Topic calendar - extension for mini cal v 1.11
## MOD Author: Ptirhiik < admin@rpgnet-fr.com > (Pierre) http://www.rpgnet-fr.com
## MOD Description:
##		Extension of mini cal for topic calendar mod
##
## MOD Version: 1.0.0
## 
## Installation Level: Easy
## Installation Time: 10 Minutes
## Files To Edit:
##		mods/netclectic/mini_cal/mini_cal_config.php
##		mods/netclectic/mini_cal/mini_cal.php
##		search.php
##
## Included Files: n/a
############################################################## 
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the 
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code 
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered 
## in our MOD-Database, located at: http://www.phpbb.com/mods/ 
############################################################## 
## Author Notes: 
## 
############################################################## 
## MOD History: 
## 
##   2003-08-26 - Version 0.0.3
##	- ajustement for new duration managing
##
##   2003-08-26 - Version 0.0.2
##      - complete
## 
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
##############################################################
#
#-----[ OPEN ]------------------------------------------------
#
mods/netclectic/mini_cal/mini_cal_config.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : topic calendar ext ----------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
// Defines which 'branch' of MyCalendar you are using, if any
// can be either:
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : topic calendar ext ----------------------------------------------------------------------
//-- add
//		TOPIC_CALENDAR : topic calendar installed
//-- mod : topic calendar ext ----------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
define('MINI_CAL_MYCAL_VERSION', 'STANDARD');
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
// define('MINI_CAL_MYCAL_VERSION', 'STANDARD');
define('MINI_CAL_MYCAL_VERSION', 'TOPIC_CALENDAR');
#
#-----[ OPEN ]------------------------------------------------
#
mods/netclectic/mini_cal/mini_cal.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : topic calendar ext ----------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
			if ( ($mini_cal_auth_level['auth_post']) && ((MINI_CAL_MYCAL_VERSION == 'PLUS' ) ? $mini_cal_auth_level['auth_calendar'] : true) )
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//-- mod : topic calendar ext ----------------------------------------------------------------------
//-- delete
//            if ( ($mini_cal_auth_level['auth_post']) && ((MINI_CAL_MYCAL_VERSION == 'PLUS' ) ? $mini_cal_auth_level['auth_calendar'] : true) )
//-- add
			if ( ($mini_cal_auth_level['auth_post']) && ((MINI_CAL_MYCAL_VERSION == 'PLUS' ) ? $mini_cal_auth_level['auth_calendar'] : ((MINI_CAL_MYCAL_VERSION == 'TOPIC_CALENDAR' ) ? $mini_cal_auth_level['auth_cal'] : true)) )
//-- fin mod : topic calendar ext ------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
            $mini_cal_event_days = array();
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : topic calendar ext ----------------------------------------------------------------------
//-- add
			if (MINI_CAL_MYCAL_VERSION != 'TOPIC_CALENDAR')
			{
//-- fin mod : topic calendar ext ------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
                    $mini_cal_event_days[] = $row['event_day'];
                }
            }
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : topic calendar ext ----------------------------------------------------------------------
//-- add
			}
			else
			{
				// start and end date
				$start_date = mktime(0,0,0, $mini_cal_this_month, 01, $mini_cal_this_year);
				$w_month = $mini_cal_this_month + 1;
				$w_year = $mini_cal_this_year;
				if ($w_month > 12)
				{
					$w_month = 01;
					$w_year++;
				}
				$end_date = mktime(0,0,0, $w_month, 01, $w_year);

				// we consider the duration
				$sql = "SELECT DISTINCT topic_calendar_time, topic_calendar_duration
						FROM " . TOPICS_TABLE . "
						WHERE forum_id IN ($auth_view_forums)
							AND (topic_calendar_time + topic_calendar_duration) >= $start_date
							AND topic_calendar_time < $end_date
							AND topic_calendar_time IS NOT NULL
							AND topic_calendar_time <> 0";
				if ( $result = $db->sql_query($sql) )
				{
					$mini_cal_event_days_ww = array();
					while( $row = $db->sql_fetchrow($result) )
					{
						$start_day = intval(date('d', $row['topic_calendar_time']));
						for ($i = 0; ( ($i <= intval($row['topic_calendar_duration'] / 86400)) && ( ($start_day + $i) <= 31) ); $i++)
						{
							$mini_cal_event_days_ww[ ($start_day + $i) ] = true;
						}
					}
					while (list($mini_cal_event_day, $mini_cal_event_present) = each($mini_cal_event_days_ww) )
					{
						$mini_cal_event_days[] = $mini_cal_event_day;
					}
				}
			}
//-- fin mod : topic calendar ext ------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
        // get the events 
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : topic calendar ext ----------------------------------------------------------------------
//-- add
		if ( MINI_CAL_MYCAL_VERSION != 'TOPIC_CALENDAR')
		{
//-- fin mod : topic calendar ext ------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
    	          0," . MINI_CAL_LIMIT;
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : topic calendar ext ----------------------------------------------------------------------
//-- add
		}
		else
		{
			// start and end date
			$start_date = mktime(0,0,0, $mini_cal_this_month, 01, $mini_cal_this_year);
			$w_month = $mini_cal_this_month + 1;
			$w_year = $mini_cal_this_year;
			if ($w_month > 12)
			{
				$w_month = 01;
				$w_year++;
			}
			$end_date = mktime(0,0,0, $w_month, 01, $w_year);

			// get events
			$sql = "SELECT t.topic_id, t.topic_calendar_time, t.topic_title, t.forum_id
					FROM " . TOPICS_TABLE . " t
					WHERE topic_calendar_time >= $start_date
						AND topic_calendar_time < $end_date
						AND topic_calendar_time IS NOT NULL
						AND topic_calendar_time <> 0
						$mini_cal_auth_sql";
		}
//-- fin mod : topic calendar ext ------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
                    $cal_date_replace = array(
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : topic calendar ext ----------------------------------------------------------------------
//-- add
					// let's do as if :)
					if ( MINI_CAL_MYCAL_VERSION == 'TOPIC_CALENDAR')
					{
						$row['cal_weekday']		= date('w', $row['topic_calendar_time']);
						$row['cal_month']		= date('m', $row['topic_calendar_time']);
						$row['cal_monthday']	= date('d', $row['topic_calendar_time']);
						$row['cal_year']		= date('Y', $row['topic_calendar_time']);
						$row['cal_hour']		= date('H', $row['topic_calendar_time']);
						$row['cal_min']			= date('i', $row['topic_calendar_time']);
						$row['cal_sec']			= date('s', $row['topic_calendar_time']);
					}
//-- fin mod : topic calendar ext ------------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
#
search.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : topic calendar ext ----------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
            else if ( $search_id == 'mini_cal_events' )
            {
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : topic calendar ext ----------------------------------------------------------------------
//-- add
			define('IN_MINI_CAL', 1);
			include_once($phpbb_root_path . 'mods/netclectic/mini_cal/mini_cal_config.'.$phpEx);
			if (MINI_CAL_MYCAL_VERSION != 'TOPIC_CALENDAR')
			{
//-- fin mod : topic calendar ext ------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
            }
			else
			{
				$search_author = str_replace('*', '%', trim($search_author));
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
//-- mod : topic calendar ext ----------------------------------------------------------------------
//-- add
			}
			else
			{
				$s_yy = intval(substr($search_date, 0, 4));
				$s_mm = intval(substr($search_date, 4, 2));
				$s_dd = intval(substr($search_date, 6, 2));
				$search_date = mktime(0,0,0, $s_mm, $s_dd, $s_yy);
				$nix_tomorrow  = mktime (0,0,0, $s_mm, $s_dd + 1, $s_yy);

				$sql = "SELECT topic_first_post_id as post_id
					FROM " . TOPICS_TABLE . " 
					WHERE (topic_calendar_time + topic_calendar_duration) >= $search_date AND topic_calendar_time < $nix_tomorrow";
			}
//-- fin mod : topic calendar ext ------------------------------------------------------------------
#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------------
#
# EoM