Forums / Setup & design / Fetching users information

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!

eZ debug

Timing: Jan 31 2025 00:39:12
Script start
Timing: Jan 31 2025 00:39:12
Module start 'content'
Timing: Jan 31 2025 00:39:12
Module end 'content'
Timing: Jan 31 2025 00:39:13
Script end

Main resources:

Total runtime0.2002 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0058 587.9297370.2969
Module start 'content' 0.00590.0110 958.22661,009.5156
Module end 'content' 0.01690.1832 1,967.74223,899.4375
Script end 0.2001  5,867.1797 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00412.0280200.0002
Check MTime0.00120.6034200.0001
Mysql Total
Database connection0.00050.261310.0005
Mysqli_queries0.120960.37881410.0009
Looping result0.00110.55641390.0000
Template Total0.182891.310.1828
Template load0.00110.546610.0011
Template processing0.181790.782010.1817
Override
Cache load0.00080.415610.0008
Sytem overhead
Fetch class attribute can translate value0.00180.885410.0018
XML
Image XML parsing0.00020.102410.0002
General
dbfile0.00442.2092200.0002
String conversion0.00000.002030.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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