MOD download & history

Mod that adds a birthday field to the users profile, theire age are displayed beside the posts, and on there birthday they will have a greeting popup
Forum rules
The content in this forum is dated Dec. 21 2005 and can be used as Archive only. This Forum is LOCKED and READ ONLY !

Postby Niels on Fri 27. Sep, 2002 09:58

in PART 2 version 1.2.0, it was not posible for admin to manually change the next birthday popup year, the mod was supposed to allow this
this is now corrected in the new PART 2 version 1.2.1.

here are how to upgrade:

in file admin_users.php

Code: Select all
[FIND]
$birthday = ( !empty($HTTP_POST_VARS['birthday']) ) ? trim(strip_tags( $HTTP_POST_VARS['birthday'] ) ) : '';

[AFTER, ADD]
$next_birthday_greeting = ( !empty($HTTP_POST_VARS['next_birthday_greeting']) ) ? intval( $HTTP_POST_VARS['next_birthday_greeting'] ) : 0;
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

Postby Niels on Wed 30. Oct, 2002 19:33

to avoid using the same variables as some other mods, I have changed the variable name $year into $birth_year in the how-to, a user did reported that this variable name was also used by anoter mod
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

Postby Niels on Tue 19. Nov, 2002 22:20

On request I have upgraded this mod, so you now as admin can deside if the input box should be a drop down box, or a regular text box
new version is 1.3.0 PART 1

You decide witch type of code to include into the template, therefor different templates can behaive differently.

her are how to upgrade
in file lang_main.php
Code: Select all
[FIND]
$lang ['Nobirthday_today']='No users have a birthday today';

[AFTER, ADD]
$lang['Year'] = 'Year';
$lang['Month'] = 'Month';
$lang['Day'] = 'Day';


in file usercp_register.php
Code: Select all
[FIND]
$signature = str_replace('<br />', "\n", $signature);

[AFTER, AD]
$b_day = ( isset($HTTP_POST_VARS['b_day']) ) ? intval ($HTTP_POST_VARS['b_day']) : 0;
$b_md = ( isset($HTTP_POST_VARS['b_md']) ) ? intval ($HTTP_POST_VARS['b_md']) : 0;
$b_year = ( isset($HTTP_POST_VARS['b_year']) ) ? intval ($HTTP_POST_VARS['b_year']) : 0;


[FIND]
// find the birthday values, reflected by the $lang['Submit_date_format']

[AFTER, ADD]
if ($b_day || $b_md || $b_year) //if a birthday is submited, then validate it
{
      $user_age=(date('md')>=$b_md.$b_day) ? date('Y') - $b_year : date('Y') - $b_year - 1 ;
      // Check maximum user age
      if ($user_age>$board_config['max_user_age']) $b_md=13  ;
      // Check minimum user age
      if ($user_age<$board_config['min_user_age']) $b_md=13  ;
      if (!checkdate($b_md,$b_day,$b_year))
      {
         $error = TRUE;
         if( isset($error_msg) )$error_msg .= "<br />";
         $error_msg .= $lang['Wrong_birthday_format'];
      } else
      {
         $birthday = ($error) ? $birthday : mkrealdate($b_day,$b_md,$b_year);
         $next_birthday_greeting = (date('md')<$b_md.$b_day) ? date('Y'):date('Y')+1 ;
      }
} else

[FIND]
$interests = htmlspecialchars($userdata['user_interests']);

[AFTER, ADD]
$b_day = ($userdata['user_birthday']!=999999) ? realdate('d',$userdata['user_birthday']):'';
$b_md = ($userdata['user_birthday']!=999999) ? realdate('m',$userdata['user_birthday']):'';
$b_year = ($userdata['user_birthday']!=999999) ? realdate('Y',$userdata['user_birthday']):'';


[FIND]
if ( $mode == 'editprofile' )
{
   $template->assign_block_vars('switch_edit_profile', array());
}

[BEFORE, ADD]
$s_b_day = $lang['Day'].'&nbsp;<select name="b_day" size="1" class="gensmall" size="1">
   <option value="0"'.(($b_day==0)?'SELECTED':'').'>&nbsp;-&nbsp;</option>
   <option value="1"'.(($b_day==1)?'SELECTED':'').'>&nbsp;1&nbsp;</option>
   <option value="2"'.(($b_day==2)?'SELECTED':'').'>&nbsp;2&nbsp;</option>
   <option value="3"'.(($b_day==3)?'SELECTED':'').'>&nbsp;3&nbsp;</option>
   <option value="4"'.(($b_day==4)?'SELECTED':'').'>&nbsp;4&nbsp;</option>
   <option value="5"'.(($b_day==5)?'SELECTED':'').'>&nbsp;5&nbsp;</option>
   <option value="6"'.(($b_day==6)?'SELECTED':'').'>&nbsp;6&nbsp;</option>
   <option value="7"'.(($b_day==7)?'SELECTED':'').'>&nbsp;7</option>
   <option value="8"'.(($b_day==8)?'SELECTED':'').'>&nbsp;8</option>
   <option value="9"'.(($b_day==9)?'SELECTED':'').'>&nbsp;9</option>
   <option value="10"'.(($b_day==10)?'SELECTED':'').'>&nbsp;10</option>
   <option value="11"'.(($b_day==11)?'SELECTED':'').'>&nbsp;11&nbsp;</option>
   <option value="12"'.(($b_day==12)?'SELECTED':'').'>&nbsp;12&nbsp;</option>
   <option value="13"'.(($b_day==13)?'SELECTED':'').'>&nbsp;13&nbsp;</option>
   <option value="14"'.(($b_day==14)?'SELECTED':'').'>&nbsp;14&nbsp;</option>
   <option value="15"'.(($b_day==15)?'SELECTED':'').'>&nbsp;15&nbsp;</option>
   <option value="16"'.(($b_day==16)?'SELECTED':'').'>&nbsp;16&nbsp;</option>
   <option value="17"'.(($b_day==17)?'SELECTED':'').'>&nbsp;17</option>
   <option value="18"'.(($b_day==18)?'SELECTED':'').'>&nbsp;18</option>
   <option value="19"'.(($b_day==19)?'SELECTED':'').'>&nbsp;19</option>
   <option value="20"'.(($b_day==20)?'SELECTED':'').'>&nbsp;20</option>
   <option value="21"'.(($b_day==21)?'SELECTED':'').'>&nbsp;21&nbsp;</option>
   <option value="22"'.(($b_day==22)?'SELECTED':'').'>&nbsp;22&nbsp;</option>
   <option value="23"'.(($b_day==23)?'SELECTED':'').'>&nbsp;23&nbsp;</option>
   <option value="24"'.(($b_day==24)?'SELECTED':'').'>&nbsp;24&nbsp;</option>
   <option value="25"'.(($b_day==25)?'SELECTED':'').'>&nbsp;25&nbsp;</option>
   <option value="26"'.(($b_day==26)?'SELECTED':'').'>&nbsp;26&nbsp;</option>
   <option value="27"'.(($b_day==27)?'SELECTED':'').'>&nbsp;27</option>
   <option value="28"'.(($b_day==28)?'SELECTED':'').'>&nbsp;28</option>
   <option value="29"'.(($b_day==29)?'SELECTED':'').'>&nbsp;29</option>
   <option value="30"'.(($b_day==30)?'SELECTED':'').'>&nbsp;30</option>
   <option value="31"'.(($b_day==31)?'SELECTED':'').'>&nbsp;31</option>
     </select>&nbsp;&nbsp;';
$s_b_md = $lang['Month'].'&nbsp;<select name="b_md" size="1" class="gensmall" size="1"}">
   <option value="0"'.(($b_day==0)?'SELECTED':'').'>&nbsp;-&nbsp;</option>
   <option value="1"'.(($b_md==1)?'SELECTED':'').'>&nbsp;1&nbsp;</option>
   <option value="2"'.(($b_md==2)?'SELECTED':'').'>&nbsp;2&nbsp;</option>
   <option value="3"'.(($b_md==3)?'SELECTED':'').'>&nbsp;3&nbsp;</option>
   <option value="4"'.(($b_md==4)?'SELECTED':'').'>&nbsp;4&nbsp;</option>
   <option value="5"'.(($b_md==5)?'SELECTED':'').'>&nbsp;5&nbsp;</option>
   <option value="6"'.(($b_md==6)?'SELECTED':'').'>&nbsp;6&nbsp;</option>
   <option value="7"'.(($b_md==7)?'SELECTED':'').'>&nbsp;7</option>
   <option value="8"'.(($b_md==8)?'SELECTED':'').'>&nbsp;8</option>
   <option value="9"'.(($b_md==9)?'SELECTED':'').'>&nbsp;9</option>
   <option value="10"'.(($b_md==10)?'SELECTED':'').'>&nbsp;10</option>
   <option value="11"'.(($b_md==11)?'SELECTED':'').'>&nbsp;11</option>
   <option value="12"'.(($b_md==12)?'SELECTED':'').'>&nbsp;12</option>
     </select>&nbsp;&nbsp;';
$s_b_year = $lang['Year'].'&nbsp;<input type="text" class="post"style="width: 80px"  name="b_year" size="4" maxlength="4" value="'.$b_year.'" />&nbsp;&nbsp; ';
$i=0;
$s_birthday='';
for ($i=0;$i<=strlen($lang['Submit_date_format']);$i++)
{
   switch ($lang['Submit_date_format'][$i])
      {
          case d:  $s_birthday .=$s_b_day;break;
           case m:  $s_birthday .=$s_b_md;break;
         case Y:  $s_birthday .=$s_b_year;break;
      }
}

[FIND]
'BIRTHDAY' => $birthday,

[REPLACE WITH]
'S_BIRTHDAY' => $s_birthday,




In your template, you may choise if you would like a drop down, or a regular text box, here are showen how the to types should look in subsilver template

in file profile_add_body.tpl
Regular text box
Code: Select all
<tr>
   <td class="row1"><span class="gen">{L_BIRTHDAY}:</span><br /><span class="gensmall">{L_BIRTHDAY_EXPLAIN}<br /></span></td>
   <td class="row2"><input type="text" class="post"style="width: 80px"  name="birthday" size="10" maxlength="10" value="{BIRTHDAY}" /></td>
</tr>

Drop down box
Code: Select all
<tr>
   <td class="row1"><span class="gen">{L_BIRTHDAY}:</span></td>
   <td class="row2"><span class="gensmall">{S_BIRTHDAY}</span></td>
</tr>
[/code]
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

Postby Niels on Wed 20. Nov, 2002 21:45

A minor bug, have been found in this mod, only showen if birthday look farward was set to "0"

here are how to upgrade part 1 to version 1.3.1

in file index.php
Code: Select all
[FIND]
if (!empty($birthdayrow))

[REPLACE WITH]
if (!empty($birthdayrow) && $board_config['birthday_check_day'])

[FIND]
'L_WHOSBIRTHDAY_WEEK' => sprintf((($birthday_week_list)? $lang ['Birthday_week'].$birthday_week_list:$lang ['Nobirthday_week']),$board_config['birthday_check_day']),
'L_WHOSBIRTHDAY_TODAY' =>($birthday_today_list&&$board_config['birthday_check_day'])? $lang ['Birthday_today'].$birthday_today_list:$lang ['Nobirthday_today'],


[REPLACE WITH]
'L_WHOSBIRTHDAY_WEEK' => ($board_config['birthday_check_day']>1) ? sprintf((($birthday_week_list)? $lang ['Birthday_week'].$birthday_week_list:$lang ['Nobirthday_week']),$board_config['birthday_check_day']) : '',
'L_WHOSBIRTHDAY_TODAY' =>($board_config['birthday_check_day']) ?($birthday_today_list)? $lang ['Birthday_today'].$birthday_today_list:$lang ['Nobirthday_today'] : '',
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

Postby Niels on Sun 01. Dec, 2002 16:41

I have got some reports about difficultes in the lates how-to, and apperently there was some mistakes introduced in ver 1.3.0, witch this upgrade instruction hopefully will correct :)
new version is 1.3.3.

in file usercp_register.php
Code: Select all
[FIND]
$interests = htmlspecialchars(stripslashes($interests));
$b_day = ($userdata['user_birthday']!=999999) ? realdate('d',$userdata['user_birthday']):'';
$b_md = ($userdata['user_birthday']!=999999) ? realdate('m',$userdata['user_birthday']):'';
$b_year = ($userdata['user_birthday']!=999999) ? realdate('Y',$userdata['user_birthday']):'';

[REPLACE WITH]
$interests = htmlspecialchars(stripslashes($interests));

[FIND]
$birthday = ($userdata['user_birthday']!=999999) ? realdate($lang['Submit_date_format'],$userdata['user_birthday']):'';

[AFTER, ADD]
$b_day = ($userdata['user_birthday']!=999999) ? realdate('d',$userdata['user_birthday']):'';
$b_md = ($userdata['user_birthday']!=999999) ? realdate('m',$userdata['user_birthday']):'';
$b_year = ($userdata['user_birthday']!=999999) ? realdate('Y',$userdata['user_birthday']):'';

[FIND]
// find the birthday values, reflected by the $lang['Submit_date_format']
if ($b_day || $b_md || $b_year) //if a birthday is submited, then validate it
{
.
.
all code between
.
.
.
} else $birthday = ($error) ? '' : 999999;

[REPLACE WITH]
// find the birthday values, reflected by the $lang['Submit_date_format']
if ($b_day || $b_md || $b_year) //if a birthday is submited, then validate it
{
      $user_age=(date('md')>=$b_md.$b_day) ? date('Y') - $b_year : date('Y') - $b_year - 1 ;
      // Check date, mximum / minimum user age
      if (!checkdate($b_md,$b_day,$b_year)|| $user_age>$board_config['max_user_age'] ||$user_age<$board_config['min_user_age'])
      {
         $error = TRUE;
         if( isset($error_msg) )$error_msg .= "<br />";
         $error_msg .= $lang['Wrong_birthday_format'];
      } else
      {
         $birthday = ($error) ? $birthday : mkrealdate($b_day,$b_md,$b_year);
         $next_birthday_greeting = (date('md')<$b_md.$b_day) ? date('Y'):date('Y')+1 ;
      }
} else
if ($birthday  || !$board_config['min_user_age']) //if a birthday is submited, then validate it
{
   for ($i=0;$i<=strlen($lang['Submit_date_format']);$i++)
   {
      switch ($lang['Submit_date_format'][$i])
      {
        case d:   $day=$birthday_lengt;$date_count++;
         $birthday_lengt++;break;
        case m:   $md=$birthday_lengt;$date_count++;
         $birthday_lengt++;break;
       case Y:   $year=$birthday_lengt;$date_count++;
         $birthday_lengt=$birthday_lengt+3;break;
      }
      $birthday_lengt++;
   }
   // did we find both day,month and year
   if ($date_count<3)
   {
      $error = TRUE;
      if( isset($error_msg) )$error_msg .= "<br />";
      $error_msg .= $lang['Wrong_birthday_format'];
   } else
   {
      $day=$birthday[$day].$birthday[$day+1];
      $md=$birthday[$md].$birthday[$md+1];
      $year=$birthday[$year].$birthday[$year+1].$birthday[$year+2].$birthday[$year+3];
      $user_age=(date('md')>=$md.$day) ? date('Y') - $year : date('Y') - $year - 1 ;
     // Check date, mximum / minimum user age
      if (!checkdate($md,$day,$year) || $user_age<$board_config['min_user_age'] || $user_age>$board_config['max_user_age'])
      {
         $error = TRUE;
         if( isset($error_msg) )$error_msg .= "<br />";
         $error_msg .= $lang['Wrong_birthday_format'];
      } else
      {
         $birthday = ($error) ? $birthday : mkrealdate($day,$md,$year);
         $next_birthday_greeting = (date('md')<$md.$day) ? date('Y'):date('Y')+1 ;
      }
   }   
} else $birthday = ($error) ? '' : 999999;
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

Postby Niels on Tue 10. Dec, 2002 16:08

the dates was not calculated rigth, on 31 dec. in a leap year after 1970

I have updated this mod's PART 1
new version is 1.3.4

here are how to upgrade
in file functions.php
Code: Select all
[FIND]
      while ($date_mid>364)
      {
         $date_mid=$date_mid-365;
         $birth_year++;
         if ($i==3)
         {
            $i=0;
            if ($date_mid>365)
            {
               $date_mid--;
            }
         } else $i++;
      }
   } else if ($date<0)
   {
      while ($date_mid<0)
      {
         $birth_year--;
         $date_mid=$date_mid+365;
         if ($i==3)
         {
            $i=0;
            $date_mid++;
         } else $i++;
      }
   }
   $days=$days+$date_mid;

[REPLACE WITH]
   while ($date_mid > 364)
       {
      $year++;      
      $date_mid-=365;    
      if ($i++==3)
      {
         $i=0;
         $date_mid--;
      }
   }
   if (date_mid<=0 && $i==0)
   {
      $date_mid++;
   }
   } else
   {
      while ($date_mid<0)
      {
         $year--;
         $date_mid+=365;
         if ($i++==3)
         {
            $i=0;
            $date_mid++;
         }
      }
   }
   $days=$date_mid;
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

Postby Niels on Wed 11. Dec, 2002 02:38

there was a typo in PART 1 version 1.3.2. -> 1.3.4
to correct this, ONLY users installed those versions should do this

in file page_header.php
Code: Select all
[FIND]
'U_GREETING_POPUP' => append_sid('privmsg.'.$phpEx.'?mode=birthday'),

[REPLACE WITH]
'U_GREETING_POPUP' => append_sid('birthday_popup.'.$phpEx),
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

upgrade

Postby Niels on Mon 16. Dec, 2002 14:53

weaselweb have come up with a improvement, witch I have now included into the PART 1 of this mod
new version is PART 1 1.3.6.
to upgrade
in file usercp_register.php
Code: Select all
[FIND]
$s_b_md = $lang['Month'].'&nbsp;<select name="b_md" size="1" class="gensmall" size="1"}">
   <option value="0"'.(($b_day==0)?'SELECTED':'').'>&nbsp;-&nbsp;</option>
   <option value="1"'.(($b_md==1)?'SELECTED':'').'>&nbsp;1&nbsp;</option>
   <option value="2"'.(($b_md==2)?'SELECTED':'').'>&nbsp;2&nbsp;</option>
   <option value="3"'.(($b_md==3)?'SELECTED':'').'>&nbsp;3&nbsp;</option>
   <option value="4"'.(($b_md==4)?'SELECTED':'').'>&nbsp;4&nbsp;</option>
   <option value="5"'.(($b_md==5)?'SELECTED':'').'>&nbsp;5&nbsp;</option>
   <option value="6"'.(($b_md==6)?'SELECTED':'').'>&nbsp;6&nbsp;</option>
   <option value="7"'.(($b_md==7)?'SELECTED':'').'>&nbsp;7</option>
   <option value="8"'.(($b_md==8)?'SELECTED':'').'>&nbsp;8</option>
   <option value="9"'.(($b_md==9)?'SELECTED':'').'>&nbsp;9</option>
   <option value="10"'.(($b_md==10)?'SELECTED':'').'>&nbsp;10</option>
   <option value="11"'.(($b_md==11)?'SELECTED':'').'>&nbsp;11</option>
   <option value="12"'.(($b_md==12)?'SELECTED':'').'>&nbsp;12</option>
     </select>&nbsp;&nbsp;';

[REPLACE WITH]
$s_b_md = $lang['Month'].'&nbsp;<select name="b_md" size="1" class="gensmall" size="1"}">
<option value="0" '.(($b_day==0)?'SELECTED':'').'>&nbsp;-&nbsp;</option>
<option value="1" '.(($b_md==1)?'SELECTED':'').'>&nbsp;'.$lang['datetime']['January'].'&nbsp;</option>
<option value="2" '.(($b_md==2)?'SELECTED':'').'>&nbsp;'.$lang['datetime']['February'].'&nbsp;</option>
<option value="3" '.(($b_md==3)?'SELECTED':'').'>&nbsp;'.$lang['datetime']['March'].'&nbsp;</option>
<option value="4" '.(($b_md==4)?'SELECTED':'').'>&nbsp;'.$lang['datetime']['April'].'&nbsp;</option>
<option value="5" '.(($b_md==5)?'SELECTED':'').'>&nbsp;'.$lang['datetime']['May'].'&nbsp;</option>
<option value="6" '.(($b_md==6)?'SELECTED':'').'>&nbsp;'.$lang['datetime']['June'].'&nbsp;</option>
<option value="7" '.(($b_md==7)?'SELECTED':'').'>&nbsp;'.$lang['datetime']['July'].'</option>
<option value="8" '.(($b_md==8)?'SELECTED':'').'>&nbsp;'.$lang['datetime']['August'].'</option>
<option value="9" '.(($b_md==9)?'SELECTED':'').'>&nbsp;'.$lang['datetime']['September'].'</option>
<option value="10" '.(($b_md==10)?'SELECTED':'').'>&nbsp;'.$lang['datetime']['October'].'</option>
<option value="11" '.(($b_md==11)?'SELECTED':'').'>&nbsp;'.$lang['datetime']['November'].'</option>
<option value="12" '.(($b_md==12)?'SELECTED':'').'>&nbsp;'.$lang['datetime']['December'].'</option>
</select>&nbsp;&nbsp;';
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

PreviousNext

Return to Birthday [2.0.10/EM]

Who is online

Users browsing this forum: No registered users and 1 guest

cron