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.