private void BindAccount() { // load user UserInfo user = UsersHelper.GetUser(PanelSecurity.SelectedUserId); if (user != null) { imgAdmin.Visible = (user.Role == UserRole.Administrator); imgReseller.Visible = (user.Role == UserRole.Reseller); imgUser.Visible = (user.Role == UserRole.User); // bind account details litUsername.Text = user.Username; litFullName.Text = Utils.EllipsisString(PortalAntiXSS.Encode(user.FirstName) + " " + PortalAntiXSS.Encode(user.LastName), 25); litSubscriberNumber.Text = PortalAntiXSS.Encode(user.SubscriberNumber); litRole.Text = PanelFormatter.GetUserRoleName(user.RoleId); litCreated.Text = user.Created.ToString(); litUpdated.Text = user.Changed.ToString(); lnkEmail.Text = Utils.EllipsisString(user.Email, 25); lnkEmail.NavigateUrl = "mailto:" + user.Email; // load owner account //UserInfo owner = UsersHelper.GetUser(user.OwnerId); //if(owner != null) //{ // litReseller.Text = owner.Username; //} // bind account status UserStatus status = user.Status; litStatus.Text = PanelFormatter.GetAccountStatusName((int)status); cmdActive.Visible = (status != UserStatus.Active); cmdSuspend.Visible = (status == UserStatus.Active); cmdCancel.Visible = (status != UserStatus.Cancelled); StatusBlock.Visible = (PanelSecurity.SelectedUserId != PanelSecurity.EffectiveUserId); // links lnkSummaryLetter.NavigateUrl = EditUrl("UserID", PanelSecurity.SelectedUserId.ToString(), "summary_letter"); lnkSummaryLetter.Visible = (PanelSecurity.SelectedUser.Role != UserRole.Administrator); lnkEditAccountDetails.NavigateUrl = EditUrl("UserID", PanelSecurity.SelectedUserId.ToString(), "edit_details"); lnkChangePassword.NavigateUrl = EditUrl("UserID", PanelSecurity.SelectedUserId.ToString(), "change_password"); lnkChangePassword.Visible = !((PanelSecurity.SelectedUserId == PanelSecurity.EffectiveUserId) && PanelSecurity.LoggedUser.IsPeer); lnkDelete.NavigateUrl = EditUrl("UserID", PanelSecurity.SelectedUserId.ToString(), "delete"); if (!((PanelSecurity.LoggedUser.Role == UserRole.Reseller) | (PanelSecurity.LoggedUser.Role == UserRole.Administrator))) { lnkDelete.Visible = false; } else { lnkDelete.Visible = (PanelSecurity.SelectedUserId != PanelSecurity.EffectiveUserId); } } }
private void BindUser() { try { UserInfo user = UsersHelper.GetUser(PanelSecurity.SelectedUserId); if (user != null) { // bind roles BindRoles(PanelSecurity.EffectiveUserId); bool editAdminAccount = (user.UserId == PanelSecurity.EffectiveUserId); if (!editAdminAccount) { role.Items.Remove("Administrator"); } // select role Utils.SelectListItem(role, user.Role.ToString()); // bind ec chkEcommerceEnbl.Checked = user.EcommerceEnabled; BindEcommerceEnabled(); rowRole.Visible = !editAdminAccount; // select status chkDemo.Checked = user.IsDemo; rowDemo.Visible = !editAdminAccount; // account info txtFirstName.Text = Server.HtmlDecode(user.FirstName); txtLastName.Text = Server.HtmlDecode(user.LastName); txtEmail.Text = user.Email; txtSecondaryEmail.Text = user.SecondaryEmail; ddlMailFormat.SelectedIndex = user.HtmlMail ? 1 : 0; lblUsername.Text = user.Username; // contact info contact.CompanyName = user.CompanyName; contact.Address = user.Address; contact.City = user.City; contact.Country = user.Country; contact.State = user.State; contact.Zip = user.Zip; contact.PrimaryPhone = user.PrimaryPhone; contact.SecondaryPhone = user.SecondaryPhone; contact.Fax = user.Fax; contact.MessengerId = user.InstantMessenger; ViewState[UserStatusConst] = user.Status; } else { // can't be found RedirectAccountHomePage(); } } catch (Exception ex) { ShowErrorMessage("USER_GET_USER", ex); return; } }
private void BindMenu(MenuItemCollection items, XmlNodeList nodes) { bool ecUserEnabled = false; bool ecAdminEnabled = PanelSecurity.SelectedUser.EcommerceEnabled; // UserInfo parent = UsersHelper.GetUser(PanelSecurity.SelectedUser.OwnerId); // if (parent != null) { ecUserEnabled = parent.EcommerceEnabled; } foreach (XmlNode node in nodes) { string pageId = null; if (node.Attributes["pageID"] != null) { pageId = node.Attributes["pageID"].Value; } if (!PortalUtils.PageExists(pageId)) { continue; } string url = null; if (node.Attributes["url"] != null) { url = node.Attributes["url"].Value; } string title = null; if (node.Attributes["title"] != null) { title = node.Attributes["title"].Value; } string target = null; if (node.Attributes["target"] != null) { target = node.Attributes["target"].Value; } string roles = null; if (node.Attributes["roles"] != null) { roles = node.Attributes["roles"].Value; } string selectedUserContext = null; if (node.Attributes["selectedUserContext"] != null) { selectedUserContext = node.Attributes["selectedUserContext"].Value; } // get custom page parameters XmlNodeList xmlParameters = node.SelectNodes("Parameters/Add"); List <string> parameters = new List <string>(); foreach (XmlNode xmlParameter in xmlParameters) { parameters.Add(xmlParameter.Attributes["name"].Value + "=" + xmlParameter.Attributes["value"].Value); } bool display = true; // set user role visibility second if (!String.IsNullOrEmpty(selectedUserContext)) { display = false; string[] arrRoles = selectedUserContext.Split(','); string userRole = PanelSecurity.SelectedUser.Role.ToString(); foreach (string role in arrRoles) { if (String.Compare(userRole, role, true) == 0) { display = true; break; } } } if ((!String.IsNullOrEmpty(roles)) & display) { display = false; string[] arrRoles = roles.Split(','); string userRole = PanelSecurity.LoggedUser.Role.ToString(); foreach (string role in arrRoles) { if (String.Compare(userRole, role, true) == 0) { display = true; break; } } } // set ecommerce user visibility first if (display && node.Attributes["ecuser"] != null) { display = ecUserEnabled; } // set ecommerce admin visibility third if (display && node.Attributes["ecadmin"] != null) { display = ecAdminEnabled; } //Audit Log functionality is disabled when user is in Demo mode if ((pageId == "AuditLog") && (PanelSecurity.SelectedUser.IsDemo)) { display = false; } // add menu item if (display) { string pageUrl = !String.IsNullOrEmpty(url) ? url : PortalUtils.NavigatePageURL( pageId, PortalUtils.USER_ID_PARAM, PanelSecurity.SelectedUserId.ToString(), parameters.ToArray()); string pageName = !String.IsNullOrEmpty(title) ? title : PortalUtils.GetLocalizedPageName(pageId); MenuItem item = new MenuItem(pageName, "", "", pageUrl); if (!String.IsNullOrEmpty(target)) { item.Target = target; } items.Add(item); // process nested menu items XmlNodeList xmlNestedNodes = node.SelectNodes("MenuItems/MenuItem"); BindMenu(item.ChildItems, xmlNestedNodes); } } }