예제 #1
0
        protected virtual HyperLink AddAnchor(Control container, PluginContext context)
        {
            string tooltip     = Utility.GetResourceString(GlobalResourceClassName, Name + ".ToolTip") ?? ToolTip;
            string title       = Utility.GetResourceString(GlobalResourceClassName, Name + ".Title") ?? Title;
            string alternative = Utility.GetResourceString(GlobalResourceClassName, Name + ".AlternativeText") ?? AlternativeText;

            HyperLink a = new HyperLink();

            a.ID          = "h" + Name;
            a.NavigateUrl = context.Rebase(context.Format(UrlFormat, true));
            a.SkinID      = "ToolBarLink_" + Name;

            a.Target = Target;
            a.Attributes["class"] = Name + " " + RequiredPermission.ToString() + (string.IsNullOrEmpty(IconUrl) ? "" : " iconed");
            if (UrlFormat.Contains("{"))
            {
                a.Attributes["class"]            += " templatedurl";
                a.Attributes["data-url-template"] = context.Rebase(UrlFormat);
            }
            a.ToolTip = tooltip;
            a.Text    = title;
            ApplyStyles(context, a);

            container.Controls.Add(a);
            return(a);
        }
예제 #2
0
 public RequirePermissionAttribute(RequiredPermission requiredPermission)
 {
     RequiredPermission = requiredPermission;
 }
예제 #3
0
파일: Util.cs 프로젝트: vendstor/vendstor
            public static bool IsUserAllowed(Objects.User user, PermissionAlertType alertType = PermissionAlertType.None, Form form = null, RequiredPermission reqPermission = RequiredPermission.Admin)
            {
                if (user == null)
                {
                    return(false);
                }

                bool isAllowed = true;

                switch (reqPermission)
                {
                case RequiredPermission.Admin:
                    if (user.Role.ToLower() != "admin")
                    {
                        isAllowed = false;
                    }
                    break;
                }

                //Alert User
                if (!isAllowed)
                {
                    switch (alertType)
                    {
                    case PermissionAlertType.Alert:
                        Alert.Show("Limited Permission", "You must be an Admin to perform this action.", Alert.AlertType.Warning);
                        break;

                    case PermissionAlertType.Message:
                        MessageParser.Permission(caller: form);
                        break;

                    case PermissionAlertType.None:
                        break;
                    }
                }

                return(isAllowed);
            }