public static string GetButtonAsXml(this ListMetadataAction action) { XDocument btnDoc = new XDocument( new XElement("Button", new XAttribute("Id", action.Id.ToString("N")), new XAttribute("Sequence", action.Sequence.ToString()), new XAttribute("Image32by32", action.ImageUrl), new XAttribute("Description", action.Description ?? string.Empty), new XAttribute("Command", action.GetCommandName()), new XAttribute("LabelText", action.LabelText), new XAttribute("TemplateAlias", "ONERW"))); return(btnDoc.ToString(SaveOptions.DisableFormatting)); }
public static bool IsVisibleForUser(this ListMetadataAction customAction, SPUser user) { try { if (string.IsNullOrEmpty(customAction.AccessGroup.Trim())) { return(true); } return(SPContext.Current.Web.CurrentUser.ID == SPContext.Current.Site.SystemAccount.ID || customAction.AccessGroup.Split(';').Select(g => g.ToUpper()).Intersect(user.Groups.Cast <SPGroup>().Select(gr => gr.Name.ToUpper())).Any()); } catch { return(false); } }
public static string GetCommandName(this ListMetadataAction action) { return(string.Format("{0}.{1}", action.Id.ToString("N"), "Command")); }