Create Child Page under own pages only

Posted by Community Admin on 03-Aug-2018 20:50

Create Child Page under own pages only

All Replies

Posted by Community Admin on 17-Nov-2014 00:00

Hi,

I'm setting up the security for a new site and I want a setup so users can create and manage pages in a section of the site. When I grant the 'Create Page' right then the user can create sub pages under all pages by default. I want the user to be able to create child pages only under the pages he or she owns. I don't want to break the inheritance of the page permissions on all root pages just to prevent users from creating child pages under other pages then they own. Can this be done?

Regards,
Arjan Vermunt

Posted by Community Admin on 15-Dec-2014 00:00

Hello Arjan,

This could be achieved by extending the pageservice and filter the pages it returns (you need to take care when a user dargs&drops a page in backend list view or when he create / edit /duplicate a page using the create / edit / duplciate dialog):

Add a custom page service:

  • include PageServiceExtended.cs in your solution (please find it attached in this reply)
  • include PageServiceExtended.svc in ~\Sitefinity\Services\Pages\PageServiceExtended.svc
  • build the solution
  • go to Administration >> Settings >> Advanced >> ContentView >> Controls >> FrontendPagesListView, under  WebServiceBaseUrl type the new one: ~/Sitefinity/Services/Pages/PagesServiceExtended.svc/
  • go to Administration >> Settings >> Advanced >> ContentView >> Controls >> FrontendPagesCreate (same also for FrontendPagesEdit and FrontendPagesDuplicate) >> Sections >> MainSection >> Fields >> Parent, under  WebServiceBaseUrl type the new one: ~/Sitefinity/Services/Pages/PagesServiceExtended.svc/
  • restart the application

After performing the above, all requests for create, edit, duplicate and list view will pass trough your custom page service. What is left is to put a custom code to filter the result accordingly. You need to plug custom logic on two places:

public Telerik.Sitefinity.Web.Services.CollectionContext<Telerik.Sitefinity.Modules.Pages.Web.Services.Model.PageViewModel> BatchPlacePage(string[] sourcePageIds, string providerName, string placePosition, string destination, string root)
    return pageservice.BatchPlacePage(sourcePageIds, providerName, placePosition, destination, root);


and

public Telerik.Sitefinity.Web.Services.CollectionContext<Telerik.Sitefinity.Modules.Pages.Web.Services.Model.PageViewModel> BatchPlacePage(string[] sourcePageIds, string providerName, string placePosition, string destination, string root)
    return pageservice.BatchPlacePage(sourcePageIds, providerName, placePosition, destination, root);


In both methods you have to perform additional check if

var identity = ClaimsManager.GetCurrentIdentity();


is in specific role or is an owner of each page the service returns and if needed to be filtered out.

Hope this helps.

Regards,
Vassil Vassilev
Telerikabout:newtab

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
[View:/cfs-file/__key/communityserver-discussions-components-files/295/f08a2d4c_2D00_ea75_2D00_4355_2D00_97e8_2D00_4dfe0b45db7a_5F00_PageServiceExtended_2D00_cs.zip:320:240]
[View:/cfs-file/__key/communityserver-discussions-components-files/295/0678dbf5_2D00_9d6e_2D00_452b_2D00_802f_2D00_f5092199029c_5F00_PagesServiceExtended_2D00_svc.zip:320:240]
 

This thread is closed