Fetching users information

Author Message

Guilherme Longo

Thursday 20 September 2007 2:49:59 am

Mates, I'm trying to create one block, where I can fetch some user specification for, if the user belong of EDITORS user group, for example, he will be able to see one checkbox in one page.

Ex:

<div class="block">

<b>{foreach $user_id as $user => $id}</b>
<b>{if $id.user_id|eq(editors)}</b>

<label for="id3">{"Administrator interface"|i18n("design/ezwebin/user/login")}</label><div class="labelbreak"></div>
<input type="checkbox" size="10" name="AdminSiteaccessURI" id="id3" value="" tabindex="1" onclick="AdminSiteaccessCheckbox(this);" />

<b>{else}</b>

<input type="hidden" size="10" name="AdminSiteaccessURI" id="id3" value="" tabindex="1" onclick="AdminSiteaccessCheckbox(this);" />

<b>{/foreach}</b>

</div>

I tried find <b>$some thing</b> to get users informations but a did'nt find.

Someone could help me?
Thank

Laurent BOURREL

Thursday 20 September 2007 3:03:25 am

Did you have a look on :
http://ez.no/doc/ez_publish/technical_manual/3_9/reference/modules/user

You can get the roles, the policies, etc.

Guilherme Longo

Thursday 20 September 2007 3:38:57 am

yes, I read it before and a used this way:

<div class="block">

{def $users=fetch( 'user', 'current_user' )}

{foreach $users.group as $key => $group}
{def $group=fetch( 'user', 'current_user' )}
<b>{if $item.groups|eq(Webeditors)}</b>

<label for="id3">{"Administrator interface"|i18n("design/ezwebin/user/login")}</label><div class="labelbreak"></div>
<input type="checkbox" size="10" name="AdminSiteaccessURI" id="id3" value="" tabindex="1"

onclick="AdminSiteaccessCheckbox(this);" />

{else}

<input type="hidden" size="10" name="AdminSiteaccessURI" id="id3" value="" tabindex="1"

onclick="AdminSiteaccessCheckbox(this);" />

{/foreach}

</div>

But without successfull ;O(
Maybe has some thing wrong in the bolder line above, but i did'nt find yet whats happen

Guilherme Longo

Thursday 20 September 2007 4:48:07 am

Mates

I almost get to make by this way:

{def $user=fetch( 'user', 'current_user' )}

{foreach $user.groups as $key => $group}
{def $group=fetch( 'content', 'object', hash( 'object_id', $user.groups[$key] ) )}
{if $group.name|eq(Webeditors)}

<li><a href={"/eng/site_admin"} title="Admin Interface">Admin Interface</a></li>

{else}

.....
...

But, the problem is all users belong of 2 groups (Main Group: User) and your Children: Editors or whatever. I need change this role <b>{foreach $user.groups as $key => $group}</b>, using foreach will go to be impossible.

Guilherme Longo

Thursday 20 September 2007 9:10:46 am

Friends, i did got to find one solution for my problem

by the end, i'm here:

{def $users=fetch( 'user', 'current_user' )}

{foreach $users.group<b>|ne</b>(Users) as $key => $group}
{def $group=fetch( 'user', 'current_user' )}
{if $item.groups<b>|eq</b>(Webeditors)}

<li>.........<li>

{else}

<li>...........<li>

{/if}
{/foreach}

Using this way, all <li> desappear ;O(
now finish my ideas....
Could someone help me

Pascal Specht

Thursday 20 September 2007 9:13:48 am

Guilherme,

did you try using $variable|attribute(show) to see if the variable really contains what you expect?

-Pascal

Guilherme Longo

Friday 21 September 2007 4:22:23 am

Thank you so much for your tip Pascal Specht and everyone that helped me.

My variable was empty, so my menu disappeared.
Testing the variable I found one way to do my condition:

{def $user=fetch( 'user', 'current_user' )}
{foreach $user.groups as $key => $group}
{def $group=fetch( 'content', 'object', hash( 'object_id', $user.groups[$key] ) )}
{if $group.name|ne(Users) }
{if $group.name|eq(Webeditors) }

........
.........

{else}

.............
............

{/if}
{/if}
{/foreach}

Thank again!

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 03:30:44
Script start
Timing: Jan 31 2025 03:30:44
Module start 'layout'
Timing: Jan 31 2025 03:30:44
Module start 'content'
Timing: Jan 31 2025 03:30:44
Module end 'content'
Timing: Jan 31 2025 03:30:44
Script end

Main resources:

Total runtime0.0298 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.0075 588.1328151.2109
Module start 'layout' 0.00750.0040 739.3438220.6875
Module start 'content' 0.01150.0169 960.03131,005.7891
Module end 'content' 0.02840.0013 1,965.820337.9922
Script end 0.0297  2,003.8125 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00299.8211140.0002
Check MTime0.00113.7591140.0001
Mysql Total
Database connection0.00144.810810.0014
Mysqli_queries0.003612.114330.0012
Looping result0.00000.036810.0000
Template Total0.00093.010.0009
Template load0.00072.351710.0007
Template processing0.00020.678410.0002
Override
Cache load0.00051.605210.0005
General
dbfile0.00165.389980.0002
String conversion0.00000.029640.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