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; page.Permissions = _permissionRepository.EncodePermissions(new List <Permission> { new Permission(PermissionNames.View, userid, true), new Permission(PermissionNames.Edit, userid, true) }); page.IsPersonalizable = false; page.UserId = int.Parse(userid); page = _pages.AddPage(page); _syncManager.AddSyncEvent(EntityNames.Site, page.SiteId); // 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; module.Permissions = _permissionRepository.EncodePermissions(new List <Permission> { new Permission(PermissionNames.View, userid, true), new Permission(PermissionNames.Edit, userid, true) }); 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); }
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; }
public string Export(int moduleid) { string content = ""; if (_userPermissions.IsAuthorized(User, EntityNames.Module, moduleid, PermissionNames.Edit)) { content = _modules.ExportModule(moduleid); } else { _logger.Log(LogLevel.Error, this, LogFunction.Other, "User Not Authorized To Export Module {ModuleId}", moduleid); HttpContext.Response.StatusCode = 401; } return(content); }
public string Export(int moduleid) { string content = ""; var module = _modules.GetModule(moduleid); if (module != null && module.SiteId == _alias.SiteId && _userPermissions.IsAuthorized(User, EntityNames.Module, module.ModuleId, PermissionNames.Edit)) { content = _modules.ExportModule(moduleid); if (!string.IsNullOrEmpty(content)) { _logger.Log(LogLevel.Information, this, LogFunction.Read, "Module Content Exported {ModuleId}", moduleid); } else { _logger.Log(LogLevel.Warning, this, LogFunction.Read, "No Module Content Exported {ModuleId}", moduleid); } } else { _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Module Export Attempt {ModuleId}", moduleid); HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden; } return(content); }
public Page Post(int id, string userid) { Page page = null; Page parent = _pages.GetPage(id); if (parent != null && parent.SiteId == _alias.SiteId && parent.IsPersonalizable && _userPermissions.GetUser(User).UserId == int.Parse(userid)) { page = new Page(); page.SiteId = parent.SiteId; page.Name = parent.Name; page.Title = parent.Title; page.Path = parent.Path; page.ParentId = parent.PageId; page.Order = 0; page.IsNavigation = false; page.Url = ""; page.ThemeType = parent.ThemeType; page.DefaultContainerType = parent.DefaultContainerType; page.Icon = parent.Icon; page.Permissions = new List <Permission> { new Permission(PermissionNames.View, int.Parse(userid), true), new Permission(PermissionNames.Edit, int.Parse(userid), true) }.EncodePermissions(); page.IsPersonalizable = false; page.UserId = int.Parse(userid); page = _pages.AddPage(page); _syncManager.AddSyncEvent(_alias.TenantId, EntityNames.Site, page.SiteId); // 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; module.AllPages = false; module.Permissions = new List <Permission> { new Permission(PermissionNames.View, int.Parse(userid), true), new Permission(PermissionNames.Edit, int.Parse(userid), true) }.EncodePermissions(); 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); } } else { _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Page Post Attempt {PageId} By User {UserId}", id, userid); HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden; page = null; } return(page); }