Forums / Setup & design / can_create and permissions

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