Permissions for all the widgets in a page.
Hi team,
I have some doubts in setting the permissions of widgets in a page.
Instead of assigning the permission for each widget separate inside a page, is there any option to set the permission globally for all the widgets of a page.
In our project we have 2 main roles content manager and content writer. content manager should able to edit, move, delete and can add new content widget to the main page. And content writer only should able to edit and update the content widget to the main page, he is not allowed to delete or move the content widget. Finally it is worked well by editing the permission of each widget separate separately, also i checked it by logging in as content writer and content manager.
but to do this we need to edit the permission of each widget separately. If i delete a content widget and added a new content widget in that same place the permission of deleted content widget is not inherited to the new one. and again we need to set the permission from the scratch. so im searching a way to set the permission globally. i also searched a lot about page permission and permissions of all page, but there is no option to set move, delete permission for the widget, only edit content of the page, add widget to the page permission is there.
so now my question is,
1. how to set permission to (move, delete, edit) all content widgets of a page(globally)?. and
2. how to inherit the permissions to new content widget from the deleted one, or from the another content widget of the same page?.
Thank u.
Hi,
Answering the two questions:
1. To set permissions on widgets different than the default set of permissions is best to do this using Sitefinity API for permissions. This is because the default permissions for widgets are rooted in the PageManager class.
To update permissions on a widget refer to the attached UpdatePermissionsOnWidget.zip containing a webform that accepts a title of a page and loops trough all of this page widgets assigning Authors role to have View permission over the widgets.
SecurityConstants.Sets.Controls.View
var manager = PageManager.GetManager();
manager.CopyPermissions(control1.Permissions, (IList)control2.Permissions, control1.Id, control2.Id);