Advertisement:

Author Topic: Restrict forum access based upon birthday  (Read 8022 times)

Offline jdougher

  • Jr. Member
  • **
  • Posts: 299
    • PoetryCircle
Restrict forum access based upon birthday
« on: July 23, 2005, 08:54:50 AM »
Can I restrict access to a particular forum on my site http://www.photocamel.com based upon the birthday that a user enters? I'm trying to figure out an elegant, easy way for me to have ONE forum available only to people over 18. Thanks. This is a problem that's really pestering me and is fairly urgent.

Offline Furvert

  • Semi-Newbie
  • *
  • Posts: 81
  • Gender: Male
    • A Tribute To Minerva Mink
Re: Restrict forum access based upon birthday
« Reply #1 on: July 24, 2005, 07:36:19 PM »
I too would love to see a solution using this directly.
I currently manually set people to an adult membergroup with different permissions which does require some effort on my part and delays to the user.

Unfortunately I think this would require a database mod to enable age as a permission setting.

Of course if they can edit birthday, they can set themself adult and change back later! It would be nice if it was locked out from reeditting somehow?

Offline jdougher

  • Jr. Member
  • **
  • Posts: 299
    • PoetryCircle
Re: Restrict forum access based upon birthday
« Reply #2 on: July 24, 2005, 09:08:56 PM »
I too would love to see a solution using this directly.
I currently manually set people to an adult membergroup with different permissions which does require some effort on my part and delays to the user.

Unfortunately I think this would require a database mod to enable age as a permission setting.

Of course if they can edit birthday, they can set themself adult and change back later! It would be nice if it was locked out from reeditting somehow?

You and I are in the same boat. I would think this should be a feature.

Offline Furvert

  • Semi-Newbie
  • *
  • Posts: 81
  • Gender: Male
    • A Tribute To Minerva Mink
Re: Restrict forum access based upon birthday
« Reply #3 on: July 24, 2005, 09:14:36 PM »
I am looking into what code is required.
I wanted to add age to memberlist as well, so I am trying to code that as a test.
'age' appears to be defined in the database on people, or at least something in profiles assigns it temporarily. Either way that code should be usable.

Offline Ben_S

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 11,702
  • xxx
Re: Restrict forum access based upon birthday
« Reply #4 on: July 24, 2005, 09:39:54 PM »
Have a look at http://www.simplemachines.org/community/index.php?topic=43141.0

It may help, although it has some limitations as I mention in that post.
Liverpool FC Forum with 14 million+ posts.

Offline Furvert

  • Semi-Newbie
  • *
  • Posts: 81
  • Gender: Male
    • A Tribute To Minerva Mink
Re: Restrict forum access based upon birthday
« Reply #5 on: July 24, 2005, 10:23:13 PM »
I now have AGE added to the memberlist display and working for sorts as well.
Mods to 'Memberlist.php' in source
Mods to 'Memberlist.template.php' in default theme

It wasn't difficult other than I could not use the language defined 'Age' in $txt[420] for the column title, so put it in English for now. $txt[420] is used by profiles.english.php but the code grabs from index.english.php where I though it was global?

Maybe someone knows how to fix this properly for best compatability.

http://furvert.net/smf/index.php
test/test

If others desire this mod I can try to make instructions

Offline jdougher

  • Jr. Member
  • **
  • Posts: 299
    • PoetryCircle
Re: Restrict forum access based upon birthday
« Reply #6 on: July 25, 2005, 09:30:42 AM »
I now have AGE added to the memberlist display and working for sorts as well.
Mods to 'Memberlist.php' in source
Mods to 'Memberlist.template.php' in default theme

It wasn't difficult other than I could not use the language defined 'Age' in $txt[420] for the column title, so put it in English for now. $txt[420] is used by profiles.english.php but the code grabs from index.english.php where I though it was global?

Maybe someone knows how to fix this properly for best compatability.

http://furvert.net/smf/index.php
test/test

If others desire this mod I can try to make instructions

Yes, I would love instructions. Thanks.

Offline Furvert

  • Semi-Newbie
  • *
  • Posts: 81
  • Gender: Male
    • A Tribute To Minerva Mink
Re: Restrict forum access based upon birthday
« Reply #7 on: July 25, 2005, 03:30:05 PM »
Ok, I tried to write it in the 'mod' format, dont see a post file option so have to do it inline.
One thing that needs fixing is 'label' => 'Age' but that requires another file mod to add $txt[] somewhere so that it can be updated for languages.

AgeInMemberlist_11b3p.mod
Code: [Select]
<id>
AgeInMemberlist_11b3p
</id>

<version>
1.1b3p
</version>

<mod info>
Add member age to the memberlisting with sorting.
</mod info>

<author>
Furvert
</author>

<homepage>
http://furvert.net/smf/
</homepage>

<edit file>
Sources/Memberlist.php
</edit file>

<search>
'realName' => array(
'label' => $txt[35]
),
</search>

<replace>
'realName' => array(
'label' => $txt[35]
),
'age' => array(
'label' => 'Age'
),
</replace>

<search>
'realName' => array(
'down' => 'mem.realName ASC',
'up' => 'mem.realName DESC'
),
</search>

<replace>
'realName' => array(
'down' => 'mem.realName ASC',
'up' => 'mem.realName DESC'
),
'age' => array(
'down' => 'mem.birthdate ASC',
'up' => 'mem.birthdate DESC'
),
</replace>

<edit file>
Themes\default\Memberlist.template.php
</edit file>

<search>
foreach ($context['members'] as $member)
</search>

<replace>
foreach ($context['members'] as $member)
{
if (empty($member['birth_date']))
{
$member +=  array(
'age' => &$txt[470],
);
}
else
{
list ($birth_year, $birth_month, $birth_day) = sscanf($member['birth_date'], '%d-%d-%d');
$datearray = getdate(forum_time());
$member += array(
'age' => empty($birth_year) ? $txt[470] : $datearray['year'] - $birth_year - (($datearray['mon'] > $birth_month || ($datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day)) ? 0 : 1),
);
}
</replace>

<search>
<td class="windowbg" align="left">', $member['link'], '</td>
</search>

<replace>
<td class="windowbg" align="left">', $member['link'], '</td>
<td class="windowbg" align="right">', $member['age'], '</td>
</replace>

<search>
}
// No members?
</search>

<replace>
}
}
// No members?
</replace>

Offline jdougher

  • Jr. Member
  • **
  • Posts: 299
    • PoetryCircle
Re: Restrict forum access based upon birthday
« Reply #8 on: July 25, 2005, 08:28:36 PM »
Thanks! so this is not "good to go," right?

Offline Furvert

  • Semi-Newbie
  • *
  • Posts: 81
  • Gender: Male
    • A Tribute To Minerva Mink
Re: Restrict forum access based upon birthday
« Reply #9 on: July 25, 2005, 09:59:13 PM »
You can do the edits as shown manually, I do not know how to make a package version.
Someone may be able to take that mod file and do it though, as I think it needs some xml to work?
I could be wrong on that.

I have been using it since I made it with no problems so I dont expect others will have any. If someone uses other language files, the 'Age' label will stay in english as I have not fixed that aspect yet. The profiles.english.php has the word 'age' defined but it did not access it for $txt[420] like I expected it to. If it had then other language packs should have worked.

Offline jdougher

  • Jr. Member
  • **
  • Posts: 299
    • PoetryCircle
Re: Restrict forum access based upon birthday
« Reply #10 on: July 26, 2005, 09:34:59 AM »
You can do the edits as shown manually, I do not know how to make a package version.
Someone may be able to take that mod file and do it though, as I think it needs some xml to work?
I could be wrong on that.

I have been using it since I made it with no problems so I dont expect others will have any. If someone uses other language files, the 'Age' label will stay in english as I have not fixed that aspect yet. The profiles.english.php has the word 'age' defined but it did not access it for $txt[420] like I expected it to. If it had then other language packs should have worked.

Thanks. I hope I can figure out how to insert this.


Offline Furvert

  • Semi-Newbie
  • *
  • Posts: 81
  • Gender: Male
    • A Tribute To Minerva Mink
Re: Restrict forum access based upon birthday
« Reply #11 on: July 31, 2005, 04:39:36 AM »
See http://www.simplemachines.org/community/index.php?topic=43818.0
I changed to a new topic for code help

With a little help I think I can write this

Offline Furvert

  • Semi-Newbie
  • *
  • Posts: 81
  • Gender: Male
    • A Tribute To Minerva Mink
Re: Restrict forum access based upon birthday
« Reply #12 on: August 08, 2005, 09:59:06 PM »
In a related MOD, I added 'Last Login' to Memberlist with sorting as a means to determine how active members are. If someone wants it I can write a MOD file for it like the AGE MOD. It was quite similar except for a timestamp conversion needed.

I have partial code on the AGE restriction by Board. I need to write the admin panel yet. Hopefully I will get a chance to work on it soon.