can_create and permissions

Author Message

BJørnar Trondsen

Thursday 17 August 2006 11:53:34 am

I have 2 users: One user has create permission to a certain class. The other one has create permission to all classes.

When displaying a NewButton which creates a new object that one of the user has permission to create, while the other user has not, the NewButton is display even though a user hasn't got access to create an object of a that specific class.
I only want to have the NewButton displayed for the user having the correct permission.

Here's the output for the user 1:
can_read boolean true
can_create boolean true
can_edit boolean false
can_hide boolean false
can_remove boolean false
can_move boolean false
can_move_from boolean false
can_add_location boolean false
can_remove_location boolean false
can_view_embed boolean false
is_main boolean true

Output for ouser 2:
can_read boolean true
can_create boolean true
can_edit boolean false
can_hide boolean false
can_remove boolean false
can_move boolean false
can_move_from boolean false
can_add_location boolean false
can_remove_location boolean false
can_view_embed boolean false
is_main boolean true

This are all the same.

Here's my code:
{section show=$node.object.can_create}
<form method="post" action={"/content/action"|ezurl}>
<input type="hidden" name="NodeID" value="{$node.node_id}" />
<input type="hidden" name="ClassID" value="24" />
<input type="hidden" name="ContentLanguageCode" value="eng-US" />
<input class="button" type="submit" name="NewButton" value="{'Upload Document'|i18n('design/standard/node/view')}" />
</form>
{/section}

Of course, when I log in with the user not having the permission and hit the NewButton, I get an access error (while it works for the user having the correct permission).

How can I have the NewButton displayed only for the user having the permission to create an object?

Marcin Drozd

Thursday 17 August 2006 1:26:52 pm

Hi
Did U try to disable cache for this template?
Put first line in your tpl: {set-block scope=root variable=cache_ttl}0{/set-block}
or maybe try with:
http://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/content/fetch_functions/access
http://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/content/fetch_functions/can_instantiate_classes
http://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/content/fetch_functions/can_instantiate_class_list
http://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/user/fetch_functions/has_access_to

http://ez-publish.pl

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 22:31:10
Script start
Timing: Jan 18 2025 22:31:10
Module start 'layout'
Timing: Jan 18 2025 22:31:10
Module start 'content'
Timing: Jan 18 2025 22:31:11
Module end 'content'
Timing: Jan 18 2025 22:31:11
Script end

Main resources:

Total runtime0.5611 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0073 587.9141152.6250
Module start 'layout' 0.00730.0027 740.539139.4453
Module start 'content' 0.01000.5495 779.9844499.9219
Module end 'content' 0.55950.0015 1,279.906312.1641
Script end 0.5610  1,292.0703 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.7026160.0002
Check MTime0.00140.2464160.0001
Mysql Total
Database connection0.00100.185410.0010
Mysqli_queries0.507290.4066540.0094
Looping result0.00050.0874520.0000
Template Total0.530794.620.2653
Template load0.00220.393720.0011
Template processing0.528494.184620.2642
Template load and register function0.00020.036910.0002
states
state_id_array0.00090.157710.0009
state_identifier_array0.00070.121220.0003
Override
Cache load0.00190.3352510.0000
Sytem overhead
Fetch class attribute can translate value0.00070.125520.0004
Fetch class attribute name0.00140.252920.0007
XML
Image XML parsing0.00020.044220.0001
class_abstraction
Instantiating content class attribute0.00000.002320.0000
General
dbfile0.00080.1444100.0001
String conversion0.00000.001440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 15
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs