In Sharepoint 2013 there may be situations when list edit ribbon which contains such commands as Save, Attach file, etc., is not shown for the user even if user has permissions to add or edit items in this list. For example user may have Read permission on the whole SPWeb and Member permission on the list (i.e. list has unique permissions not inherited from its parent SPWeb). In order to show the ribbon we need to edit system master page used in the current SPWeb (you may check what master page is used as system master pages in Site settings > Master page). In the masterpage file find the following code:
1: <SharePoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControlManageWeb"
2: PermissionsString="ManageWeb" runat="server">
3: <script type="text/javascript">1:
2: document.getElementById("s4-ribbonrow").style.display = "block";3: document.getElementById("suiteBar").style.display = "block";4:
</script>1:
2: </SharePoint:SPSecurityTrimmedControl>
3: <SharePoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControlAddAndCustomizePages"4: PermissionsString="AddAndCustomizePages" runat="server">5: <script type="text/javascript">6: document.getElementById("s4-ribbonrow").style.display = "block";7: document.getElementById("suiteBar").style.display = "block";8:
</script>
4: </SharePoint:SPSecurityTrimmedControl>
There are 2 security trimmed controls which add the same javascript code if users have ManageWeb or AddAndCustomizePages permissions. Added javascript code shows divs with s4-ribbonrow and suiteBar ids. Div suiteBar contains Site actions gear, and s4-ribbonrow contains ribbon controls. In order to show the ribbon for the user with AddListItems permissions we need to add one more security trimmed control under these 2 controls:
1: <SharePoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControlAddListItems"
2: PermissionsString="AddListItems" PermissionContext="CurrentList" runat="server">
3: <script type="text/javascript">1:
2: document.getElementById("s4-ribbonrow").style.display = "block";3: document.getElementById("RibbonContainer-TabRowRight").style.visibility = "hidden";4:
</script>
4: </SharePoint:SPSecurityTrimmedControl>
Note that in addition to PermissionString property we added PermissionContext=”CurrentList” here. In 2 controls shown above there was no PermissionContext propery – they use default CurrentSite value. Here is the list of another values (see here):
- CurrentFolder
- CurrentItem
- CurrentList
- CurrentSite
- RootSite
Also note that we hided another child div with id=”RibbonContainer-TabRowRight”. This div contains Follow and Share links which may be not desired for users which only may add list items.
After that users which have AddListItems permissions will see list edit ribbon:
Hope that this information will be helpful.
No comments:
Post a Comment