protected void Page_Load(object sender, EventArgs e) { // get the page navigation id if (!int.TryParse(Request.QueryString["InstanceId"], out _instanceId)) { _instanceId = WebModulesProfile.Current.StartPageId; if (_instanceId <= 0) { _instanceId = Webpage.RootNavigationId; } } if (!IsPostBack) { //check user permissions. if (!NavigationRole.IsUserAuthorized(_instanceId, Page.User)) { throw new System.Security.SecurityException(Permission.MSG_SECURITY_FAILURE); } bool allowEdit = Permission.AllowEditContent(); bool allowManagePage = Permission.AllowManagePage(); //sort buttons ModulesGridView.Columns[3].Visible = allowEdit; ModulesGridView.Columns[4].Visible = allowEdit; //settings ModulesGridView.Columns[5].Visible = allowEdit; //delete ModulesGridView.Columns[6].Visible = allowManagePage; LoadModules(); } }
protected void SubpagesGridView_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { WebpageInfo page = e.Row.DataItem as WebpageInfo; //disable the page if the user does not have permissions to it. e.Row.Enabled = NavigationRole.IsUserAuthorized(page.InstanceId, Page.User); string iconPath = "~/WebModules/Admin/Images/Icons/Small/"; Image iconImage = (Image)e.Row.Cells[0].FindControl("IconImage"); if (e.Row.Enabled) { if (page.IsAlias || !string.IsNullOrEmpty(page.ExternalUrl)) { iconImage.ImageUrl = iconPath + "WebpageAlias.png"; } else { iconImage.ImageUrl = iconPath + "Webpage.gif"; } } else { iconImage.ImageUrl = iconPath + "Security.gif"; } } }
public JsonResult Edit(NavigationDto request) { PageResponse response = new PageResponse(); Navigation model = new Navigation() { Areas = request.Areas, ControllerName = request.ControllerName, Icon = request.Icon, Id = request.Id, IsSys = request.IsSys, Link = request.Link, Name = request.Name, ParentId = request.ParentId, Sort = request.Sort, Level = request.Level }; //删除该菜单下,所有的权限按钮 var list_role = _NavigationRoleService.GetList(m => m.NId == model.Id).ToList(); foreach (var item in list_role) { _NavigationRoleService.Delete(item.Id); } //新增菜单权限 foreach (var item in request.DictList) { NavigationRole m_nr = new NavigationRole() { Id = Guid.NewGuid().GuidTo16String(), DId = item.Id, NId = model.Id, Status = item.Status }; _NavigationRoleService.Add(m_nr); } _NavigationService.Update(model); zTree ztree = new zTree() { id = model.Id, pId = model.ParentId ?? "0", name = model.Name, open = true }; if (model.IsSys == 1) { ztree.noEditBtn = true; ztree.noRemoveBtn = true; } //获取菜单权限字典 response.code = StatusCodeDefine.Success; response.status = 0; response.data = ztree; return(Json(response)); }
/// <summary> /// 更新一条数据 /// </summary> public virtual void Update(NavigationRole model) { using (var session = sessionFactory.OpenSession()) { session.SaveOrUpdate(model); session.Flush(); } }
/// <summary> /// 增加一条数据 /// </summary> public virtual object Save(NavigationRole model) { using (ISession session = sessionFactory.OpenSession()) { var id = session.Save(model); session.Flush(); return(id); } }
public JsonResult Create(NavigationDto request) { Navigation model = new Navigation() { Areas = request.Areas, ControllerName = request.ControllerName, Icon = request.Icon, Id = Guid.NewGuid().GuidTo16String(), IsSys = request.IsSys, Link = request.Link, Name = request.Name, ParentId = request.ParentId, Sort = request.Sort, Level = request.Level }; var id = _NavigationService.Add(model); //新增菜单权限 foreach (var item in request.DictList) { NavigationRole m_nr = new NavigationRole() { Id = Guid.NewGuid().GuidTo16String(), DId = item.Id, NId = model.Id, Status = item.Status }; _NavigationRoleService.Add(m_nr); } zTree ztree = new zTree() { id = model.Id, pId = model.ParentId ?? "0", name = model.Name, open = true }; if (model.IsSys == 1) { ztree.noEditBtn = true; ztree.noRemoveBtn = true; } PageResponse response = new PageResponse(); response.code = StatusCodeDefine.Success; response.status = 0; response.data = ztree; return(Json(response)); }
void load_(WebpageInfo p) { // //the business rules of inheritance are implemented by NavigationRole.IsUserAuthorized() //using NavigationRole.GetAcl(); the rules are followed in the same way by this //control, PageSecurity.ascx, and therefore there is a precarious coupling between //the two. In the future we will encapsulate the ACL/IsPublic business rules. // bool isPublic; NavigationRoleCollection acl = NavigationRole.GetAcl(p, true, out isPublic); AclList.DataSource = acl; AclList.DataBind(); IsPublic.Checked = isPublic; if (!isPublic && p.IsPublic) { IsPublic.Enabled = false; IsPublic.Text = "Public (inherited)"; } else { IsPublic.Text = "Public"; } // //set help text // if (isPublic) //overrides role assignments { HelpText.Text = "<strong>All users,</strong> including anonymous/public users, can access the page."; } else if (acl.Count > 0) { HelpText.Text = "<strong>Access is restricted.</strong> Only the roles listed below have access to the page."; } else { HelpText.Text = "<strong>All logged-in users</strong> can access the page. Anonymous/public users cannot access the page."; } }
protected void Page_Load(object sender, EventArgs e) { // get the current page navigation id if (!int.TryParse(Request.QueryString["InstanceId"], out _instanceId)) { _instanceId = WebModulesProfile.Current.StartPageId; if (_instanceId <= 0) { _instanceId = Webpage.RootNavigationId; } } _isSystemRoot = (_instanceId == Webpage.RootNavigationId); //check user permissions. if (!NavigationRole.IsUserAuthorized(_instanceId, Page.User)) { throw new System.Security.SecurityException(BayshoreSolutions.WebModules.Security.Permission.MSG_SECURITY_FAILURE); } SubpagesDataSource.SelectParameters["parentNavigationId"].DefaultValue = _instanceId.ToString(); if (!IsPostBack) { // get the current page instance WebpageInfo page = Webpage.GetWebpage(_instanceId); if (null == page) { throw new ArgumentException(string.Format("Page with instance id '{0}' does not exist.", _instanceId)); } // set page details WebpageNameLink.Text = page.Text; WebpageUrlLabel.Text = Bss.Web.Html.InsertSoftBreaks(page.Path.TrimStart('~'), 90); TitleLabel.Text = page.Title; Keywords_p.Visible = (page.MetaKeywords != null && page.MetaKeywords.Trim().Length > 0); KeywordsLabel.Text = page.MetaKeywords; Description_p.Visible = (page.MetaDescription != null && page.MetaDescription.Trim().Length > 0); DescriptionLabel.Text = page.MetaDescription; AddPageLink.Visible = Permission.AllowManagePage(); AddPageLink.NavigateUrl = "AddWebpage.aspx?parentInstanceId=" + _instanceId; uxAddLink.Visible = AddPageLink.Visible; uxAddLink.NavigateUrl = "AddLink.aspx?parentInstanceId=" + _instanceId; AddModuleLink.NavigateUrl = string.Format( "AddModule.aspx?PageId={0}&InstanceId={1}", page.Id, _instanceId); // // set the UI based on the type of page. // if (_isSystemRoot) { //this is the system root--not an actual page. AddPageLink.Text = "New Website"; WebpageNameLink.NavigateUrl = null; WebpageNameLink.CssClass += " disabled"; uxAddLink.Visible = false; //it wouldn't make sense to use a link as a website root. PageDetails_div.Visible = false; Modules_div.Visible = false; WebpageUrlLabel.Visible = false; AddModuleLink.Visible = false; HideSortButtons(); } else if (null == page.Website) { //the root page is not associated with a website, so any link would be bogus. WebpageNameLink.NavigateUrl = null; WebpageNameLink.CssClass += " disabled"; WebpageNameLink.ToolTip = "This page is not associated with a website."; } else if (page.Website.SiteId != Website.Current.SiteId) { //the page's website is different than the current website, therefore we must use a kludge. //DO NOT USE THE 'webmodules_websiteId' QUERY-STRING ANYWHERE ELSE-- //WE DO NOT WANT ANOTHER QUERY-STRING DEPENDENCY IN THE CMS. WebpageNameLink.NavigateUrl += page.Path + "?webmodules_websiteId=" + page.Website.SiteId; // "/?NavigationId=" + page.InstanceId; } else { //joy! we are administering the current website. WebpageNameLink.NavigateUrl = page.Path; } if (!Permission.AllowManagePage()) { HideSortButtons(); } // check IsAlias before checking ExternalUrl (otherwise an alias //_to_ an external link will look like an external link). if (page.IsAlias) { AddModuleLink.Visible = false; } else if (!string.IsNullOrEmpty(page.ExternalUrl)) { //the navigation instance is an external link. AddModuleLink.Visible = false; } //bind the settings list. PageSettingsList1.DataSource = GetPageSettings(page); PageSettingsList1.DataBind(); PageSettings_div.Visible = (PageSettingsList1.Items.Count > 0); } }
public IActionResult Authorize(string Id) { //获取所有的权限按钮 List <DictDto> list_dict = GetDictRole(); //获取菜单所有的按钮 var res = _NavigationRoleService.GetList(new NavigationRoleDto() { NId = Id }); if (res.total > 0) { var NRList = (List <NavigationRoleDto>)res.data; var list_dict_new = list_dict.Where(m => NRList.Select(p => p.DId).Contains(m.Id)).ToList(); //权限按钮交集 var NRList_new = NRList.Where(m => list_dict.Select(p => p.Id).Contains(m.DId)).ToList(); //菜单按钮交集 NRList.RemoveAll(m => NRList_new.Select(p => p.Id).Contains(m.Id)); list_dict.RemoveAll(m => list_dict_new.Select(p => p.Id).Contains(m.Id)); List <NavigationRole> list_nr_add = new List <NavigationRole>(); List <NavigationRole> list_nr_del = new List <NavigationRole>(); foreach (var item in list_dict) { NavigationRole nr_model = new NavigationRole() { Id = Guid.NewGuid().GuidTo16String(), DId = item.Id, NId = Id, Status = 0 }; list_nr_add.Add(nr_model); } list_nr_del = _IMapper.Map <List <NavigationRole> >(NRList); _NavigationRoleService.Add(list_nr_add, false); _NavigationRoleService.Delete(list_nr_del, false); } else { List <NavigationRole> list_nr_init = new List <NavigationRole>(); foreach (var item in list_dict) { NavigationRole nr_model = new NavigationRole() { Id = Guid.NewGuid().GuidTo16String(), DId = item.Id, NId = Id, Status = 0 }; list_nr_init.Add(nr_model); } _NavigationRoleService.Add(list_nr_init, false); } _NavigationRoleService.SaveChanges(); var response = _NavigationRoleService.GetList(new NavigationRoleDto() { NId = Id }); ViewData["list_nr"] = response.data; return(View()); }
/// <summary> /// 修改 /// </summary> /// <param name="m_user"></param> /// <returns></returns> public void Update(NavigationRole model) { dao.Update(model); }
/// <summary> /// 添加 /// </summary> /// <param name="m_user"></param> /// <returns></returns> public string Save(NavigationRole model) { return(dao.Save(model).ToString()); }