to previous topic Print topic to next topic

 Root :: Developments :: Tutorials and programming :: Under 18
 Moderated by:
 
  Bottom  Under 18
wicked Posted: 26.07.2005, 15:16
Noob
Noob


registered: Oct 27, 2004
Posts: 11

Status:  offline
last visit: 27.07.05
I've added a new field in the users table: $birthday

Code
  1. `pn_birthday` varchar(25) NOT NULL default ''
  2.  


$birthday = pnUserGetVar('birthday');
$now = date();
$years_old = $now - $birthday;
$years_old = date("y", $years_old);

I try to don't show the news under the topic "sex" ($tid == "2") to the users that their age < 18 and show an error message if they try to see it, but i don't know what i have to do... LOST...

Any idea?? :( :( :(

Sorry for my english :!:
Top  wicked send PM
 
Chestnut Posted: 26.07.2005, 16:12
Site Admin
avatar

registered: Jun 02, 2002
Posts: 1320

Status:  offline
last visit: 07.02.08
mmm...

Could take a little more than that.

Best way possible is to add the kiddos into a group (you must know there are under 18), then simply add a permission for them not to see the specific topic.


Chestnut ! Cool
Site Admin
Top  Chestnut send PM Homepage
 
wicked Posted: 26.07.2005, 21:55
Noob
Noob


registered: Oct 27, 2004
Posts: 11

Status:  offline
last visit: 27.07.05
umMMMm, it's a great idea, very simple and nice :)

But works with dates is a beat complicated for me :( I would do a sql for insert those users wich $now - $birthday (date in years) will be < 18 and delete them when this sustraction be > 18 :(

I repeat: sorry for my bad english :(
Top  wicked send PM
 
Chestnut Posted: 27.07.2005, 00:25
Site Admin
avatar

registered: Jun 02, 2002
Posts: 1320

Status:  offline
last visit: 07.02.08
First, I'm not sure you pn_birthday field can work that way...

You should create a dynamic field instead as to not break the DB for future updates.

Secondlyn unless you are filling the birthday field yourself, from what I can see, you are assuming that they are filling their birthday in a timestamp format wich I doubt anyone can....... unless some autist able to count the number of seconds since 1970..... :wink:

One of way that could work is to make 3 dyna fields
_BIRTHDAY
_BIRTHMONTH
_BIRTHYEAR

That way, it'll be a breeze to combine them using the mktime function ( http://www.php.net/mktime )

Then, you'll be able to do easily a $now - mktime(0,0,0, $month, $day, $year) to know if he has more or less than 18.

Something like that.


Chestnut ! Cool
Site Admin
Top  Chestnut send PM Homepage
 
wicked Posted: 27.07.2005, 00:36
Noob
Noob


registered: Oct 27, 2004
Posts: 11

Status:  offline
last visit: 27.07.05
I understand... but... my big problem is the same...

Thanks for all Chestnut, keep up the good work!
Top  wicked send PM
 
Chestnut Posted: 27.07.2005, 00:54
Site Admin
avatar

registered: Jun 02, 2002
Posts: 1320

Status:  offline
last visit: 07.02.08
mmm The future uses of hooks within PostNuke will make our lives so much simpler, you can't imagine.

I know what I mean... icon_lol

:wink:


Chestnut ! Cool
Site Admin
Top  Chestnut send PM Homepage
 
Chestnut Posted: 27.07.2005, 01:00
Site Admin
avatar

registered: Jun 02, 2002
Posts: 1320

Status:  offline
last visit: 07.02.08
wickedI understand... but... my big problem is the same...


Wich is ? If building the thing it is, then I admit that I don't have any automated way I'm afraid and building it might need a little reflexion...

The sql and all...

Not necessarily hard... but still...

1 Getting all your users
2 Building the birthtime from their info

3 Moving through your result and if > 18, removing from non-priviledged group else... adding them...

But it quite manual.


Chestnut ! Cool
Site Admin
Top  Chestnut send PM Homepage
 



Powered by pnForum Version 2.0.1
DarkMindZ