[BETA] Birthday Extension for Topic Calendar

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
daniel33
Registered User
Posts: 4
Joined: Wed Feb 04, 2004 8:34 pm

[BETA] Birthday Extension for Topic Calendar

Post by daniel33 »

It's a birthday extension for the Topic Calendar.
The Birthday Mod is requiered.
PCP is NOT requiered.

Since it looks as there is no mod for displaying birthdays on the Topic Calendar I sat down for an hour and wrote this.
It's my first mod (I never wanted to write one, but I looked two days for a right mod for me...)

It needs to be optimized - I'll do that in the next days.
But it does it's work.

Here is a link what it looks when installed: http://www.webdesign4all.biz/forum/calendar.php

Actual Version: 0.9.1
fixed: - Date Problem
- where to include the function call.

Code: Select all

############################################################## 
## MOD Title:          Birthday Extension for Topic Calender & Birthday Mod 
## MOD Author:         Flani < info@flanisoft.at >
## MOD Description:    This mod will add birthdays to your Topic Calender.
##                     You don't need the PCP for it.
## MOD Version:        0.9.1
## MOD Compatibility:  2.0.6
## 
## Requierements:      Topic Calender
##                     Birthday Mod (Niels < ncr@db9.dk > (Niels Chr. Rød) )
##
## Installation Level: Easy
## Installation Time:  3 Minutes
## Files To Edit:      2
##      includes/functions_calender.php
##      language/lang_english/lang_extend_topic_calendar.php
##
## Included Files:     0
##
############################################################## 
## 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: 
## 
## 1. Full MOD description
## -----------
## This mod, will add all members birthdays to the Topic Calender.
## You'll need Topic Calender and the Birthday Mod installed to run this Mod.
## A link leads to the users profile.
##
## 2. Official last version link
## -----------
## ??
##
## 3. Todo - Next Version
## -----------
## Optimizing.
## Read only informations out that are valid for a specific timerange
##
##
## 
############################################################## 
## MOD History:
##
##
##   2004-02-04 - Version 0.9.0
##        - initial beta
##
##   2004-02-06 - Version 0.9.1
##        - Date problem fixed
##          should now work with any dateformat
##
############################################################## 

## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
############################################################## 
# 

# 
#-----[ OPEN ]------------------------------------------------ 
# 
includes/functions_calendar.php

# 
#-----[ FIND ]------------------------------------------------ 
# 
//
// birthday (only with PCP)
//

# 
#-----[ BEVORE, ADD ]------------------------------------------ 
#


//
// Birthday Mod for Topic Calendar & Birthday Mod wihout PCP
//
function get_birthday(&$events, &$number, $start_date, $end_date, $limit=false, $start=0, $max_limit=-1)
{
	global $template, $lang, $images, $userdata, $board_config, $db, $phpbb_root_path, $phpEx;

        $sql = "SELECT u.*
		FROM " . USERS_TABLE . " AS u 
		WHERE u.user_id <> " . ANONYMOUS . " 
			AND u.user_birthday <> 999999 
		ORDER BY username";
	
	if ( !$result = $db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Could not read user table to get birthday today info', '', __LINE__, __FILE__, $sql);
	}

	// get the number of occurences
	$number = $db->sql_numrows($result);
	// if limit per page asked, limit the number of results

	// read users
	while ($row = $db->sql_fetchrow($result))
	{
		$user_id		= $row['user_id'];
		$username		= $row['username'];
                $user_birthday = realdate($lang['DATE_FORMAT'], $row['user_birthday']);

		$ignore			= $row['user_ignore'];
		$friend			= $row['user_friend'];
		$always_visible = $row['user_visible'];

		$username_link = append_sid($phpbb_root_path . "./profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$user_id");


		$event_day	= realdate('d',$row['user_birthday']);
		$event_month	= realdate('n',$row['user_birthday']);
		$event_year2	= realdate('Y',$row['user_birthday']);
		$start_month	= intval(date('m', $start_date));
		$event_year		= intval(date('Y', $start_date));
		if ($event_month < $start_month) $event_year++;
		$event_time = mktime( 0,0,0, $event_month, $event_day, $event_year );


                $tmp_message = sprintf($lang['birthday'],$username);
		$message = htmlspecialchars("<table cellspacing='1' cellpadding='2' border='0' width='100%' class='forumline'><tr><td class='row1' nowrap='nowrap'><b>".$lang['birthday_header']."</b><span class='topictitle'></span><hr /><span class='genmed'>".$tmp_message."</span></td></tr></table>");
	        $message = preg_replace("/[\n\r]{1,2}/", '', $message);

		$new_row = array();
		$new_row['event_id']				= POST_USERS_URL . $user_id;

		$new_row['event_author_id']			= $user_id;
		$new_row['event_author']			= $username;
		$new_row['event_time']				= $event_time;

		$new_row['event_last_author_id']	= '';
		$new_row['event_last_author']		= '';
		$new_row['event_last_time']			= '';

		$new_row['event_replies']			= '';
		$new_row['event_views']				= '';
		$new_row['event_type']				= POST_BIRTHDAY;
		$new_row['event_vote']				= '';
		$new_row['event_status']			= '';
		$new_row['event_moved_id']			= '';
		$new_row['event_last_id']			= '';
		$new_row['event_forum_id']			= '';
		$new_row['event_forum_name']		= '';

		$new_row['event_icon']				= '';
		$new_row['event_title']				= $username;
		$new_row['event_short_title']		= $username;
		$new_row['event_message']			= $message;
		$new_row['event_calendar_time']		= $event_time;
		$new_row['event_calendar_duration']	= '';
		$new_row['event_link']				= $username_link;
		$new_row['event_txt_class']			= $txt_class;
		$new_row['event_type_icon']			= '<img src="' . $images['icon_tiny_profile'] . '" border="0" align="absbottom" hspace="2" />';
		$events[] = $new_row;
	}
}



# 
#-----[ FIND ]------------------------------------------------ 
#  
# around line 401
#
		$message					= $row['post_text'];


# 
#-----[ REPLACE WITH ]------------------------------------------------ 
# 
		$message					= htmlspecialchars($row['post_text']);




# 
#-----[ FIND ]------------------------------------------------ 
#  

	get_event_PCP_birthday($events, $number, $start_date, $end_date);

# 
#-----[ AFTER, ADD ]------------------------------------------------ 
# 

        get_birthday($events, $number, $start_date, $end_date);


# 
#-----[ OPEN ]------------------------------------------------ 
#
# do the same with all other languages you've installed
# 
language/lang_english/lang_extend_topic_calendar.php

# 
#-----[ FIND ]------------------------------------------------ 
# 

?>

# 
#-----[ BEFORE, ADD ]----------------------------------------- 
#

$lang['birthday_header']	= 'Happy Birthday!';
$lang['birthday']	= '<b>%s</b> has birthday today!';

# 
#-----[ SAVE/CLOSE ALL FILES ]-------------------------------- 
# 
# EoM
Last edited by daniel33 on Fri Feb 06, 2004 8:30 pm, edited 1 time in total.
User avatar
Vampy
Registered User
Posts: 140
Joined: Mon May 12, 2003 4:25 pm

Post by Vampy »

Great! I've been waiting for this mod for a long time. I'll try it out the first chance I have. Will let you know.
Julian
chadsmith
Registered User
Posts: 261
Joined: Sat Jul 13, 2002 4:54 pm
Location: 67212
Contact:

Post by chadsmith »

I was afraid I would have to rewrite the one I had for myCalendar. Thanks!
Probably the toughest time in anyone's life is when you have to murder a loved one because they're the devil.
madnessmotors
Registered User
Posts: 269
Joined: Sun Aug 17, 2003 7:33 pm
Contact:

Post by madnessmotors »

What's the difference between Topic Calendar and myCaldendar?
gurukast
Registered User
Posts: 230
Joined: Fri Aug 29, 2003 4:13 pm

Post by gurukast »

okay.. i'm lost
added this in..how to make it display?

i.e how do i trigger that... call birthday part?
Image
gurukast
Registered User
Posts: 230
Joined: Fri Aug 29, 2003 4:13 pm

Post by gurukast »

I put

Code: Select all

	// NO PCP
	get_birthday($events, $number, $start_date, $end_date);

	// birthday
	get_event_PCP_birthday($events, $number, $start_date, $end_date);
as well as

Code: Select all

get_event_PCP_birthday($events, $number, $month_start, $month_end);
get_birthday($events, $number, $month_start, $month_end);
get_event_topics($events, $number, $month_start, $month_end, false, 0, -1, $fid);
in the scheduler...no go
Image
gurukast
Registered User
Posts: 230
Joined: Fri Aug 29, 2003 4:13 pm

Post by gurukast »

okay you wern't kidding :) slow for real lol
is there anyway to mod this to like..run thrugh the members and add thier birthdays as events? So basically you run it once in a while, to update and add new members..
pehraps a mod on the prifile form so when it changes.. it updates..
Image
User avatar
Ptirhiik
Registered User
Posts: 7411
Joined: Mon Jan 06, 2003 10:36 pm
Contact:

Post by Ptirhiik »

Advice : add a new field to the users table, and translate once for all users the birthday date into a flat format (AAAAMMDD) : this has to be done on user editing and registering (usercp_register/admin_users), and you will have to write a little tool to initiate this fields for existing users (to run once, should be similar for a large part to the migration tool delivered with the PCP). This is the only way I figure to avoid a too high sql/php ressource consumption. Although it is a duplication of data, it will improve drasticely the process. You will also be able to use a copy of the today PCP process (the PCP stores its date onto AAAAMMJJ format).
gurukast
Registered User
Posts: 230
Joined: Fri Aug 29, 2003 4:13 pm

Post by gurukast »

Ptirhiik - RPGnet-fr wrote: Advice : add a new field to the users table, and translate once for all users the birthday date into a flat format (AAAAMMDD) : this has to be done on user editing and registering (usercp_register/admin_users), and you will have to write a little tool to initiate this fields for existing users (to run once, should be similar for a large part to the migration tool delivered with the PCP). This is the only way I figure to avoid a too high sql/php ressource consumption. Although it is a duplication of data, it will improve drasticely the process. You will also be able to use a copy of the today PCP process (the PCP stores its date onto AAAAMMJJ format).


Thanks a lot man.. i was now thinking of an altenative way of storing the bdays. I reaaly would like to migrate to your excellant PCP.. but the number of mods i have installed makes the task ardous.

One method I am thinking of doing is to create another directory..like../forumnew and start with a fresh verion of phpbb using the existing tables and install all the various mods in a proper order one night...then rename forumnew to forum....
Image
User avatar
Ptirhiik
Registered User
Posts: 7411
Joined: Mon Jan 06, 2003 10:36 pm
Contact:

Post by Ptirhiik »

Take the time to have a look to this post, especially on the part regarding local environement :).
daniel33
Registered User
Posts: 4
Joined: Wed Feb 04, 2004 8:34 pm

Post by daniel33 »

It seems as this mod will only work with the european date format.
(dd.mm.yy)

I'll have a look on the code and fix it in the next days!
daniel33
Registered User
Posts: 4
Joined: Wed Feb 04, 2004 8:34 pm

Post by daniel33 »

I fixed the date problem and added to the description where to include the "function call" for get_birthday.

See first post in this topic for the latest version.
gurukast
Registered User
Posts: 230
Joined: Fri Aug 29, 2003 4:13 pm

Post by gurukast »

gurukast wrote:
Ptirhiik - RPGnet-fr wrote:Advice : add a new field to the users table, and translate once for all users the birthday date into a flat format (AAAAMMDD) : this has to be done on user editing and registering (usercp_register/admin_users), and you will have to write a little tool to initiate this fields for existing users (to run once, should be similar for a large part to the migration tool delivered with the PCP). This is the only way I figure to avoid a too high sql/php ressource consumption. Although it is a duplication of data, it will improve drasticely the process. You will also be able to use a copy of the today PCP process (the PCP stores its date onto AAAAMMJJ format).


Thanks a lot man.. i was now thinking of an altenative way of storing the bdays. I reaaly would like to migrate to your excellant PCP.. but the number of mods i have installed makes the task ardous.

One method I am thinking of doing is to create another directory..like../forumnew and start with a fresh verion of phpbb using the existing tables and install all the various mods in a proper order one night...then rename forumnew to forum....


I hacked another field inside.. user_pcp_birthday and you're right.. its amazingly fast! One weekend i am going to have to sit down and convert entirely across to PCP..or complety convert my birthday handling routines..

Ptirhiik :: - we're not worthy! :mrgreen:
Image
User avatar
Vampy
Registered User
Posts: 140
Joined: Mon May 12, 2003 4:25 pm

Post by Vampy »

I was wondering if this mod could be extended to do the following. It would be great if not only does it display the birthday of the user on the calendar but it will create a new topic when the user's birthday is in x number of days time. The topic would be to wish the user a happy birthday and so that other users can also wish that user a happy birthday as well. I was also thinking that instead of creating one topic for every birthday guy/gal maybe it will look into compiling a list of the users where the borthday is with say a week and post a single topic with all the users names and wish them a happy birthday.

I dunno if this could be done or whether this would slow the forum down. Can someone comment on this? I will try my hand at it and see if I can do it. Thanks.
Julian
daniel33
Registered User
Posts: 4
Joined: Wed Feb 04, 2004 8:34 pm

Post by daniel33 »

From the technical side it's not so a big Problem.
But I think that most admins don't want that.

If you have +1000 registered Users you'll have about 3 birthdays a day. That are 3 topics/threads a day extra.

But let's hear what other people think.
Post Reply

Return to “[2.0.x] MODs in Development”