/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Init"/> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param> protected override void OnInit(EventArgs e) { if (!this.IsEditable) { this.ModuleConfiguration.DisplayPrint = false; } SubControlInfo controlToLoad; try { base.OnInit(e); controlToLoad = this.GetControlToLoad(); } catch (LicenseException) { controlToLoad = LicenseErrorControl; } if (!controlToLoad.RequiresEditPermission || PortalSecurity.HasNecessaryPermission(SecurityAccessLevel.Edit, this.PortalSettings, this.ModuleConfiguration, this.UserInfo.Username)) { this.LoadChildControl(controlToLoad); } else if (Engage.Utility.IsLoggedIn) { this.Response.Redirect(Globals.NavigateURL(this.TabId), true); } else { this.Response.Redirect(Dnn.Utility.GetLoginUrl(this.PortalSettings, this.Request), true); } }
protected void Page_Load(Object sender, EventArgs e) { try { UserInfo _UserInfo = UserController.GetCurrentUserInfo(); foreach (ModuleAction action in this.MenuActions) { if (action.CommandName == ModuleActionType.PrintModule) { if (action.Visible && PortalSecurity.HasNecessaryPermission(action.Secure, PortalSettings, ModuleConfiguration, _UserInfo.UserID.ToString())) { bool blnPreview = false; if (Request.Cookies["_Tab_Admin_Preview" + PortalSettings.PortalId] != null) { blnPreview = bool.Parse(Request.Cookies["_Tab_Admin_Preview" + PortalSettings.PortalId].Value); } if (blnPreview == false || (action.Secure == SecurityAccessLevel.Anonymous || action.Secure == SecurityAccessLevel.View)) { if (PortalModule.ModuleConfiguration.DisplayPrint) { ImageButton ModuleActionIcon = new ImageButton(); if (!String.IsNullOrEmpty(PrintIcon)) { ModuleActionIcon.ImageUrl = PortalModule.ModuleConfiguration.ContainerPath.Substring(0, ModuleConfiguration.ContainerPath.LastIndexOf("/") + 1) + PrintIcon; } else { ModuleActionIcon.ImageUrl = "~/images/" + action.Icon; } ModuleActionIcon.ToolTip = action.Title; ModuleActionIcon.ID = "ico" + action.ID; ModuleActionIcon.CausesValidation = false; ModuleActionIcon.Click += new ImageClickEventHandler(IconAction_Click); this.Controls.Add(ModuleActionIcon); } } } } } // set visibility if (this.Controls.Count > 0) { this.Visible = true; } else { this.Visible = false; } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
private void BindLinkList() { object with_1 = m_menuActionRoot; // Is Root Menu visible? if (((ModuleAction)with_1).Visible) { if (this.Controls.Count > 0) { this.Controls.Clear(); } LiteralControl PreSpacer = new LiteralControl(ItemSeparator); this.Controls.Add(PreSpacer); // Add Menu Items foreach (ModuleAction action in m_menuActionRoot.Actions) { if (action.Title == "~") { // not supported in this Action object } else { UserInfo userInfo = UserController.GetCurrentUserInfo(); if (action.Visible && PortalSecurity.HasNecessaryPermission(action.Secure, ((PortalSettings)HttpContext.Current.Items["PortalSettings"]), ModuleConfiguration, userInfo.UserID.ToString())) { if ((EditMode && PortalModule.PortalSettings.ActiveTab.IsAdminTab == false && Globals.IsAdminControl() == false) || (action.Secure != SecurityAccessLevel.Anonymous && action.Secure != SecurityAccessLevel.View)) { LinkButton ModuleActionLink = new LinkButton(); ModuleActionLink.Text = action.Title; ModuleActionLink.CssClass = "CommandButton"; ModuleActionLink.ID = "lnk" + action.ID; ModuleActionLink.Click += new EventHandler(LinkAction_Click); this.Controls.Add(ModuleActionLink); LiteralControl Spacer = new LiteralControl(ItemSeparator); this.Controls.Add(Spacer); } } } } } //Need to determine if this action list actually has any items. if (this.Controls.Count > 0) { this.Visible = true; } else { this.Visible = false; } }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Init"/> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param> protected override void OnInit(EventArgs e) { base.OnInit(e); if (PortalSecurity.HasNecessaryPermission(SecurityAccessLevel.Edit, this.PortalSettings, this.ModuleConfiguration, this.UserInfo.Username)) { this.LoadChildControl(this.GetControlToLoad()); } else { this.GlobalNavigation.Visible = false; this.NoPermissionMessage.Visible = true; } }
private bool CanAddAction(SecurityAccessLevel access, bool checkAdminControl) { bool canAdd; string userName = Null.NullString; if (UserInfo != null) { userName = UserInfo.Username; } canAdd = PortalSecurity.HasNecessaryPermission(access, PortalSettings, ModuleConfiguration, userName); if (canAdd && checkAdminControl) { canAdd = EditMode && !ModuleConfiguration.IsAdmin && !(Globals.IsAdminControl()); } return(canAdd); }
/// <summary> /// Gets an instance of the Employment module with the given <paramref name="moduleDefinition"/> and <paramref name="jobGroupId"/> which can be viewed by the current user. /// </summary> /// <param name="portalSettings">The portal id.</param> /// <param name="moduleDefinition">The module definition.</param> /// <param name="jobGroupId">ID of the Job Group displayed on the module.</param> /// <returns>A non-deleted <see cref="ModuleInfo"/> with the given <paramref name="moduleDefinition"/>, or null if none exists.</returns> public static ModuleInfo GetCurrentModuleByDefinition(PortalSettings portalSettings, ModuleDefinition moduleDefinition, int?jobGroupId) { var moduleController = new ModuleController(); var tabController = new TabController(); // GetModulesByDefinition's obsolete status was rescinded after DNN 5.0 #pragma warning disable 618 return((from ModuleInfo module in moduleController.GetModulesByDefinition(portalSettings.PortalId, moduleDefinition.ToString()) where !module.IsDeleted && PortalSecurity.HasNecessaryPermission(SecurityAccessLevel.View, portalSettings, module) let moduleJobGroupSetting = ModuleSettings.JobGroupId.GetValueAsInt32For(EmploymentController.DesktopModuleName, module, ModuleSettings.JobGroupId.DefaultValue) let tab = tabController.GetTab(module.TabID, portalSettings.PortalId, false) where tab != null && !tab.IsDeleted && TabPermissionController.HasTabPermission(tab.TabPermissions, "VIEW") && (jobGroupId.Equals(moduleJobGroupSetting) || moduleJobGroupSetting == null) orderby !jobGroupId.Equals(moduleJobGroupSetting), moduleJobGroupSetting != null // false then true (i.e. job groups are equal *first*, then module's job group is null) select module).FirstOrDefault()); #pragma warning restore 618 }
private bool UserHasRights(int tabId) { var modules = new ModuleController(); Dictionary <int, ModuleInfo> tabModules = modules.GetTabModules(tabId); foreach (ModuleInfo module in tabModules.Values) { if (module.DesktopModule.FriendlyName.Equals(Utility.DnnFriendlyModuleName)) { bool overrideable; object overrideableObj = modules.GetTabModuleSettings(module.TabModuleID)["Overrideable"]; if (overrideableObj != null && bool.TryParse(overrideableObj.ToString(), out overrideable) && overrideable) { //keep checking until there is an overrideable module that the user is authorized to see. BD if (PortalSecurity.HasNecessaryPermission(SecurityAccessLevel.View, PortalSettings, module)) { return(true); } } } } return(false); }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Init"/> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param> protected override void OnInit(EventArgs e) { SubControlInfo controlToLoad; try { base.OnInit(e); controlToLoad = this.GetControlToLoad(); } catch (LicenseException) { controlToLoad = LicenseErrorControl; } if (!controlToLoad.RequiresEditPermission || PortalSecurity.HasNecessaryPermission(SecurityAccessLevel.Edit, this.PortalSettings, this.ModuleConfiguration, this.UserInfo.Username)) { this.LoadChildControl(controlToLoad); } else { this.DenyAccess(); } }
private void GetPermissions(object sender, EventArgs e) { View.Model.CanEdit = PortalSecurity.HasNecessaryPermission(SecurityAccessLevel.Edit, ModuleContext.PortalSettings, ModuleInfo, ModuleContext.PortalSettings.UserInfo); View.Model.EditEnabled = (ModuleContext.PortalSettings.UserMode != PortalSettings.Mode.View) && View.Model.CanEdit; View.Model.CanSubscribe = ModulePermissionController.HasModulePermission(ModuleInfo.ModulePermissions, PermissionName.HasSubscribePermission); }
protected void Page_Load(Object sender, EventArgs e) { try { UserInfo userInfo = UserController.GetCurrentUserInfo(); foreach (ModuleAction action in this.MenuActions) { if (action.CommandName == CommandName) { if (action.Visible && PortalSecurity.HasNecessaryPermission(action.Secure, PortalSettings, PortalModule.ModuleConfiguration, userInfo.UserID.ToString())) { bool blnPreview = false; if (Request.Cookies["_Tab_Admin_Preview" + PortalSettings.PortalId] != null) { blnPreview = bool.Parse(Request.Cookies["_Tab_Admin_Preview" + PortalSettings.PortalId].Value); } if (blnPreview == false || (action.Secure == SecurityAccessLevel.Anonymous || action.Secure == SecurityAccessLevel.View)) { if (action.CommandName == ModuleActionType.PrintModule && PortalModule.ModuleConfiguration.DisplayPrint == false) { DisplayIcon = false; DisplayLink = false; } if (action.CommandName == ModuleActionType.SyndicateModule && PortalModule.ModuleConfiguration.DisplaySyndicate == false) { DisplayIcon = false; DisplayLink = false; } if (DisplayIcon && (!String.IsNullOrEmpty(action.Icon) || !String.IsNullOrEmpty(IconFile))) { Image ModuleActionIcon = new Image(); //New ImageButton LinkButton ModuleActionLink = new LinkButton(); if (!String.IsNullOrEmpty(IconFile)) { ModuleActionIcon.ImageUrl = PortalModule.ModuleConfiguration.ContainerPath.Substring(0, PortalModule.ModuleConfiguration.ContainerPath.LastIndexOf("/") + 1) + IconFile; } else { if (action.Icon.IndexOf("/") > 0) { ModuleActionIcon.ImageUrl = action.Icon; } else { ModuleActionIcon.ImageUrl = "~/images/" + action.Icon; } } ModuleActionIcon.ToolTip = action.Title; ModuleActionIcon.AlternateText = action.Title; ModuleActionLink.ID = "ico" + action.ID; ModuleActionLink.CausesValidation = false; ModuleActionLink.EnableViewState = false; GetClientScriptURL(action, ModuleActionLink); ModuleActionLink.Click += new EventHandler(LinkAction_Click); //IconAction_Click ModuleActionLink.Controls.Add(ModuleActionIcon); this.Controls.Add(ModuleActionLink); } if (DisplayLink) { LinkButton ModuleActionLink = new LinkButton(); ModuleActionLink.Text = action.Title; ModuleActionLink.ToolTip = action.Title; ModuleActionLink.CssClass = CssClass; ModuleActionLink.ID = "lnk" + action.ID; ModuleActionLink.CausesValidation = false; ModuleActionLink.EnableViewState = false; GetClientScriptURL(action, ModuleActionLink); ModuleActionLink.Click += new EventHandler(LinkAction_Click); this.Controls.Add(ModuleActionLink); } this.Controls.Add(new LiteralControl(ButtonSeparator)); } } } } // set visibility if (this.Controls.Count > 0) { this.Visible = true; } else { this.Visible = false; } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
/// <summary> /// Recursive function to add module's actions to the DNNNodeCollection based off of passed in ModuleActions /// </summary> /// <param name="objParentAction">Parent action</param> /// <param name="objParentNode">Parent node</param> /// <param name="objRootNode"></param> /// <param name="objModule">Module to base actions off of</param> /// <param name="objUserInfo">User Info Object</param> /// <param name="intDepth">How many levels deep should be populated</param> /// <remarks> /// </remarks> /// <history> /// [Jon Henning] 5/15/2006 Created /// </history> private static void AddChildActions(ModuleAction objParentAction, DNNNode objParentNode, DNNNode objRootNode, ActionBase objModule, UserInfo objUserInfo, int intDepth) { // Add Menu Items foreach (ModuleAction objAction in objParentAction.Actions) { bool blnPending = IsActionPending(objParentNode, objRootNode, intDepth); if (objAction.Title == "~") { if (blnPending == false) { //A title (text) of ~ denotes a break objParentNode.DNNNodes.AddBreak(); } } else { //if action is visible and user has permission if (objAction.Visible & PortalSecurity.HasNecessaryPermission(objAction.Secure, (PortalSettings)(HttpContext.Current.Items["PortalSettings"]), objModule.ModuleConfiguration, objUserInfo.UserID.ToString())) { //(if edit mode and not admintab and not admincontrol) if (blnPending) { objParentNode.HasNodes = true; } else { int i = objParentNode.DNNNodes.Add(); DNNNode objNode = objParentNode.DNNNodes[i]; objNode.ID = objAction.ID.ToString(); objNode.Key = objAction.ID.ToString(); objNode.Text = objAction.Title; //no longer including SPACE in generic node collection, each control must handle how they want to display // HACK : Modified to not error if object is null. //if (objAction.ClientScript.Length > 0) if (!String.IsNullOrEmpty(objAction.ClientScript)) { objNode.JSFunction = objAction.ClientScript; objNode.ClickAction = eClickAction.None; } else { objNode.NavigateURL = objAction.Url; // HACK : Modified to handle null string in objNode.NavigateURL //if (objAction.UseActionEvent == false && objNode.NavigateURL.Length > 0) if (objAction.UseActionEvent == false && !String.IsNullOrEmpty(objNode.NavigateURL)) { objNode.ClickAction = eClickAction.Navigate; } else { objNode.ClickAction = eClickAction.PostBack; } } objNode.Image = objAction.Icon; if (objAction.HasChildren()) //if action has children then call function recursively { AddChildActions(objAction, objNode, objRootNode, objModule, objUserInfo, intDepth); } } } } } }