How to enable/disable ribbon button for Administrator in SharePoint 2010.
-
8 สิงหาคม 2555 13:32I have one custom ribbon button that should be enable when administrator login in SharePoint 2010.
- แก้ไขโดย maheshmartha 8 สิงหาคม 2555 13:48
ตอบทั้งหมด
-
8 สิงหาคม 2555 15:20
Have a look at the answer on this post: http://sharepoint.stackexchange.com/questions/26861/hiding-buttons-of-the-ribbon-bar
It covers the OM methods you can use to acheive this functionality.
Brandon Atkinson - Blog: http://brandonatkinson.blogspot.com/
-
8 สิงหาคม 2555 15:34
I don't think you'll be able to enable/disable the ribbon to administrators by using SPSecurityTrimmedControl class. Because SPSecurityTrimmedClass has only the option to provide access to 'any users', or authenticated users.
For this specific case you need to use ECMA Script to find out whether the user has relevant permissions before allowing the ribbon to be rendered
function checkifUserHasEditPermissions()
{
Esubvali=false;
context = new SP.ClientContext.get_current();
web = context.get_web();
this._currentUser = web.get_currentUser();
this._theList = web.get_lists().getByTitle('Shared Documents');
context.load(this._currentUser);
context.load(web,'EffectiveBasePermissions');
context.load(this._theList, 'EffectiveBasePermissions')
context.executeQueryAsync(Function.createDelegate(this, onPermissionsSuccessMethod), Function.createDelegate(this, onPermissionsFailureMethod));
}
Please mark the replies as answers if they help or unmark if not.
- แก้ไขโดย Sundar NarasimanMVP 8 สิงหาคม 2555 15:34
- ทำเครื่องหมายเป็นคำตอบโดย Lhan HanModerator 16 สิงหาคม 2555 3:28
-
8 สิงหาคม 2555 16:08
Hi Sundar Narasiman,
I have fallowed this link this link but no luck here i am not able to getting return value back with this method context.executeQueryAsync(Function.createDelegate(this, onPermissionsSuccessMethod), Function.createDelegate(this, onPermissionsFailureMethod));
if i use method like this context.executeQueryAsync(Function.createDelegate(this, this.onPermissionsSuccessMethod), Function.createDelegate(this, this.onPermissionsFailureMethod));
getting error could you please help me on this
Thanks in advance
Esubvali sayyed
-
8 สิงหาคม 2555 16:15
I have one custom ribbon button that should be enable when administrator login in SharePoint 2010.
Hi,
In the solution you are defining your custom action , you can add RequireSiteAdministrator attribute and set it to TRUE or if you would need more complex permission check you can add Rights attribute and specify permission mask that user should have to see your action.
EG:
<CustomAction Description="Search Title on Bing" Title="Bing It!" Id="{E538E8C7-65DA-454E-AD87-4A603B6CC569}" Location="CommandUI.Ribbon.DisplayForm" RegistrationId="100" RegistrationType="List" RequireSiteAdministrator="TRUE" Sequence="0" xmlns="http://schemas.microsoft.com/sharepoint/"> ... </CustomAction>or
<CustomAction Description="Search Title on Bing" Title="Bing It!" Id="{E538E8C7-65DA-454E-AD87-4A603B6CC569}" Location="CommandUI.Ribbon.DisplayForm" RegistrationId="100" RegistrationType="List" Sequence="0" Rights="ViewListItems,ManageAlerts" xmlns="http://schemas.microsoft.com/sharepoint/"> ... </CustomAction>
LinkedIn Profile
SharePoint Advanced Visibility Options project
SharePoint Managed Metadata Claims Provider project- แก้ไขโดย HeToCMicrosoft Community Contributor 8 สิงหาคม 2555 16:16
- ทำเครื่องหมายเป็นคำตอบโดย Lhan HanModerator 16 สิงหาคม 2555 3:28
-
9 สิงหาคม 2555 9:08
Hi HeToC
Thanks for your valuable suggestions,Custom Action is supporting to ECB menu items but in case ribbon button how to enable the script based on the user permissions? Could you please tell me how to enable ribbon button
Thanks in Advance
Esubvali Sayyed
-
9 สิงหาคม 2555 18:44
Hi Sayyed
btw: Custom Action can be used for Ribbon buttons too.
Can you post here the ID of the button you want to be enabled if it is a standard sharepoints' ones,
or in case of a custom solution and you have its source code please post here its Custom Action xml definition.
LinkedIn Profile
SharePoint Advanced Visibility Options project
SharePoint Managed Metadata Claims Provider project -
13 สิงหาคม 2555 15:55
Hi,
Finally i achieved with this
EnabledScript="javascript:
var test = false;
function onQuerySucceeded(sender, args) {
isView();
}
function onQueryFailed(sender, args) {
//failed code here
}
function isView() {
this._currentUser = web.get_currentUser();
this._theList = web.get_lists().getById(this.selectedList);
this.clientContext.load(this._currentUser);
this.clientContext.load(web,'EffectiveBasePermissions');
this.clientContext.load(this._theList, 'EffectiveBasePermissions')
this.clientContext.executeQueryAsync(
Function.createDelegate(this, isUserAuthorizedSuccess),
Function.createDelegate(this, isUserAuthorizedFailed));
}
function isUserAuthorizedSuccess(sender, args) {
this.testPermitrequest = true;
if (this._theList.get_effectiveBasePermissions().has(SP.PermissionKind.editListItems))
{
this.testbyValue = true;
this.testtoValue = true;
if (this.testbyValue == true && this.testtoValue == true) {
test = true;
}
}
else
{
this.testbyValue = false;
}
RefreshCommandUI();
}
function isUserAuthorizedFailed(sender, args) {
//failed code here
}
function SelectedFilesRequest() {
//this.selectedItem = SP.ListOperation.Selection.getSelectedItems();
this.clientContext = SP.ClientContext.get_current();
web = clientContext.get_web();
this.selectedList = SP.ListOperation.Selection.getSelectedList();
this.listItem = web.get_lists().getById(this.selectedList);
this.clientContext.load(listItem, 'Title', 'Id');
this.clientContext.executeQueryAsync(Function.createDelegate(this, onQuerySucceeded), Function.createDelegate(this, onQueryFailed));
}
function enableButtonRequest() {
var listGuid = SP.ListOperation.Selection.getSelectedList();
test = false;
if (listGuid !=null) {
if (this.adminItemIdenable != listGuid) {
this.adminItemIdenable = listGuid;
SelectedFilesRequest();
} else if (this.testbyValue == true && this.testtoValue == true ) {
if (this.testPermitrequest == true) {
test = true;
} else {
test = false;
}
}
}
return test;
}
enableButtonRequest();"/>Its working for me
Thanks
Esubvali Sayyed
- เสนอเป็นคำตอบโดย Sayyed Esubvali 13 สิงหาคม 2555 15:56
- ทำเครื่องหมายเป็นคำตอบโดย Lhan HanModerator 16 สิงหาคม 2555 3:28