Displaying specific folders to users of a minimum age

Author Message

Andy Woods

Monday 04 April 2011 10:54:56 am

I'm developing a site for children aged between 5 and 18.

Some folders are only to be viewed by young people that are at secondary school (aged 12+).

I've added a date field in the 'User' class to specify each user's date of birth.

Can anyone help me with the code I need to be able to:

a) determine how old a user is

b) how I would enable children of age 12+ to see specific folders but not display them to children younger than 12 years old

Thanks,

Andy

Gaetano Giunta

Tuesday 05 April 2011 1:06:37 am

Not a detailed walkthrough, but here you go:

1. take care about the datatype used for 'date of birth'. Standard date datatype cannot go below 1/1/1970, so if your website has also older people registered, you need a custom datatype (there is an extension or two on projects.ez.no with that)

2. you should create two roles, and divide users in two groups, each with one role assigned. Then move boys in group A, with role 'boys', and kids to group B, with role 'kids'. Assign read different read permissions to kids and boys groups.

3. Use the workflow system to make sure that when accounts are created, the user is put in the proper group depending on his age (unless you do this manually)

4. Set up a cronjob that runs once a day and checks if kids have become old enough to be migrated to boys

Principal Consultant International Business
Member of the Community Project Board

Andy Woods

Tuesday 05 April 2011 11:54:21 am

Thanks Gaetano,

That looks like a good plan.

Can you tell me the table and field I need to update to change the user's group please?

Thanks,

Andy

Gaetano Giunta

Wednesday 06 April 2011 1:52:03 am

To change a group that a user is in I recommend you do not try to access the db directly, but use the eZP php api dealing with content objects. The operation you want to do is move a node.

Principal Consultant International Business
Member of the Community Project Board

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 01:07:24
Script start
Timing: Jan 18 2025 01:07:24
Module start 'layout'
Timing: Jan 18 2025 01:07:24
Module start 'content'
Timing: Jan 18 2025 01:07:24
Module end 'content'
Timing: Jan 18 2025 01:07:24
Script end

Main resources:

Total runtime0.0171 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0061 589.2734152.6563
Module start 'layout' 0.00610.0034 741.929739.5156
Module start 'content' 0.00950.0055 781.445393.2891
Module end 'content' 0.01500.0021 874.734434.2891
Script end 0.0171  909.0234 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002715.5261140.0002
Check MTime0.00126.7471140.0001
Mysql Total
Database connection0.00084.645610.0008
Mysqli_queries0.003218.482230.0011
Looping result0.00010.345110.0001
Template Total0.001710.010.0017
Template load0.00095.171710.0009
Template processing0.00084.839010.0008
Override
Cache load0.00063.589310.0006
General
dbfile0.00042.104380.0000
String conversion0.00000.075240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs