70 likes | 168 Views
How to Enable/Disable Ribbon button in CustomAction Element base on user’s rights? . Lyudmila Zharova SharePoint Developer at MRM Worlwide lzharova077@gmail.com 12 /15/2010. SharePoint 2010 Extensibility Projects can be downloaded from the MSDN Code Gallery here:
E N D
How to Enable/Disable Ribbon button in CustomAction Element base on user’s rights? Lyudmila Zharova SharePoint Developer at MRM Worlwide lzharova077@gmail.com 12/15/2010
SharePoint 2010 Extensibility Projects can be downloaded from the MSDN Code Gallery here: http://code.msdn.microsoft.com/vsixforsp and use a new SharePoint Ribbon Project Template Andrew Connel explained how to: -Handle Events in the SharePoint Ribbon http://www.andrewconnell.com/blog/archive/2010/10/11/handling-events-in-the-sharepoint-ribbon.aspx - Asynchronously check if a command is available in the SharePoint Ribbon: http://www.andrewconnell.com/blog/archive/2010/10/14/asynchronously-checking-if-a -command-is-available-in-the-sharepoint.aspx To verify if the user has permission on the item level you can use EsmaScript: get_effectiveBasePermissions().has(SP.PermissionKind.editListItems)) You can hide the Ribbon from Anonymus users and allow only logged in users with the right permissions to see it by placing SPSecurityTrimmedControl on your custom master page.
Open and check-out your master page, find where your ribbon control starts or look for <WebPartPages:SPWebPartManager id=”m” runat=”Server”/> Place this control below <Sharepoint:SPSecurityTrimmedControlrunat=”server” Permissions=” ManageLists”> Find where your ribbon control ends or look for <div id=s4-workspace> and place the closing control above it </SharePoint:SPSecurityTrimmedControl> Save, check-in the master page and publish it to see the changes. Set the correct permissions in the Permissions attribute
How to Enable/Disable Ribbon button in CustomAction Element base on user’s rights? <CustomAction … Rights = "ApproveItems" … </CustomAction> “Rights” attribute is optional ApproveItems - Approve a minor version of a list item or document. According to msdn article http://msdn.microsoft.com/en-us/library/ms460194.aspx it specifies a set of rights that the user must have for the link to be visible, for example, "ApproveItems, ViewListItems, ManageAlerts". If it is not specified, the action always appears in the list of actions. To specify multiple rights, separate the values by using commas. The set of rights are grouped logically according to AND logic, which means that a user must have all the specified rights to see an action. To see all SPBasePermissions Enumeration follow this link: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spbasepermissions.aspx