private async Task <string> Publish(string s, PageModule pagemodule)
        {
            var permissions = UserSecurity.GetPermissionStrings(pagemodule.Module.Permissions);

            foreach (var permissionstring in permissions)
            {
                if (permissionstring.PermissionName == PermissionNames.View)
                {
                    List <string> ids = permissionstring.Permissions.Split(';').ToList();
                    if (!ids.Contains(Constants.AllUsersRole))
                    {
                        ids.Add(Constants.AllUsersRole);
                    }
                    if (!ids.Contains(Constants.RegisteredRole))
                    {
                        ids.Add(Constants.RegisteredRole);
                    }
                    permissionstring.Permissions = string.Join(";", ids.ToArray());
                }
            }
            pagemodule.Module.Permissions = UserSecurity.SetPermissionStrings(permissions);
            await ModuleService.UpdateModuleAsync(pagemodule.Module);

            return(NavigateUrl(s, "reload"));
        }
示例#2
0
        private async Task <string> Publish(string url, PageModule pagemodule)
        {
            var permissions = UserSecurity.GetPermissionStrings(pagemodule.Module.Permissions);

            foreach (var permissionstring in permissions)
            {
                if (permissionstring.PermissionName == PermissionNames.View)
                {
                    List <string> ids = permissionstring.Permissions.Split(';').ToList();
                    if (!ids.Contains(RoleNames.Everyone))
                    {
                        ids.Add(RoleNames.Everyone);
                    }
                    if (!ids.Contains(RoleNames.Registered))
                    {
                        ids.Add(RoleNames.Registered);
                    }
                    permissionstring.Permissions = string.Join(";", ids.ToArray());
                }
            }
            pagemodule.Module.Permissions = UserSecurity.SetPermissionStrings(permissions);
            await ModuleService.UpdateModuleAsync(pagemodule.Module);

            return(url);
        }
示例#3
0
 public Page Post([FromBody] Page Page)
 {
     if (ModelState.IsValid)
     {
         string permissions;
         if (Page.ParentId != null)
         {
             permissions = Pages.GetPage(Page.ParentId.Value).Permissions;
         }
         else
         {
             permissions = UserSecurity.SetPermissionStrings(new List<PermissionString> { new PermissionString { PermissionName = "Edit", Permissions = Constants.AdminRole } });
         }
     
         if (UserPermissions.IsAuthorized(User, "Edit", permissions))
         {
             Page = Pages.AddPage(Page);
             logger.Log(LogLevel.Information, this, LogFunction.Create, "Page Added {Page}", Page);
         }
         else
         {
             logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add Page {Page}", Page);
             HttpContext.Response.StatusCode = 401;
             Page = null;
         }
     }
     return Page;
 }
示例#4
0
        public Page Post(int id, string userid)
        {
            Page page = null;
            Page parent = Pages.GetPage(id);
            if (parent != null && parent.IsPersonalizable && UserPermissions.GetUser(User).UserId == int.Parse(userid))
            {
                page = new Page();
                page.SiteId = parent.SiteId;
                page.Name = parent.Name;
                page.Path = parent.Path;
                page.ParentId = parent.PageId;
                page.Order = 0;
                page.IsNavigation = false;
                page.EditMode = false;
                page.ThemeType = parent.ThemeType;
                page.LayoutType = parent.LayoutType;
                page.Icon = parent.Icon;
                List<PermissionString> permissions = new List<PermissionString>();
                permissions.Add(new PermissionString { PermissionName = "View", Permissions = "[" + userid + "]" });
                permissions.Add(new PermissionString { PermissionName = "Edit", Permissions = "[" + userid + "]" });
                page.Permissions = UserSecurity.SetPermissionStrings(permissions);
                page.IsPersonalizable = false;
                page.UserId = int.Parse(userid);
                page = Pages.AddPage(page);

                // copy modules
                List<PageModule> pagemodules = PageModules.GetPageModules(page.SiteId).ToList();
                foreach (PageModule pm in pagemodules.Where(item => item.PageId == parent.PageId && !item.IsDeleted))
                {
                    Module module = new Module();
                    module.SiteId = page.SiteId;
                    module.PageId = page.PageId;
                    module.ModuleDefinitionName = pm.Module.ModuleDefinitionName;
                    permissions = new List<PermissionString>();
                    permissions.Add(new PermissionString { PermissionName = "View", Permissions = "[" + userid + "]" });
                    permissions.Add(new PermissionString { PermissionName = "Edit", Permissions = "[" + userid + "]" });
                    module.Permissions = UserSecurity.SetPermissionStrings(permissions);
                    module = Modules.AddModule(module);

                    string content = Modules.ExportModule(pm.ModuleId);
                    if (content != "")
                    {
                        Modules.ImportModule(module.ModuleId, content);
                    }

                    PageModule pagemodule = new PageModule();
                    pagemodule.PageId = page.PageId;
                    pagemodule.ModuleId = module.ModuleId;
                    pagemodule.Title = pm.Title;
                    pagemodule.Pane = pm.Pane;
                    pagemodule.Order = pm.Order;
                    pagemodule.ContainerType = pm.ContainerType;

                    PageModules.AddPageModule(pagemodule);
                }
            }
            return page;
        }
        private async Task <string> Unpublish(string s, PageModule pagemodule)
        {
            var permissions = UserSecurity.GetPermissionStrings(pagemodule.Module.Permissions);

            foreach (var permissionstring in permissions)
            {
                if (permissionstring.PermissionName == PermissionNames.View)
                {
                    List <string> ids = permissionstring.Permissions.Split(';').ToList();
                    ids.Remove(RoleNames.Everyone);
                    ids.Remove(RoleNames.Registered);
                    permissionstring.Permissions = string.Join(";", ids.ToArray());
                }
            }
            pagemodule.Module.Permissions = UserSecurity.SetPermissionStrings(permissions);
            await ModuleService.UpdateModuleAsync(pagemodule.Module);

            return(NavigateUrl(s, "reload"));
        }
示例#6
0
 public Folder Post([FromBody] Folder Folder)
 {
     if (ModelState.IsValid)
     {
         string permissions;
         if (Folder.ParentId != null)
         {
             permissions = _folders.GetFolder(Folder.ParentId.Value).Permissions;
         }
         else
         {
             permissions = UserSecurity.SetPermissionStrings(new List <PermissionString> {
                 new PermissionString {
                     PermissionName = "Edit", Permissions = Constants.AdminRole
                 }
             });
         }
         if (_userPermissions.IsAuthorized(User, "Edit", permissions))
         {
             if (string.IsNullOrEmpty(Folder.Path) && Folder.ParentId != null)
             {
                 Folder parent = _folders.GetFolder(Folder.ParentId.Value);
                 Folder.Path = parent.Path + Folder.Name + "\\";
             }
             Folder = _folders.AddFolder(Folder);
             _logger.Log(LogLevel.Information, this, LogFunction.Create, "Folder Added {Folder}", Folder);
         }
         else
         {
             _logger.Log(LogLevel.Error, this, LogFunction.Create, "User Not Authorized To Add Folder {Folder}", Folder);
             HttpContext.Response.StatusCode = 401;
             Folder = null;
         }
     }
     return(Folder);
 }
 public string GetPermissions()
 {
     ValidatePermissions();
     return(UserSecurity.SetPermissionStrings(_permissions));
 }