示例#1
0
        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));
        }
示例#2
0
        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);
            }
        }
示例#3
0
 public static string GetCommandName(this ListMetadataAction action)
 {
     return(string.Format("{0}.{1}", action.Id.ToString("N"), "Command"));
 }