Forums / Setup & design / fetch list with limitation

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

eZ debug

Timing: Jan 18 2025 18:23:26
Script start
Timing: Jan 18 2025 18:23:26
Module start 'content'
Timing: Jan 18 2025 18:23:27
Module end 'content'
Timing: Jan 18 2025 18:23:27
Script end

Main resources:

Total runtime0.9313 sec
Peak memory usage4,096.0000 KB
Database Queries200

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0046 587.7109180.8359
Module start 'content' 0.00460.8079 768.5469586.1406
Module end 'content' 0.81250.1187 1,354.6875341.3750
Script end 0.9312  1,696.0625 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00380.4072210.0002
Check MTime0.00130.1400210.0001
Mysql Total
Database connection0.00070.070610.0007
Mysqli_queries0.848591.10752000.0042
Looping result0.00230.24781980.0000
Template Total0.907397.420.4536
Template load0.00190.206120.0010
Template processing0.905497.217620.4527
Template load and register function0.00010.009110.0001
states
state_id_array0.00070.078510.0007
state_identifier_array0.00190.201720.0009
Override
Cache load0.00170.1790520.0000
Sytem overhead
Fetch class attribute can translate value0.00420.448330.0014
Fetch class attribute name0.00190.200370.0003
XML
Image XML parsing0.00110.118630.0004
class_abstraction
Instantiating content class attribute0.00000.0025100.0000
General
dbfile0.00370.3977330.0001
String conversion0.00000.000630.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
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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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