Forums / General / Roles and Policies Newbie question

Roles and Policies Newbie question

Author Message

Uli Kimmich

Wednesday 20 April 2011 3:13:29 pm

I'm a newbie to roles and policies. The project I'm working on requires that every registered reporter after login only sees his stories that he wrote in the folder My Stories. Let's say I have 20 reporters that after login only see their individual stories they created.

I created a user group Reporter with role Reporter with the following policies:

Reporter content read Class( Folder ) , Section( Standard )
Reporter content read Subtree( My Stories ) , Class( Story ) , Section( Standard ) , Owner( Self )
Reporter user login SiteAccess( eng ) Reporter user selfedit No limitations

I'm stuck since it doesn't work as expected. All the stories show on each reporters page even if I login in with a different reporter account.

Please help. Thanks.

Uli

Nicolas Pastorino

Wednesday 20 April 2011 10:17:09 pm

Hi Uli,

Could you tell us more about the fetch function used to retrieve and display the children of the My Stories folder ? Any chance the 'limitation' parameter is used ? (feel free to paste the call to the fetch function here).

Cheers,

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Uli Kimmich

Thursday 21 April 2011 3:00:02 am

Hi Nicolas,

thank you for your quick reply. I really appreciate it.

Actually I haven't touched the template yet regarding the fetch function. I assumed that I could control the content through roles and policies only.

I'm using ezPublish 4.2011 and created a user group "reporters" with policy setting "Content read Owner (self)". Also I use the standard user class to create reporter objects. I figured that just by using Owner (self) would display only the content that a user created. So whenever a user creates an article he is the owner, I guess. After login only those articles of this specific user should be shown.

What is the purpose of having Owner(self) if it doesn't list me only the objects related to a specific user?

If I have to use a fetch function how would that look like?

Thank you.

Uli

Marko Žmak

Thursday 21 April 2011 6:37:38 am

Hm, maybe your users have some other role assigned that allows them to read articles.

For example they can have the Anonymous role assigned which can have the content/read/* policy. In that case every user would have access to all the articles regardless of any other new roless you assign.

Also, you should be clear about what you want to do:

  • a) restrict logged in users so that they can read only their articles and in no way to be able to read any other article
  • b) allow logged in users to read any article but have a special box in one part of the page where they can see only their articles

If yours is case a) then you should use the roles and policies to restrict it.

But if yours is case b) you should change the templates and use template fetch functions with attribute filtering. See here for the docs about template fetch functions:

  • http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Modules/content/Fetch-functions/tree
  • http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Modules/content/Fetch-functions/list

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Uli Kimmich

Thursday 21 April 2011 7:05:57 pm

Hi Marko,

thanks for your reply.

Case a) is what I'd like to implement.

I created a Usergroup "Reporters" and a role "Reporters" with the following policies:

content create No limitations
content edit Owner( Self )
content read Owner( Self )
user login SiteAccess( eng )
user password No limitations
user selfedit No limitations
websitetoolbar all functions No limitations

After creating user1 and user2 I assign them to the usergroup Reporters with role Reporters.

After I login with user1 I created an article. After logout I logged in with user2 and the article shows also under user2. Anything I did wrong?

Thanks.

Uli

Marko Žmak

Thursday 21 April 2011 11:22:46 pm

Some things to check:

  • does the "Reporters" group have any other roles asigned
  • does the "Reporters" group belong to any other user group
  • when you look at your site as anonymous user (not logged in) can you see this article made by user1?
  • try disabling the cache on your site

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Uli Kimmich

Friday 22 April 2011 7:40:54 pm

Hi Marko,

thank you. Yes, it is the cache that causes the problem. Once it is disabled it seem to work now.

Thanks again.

Uli

Marko Žmak

Saturday 23 April 2011 2:17:31 am

Disabling cache is not a good solution, you should use ViewCacheTweak configuration setting and set it to pr_user.

By default the cache in eZP is not generated per user but you have the same cache for the users that have the same set of roles. This ViewCacheTweak settings allows you to have a per user cache.

The setting is not documented in the official eZ docs but you can find some info about it here:

  • http://serwatka.net/blog/ez_publish_4_1_and_4_2_hidden_gems
  • http://share.ez.no/forums/setup-design/viewcaching-per-user

and also take a look at the settings/site.ini and read the info below ViewCacheTweak.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Uli Kimmich

Sunday 24 April 2011 11:41:33 pm

Thanks Marko. I'll check it out.

Uli

eZ debug

Timing: Jan 17 2025 23:55:43
Script start
Timing: Jan 17 2025 23:55:43
Module start 'content'
Warning: PHP: E_DEPRECATED Jan 17 2025 23:55:44
trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/ze/public_html/share.se7enx.com/var/community/cache/template/compiled/table-c0a31fef795ad927ef08940ddf2d392f.php on line 147
Timing: Jan 17 2025 23:55:44
Module end 'content'
Timing: Jan 17 2025 23:55:44
Script end

Main resources:

Total runtime0.6944 sec
Peak memory usage4,096.0000 KB
Database Queries214

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0060 588.8281180.8438
Module start 'content' 0.00600.5730 769.6719705.1875
Module end 'content' 0.57900.1153 1,474.8594348.6484
Script end 0.6944  1,823.5078 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.5669210.0002
Check MTime0.00150.2088210.0001
Mysql Total
Database connection0.00080.108010.0008
Mysqli_queries0.583283.98682140.0027
Looping result0.00200.28272120.0000
Template Total0.671796.720.3358
Template load0.00190.267620.0009
Template processing0.669896.452820.3349
Template load and register function0.00020.031210.0002
states
state_id_array0.00080.111410.0008
state_identifier_array0.00070.103020.0004
Override
Cache load0.00180.26291130.0000
Sytem overhead
Fetch class attribute can translate value0.00110.159840.0003
Fetch class attribute name0.00110.1656120.0001
XML
Image XML parsing0.00330.477940.0008
class_abstraction
Instantiating content class attribute0.00000.0048180.0000
General
dbfile0.00670.9696410.0002
String conversion0.00000.000930.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
9content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
9content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
14content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
7content/datatype/view/ezxmltags/emphasize.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/emphasize.tplEdit templateOverride template
4content/datatype/view/ezxmltags/li.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/li.tplEdit templateOverride template
4content/datatype/view/ezxmltags/ul.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/ul.tplEdit templateOverride template
12content/datatype/view/ezxmltags/td.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/td.tplEdit templateOverride template
7content/datatype/view/ezxmltags/tr.tpl<No override>extension/community/design/community/templates/content/datatype/view/ezxmltags/tr.tplEdit templateOverride template
1content/datatype/view/ezxmltags/table.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/table.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 70
 Number of unique templates used: 12

Time used to render debug report: 0.0002 secs