fetch list with limitation

Author Message

Xavier Dutoit

Monday 12 June 2006 10:10:57 am

Does anyone have fetched a list with a specific limitation set ?

My goal is to let the anonymous fetch the content of a specific folder and list it (view=line) as a user of the group "member" would have had the right to do it, but display a "you should register yourself" message once it try to read it (view full).

According to the doc

http://ez.no/doc/ez_publish/technical_manual/3_6/reference/modules/content/fetch_functions/list

This is possible. However, the documentation is kind of silent on what to pass as parameter to the limitation.

Any idea ?

Access override

The "limitations" parameter makes it possible to instruct the system to use an alternate set of access limitations instead of the ones that belong to the current user. This is typically useful when there is a need to fetch nodes that the current user does not have access to. All permission checking can be skipped by providing an empty array. It is also possible to provide arrays that dictate the access limitations of other users and/or virtual sets of limitations. The array follows an internal structure that will be documented in the future.

X+

http://www.sydesy.com

Kristof Coomans

Monday 12 June 2006 11:02:58 am

Hi Xavier

Related topic: http://ez.no/community/forum/setup_design/fetch_limitation_parameter . But it doesn't tell you what to use inside the array ;-)

You can modify eZContentObjectTreeNode::getLimitationList. Before it's last line...

return $limitationList;

...put something like this:

eZDebug::writeDebug( $limitationList );

...and now you can see the limitation list of the current user.

Or if we're going a bit further we end up in eZUser::hasAccessTo:

$accessArray =& eZRole::accessArrayByUserID( array_merge( $this->groups(), array( $userID ) ) );

You will find the limitation list in $accessArray['content']['read'].

It goes further in eZRole::accessArrayByUserID, which accepts an array of id's (user object id's and/or user group object id's). The problem with all these functions is that they use a caching mechanism ( in site.ini: [RoleSettings] EnableCaching ). Otherwise you could make a template operator or fetch function calling eZRole::accessArrayByUserID with whatever user group you want, and get the limitation list of that group back.

A quick hack would be the modification of eZRole::accessArrayByUserID

function accessArrayByUserID( $userIDArray, $enableCaching = null )

and if $enableCaching is a boolean then don't execute

$enableCaching = $ini->variable( 'RoleSettings', 'EnableCaching' );

It would be a small hack, but what you have to accomplish will be much easier (and dynamic, in case the policies of the "member" group change).

Good luck! And thanks in advance for sharing the hack & template operator / fetch function with us ;-)

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Xavier Dutoit

Monday 12 June 2006 11:12:12 am

Hi Kristof,

Add one pint to the list of what's on my round for next time you come here ;)

Thanks for the hints.

Not sure I do get the logic of testing again the permissions on {node_view_gui }, and it's be great to be able to use them in my case.

Anyway, let's dig and see what I come up to.

X+

http://www.sydesy.com

Kristof Coomans

Monday 12 June 2006 11:45:33 pm

Not sure I do get the logic of testing again the permissions on {node_view_gui }, and it's be great to be able to use them in my case.

I'm not sure I'm following. Did I say something about that?

What you basically have to do:

{def $limitationArray=fetch( 'advancedrole', 'content_read_limitation_array', hash( 'object_id', $memberGroupID ) )
      $nodes=fetch('content','list',hash('parent_node_id',$someNodeID, 'limitation', $limitationArray))}
{foreach $nodes as $nd}
    {node_view_gui view='line' content_node=$nd}
{/foreach}
{undef $nodes $limitationArray}

The only thing you need is an advancedrole/content_read_limitation_array fetch function from which you can call eZRole::accessArrayByUserID or do something similar to fetch the function limitation list of a specific user.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Xavier Dutoit

Tuesday 13 June 2006 1:09:59 am

For those that follow,

I did test the node_view_gui and the limitation=array() and it works fine indeed. I misunderstood a post on the other thread in the forum you mentionned.

Magic Kristof has worked on the patch and extension he suggested (yes, another beer waiting for him ;). I'll test that and if I can make it work, he'll post it on the contribs.

X+

http://www.sydesy.com

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 20:48:06
Script start
Timing: Jan 18 2025 20:48:06
Module start 'layout'
Timing: Jan 18 2025 20:48:06
Module start 'content'
Timing: Jan 18 2025 20:48:07
Module end 'content'
Timing: Jan 18 2025 20:48:07
Script end

Main resources:

Total runtime0.8052 sec
Peak memory usage4,096.0000 KB
Database Queries63

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0072 587.9141152.6250
Module start 'layout' 0.00720.0029 740.539139.4453
Module start 'content' 0.01000.7935 779.9844581.0625
Module end 'content' 0.80350.0016 1,361.046916.1641
Script end 0.8051  1,377.2109 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.4065160.0002
Check MTime0.00130.1646160.0001
Mysql Total
Database connection0.00220.268110.0022
Mysqli_queries0.731090.7825630.0116
Looping result0.00060.0792610.0000
Template Total0.760194.420.3800
Template load0.00220.272720.0011
Template processing0.757894.121320.3789
Template load and register function0.00010.012110.0001
states
state_id_array0.00410.507610.0041
state_identifier_array0.00100.121720.0005
Override
Cache load0.00190.2302520.0000
Sytem overhead
Fetch class attribute can translate value0.00070.085920.0003
Fetch class attribute name0.00150.191070.0002
XML
Image XML parsing0.00100.124320.0005
class_abstraction
Instantiating content class attribute0.00000.0028100.0000
General
dbfile0.00190.2315220.0001
String conversion0.00000.001040.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
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
12content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
8content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 32
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs