Exemplo n.º 1
0
        protected override string ProcessToken(ModuleActionDto model, UserInfo accessingUser, Scope accessLevel)
        {
            var title = (!String.IsNullOrEmpty(model.TitleKey) && !String.IsNullOrEmpty(model.LocalResourceFile))
                                ? Localization.GetString(model.TitleKey, model.LocalResourceFile)
                                : model.Title;

            SecurityAccessLevel securityAccessLevel = SecurityAccessLevel.View;

            if (!String.IsNullOrEmpty(model.SecurityAccessLevel))
            {
                switch (model.SecurityAccessLevel)
                {
                case "Edit":
                    securityAccessLevel = SecurityAccessLevel.Edit;
                    break;

                case "Admin":
                    securityAccessLevel = SecurityAccessLevel.Admin;
                    break;

                case "Host":
                    securityAccessLevel = SecurityAccessLevel.Host;
                    break;

                default:
                    securityAccessLevel = SecurityAccessLevel.View;
                    break;
                }
            }

            var moduleAction = new ModuleAction(_moduleContext.GetNextActionID())
            {
                Title  = title,
                Icon   = model.Icon,
                Secure = securityAccessLevel
            };

            if (string.IsNullOrEmpty(model.Script))
            {
                moduleAction.Url = _moduleContext.EditUrl(model.ControlKey);
            }
            else
            {
                moduleAction.Url = model.Script.StartsWith("javascript:", StringComparison.InvariantCultureIgnoreCase) ?
                                   model.Script :
                                   string.Format("javascript:{0}", model.Script);
            }

            _moduleActions.Add(moduleAction);

            return(String.Empty);
        }
Exemplo n.º 2
0
 public int GetNextActionID()
 {
     return(ModuleContext.GetNextActionID());
 }