[SOLUTION] Birthyear not mandatory anymore

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 Gadget Wizard on Tue 02. Aug, 2005 15:23

easygo,

Are you saying that we should assign a constant to the year field if left blank and just keep it from displaying the age/year when we see the constant?

That way, users who actually enter a valid year will be able to see their age.

That sound kinda like to approach I was thinking of. We would need to circumvent the validity check on the year...
Gadget Wizard
Image
Gadget Wizard
Poster
Poster
 
Posts: 8
Joined: Tue 02. Aug, 2005 12:46

Postby kimberlyteed on Tue 02. Aug, 2005 16:12

A constant? ... so then they would be some preassigned age? If so, make it computer/silly like age: 404 ... but then every year they would age, so it would only be silly the first year :?
Web Site Designer + Host
my board > http://www.kimberlyteed.com/213
... always an original design, never a template :)
kimberlyteed
Poster
Poster
 
Posts: 10
Joined: Thu 16. Jun, 2005 17:43

Postby Gadget Wizard on Tue 02. Aug, 2005 16:37

You do a => check on a large constant.

That is just a thought, but I'm putting the cart way ahead of the horse. Need to look at the code in more detail first. There is a language/communication barrier here that I'm having a hard time with. 8)

I'm kinda surprised that this hasn't been done before. :?:
Gadget Wizard
Image
Gadget Wizard
Poster
Poster
 
Posts: 8
Joined: Tue 02. Aug, 2005 12:46

Postby easygo on Tue 02. Aug, 2005 21:15

Gadget Wizard wrote:easygo,

Are you saying that we should assign a constant to the year field if left blank and just keep it from displaying the age/year when we see the constant?

A constant like 1977, 1988, ... you know

easygo wrote:In addition remove the display of the age inside relevant files

... generally! Hope that makes it clear enough.

greetz :wink: easy
Here we go ^^
Image
easygo
Poster
Poster
 
Posts: 44
Joined: Tue 02. Nov, 2004 17:03

Hide Age: Addon to Birthday Mod 1.5.7

Postby Gadget Wizard on Wed 03. Aug, 2005 18:38

After looking at the code a little more. The best method was to create another field in the user table so each user could selectively hide their age if they wish.

This is beta code so make sure you BACKUP all files and the database before you attempt the mod. I can assume no liability for anyone failing to do so!!

Here is a beta version of the addon.

EDIT: See below or download latest version here

Here is the original birthday_db_update.php that Niels provided with code to add the additional field included.

You can run this again without any problems. Fields that are already included in the table will be ignored.

Code: Select all
<?php
#########################################################
## SQL commands to phpBB2
## Author: Niels Chr. Rød
## Nickname: Niels Chr. Denmark
## Email: ncr@db9.dk
##
## Ver 1.0.7
##
## phpBB2 database update script for mods
## this file is intended to use with phpBB2, when installing mods
## after so you may delete this file, but only admin can use so it really doesen't matter
## The script will look what prefix you are using, and use the existing DB defined by congig.php
## The execution of this script's included SQL is harmless, so you can run it as meny times you like
## note, though that the users last visit, will be set back to his/her last login,
## but that is a minor cosmetic isue, that will correct it self next time the use  logs in
##
## the following example are from my mods, and you can add some self, for other mods if you like
## you will after execution get a list over those commands that are run with succes and those with warnings !
## delete the sample lines if you are using it only for other mods
##
#########################################################

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'includes/functions_selects.'.$phpEx);
define('SITE_HISTORY_TABLE', $table_prefix.'site_history');

###################################################################################################
##
## put the SQL commands below here, the SQL commands listed below are only exampels, substitude them with the one you need ##
##
###################################################################################################
$sql=array(
'ALTER TABLE '.USERS_TABLE.' ADD user_age_flag INT DEFAULT "0" not null ',
'ALTER TABLE '.USERS_TABLE.' ADD user_birthday INT DEFAULT "999999" not null  ',
'ALTER TABLE '.USERS_TABLE.' ADD user_next_birthday_greeting INT DEFAULT "0" not null ',
'INSERT INTO '.CONFIG_TABLE.' (config_name, config_value) VALUES ("birthday_required", "0")',
'INSERT INTO '.CONFIG_TABLE.' (config_name, config_value) VALUES ("birthday_greeting", "1")',
'INSERT INTO '.CONFIG_TABLE.' (config_name, config_value) VALUES ("max_user_age", "100")',
'INSERT INTO '.CONFIG_TABLE.' (config_name, config_value) VALUES ("min_user_age", "5")',
'INSERT INTO '.CONFIG_TABLE.' (config_name, config_value) VALUES ("birthday_check_day", "7")'
);


$mods = array (
'Birthday PART 1 Mod','Birthday PART 1 Mod','Birthday PART 1 Mod','Birthday PART 2 Mod','Birthday PART 2 Mod','Birthday PART 2 Mod','Birthday PART 2 Mod','Birthday PART 2 Mod',
);

############################################### Do not change anything below this line #######################################

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//

if ($userdata['user_level']!=ADMIN)
      message_die(GENERAL_ERROR, "You are not Authorised to do this");
$n=0;
$message="<b>This list is a result of the SQL queries needed for the additional mods in the pre-moded pack</b><br/><br/>";
while($sql[$n])
{
   $message .= ($mods[$n-1] != $mods[$n]) ? '<p><b><font size=3>'.$mods[$n].'</font></b><br/>' : '';
   if(!$result = $db->sql_query($sql[$n]))
   $message .= '<b><font color=#FF0000>[Already added]</font></b> line: '.($n+1).' , '.$sql[$n].'<br />';
   else $message .='<b><font color=#0000fF>[Added/Updated]</font></b> line: '.($n+1).' , '.$sql[$n].'<br />';
   $n++;
}
message_die(GENERAL_MESSAGE, $message);
?>
Last edited by Gadget Wizard on Thu 04. Aug, 2005 06:38, edited 1 time in total.
Gadget Wizard
Image
Gadget Wizard
Poster
Poster
 
Posts: 8
Joined: Tue 02. Aug, 2005 12:46

Postby Beeveer on Wed 03. Aug, 2005 20:36

I'll make a sticky of this topic, and make it easymod compatible for you ;)

EDIT: Stupid mod editor, replaced the name

Code: Select all
## EasyMod compliant
##############################################################
## MOD Title: Hide Age: Addon to Birthday Mod
## MOD Author: Gadget Wizard < gadgetwizard@upstateforums.com > (N/A) http://www.upstateforums.com
## MOD Description: This addon will create an option in the user's control
##                  panel that allows users to hide their age. With this option
##                  on, only the month and day will be shown when viewing
##                  a user's profile and the age will no longer appear under
##                  the avatar or in the birthday list.
## MOD Version: 0.9.0
##
## Installation Level: Intermediate
## Installation Time: 30 min
## Files To Edit: (9)
##                  index.php
##                  viewtopic.php
##                  admin/admin_users.php
##                  includes/usercp_avatar.php
##                  includes/usercp_register.php 
##                  includes/usercp_viewprofile.php
##                  language/lang_english/lang_main.php   
##                  templates/subSilver/profile_add_body.tpl
##                  templates/subSilver/admin/user_edit_body.tpl
## Included Files: (N/A)
## License: http://opensource.org/licenses/gpl-license.php GNU Public License v2
##############################################################
## For security purposes, please check: http://www.phpbb.com/mods/
## for the latest version of this MOD. Although MODs are checked
## before being allowed in the MODs Database there is no guarantee
## that there are no security problems within the MOD. No support
## will be given for MODs not found within the MODs Database which
## can be found at http://www.phpbb.com/mods/
##############################################################
## MOD History:
##
##   2005-08-03  -  Version 0.9.0
##      - First beta version created
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ SQL ]------------------------------------------
#

ALTER TABLE phpbb_users ADD 'user_age_flag' INT DEFAULT "0" NOT NULL;

#
#-----[ OPEN ]------------------------------------------
#

index.php

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

$sql = ($board_config['birthday_check_day'])

#
#-----[ IN-LINE FIND ]------------------------------------------
#

, user_birthday

#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#

, user_age_flag = '$age_flag'

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

switch ($birthdayrow['user_level'])

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

if ($birthdayrow['user_age_flag']) $user_age= 'xx';

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

switch ($birthdayrow['user_level'])

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

if ($birthdayrow['user_age_flag']) $user_age= 'xx';

#
#-----[ OPEN ]------------------------------------------
#

viewtopic.php

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

$sql = "SELECT u.username, u.user_id, u.user_posts,

#
#-----[ IN-LINE FIND ]------------------------------------------
#

, u.user_allowsmile

#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#

, u.user_age_flag

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

$poster_age = $lang['Age'] . ': ' . $poster_age;

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

if ($postrow[$i]['user_age_flag']) $poster_age= '';

#
#-----[ OPEN ]------------------------------------------
#

admin/admin_users.php

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

$interests = ( !empty($HTTP_POST_VARS['interests']) ) ? trim(strip_tags( $HTTP_POST_VARS['interests'] ) ) : '';

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

$age_flag = ( isset( $HTTP_POST_VARS['age_flag']) ) ? ( ( $HTTP_POST_VARS['age_flag'] ) ? TRUE : 0 ) : 0;

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

$sql = "UPDATE " . USERS_TABLE . "

#
#-----[ IN-LINE FIND ]------------------------------------------
#

$interests) . "'

#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#

, user_age_flag = '$age_flag'

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

$interests = htmlspecialchars($this_userdata['user_interests']);

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

$age_flag = $this_userdata['user_age_flag'];

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

$s_hidden_fields .= '<input type="hidden" name="interests" value="' . str_replace("\"", "&quot;", $interests) . '" />';

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

$s_hidden_fields .= '<input type="hidden" name="age_flag" value="' . $age_flag . '" />';

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

'INTERESTS' => $interests,

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

'AGE_FLAG_YES' => ( $age_flag ) ? 'checked="checked"' : '',
'AGE_FLAG_NO' => ( !$age_flag ) ? 'checked="checked"' : '',
'L_AGE_FLAG'=> $lang['age_flag'],

#
#-----[ OPEN ]------------------------------------------
#

includes/usercp_avatar.php

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

function display_avatar_gallery($mode, &$category

#
#-----[ IN-LINE FIND ]------------------------------------------
#

&$interests

#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#

, &$age_flag

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

$params = array('coppa', 'user_id'

#
#-----[ IN-LINE FIND ]------------------------------------------
#

'interests'

#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#

, 'age_flag'

#
#-----[ OPEN ]------------------------------------------
#

includes/usercp_register.php

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

$viewemail = ( isset($HTTP_POST_VARS['viewemail']) ) ? ( ($HTTP_POST_VARS['viewemail']) ? TRUE : 0 ) : 0;

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

$age_flag  = ( isset($HTTP_POST_VARS['age_flag']) ) ? ( ($HTTP_POST_VARS['age_flag']) ? TRUE : 0 ) : 0;

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

$sql = "UPDATE " . USERS_TABLE . "

#
#-----[ IN-LINE FIND ]------------------------------------------
#

$interests) . "'

#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#

, user_age_flag = '$age_flag'

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

$sql = "INSERT INTO " . USERS_TABLE . "

#
#-----[ IN-LINE FIND ]------------------------------------------
#

user_interests

#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#

, user_age_flag

#
#-----[ IN-LINE FIND ]------------------------------------------
#

$interests) . "'

#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#

, '$age_flag'

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

$birthday = $userdata['user_birthday'];

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

$age_flag = $userdata['user_age_flag'];

#
#-----[ OPEN ]------------------------------------------
#

includes/usercp_viewprofile.php

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

        $user_birthday = $lang['No_birthday_specify'];
}

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

if ($profiledata['user_age_flag']) $user_birthday = realdate('M d', $profiledata['user_birthday']);

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

'BIRTHDAY' => $user_birthday,

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

'AGE_FLAG' => ( $profiledata['user_age_flag'] == '0' ) ? $lang['No'] : $lang['Yes'],
'L_AGE_FLAG'=> $lang['age_flag'],

#
#-----[ OPEN ]------------------------------------------
#

language/lang_english/lang_main.php

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

$lang['Birthday'] = 'Birthday';

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

$lang['age_flag'] = 'Hide Your Age';

#
#-----[ OPEN ]------------------------------------------
#

templates/subSilver/profile_add_body.tpl

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

     <td class="row2"><span class="gen">{S_BIRTHDAY}</span></td>
   </tr>
   
#
#-----[ AFTER, ADD ]------------------------------------------
#

   <tr>
     <td class="row1"><span class="gen">{L_AGE_FLAG}:</span></td>
       <td class="row2">
      <input type="radio" name="age_flag" value="1" {INFO_YES} />
      <span class="gen">{L_YES}</span>&nbsp;&nbsp;
      <input type="radio" name="age_flag" value="0" {INFO_NO} />
      <span class="gen">{L_NO}</span></td>
   </tr>
   
#
#-----[ OPEN ]------------------------------------------
#

templates/subSilver/admin/user_edit_body.tpl

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

     <td class="row2"><span class="gen">{S_BIRTHDAY}</span></td>
   </tr>
   
#
#-----[ AFTER, ADD ]------------------------------------------
#

   <tr>
     <td class="row1"><B><span class="gen">{L_AGE_FLAG}:</span></B></td>
       <td class="row2">
      <input type="radio" name="age_flag" value="1" {AGE_FLAG_YES} />
      <span class="gen">{L_YES}</span>&nbsp;&nbsp;
      <input type="radio" name="age_flag" value="0" {AGE_FLAG_NO} />
      <span class="gen">{L_NO}</span></td>
   </tr>

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
User avatar
Beeveer
brilliant supporter
 
Posts: 264
Joined: Tue 30. Nov, 2004 19:13
Location: Boskoop, South-Holland, the Netherlands

Postby Gadget Wizard on Thu 04. Aug, 2005 01:29

Hey thanks Beeveer!!

Maybe someone will give it a test. :wink:

One thing I should mention is that the year is still mandatory. This hack justs adds a option below the date input field in the user profile edit screen that lets the user select whether or not they would like to hide their age from other forum members.

If a user selects "Yes"

1) age:xx will not appear below the avatar
2) Birthday today and lookfoward will display username(xx)
3) No year shown when a forum member displays someone else's profile

This effectively hides your age from all other forum members, but you are still required to enter the year field to ensure the original Birthday Mod will function correctly.
Gadget Wizard
Image
Gadget Wizard
Poster
Poster
 
Posts: 8
Joined: Tue 02. Aug, 2005 12:46

Postby cbl22 on Sun 28. Aug, 2005 19:31

Is there a way to set the Hide age option in the profile to "Yes" by default? Everytime I edit a profile, it unchecks the box, and ages are showing up again! Thanks for the help.
cbl22
Poster
Poster
 
Posts: 5
Joined: Sun 07. Aug, 2005 15:51

PreviousNext

Return to Birthday [2.0.10/EM]

Who is online

Users browsing this forum: No registered users and 1 guest

cron