Disable Set as Homepage

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

Disable Set as Homepage

All Replies

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

Hi,

I've read a lot of posts concerning this issue, but I can't seem to find the answer. I want to disable the 'Set as homepage' option from the Action menu. Some users can create/modify pages in a section of the web site, including the properties. They can't change properties of the current home page. But they CAN set one of their pages as home page. Therefore changing the properties of the Home page. How can I prevent this?

ps. I'm using SF 7.2.

Thanks in advance,
Arjan Vermunt

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

Hello Arjan,

Yes, this is a known issue described here: Ability to Change Homepage should be able to be restricted

We are planning in some of our future releases to perform a complete code refactoring of Sitefinity`s permissions module to provide more flexibility and cover scenarios as your current one.

Kind regards,
Vassil Vassilev
Telerik

 
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
 

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

Just a quick follow up: your scenario can be achieved using custom code rather easily by simply extending PageService (I have attached the necessary files to achieve this).

The steps required are:

  • include PageServiceExtended.cs in your solution
  • include PageServiceExtended.svc in ~\Sitefinity\Services\Pages\PageServiceExtended.svc
  • build the solution
  • go to Administration >> Settings >> Advanced >> ContentView >> Controls >> FrontendPagesListView and under  WebServiceBaseUrl type the new one: ~/Sitefinity/Services/Pages/PagesServiceExtended.svc/
  • restart the application


When someone changes the home page is called:

public void SetHomePage(string pageId)
    pageservice.SetHomePage(pageId);


What you can do is to check if the current user belongs to a restricted role and if he does, to skip the line "pageservice.SetHomePage(pageId)" method.

Hope this helps.

Regards,
Vassil Vassilev
Telerik

 
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/46f8371b_2D00_9b12_2D00_4424_2D00_8054_2D00_c02c8f7daf89_5F00_PagesServiceExtended_2D00_svc.zip:320:240]
[View:/cfs-file/__key/communityserver-discussions-components-files/295/984ee8ee_2D00_568c_2D00_47e2_2D00_8ae7_2D00_c838b18fcac8_5F00_PageServiceExtended_2D00_cs.zip:320:240]
 

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

Hi Vassil,

The solution you supplied works like a charm.

Can the same be done for editing Lists/List Items. I have a support call concerning ownership of Lists. I want to prevent users, other than the owner of the List, editing List Items in that List. Can I create a custom service for editing List Items in Lists.

Thanks,
Arjan

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

Hello Arjan,

I am glad this helped.

You can modifying the lists following the approach with the pages- easiest solution is to modify the service not to return the lists, for which the user does not an owner (maybe there should be additional logic for admins to see all lists).

This can be achieved as follows:

  • add ListServiceExtended.svc in ~\Sitefinity\Services\Pages\ListServiceExtended.svc
  • add ListServiceExtended.cs in your project
  • build it
  • go to Administration >> Settings >> Advanced >> ContentView >> Controls >> ListsBackend >> Views >> ListsBackendList  and under  WebServiceBaseUrl type the new one: ~/Sitefinity/Services/Pages/ListServiceExtended.svc/
  • restart the application


The trick is to add custom logic in here:

public override IEnumerable<ListViewModel> GetViewModelList(IEnumerable<List> contentList, ContentDataProviderBase dataProvider)
    var viewModels = listservice.GetViewModelList(contentList, dataProvider);
    return viewModels;


You can filter viewModels before the service return it as you need - for instance you can remove any lists that the user should not modify and they will not be displayed in the grid.

Hope this information helps.


Regards, Vassil Vassilev
Telerik

 
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/2e68c37d_2D00_7306_2D00_4cd8_2D00_a370_2D00_b2915e74655c_5F00_ListServiceExtended.zip:320:240]
[View:/cfs-file/__key/communityserver-discussions-components-files/295/ec15d220_2D00_761c_2D00_473a_2D00_8e45_2D00_f6c8ec4e3cf5_5F00_ListServiceExtended.zip:320:240]

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

Hi Vassil,

I gave your suggestion a go and was able to override the default behavior of fetching the lists. How can I determine the id of the owner. The Lists object has an Owner property of type string, but that seems to be a concatenation of the First and Last name. Which api should I use to compare the current user against the owner of the list?

Thnx,
Arjan

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

Hello,

I could suggest the following approach:

public override IEnumerable<ListViewModel> GetViewModelList(IEnumerable<List> contentList, ContentDataProviderBase dataProvider)
    var identity = ClaimsManager.GetCurrentIdentity();
    var UserId = identity.UserId;
     
    var viewModels = listservice.GetViewModelList(contentList, dataProvider).Where(vm => vm.ContentItem.Owner == UserId).ToList();
    return viewModels;

Keep in mind that you need to add additional check for admin users.

Hope this helps.

Regards,
Vassil Vassilev
Telerik
 
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
 

This thread is closed