Redirect to homepage if access to an extension is denied

Author Message

Carlos Revillo

Tuesday 05 June 2007 12:34:00 pm

Hello. Now i wanna make an extension. Let's call it "articles".
I have two kind of users. Group Users can be A or B.

B users have access to "articles", but a Users A haven't.

So, if an A user tries to work with articles extension, he is showed an error message.

I don't want to show this message to A user. Instead of, i want redirect him to my homepage, so he can login from there.

I know i can play with ezUser::hasAccessTo("module") or something like that... but where do i have to do this check? Will it be sufficient if i do it in my module.php file, or should i do for all the views of my extension?

Thank you.

Bruce Morrison

Tuesday 05 June 2007 4:27:31 pm

Hi Carlos

Permissions are handled before the module views are run, so to do what you are asking you'd have allow all users to access the view(s) and redirect dependant on the user.

If you were willing to redirect all "access denied" access to the homepage you can setup this behaviour in error.ini. Doesn't appear to be documentated but the comments in the main ini file should give enough info for you to get by.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Carlos Revillo

Wednesday 06 June 2007 3:12:56 am

hi. thanks a lot. it worked.

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 31 2025 01:21:59
Script start
Timing: Jan 31 2025 01:21:59
Module start 'layout'
Timing: Jan 31 2025 01:21:59
Module start 'content'
Timing: Jan 31 2025 01:21:59
Module end 'content'
Timing: Jan 31 2025 01:21:59
Script end

Main resources:

Total runtime0.0266 sec
Peak memory usage6,144.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0053 588.3828151.2422
Module start 'layout' 0.00530.0038 739.6250220.7344
Module start 'content' 0.00920.0154 960.3594997.8203
Module end 'content' 0.02460.0019 1,958.179733.9922
Script end 0.0265  1,992.1719 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.003412.6410140.0002
Check MTime0.00145.3148140.0001
Mysql Total
Database connection0.00072.618810.0007
Mysqli_queries0.00217.752330.0007
Looping result0.00000.045810.0000
Template Total0.00145.210.0014
Template load0.00103.917010.0010
Template processing0.00031.264110.0003
Override
Cache load0.00072.720210.0007
General
dbfile0.00031.192380.0000
String conversion0.00000.026940.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