private void BindServer() { ServerInfo server = ES.Services.Servers.GetServerById(PanelRequest.ServerId); if (server == null) { RedirectToBrowsePage(); } // header txtName.Text = PortalAntiXSS.DecodeOld(server.ServerName); txtComments.Text = PortalAntiXSS.DecodeOld(server.Comments); // connection txtUrl.Text = server.ServerUrl; // AD rbUsersCreationMode.SelectedIndex = server.ADEnabled ? 1 : 0; Utils.SelectListItem(ddlAdAuthType, server.ADAuthenticationType); txtDomainName.Text = server.ADRootDomain; txtAdUsername.Text = server.ADUsername; txtAdParentDomain.Text = server.ADParentDomain; txtAdParentDomainController.Text = server.ADParentDomainController; chkUseAdParentDomain.Checked = !string.IsNullOrEmpty(server.ADParentDomain); chkUseAdParentDomain_StateChanged(null, null); // Preview Domain txtPreviewDomain.Text = server.InstantDomainAlias; }
private void BindSpace() { PackageInfo package = ES.Services.Packages.GetPackage(PanelSecurity.PackageId); if (package != null) { // bind plans BindHostingPlans(); // bind space txtName.Text = PortalAntiXSS.DecodeOld(package.PackageName); txtComments.Text = PortalAntiXSS.DecodeOld(package.PackageComments); PurchaseDate.SelectedDate = package.PurchaseDate; serverDetails.ServerId = package.ServerId; Utils.SelectListItem(ddlPlan, package.PlanId); // bind quotas packageQuotas.BindQuotas(PanelRequest.PackageID); // bind override flag rbPlanQuotas.Checked = !package.OverrideQuotas; rbPackageQuotas.Checked = package.OverrideQuotas; // toggle quotas editor ToggleQuotasEditor(); } }
private void SaveAddon() { if (!Page.IsValid) { return; } // gather form data PackageAddonInfo addon = new PackageAddonInfo(); addon.PackageAddonId = PanelRequest.PackageAddonID; addon.PackageId = PanelSecurity.PackageId; addon.Comments = txtComments.Text; addon.PlanId = Utils.ParseInt(ddlPlan.SelectedValue, 0); addon.StatusId = Utils.ParseInt(ddlStatus.SelectedValue, 0); addon.PurchaseDate = PurchaseDate.SelectedDate; addon.Quantity = Utils.ParseInt(txtQuantity.Text, 1); if (PanelRequest.PackageAddonID == 0) { // add a new package addon try { PackageResult result = ES.Services.Packages.AddPackageAddon(addon); if (result.Result < 0) { ShowResultMessage(result.Result); lblMessage.Text = PortalAntiXSS.Encode(GetExceedingQuotasMessage(result.ExceedingQuotas)); return; } } catch (Exception ex) { ShowErrorMessage("PACKAGE_ADD_ADDON", ex); return; } } else { // update existing package addon try { PackageResult result = ES.Services.Packages.UpdatePackageAddon(addon); if (result.Result < 0) { ShowResultMessage(result.Result); lblMessage.Text = PortalAntiXSS.Encode(GetExceedingQuotasMessage(result.ExceedingQuotas)); return; } } catch (Exception ex) { ShowErrorMessage("PACKAGE_UPDATE_ADDON", ex); return; } } RedirectBack(); }
protected void path_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "browse") { litPath.Text = PortalAntiXSS.Encode((string)e.CommandArgument); BindPath(); } }
public void RenderMessage(MessageBoxType messageType, string message, string description, Exception ex, params string[] additionalParameters) { this.Visible = true; // show message // set icon and styles string boxStyle = "MessageBox Green"; if (messageType == MessageBoxType.Warning) { boxStyle = "MessageBox Yellow"; } else if (messageType == MessageBoxType.Error) { boxStyle = "MessageBox Red"; } tblMessageBox.Attributes["class"] = boxStyle; // set texts litMessage.Text = message; litDescription.Text = !String.IsNullOrEmpty(description) ? String.Format("<br/><span class=\"description\">{0}</span>", description) : ""; // show exception if (ex != null) { // show error try { // technical details litPageUrl.Text = PortalAntiXSS.Encode(Request.Url.ToString()); litLoggedUser.Text = PanelSecurity.LoggedUser.Username; litSelectedUser.Text = PanelSecurity.SelectedUser.Username; litPackageName.Text = PanelSecurity.PackageId.ToString(); litStackTrace.Text = ex.ToString().Replace("\n", "<br/>"); // send form litSendFrom.Text = PanelSecurity.LoggedUser.Email; if (!String.IsNullOrEmpty(PortalUtils.FromEmail)) { litSendFrom.Text = PortalUtils.FromEmail; } //litSendTo.Text = this.PortalSettings.Email; litSendTo.Text = PortalUtils.AdminEmail; litSendCC.Text = PanelSecurity.LoggedUser.Email; litSendSubject.Text = GetLocalizedString("Text.Subject"); } catch { /* skip */ } } else { rowTechnicalDetails.Visible = false; } }
private void BindPlan() { // hide "target server" section for non-admins bool isUserAdmin = PanelSecurity.SelectedUser.Role == UserRole.Administrator; rowTargetServer.Visible = isUserAdmin; rowTargetSpace.Visible = !isUserAdmin; if (isUserAdmin) { BindServers(); } else { BindSpaces(); } if (PanelRequest.PlanID == 0) { // new plan BindQuotas(); return; } HostingPlanInfo plan = ES.Services.Packages.GetHostingPlan(PanelRequest.PlanID); if (plan == null) { // plan not found RedirectBack(); } if (ShouldCopyCurrentHostingPlan()) { plan.PlanId = 0; plan.PlanName = "Copy of " + plan.PlanName; } // bind plan txtPlanName.Text = PortalAntiXSS.DecodeOld(plan.PlanName); txtPlanDescription.Text = PortalAntiXSS.DecodeOld(plan.PlanDescription); //chkAvailable.Checked = plan.Available; //txtSetupPrice.Text = plan.SetupPrice.ToString("0.00"); //txtRecurringPrice.Text = plan.RecurringPrice.ToString("0.00"); //txtRecurrenceLength.Text = plan.RecurrenceLength.ToString(); //Utils.SelectListItem(ddlRecurrenceUnit, plan.RecurrenceUnit); Utils.SelectListItem(ddlServer, plan.ServerId); Utils.SelectListItem(ddlSpace, plan.PackageId); // bind quotas BindQuotas(); }
private HostingPlanInfo[] GetHostingPlanAddonsInfo() { UserInfo user = UsersHelper.GetUser(PanelSecurity.SelectedUserId); HostingPlanInfo[] hpi = ES.Services.Packages.GetUserAvailableHostingAddons(user.UserId); for (int i = 0; i < hpi.Length; i++) { hpi[i].PlanDescription = PortalAntiXSS.DecodeOld(hpi[i].PlanDescription); hpi[i].PlanName = PortalAntiXSS.DecodeOld(hpi[i].PlanName); } return hpi; }
private void SaveSpace() { if (!Page.IsValid) { return; } // gather form data PackageInfo package = new PackageInfo(); // load package for update if (PanelSecurity.PackageId > 0) { package = ES.Services.Packages.GetPackage(PanelSecurity.PackageId); } package.PackageId = PanelSecurity.PackageId; package.PackageName = txtName.Text; package.PackageComments = txtComments.Text; package.PlanId = Utils.ParseInt(ddlPlan.SelectedValue, 0); package.PurchaseDate = PurchaseDate.SelectedDate; package.OverrideQuotas = rbPackageQuotas.Checked; if (package.OverrideQuotas) { package.Groups = editPackageQuotas.Groups; package.Quotas = editPackageQuotas.Quotas; } try { // update existing package PackageResult result = ES.Services.Packages.UpdatePackage(package); if (result.Result < 0) { ShowResultMessage(result.Result); lblMessage.Text = PortalAntiXSS.Encode(GetExceedingQuotasMessage(result.ExceedingQuotas)); return; } } catch (Exception ex) { ShowErrorMessage("PACKAGE_UPDATE_PACKAGE", ex); return; } // return RedirectSpaceHomePage(); }
private void BindGroupings() { DataSet dsUsers = ES.Services.Users.GetUsersSummary(PanelSecurity.SelectedUserId); // all customers lnkAllCustomers.Text = PortalAntiXSS.Encode(String.Format(GetLocalizedString("AllCustomers.Text"), dsUsers.Tables[0].Rows[0]["UsersNumber"])); // by status repUserStatuses.DataSource = dsUsers.Tables[1]; repUserStatuses.DataBind(); // by role repUserRoles.DataSource = dsUsers.Tables[2]; repUserRoles.DataBind(); }
private void BindAddons(int userId) { HostingPlanInfo[] hpi = ES.Services.Packages.GetUserAvailableHostingAddons(userId); // Next code is user for decoding incorectly stored plan names and descriptions with pre 1.2.2 installations for (int i = 0; i < hpi.Length; i++) { hpi[i].PlanDescription = PortalAntiXSS.DecodeOld(hpi[i].PlanDescription); hpi[i].PlanName = PortalAntiXSS.DecodeOld(hpi[i].PlanName); } ddlPlan.DataSource = hpi; ddlPlan.DataBind(); ddlPlan.Items.Insert(0, new ListItem(GetLocalizedString("SelectHostingPlan.Text"), "")); }
private void BindServer() { server = ES.Services.Servers.GetServerById(PanelRequest.ServerId); if (server == null) { RedirectToBrowsePage(); } // header txtName.Text = PortalAntiXSS.DecodeOld(server.ServerName); txtComments.Text = PortalAntiXSS.DecodeOld(server.Comments); Utils.SelectListItem(ddlPrimaryGroup, server.PrimaryGroupId); // Preview Domain txtPreviewDomain.Text = server.InstantDomainAlias; }
private void BindSummary() { DataSet ds = ES.Services.Packages.GetPackageDiskspace(PanelSecurity.PackageId); long negativeDiskspace = 0; foreach (DataRow dr in ds.Tables[0].Rows) { long diskspace = Convert.ToInt64(dr["Diskspace"]); DiskspaceTotal += diskspace; if (diskspace < 0) { negativeDiskspace += diskspace; } } // subtract negative from "Files" and remove negative groups DataRowCollection rows = ds.Tables[0].Rows; int i = 0; while (i < rows.Count) { int groupId = (int)rows[i]["GroupID"]; long diskspace = Convert.ToInt64(rows[i]["Diskspace"]); long diskspaceBytes = Convert.ToInt64(rows[i]["DiskspaceBytes"]); if (groupId == 1) { rows[i]["Diskspace"] = diskspace + negativeDiskspace; } else if (diskspaceBytes < 0) { rows.RemoveAt(i); continue; } i++; } litTotal.Text = PortalAntiXSS.Encode(DiskspaceTotal.ToString()); // get summary gvSummary.DataSource = ds; gvSummary.DataBind(); }
private void BindUser() { UserInfo user = ES.Services.Users.GetUserById(PanelSecurity.LoggedUserId); if (user != null) { userPassword.SetUserPolicy(user.UserId, UserSettings.SolidCP_POLICY, "PasswordPolicy"); // account info txtFirstName.Text = PortalAntiXSS.DecodeOld(user.FirstName); txtLastName.Text = PortalAntiXSS.DecodeOld(user.LastName); txtEmail.Text = user.Email; txtSecondaryEmail.Text = user.SecondaryEmail; lblUsername.Text = user.Username; ddlMailFormat.SelectedIndex = user.HtmlMail ? 1 : 0; // 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; // bind language /*DotNetNuke.Entities.Users.UserInfo dnnUser = * DnnUsers.GetUserByName(PortalSettings.PortalId, user.Username, false); * * if (dnnUser != null) * Utils.SelectListItem(ddlLanguage, dnnUser.Profile.PreferredLocale);*/ // bind items per page txtItemsPerPage.Text = UsersHelper.GetDisplayItemsPerPage().ToString(); } }
private void BindPlan() { if (PanelRequest.PlanID == 0) { // new plan BindQuotas(); return; } HostingPlanInfo plan = ES.Services.Packages.GetHostingPlan(PanelRequest.PlanID); if (plan == null) { // plan not found RedirectBack(); } if (ShouldCopyCurrentHostingAddon()) { plan.PlanId = 0; plan.PlanName = "Copy of " + plan.PlanName; } // bind plan txtPlanName.Text = PortalAntiXSS.DecodeOld(plan.PlanName); txtPlanDescription.Text = PortalAntiXSS.DecodeOld(plan.PlanDescription); //chkAvailable.Checked = plan.Available; //txtSetupPrice.Text = plan.SetupPrice.ToString("0.00"); //txtRecurringPrice.Text = plan.RecurringPrice.ToString("0.00"); //txtRecurrenceLength.Text = plan.RecurrenceLength.ToString(); //Utils.SelectListItem(ddlRecurrenceUnit, plan.RecurrenceUnit); // bind quotas BindQuotas(); }
private void SavePlan() { if (!Page.IsValid) { return; } // gather form info HostingPlanInfo plan = new HostingPlanInfo(); plan.UserId = PanelSecurity.SelectedUserId; plan.PlanId = PanelRequest.PlanID; plan.IsAddon = false; plan.PlanName = txtPlanName.Text; plan.PlanDescription = txtPlanDescription.Text; plan.Available = true; // always available plan.SetupPrice = 0; plan.RecurringPrice = 0; plan.RecurrenceLength = 1; plan.RecurrenceUnit = 2; // month plan.PackageId = Utils.ParseInt(ddlSpace.SelectedValue, 0); plan.ServerId = Utils.ParseInt(ddlServer.SelectedValue, 0); // if this is non-admin // get server info from parent package if (PanelSecurity.EffectiveUser.Role != UserRole.Administrator) { try { PackageInfo package = ES.Services.Packages.GetPackage(plan.PackageId); if (package != null) { plan.ServerId = package.ServerId; } } catch (Exception ex) { ShowErrorMessage("PACKAGE_GET_PACKAGE", ex); return; } } plan.Groups = hostingPlansQuotas.Groups; plan.Quotas = hostingPlansQuotas.Quotas; int planId = PanelRequest.PlanID; if ((PanelRequest.PlanID == 0) || ShouldCopyCurrentHostingPlan()) { // new plan try { planId = ES.Services.Packages.AddHostingPlan(plan); if (planId < 0) { ShowResultMessage(planId); return; } } catch (Exception ex) { ShowErrorMessage("PLAN_ADD_PLAN", ex); return; } } else { // update plan try { PackageResult result = ES.Services.Packages.UpdateHostingPlan(plan); if (result.Result < 0) { ShowResultMessage(result.Result); lblMessage.Text = PortalAntiXSS.Encode(GetExceedingQuotasMessage(result.ExceedingQuotas)); return; } } catch (Exception ex) { ShowErrorMessage("PLAN_UPDATE_PLAN", ex); return; } } // redirect RedirectBack(); }
private void SavePlan() { if (!Page.IsValid) { return; } // gather form info HostingPlanInfo plan = new HostingPlanInfo(); plan.UserId = PanelSecurity.SelectedUserId; plan.PlanId = PanelRequest.PlanID; plan.IsAddon = true; plan.PlanName = txtPlanName.Text; plan.PlanDescription = txtPlanDescription.Text; plan.Available = true; // always available plan.SetupPrice = 0; plan.RecurringPrice = 0; plan.RecurrenceLength = 1; plan.RecurrenceUnit = 2; // month plan.Groups = hostingPlansQuotas.Groups; plan.Quotas = hostingPlansQuotas.Quotas; int planId = PanelRequest.PlanID; if ((PanelRequest.PlanID == 0) || ShouldCopyCurrentHostingAddon()) { // new plan try { planId = ES.Services.Packages.AddHostingPlan(plan); if (planId < 0) { ShowResultMessage(planId); return; } } catch (Exception ex) { ShowErrorMessage("ADDON_ADD_ADDON", ex); return; } } else { // update plan try { PackageResult result = ES.Services.Packages.UpdateHostingPlan(plan); lblMessage.Text = PortalAntiXSS.Encode(GetExceedingQuotasMessage(result.ExceedingQuotas)); if (result.Result < 0) { ShowResultMessage(result.Result); return; } } catch (Exception ex) { ShowErrorMessage("ADDON_UPDATE_ADDON", ex); return; } } // redirect RedirectBack(); }
private void BindUser() { UserInfo user = ES.Services.Users.GetUserById(PanelSecurity.LoggedUserId); if (user != null) { userPassword.SetUserPolicy(user.UserId, UserSettings.SolidCP_POLICY, "PasswordPolicy"); // account info txtFirstName.Text = PortalAntiXSS.DecodeOld(user.FirstName); txtLastName.Text = PortalAntiXSS.DecodeOld(user.LastName); txtEmail.Text = user.Email; txtSecondaryEmail.Text = user.SecondaryEmail; lblUsername.Text = user.Username; ddlMailFormat.SelectedIndex = user.HtmlMail ? 1 : 0; // 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; // bind language /*DotNetNuke.Entities.Users.UserInfo dnnUser = * DnnUsers.GetUserByName(PortalSettings.PortalId, user.Username, false); * * if (dnnUser != null) * Utils.SelectListItem(ddlLanguage, dnnUser.Profile.PreferredLocale);*/ // bind items per page txtItemsPerPage.Text = UsersHelper.GetDisplayItemsPerPage().ToString(); string UserThemeStyle = ""; DataSet UserThemeSettingsData = ES.Services.Users.GetUserThemeSettings(PanelSecurity.LoggedUserId); if (UserThemeSettingsData.Tables.Count > 0) { foreach (DataRow row in UserThemeSettingsData.Tables[0].Rows) { string RowPropertyName = row.Field <String>("PropertyName"); string RowPropertyValue = row.Field <String>("PropertyValue"); if (RowPropertyName == "Style") { Utils.SelectListItem(ddlThemeStyle, RowPropertyValue); UserThemeStyle = RowPropertyValue; } if (RowPropertyName == "color-Header") { //Utils.SelectListItem(ddlThemecolorHeader, RowPropertyValue); } if (RowPropertyName == "color-Sidebar") { //Utils.SelectListItem(ddlThemecolorSidebar, RowPropertyValue); } } } //TODO: Dynamically load the Theme Settings } }
private void CreateHostingSpace() { if (!Page.IsValid) { return; } string spaceName = ddlPlans.SelectedItem.Text; string ftpAccount = (rbFtpAccountName.SelectedIndex == 0) ? null : ftpAccountName.Text; string domainName = txtDomainName.Text.Trim(); PackageResult result = null; try { result = ES.Services.Packages.AddPackageWithResources(PanelSecurity.SelectedUserId, Utils.ParseInt(ddlPlans.SelectedValue, 0), spaceName, Utils.ParseInt(ddlStatus.SelectedValue, 0), chkPackageLetter.Checked, chkCreateResources.Checked, domainName, false, chkCreateWebSite.Checked, chkCreateFtpAccount.Checked, ftpAccount, chkCreateMailAccount.Checked, txtHostName.Text); if (result.Result < 0) { ShowResultMessage(result.Result); lblMessage.Text = PortalAntiXSS.Encode(GetExceedingQuotasMessage(result.ExceedingQuotas)); return; } else { if ((chkIntegratedOUProvisioning.Checked) & !string.IsNullOrEmpty(domainName)) { UserInfo user = UsersHelper.GetUser(PanelSecurity.SelectedUserId); if (user != null) { if (user.Role != UserRole.Reseller) { UserSettings settings = ES.Services.Users.GetUserSettings(user.UserId, UserSettings.EXCHANGE_POLICY); string orgId = domainName.ToLower(); if (settings != null && settings["OrgIdPolicy"] != null) { orgId = GetOrgId(settings["OrgIdPolicy"], domainName, result.Result); } ES.Services.Organizations.CreateOrganization(result.Result, orgId, domainName.ToLower(), domainName.ToLower()); if (result.Result < 0) { ShowErrorMessage("USERWIZARD_CREATE_ACCOUNT"); return; } //Add Mail Cleaner Knom.Helpers.Net.APIMailCleanerHelper.DomainAdd(domainName, Utils.ParseInt(ddlPlans.SelectedValue, 0)); } } } if ((chkCreateMailAccount.Checked) & !string.IsNullOrEmpty(domainName)) { //Add Mail Cleaner Knom.Helpers.Net.APIMailCleanerHelper.DomainAdd(domainName, Utils.ParseInt(ddlPlans.SelectedValue, 0)); } } } catch (Exception ex) { ShowErrorMessage("USERWIZARD_CREATE_ACCOUNT", ex); return; } // Save addons try { int spaceId = result.Result; foreach (RepeaterItem item in repHostingAddons.Items) { PackageAddonInfo addon = new PackageAddonInfo(); addon.PackageAddonId = 0; //PanelRequest.PackageAddonID; addon.PackageId = spaceId; //PanelSecurity.PackageId; addon.Comments = ""; addon.PlanId = Utils.ParseInt(GetDropDownListSelectedValue(item, "ddlPlan"), 0); addon.StatusId = Utils.ParseInt(ddlStatus.SelectedValue, 0); addon.PurchaseDate = DateTime.Now; addon.Quantity = Utils.ParseInt(GetTextBoxText(item, "txtQuantity"), 1); PackageResult addonResult = ES.Services.Packages.AddPackageAddon(addon); } if (rbPackageQuotas.Checked) { //TODO: add logic to recalculate quota //If checked rbPackageQuotas take all addons quota, sum it and replace to main hosting quota //You can look the idea from SpaceEditDetails, but in SpaceEditDetails it is manually, need automatic here //At this moment here is a lot of work, maybe later. } //PackageContext cntx = PackagesHelper.GetCachedPackageContext(spaceId); //string resourceGroup = "VPS2012"; //if (cntx != null && cntx.Groups.ContainsKey(resourceGroup)) //{ // string pageId = "SpaceVPS2012"; // string pageUrl = PortalUtils.NavigatePageURL( //pageId, PortalUtils.SPACE_ID_PARAM, spaceId.ToString(), null); // Response.Redirect(pageUrl); //} } catch { //If something happens here, just ignore it. Addons not so important that a Hosting Space } if (chkRedirectToCreateVPS.Checked) { string pageId = "SpaceVPS2012"; string pageUrl = PortalUtils.NavigatePageURL( pageId, PortalUtils.SPACE_ID_PARAM, result.Result.ToString(), null); Response.Redirect(pageUrl); } else { // go to space home Response.Redirect(PortalUtils.GetSpaceHomePageUrl(result.Result)); } }
protected void gvFiles_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "browse") { string fileName = (string)e.CommandArgument; litPath.Text += PortalAntiXSS.Encode((litPath.Text != "\\") ? ("\\" + fileName) : fileName); BindPath(); } else if (e.CommandName == "download") { string path = GetFullRelativePath((string)e.CommandArgument); Response.Redirect(NavigateURL(PortalUtils.SPACE_ID_PARAM, PanelSecurity.PackageId.ToString(), "DownloadFile=" + Server.UrlEncode(path))); } else if (e.CommandName == "edit_file") { // read file content try { string path = GetFullRelativePath((string)e.CommandArgument); ViewState["EditFile"] = path; txtEditFileContent.Text = GetFileContent(path, ddlFileEncodings.SelectedValue); // show edit panel EditFileModal.Show(); } catch (Exception ex) { messageBox.ShowErrorMessage("FILES_READ_FILE", ex); } } else if (e.CommandName == "edit_permissions") { // read file content try { string path = GetFullRelativePath((string)e.CommandArgument); ViewState["EditPermissions"] = path; UserPermission[] users = ES.Services.Files.GetFilePermissions(PanelSecurity.PackageId, path); gvFilePermissions.DataSource = users; gvFilePermissions.DataBind(); // show permissions panel PermissionsFileModal.Show(); } catch (Exception ex) { messageBox.ShowErrorMessage("FILES_READ_PERMISSIONS", ex); } } else if (e.CommandName == "rename") { RenameFileModal.Show(); ViewState["RenameFile"] = (string)e.CommandArgument; txtRenameFile.Text = (string)e.CommandArgument; } }
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()); // select loginStatus loginStatus.SelectedIndex = user.LoginStatusId; rowRole.Visible = !editAdminAccount; // select status chkDemo.Checked = user.IsDemo; rowDemo.Visible = !editAdminAccount; // account info txtFirstName.Text = PortalAntiXSS.DecodeOld(user.FirstName); txtLastName.Text = PortalAntiXSS.DecodeOld(user.LastName); txtSubscriberNumber.Text = PortalAntiXSS.DecodeOld(user.SubscriberNumber); 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 BindUser() { ShowControls(PanelRequest.PeerID != 0); if (PanelRequest.PeerID == 0) { userPassword.SetUserPolicy(PanelSecurity.SelectedUserId, UserSettings.SolidCP_POLICY, "PasswordPolicy"); userPassword.ValidationGroup = ""; if (PanelSecurity.SelectedUser.RoleId == (int)UserRole.Administrator) { role.Items.Add("CSR"); role.Items.Add("Helpdesk"); role.Items.Add("Administrator"); } else if (PanelSecurity.SelectedUser.RoleId == (int)UserRole.Reseller) { role.Items.Add("CSR"); role.Items.Add("Helpdesk"); role.Items.Add("Reseller"); } else { rowRole.Visible = false; } return; // it's a new user } if (PanelSecurity.LoggedUser.IsPeer && PanelSecurity.LoggedUserId == PanelRequest.PeerID) { btnDelete.Visible = false; // peer can't delete his own account } UserInfo user = UsersHelper.GetUser(PanelRequest.PeerID); if (user != null) { if ((PanelSecurity.SelectedUser.RoleId == (int)UserRole.Administrator) | (PanelSecurity.SelectedUser.RoleId == (int)UserRole.PlatformCSR) | (PanelSecurity.SelectedUser.RoleId == (int)UserRole.PlatformHelpdesk)) { role.Items.Add("CSR"); role.Items.Add("Helpdesk"); role.Items.Add("Administrator"); } else if ((PanelSecurity.SelectedUser.RoleId == (int)UserRole.Reseller) | (PanelSecurity.SelectedUser.RoleId == (int)UserRole.ResellerCSR) | (PanelSecurity.SelectedUser.RoleId == (int)UserRole.ResellerHelpdesk)) { role.Items.Add("CSR"); role.Items.Add("Helpdesk"); role.Items.Add("Reseller"); } else { rowRole.Visible = false; } userPassword.SetUserPolicy(PanelSecurity.SelectedUserId, UserSettings.SolidCP_POLICY, "PasswordPolicy"); userPassword.ValidationGroup = "NewPassword"; // account info txtFirstName.Text = PortalAntiXSS.DecodeOld(user.FirstName); txtLastName.Text = PortalAntiXSS.DecodeOld(user.LastName); txtEmail.Text = user.Email; txtSecondaryEmail.Text = user.SecondaryEmail; ddlMailFormat.SelectedIndex = user.HtmlMail ? 1 : 0; txtUsername.Text = user.Username; lblUsername.Text = user.Username; chkDemo.Checked = user.IsDemo; if (user.RoleId == (int)UserRole.ResellerCSR) { role.SelectedIndex = 0; } if (user.RoleId == (int)UserRole.PlatformCSR) { role.SelectedIndex = 0; } if (user.RoleId == (int)UserRole.PlatformHelpdesk) { role.SelectedIndex = 1; } if (user.RoleId == (int)UserRole.ResellerHelpdesk) { role.SelectedIndex = 1; } if (user.RoleId == (int)UserRole.Reseller) { role.SelectedIndex = 2; } if (user.RoleId == (int)UserRole.Administrator) { role.SelectedIndex = 2; } // select loginStatus loginStatus.SelectedIndex = user.LoginStatusId; // 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; } else { // can't be found RedirectBack(); } }
private void BindSpace() { // load space PackageInfo package = ES.Services.Packages.GetPackage(PanelSecurity.PackageId); if (package != null) { litSpaceName.Text = PortalAntiXSS.EncodeOld(package.PackageName); chkDefault.Checked = package.DefaultTopPackage; // bind space status PackageStatus status = (PackageStatus)package.StatusId; litStatus.Text = PanelFormatter.GetPackageStatusName(package.StatusId); cmdActive.Visible = (status != PackageStatus.Active); cmdSuspend.Visible = (status == PackageStatus.Active); cmdCancel.Visible = (status != PackageStatus.Cancelled); StatusBlock.Visible = (PanelSecurity.SelectedUserId != PanelSecurity.EffectiveUserId); // bind account details litCreated.Text = package.PurchaseDate.ToString(); bool isNotUser = ((PanelSecurity.LoggedUser.Role != UserRole.User)); lblSuspendedDate.Visible = litSuspendedDate.Visible = false; if (status != PackageStatus.Active) { lblSuspendedDate.Visible = litSuspendedDate.Visible = isNotUser; litSuspendedDate.Text = package.StatusIDchangeDate.ToString(); } serverDetails.ServerId = package.ServerId; // load plan HostingPlanInfo plan = ES.Services.Packages.GetHostingPlan(package.PlanId); if (plan != null) { litHostingPlan.Text = plan.PlanName; } // links lnkSummaryLetter.NavigateUrl = EditUrl(PortalUtils.SPACE_ID_PARAM, PanelSecurity.PackageId.ToString(), "summary_letter"); lnkSummaryLetter.Visible = (PanelSecurity.PackageId > 1); lnkOverusageReport.NavigateUrl = NavigatePageURL("OverusageReport", PortalUtils.SPACE_ID_PARAM, PanelSecurity.PackageId.ToString()); OverusageReport.Visible = (PanelSecurity.SelectedUser.Role != UserRole.User); lnkEditSpaceDetails.NavigateUrl = EditUrl(PortalUtils.SPACE_ID_PARAM, PanelSecurity.PackageId.ToString(), "edit_details"); bool ownSpace = (package.UserId == PanelSecurity.EffectiveUserId); lnkEditSpaceDetails.Visible = (PanelSecurity.PackageId > 1 && !ownSpace); lnkDelete.NavigateUrl = EditUrl(PortalUtils.SPACE_ID_PARAM, PanelSecurity.PackageId.ToString(), "delete"); if (!((PanelSecurity.LoggedUser.Role == UserRole.Reseller) | (PanelSecurity.LoggedUser.Role == UserRole.Administrator))) { lnkDelete.Visible = false; } else { lnkDelete.Visible = ((PanelSecurity.SelectedUserId != PanelSecurity.EffectiveUserId) && (PanelSecurity.PackageId > 1)); } } }