protected void Page_Load(object sender, EventArgs e) { if (FileHelper.FileExists(controlPath)) { // Load the group selector ctrl = this.LoadControl(controlPath) as FormEngineUserControl ; ctrl.ID = "groupSelector"; plcGroupSelector.Controls.Add(ctrl); UniSelector usGroups = ctrl.GetValue("CurrentSelector") as UniSelector; if (usGroups != null) { usGroups.ReturnColumnName = "GroupID"; } mSiteId = QueryHelper.GetInteger("siteid", 0); mNodeId = QueryHelper.GetInteger("nodeid", 0); mGroupId = QueryHelper.GetInteger("groupid", 0); if (!RequestHelper.IsPostBack()) { ctrl.Value = mGroupId; } ctrl.IsLiveSite = false; ctrl.SetValue("DisplayCurrentGroup", false); ctrl.SetValue("DisplayNoneValue", true); ctrl.SetValue("SiteID", mSiteId); ctrl.SetValue("CurrentSelector", usGroups); } }
private void Control_OnItemValidation(object sender, ref string errorMessage) { FormEngineUserControl control = sender as FormEngineUserControl; if (control != null && String.IsNullOrWhiteSpace(errorMessage)) { switch (control.FieldInfo.Name) { case "FacebookApplicationConsumerKey": Validate <FacebookApplicationInfo>(control, "sm.facebook.application.msg.consumerkeyexists", ref errorMessage); break; case "FacebookAccountPageID": Validate <FacebookAccountInfo>(control, "sm.facebook.account.msg.pageidexists", ref errorMessage); break; case "TwitterApplicationConsumerKey": Validate <TwitterApplicationInfo>(control, "sm.twitter.application.msg.consumerkeyexists", ref errorMessage); break; } } }
/// <summary> /// Initializes group selector. /// </summary> private void InitializeGroupSelector() { if (groupsSelector == null) { try { groupsSelector = this.LoadUserControl(controlPath) as FormEngineUserControl; // Set up selector groupsSelector.ID = "dialogsGroupSelector"; groupsSelector.SetValue("DisplayCurrentGroup", false); groupsSelector.SetValue("SiteID", 0); groupsSelector.IsLiveSite = IsLiveSite; groupsSelector.Changed += groupSelector_Changed; // Get uniselector and set it up UniSelector us = groupsSelector.GetValue("CurrentSelector") as UniSelector; if (us != null) { us.ReturnColumnName = "GroupID"; } // Get dropdownlist and set it up DropDownList drpGroups = groupsSelector.GetValue("CurrentDropDown") as DropDownList; if (drpGroups != null) { drpGroups.AutoPostBack = true; } // Add control to panel pnlGroupSelector.Controls.Add(groupsSelector); } catch (HttpException) { // Couldn't load the control plcGroupSelector.Visible = false; } } }
/// <summary> /// Gets selected product options from the selection control. /// </summary> public string GetSelectedSKUOptions() { if (SelectionControl != null) { // Dropdown list, Radiobutton list - single selection if ((SelectionControl.GetType() == typeof(LocalizedDropDownList)) || (SelectionControl.GetType() == typeof(LocalizedRadioButtonList))) { return(((ListControl)SelectionControl).SelectedValue); } // Checkbox list - multiple selection else if (SelectionControl.GetType() == typeof(LocalizedCheckBoxList)) { string result = ""; foreach (ListItem item in ((CheckBoxList)SelectionControl).Items) { if (item.Selected) { result += item.Value + ","; } } return(result.TrimEnd(',')); } // TextBox else if (SelectionControl is TextBox) { return(((TextBox)(SelectionControl)).Text); } // Form control else if (SelectionControl is FormEngineUserControl) { FormEngineUserControl fc = SelectionControl as FormEngineUserControl; return(ValidationHelper.GetString(fc.Value, string.Empty)); } } return(null); }
/// <summary> /// Returns TRUE when selection control is empty or only '(none)' record is included, otherwise returns FALSE. /// </summary> public bool IsSelectionControlEmpty() { if (SelectionControl != null) { // Text type TextBox tb = SelectionControl as TextBox; if (tb != null) { return(string.IsNullOrEmpty(tb.Text)); } // List control types ListControl list = SelectionControl as ListControl; if (list != null) { bool noItems = (list.Items.Count == 0); bool onlyNoneRecord = ((list.Items.Count == 1) && (list.Items.FindByValue("0") != null)); return(noItems || onlyNoneRecord); } // Form controls FormEngineUserControl formControl = SelectionControl as FormEngineUserControl; if (formControl != null) { if (ValidationHelper.GetInteger(formControl.Value, 1) <= 0) { return(true); } return((formControl.Value == null) || string.IsNullOrEmpty(formControl.Value.ToString())); } return(false); } return(true); }
/// <summary> /// Shows warning if there is wrong web part zone count set. /// </summary> private void HandleWebpartZonesCountWarning() { if (EditedObjectType == EditedObjectTypeEnum.Layout) { if (actualLayoutInfo == null) { actualLayoutInfo = EditedObject as LayoutInfo; } FormEngineUserControl zonesCountControl = EditFormLayout.FieldControls["layoutzonecount"]; if ((actualLayoutInfo == null) || (zonesCountControl == null) || (!zonesCountControl.Visible)) { return; } // Handle difference between counted and entered number of web part zones if (actualLayoutInfo.LayoutZoneCountAutomatic != actualLayoutInfo.LayoutZoneCount) { string msg = (actualLayoutInfo.LayoutZoneCount >= 0) ? String.Format(ResHelper.GetString("pagelayout.webpartzonescountnotmatch"), actualLayoutInfo.LayoutZoneCount, actualLayoutInfo.LayoutZoneCountAutomatic) : ResHelper.GetString("pagelayout.webpartzonescountmissing"); ShowWarning(msg, null, null); } } }
/// <summary> /// Gets CheckBox control for given field name /// </summary> /// <param name="fieldName">Name of field which can have inherited value</param> private CMSCheckBox GetCheckBox(string fieldName) { if (checkboxes.ContainsKey(fieldName)) { // Return from dictionary return(checkboxes[fieldName]); } FormEngineUserControl control = Control.FieldControls[fieldName + SUFFIX_INHERIT]; if (control != null) { // Get checkbox from form control CMSCheckBox checkbox = ControlsHelper.GetChildControl <CMSCheckBox>(control); if (checkbox != null) { checkboxes[fieldName] = checkbox; return(checkbox); } } return(null); }
/// <summary> /// Loads group selector control to the page. /// </summary> /// <param name="siteId">Site ID</param> /// <returns>Returns true if site contains group and group selector was loaded</returns> private bool AddGroupSelector(int siteId) { SiteInfo si = SiteInfoProvider.GetSiteInfo(siteId); if ((si != null) && (ModuleCommands.CommunitySiteHasGroup(si.SiteID))) { groupsControl = Page.LoadUserControl("~/CMSModules/Groups/FormControls/MultipleGroupSelector.ascx") as FormEngineUserControl; if (groupsControl != null) { groupsControl.FormControlParameter = siteId; groupsControl.IsLiveSite = false; groupsControl.ID = "selectgroups"; groupsControl.ShortID = "sg"; groupsControl.SetValue("ReturnColumnName", "GroupID"); plcGroupSelector.Controls.Add(groupsControl); return(true); } } return(false); }
protected override void SaveStepData(object sender, StepEventArgs e) { base.SaveStepData(sender, e); // Just set current filed values into EditableObject, saving was canceled in OnBeforeSave customerForm.SaveData(null, false); CustomerInfo customer = customerForm.EditedObject as CustomerInfo; FormEngineUserControl typeSelector = TypeSelector; // Clear company fields for non-company type if ((typeSelector != null) && (!typeSelector.Value.Equals(COMPANY_TYPE))) { customer.CustomerCompany = ""; customer.CustomerOrganizationID = ""; customer.CustomerTaxRegistrationID = ""; } ShoppingCart.Customer = customer; // Update contact with customer details ModuleCommands.OnlineMarketingUpdateContactFromExternalData(customer, ContactID); }
/// <summary> /// Performs extra validation for the value of the specified form control. /// </summary> /// <param name="formControl">Form control</param> /// <returns>Returns an error message if the field value is invalid, otherwise returns null.</returns> private string ValidateField(FormEngineUserControl formControl) { switch (formControl.FieldInfo.Name.ToLowerCSafe()) { case INDEX_NAME: { var value = ValidationHelper.GetString(formControl.Value, null); // Possible length of path - already taken, +1 because in MAX_INDEX_PATH is count code name of length 1 var indexPath = Path.Combine(SystemContext.WebApplicationPhysicalPath, SearchHelper.SearchPath); var maxLength = SearchHelper.MAX_INDEX_PATH - indexPath.Length + 1; if (value.Length > maxLength) { return(GetString("srch.codenameexceeded")); } break; } } return(null); }
private void ReloadData() { if (Node != null) { // Hide parts which are not relevant to content only nodes if (ShowContentOnlyProperties) { pnlUIAdvanced.Visible = false; pnlUICache.Visible = false; pnlUIDesign.Visible = false; plcPermanent.Visible = false; pnlUIOnlineMarketing.Visible = false; } // Log activities checkboxes if (!RequestHelper.IsPostBack()) { bool?logVisit = Node.DocumentLogVisitActivity; chkLogPageVisit.Checked = (logVisit == true); if (Node.NodeParentID > 0) // Init "inherit" option for child nodes (and hide option for root) { chkPageVisitInherit.Checked = (logVisit == null); if (logVisit == null) { chkPageVisitInherit_CheckedChanged(null, EventArgs.Empty); } } chkLogPageVisit.Enabled = !chkPageVisitInherit.Checked; } // Check modify permission canEdit = (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Modify) != AuthorizationResultEnum.Denied); // Show document group owner selector if (ModuleEntryManager.IsModuleLoaded(ModuleName.COMMUNITY) && canEditOwner && LicenseHelper.CheckFeature(RequestContext.CurrentDomain, FeatureEnum.Groups)) { plcOwnerGroup.Controls.Clear(); // Initialize panel content Panel rowWrapperPanel = new Panel(); rowWrapperPanel.CssClass = "form-group"; Panel lblPanel = new Panel(); lblPanel.CssClass = "editing-form-label-cell"; Panel ctrlPanel = new Panel(); ctrlPanel.CssClass = "editing-form-value-cell"; // Initialize caption LocalizedLabel lblOwnerGroup = new LocalizedLabel(); lblOwnerGroup.EnableViewState = false; lblOwnerGroup.ResourceString = "community.group.documentowner"; lblOwnerGroup.ID = "lblOwnerGroup"; lblOwnerGroup.CssClass = "control-label"; lblPanel.Controls.Add(lblOwnerGroup); // Initialize selector fcDocumentGroupSelector = (FormEngineUserControl)Page.LoadUserControl("~/CMSAdminControls/UI/Selectors/DocumentGroupSelector.ascx"); fcDocumentGroupSelector.ID = "fcDocumentGroupSelector"; fcDocumentGroupSelector.StopProcessing = pnlUIOwner.IsHidden; ctrlPanel.Controls.Add(fcDocumentGroupSelector); fcDocumentGroupSelector.Value = ValidationHelper.GetInteger(Node.GetValue("NodeGroupID"), 0); fcDocumentGroupSelector.SetValue("siteid", SiteContext.CurrentSiteID); fcDocumentGroupSelector.SetValue("nodeid", Node.NodeID); // Add controls to containers rowWrapperPanel.Controls.Add(lblPanel); rowWrapperPanel.Controls.Add(ctrlPanel); plcOwnerGroup.Controls.Add(rowWrapperPanel); plcOwnerGroup.Visible = true; } // Show owner editing only when authorized to change the permissions if (canEditOwner) { lblOwner.Visible = false; usrOwner.Visible = true; usrOwner.SetValue("AdditionalUsers", new[] { Node.NodeOwner }); } else { usrOwner.Visible = false; } if (!RequestHelper.IsPostBack()) { if (canEditOwner) { usrOwner.Value = Node.GetValue("NodeOwner"); } } // Load the data lblName.Text = HttpUtility.HtmlEncode(Node.GetDocumentName()); lblNamePath.Text = HttpUtility.HtmlEncode(Convert.ToString(Node.GetValue("DocumentNamePath"))); lblAliasPath.Text = Convert.ToString(Node.NodeAliasPath); string typeName = DataClassInfoProvider.GetDataClassInfo(Node.NodeClassName).ClassDisplayName; lblType.Text = HttpUtility.HtmlEncode(ResHelper.LocalizeString(typeName)); lblNodeID.Text = Convert.ToString(Node.NodeID); // Modifier SetUserLabel(lblLastModifiedBy, "DocumentModifiedByUserId"); // Get modified time TimeZoneInfo usedTimeZone; DateTime lastModified = ValidationHelper.GetDateTime(Node.GetValue("DocumentModifiedWhen"), DateTimeHelper.ZERO_TIME); lblLastModified.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(lastModified, MembershipContext.AuthenticatedUser, SiteContext.CurrentSite, out usedTimeZone); ScriptHelper.AppendTooltip(lblLastModified, TimeZoneHelper.GetUTCLongStringOffset(usedTimeZone), "help"); if (!canEditOwner) { // Owner SetUserLabel(lblOwner, "NodeOwner"); } // Creator SetUserLabel(lblCreatedBy, "DocumentCreatedByUserId"); DateTime createdWhen = ValidationHelper.GetDateTime(Node.GetValue("DocumentCreatedWhen"), DateTimeHelper.ZERO_TIME); lblCreated.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(createdWhen, MembershipContext.AuthenticatedUser, SiteContext.CurrentSite, out usedTimeZone); ScriptHelper.AppendTooltip(lblCreated, TimeZoneHelper.GetUTCLongStringOffset(usedTimeZone), "help"); // URL if (plcPermanent.Visible) { string permanentUrl = DocumentURLProvider.GetPermanentDocUrl(Node.NodeGUID, Node.NodeAlias, Node.NodeSiteName, extension: ".aspx"); permanentUrl = URLHelper.ResolveUrl(permanentUrl); lnkPermanentURL.HRef = permanentUrl; lnkPermanentURL.InnerText = permanentUrl; } string liveUrl = DocumentURLProvider.GetAbsoluteLiveSiteURL(Node); lnkLiveURL.HRef = liveUrl; lnkLiveURL.InnerText = liveUrl; bool isRoot = Node.IsRoot(); // Hide preview URL for root node if (!isRoot) { plcPreview.Visible = true; btnResetPreviewGuid.ToolTip = GetString("GeneralProperties.InvalidatePreviewURL"); btnResetPreviewGuid.Click += btnResetPreviewGuid_Click; btnResetPreviewGuid.OnClientClick = "if(!confirm(" + ScriptHelper.GetLocalizedString("GeneralProperties.GeneratePreviewURLConf") + ")){return false;}"; InitPreviewUrl(); } lblGUID.Text = Convert.ToString(Node.NodeGUID); lblDocGUID.Text = (Node.DocumentGUID == Guid.Empty) ? ResHelper.Dash : Node.DocumentGUID.ToString(); lblDocID.Text = Convert.ToString(Node.DocumentID); // Culture CultureInfo ci = CultureInfoProvider.GetCultureInfo(Node.DocumentCulture); lblCulture.Text = ((ci != null) ? ResHelper.LocalizeString(ci.CultureName) : Node.DocumentCulture); if (Node.IsPublished) { lblPublished.Text = GetString("General.Yes"); lblPublished.CssClass += " DocumentPublishedYes"; } else { lblPublished.CssClass += " DocumentPublishedNo"; lblPublished.Text = GetString("General.No"); } // Load page info for inherited cache settings currentPage = PageInfoProvider.GetPageInfo(Node.NodeSiteName, Node.NodeAliasPath, Node.DocumentCulture, null, Node.NodeID, false); if (!RequestHelper.IsPostBack()) { // Init radio buttons for cache settings if (isRoot) { radInherit.Visible = false; radFSInherit.Visible = false; chkCssStyle.Visible = false; } else { // Show what is inherited value radInherit.Text = GetString("GeneralProperties.radInherit") + " (" + GetInheritedCacheCaption("NodeCacheMinutes") + ")"; radFSInherit.Text = GetString("GeneralProperties.radInherit") + " (" + GetInheritedCacheCaption("NodeAllowCacheInFileSystem") + ")"; } string cacheMinutes = ""; switch (Node.NodeCacheMinutes) { case null: // Cache setting is inherited { radNo.Checked = true; radYes.Checked = false; radInherit.Checked = false; if (!isRoot) { radInherit.Checked = true; radNo.Checked = false; if ((currentPage != null) && (currentPage.NodeCacheMinutes > 0)) { cacheMinutes = currentPage.NodeCacheMinutes.ToString(); } } } break; case 0: // Cache is off radNo.Checked = true; radYes.Checked = false; radInherit.Checked = false; break; default: // Cache is enabled radNo.Checked = false; radYes.Checked = true; radInherit.Checked = false; cacheMinutes = Node.NodeCacheMinutes.ToString(); break; } // Set secured radio buttons switch (Node.NodeAllowCacheInFileSystem) { case false: radFSNo.Checked = true; break; case true: radFSYes.Checked = true; break; default: if (!isRoot) { radFSInherit.Checked = true; } else { radFSYes.Checked = true; } break; } txtCacheMinutes.Text = cacheMinutes; if (!radYes.Checked) { txtCacheMinutes.Enabled = false; } var defaultStylesheet = GetDefaultStylesheet(); if (Node.DocumentInheritsStylesheet && !isRoot) { chkCssStyle.Checked = true; // Get stylesheet from the parent node string value = GetStylesheetParentValue(); ctrlSiteSelectStyleSheet.Value = String.IsNullOrEmpty(value) ? defaultStylesheet : value; } else { // Get stylesheet from the current node var stylesheetId = Node.DocumentStylesheetID; ctrlSiteSelectStyleSheet.Value = (stylesheetId == 0) ? defaultStylesheet : stylesheetId.ToString(); } } // Disable new button if document inherit stylesheet bool disableCssSelector = (!isRoot && chkCssStyle.Checked); ctrlSiteSelectStyleSheet.Enabled = !disableCssSelector; ctrlSiteSelectStyleSheet.ButtonNewEnabled = !disableCssSelector; // Initialize Rating control RefreshCntRatingResult(); double rating = 0.0f; if (Node.DocumentRatings > 0) { rating = Node.DocumentRatingValue / Node.DocumentRatings; } ratingControl.MaxRating = 10; ratingControl.CurrentRating = rating; ratingControl.Visible = true; ratingControl.Enabled = false; // Initialize Reset button for rating btnResetRating.OnClientClick = "if (!confirm(" + ScriptHelper.GetString(GetString("GeneralProperties.ResetRatingConfirmation")) + ")) return false;"; object[] param = new object[1]; param[0] = Node.DocumentID; plcAdHocForums.Visible = hasAdHocForum; plcAdHocBoards.Visible = hasAdHocBoard; if (!canEdit) { // Disable form editing DisableFormEditing(); } } else { btnResetRating.Visible = false; } }
protected override void OnInit(EventArgs e) { if (File.Exists(HttpContext.Current.Request.MapPath(ResolveUrl(pathToGroupselector)))) { Control ctrl = this.LoadControl(pathToGroupselector); if (ctrl != null) { selectInGroups = ctrl as FormEngineUserControl; ctrl.ID = "selGroups"; ctrl = this.LoadControl(pathToGroupselector); selectNotInGroups = ctrl as FormEngineUserControl; ctrl.ID = "selNoGroups"; this.plcGroups.Visible = true; plcSelectInGroups.Controls.Add(selectInGroups); plcSelectNotInGroups.Controls.Add(selectNotInGroups); this.selectNotInGroups.SetValue("UseFriendlyMode", true); this.selectInGroups.IsLiveSite = false; this.selectInGroups.SetValue("UseFriendlyMode", true); this.selectNotInGroups.IsLiveSite = false; } } base.OnInit(e); }
/// <summary> /// Sets contact role ID to given role selector control based on contact selector value and edited account. /// </summary> private void SetContactRoleID(FormEngineUserControl contactSelector, FormEngineUserControl roleSelector) { int contactID = ValidationHelper.GetInteger(contactSelector.Value, 0); int accountID = ai.AccountID; var accountContactInfo = AccountContactInfoProvider.GetAccountContactInfo(accountID, contactID); roleSelector.Value = (accountContactInfo != null) ? accountContactInfo.ContactRoleID : UniSelector.US_NONE_RECORD; }
protected void Page_Load(object sender, EventArgs e) { bool displayNone = false; bool currentIsCustomizedOfInstalled = false; elementInfo = UIContext.EditedObject as UIElementInfo; if (elementInfo != null && elementInfo.ElementID > 0) { ParentID = elementInfo.ElementParentID; EditForm.FieldControls["ElementPageTemplateID"].SetValue("ItemGuid", elementInfo.ElementGUID); EditForm.FieldControls["ElementPageTemplateID"].SetValue("ItemName", elementInfo.ElementDisplayName); // Exclude current element and children from dropdown list EditForm.FieldControls["ElementParentID"].SetValue("WhereCondition", "ElementIDPath NOT LIKE N'" + elementInfo.ElementIDPath + "%'"); // Enable editing only for current module. Disable for root EditForm.Enabled = ((!UIElementInfoProvider.AllowEditOnlyCurrentModule || (ResourceID == elementInfo.ElementResourceID) && elementInfo.ElementIsCustom) && (elementInfo.ElementParentID != 0)); // Allow global application checkbox only for applications if (!elementInfo.IsApplication && !elementInfo.ElementIsGlobalApplication) { EditForm.FieldsToHide.Add("ElementIsGlobalApplication"); EditForm.FieldsToHide.Add(nameof(UIElementInfo.ElementRequiresGlobalAdminPriviligeLevel)); } // Show info for customized elements ResourceInfo ri = ResourceInfoProvider.GetResourceInfo(elementInfo.ElementResourceID); if (ri != null) { if (elementInfo.ElementIsCustom && !ri.ResourceIsInDevelopment) { currentIsCustomizedOfInstalled = true; ShowInformation(GetString("module.customeleminfo")); } } } // New item else { isNew = true; if (!RequestHelper.IsPostBack()) { EditForm.FieldControls["ElementFromVersion"].Value = CMSVersion.GetVersion(true, true, false, false); } // Predefine current resource if is in development ResourceInfo ri = CurrentResourceInfo; if ((ri != null) && ri.ResourceIsInDevelopment) { EditForm.FieldControls["ElementResourceID"].Value = ResourceID; } // Display none if is under not-development resource else { displayNone = true; } EditForm.FieldControls["ElementParentID"].Value = ParentID; EditForm.FieldsToHide.Add("ElementParentID"); var parent = UIElementInfoProvider.GetUIElementInfo(ParentID); if ((parent == null) || (parent.ElementLevel != 2) || !parent.IsInAdministrationScope) { EditForm.FieldsToHide.Add("ElementIsGlobalApplication"); EditForm.FieldsToHide.Add(nameof(UIElementInfo.ElementRequiresGlobalAdminPriviligeLevel)); } } // Allow only modules in development mode FormEngineUserControl resourceCtrl = EditForm.FieldControls["ElementResourceID"]; if (resourceCtrl != null) { resourceCtrl.SetValue("DisplayOnlyModulesInDevelopmentMode", true); } // Disable form and add customize button if element is not custom and not development mode if (!SystemContext.DevelopmentMode && (elementInfo != null) && (ResourceID == elementInfo.ElementResourceID) && !elementInfo.ElementIsCustom && (elementInfo.ElementParentID != 0)) { ICMSMasterPage master = Page.Master as ICMSMasterPage; if (master != null) { master.HeaderActions.AddAction(new HeaderAction { Text = GetString("general.customize"), CommandName = "customize", OnClientClick = "if (!confirm(" + ScriptHelper.GetString(ResHelper.GetString("module.customizeconfirm")) + ")) { return false; }" }); master.HeaderActions.ActionPerformed += HeaderActions_ActionPerformed; } EditForm.Enabled = false; } if (resourceCtrl != null) { // Display all modules in disabled UI if (!EditForm.Enabled) { resourceCtrl.SetValue("DisplayOnlyModulesInDevelopmentMode", false); } // Display all modules in customized element but do not allow change the module else if (currentIsCustomizedOfInstalled) { resourceCtrl.SetValue("DisplayOnlyModulesInDevelopmentMode", false); resourceCtrl.Enabled = false; } // Display none if needed resourceCtrl.SetValue("DisplayNone", displayNone); } }
protected void Page_Load(object sender, EventArgs e) { // Check license if (DataHelper.GetNotEmpty(URLHelper.GetCurrentDomain(), "") != "") { LicenseHelper.CheckFeatureAndRedirect(URLHelper.GetCurrentDomain(), FeatureEnum.WebAnalytics); } ucABTests = LoadControl("~/CMSModules/OnlineMarketing/FormControls/SelectABTest.ascx") as FormEngineUserControl; ucMVTests = LoadControl("~/CMSModules/OnlineMarketing/FormControls/SelectMVTest.ascx") as FormEngineUserControl; if (ucABTests != null) { ucABTests.ID = "abTestSelector"; pnlABTests.Controls.Add(ucABTests); } if (ucMVTests != null) { ucMVTests.ID = "mvtSelector"; pnlMVTests.Controls.Add(ucMVTests); } if (!RequestHelper.IsPostBack() && (ucABTests != null) && (ucMVTests != null)) { string[,] fields = new string[2, 2]; fields[0, 0] = GetString("general.pleaseselect"); fields[0, 1] = "pleaseselect"; fields[1, 0] = "(" + GetString("general.all") + ")"; fields[1, 1] = ValidationHelper.GetString(ucABTests.GetValue("AllRecordValue"), String.Empty); ucABTests.SetValue("SpecialFields", fields); ucABTests.Value = "pleaseselect"; ucABTests.SetValue("AllowEmpty", false); ucABTests.SetValue("ReturnColumnName", "ABTestName"); ucMVTests.SetValue("SpecialFields", fields); ucMVTests.Value = "pleaseselect"; ucMVTests.SetValue("AllowEmpty", false); ucMVTests.SetValue("ReturnColumnName", "MVTestName"); usCampaigns.UniSelector.SpecialFields = fields; usCampaigns.Value = "pleaseselect"; } CurrentUserInfo user = CMSContext.CurrentUser; // Check permissions for CMS Desk -> Tools -> Web analytics tab if (!user.IsAuthorizedPerUIElement("CMS.Tools", "WebAnalytics")) { RedirectToCMSDeskUIElementAccessDenied("CMS.Tools", "WebAnalytics"); } // Check 'Read' permission if (!user.IsAuthorizedPerResource("CMS.WebAnalytics", "Read")) { RedirectToCMSDeskAccessDenied("CMS.WebAnalytics", "Read"); } string title = GetString("AnayticsManageData.ManageData"); this.Page.Title = title; this.CurrentMaster.Title.TitleText = title; this.CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Reporting/managedata.png"); // Confirmation message for deleting string deleteFromToMessage = ScriptHelper.GetString(GetString("webanal.deletefromtomsg")); deleteFromToMessage = deleteFromToMessage.Replace("##FROM##", "' + elemFromStr + '"); deleteFromToMessage = deleteFromToMessage.Replace("##TO##", "' + elemToStr + '"); string script = " var elemTo = document.getElementById('" + pickerTo.ClientID + "_txtDateTime'); " + " var elemFrom = document.getElementById('" + pickerFrom.ClientID + "_txtDateTime'); " + " var elemToStr = " + ScriptHelper.GetString(GetString("webanal.now")) + "; " + " var elemFromStr = " + ScriptHelper.GetString(GetString("webanal.beginning")) + "; " + " var deleteAll = 1; " + " if (elemTo.value != '') { deleteAll = 0; elemToStr = elemTo.value; }; " + " if (elemFrom.value != '') { deleteAll = 0; elemFromStr = elemFrom.value; }; " + " if (deleteAll == 1) { return confirm(" + ScriptHelper.GetString(GetString("webanal.deleteall")) + "); } " + " else { return confirm(" + deleteFromToMessage + "); }; "; btnDelete.OnClientClick = script + "; return false;"; statCodeName = QueryHelper.GetString("statCodeName", String.Empty); if (statCodeName == "abtest") { pnlABTestSelector.Visible = true; } if (statCodeName == "mvtest") { pnlMVTSelector.Visible = true; } if (statCodeName == "campaigns") { pnlCampaigns.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { ci = (ContactInfo)EditedObject; this.CheckReadPermission(ci.ContactSiteID); globalContact = (ci.ContactSiteID <= 0); mergedContact = (ci.ContactMergedWithContactID > 0); modifyAllowed = ContactHelper.AuthorizedModifyContact(ci.ContactSiteID, false); contactId = QueryHelper.GetInteger("contactid", 0); string where = null; // Filter only site members in CMSDesk (for global contacts) if (!this.IsSiteManager && globalContact && AuthorizedForSiteContacts) { where += " (ContactSiteID IS NULL OR ContactSiteID=" + CMSContext.CurrentSiteID + ")"; } fltElem.ShowContactNameFilter = globalContact; fltElem.ShowSiteFilter = this.IsSiteManager && globalContact; // Choose correct object ("query") according to type of contact if (globalContact) { gridElem.ObjectType = OnlineMarketingObjectType.MEMBERSHIPGLOBALCUSTOMERLIST; } else if (mergedContact) { gridElem.ObjectType = OnlineMarketingObjectType.MEMBERSHIPMERGEDCUSTOMERLIST; } else { gridElem.ObjectType = OnlineMarketingObjectType.MEMBERSHIPCUSTOMERLIST; } // Query parameters QueryDataParameters parameters = new QueryDataParameters(); parameters.Add("@ContactId", contactId); where = SqlHelperClass.AddWhereCondition(where, fltElem.WhereCondition); gridElem.WhereCondition = where; gridElem.QueryParameters = parameters; gridElem.OnAction += new OnActionEventHandler(gridElem_OnAction); gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound); // Hide header actions for global contact this.CurrentMaster.HeaderActionsPlaceHolder.Visible = modifyAllowed && !globalContact && !mergedContact; // Setup customer selector try { ucSelectCustomer = (FormEngineUserControl)this.Page.LoadControl("~/CMSModules/Ecommerce/FormControls/CustomerSelector.ascx"); ucSelectCustomer.SetValue("Mode", "OnlineMarketing"); ucSelectCustomer.SetValue("SiteID", ci.ContactSiteID); ucSelectCustomer.Changed += new EventHandler(ucSelectCustomer_Changed); ucSelectCustomer.IsLiveSite = false; pnlSelectCustomer.Controls.Clear(); pnlSelectCustomer.Controls.Add(ucSelectCustomer); } catch { } }
protected void Page_Load(object sender, EventArgs e) { // Required field validator error messages initialization rfvAnswerText.ErrorMessage = GetString("Polls_Answer_Edit.AnswerTextError"); // Controls initializations lblAnswerText.Text = GetString("Polls_Answer_Edit.AnswerTextLabel"); lblVotes.Text = GetString("Polls_Answer_Edit.Votes"); // Set if it is live site txtAnswerText.IsLiveSite = IsLiveSite; // Load BizForm selector if BizForms module is available if (ModuleEntry.IsModuleLoaded(ModuleEntry.BIZFORM) && ResourceSiteInfoProvider.IsResourceOnSite(ModuleEntry.BIZFORM, CMSContext.CurrentSiteName)) { bizFormElem = (FormEngineUserControl)Page.LoadUserControl("~/CMSModules/BizForms/FormControls/SelectBizForm.ascx"); bizFormElem.ShortID = "bizFormElem"; bizFormElem.SetValue("ShowSiteFilter", false); plcBizFormSelector.Controls.Add(bizFormElem); bizFormElem.Visible = true; UniSelector uniSelector = bizFormElem.GetValue("UniSelector") as UniSelector; if (uniSelector != null) { uniSelector.OnSelectionChanged += new EventHandler(BizFormSelector_OnSelectionChanged); } } if (!RequestHelper.IsPostBack() && !IsLiveSite) { LoadData(); } }
private void ReloadData() { if (Node != null) { // Log activities checkboxes if (!RequestHelper.IsPostBack()) { bool?logVisit = Node.DocumentLogVisitActivity; chkLogPageVisit.Checked = (logVisit == true); if (Node.NodeParentID > 0) // Init "inherit" option for child nodes (and hide option for root) { chkPageVisitInherit.Checked = (logVisit == null); if (logVisit == null) { chkPageVisitInherit_CheckedChanged(null, EventArgs.Empty); } } chkLogPageVisit.Enabled = !chkPageVisitInherit.Checked; } // Check modify permission canEdit = (CMSContext.CurrentUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Modify) != AuthorizationResultEnum.Denied); // Show document group owner selector if (ModuleEntry.IsModuleLoaded(ModuleEntry.COMMUNITY) && canEditOwner && LicenseHelper.CheckFeature(URLHelper.GetCurrentDomain(), FeatureEnum.Groups)) { plcOwnerGroup.Controls.Clear(); // Initialize table TableRow rowOwner = new TableRow(); TableCell cellTitle = new TableCell(); TableCell cellSelector = new TableCell(); // Initialize caption LocalizedLabel lblOwnerGroup = new LocalizedLabel(); lblOwnerGroup.EnableViewState = false; lblOwnerGroup.ResourceString = "community.group.documentowner"; lblOwnerGroup.ID = "lblOwnerGroup"; cellTitle.Controls.Add(lblOwnerGroup); // Initialize selector fcDocumentGroupSelector = (FormEngineUserControl)Page.LoadUserControl("~/CMSAdminControls/UI/Selectors/DocumentGroupSelector.ascx"); fcDocumentGroupSelector.ID = "fcDocumentGroupSelector"; fcDocumentGroupSelector.StopProcessing = pnlUIOwner.IsHidden; cellSelector.Controls.Add(fcDocumentGroupSelector); fcDocumentGroupSelector.Value = ValidationHelper.GetInteger(Node.GetValue("NodeGroupID"), 0); fcDocumentGroupSelector.SetValue("siteid", CMSContext.CurrentSiteID); fcDocumentGroupSelector.SetValue("nodeid", Node.NodeID); // Add controls to containers rowOwner.Cells.Add(cellTitle); rowOwner.Cells.Add(cellSelector); plcOwnerGroup.Controls.Add(rowOwner); plcOwnerGroup.Visible = true; } // Show owner editing only when authorized to change the permissions if (canEditOwner) { lblOwner.Visible = false; usrOwner.Visible = true; usrOwner.SetValue("AdditionalUsers", new int[] { Node.NodeOwner }); } else { usrOwner.Visible = false; } if (!RequestHelper.IsPostBack()) { if (canEditOwner) { usrOwner.Value = Node.GetValue("NodeOwner"); } } // Load the data lblName.Text = HttpUtility.HtmlEncode(Node.GetDocumentName()); lblNamePath.Text = HttpUtility.HtmlEncode(Convert.ToString(Node.GetValue("DocumentNamePath"))); lblAliasPath.Text = Convert.ToString(Node.NodeAliasPath); string typeName = DataClassInfoProvider.GetDataClass(Node.NodeClassName).ClassDisplayName; lblType.Text = HttpUtility.HtmlEncode(ResHelper.LocalizeString(typeName)); lblNodeID.Text = Convert.ToString(Node.NodeID); // Modifier SetUserLabel(lblLastModifiedBy, "DocumentModifiedByUserId"); // Get modified time TimeZoneInfo usedTimeZone = null; DateTime lastModified = ValidationHelper.GetDateTime(Node.GetValue("DocumentModifiedWhen"), DateTimeHelper.ZERO_TIME); lblLastModified.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(lastModified, CMSContext.CurrentUser, CMSContext.CurrentSite, out usedTimeZone); ScriptHelper.AppendTooltip(lblLastModified, TimeZoneHelper.GetGMTLongStringOffset(usedTimeZone), "help"); if (!canEditOwner) { // Owner SetUserLabel(lblOwner, "NodeOwner"); } // Creator SetUserLabel(lblCreatedBy, "DocumentCreatedByUserId"); DateTime createdWhen = ValidationHelper.GetDateTime(Node.GetValue("DocumentCreatedWhen"), DateTimeHelper.ZERO_TIME); lblCreated.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(createdWhen, CMSContext.CurrentUser, CMSContext.CurrentSite, out usedTimeZone); ScriptHelper.AppendTooltip(lblCreated, TimeZoneHelper.GetGMTLongStringOffset(usedTimeZone), "help"); // URL string liveUrl = Node.IsLink ? CMSContext.GetUrl(Node.NodeAliasPath, null) : CMSContext.GetUrl(Node.NodeAliasPath, Node.DocumentUrlPath); lnkLiveURL.Text = URLHelper.ResolveUrl(liveUrl, true, false); lnkLiveURL.NavigateUrl = URLHelper.ResolveUrl(liveUrl); bool isRoot = (Node.NodeClassName.ToLowerCSafe() == "cms.root"); // Preview URL if (!isRoot) { plcPreview.Visible = true; string path = canEdit ? "/CMSModules/CMS_Content/Properties/resetlink.png" : "/CMSModules/CMS_Content/Properties/resetlinkdisabled.png"; btnResetPreviewGuid.ImageUrl = GetImageUrl(path); btnResetPreviewGuid.ToolTip = GetString("GeneralProperties.InvalidatePreviewURL"); btnResetPreviewGuid.ImageAlign = ImageAlign.AbsBottom; btnResetPreviewGuid.Click += btnResetPreviewGuid_Click; btnResetPreviewGuid.OnClientClick = "if(!confirm('" + GetString("GeneralProperties.GeneratePreviewURLConf") + "')){return false;}"; InitPreviewUrl(); } lblGUID.Text = Convert.ToString(Node.NodeGUID); lblDocGUID.Text = (Node.DocumentGUID == Guid.Empty) ? ResHelper.Dash : Node.DocumentGUID.ToString(); lblDocID.Text = Convert.ToString(Node.DocumentID); // Culture CultureInfo ci = CultureInfoProvider.GetCultureInfo(Node.DocumentCulture); lblCulture.Text = ((ci != null) ? ResHelper.LocalizeString(ci.CultureName) : Node.DocumentCulture); lblPublished.Text = (Node.IsPublished ? "<span class=\"DocumentPublishedYes\">" + GetString("General.Yes") + "</span>" : "<span class=\"DocumentPublishedNo\">" + GetString("General.No") + "</span>"); if (!RequestHelper.IsPostBack()) { // Init radio buttons for cache settings if (isRoot) { radInherit.Visible = false; radFSInherit.Visible = false; chkCssStyle.Visible = false; } string cacheMinutes = ""; switch (Node.NodeCacheMinutes) { case -1: // Cache is off { radNo.Checked = true; radYes.Checked = false; radInherit.Checked = false; if (!isRoot) { radInherit.Checked = true; radNo.Checked = false; } } break; case 0: // Cache is off radNo.Checked = true; radYes.Checked = false; radInherit.Checked = false; break; default: // Cache is enabled radNo.Checked = false; radYes.Checked = true; radInherit.Checked = false; cacheMinutes = Node.NodeCacheMinutes.ToString(); break; } // Set secured radio buttons switch (Node.NodeAllowCacheInFileSystem) { case 0: radFSNo.Checked = true; break; case 1: radFSYes.Checked = true; break; default: if (!isRoot) { radFSInherit.Checked = true; } else { radFSYes.Checked = true; } break; } txtCacheMinutes.Text = cacheMinutes; if (!radYes.Checked) { txtCacheMinutes.Enabled = false; } if (Node.GetValue("DocumentStylesheetID") == null) { // If default site not exist edit is set to -1 - disabled if (CMSContext.CurrentSiteStylesheet != null) { ctrlSiteSelectStyleSheet.Value = "default"; } else { ctrlSiteSelectStyleSheet.Value = -1; } } else { // If stylesheet is inherited from parent document if (ValidationHelper.GetInteger(Node.GetValue("DocumentStylesheetID"), 0) == -1) { if (!isRoot) { chkCssStyle.Checked = true; // Get parent stylesheet string value = PageInfoProvider.GetParentProperty(CMSContext.CurrentSite.SiteID, Node.NodeAliasPath, "(DocumentStylesheetID <> -1 OR DocumentStylesheetID IS NULL) AND DocumentCulture = N'" + SqlHelperClass.GetSafeQueryString(Node.DocumentCulture, false) + "'", "DocumentStylesheetID"); if (String.IsNullOrEmpty(value)) { // If default site stylesheet not exist edit is set to -1 - disabled if (CMSContext.CurrentSiteStylesheet != null) { ctrlSiteSelectStyleSheet.Value = "default"; } else { ctrlSiteSelectStyleSheet.Value = -1; } } else { // Set parent stylesheet to current document ctrlSiteSelectStyleSheet.Value = value; } } } else { ctrlSiteSelectStyleSheet.Value = Node.GetValue("DocumentStylesheetID"); } } } // Disable new button if document inherit stylesheet bool disableCssSelector = (!isRoot && chkCssStyle.Checked); ctrlSiteSelectStyleSheet.Enabled = !disableCssSelector; ctrlSiteSelectStyleSheet.ButtonNewEnabled = !disableCssSelector; // Initialize Rating control RefreshCntRatingResult(); double rating = 0.0f; if (Node.DocumentRatings > 0) { rating = Node.DocumentRatingValue / Node.DocumentRatings; } ratingControl.MaxRating = 10; ratingControl.CurrentRating = rating; ratingControl.Visible = true; ratingControl.Enabled = false; // Initialize Reset button for rating btnResetRating.Text = GetString("general.reset"); btnResetRating.OnClientClick = "if (!confirm(" + ScriptHelper.GetString(GetString("GeneralProperties.ResetRatingConfirmation")) + ")) return false;"; object[] param = new object[1]; param[0] = Node.DocumentID; plcAdHocForums.Visible = hasAdHocForum; plcAdHocBoards.Visible = hasAdHocBoard; if (!canEdit) { // Disable form editing DisableFormEditing(); } } else { btnResetRating.Visible = false; } }
protected void EditForm_OnBeforeSave(object sender, EventArgs e) { MacroRuleInfo info = Control.EditedObject as MacroRuleInfo; if (info != null) { // Generate automatic fields when present in UserText FormEngineUserControl control = Control.FieldControls["MacroRuleText"]; if (control != null) { string userText = ValidationHelper.GetString(control.Value, String.Empty); if (!string.IsNullOrEmpty(userText)) { Regex regex = RegexHelper.GetRegex("\\{[-_a-zA-Z0-9]*\\}"); MatchCollection match = regex.Matches(userText); if (match.Count > 0) { FormInfo fi = new FormInfo(info.MacroRuleParameters); foreach (Match m in match) { foreach (Capture c in m.Captures) { string name = c.Value.Substring(1, c.Value.Length - 2).ToLowerCSafe(); FormFieldInfo ffi = fi.GetFormField(name); if (ffi == null) { ffi = new FormFieldInfo(); ffi.Name = name; ffi.DataType = FieldDataType.Text; ffi.Size = 100; ffi.FieldType = FormFieldControlTypeEnum.CustomUserControl; ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "select operation"); ffi.AllowEmpty = true; switch (name) { case "_is": ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, ";is"); ffi.Settings["controlname"] = "MacroNegationOperator"; ffi.Settings["EditText"] = "false"; ffi.Settings["Options"] = ";is\r\n!;is not"; break; case "_was": ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, ";was"); ffi.Settings["controlname"] = "MacroNegationOperator"; ffi.Settings["EditText"] = "false"; ffi.Settings["Options"] = ";was\r\n!;was not"; break; case "_will": ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, ";will"); ffi.Settings["controlname"] = "MacroNegationOperator"; ffi.Settings["EditText"] = "false"; ffi.Settings["Options"] = ";will\r\n!;will not"; break; case "_has": ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, ";has"); ffi.Settings["controlname"] = "MacroNegationOperator"; ffi.Settings["EditText"] = "false"; ffi.Settings["Options"] = ";has\r\n!;does not have"; break; case "_perfectum": ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, ";has"); ffi.Settings["controlname"] = "MacroNegationOperator"; ffi.Settings["EditText"] = "false"; ffi.Settings["Options"] = ";has\r\n!;has not"; break; case "_any": ffi.SetPropertyValue(FormFieldPropertyEnum.DefaultValue, "false;any"); ffi.Settings["controlname"] = "macro_any-all_bool_selector"; ffi.Settings["EditText"] = "false"; ffi.Settings["Options"] = "false;any\r\ntrue;all"; break; default: ffi.FieldType = FormFieldControlTypeEnum.TextBoxControl; ffi.Size = 1000; ffi.SetPropertyValue(FormFieldPropertyEnum.FieldCaption, "enter text"); break; } fi.AddFormItem(ffi); } } } info.MacroRuleParameters = fi.GetXmlDefinition(); } } } } Control.EditedObject.SetValue("MacroRuleIsCustom", !SystemContext.DevelopmentMode); }
private void ReloadData() { if (Node != null) { // Log activities checkboxes if (!RequestHelper.IsPostBack()) { bool? logVisit = Node.DocumentLogVisitActivity; chkLogPageVisit.Checked = (logVisit == true); if (Node.NodeParentID > 0) // Init "inherit" option for child nodes (and hide option for root) { chkPageVisitInherit.Checked = (logVisit == null); if (logVisit == null) { chkPageVisitInherit_CheckedChanged(null, EventArgs.Empty); } } chkLogPageVisit.Enabled = !chkPageVisitInherit.Checked; } // Check modify permission canEdit = (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Modify) != AuthorizationResultEnum.Denied); // Show document group owner selector if (ModuleEntryManager.IsModuleLoaded(ModuleName.COMMUNITY) && canEditOwner && LicenseHelper.CheckFeature(RequestContext.CurrentDomain, FeatureEnum.Groups)) { plcOwnerGroup.Controls.Clear(); // Initialize panel content Panel rowWrapperPanel = new Panel(); rowWrapperPanel.CssClass = "form-group"; Panel lblPanel = new Panel(); lblPanel.CssClass = "editing-form-label-cell"; Panel ctrlPanel = new Panel(); ctrlPanel.CssClass = "editing-form-value-cell"; // Initialize caption LocalizedLabel lblOwnerGroup = new LocalizedLabel(); lblOwnerGroup.EnableViewState = false; lblOwnerGroup.ResourceString = "community.group.documentowner"; lblOwnerGroup.ID = "lblOwnerGroup"; lblOwnerGroup.CssClass = "control-label"; lblPanel.Controls.Add(lblOwnerGroup); // Initialize selector fcDocumentGroupSelector = (FormEngineUserControl)Page.LoadUserControl("~/CMSAdminControls/UI/Selectors/DocumentGroupSelector.ascx"); fcDocumentGroupSelector.ID = "fcDocumentGroupSelector"; fcDocumentGroupSelector.StopProcessing = pnlUIOwner.IsHidden; ctrlPanel.Controls.Add(fcDocumentGroupSelector); fcDocumentGroupSelector.Value = ValidationHelper.GetInteger(Node.GetValue("NodeGroupID"), 0); fcDocumentGroupSelector.SetValue("siteid", SiteContext.CurrentSiteID); fcDocumentGroupSelector.SetValue("nodeid", Node.NodeID); // Add controls to containers rowWrapperPanel.Controls.Add(lblPanel); rowWrapperPanel.Controls.Add(ctrlPanel); plcOwnerGroup.Controls.Add(rowWrapperPanel); plcOwnerGroup.Visible = true; } // Show owner editing only when authorized to change the permissions if (canEditOwner) { lblOwner.Visible = false; usrOwner.Visible = true; usrOwner.SetValue("AdditionalUsers", new[] { Node.NodeOwner }); } else { usrOwner.Visible = false; } if (!RequestHelper.IsPostBack()) { if (canEditOwner) { usrOwner.Value = Node.GetValue("NodeOwner"); } } // Load the data lblName.Text = HttpUtility.HtmlEncode(Node.GetDocumentName()); lblNamePath.Text = HttpUtility.HtmlEncode(Convert.ToString(Node.GetValue("DocumentNamePath"))); lblAliasPath.Text = Convert.ToString(Node.NodeAliasPath); string typeName = DataClassInfoProvider.GetDataClassInfo(Node.NodeClassName).ClassDisplayName; lblType.Text = HttpUtility.HtmlEncode(ResHelper.LocalizeString(typeName)); lblNodeID.Text = Convert.ToString(Node.NodeID); // Modifier SetUserLabel(lblLastModifiedBy, "DocumentModifiedByUserId"); // Get modified time TimeZoneInfo usedTimeZone; DateTime lastModified = ValidationHelper.GetDateTime(Node.GetValue("DocumentModifiedWhen"), DateTimeHelper.ZERO_TIME); lblLastModified.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(lastModified, MembershipContext.AuthenticatedUser, SiteContext.CurrentSite, out usedTimeZone); ScriptHelper.AppendTooltip(lblLastModified, TimeZoneHelper.GetUTCLongStringOffset(usedTimeZone), "help"); if (!canEditOwner) { // Owner SetUserLabel(lblOwner, "NodeOwner"); } // Creator SetUserLabel(lblCreatedBy, "DocumentCreatedByUserId"); DateTime createdWhen = ValidationHelper.GetDateTime(Node.GetValue("DocumentCreatedWhen"), DateTimeHelper.ZERO_TIME); lblCreated.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(createdWhen, MembershipContext.AuthenticatedUser, SiteContext.CurrentSite, out usedTimeZone); ScriptHelper.AppendTooltip(lblCreated, TimeZoneHelper.GetUTCLongStringOffset(usedTimeZone), "help"); // URL string liveUrl = Node.IsLink ? DocumentURLProvider.GetUrl(Node.NodeAliasPath) : DocumentURLProvider.GetUrl(Node.NodeAliasPath, Node.DocumentUrlPath); lnkLiveURL.Text = URLHelper.ResolveUrl(liveUrl); lnkLiveURL.NavigateUrl = URLHelper.ResolveUrl(liveUrl); string permanentUrl = DocumentURLProvider.GetPermanentDocUrl(Node.NodeGUID, Node.NodeAlias, Node.NodeSiteName, PageInfoProvider.PREFIX_CMS_GETDOC, ".aspx"); lnkPermanentUrl.Text = URLHelper.ResolveUrl(permanentUrl); lnkPermanentUrl.NavigateUrl = URLHelper.ResolveUrl(permanentUrl); bool isRoot = (Node.NodeClassName.ToLowerCSafe() == "cms.root"); // Preview URL if (!isRoot) { plcPreview.Visible = true; btnResetPreviewGuid.ToolTip = GetString("GeneralProperties.InvalidatePreviewURL"); btnResetPreviewGuid.Click += btnResetPreviewGuid_Click; btnResetPreviewGuid.OnClientClick = "if(!confirm(" + ScriptHelper.GetLocalizedString("GeneralProperties.GeneratePreviewURLConf") + ")){return false;}"; InitPreviewUrl(); } lblGUID.Text = Convert.ToString(Node.NodeGUID); lblDocGUID.Text = (Node.DocumentGUID == Guid.Empty) ? ResHelper.Dash : Node.DocumentGUID.ToString(); lblDocID.Text = Convert.ToString(Node.DocumentID); // Culture CultureInfo ci = CultureInfoProvider.GetCultureInfo(Node.DocumentCulture); lblCulture.Text = ((ci != null) ? ResHelper.LocalizeString(ci.CultureName) : Node.DocumentCulture); lblPublished.Text = (Node.IsPublished ? "<span class=\"DocumentPublishedYes\">" + GetString("General.Yes") + "</span>" : "<span class=\"DocumentPublishedNo\">" + GetString("General.No") + "</span>"); // Load page info for inherited cache settings currentPage = PageInfoProvider.GetPageInfo(Node.DocumentGUID); if (!RequestHelper.IsPostBack()) { // Init radio buttons for cache settings if (isRoot) { radInherit.Visible = false; radFSInherit.Visible = false; chkCssStyle.Visible = false; } else { // Show what is inherited value radInherit.Text = GetString("GeneralProperties.radInherit") + " (" + GetInheritedCacheCaption("NodeCacheMinutes") + ")"; radFSInherit.Text = GetString("GeneralProperties.radInherit") + " (" + GetInheritedCacheCaption("NodeAllowCacheInFileSystem") + ")"; } string cacheMinutes = ""; switch (Node.NodeCacheMinutes) { case -1: // Cache setting is inherited { radNo.Checked = true; radYes.Checked = false; radInherit.Checked = false; if (!isRoot) { radInherit.Checked = true; radNo.Checked = false; if ((currentPage != null) && (currentPage.NodeCacheMinutes > 0)) { cacheMinutes = currentPage.NodeCacheMinutes.ToString(); } } } break; case 0: // Cache is off radNo.Checked = true; radYes.Checked = false; radInherit.Checked = false; break; default: // Cache is enabled radNo.Checked = false; radYes.Checked = true; radInherit.Checked = false; cacheMinutes = Node.NodeCacheMinutes.ToString(); break; } // Set secured radio buttons switch (Node.NodeAllowCacheInFileSystem) { case 0: radFSNo.Checked = true; break; case 1: radFSYes.Checked = true; break; default: if (!isRoot) { radFSInherit.Checked = true; } else { radFSYes.Checked = true; } break; } txtCacheMinutes.Text = cacheMinutes; if (!radYes.Checked) { txtCacheMinutes.Enabled = false; } if (Node.GetValue("DocumentStylesheetID") == null) { ctrlSiteSelectStyleSheet.Value = GetDefaultStylesheet(); } else { // If stylesheet is inherited from parent document if (ValidationHelper.GetInteger(Node.GetValue("DocumentStylesheetID"), 0) == -1) { if (!isRoot) { chkCssStyle.Checked = true; // Get parent stylesheet string value = GetParentProperty(); ctrlSiteSelectStyleSheet.Value = String.IsNullOrEmpty(value) ? GetDefaultStylesheet() : value; } } else { ctrlSiteSelectStyleSheet.Value = Node.GetValue("DocumentStylesheetID"); } } } // Disable new button if document inherit stylesheet bool disableCssSelector = (!isRoot && chkCssStyle.Checked); ctrlSiteSelectStyleSheet.Enabled = !disableCssSelector; ctrlSiteSelectStyleSheet.ButtonNewEnabled = !disableCssSelector; // Initialize Rating control RefreshCntRatingResult(); double rating = 0.0f; if (Node.DocumentRatings > 0) { rating = Node.DocumentRatingValue / Node.DocumentRatings; } ratingControl.MaxRating = 10; ratingControl.CurrentRating = rating; ratingControl.Visible = true; ratingControl.Enabled = false; // Initialize Reset button for rating btnResetRating.Text = GetString("general.reset"); btnResetRating.OnClientClick = "if (!confirm(" + ScriptHelper.GetString(GetString("GeneralProperties.ResetRatingConfirmation")) + ")) return false;"; object[] param = new object[1]; param[0] = Node.DocumentID; plcAdHocForums.Visible = hasAdHocForum; plcAdHocBoards.Visible = hasAdHocBoard; if (!canEdit) { // Disable form editing DisableFormEditing(); } } else { btnResetRating.Visible = false; } }
protected override void OnInit(EventArgs e) { // Culture independent data SplitModeAllwaysRefresh = true; // Non-versioned data are modified DocumentManager.UseDocumentHelper = false; base.OnInit(e); // Check UI element permission if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.Content", "Properties.General")) { RedirectToUIElementAccessDenied("CMS.Content", "Properties.General"); } // Redirect to information page when no UI elements displayed if (pnlUIAdvanced.IsHidden && pnlUICache.IsHidden && pnlUIDesign.IsHidden && pnlUIOther.IsHidden && pnlUIOwner.IsHidden) { RedirectToUINotAvailable(); } // Init document manager events DocumentManager.OnSaveData += DocumentManager_OnSaveData; DocumentManager.OnAfterAction += DocumentManager_OnAfterAction; EnableSplitMode = true; // Set user control properties usrOwner = Page.LoadUserControl("~/CMSModules/Membership/FormControls/Users/selectuser.ascx") as FormEngineUserControl; if (usrOwner != null) { usrOwner.ID = "ctrlUsrOwner"; usrOwner.IsLiveSite = false; usrOwner.SetValue("ShowSiteFilter", false); usrOwner.StopProcessing = pnlUIOwner.IsHidden; plcUsrOwner.Controls.Add(usrOwner); } }
protected override void OnInit(EventArgs e) { SiteID = QueryHelper.GetInteger("siteid", 0); if (File.Exists(HttpContext.Current.Request.MapPath(ResolveUrl(pathToGroupselector)))) { Control ctrl = this.LoadUserControl(pathToGroupselector); if (ctrl != null) { selectInGroups = ctrl as FormEngineUserControl; ctrl.ID = "selGroups"; ctrl = this.LoadUserControl(pathToGroupselector); selectNotInGroups = ctrl as FormEngineUserControl; ctrl.ID = "selNoGroups"; plcGroups.Visible = true; plcSelectInGroups.Controls.Add(selectInGroups); plcSelectNotInGroups.Controls.Add(selectNotInGroups); selectNotInGroups.SetValue("UseFriendlyMode", true); selectInGroups.IsLiveSite = false; selectInGroups.SetValue("UseFriendlyMode", true); selectNotInGroups.IsLiveSite = false; } } if (LicenseHelper.CheckFeature(URLHelper.GetCurrentDomain(), FeatureEnum.LeadScoring) && ResourceSiteInfoProvider.IsResourceOnSite("CMS.Scoring", CMSContext.CurrentSiteName) && SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSEnableOnlineMarketing")) { Control ctrl = this.LoadUserControl(pathToScoreSelector); if (ctrl != null) { ctrl.ID = "selectScore"; scoreSelector = ctrl as FormEngineUserControl; if (scoreSelector != null) { plcUpdateContent.Controls.Add(scoreSelector); scoreSelector.SetValue("AllowAll", false); scoreSelector.SetValue("AllowEmpty", true); } } } else { plcScore.Visible = false; lblScore.AssociatedControlID = null; } CMSUsersPage usersPage = (CMSUsersPage)Page; if (usersPage != null) { CurrentMode = usersPage.FilterMode; EnableDisplayingGuests = usersPage.EnableDisplayingGuests; if (CurrentMode == "online" && usersPage.DisplayContacts) { if (usersPage.DisplayScore && (scoreSelector != null)) { plcScore.Visible = true; } } } // Initialize advanced filter dropdownlists if (!RequestHelper.IsPostBack()) { InitAllAnyDropDown(drpTypeSelectInRoles); InitAllAnyDropDown(drpTypeSelectNotInRoles); InitAllAnyDropDown(drpTypeSelectInGroups); InitAllAnyDropDown(drpTypeSelectNotInGroups); // Init lock account reason DDL drpLockReason.Items.Add(new ListItem(GetString("General.selectall"), "")); DataHelper.FillListControlWithEnum(typeof(UserAccountLockEnum), drpLockReason, "userlist.account.", null); } base.OnInit(e); plcDisplayAnonymous.Visible = ContactManagementPermission && SessionManager.StoreOnlineUsersInDatabase && EnableDisplayingGuests; if (!RequestHelper.IsPostBack()) { chkDisplayAnonymous.Checked = DisplayGuestsByDefault; } siteSelector.DropDownSingleSelect.AutoPostBack = true; }
protected void Page_Load(object sender, EventArgs e) { CheckUIElementAccessHierarchical(ModuleName.ONLINEMARKETING, "ContactMembership.Customers"); ci = (ContactInfo)EditedObject; if (ci == null) { RedirectToAccessDenied(GetString("general.invalidparameters")); } CheckReadPermission(ci.ContactSiteID); globalContact = (ci.ContactSiteID <= 0); mergedContact = (ci.ContactMergedWithContactID > 0); modifyAllowed = ContactHelper.AuthorizedModifyContact(ci.ContactSiteID, false); contactId = QueryHelper.GetInteger("contactid", 0); string where = null; // Filter only site members in CMSDesk (for global contacts) if (!IsSiteManager && globalContact && AuthorizedForSiteContacts) { where += " (ContactSiteID IS NULL OR ContactSiteID=" + SiteContext.CurrentSiteID + ")"; } // Choose correct object ("query") according to type of contact if (globalContact) { gridElem.ObjectType = ContactMembershipGlobalCustomerListInfo.OBJECT_TYPE; } else if (mergedContact) { gridElem.ObjectType = ContactMembershipMergedCustomerListInfo.OBJECT_TYPE; } else { gridElem.ObjectType = ContactMembershipCustomerListInfo.OBJECT_TYPE; } // Query parameters QueryDataParameters parameters = new QueryDataParameters(); parameters.Add("@ContactId", contactId); gridElem.WhereCondition = where; gridElem.QueryParameters = parameters; gridElem.OnAction += gridElem_OnAction; gridElem.OnExternalDataBound += gridElem_OnExternalDataBound; // Hide header actions for global contact or merged contact. CurrentMaster.HeaderActionsPlaceHolder.Visible = modifyAllowed && !globalContact && !mergedContact; // Setup customer selector try { ucSelectCustomer = (FormEngineUserControl)Page.LoadUserControl("~/CMSModules/Ecommerce/FormControls/CustomerSelector.ascx"); ucSelectCustomer.SetValue("Mode", "OnlineMarketing"); ucSelectCustomer.SetValue("SiteID", ci.ContactSiteID); ucSelectCustomer.Changed += ucSelectCustomer_Changed; ucSelectCustomer.IsLiveSite = false; pnlSelectCustomer.Controls.Clear(); pnlSelectCustomer.Controls.Add(ucSelectCustomer); } catch { } }
/// <summary> /// Configures selectors. /// </summary> private void SetupSelectors() { // Setup role selector selectRole.CurrentSelector.SelectionMode = SelectionModeEnum.MultipleButton; selectRole.CurrentSelector.OnItemsSelected += RolesSelector_OnItemsSelected; selectRole.CurrentSelector.ReturnColumnName = "RoleID"; selectRole.CurrentSelector.ButtonImage = GetImageUrl("Objects/CMS_Role/add.png"); selectRole.ImageDialog.CssClass = "NewItemImage"; selectRole.LinkDialog.CssClass = "NewItemLink"; selectRole.ShowSiteFilter = false; selectRole.CurrentSelector.ResourcePrefix = "addroles"; selectRole.DialogButton.CssClass = "LongButton"; selectRole.IsLiveSite = false; selectRole.UseCodeNameForSelection = false; // Setup user selector selectUser.UniSelector.SelectionMode = SelectionModeEnum.MultipleButton; selectUser.UniSelector.OnItemsSelected += UserSelector_OnItemsSelected; selectUser.UniSelector.ReturnColumnName = "UserID"; selectUser.UniSelector.DisplayNameFormat = "{%FullName%} ({%Email%})"; selectUser.UniSelector.ButtonImage = GetImageUrl("Objects/CMS_User/add.png"); selectUser.ImageDialog.CssClass = "NewItemImage"; selectUser.LinkDialog.CssClass = "NewItemLink"; selectUser.ShowSiteFilter = false; selectUser.ResourcePrefix = "addusers"; selectUser.DialogButton.CssClass = "LongButton"; selectUser.IsLiveSite = false; // Setup subscriber selector selectSubscriber.UniSelector.SelectionMode = SelectionModeEnum.MultipleButton; selectSubscriber.UniSelector.OnItemsSelected += SubscriberSelector_OnItemsSelected; selectSubscriber.UniSelector.ReturnColumnName = "SubscriberID"; selectSubscriber.UniSelector.ButtonImage = GetImageUrl("Objects/Newsletter_Subscriber/add.png"); selectSubscriber.ImageDialog.CssClass = "NewItemImage"; selectSubscriber.LinkDialog.CssClass = "NewItemLink"; selectSubscriber.ShowSiteFilter = false; selectSubscriber.DialogButton.CssClass = "LongButton"; selectSubscriber.IsLiveSite = false; // Setup contact group selector if (ModuleEntry.IsModuleLoaded(ModuleEntry.ONLINEMARKETING) && CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.ContactManagement", "ReadContactGroups") && LicenseHelper.CheckFeature(URLHelper.GetCurrentDomain(), FeatureEnum.ContactManagement)) { // Load selector control and initialize it plcSelectCG.Controls.Clear(); cgSelector = (FormEngineUserControl)Page.LoadControl("~/CMSModules/ContactManagement/FormControls/ContactGroupSelector.ascx"); if (cgSelector != null) { cgSelector.ID = "selectCG"; // Get inner uniselector control UniSelector selector = (UniSelector)cgSelector.GetValue("uniselector"); if (selector != null) { // Bind an event handler on 'items selected' event selector.OnItemsSelected += new EventHandler(selector_OnItemsSelected); selector.ResourcePrefix = "contactgroupsubscriber"; } // Insert selector to the header plcSelectCG.Controls.Add(cgSelector); } } // Initialize mass actions if (this.drpActions.Items.Count == 0) { drpActions.Items.Add(new ListItem(GetString("general.selectaction"), "SELECT")); drpActions.Items.Add(new ListItem(GetString("general.approve"), "APPROVE")); drpActions.Items.Add(new ListItem(GetString("general.Reject"), "REJECT")); drpActions.Items.Add(new ListItem(GetString("general.remove"), "REMOVE")); } }
/// <summary> /// Displays and hides plain CSS code preview. /// </summary> private void HandleCssCodePreview() { if (RequestHelper.IsPostBack() && !plainCssOnly) { // Don't process if the CSS preview control is not visible FormEngineUserControl previewControl = EditForm.FieldControls["StylesheetCodePreview"]; if ((previewControl != null) && !previewControl.Visible) { return; } // Get the edited stylesheet CssStylesheetInfo cssInfo = EditForm.EditedObject as CssStylesheetInfo; if (cssInfo == null) { return; } string lang = ValidationHelper.GetString(cssInfo.StylesheetDynamicLanguage, CssStylesheetInfo.PLAIN_CSS); string previewMode = ValidationHelper.GetString(EditForm.GetFieldValue("StylesheetCodePreview"), String.Empty); // Display preview if (!String.IsNullOrEmpty(previewMode) && previewMode.EqualsCSafe("preview", true) && !lang.EqualsCSafe(CssStylesheetInfo.PLAIN_CSS, true)) { // Get the stylesheet dynamic code string code = ValidationHelper.GetString(EditForm.GetFieldValue("StylesheetDynamicCode"), String.Empty); string output = String.Empty; // Run preprocessor string parserError = CSSStylesheetNewControlExtender.ProcessCss(code, lang, out output, hidCompiledCss); if (String.IsNullOrEmpty(parserError)) { // Set the editor value and disable editing FormEngineUserControl plainCssEditor = EditForm.FieldControls["StylesheetText"]; if (plainCssEditor != null) { plainCssEditor.Value = output; codePreviewDisplayed = true; } // Hide dynamic code editor FormEngineUserControl dynamicCodeEditor = EditForm.FieldControls["StylesheetDynamicCode"]; if (dynamicCodeEditor != null) { dynamicCodeEditor.CssClass = "Hidden"; } } else { // Handle the error that occurred during parsing EditForm.ShowError(parserError); FormEngineUserControl previewField = EditForm.FieldControls["StylesheetCodePreview"]; if (previewField != null) { previewField.Value = lang; } } return; } // Hide preview if (!String.IsNullOrEmpty(previewMode) && !previewMode.EqualsCSafe("preview", true)) { // Ensure the visibility of the field if the preview is not active FormEngineUserControl dynamicCodeEditor = EditForm.FieldControls["StylesheetDynamicCode"]; if (dynamicCodeEditor != null) { dynamicCodeEditor.CssClass = ""; } // Enable for editing despite the editor is hidden FormEngineUserControl plainCssEditor = EditForm.FieldControls["StylesheetText"]; if (plainCssEditor != null) { plainCssEditor.Enabled = true; } } } }
/// <summary> /// Performs an additional SKU validation on the specified form control. /// Returns an error message if the field is not valid, otherwise returns null. /// </summary> private string ValidateSkuField(FormEngineUserControl formControl) { // General validation switch (formControl.FieldInfo.Name) { case "SKUImagePath": { string value = formControl.Value as string; // Validate meta files file system permissions string siteName = SiteInfoProvider.GetSiteName(ProductSiteID); var filesLocationType = FileHelper.FilesLocationType(siteName); if (!string.IsNullOrEmpty(value) && (filesLocationType != FilesLocationTypeEnum.Database)) { string path = MetaFileInfoProvider.GetFilesFolderPath(siteName); if (!DirectoryHelper.CheckPermissions(path)) { return GetString("com.newproduct.accessdeniedtopath"); } } } break; case "SKUMembershipGUID": { Guid value = ValidationHelper.GetGuid(formControl.Value, Guid.Empty); // Validate membership is selected if (value == Guid.Empty) { return GetString("com.membership.nomembershipselectederror"); } } break; case "SKUWeight": { double? value = GetNullableDouble(formControl.Value); // Validate weight is > 0 if (value.HasValue && value.Value <= 0) { return GetString("com.productedit.packageweightinvalid"); } } break; case "SKUHeight": { double? value = GetNullableDouble(formControl.Value); // Validate height is > 0 if (value.HasValue && value.Value <= 0) { return GetString("com.productedit.packageheightinvalid"); } } break; case "SKUWidth": { double? value = GetNullableDouble(formControl.Value); // Validate width is > 0 if (value.HasValue && value.Value <= 0) { return GetString("com.productedit.packagewidthinvalid"); } } break; case "SKUDepth": { double? value = GetNullableDouble(formControl.Value); // Validate depth is > 0 if (value.HasValue && value.Value <= 0) { return GetString("com.productedit.packagedepthinvalid"); } } break; case "SKUMinItemsInOrder": { int? value = GetNullableInteger(formControl.Value); // Validate minimum items in one order is > 0 if (value.HasValue && value.Value <= 0) { return GetString("com.productedit.minorderitemsinvalid"); } // Validate minimum items in one order is lower than maximum int? maxItems = GetNullableInteger(GetFieldValue(CurrentSKUForms, "SKUMaxItemsInOrder")); if (value.HasValue && maxItems.HasValue && (value.Value > maxItems.Value)) { return GetString("com.productedit.minorderitemsexceedsmax"); } } break; case "SKUMaxItemsInOrder": { int? value = GetNullableInteger(formControl.Value); // Validate maximum items in one order if (value.HasValue && value.Value <= 0) { return GetString("com.productedit.maxorderitemsinvalid"); } } break; } // Donation specific validation if (SKURepresenting == SKUProductTypeEnum.Donation) { switch (formControl.FieldInfo.Name) { case "SKUPrice": { double? value = GetNullableDouble(formControl.Value); // Validate price against donation amount if (value.HasValue) { double? minDonationAmount = GetNullableDouble(GetFieldValue(CurrentSKUForms, "SKUMinPrice")); double? maxDonationAmount = GetNullableDouble(GetFieldValue(CurrentSKUForms, "SKUMaxPrice")); if ((minDonationAmount.HasValue && minDonationAmount.Value > value.Value) || (maxDonationAmount.HasValue && maxDonationAmount < value.Value)) { return GetString("com.productedit.donationpriceinvalid"); } } } break; case "SKURetailPrice": { double? value = GetNullableDouble(formControl.Value); // Validate retail price against donation amount if (value.HasValue) { double? minDonationAmount = GetNullableDouble(GetFieldValue(CurrentSKUForms, "SKUMinPrice")); double? maxDonationAmount = GetNullableDouble(GetFieldValue(CurrentSKUForms, "SKUMaxPrice")); if ((minDonationAmount.HasValue && minDonationAmount.Value > value.Value) || (maxDonationAmount.HasValue && maxDonationAmount < value.Value)) { return GetString("com.productedit.donationpriceinvalid"); } } } break; case "SKUMinPrice": { double? value = GetNullableDouble(formControl.Value); // Validate min donation amount is lower than maximum if (value.HasValue) { double? maxDonationAmount = GetNullableDouble(GetFieldValue(CurrentSKUForms, "SKUMaxPrice")); if (maxDonationAmount.HasValue && (value.Value > maxDonationAmount.Value)) { return GetString("com.donation.donationamountrangeinvalid"); } } } break; } } return null; }
protected void Page_Load(object sender, EventArgs e) { UIContext.PropertyTab = PropertyTabEnum.General; // Register the scripts ScriptHelper.RegisterProgress(Page); ScriptHelper.RegisterTooltip(Page); ScriptHelper.RegisterDialogScript(this); // Set user control properties usrOwner = Page.LoadUserControl("~/CMSModules/Membership/FormControls/Users/selectuser.ascx") as FormEngineUserControl; if (usrOwner != null) { usrOwner.ID = "ctrlUsrOwner"; usrOwner.IsLiveSite = false; usrOwner.SetValue("ShowSiteFilter", false); usrOwner.StopProcessing = pnlUIOwner.IsHidden; plcUsrOwner.Controls.Add(usrOwner); } // Init strings pnlDesign.GroupingText = GetString("GeneralProperties.DesignGroup"); pnlCache.GroupingText = GetString("GeneralProperties.CacheGroup"); pnlOther.GroupingText = GetString("GeneralProperties.OtherGroup"); pnlAdvanced.GroupingText = GetString("GeneralProperties.AdvancedGroup"); pnlOwner.GroupingText = GetString("GeneralProperties.OwnerGroup"); // Advanced section mEditableContent = GetString("GeneralProperties.EditableContent"); mForums = GetString("PageProperties.AdHocForum"); mMessageBoards = GetString("PageProperties.MessageBoards"); lnkEditableContent.OnClientClick = "ShowEditableContent(); return false;"; lnkMessageBoards.OnClientClick = "ShowMessageBoards(); return false;"; lnkForums.OnClientClick = "ShowForums(); return false;"; imgEditableContent.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditableContent/editablecontent.png"); imgMessageBoards.ImageUrl = GetImageUrl("CMSModules/CMS_MessageBoards/module.png"); imgForums.ImageUrl = GetImageUrl("CMSModules/CMS_Forums/module.png"); // Get strings for radio buttons lblCacheMinutes.Text = GetString("GeneralProperties.cacheMinutes"); // Get strings for labels lblNameTitle.Text = GetString("GeneralProperties.Name"); lblNamePathTitle.Text = GetString("GeneralProperties.NamePath"); lblAliasPathTitle.Text = GetString("GeneralProperties.AliasPath"); lblTypeTitle.Text = GetString("GeneralProperties.Type"); lblNodeIDTitle.Text = GetString("GeneralProperties.NodeID"); lblLastModifiedByTitle.Text = GetString("GeneralProperties.LastModifiedBy"); lblLastModifiedTitle.Text = GetString("GeneralProperties.LastModified"); lblLiveURLTitle.Text = GetString("GeneralProperties.LiveURL"); lblPreviewURLTitle.Text = GetString("GeneralProperties.PreviewURL"); lblGUIDTitle.Text = GetString("GeneralProperties.GUID"); lblDocGUIDTitle.Text = GetString("GeneralProperties.DocumentGUID"); lblDocIDTitle.Text = GetString("GeneralProperties.DocumentID"); lblCultureTitle.Text = GetString("GeneralProperties.Culture"); lblCreatedByTitle.Text = GetString("GeneralProperties.CreatedBy"); lblCreatedTitle.Text = GetString("GeneralProperties.Created"); lblOwnerTitle.Text = GetString("GeneralProperties.Owner"); lblCssStyle.Text = GetString("PageProperties.CssStyle"); lblPublishedTitle.Text = GetString("PageProperties.Published"); chkCssStyle.Text = GetString("Metadata.Inherit"); pnlOnlineMarketing.GroupingText = GetString("general.onlinemarketing"); // Set default item value string defaultStyleSheet = "-1"; CssStylesheetInfo cssInfo = CMSContext.CurrentSiteStylesheet; // If current site default style sheet defined, choose it if (cssInfo != null) { defaultStyleSheet = "default"; } ctrlSiteSelectStyleSheet.CurrentSelector.SpecialFields = new string[, ] { { GetString("general.defaultchoice"), defaultStyleSheet } }; ctrlSiteSelectStyleSheet.ReturnColumnName = "StyleSheetID"; ctrlSiteSelectStyleSheet.SiteId = CMSContext.CurrentSiteID; if ((CMSContext.CurrentSite != null) && (usrOwner != null)) { usrOwner.SetValue("SiteID", CMSContext.CurrentSite.SiteID); } int documentId = 0; string script = null; TreeNode node = Node; if (node != null) { // Create wireframe option if (node.NodeWireframeTemplateID <= 0) { mWireframe = GetString("Wireframe.Create"); string createUrl = URLHelper.ResolveUrl(String.Format("~/CMSModules/Content/CMSDesk/Properties/CreateWireframe.aspx?nodeid={0}&culture={1}", node.NodeID, node.DocumentCulture)); lnkWireframe.OnClientClick = "parent.location.replace('" + createUrl + "'); return false;"; imgWireframe.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/createwireframe.png"); } else { mWireframe = GetString("Wireframe.Remove"); imgWireframe.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/removewireframe.png"); lnkWireframe.OnClientClick = "return confirm('" + GetString("Wireframe.ConfirmRemove") + "')"; lnkWireframe.Click += new EventHandler(lnkWireframe_Click); } plcWireframe.Visible = PortalHelper.IsWireframingEnabled(CMSContext.CurrentSiteName); documentId = node.DocumentID; canEditOwner = (CMSContext.CurrentUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.ModifyPermissions) == AuthorizationResultEnum.Allowed); ctrlSiteSelectStyleSheet.AliasPath = node.NodeAliasPath; ReloadData(); // Check ad-hoc forum counts hasAdHocForum = (ModuleCommands.ForumsGetDocumentForumsCount(node.DocumentID) > 0); // Ad-Hoc message boards check hasAdHocBoard = (ModuleCommands.MessageBoardGetDocumentBoardsCount(node.DocumentID) > 0); script += "function ShowEditableContent() { modalDialog('" + ResolveUrl("Advanced/EditableContent/default.aspx") + "?nodeid=" + node.NodeID + "', 'EditableContent', 1015, 700); } \n"; } // Generate executive script if (hasAdHocBoard) { plcAdHocBoards.Visible = true; script += "function ShowMessageBoards() { modalDialog('" + ResolveUrl("~/CMSModules/MessageBoards/Content/Properties/default.aspx") + "?documentid=" + documentId + "', 'MessageBoards', 1020, 680); } \n"; } if (hasAdHocForum) { plcAdHocForums.Visible = true; script += "function ShowForums() { modalDialog('" + ResolveUrl("~/CMSModules/Forums/Content/Properties/default.aspx") + "?documentid=" + documentId + "', 'Forums', 1130, 680); } \n"; } ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ModalDialogsToAdvancedSection", ScriptHelper.GetScript(script)); // Reflect processing action pnlContent.Enabled = DocumentManager.AllowSave; if (chkCssStyle.Checked) { // Enable the edit button ctrlSiteSelectStyleSheet.ButtonEditEnabled = true; } }
/// <summary> /// Initializes group selector. /// </summary> private void InitializeGroupSelector() { if (groupsSelector == null) { try { groupsSelector = LoadControl(controlPath) as FormEngineUserControl; // Set up selector groupsSelector.ID = "dialogsGroupSelector"; groupsSelector.SetValue("DisplayCurrentGroup", false); groupsSelector.SetValue("SiteID", 0); groupsSelector.IsLiveSite = IsLiveSite; groupsSelector.Changed += groupSelector_Changed; // Get uniselector and set it up UniSelector us = groupsSelector.GetValue("CurrentSelector") as UniSelector; if (us != null) { us.ReturnColumnName = "GroupID"; } // Get dropdownlist and set it up DropDownList drpGroups = groupsSelector.GetValue("CurrentDropDown") as DropDownList; if (drpGroups != null) { drpGroups.AutoPostBack = true; } // Add control to panel pnlGroupSelector.Controls.Add(groupsSelector); } catch(HttpException) { // Couldn't load the control plcGroupSelector.Visible = false; } } }
/// <summary> /// Add style to the control defined by id. /// </summary> /// <param name="sourceControl">Source control containing the target control</param> /// <param name="id">Id of the target control</param> /// <param name="type">Type of the target control</param> /// <param name="styles">Style of the target control</param> private void SetStyle(FormEngineUserControl sourceControl, string id, string type, string styles) { if (type == "panel") { Panel p = sourceControl.FindControl(id) as Panel; if (p != null) { foreach (string style in styles.Split(';')) { p.Style[style.Split(':')[0].Trim()] = style.Split(':')[1].Trim(); } } } else if (type == "htmlcontrol") { HtmlControl p = sourceControl.FindControl(id) as HtmlControl; if (p != null) { foreach (string style in styles.Split(';')) { p.Style[style.Split(':')[0].Trim()] = style.Split(':')[1].Trim(); } } } }
/// <summary> /// Adds new row into result table. /// </summary> private void AddRow(bool isDefaultCulture, ref int rowCount, TableRow row, TableCell cellText, TableCell cellValue, FormEngineUserControl control, Control c, DataRow dr) { string cultureName = HTMLHelper.HTMLEncode(ValidationHelper.GetString(dr["UICultureName"], null)); string cultureCode = ValidationHelper.GetString(dr["UICultureCode"], null); if ((cultureCode != CultureHelper.DefaultUICulture) || isDefaultCulture) { // Create new row row = new TableRow(); row.CssClass = (rowCount % 2 == 0) ? "OddRow" : "EvenRow"; rowCount++; // Create cell with culture name cellText = new TableCell(); cellText.Text = "<img class=\"Image16\" style=\"vertical-align:middle;\" src=\"" + UIHelper.GetFlagIconUrl(this.Page, ValidationHelper.GetString(dr["UICultureCode"], null), "16x16") + "\" alt=\"" + cultureName + "\" /> " + cultureName; if (isDefaultCulture) { cellText.Text += " " + GetString("general.defaultchoice"); } row.Cells.Add(cellText); // Create cell with translation text cellValue = new TableCell(); control = null; c = Page.LoadControl("~/CMSFormControls/Inputs/LargeTextArea.ascx"); cellValue.Controls.Add(c); row.Cells.Add(cellValue); tblGrid.Rows.Add(row); c.ID = cultureCode; if (c.ID == CultureHelper.DefaultUICulture) { defaultCultureName = cellText.Text; } if (c is FormEngineUserControl) { control = (FormEngineUserControl)c; control.Value = ValidationHelper.GetString(dr["TranslationText"], null); ; translations[dr["UICultureCode"]] = control; } } }
/// <summary> /// Create customer personify info object /// </summary> /// <param name="firstName">firstName</param> /// <param name="lastName">lastName</param> public bool CreateCustomerInf(string userName, string firstName, string lastName) { string personifyAddress = string.Empty, address1 = string.Empty, address2 = string.Empty, city = string.Empty, state = string.Empty, zip = string.Empty, country = string.Empty; bool custInfCreated = false; try { FormEngineUserControl PersonifyAddress = formUser.FieldControls["PersonifyAddress"]; if (PersonifyAddress != null) { personifyAddress = ValidationHelper.GetString(PersonifyAddress.Value, String.Empty); } var address = personifyAddress.Split('|'); address1 = address[0]; address2 = address[1]; city = address[2]; state = address[3]; country = address[4]; zip = address[5]; //Create an individual Customer with 1 address linked to employer and another individual address var a = new DataServiceCollection <SaveAddressInput>(null, TrackingMode.None); //Address linked to a company SaveAddressInput a1 = new SaveAddressInput() { AddressTypeCode = "WORK", Address1 = address1, Address2 = address2, City = city, State = state, PostalCode = zip, CountryCode = country, OverrideAddressValidation = false, SetRelationshipAsPrimary = true, PrimaryAddress = true, CreateNewAddressIfOrdersExist = true, EndOldPrimaryRelationship = true, WebMobileDirectory = true, }; a.Add(a1); CusCommunicationInput emailInput = new CusCommunicationInput(); emailInput.CommLocationCode = "WORK"; emailInput.CommTypeCode = "EMAIL"; emailInput.PrimaryFlag = true; emailInput.ActiveFlag = true; emailInput.CountryCode = country; emailInput.FormattedPhoneAddress = userName; SaveCustomerInput s = new SaveCustomerInput() { FirstName = firstName, LastName = lastName, CustomerClassCode = "INDIV", Addresses = a, Communication = new DataServiceCollection <CusCommunicationInput>(null, TrackingMode.None) }; s.Communication.Add(emailInput); SaveCustomerOutput op = PersonifyDataServiceClient.Post <SaveCustomerOutput>("CreateIndividual", s); if (!String.IsNullOrEmpty(op.MasterCustomerId)) { var newIdentifier = op.MasterCustomerId + "|0"; custInfCreated = true; var result = ssoClient.TIMSSCustomerIdentifierSet(PersonifyVendorName, PersonifyVendorPassword, userName, newIdentifier); custInfCreated = result.CustomerIdentifier == newIdentifier; if (!custInfCreated) { throw new Exception(result.Errors.FirstOrDefault()); } FormEngineUserControl txtEducationLevel = formUser.FieldControls["EducationLevel"]; if (txtEducationLevel != null) { var educationLevel = ValidationHelper.GetString(txtEducationLevel.Value, String.Empty); if (!String.IsNullOrEmpty(educationLevel)) { var demo1 = PersonifyDataServiceClient.Create <CusDemographicList>(); demo1.MasterCustomerId = op.MasterCustomerId; demo1.SubCustomerId = op.SubCustomerId; demo1.DemographicCode = "EDUC_LEVEL"; demo1.DemographicSubcode = educationLevel; var result1 = PersonifyDataServiceClient.Save <CusDemographicList>(demo1); } } FormEngineUserControl txtReferralSource = formUser.FieldControls["ReferralSource"]; if (txtReferralSource != null) { var referralSource = ValidationHelper.GetString(txtReferralSource.Value, String.Empty); if (!String.IsNullOrEmpty(referralSource)) { var demo2 = PersonifyDataServiceClient.Create <CusDemographicList>(); demo2.MasterCustomerId = op.MasterCustomerId; demo2.SubCustomerId = op.SubCustomerId; demo2.DemographicCode = "REFERRAL_SOURCE"; demo2.DemographicSubcode = referralSource; var result2 = PersonifyDataServiceClient.Save <CusDemographicList>(demo2); } } FormEngineUserControl txtInterestArea = formUser.FieldControls["InterestArea"]; if (txtInterestArea != null) { var interestArea = ValidationHelper.GetString(txtInterestArea.Value, String.Empty); if (!String.IsNullOrEmpty(interestArea)) { var demo3 = PersonifyDataServiceClient.Create <CusDemographicList>(); demo3.MasterCustomerId = op.MasterCustomerId; demo3.SubCustomerId = op.SubCustomerId; demo3.DemographicCode = "INT_AREA"; demo3.DemographicSubcode = interestArea; var result3 = PersonifyDataServiceClient.Save <CusDemographicList>(demo3); } } FormEngineUserControl txtIndustry = formUser.FieldControls["Industry"]; if (txtIndustry != null) { var industry = ValidationHelper.GetString(txtIndustry.Value, String.Empty); if (!String.IsNullOrEmpty(industry)) { var demo4 = PersonifyDataServiceClient.Create <CusDemographicList>(); demo4.MasterCustomerId = op.MasterCustomerId; demo4.SubCustomerId = op.SubCustomerId; demo4.DemographicCode = "INDUSTRY"; demo4.DemographicSubcode = industry; var result4 = PersonifyDataServiceClient.Save <CusDemographicList>(demo4); } } } else { throw new Exception("created individual, but master customer id was empty."); } } catch (DataServiceClientException ex) { //disable customer account ssoClient.SSOEnableDisableCustomerAccount(PersonifyVendorName, PersonifyVendorPassword, userName, true); custInfCreated = false; throw ex; } return(custInfCreated); }
/// <summary> /// OnInit event. /// </summary> protected override void OnInit(EventArgs e) { SiteID = QueryHelper.GetInteger("siteid", 0); if (File.Exists(HttpContext.Current.Request.MapPath(ResolveUrl(pathToGroupselector)))) { Control ctrl = LoadUserControl(pathToGroupselector); if (ctrl != null) { selectInGroups = ctrl as FormEngineUserControl; ctrl.ID = "selGroups"; ctrl = LoadUserControl(pathToGroupselector); selectNotInGroups = ctrl as FormEngineUserControl; ctrl.ID = "selNoGroups"; plcGroups.Visible = true; plcSelectInGroups.Controls.Add(selectInGroups); plcSelectNotInGroups.Controls.Add(selectNotInGroups); selectNotInGroups.SetValue("UseFriendlyMode", true); selectInGroups.IsLiveSite = false; selectInGroups.SetValue("UseFriendlyMode", true); selectNotInGroups.IsLiveSite = false; } } if (DisplayScore && SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSEnableOnlineMarketing")) { Control ctrl = LoadUserControl(pathToScoreSelector); if (ctrl != null) { ctrl.ID = "selectScore"; scoreSelector = ctrl as FormEngineUserControl; if (scoreSelector != null) { plcUpdateContent.Controls.Add(scoreSelector); scoreSelector.SetValue("AllowAll", false); scoreSelector.SetValue("AllowEmpty", true); } } } else { plcScore.Visible = false; lblScore.AssociatedControlID = null; } // Initialize advanced filter dropdownlists if (!RequestHelper.IsPostBack()) { InitAllAnyDropDown(drpTypeSelectInRoles); InitAllAnyDropDown(drpTypeSelectNotInRoles); InitAllAnyDropDown(drpTypeSelectInGroups); InitAllAnyDropDown(drpTypeSelectNotInGroups); // Init lock account reason DDL drpLockReason.Items.Add(new ListItem(GetString("General.selectall"), "")); ControlsHelper.FillListControlWithEnum<UserAccountLockEnum>(drpLockReason, "userlist.account"); } base.OnInit(e); plcDisplayAnonymous.Visible = ContactManagementPermission && SessionManager.StoreOnlineUsersInDatabase && EnableDisplayingGuests; if (!RequestHelper.IsPostBack()) { chkDisplayAnonymous.Checked = DisplayGuestsByDefault; } siteSelector.DropDownSingleSelect.AutoPostBack = true; }
/// <summary> /// OK click handler (Proceed registration). /// </summary> private void btnRegister_Click(object sender, EventArgs e) { string currentSiteName = SiteContext.CurrentSiteName; string[] siteList = { currentSiteName }; // If AssignToSites field set if (!String.IsNullOrEmpty(AssignToSites)) { siteList = AssignToSites.Split(';'); } if ((PageManager.ViewMode == ViewModeEnum.Design) || (HideOnCurrentPage) || (!IsVisible)) { // Do not process } else { // Ban IP addresses which are blocked for registration if (!BannedIPInfoProvider.IsAllowed(currentSiteName, BanControlEnum.Registration)) { lblError.Visible = true; lblError.Text = GetString("banip.ipisbannedregistration"); return; } // Check if captcha is required and verify captcha text if (DisplayCaptcha && !captchaElem.IsValid()) { // Display error message if captcha text is not valid lblError.Visible = true; lblError.Text = GetString("Webparts_Membership_RegistrationForm.captchaError"); return; } string userName = String.Empty; string nickName = String.Empty; string firstName = String.Empty; string lastName = String.Empty; string emailValue = String.Empty; string pwd = string.Empty; string confPassword = string.Empty; string educationLevel = String.Empty; string interestArea = String.Empty; string industry = String.Empty; string referralSource = string.Empty; // Check duplicate user // 1. Find appropriate control and get its value (i.e. user name) // 2. Try to find user info //FormEngineUserControl txtUserName = formUser.FieldControls["UserName"]; //if (txtUserName != null) //{ // userName = ValidationHelper.GetString(txtUserName.Value, String.Empty); //} FormEngineUserControl txtEmail = formUser.FieldControls["Email"]; if (txtEmail != null) { emailValue = ValidationHelper.GetString(txtEmail.Value, String.Empty); userName = emailValue; } // If user name and e-mail aren't filled stop processing and display error. if (string.IsNullOrEmpty(userName) && String.IsNullOrEmpty(emailValue)) { formUser.StopProcessing = true; lblError.Visible = true; lblError.Text = GetString("customregistrationform.usernameandemail"); return; } else { formUser.Data.SetValue("UserName", userName); } //check if email is valid if (!ValidationHelper.IsEmail(txtEmail.Text.ToLowerCSafe())) { lblError.Visible = true; lblError.Text = GetString("Webparts_Membership_RegistrationForm.EmailIsNotValid"); return; } FormEngineUserControl txtNickName = formUser.FieldControls["UserNickName"]; if (txtNickName != null) { nickName = ValidationHelper.GetString(txtNickName.Value, String.Empty); } FormEngineUserControl txtFirstName = formUser.FieldControls["FirstName"]; if (txtFirstName != null) { firstName = ValidationHelper.GetString(txtFirstName.Value, String.Empty); } FormEngineUserControl txtLastName = formUser.FieldControls["LastName"]; if (txtLastName != null) { lastName = ValidationHelper.GetString(txtLastName.Value, String.Empty); } FormEngineUserControl txtPwd = formUser.FieldControls["UserPassword"]; if (txtPwd != null) { pwd = ValidationHelper.GetString(txtPwd.Value, String.Empty); } FormEngineUserControl txtConfPassword = formUser.FieldControls["ReenterPassword"]; if (txtConfPassword != null) { confPassword = ValidationHelper.GetString(txtConfPassword.Value, String.Empty); } if (string.IsNullOrEmpty(pwd) || string.IsNullOrEmpty(confPassword)) { lblError.Visible = true; lblError.Text = "please enter password with confirmation"; return; } if (pwd != confPassword) { lblError.Visible = true; lblError.Text = "Password doesn't match"; return; } if (validateFields(formUser.FieldControls["UserPassword"].Value.ToString())) { // Test if "global" or "site" user exists. SiteInfo si = SiteContext.CurrentSite; UserInfo siteui = UserInfoProvider.GetUserInfo(UserInfoProvider.EnsureSitePrefixUserName(userName, si)); if ((UserInfoProvider.GetUserInfo(userName) != null) || (siteui != null)) { lblError.Visible = true; lblError.Text = GetString("Webparts_Membership_RegistrationForm.UserAlreadyExists").Replace("%%name%%", HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(userName, true))); return; } // Check for reserved user names like administrator, sysadmin, ... if (UserInfoProvider.NameIsReserved(currentSiteName, userName)) { lblError.Visible = true; lblError.Text = GetString("Webparts_Membership_RegistrationForm.UserNameReserved").Replace("%%name%%", HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(userName, true))); return; } if (UserInfoProvider.NameIsReserved(currentSiteName, nickName)) { lblError.Visible = true; lblError.Text = GetString("Webparts_Membership_RegistrationForm.UserNameReserved").Replace("%%name%%", HTMLHelper.HTMLEncode(nickName)); return; } // Check limitations for site members if (!UserInfoProvider.LicenseVersionCheck(RequestContext.CurrentDomain, FeatureEnum.SiteMembers, ObjectActionEnum.Insert, false)) { lblError.Visible = true; lblError.Text = GetString("License.MaxItemsReachedSiteMember"); return; } // Check whether email is unique if it is required if (!UserInfoProvider.IsEmailUnique(emailValue, siteList, 0)) { lblError.Visible = true; lblError.Text = GetString("UserInfo.EmailAlreadyExist"); return; } // Validate and save form with new user data if (!formUser.Save()) { // Return if saving failed return; } // Get user info from form UserInfo ui = (UserInfo)formUser.Info; // Add user prefix if settings is on // Ensure site prefixes if (UserInfoProvider.UserNameSitePrefixEnabled(currentSiteName)) { ui.UserName = UserInfoProvider.EnsureSitePrefixUserName(userName, si); } ui.Enabled = EnableUserAfterRegistration; ui.UserURLReferrer = MembershipContext.AuthenticatedUser.URLReferrer; ui.UserCampaign = AnalyticsHelper.Campaign; ui.SetPrivilegeLevel(UserPrivilegeLevelEnum.None); // Fill optionally full user name if (String.IsNullOrEmpty(ui.FullName)) { ui.FullName = UserInfoProvider.GetFullName(ui.FirstName, ui.MiddleName, ui.LastName); } // Ensure nick name if (ui.UserNickName.Trim() == String.Empty) { ui.UserNickName = Functions.GetFormattedUserName(ui.UserName, true); } ui.UserSettings.UserRegistrationInfo.IPAddress = RequestContext.UserHostAddress; ui.UserSettings.UserRegistrationInfo.Agent = HttpContext.Current.Request.UserAgent; ui.UserSettings.UserLogActivities = true; ui.UserSettings.UserShowIntroductionTile = true; // Check whether confirmation is required bool requiresConfirmation = SettingsKeyInfoProvider.GetBoolValue(currentSiteName + ".CMSRegistrationEmailConfirmation"); bool requiresAdminApprove = SettingsKeyInfoProvider.GetBoolValue(currentSiteName + ".CMSRegistrationAdministratorApproval"); if (!requiresConfirmation) { // If confirmation is not required check whether administration approval is reqiures if (requiresAdminApprove) { ui.Enabled = false; ui.UserSettings.UserWaitingForApproval = true; } } else { // EnableUserAfterRegistration is overrided by requiresConfirmation - user needs to be confirmed before enable ui.Enabled = false; } // Set user's starting alias path if (!String.IsNullOrEmpty(StartingAliasPath)) { ui.UserStartingAliasPath = MacroResolver.ResolveCurrentPath(StartingAliasPath); } // Get user password and save it in apropriate format after form save string password = ValidationHelper.GetString(ui.GetValue("UserPassword"), String.Empty); UserInfoProvider.SetPassword(ui, password); var customerToken = PersonifyRegistered(emailValue, password, firstName, lastName); if (string.IsNullOrEmpty(customerToken)) { UserInfoProvider.DeleteUser(ui); return; } else { var roles = GetImsroles(customerToken); string groupslist = ""; if (roles.Length > 0) { foreach (string s in roles) { if (s.Length > 0) { groupslist += s + ","; } } } //we need this mispelling. groupslist += "peronifyUser" + ","; new LoginUsertokentico().AddUserToRole(ui, groupslist, true, false); } // Prepare macro data source for email resolver UserInfo userForMail = ui.Clone(); userForMail.SetValue("UserPassword", string.Empty); object[] data = new object[1]; data[0] = userForMail; // Prepare resolver for notification and welcome emails MacroResolver resolver = MacroContext.CurrentResolver; resolver.SetAnonymousSourceData(data); #region "Welcome Emails (confirmation, waiting for approval)" bool error = false; EmailTemplateInfo template = null; // Prepare macro replacements string[,] replacements = new string[6, 2]; replacements[0, 0] = "confirmaddress"; replacements[0, 1] = AuthenticationHelper.GetRegistrationApprovalUrl(ApprovalPage, ui.UserGUID, currentSiteName, NotifyAdministrator); replacements[1, 0] = "username"; replacements[1, 1] = userName; replacements[2, 0] = "password"; replacements[2, 1] = password; replacements[3, 0] = "Email"; replacements[3, 1] = emailValue; replacements[4, 0] = "FirstName"; replacements[4, 1] = firstName; replacements[5, 0] = "LastName"; replacements[5, 1] = lastName; // Set resolver resolver.SetNamedSourceData(replacements); // Email message EmailMessage emailMessage = new EmailMessage(); emailMessage.EmailFormat = EmailFormatEnum.Default; emailMessage.Recipients = ui.Email; // Send welcome message with username and password, with confirmation link, user must confirm registration if (requiresConfirmation) { template = EmailTemplateProvider.GetEmailTemplate("RegistrationConfirmation", currentSiteName); emailMessage.Subject = GetString("RegistrationForm.RegistrationConfirmationEmailSubject"); } // Send welcome message with username and password, with information that user must be approved by administrator else if (SendWelcomeEmail) { if (requiresAdminApprove) { template = EmailTemplateProvider.GetEmailTemplate("Membership.RegistrationWaitingForApproval", currentSiteName); emailMessage.Subject = GetString("RegistrationForm.RegistrationWaitingForApprovalSubject"); } // Send welcome message with username and password, user can logon directly else { template = EmailTemplateProvider.GetEmailTemplate("Membership.Registration", currentSiteName); emailMessage.Subject = GetString("RegistrationForm.RegistrationSubject"); } } if (template != null) { emailMessage.From = EmailHelper.GetSender(template, SettingsKeyInfoProvider.GetStringValue(currentSiteName + ".CMSNoreplyEmailAddress")); // Enable macro encoding for body resolver.Settings.EncodeResolvedValues = true; emailMessage.Body = resolver.ResolveMacros(template.TemplateText); // Disable macro encoding for plaintext body and subject resolver.Settings.EncodeResolvedValues = false; emailMessage.PlainTextBody = resolver.ResolveMacros(template.TemplatePlainText); emailMessage.Subject = resolver.ResolveMacros(EmailHelper.GetSubject(template, emailMessage.Subject)); emailMessage.CcRecipients = template.TemplateCc; emailMessage.BccRecipients = template.TemplateBcc; try { EmailHelper.ResolveMetaFileImages(emailMessage, template.TemplateID, EmailTemplateInfo.OBJECT_TYPE, ObjectAttachmentsCategories.TEMPLATE); // Send the e-mail immediately EmailSender.SendEmail(currentSiteName, emailMessage, true); } catch (Exception ex) { EventLogProvider.LogException("E", "RegistrationForm - SendEmail", ex); error = true; } } // If there was some error, user must be deleted if (error) { lblError.Visible = true; lblError.Text = GetString("RegistrationForm.UserWasNotCreated"); // Email was not send, user can't be approved - delete it UserInfoProvider.DeleteUser(ui); return; } #endregion #region "Administrator notification email" // Notify administrator if enabled and email confirmation is not required if (!requiresConfirmation && NotifyAdministrator && (FromAddress != String.Empty) && (ToAddress != String.Empty)) { EmailTemplateInfo mEmailTemplate = null; if (requiresAdminApprove) { mEmailTemplate = EmailTemplateProvider.GetEmailTemplate("Registration.Approve", currentSiteName); } else { mEmailTemplate = EmailTemplateProvider.GetEmailTemplate("Registration.New", currentSiteName); } if (mEmailTemplate == null) { EventLogProvider.LogEvent(EventType.ERROR, "RegistrationForm", "GetEmailTemplate", eventUrl: RequestContext.RawURL); } else { // E-mail template ok replacements = new string[4, 2]; replacements[0, 0] = "firstname"; replacements[0, 1] = ui.FirstName; replacements[1, 0] = "lastname"; replacements[1, 1] = ui.LastName; replacements[2, 0] = "email"; replacements[2, 1] = ui.Email; replacements[3, 0] = "username"; replacements[3, 1] = userName; // Set resolver resolver.SetNamedSourceData(replacements); // Enable macro encoding for body resolver.Settings.EncodeResolvedValues = true; EmailMessage message = new EmailMessage(); message.EmailFormat = EmailFormatEnum.Default; message.From = EmailHelper.GetSender(mEmailTemplate, FromAddress); message.Recipients = ToAddress; message.Body = resolver.ResolveMacros(mEmailTemplate.TemplateText); // Disable macro encoding for plaintext body and subject resolver.Settings.EncodeResolvedValues = false; message.Subject = resolver.ResolveMacros(EmailHelper.GetSubject(mEmailTemplate, GetString("RegistrationForm.EmailSubject"))); message.PlainTextBody = resolver.ResolveMacros(mEmailTemplate.TemplatePlainText); message.CcRecipients = mEmailTemplate.TemplateCc; message.BccRecipients = mEmailTemplate.TemplateBcc; try { // Attach template meta-files to e-mail EmailHelper.ResolveMetaFileImages(message, mEmailTemplate.TemplateID, EmailTemplateInfo.OBJECT_TYPE, ObjectAttachmentsCategories.TEMPLATE); EmailSender.SendEmail(currentSiteName, message); } catch { EventLogProvider.LogEvent(EventType.ERROR, "Membership", "RegistrationEmail"); } } } #endregion #region "Web analytics" // Track successful registration conversion if (TrackConversionName != String.Empty) { if (AnalyticsHelper.AnalyticsEnabled(currentSiteName) && AnalyticsHelper.TrackConversionsEnabled(currentSiteName) && !AnalyticsHelper.IsIPExcluded(currentSiteName, RequestContext.UserHostAddress)) { HitLogProvider.LogConversions(currentSiteName, LocalizationContext.PreferredCultureCode, TrackConversionName, 0, ConversionValue); } } // Log registered user if confirmation is not required if (!requiresConfirmation) { AnalyticsHelper.LogRegisteredUser(currentSiteName, ui); } #endregion #region "On-line marketing - activity" // Log registered user if confirmation is not required if (!requiresConfirmation) { Activity activity = new ActivityRegistration(ui, DocumentContext.CurrentDocument, AnalyticsContext.ActivityEnvironmentVariables); if (activity.Data != null) { activity.Data.ContactID = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui); activity.Log(); } // Log login activity if (ui.Enabled) { // Log activity int contactID = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui); Activity activityLogin = new ActivityUserLogin(contactID, ui, DocumentContext.CurrentDocument, AnalyticsContext.ActivityEnvironmentVariables); activityLogin.Log(); } } #endregion #region "Site and roles addition and authentication" string[] roleList = AssignRoles.Split(';'); foreach (string siteName in siteList) { // Add new user to the current site UserInfoProvider.AddUserToSite(ui.UserName, siteName); foreach (string roleName in roleList) { if (!String.IsNullOrEmpty(roleName)) { String sn = roleName.StartsWithCSafe(".") ? String.Empty : siteName; // Add user to desired roles if (RoleInfoProvider.RoleExists(roleName, sn)) { UserInfoProvider.AddUserToRole(ui.UserName, roleName, sn); } } } } if (ui.Enabled) { if (this.AutoLoginAfterRegistration) { Session["UserName"] = userName; Session["Password"] = password; Session["RememberMe"] = true; Session["RetryCount"] = null; if (this.Request.QueryString["ReturnURL"] != null) { var returnURL = this.Request.QueryString["ReturnURL"]; Session["ReturnURL"] = returnURL; } else if (!String.IsNullOrEmpty(this.RedirectToURL)) { var returnURL = this.Request.QueryString["ReturnURL"]; Session["ReturnURL"] = returnURL; } Response.Redirect("~/sso/ssohandler.aspx", true); } else if (!String.IsNullOrEmpty(this.LoginURL)) { Response.Redirect(string.Format(this.LoginURL, userName), true); } else if (!String.IsNullOrEmpty(this.RedirectToURL)) { Response.Redirect(this.RedirectToURL, true); } } #endregion lblError.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { UIContext.PropertyTab = PropertyTabEnum.General; // Register the scripts ScriptHelper.RegisterProgress(Page); ScriptHelper.RegisterTooltip(Page); ScriptHelper.RegisterDialogScript(this); // Set user control properties usrOwner = Page.LoadUserControl("~/CMSModules/Membership/FormControls/Users/selectuser.ascx") as FormEngineUserControl; if (usrOwner != null) { usrOwner.ID = "ctrlUsrOwner"; usrOwner.IsLiveSite = false; usrOwner.SetValue("ShowSiteFilter", false); usrOwner.StopProcessing = pnlUIOwner.IsHidden; plcUsrOwner.Controls.Add(usrOwner); } // Init strings pnlDesign.GroupingText = GetString("GeneralProperties.DesignGroup"); pnlCache.GroupingText = GetString("GeneralProperties.CacheGroup"); pnlOther.GroupingText = GetString("GeneralProperties.OtherGroup"); pnlAdvanced.GroupingText = GetString("GeneralProperties.AdvancedGroup"); pnlOwner.GroupingText = GetString("GeneralProperties.OwnerGroup"); // Advanced section mEditableContent = GetString("GeneralProperties.EditableContent"); mForums = GetString("PageProperties.AdHocForum"); mMessageBoards = GetString("PageProperties.MessageBoards"); lnkEditableContent.OnClientClick = "ShowEditableContent(); return false;"; lnkMessageBoards.OnClientClick = "ShowMessageBoards(); return false;"; lnkForums.OnClientClick = "ShowForums(); return false;"; imgEditableContent.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditableContent/editablecontent.png"); imgMessageBoards.ImageUrl = GetImageUrl("CMSModules/CMS_MessageBoards/module.png"); imgForums.ImageUrl = GetImageUrl("CMSModules/CMS_Forums/module.png"); // Get strings for radio buttons lblCacheMinutes.Text = GetString("GeneralProperties.cacheMinutes"); // Get strings for labels lblNameTitle.Text = GetString("GeneralProperties.Name"); lblNamePathTitle.Text = GetString("GeneralProperties.NamePath"); lblAliasPathTitle.Text = GetString("GeneralProperties.AliasPath"); lblTypeTitle.Text = GetString("GeneralProperties.Type"); lblNodeIDTitle.Text = GetString("GeneralProperties.NodeID"); lblLastModifiedByTitle.Text = GetString("GeneralProperties.LastModifiedBy"); lblLastModifiedTitle.Text = GetString("GeneralProperties.LastModified"); lblLiveURLTitle.Text = GetString("GeneralProperties.LiveURL"); lblPreviewURLTitle.Text = GetString("GeneralProperties.PreviewURL"); lblGUIDTitle.Text = GetString("GeneralProperties.GUID"); lblDocGUIDTitle.Text = GetString("GeneralProperties.DocumentGUID"); lblDocIDTitle.Text = GetString("GeneralProperties.DocumentID"); lblCultureTitle.Text = GetString("GeneralProperties.Culture"); lblCreatedByTitle.Text = GetString("GeneralProperties.CreatedBy"); lblCreatedTitle.Text = GetString("GeneralProperties.Created"); lblOwnerTitle.Text = GetString("GeneralProperties.Owner"); lblCssStyle.Text = GetString("PageProperties.CssStyle"); lblPublishedTitle.Text = GetString("PageProperties.Published"); chkCssStyle.Text = GetString("Metadata.Inherit"); pnlOnlineMarketing.GroupingText = GetString("general.onlinemarketing"); // Set default item value string defaultStyleSheet = "-1"; CssStylesheetInfo cssInfo = CMSContext.CurrentSiteStylesheet; // If current site default style sheet defined, choose it if (cssInfo != null) { defaultStyleSheet = "default"; } ctrlSiteSelectStyleSheet.CurrentSelector.SpecialFields = new string[,] { { GetString("general.defaultchoice"), defaultStyleSheet } }; ctrlSiteSelectStyleSheet.ReturnColumnName = "StyleSheetID"; ctrlSiteSelectStyleSheet.SiteId = CMSContext.CurrentSiteID; if ((CMSContext.CurrentSite != null) && (usrOwner != null)) { usrOwner.SetValue("SiteID", CMSContext.CurrentSite.SiteID); } int documentId = 0; string script = null; TreeNode node = Node; if (node != null) { // Create wireframe option if (node.NodeWireframeTemplateID <= 0) { mWireframe = GetString("Wireframe.Create"); string createUrl = URLHelper.ResolveUrl(String.Format("~/CMSModules/Content/CMSDesk/Properties/CreateWireframe.aspx?nodeid={0}&culture={1}", node.NodeID, node.DocumentCulture)); lnkWireframe.OnClientClick = "parent.location.replace('" + createUrl + "'); return false;"; imgWireframe.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/createwireframe.png"); } else { mWireframe = GetString("Wireframe.Remove"); imgWireframe.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/removewireframe.png"); lnkWireframe.OnClientClick = "return confirm('" + GetString("Wireframe.ConfirmRemove") + "')"; lnkWireframe.Click += new EventHandler(lnkWireframe_Click); } plcWireframe.Visible = PortalHelper.IsWireframingEnabled(CMSContext.CurrentSiteName); documentId = node.DocumentID; canEditOwner = (CMSContext.CurrentUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.ModifyPermissions) == AuthorizationResultEnum.Allowed); ctrlSiteSelectStyleSheet.AliasPath = node.NodeAliasPath; ReloadData(); // Check ad-hoc forum counts hasAdHocForum = (ModuleCommands.ForumsGetDocumentForumsCount(node.DocumentID) > 0); // Ad-Hoc message boards check hasAdHocBoard = (ModuleCommands.MessageBoardGetDocumentBoardsCount(node.DocumentID) > 0); script += "function ShowEditableContent() { modalDialog('" + ResolveUrl("Advanced/EditableContent/default.aspx") + "?nodeid=" + node.NodeID + "', 'EditableContent', 1015, 700); } \n"; } // Generate executive script if (hasAdHocBoard) { plcAdHocBoards.Visible = true; script += "function ShowMessageBoards() { modalDialog('" + ResolveUrl("~/CMSModules/MessageBoards/Content/Properties/default.aspx") + "?documentid=" + documentId + "', 'MessageBoards', 1020, 680); } \n"; } if (hasAdHocForum) { plcAdHocForums.Visible = true; script += "function ShowForums() { modalDialog('" + ResolveUrl("~/CMSModules/Forums/Content/Properties/default.aspx") + "?documentid=" + documentId + "', 'Forums', 1130, 680); } \n"; } ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ModalDialogsToAdvancedSection", ScriptHelper.GetScript(script)); // Reflect processing action pnlContent.Enabled = DocumentManager.AllowSave; if (chkCssStyle.Checked) { // Enable the edit button ctrlSiteSelectStyleSheet.ButtonEditEnabled = true; } }
/// <summary> /// Initializes controls on the page. /// </summary> protected void InitializeControls() { DataClassInfo classInfo = DataClassInfoProvider.GetDataClassInfo(ClassName); if (classInfo == null) { return; } // Set class names fldAddress1.ClassName = ClassName; fldBirthday.ClassName = ClassName; fldBusinessPhone.ClassName = ClassName; fldCity.ClassName = ClassName; fldCompanyName.ClassName = ClassName; fldCountry.ClassName = ClassName; fldEmail.ClassName = ClassName; fldFirstName.ClassName = ClassName; fldGender.ClassName = ClassName; fldJobTitle.ClassName = ClassName; fldLastName.ClassName = ClassName; fldMiddleName.ClassName = ClassName; fldMobilePhone.ClassName = ClassName; fldState.ClassName = ClassName; fldZip.ClassName = ClassName; if (!string.IsNullOrEmpty(classInfo.ClassContactMapping)) { // Prepare form info based on mapping data FormInfo mapInfo = new FormInfo(classInfo.ClassContactMapping); if (mapInfo.ItemsList.Count > 0) { FormEngineUserControl customControl = null; // Get all mapped fields var fields = mapInfo.GetFields(true, true); // Name property contains a column of contact object // and MappedToField property contains form field mapped to the contact column foreach (FormFieldInfo ffi in fields) { // Set mapping values... switch (ffi.Name.ToLowerCSafe()) { case "contactaddress1": // ... Address1 fldAddress1.Value = ffi.MappedToField; break; case "contactbirthday": // ... birthday fldBirthday.Value = ffi.MappedToField; break; case "contactbusinessphone": // ... business phone fldBusinessPhone.Value = ffi.MappedToField; break; case "contactcity": // ... city fldCity.Value = ffi.MappedToField; break; case "contactcountryid": // ... country fldCountry.Value = ffi.MappedToField; break; case "contactcompanyname": // ... company name fldCompanyName.Value = ffi.MappedToField; break; case "contactemail": // ... email fldEmail.Value = ffi.MappedToField; break; case "contactfirstname": // ... first name fldFirstName.Value = ffi.MappedToField; break; case "contactgender": // ... gender fldGender.Value = ffi.MappedToField; break; case "contactjobtitle": // ... job title fldJobTitle.Value = ffi.MappedToField; break; case "contactlastname": // ... last name fldLastName.Value = ffi.MappedToField; break; case "contactmiddlename": // ... middle name fldMiddleName.Value = ffi.MappedToField; break; case "contactmobilephone": // ... mobile phone fldMobilePhone.Value = ffi.MappedToField; break; case "contactstateid": // ... state fldState.Value = ffi.MappedToField; break; case "contactzip": // ... ZIP fldZip.Value = ffi.MappedToField; break; default: // ... contact's custom fields if (customControls != null) { customControl = (FormEngineUserControl)customControls[ffi.Name]; if (customControl != null) { customControl.Value = ffi.MappedToField; } } break; } } } } }
/// <summary> /// Configures selectors. /// </summary> private void SetupSelectors() { // Setup role selector selectRole.CurrentSelector.SelectionMode = SelectionModeEnum.MultipleButton; selectRole.CurrentSelector.OnItemsSelected += RolesSelector_OnItemsSelected; selectRole.CurrentSelector.ReturnColumnName = "RoleID"; selectRole.ShowSiteFilter = false; selectRole.CurrentSelector.ResourcePrefix = "addroles"; selectRole.IsLiveSite = false; selectRole.UseCodeNameForSelection = false; selectRole.GlobalRoles = false; // Setup user selector selectUser.SelectionMode = SelectionModeEnum.MultipleButton; selectUser.UniSelector.OnItemsSelected += UserSelector_OnItemsSelected; selectUser.UniSelector.ReturnColumnName = "UserID"; selectUser.UniSelector.DisplayNameFormat = "{%FullName%} ({%Email%})"; selectUser.UniSelector.AdditionalSearchColumns = "UserName, Email"; selectUser.ShowSiteFilter = false; selectUser.ResourcePrefix = "newsletteraddusers"; selectUser.IsLiveSite = false; // Setup subscriber selector selectSubscriber.UniSelector.SelectionMode = SelectionModeEnum.MultipleButton; selectSubscriber.UniSelector.OnItemsSelected += SubscriberSelector_OnItemsSelected; selectSubscriber.UniSelector.ReturnColumnName = "SubscriberID"; selectSubscriber.ShowSiteFilter = false; selectSubscriber.IsLiveSite = false; selectSubscriber.UniSelector.RemoveMultipleCommas = true; // Setup contact group and contact selectors if (ModuleEntryManager.IsModuleLoaded(ModuleName.ONLINEMARKETING) && LicenseHelper.CheckFeature(RequestContext.CurrentDomain, FeatureEnum.ContactManagement)) { plcSelectCG.Controls.Clear(); // Check read permission for contact groups if (MembershipContext.AuthenticatedUser.IsAuthorizedPerResource(ModuleName.CONTACTMANAGEMENT, "ReadContactGroups")) { // Load selector control and initialize it cgSelector = (FormEngineUserControl)Page.LoadUserControl("~/CMSModules/ContactManagement/FormControls/ContactGroupSelector.ascx"); if (cgSelector != null) { cgSelector.ID = "selectCG"; cgSelector.ShortID = "scg"; // Get inner uniselector control UniSelector selector = (UniSelector)cgSelector.GetValue("uniselector"); if (selector != null) { // Bind an event handler on 'items selected' event selector.OnItemsSelected += CGSelector_OnItemsSelected; selector.ResourcePrefix = "contactgroupsubscriber"; } // Insert selector to the header plcSelectCG.Controls.Add(cgSelector); } } // Check read permission for contacts if (MembershipContext.AuthenticatedUser.IsAuthorizedPerResource(ModuleName.CONTACTMANAGEMENT, "ReadContacts")) { // Load selector control and initialize it cSelector = (FormEngineUserControl)Page.LoadUserControl("~/CMSModules/ContactManagement/FormControls/ContactSelector.ascx"); if (cSelector != null) { cSelector.ID = "slContact"; cSelector.ShortID = "sc"; // Set where condition to filter contacts with email addresses cSelector.SetValue("wherecondition", "NOT (ContactEmail IS NULL OR ContactEmail LIKE '')"); // Set site ID cSelector.SetValue("siteid", SiteContext.CurrentSiteID); // Get inner uniselector control UniSelector selector = (UniSelector)cSelector.GetValue("uniselector"); if (selector != null) { // Bind an event handler on 'items selected' event selector.OnItemsSelected += ContactSelector_OnItemsSelected; selector.SelectionMode = SelectionModeEnum.MultipleButton; selector.ResourcePrefix = "contactsubscriber"; selector.DisplayNameFormat = "{%ContactFirstName%} {%ContactLastName%} ({%ContactEmail%})"; selector.AdditionalSearchColumns = "ContactFirstName,ContactMiddleName,ContactEmail"; } // Insert selector to the header plcSelectCG.Controls.Add(cSelector); } } } // Setup persona selectors if (ModuleEntryManager.IsModuleLoaded(ModuleName.PERSONAS) && LicenseHelper.CheckFeature(RequestContext.CurrentDomain, FeatureEnum.Personas)) { // Check read permission for contact groups if (MembershipContext.AuthenticatedUser.IsAuthorizedPerResource(ModuleName.PERSONAS, "Read")) { // Load selector control and initialize it personaSelector = (UniSelector)Page.LoadUserControl("~/CMSAdminControls/UI/Uniselector/Uniselector.ascx"); if (personaSelector != null) { personaSelector.ID = "personaSelector"; personaSelector.ShortID = "ps"; personaSelector.ObjectType = PredefinedObjectType.PERSONA; personaSelector.ReturnColumnName = "PersonaID"; personaSelector.WhereCondition = "PersonaSiteID = " + SiteContext.CurrentSiteID; personaSelector.SelectionMode = SelectionModeEnum.MultipleButton; personaSelector.DisplayNameFormat = "{%PersonaDisplayName%}"; personaSelector.ResourcePrefix = "personasubscriber"; personaSelector.IsLiveSite = false; // Bind an event handler on 'items selected' event personaSelector.OnItemsSelected += PersonaSelector_OnItemsSelected; // Add selector to the header plcSelectCG.Controls.Add(personaSelector); } } } // Initialize mass actions if (drpActions.Items.Count == 0) { drpActions.Items.Add(new ListItem(GetString("general.selectaction"), SELECT)); drpActions.Items.Add(new ListItem(GetString("newsletter.unsubscribelink"), UNSUBSCRIBE)); drpActions.Items.Add(new ListItem(GetString("newsletter.renewsubscription"), SUBSCRIBE)); drpActions.Items.Add(new ListItem(GetString("newsletter.approvesubscription"), APPROVE)); drpActions.Items.Add(new ListItem(GetString("newsletter.deletesubscription"), REMOVE)); } }
/// <summary> /// Creates new <see cref="FieldMacroRule"/> object based on inputs. /// </summary> private FieldMacroRule CreateMacroRule() { if (!IsValid()) { return(null); } MacroRuleTree main = null; FieldMacroRule fmr = null; MacroRuleInfo mri = MacroRuleInfoProvider.GetMacroRuleInfo(mSelectedRuleName); if (mri != null) { main = new MacroRuleTree(); MacroRuleTree childern = new MacroRuleTree() { RuleText = mri.MacroRuleText, RuleName = mri.MacroRuleName, RuleCondition = mri.MacroRuleCondition, Parent = main }; main.Children.Add(childern); foreach (string paramName in formProperties.Fields) { // Load value from the form control FormEngineUserControl ctrl = formProperties.FieldControls[paramName]; if (ctrl != null) { // Convert value to EN culture var dataType = ctrl.FieldInfo.DataType; var convertedValue = DataTypeManager.ConvertToSystemType(TypeEnum.Field, dataType, ctrl.Value); string value = ValidationHelper.GetString(convertedValue, "", CultureHelper.EnglishCulture); string displayName = ctrl.ValueDisplayName; if (String.IsNullOrEmpty(displayName)) { displayName = value; } MacroRuleParameter param = new MacroRuleParameter { Value = value, Text = displayName, ValueType = dataType }; childern.Parameters.Add(paramName, param); } } string macroRule = string.Format("Rule(\"{0}\", \"{1}\")", MacroElement.EscapeSpecialChars(main.GetCondition()), MacroElement.EscapeSpecialChars(main.GetXML())); if (!MacroSecurityProcessor.IsSimpleMacro(macroRule)) { // Sign complex macros macroRule = MacroSecurityProcessor.AddMacroSecurityParams(macroRule, MacroIdentityOption.FromUserInfo(MembershipContext.AuthenticatedUser)); } fmr = new FieldMacroRule(); fmr.MacroRule = string.Format("{{%{0}%}}", macroRule); fmr.ErrorMessage = txtErrorMsg.Text; } return(fmr); }
/// <summary> /// Validates whether the object property value is unique, and provides an optional error message. /// </summary> /// <typeparam name="T">The type of object to validate.</typeparam> /// <param name="control">The control that corresponds to the property to validate.</param> /// <param name="resourceKey">The resource key of the error message.</param> /// <param name="errorMessage">The error message.</param> private void Validate <T>(FormEngineUserControl control, string resourceKey, ref string errorMessage) where T : BaseInfo, new() { string uniqueText = control.Value as string; Validate <T>(control.FieldInfo.Name, uniqueText, resourceKey, ref errorMessage); }
/// <summary> /// OnPreRender event of the control. /// </summary> /// <param name="e">Event argument</param> protected override void OnPreRender(EventArgs e) { FormEngineUserControl plainCssPreviewControl = EditForm.FieldControls["StylesheetCodePreview"]; CMSRadioButtonList radios = ControlsHelper.GetChildControl <CMSRadioButtonList>(plainCssPreviewControl); // Bind click event handler to radio buttons in order to compile CSS client-side after Plain CSS preview button is clicked if (radios != null) { string radioScript = @" function CompileCssForPreview(obj) { if (obj.value == 'preview') { CompileCss(); } } "; ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "CompileCssForPreview", radioScript, true); foreach (ListItem li in radios.Items) { li.Attributes.Add("onclick", "CompileCssForPreview(this)"); } } // Register script for client-side compilation RegisterClientSideCompilationScript(); startWithFullScreen = ((previewState != 0) && editMenuElem.ObjectManager.IsObjectChecked()); RegisterInitScripts(pnlContainer.ClientID, editMenuElem.MenuPanel.ClientID, startWithFullScreen); if (Editor != null) { Editor.ShowBookmarks = true; Editor.RegularExpression = @"\s*/\*\s*#\s*([a-zA-Z_0-9-/\+\*.=~\!@\$%\^&\(\[\]\);:<>\?\s]*)\s*#\s*\*/"; Editor.EnablePositionMember = true; Editor.EnableSections = true; Editor.AutoSize = true; Editor.ParentElementID = ParentClientID; // Initialize selected line string script = @" $j(document).ready(function () { setTimeout(function() { var cmCSS = document.getElementById('" + Editor.EditorID + @"'); if(cmCSS != null) { cmCSS.setCursor(" + (QueryHelper.GetInteger("line", 0) - 1) + @"); } }, 50); });"; // Register client script ScriptHelper.RegisterStartupScript(EditForm, typeof(string), "JumpToLine", script, true); } // Correct offset for displaying preview if ((previewState != 0) && (CssStylesheetCode != null)) { CssStylesheetCode.SetValue("TopOffset", 40); } // Register loader script ScriptHelper.RegisterLoader(Page); base.OnPreRender(e); }
protected void Page_Load(object sender, EventArgs e) { // Check license if (DataHelper.GetNotEmpty(URLHelper.GetCurrentDomain(), "") != "") { LicenseHelper.CheckFeatureAndRedirect(URLHelper.GetCurrentDomain(), FeatureEnum.WebAnalytics); } // If deletion is in progress if (StatisticsInfoProvider.DataDeleterIsRunning) { timeRefresh.Enabled = true; ViewState["DeleterStarted"] = true; EnableControls(false); ReloadInfoPanel(); } // If deletion has just end - add close script else if (ValidationHelper.GetBoolean(ViewState["DeleterStarted"], false)) { ScriptHelper.RegisterStartupScript(this, typeof(string), "CloseScript", ScriptHelper.GetScript("window.close(); wopener.RefreshPage(); ")); } ucABTests = LoadControl("~/CMSModules/OnlineMarketing/FormControls/SelectABTest.ascx") as FormEngineUserControl; ucMVTests = LoadControl("~/CMSModules/OnlineMarketing/FormControls/SelectMVTest.ascx") as FormEngineUserControl; if (ucABTests != null) { ucABTests.ID = "abTestSelector"; pnlABTests.Controls.Add(ucABTests); } if (ucMVTests != null) { ucMVTests.ID = "mvtSelector"; pnlMVTests.Controls.Add(ucMVTests); } // Configure dynamic selectors if (!RequestHelper.IsPostBack() && (ucABTests != null) && (ucMVTests != null)) { string[,] fields = new string[2, 2]; fields[0, 0] = GetString("general.pleaseselect"); fields[0, 1] = "pleaseselect"; fields[1, 0] = "(" + GetString("general.all") + ")"; fields[1, 1] = ValidationHelper.GetString(ucABTests.GetValue("AllRecordValue"), String.Empty); ucABTests.SetValue("SpecialFields", fields); ucABTests.Value = "pleaseselect"; ucABTests.SetValue("AllowEmpty", false); ucABTests.SetValue("ReturnColumnName", "ABTestName"); ucMVTests.SetValue("SpecialFields", fields); ucMVTests.Value = "pleaseselect"; ucMVTests.SetValue("AllowEmpty", false); ucMVTests.SetValue("ReturnColumnName", "MVTestName"); usCampaigns.UniSelector.SpecialFields = fields; usCampaigns.Value = "pleaseselect"; } CurrentUserInfo user = CMSContext.CurrentUser; // Check permissions for CMS Desk -> Tools -> Web analytics tab if (!user.IsAuthorizedPerUIElement("CMS.Tools", "WebAnalytics")) { RedirectToCMSDeskUIElementAccessDenied("CMS.Tools", "WebAnalytics"); } // Check 'Read' permission if (!user.IsAuthorizedPerResource("CMS.WebAnalytics", "Read")) { RedirectToCMSDeskAccessDenied("CMS.WebAnalytics", "Read"); } string title = GetString("AnayticsManageData.ManageData"); this.Page.Title = title; this.CurrentMaster.Title.TitleText = title; this.CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Reporting/managedata.png"); // Confirmation message for deleting string deleteFromToMessage = ScriptHelper.GetString(GetString("webanal.deletefromtomsg")); deleteFromToMessage = deleteFromToMessage.Replace("##FROM##", "' + elemFromStr + '"); deleteFromToMessage = deleteFromToMessage.Replace("##TO##", "' + elemToStr + '"); string script = " var elemTo = document.getElementById('" + pickerTo.ClientID + "_txtDateTime'); " + " var elemFrom = document.getElementById('" + pickerFrom.ClientID + "_txtDateTime'); " + " var elemToStr = " + ScriptHelper.GetString(GetString("webanal.now")) + "; " + " var elemFromStr = " + ScriptHelper.GetString(GetString("webanal.beginning")) + "; " + " var deleteAll = 1; " + " if (elemTo.value != '') { deleteAll = 0; elemToStr = elemTo.value; }; " + " if (elemFrom.value != '') { deleteAll = 0; elemFromStr = elemFrom.value; }; " + " if (deleteAll == 1) { return confirm(" + ScriptHelper.GetString(GetString("webanal.deleteall")) + "); } " + " else { return confirm(" + deleteFromToMessage + "); }; "; btnDelete.OnClientClick = script + "; return false;"; statCodeName = QueryHelper.GetString("statCodeName", String.Empty); if (statCodeName == "abtest") { pnlABTestSelector.Visible = true; } if (statCodeName == "mvtest") { pnlMVTSelector.Visible = true; } if (statCodeName == "campaigns") { pnlCampaigns.Visible = true; } }
/// <summary> /// Performs extra validation for the value of the specified form control. /// </summary> /// <param name="formControl">Form control</param> /// <returns>Returns an error message if the field value is invalid, otherwise returns null.</returns> private string ValidateField(FormEngineUserControl formControl) { switch (formControl.FieldInfo.Name.ToLowerCSafe()) { case INDEX_NAME: { var value = ValidationHelper.GetString(formControl.Value, null); // Possible length of path - already taken, +1 because in MAX_INDEX_PATH is count code name of length 1 var indexPath = Path.Combine(SystemContext.WebApplicationPhysicalPath, SearchHelper.SearchPath); var maxLength = SearchHelper.MAX_INDEX_PATH - indexPath.Length + 1; if (value.Length > maxLength) { return GetString("srch.codenameexceeded"); } break; } } return null; }
/// <summary> /// Detects stylesheet language change and converts CSS code according to the former and the latter language. /// </summary> /// <param name="originalLanguage">The previous language</param> /// <param name="newLanguage">The new language</param> private void ChangeStylesheetLanguage(string originalLanguage, string newLanguage) { // Check whether the stylesheet language has actually changed. if (!String.IsNullOrEmpty(newLanguage) && !String.IsNullOrEmpty(originalLanguage) && !originalLanguage.EqualsCSafe(newLanguage, true)) { string code = String.Empty; string output = String.Empty; string errorMessage = String.Empty; if (newLanguage.EqualsCSafe(CssStylesheetInfo.PLAIN_CSS, true)) { // Changed from any CSS preprocessor language to plain CSS. code = ValidationHelper.GetString(EditForm.GetFieldValue("StylesheetDynamicCode"), String.Empty); // Try to parse the code against the original preprocessor language. errorMessage = CSSStylesheetNewControlExtender.ProcessCss(code, originalLanguage, out output, hidCompiledCss); } else if (originalLanguage.EqualsCSafe(CssStylesheetInfo.PLAIN_CSS, true)) { // Changed from Plain CSS to some CSS preprocessor language. code = ValidationHelper.GetString(EditForm.GetFieldValue("StylesheetText"), String.Empty); // Try to parse the code against the new preprocessor language. errorMessage = CSSStylesheetNewControlExtender.ProcessCss(code, newLanguage, out output, hidCompiledCss); } else { // Changed from CSS preprocessor language to another one. code = ValidationHelper.GetString(EditForm.GetFieldValue("StylesheetDynamicCode"), String.Empty); // Try to parse the code against the original preprocessor language. errorMessage = CSSStylesheetNewControlExtender.ProcessCss(code, originalLanguage, out output, hidCompiledCss); } if (String.IsNullOrEmpty(errorMessage)) { // Success -> Set correct values to form controls. if (newLanguage.EqualsCSafe(CssStylesheetInfo.PLAIN_CSS, true)) { // output -> StylesheetText EditForm.FieldControls["StylesheetText"].Value = output; } else if (originalLanguage.EqualsCSafe(CssStylesheetInfo.PLAIN_CSS, true)) { // Copy the original code to StylesheetDynamicCode field. EditForm.FieldControls["StylesheetDynamicCode"].Value = code; } else { // Copy the original code to StylesheetDynamicCode field. EditForm.FieldControls["StylesheetDynamicCode"].Value = output; } // Prevent to additional change processing. languageChangeProceeded = true; } else { // Failure -> Show error message EditForm.AddError(errorMessage); // Prevent further processing EditForm.StopProcessing = true; // Set drop-down list to its former value FormEngineUserControl langControl = EditForm.FieldControls["StylesheetDynamicLanguage"]; if (langControl != null) { langControl.Value = originalLanguage; CssStylesheetInfo cssInfo = EditForm.EditedObject as CssStylesheetInfo; if (cssInfo != null) { cssInfo.StylesheetDynamicLanguage = originalLanguage; } } } } }
private void LoadProperty(FormFieldInfo ffi, FormFieldPropertyEnum property, FormEngineUserControl control, MessagesPlaceHolder msgPlaceHolder) { if (control != null) { bool isMacro = ffi.IsMacro(property); control.Visible = !isMacro; if (!isMacro) { control.Value = ffi.GetPropertyValue(property); } else { msgPlaceHolder.ShowInformation(GetString("FormBuilder.PropertyIsMacro")); } } }
/// <summary> /// Init event handler /// </summary> protected override void OnInit(EventArgs e) { base.OnInit(e); ElementID = QueryHelper.GetString("elementid", ""); if (!RequestHelper.IsPostBack()) { // Load the initialization script which pulls the value from the opener ScriptHelper.RegisterStartupScript(this, typeof(string), "LoadValue", ScriptHelper.GetScript(String.Format( "document.getElementById('{0}').value = wopener.document.getElementById('{1}').value; {2}", hdnValue.ClientID, ElementID, ClientScript.GetPostBackEventReference(btnLoad, null) ))); } else { // Load the form control string formControl = QueryHelper.GetString("formcontrol", ""); // Load the form control var ctrl = FormControlsHelper.LoadFormControl(Page, formControl, ""); if (ctrl != null) { plcControl.Controls.Add(ctrl); } FormControl = ctrl; } }
/// <summary> /// Displays contact relation which has more than 1 role. /// </summary> private int DisplayRoleCollisions(int contactID, DataSet relations) { DataRow[] drs = relations.Tables[0].Select("ContactID = " + contactID + " AND ContactRoleID > 0", "ContactRoleID"); // Contact is specified more than once if ((drs != null) && (drs.Length > 1)) { // Find out if contact roles are different ArrayList roleIDs = new ArrayList(); int id; roleIDs.Add(ValidationHelper.GetInteger(drs[0]["ContactRoleID"], 0)); roles.Add(drs[0]["ContactID"], drs[0]["ContactRoleID"]); foreach (DataRow dr in drs) { id = ValidationHelper.GetInteger(dr["ContactRoleID"], 0); if (!roleIDs.Contains(id)) { roleIDs.Add(id); } } // Display relation only for contacts with more roles if (roleIDs.Count > 1) { // Display table first part Literal ltl = new Literal(); string contactName = drs[0]["ContactFirstName"] + " " + drs[0]["ContactMiddleName"]; contactName = contactName.Trim() + " " + drs[0]["ContactLastName"]; ltl.Text = "<tr class=\"CollisionRow\"><td>" + contactName.Trim() + "</td>"; ltl.Text += "<td class=\"ComboBoxColumn\"><div class=\"ComboBox\">"; plcAccountContact.Controls.Add(ltl); // Display role selector FormEngineUserControl roleSelector = Page.LoadControl("~/CMSModules/ContactManagement/FormControls/ContactRoleSelector.ascx") as FormEngineUserControl; roleSelector.SetValue("siteid", parentAccount.AccountSiteID); plcAccountContact.Controls.Add(roleSelector); roleControls.Add(drs[0]["ContactID"], roleSelector); // Display table middle part Literal ltlMiddle = new Literal(); ltlMiddle.Text = "</div></td><td>"; plcAccountContact.Controls.Add(ltlMiddle); // Display icon with tooltip Image imgTooltip = new Image(); AccountContactTooltip(imgTooltip, roleIDs); imgTooltip.ImageUrl = GetImageUrl("CMSModules/CMS_ContactManagement/collision.png"); imgTooltip.Style.Add("cursor", "help"); ScriptHelper.AppendTooltip(imgTooltip, imgTooltip.ToolTip, "help"); plcAccountContact.Controls.Add(imgTooltip); // Display table last part Literal ltlLast = new Literal(); ltlLast.Text = "</td></tr>"; plcAccountContact.Controls.Add(ltlLast); return(1); } } return(0); }
/// <summary> /// OK click handler (Proceed registration). /// </summary> private void btnRegister_Click(object sender, EventArgs e) { if ((PageManager.ViewMode == ViewModeEnum.Design) || (HideOnCurrentPage) || (!IsVisible)) { // Do not process return; } // Ban IP addresses which are blocked for registration if (!BannedIPInfoProvider.IsAllowed(CurrentSiteName, BanControlEnum.Registration)) { ShowError(GetString("banip.ipisbannedregistration")); return; } // Check if captcha is required and verify captcha text if (DisplayCaptcha && !captchaElem.IsValid()) { // Display error message if captcha text is not valid ShowError(GetString("Webparts_Membership_RegistrationForm.captchaError")); return; } string userName = String.Empty; string nickName = String.Empty; string emailValue = String.Empty; // Check duplicate user // 1. Find appropriate control and get its value (i.e. user name) // 2. Try to find user info FormEngineUserControl txtUserName = formUser.FieldControls["UserName"]; if (txtUserName != null) { userName = ValidationHelper.GetString(txtUserName.Value, String.Empty); } FormEngineUserControl txtEmail = formUser.FieldControls["Email"]; if (txtEmail != null) { emailValue = ValidationHelper.GetString(txtEmail.Value, String.Empty); } // If user name and e-mail aren't filled stop processing and display error. if (string.IsNullOrEmpty(userName)) { userName = emailValue; if (String.IsNullOrEmpty(emailValue)) { formUser.StopProcessing = true; formUser.DisplayErrorLabel("Email", GetString("customregistrationform.usernameandemail")); return; } // Set username after data retrieval in case the username control is hidden (visible field hidden in custom layout) formUser.OnBeforeSave += (s, args) => formUser.Data.SetValue("UserName", userName); } FormEngineUserControl txtNickName = formUser.FieldControls["UserNickName"]; if (txtNickName != null) { nickName = ValidationHelper.GetString(txtNickName.Value, String.Empty); } // Test if "global" or "site" user exists. SiteInfo si = SiteContext.CurrentSite; UserInfo siteui = UserInfoProvider.GetUserInfo(UserInfoProvider.EnsureSitePrefixUserName(userName, si)); if ((UserInfoProvider.GetUserInfo(userName) != null) || (siteui != null)) { ShowError(GetString("Webparts_Membership_RegistrationForm.UserAlreadyExists").Replace("%%name%%", HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(userName, true)))); return; } // Check for reserved user names like administrator, sysadmin, ... if (UserInfoProvider.NameIsReserved(CurrentSiteName, userName)) { ShowError(GetString("Webparts_Membership_RegistrationForm.UserNameReserved").Replace("%%name%%", HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(userName, true)))); return; } if (UserInfoProvider.NameIsReserved(CurrentSiteName, nickName)) { ShowError(GetString("Webparts_Membership_RegistrationForm.UserNameReserved").Replace("%%name%%", HTMLHelper.HTMLEncode(nickName))); return; } // Check limitations for site members if (!UserInfoProvider.LicenseVersionCheck(RequestContext.CurrentDomain, FeatureEnum.SiteMembers, ObjectActionEnum.Insert, false)) { ShowError(GetString("License.MaxItemsReachedSiteMember")); return; } // Check whether email is unique if it is required if (!UserInfoProvider.IsEmailUnique(emailValue, SiteList, 0)) { formUser.DisplayErrorLabel("Email", GetString("UserInfo.EmailAlreadyExist")); return; } formUser.SaveData(null, String.IsNullOrEmpty(DisplayMessage.Trim())); }
private void ReloadData() { if (node != null) { // Check read permissions if (CMSContext.CurrentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Read) == AuthorizationResultEnum.Denied) { RedirectToAccessDenied(String.Format(GetString("cmsdesk.notauthorizedtoreaddocument"), node.NodeAliasPath)); } else { // Log activities checkboxes if (!RequestHelper.IsPostBack()) { bool? logVisit = node.DocumentLogVisitActivity; chkLogPageVisit.Checked = (logVisit == true); chkPageVisitInherit.Checked = (logVisit == null); chkLogPageVisit.Enabled = !chkPageVisitInherit.Checked; if (logVisit == null) { chkPageVisitInherit_CheckedChanged(null, EventArgs.Empty); } } // Show document group owner selector if (ModuleEntry.IsModuleLoaded(ModuleEntry.COMMUNITY) && canEditOwner && LicenseHelper.CheckFeature(URLHelper.GetCurrentDomain(), FeatureEnum.Groups)) { plcOwnerGroup.Controls.Clear(); // Initialize table TableRow rowOwner = new TableRow(); TableCell cellTitle = new TableCell(); TableCell cellSelector = new TableCell(); // Initialize caption LocalizedLabel lblOwnerGroup = new LocalizedLabel(); lblOwnerGroup.EnableViewState = false; lblOwnerGroup.ResourceString = "community.group.documentowner"; lblOwnerGroup.ID = "lblOwnerGroup"; cellTitle.Controls.Add(lblOwnerGroup); // Initialize selector fcDocumentGroupSelector = (FormEngineUserControl)Page.LoadControl("~/CMSAdminControls/UI/Selectors/DocumentGroupSelector.ascx"); fcDocumentGroupSelector.ID = "fcDocumentGroupSelector"; fcDocumentGroupSelector.StopProcessing = this.pnlUIOwner.IsHidden; cellSelector.Controls.Add(fcDocumentGroupSelector); fcDocumentGroupSelector.Value = ValidationHelper.GetInteger(node.GetValue("NodeGroupID"), 0); fcDocumentGroupSelector.SetValue("siteid", CMSContext.CurrentSiteID); fcDocumentGroupSelector.SetValue("nodeid", nodeId); // Add controls to containers rowOwner.Cells.Add(cellTitle); rowOwner.Cells.Add(cellSelector); plcOwnerGroup.Controls.Add(rowOwner); plcOwnerGroup.Visible = true; } // Check modify permissions if (CMSContext.CurrentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied) { // disable form editing DisableFormEditing(); // show access denied message lblInfo.Text = String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), node.NodeAliasPath); lblInfo.Visible = true; } // Show owner editing only when authorized to change the permissions if (canEditOwner) { lblOwner.Visible = false; usrOwner.Visible = true; usrOwner.SetValue("AdditionalUsers", new int[] { node.NodeOwner }); } else { usrOwner.Visible = false; } if (!RequestHelper.IsPostBack()) { if (canEditOwner) { usrOwner.Value = node.GetValue("NodeOwner"); } // Search chkExcludeFromSearch.Checked = node.DocumentSearchExcluded; } // Load the data lblName.Text = HttpUtility.HtmlEncode(node.DocumentName); lblNamePath.Text = HttpUtility.HtmlEncode(Convert.ToString(node.GetValue("DocumentNamePath"))); lblAliasPath.Text = Convert.ToString(node.NodeAliasPath); string typeName = DataClassInfoProvider.GetDataClass(node.NodeClassName).ClassDisplayName; lblType.Text = HttpUtility.HtmlEncode(ResHelper.LocalizeString(typeName)); lblNodeID.Text = Convert.ToString(node.NodeID); // Modifier SetUserLabel(lblLastModifiedBy, "DocumentModifiedByUserId"); // Get modified time TimeZoneInfo usedTimeZone = null; DateTime lastModified = ValidationHelper.GetDateTime(node.GetValue("DocumentModifiedWhen"), DateTimeHelper.ZERO_TIME); lblLastModified.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(lastModified, CMSContext.CurrentUser, CMSContext.CurrentSite, out usedTimeZone); ScriptHelper.AppendTooltip(lblLastModified, TimeZoneHelper.GetGMTLongStringOffset(usedTimeZone), "help"); if (!canEditOwner) { // Owner SetUserLabel(lblOwner, "NodeOwner"); } // Creator SetUserLabel(lblCreatedBy, "DocumentCreatedByUserId"); DateTime createdWhen = ValidationHelper.GetDateTime(node.GetValue("DocumentCreatedWhen"), DateTimeHelper.ZERO_TIME); lblCreated.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(createdWhen, CMSContext.CurrentUser, CMSContext.CurrentSite, out usedTimeZone); ScriptHelper.AppendTooltip(lblCreated, TimeZoneHelper.GetGMTLongStringOffset(usedTimeZone), "help"); // URL string liveUrl = node.IsLink ? CMSContext.GetUrl(node.NodeAliasPath, null) : CMSContext.GetUrl(node.NodeAliasPath, node.DocumentUrlPath); lnkLiveURL.Text = ResolveUrl(liveUrl); lnkLiveURL.NavigateUrl = liveUrl; bool isRoot = (node.NodeClassName.ToLower() == "cms.root"); // Preview URL if (!isRoot) { plcPreview.Visible = true; string path = canEdit ? "/CMSModules/CMS_Content/Properties/resetlink.png" : "/CMSModules/CMS_Content/Properties/resetlinkdisabled.png"; btnResetPreviewGuid.ImageUrl = GetImageUrl(path); btnResetPreviewGuid.ToolTip = GetString("GeneralProperties.InvalidatePreviewURL"); btnResetPreviewGuid.ImageAlign = ImageAlign.AbsBottom; btnResetPreviewGuid.Click += new ImageClickEventHandler(btnResetPreviewGuid_Click); btnResetPreviewGuid.OnClientClick = "if(!confirm('" + GetString("GeneralProperties.GeneratePreviewURLConf") + "')){return false;}"; InitPreviewUrl(); } lblGUID.Text = Convert.ToString(node.NodeGUID); lblDocGUID.Text = (node.DocumentGUID == Guid.Empty) ? ResHelper.Dash : node.DocumentGUID.ToString(); lblDocID.Text = Convert.ToString(node.DocumentID); // Culture CultureInfo ci = CultureInfoProvider.GetCultureInfo(node.DocumentCulture); lblCulture.Text = ((ci != null) ? ResHelper.LocalizeString(ci.CultureName) : node.DocumentCulture); lblPublished.Text = (node.IsPublished ? "<span class=\"DocumentPublishedYes\">" + GetString("General.Yes") + "</span>" : "<span class=\"DocumentPublishedNo\">" + GetString("General.No") + "</span>"); if (!RequestHelper.IsPostBack()) { // Init radio buttons for cache settings if (isRoot) { radInherit.Visible = false; chkCssStyle.Visible = false; switch (node.NodeCacheMinutes) { case -1: // Cache is off radNo.Checked = true; radYes.Checked = false; radInherit.Checked = false; txtCacheMinutes.Text = ""; break; case 0: // Cache is off radNo.Checked = true; radYes.Checked = false; radInherit.Checked = false; txtCacheMinutes.Text = ""; break; default: // Cache is enabled radNo.Checked = false; radYes.Checked = true; radInherit.Checked = false; txtCacheMinutes.Text = node.NodeCacheMinutes.ToString(); break; } } else { switch (node.NodeCacheMinutes) { case -1: // Cache setting is inherited radNo.Checked = false; radYes.Checked = false; radInherit.Checked = true; txtCacheMinutes.Text = ""; break; case 0: // Cache is off radNo.Checked = true; radYes.Checked = false; radInherit.Checked = false; txtCacheMinutes.Text = ""; break; default: // Cache is enabled radNo.Checked = false; radYes.Checked = true; radInherit.Checked = false; txtCacheMinutes.Text = node.NodeCacheMinutes.ToString(); break; } } if (!radYes.Checked) { txtCacheMinutes.Enabled = false; } } if (!RequestHelper.IsPostBack()) { if (node.GetValue("DocumentStylesheetID") == null) { // If default site not exist edit is set to -1 - disabled if (CMSContext.CurrentSiteStylesheet != null) { ctrlSiteSelectStyleSheet.Value = "default"; } else { ctrlSiteSelectStyleSheet.Value = -1; } } else { // If stylesheet is inherited from parent document if (ValidationHelper.GetInteger(node.GetValue("DocumentStylesheetID"), 0) == -1) { if (!isRoot) { chkCssStyle.Checked = true; // Get parent stylesheet string value = PageInfoProvider.GetParentProperty(CMSContext.CurrentSite.SiteID, node.NodeAliasPath, "(DocumentStylesheetID <> -1 OR DocumentStylesheetID IS NULL) AND DocumentCulture = N'" + SqlHelperClass.GetSafeQueryString(node.DocumentCulture, false) + "'", "DocumentStylesheetID"); if (String.IsNullOrEmpty(value)) { // If default site stylesheet not exist edit is set to -1 - disabled if (CMSContext.CurrentSiteStylesheet != null) { ctrlSiteSelectStyleSheet.Value = "default"; } else { ctrlSiteSelectStyleSheet.Value = -1; } } else { // Set parent stylesheet to current document ctrlSiteSelectStyleSheet.Value = value; } } } else { ctrlSiteSelectStyleSheet.Value = node.GetValue("DocumentStylesheetID"); } } } // Disable new button if document inherit stylesheet if (!isRoot && chkCssStyle.Checked) { ctrlSiteSelectStyleSheet.Enabled = false; ctrlSiteSelectStyleSheet.ButtonNew.Enabled = false; } // Initialize Rating control RefreshCntRatingResult(); double rating = 0.0f; if (node.DocumentRatings > 0) { rating = node.DocumentRatingValue / node.DocumentRatings; } ratingControl.MaxRating = 10; ratingControl.CurrentRating = rating; ratingControl.Visible = true; ratingControl.Enabled = false; // Initialize Reset button for rating btnResetRating.Text = GetString("general.reset"); btnResetRating.OnClientClick = "if (!confirm(" + ScriptHelper.GetString(GetString("GeneralProperties.ResetRatingConfirmation")) + ")) return false;"; object[] param = new object[1]; param[0] = node.DocumentID; // Check ad-hoc forum counts hasAdHocForum = (ModuleCommands.ForumsGetDocumentForumsCount(node.DocumentID) > 0); // Ad-Hoc message boards check hasAdHocBoard = (ModuleCommands.MessageBoardGetDocumentBoardsCount(node.DocumentID) > 0); plcAdHocForums.Visible = hasAdHocForum; plcAdHocBoards.Visible = hasAdHocBoard; } } else { btnResetRating.Visible = false; } }
/// <summary> /// Returns contact mapping definition. /// </summary> protected string GetMappingDefinition() { StringBuilder sb = new StringBuilder(); string pattern = "<field column=\"{0}\" mappedtofield=\"{1}\" />"; // Get mapped fields... if (!string.IsNullOrEmpty(fldAddress1.Value.ToString())) { // ... address1 sb.AppendFormat(pattern, "ContactAddress1", fldAddress1.Value.ToString()); } if (!string.IsNullOrEmpty(fldBirthday.Value.ToString())) { // ... birthday sb.AppendFormat(pattern, "ContactBirthday", fldBirthday.Value.ToString()); } if (!string.IsNullOrEmpty(fldBusinessPhone.Value.ToString())) { // ... business phone sb.AppendFormat(pattern, "ContactBusinessPhone", fldBusinessPhone.Value.ToString()); } if (!string.IsNullOrEmpty(fldCity.Value.ToString())) { // ... city sb.AppendFormat(pattern, "ContactCity", fldCity.Value.ToString()); } if (!string.IsNullOrEmpty(fldCountry.Value.ToString())) { // ... country sb.AppendFormat(pattern, "ContactCountryID", fldCountry.Value.ToString()); } if (!string.IsNullOrEmpty(fldCompanyName.Value.ToString())) { // ... company name sb.AppendFormat(pattern, "ContactCompanyName", fldCompanyName.Value.ToString()); } if (!string.IsNullOrEmpty(fldEmail.Value.ToString())) { // ... email sb.AppendFormat(pattern, "ContactEmail", fldEmail.Value.ToString()); } if (!string.IsNullOrEmpty(fldFirstName.Value.ToString())) { // ... first name sb.AppendFormat(pattern, "ContactFirstName", fldFirstName.Value.ToString()); } if (!string.IsNullOrEmpty(fldGender.Value.ToString())) { // ... gender sb.AppendFormat(pattern, "ContactGender", fldGender.Value.ToString()); } if (!string.IsNullOrEmpty(fldJobTitle.Value.ToString())) { // ... job title sb.AppendFormat(pattern, "ContactJobTitle", fldJobTitle.Value.ToString()); } if (!string.IsNullOrEmpty(fldLastName.Value.ToString())) { // ... last name sb.AppendFormat(pattern, "ContactLastName", fldLastName.Value.ToString()); } if (!string.IsNullOrEmpty(fldMiddleName.Value.ToString())) { // ... middle name sb.AppendFormat(pattern, "ContactMiddleName", fldMiddleName.Value.ToString()); } if (!string.IsNullOrEmpty(fldMobilePhone.Value.ToString())) { // ... mobile phone sb.AppendFormat(pattern, "ContactMobilePhone", fldMobilePhone.Value.ToString()); } if (!string.IsNullOrEmpty(fldState.Value.ToString())) { // ... state sb.AppendFormat(pattern, "ContactStateID", fldState.Value.ToString()); } if (!string.IsNullOrEmpty(fldZip.Value.ToString())) { // ... ZIP sb.AppendFormat(pattern, "ContactZIP", fldZip.Value.ToString()); } if (customControls != null) { // ... contact's custom fields FormEngineUserControl control = null; foreach (DictionaryEntry entry in customControls) { control = (FormEngineUserControl)entry.Value; if ((control != null) && (!string.IsNullOrEmpty(control.Value.ToString()))) { sb.AppendFormat(pattern, entry.Key, control.Value.ToString()); } } } if (sb.Length > 0) { // Surround the mapping definition with 'form' element sb.Insert(0, "<form>"); sb.Append("</form>"); } return(sb.ToString()); }
private void SaveProperty(FormFieldInfo ffi, FormFieldPropertyEnum property, FormEngineUserControl control) { if (control.Visible) { if (control is LocalizableFormEngineUserControl) { // Save translation ((LocalizableFormEngineUserControl)control).Save(); } ffi.SetPropertyValue(property, ValidationHelper.GetString(control.Value, String.Empty)); } }
/// <summary> /// OnInit event. /// </summary> protected override void OnInit(EventArgs e) { int querySiteID = QueryHelper.GetInteger("siteid", 0); // Do not allow other than current site ID out of global scope. var uiContext = UIContextHelper.GetUIContext(this); SiteID = ApplicationUIHelper.IsInGlobalApplicationScope(uiContext.UIElement) ? querySiteID : SiteContext.CurrentSiteID; if (ModuleEntryManager.IsModuleLoaded(ModuleName.COMMUNITY)) { Control ctrl = LoadUserControl(GROUP_SELECTOR_PATH); if (ctrl != null) { mSelectInGroups = ctrl as FormEngineUserControl; ctrl.ID = "selGroups"; ctrl = LoadUserControl(GROUP_SELECTOR_PATH); mSelectNotInGroups = ctrl as FormEngineUserControl; ctrl.ID = "selNoGroups"; plcGroups.Visible = true; plcSelectInGroups.Controls.Add(mSelectInGroups); plcSelectNotInGroups.Controls.Add(mSelectNotInGroups); mSelectNotInGroups.SetValue("UseFriendlyMode", true); mSelectInGroups.IsLiveSite = false; mSelectInGroups.SetValue("UseFriendlyMode", true); mSelectNotInGroups.IsLiveSite = false; } } if (DisplayScore && SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSEnableOnlineMarketing")) { Control ctrl = LoadUserControl(SCORE_SELECTOR_PATH); if (ctrl != null) { ctrl.ID = "selectScore"; mScoreSelector = ctrl as FormEngineUserControl; if (mScoreSelector != null) { plcUpdateContent.Controls.Add(mScoreSelector); mScoreSelector.SetValue("AllowAll", false); mScoreSelector.SetValue("AllowEmpty", true); } } } else { plcScore.Visible = false; lblScore.AssociatedControlID = null; } InitializeDropDownLists(); base.OnInit(e); plcDisplayAnonymous.Visible = ContactManagementPermission && SessionManager.StoreOnlineUsersInDatabase && EnableDisplayingGuests; if (!RequestHelper.IsPostBack()) { chkDisplayAnonymous.Checked = DisplayGuestsByDefault; } siteSelector.DropDownSingleSelect.AutoPostBack = true; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // Show panel with message how to enable indexing ucDisabledModule.SettingsKeys = "CMSSearchIndexingEnabled"; ucDisabledModule.InfoText = GetString("srch.searchdisabledinfo"); // Module forums is not available if (!(ModuleManager.IsModuleLoaded(ModuleName.FORUMS))) { return; } selForum = LoadUserControl("~/CMSModules/Forums/FormControls/ForumSelector.ascx") as FormEngineUserControl; if (selForum != null) { // Set default vaules for forum selector selForum.IsLiveSite = false; selForum.SetValue("selectionmode", SelectionModeEnum.MultipleTextBox); selForum.SetValue("DisplayAdHocOption", false); plcForumSelector.Controls.Add(selForum); } // Set events and default values for site selector selSite.AllowAll = false; selSite.UseCodeNameForSelection = true; selSite.DropDownSingleSelect.AutoPostBack = true; selSite.UniSelector.OnSelectionChanged += UniSelector_OnSelectionChanged; LoadControls(); if (ItemType == SearchIndexSettingsInfo.TYPE_ALLOWED) { selSite.AllowAll = true; } var siteIDs = SearchIndexSiteInfoProvider.GetIndexSiteBindings(ItemID).Column("IndexSiteID").Select(X => X.IndexSiteID.ToString()).ToList(); if (siteIDs.Count > 0) { var siteWhere = SqlHelper.GetWhereCondition<string>("SiteID", siteIDs, false); // Preselect current site if it is assigned to index var sisiId = QueryHelper.GetGuid("guid", Guid.Empty); var isNew = sisiId == Guid.Empty; if (!RequestHelper.IsPostBack() && isNew && siteIDs.Contains(SiteContext.CurrentSiteID.ToString())) { selSite.Value = SiteContext.CurrentSiteName; } selSite.UniSelector.WhereCondition = siteWhere; } else { selSite.Enabled = false; selForum.Enabled = false; btnOk.Enabled = false; ShowError(GetString("srch.index.nositeselected")); } selSite.Reload(true); selForum.SetValue("SiteName", Convert.ToString(selSite.Value)); // Init controls if (!RequestHelper.IsPostBack()) { SetControlsStatus(); } }
/// <summary> /// Loads group selector control to the page. /// </summary> /// <param name="siteId">Site ID</param> /// <returns>Returns true if site contains group and group selector was loaded</returns> private bool AddGroupSelector(int siteId) { SiteInfo si = SiteInfoProvider.GetSiteInfo(siteId); if ((si != null) && (ModuleCommands.CommunitySiteHasGroup(si.SiteID))) { groupsControl = Page.LoadUserControl("~/CMSModules/Groups/FormControls/MultipleGroupSelector.ascx") as FormEngineUserControl; if (groupsControl != null) { groupsControl.FormControlParameter = siteId; groupsControl.IsLiveSite = false; groupsControl.ID = "selectgroups"; groupsControl.ShortID = "sg"; groupsControl.SetValue("ReturnColumnName", "GroupID"); plcGroupSelector.Controls.Add(groupsControl); return true; } } return false; }
protected void Page_Load(object sender, EventArgs e) { // Show panel with message how to enable indexing ucDisabledModule.SettingsKeys = "CMSSearchIndexingEnabled"; ucDisabledModule.InfoText = GetString("srch.searchdisabledinfo"); // Module forums is not available if (!(ModuleEntry.IsModuleRegistered(ModuleEntry.FORUMS) && ModuleEntry.IsModuleLoaded(ModuleEntry.FORUMS))) { return; } selForum = this.LoadUserControl("~/CMSModules/Forums/FormControls/ForumSelector.ascx") as FormEngineUserControl; if (selForum != null) { selForum.IsLiveSite = false; plcForumSelector.Controls.Add(selForum); } selSite.AllowAll = false; selSite.UseCodeNameForSelection = true; string siteWhere = String.Empty; DataSet ds = SearchIndexSiteInfoProvider.GetIndexSites("SiteID", "IndexID = " + ItemID, null, 0); if (!DataHelper.DataSourceIsEmpty(ds)) { foreach (DataRow dr in ds.Tables[0].Rows) { siteWhere += dr["SiteID"] + ","; } siteWhere = "," + siteWhere; // Preselect current site if it is assigned to index if (!RequestHelper.IsPostBack() && siteWhere.Contains("," + CMSContext.CurrentSiteID + ",")) { selSite.Value = CMSContext.CurrentSiteName; } siteWhere = siteWhere.Trim(','); siteWhere = "SiteID IN (" + siteWhere + ")"; selSite.UniSelector.WhereCondition = siteWhere; } else { selSite.Enabled = false; selForum.Enabled = false; btnOk.Enabled = false; ShowError(GetString("srch.index.nositeselected")); } // Set default vaules for forum selector selForum.SetValue("selectionmode", SelectionModeEnum.MultipleTextBox); selForum.SetValue("DisplayAdHocOption", false); selForum.SetValue("SiteName", Convert.ToString(selSite.Value)); // Set events and default values for site selector selSite.UniSelector.OnSelectionChanged += new EventHandler(UniSelector_OnSelectionChanged); selSite.DropDownSingleSelect.AutoPostBack = true; LoadControls(); if (ItemType == SearchIndexSettingsInfo.TYPE_ALLOWED) { selSite.AllowAll = true; } // Init controls if (!RequestHelper.IsPostBack()) { selForum.Enabled = true; string siteName = ValidationHelper.GetString(selSite.Value, String.Empty); if (String.IsNullOrEmpty(siteName) || (siteName == "-1")) { selForum.Enabled = false; } else { selForum.SetValue("SiteName", siteName); SetControlsStatus(false); } } }
protected void Page_Load(object sender, EventArgs e) { // Register the scripts ScriptHelper.RegisterProgress(this.Page); ScriptHelper.RegisterTooltip(this.Page); ScriptHelper.RegisterDialogScript(this); // Set user control properties usrOwner = this.Page.LoadControl("~/CMSModules/Membership/FormControls/Users/selectuser.ascx") as FormEngineUserControl; usrOwner.ID = "ctrlUsrOwner"; usrOwner.IsLiveSite = false; usrOwner.SetValue("ShowSiteFilter", false); usrOwner.StopProcessing = this.pnlUIOwner.IsHidden; plcUsrOwner.Controls.Add(usrOwner); UIContext.PropertyTab = PropertyTabEnum.General; nodeId = QueryHelper.GetInteger("nodeid", 0); // Init strings pnlDesign.GroupingText = GetString("GeneralProperties.DesignGroup"); pnlCache.GroupingText = GetString("GeneralProperties.CacheGroup"); pnlOther.GroupingText = GetString("GeneralProperties.OtherGroup"); pnlAdvanced.GroupingText = GetString("GeneralProperties.AdvancedGroup"); pnlOwner.GroupingText = GetString("GeneralProperties.OwnerGroup"); // Advanced section mEditableContent = GetString("GeneralProperties.EditableContent"); mForums = GetString("PageProperties.AdHocForum"); mMessageBoards = GetString("PageProperties.MessageBoards"); lnkEditableContent.OnClientClick = "ShowEditableContent(); return false;"; lnkMessageBoards.OnClientClick = "ShowMessageBoards(); return false;"; lnkForums.OnClientClick = "ShowForums(); return false;"; imgEditableContent.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditableContent/editablecontent.png"); imgMessageBoards.ImageUrl = GetImageUrl("CMSModules/CMS_MessageBoards/module.png"); imgForums.ImageUrl = GetImageUrl("CMSModules/CMS_Forums/module.png"); // Get strings for radio buttons radInherit.Text = GetString("GeneralProperties.radInherit"); radYes.Text = GetString("general.yes"); radNo.Text = GetString("general.no"); lblCacheMinutes.Text = GetString("GeneralProperties.cacheMinutes"); // Get strings for labels lblNameTitle.Text = GetString("GeneralProperties.Name"); lblNamePathTitle.Text = GetString("GeneralProperties.NamePath"); lblAliasPathTitle.Text = GetString("GeneralProperties.AliasPath"); lblTypeTitle.Text = GetString("GeneralProperties.Type"); lblNodeIDTitle.Text = GetString("GeneralProperties.NodeID"); lblLastModifiedByTitle.Text = GetString("GeneralProperties.LastModifiedBy"); lblLastModifiedTitle.Text = GetString("GeneralProperties.LastModified"); lblLiveURLTitle.Text = GetString("GeneralProperties.LiveURL"); lblPreviewURLTitle.Text = GetString("GeneralProperties.PreviewURL"); lblGUIDTitle.Text = GetString("GeneralProperties.GUID"); lblDocGUIDTitle.Text = GetString("GeneralProperties.DocumentGUID"); lblDocIDTitle.Text = GetString("GeneralProperties.DocumentID"); lblCultureTitle.Text = GetString("GeneralProperties.Culture"); lblCreatedByTitle.Text = GetString("GeneralProperties.CreatedBy"); lblCreatedTitle.Text = GetString("GeneralProperties.Created"); lblOwnerTitle.Text = GetString("GeneralProperties.Owner"); lblCssStyle.Text = GetString("PageProperties.CssStyle"); lblPublishedTitle.Text = GetString("PageProperties.Published"); chkExcludeFromSearch.Text = GetString("GeneralProperties.ExcludeFromSearch"); chkCssStyle.Text = GetString("Metadata.Inherit"); pnlOnlineMarketing.GroupingText = GetString("general.onlinemarketing"); // Set default item value string defaultStyleSheet = "-1"; CssStylesheetInfo cssInfo = CMSContext.CurrentSiteStylesheet; // If current site default stylesheet defined, choose it if (cssInfo != null) { defaultStyleSheet = "default"; } ctrlSiteSelectStyleSheet.CurrentSelector.SpecialFields = new string[1, 2] { { GetString("general.defaultchoice"), defaultStyleSheet } }; ctrlSiteSelectStyleSheet.ReturnColumnName = "StyleSheetID"; ctrlSiteSelectStyleSheet.SiteId = CMSContext.CurrentSiteID; if (CMSContext.CurrentSite != null) { usrOwner.SetValue("SiteID", CMSContext.CurrentSite.SiteID); } // Initialize Save button imgSave.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/save.png"); mSave = GetString("general.save"); int documentId = 0; // Get the document TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); node = tree.SelectSingleNode(nodeId, CMSContext.PreferredCultureCode, false); // Redirect to page 'New culture version' in split mode. It must be before setting EditedDocument. if ((node == null) && displaySplitMode) { URLHelper.Redirect("~/CMSModules/Content/CMSDesk/New/NewCultureVersion.aspx" + URLHelper.Url.Query); } // Set edited document EditedDocument = node; if (node != null) { documentId = node.DocumentID; canEditOwner = (CMSContext.CurrentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.ModifyPermissions) == AuthorizationResultEnum.Allowed); ReloadData(); } // Generate executive script string script = "function ShowEditableContent() { modalDialog('" + ResolveUrl("Advanced/EditableContent/default.aspx") + "?nodeid=" + nodeId + "', 'EditableContent', 1015, 700); } \n"; if (hasAdHocBoard) { plcAdHocBoards.Visible = true; script += "function ShowMessageBoards() { modalDialog('" + ResolveUrl("~/CMSModules/MessageBoards/Content/Properties/default.aspx") + "?documentid=" + documentId + "', 'MessageBoards', 1020, 680); } \n"; } if (hasAdHocForum) { plcAdHocForums.Visible = true; script += "function ShowForums() { modalDialog('" + ResolveUrl("~/CMSModules/Forums/Content/Properties/default.aspx") + "?documentid=" + documentId + "', 'Forums', 1130, 680); } \n"; } ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ModalDialogsToAdvancedSection", ScriptHelper.GetScript(script)); // Register js synchronization script for split mode if (displaySplitMode) { RegisterSplitModeSync(true, false); } }
protected DataSet gridDocuments_OnDataReload(string completeWhere, string currentOrder, int currentTopN, string columns, int currentOffset, int currentPageSize, ref int totalRecords) { dataLoaded = true; if (Node == null) { return(null); } if (gridDocuments.FilterForm.FieldControls != null) { // Get value of filter checkbox FormEngineUserControl checkboxControl = gridDocuments.FilterForm.FieldControls["ShowAllLevels"]; if (checkboxControl != null) { ShowAllLevels = ValidationHelper.GetBoolean(checkboxControl.Value, false); } } // Get the site SiteInfo si = SiteInfo.Provider.Get(Node.NodeSiteID); if (si == null) { return(null); } if (ShowAllLevels && !checkPermissions) { // Add required columns if check permissions is false because of all levels enabled (Browse tree security check is performed) columns = SqlHelper.MergeColumns(DocumentColumnLists.SECURITYCHECK_REQUIRED_COLUMNS, columns); } if (!checkPermissions || (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Read) == AuthorizationResultEnum.Allowed)) { var completeCondition = GetCompleteWhereCondition(completeWhere, ref currentOrder); // Merge document and grid specific columns columns = SqlHelper.MergeColumns(DocumentColumnLists.SELECTNODES_REQUIRED_COLUMNS, columns); // Add additional order by column to ensure correct deterministic ordering in all cases (eg. order by NodeHasChilder) currentOrder = String.Join(",", currentOrder, "NodeID ASC"); var query = DocumentHelper.GetDocuments() .TopN(gridDocuments.TopN) .Columns(columns) .OnSite(currentSiteName) .Published(false) .CombineWithDefaultCulture() .Culture(GetSiteCultures()) .Where(completeCondition) .OrderBy(currentOrder); // Do not apply published from / to columns to make sure the published information is correctly evaluated query.Properties.ExcludedVersionedColumns = new[] { "DocumentPublishFrom", "DocumentPublishTo" }; query.Offset = currentOffset; query.MaxRecords = currentPageSize; if (ClassID > 0) { query.ClassName = DataClassInfoProvider.GetClassName(ClassID); } DataSet ds = query.Result; totalRecords = query.TotalRecords; ds = FilterPagesByPermissions(ds, checkPermissions, ShowAllLevels); return(ds); } gridDocuments.ZeroRowsText = GetString("ContentTree.ReadDocumentDenied"); // Hide mass actions when no data ctrlMassActions.Visible = false; return(null); }
protected void Page_Load(object sender, EventArgs e) { // Show panel with message how to enable indexing if (!smartSearchEnabled) { pnlDisabled.Visible = true; } // Module forums is not available if (!(ModuleEntry.IsModuleRegistered(ModuleEntry.FORUMS) && ModuleEntry.IsModuleLoaded(ModuleEntry.FORUMS))) { return; } selForum = this.LoadControl("~/CMSModules/Forums/FormControls/ForumSelector.ascx") as FormEngineUserControl; if (selForum != null) { selForum.IsLiveSite = false; plcForumSelector.Controls.Add(selForum); } this.selSite.AllowAll = false; this.selSite.UseCodeNameForSelection = true; string siteWhere = String.Empty; DataSet ds = SearchIndexSiteInfoProvider.GetIndexSites("SiteID", "IndexID = " + ItemID, null, 0); if (!DataHelper.DataSourceIsEmpty(ds)) { foreach (DataRow dr in ds.Tables[0].Rows) { siteWhere += dr["SiteID"] + ","; } siteWhere = "," + siteWhere; // Preselect current site if it is assigned to index if (!RequestHelper.IsPostBack() && siteWhere.Contains("," + CMSContext.CurrentSiteID + ",")) { this.selSite.Value = CMSContext.CurrentSiteName; } siteWhere = siteWhere.Trim(','); siteWhere = "SiteID IN (" + siteWhere + ")"; this.selSite.UniSelector.WhereCondition = siteWhere; } else { selSite.Enabled = false; selForum.Enabled = false; btnOk.Enabled = false; lblInfo.Visible = true; lblInfo.Text = GetString("srch.index.nositeselected"); } // Set default vaules for forum selector this.selForum.SetValue("selectionmode", SelectionModeEnum.MultipleTextBox); this.selForum.SetValue("DisplayAdHocOption", false); this.selForum.SetValue("SiteName", Convert.ToString(selSite.Value)); // Set events and default values for site selector this.selSite.UniSelector.OnSelectionChanged += new EventHandler(UniSelector_OnSelectionChanged); this.selSite.DropDownSingleSelect.AutoPostBack = true; this.LoadControls(); if (ItemType == SearchIndexSettingsInfo.TYPE_ALLOWED) { this.selSite.AllowAll = true; } // Init controls if (!RequestHelper.IsPostBack()) { selForum.Enabled = true; string siteName = ValidationHelper.GetString(selSite.Value, String.Empty); if (String.IsNullOrEmpty(siteName) || (siteName == "-1")) { selForum.Enabled = false; } else { selForum.SetValue("SiteName", siteName); SetControlsStatus(false); } } }
/// <summary> /// Configures selectors. /// </summary> private void SetupSelectors() { // Setup role selector selectRole.CurrentSelector.SelectionMode = SelectionModeEnum.MultipleButton; selectRole.CurrentSelector.OnItemsSelected += RolesSelector_OnItemsSelected; selectRole.CurrentSelector.ReturnColumnName = "RoleID"; selectRole.CurrentSelector.ButtonImage = GetImageUrl("Objects/CMS_Role/add.png"); selectRole.CurrentSelector.DialogLink.CssClass = "MenuItemEdit Pad"; selectRole.ShowSiteFilter = false; selectRole.CurrentSelector.ResourcePrefix = "addroles"; selectRole.CurrentSelector.DialogButton.CssClass = "LongButton"; selectRole.IsLiveSite = false; selectRole.UseCodeNameForSelection = false; selectRole.GlobalRoles = false; // Setup user selector selectUser.SelectionMode = SelectionModeEnum.MultipleButton; selectUser.UniSelector.OnItemsSelected += UserSelector_OnItemsSelected; selectUser.UniSelector.ReturnColumnName = "UserID"; selectUser.UniSelector.DisplayNameFormat = "{%FullName%} ({%Email%})"; selectUser.UniSelector.ButtonImage = GetImageUrl("Objects/CMS_User/add.png"); selectUser.UniSelector.AdditionalSearchColumns = "UserName, Email"; selectUser.UniSelector.DialogLink.CssClass = "MenuItemEdit Pad"; selectUser.ShowSiteFilter = false; selectUser.ResourcePrefix = "newsletteraddusers"; selectUser.UniSelector.DialogButton.CssClass = "LongButton"; selectUser.IsLiveSite = false; // Setup subscriber selector selectSubscriber.UniSelector.SelectionMode = SelectionModeEnum.MultipleButton; selectSubscriber.UniSelector.OnItemsSelected += SubscriberSelector_OnItemsSelected; selectSubscriber.UniSelector.ReturnColumnName = "SubscriberID"; selectSubscriber.UniSelector.ButtonImage = GetImageUrl("Objects/Newsletter_Subscriber/add.png"); selectSubscriber.UniSelector.DialogLink.CssClass = "MenuItemEdit Pad"; selectSubscriber.ShowSiteFilter = false; selectSubscriber.UniSelector.DialogButton.CssClass = "LongButton"; selectSubscriber.IsLiveSite = false; selectSubscriber.UniSelector.RemoveMultipleCommas = true; // Setup contact group and contact selectors if (ModuleEntry.IsModuleLoaded(ModuleEntry.ONLINEMARKETING) && LicenseHelper.CheckFeature(URLHelper.GetCurrentDomain(), FeatureEnum.ContactManagement)) { plcSelectCG.Controls.Clear(); // Check read permission for contact groups if (CMSContext.CurrentUser.IsAuthorizedPerResource(ModuleEntry.CONTACTMANAGEMENT, "ReadContactGroups")) { // Load selector control and initialize it cgSelector = (FormEngineUserControl)Page.LoadUserControl("~/CMSModules/ContactManagement/FormControls/ContactGroupSelector.ascx"); if (cgSelector != null) { cgSelector.ID = "selectCG"; cgSelector.ShortID = "scg"; // Get inner uniselector control UniSelector selector = (UniSelector)cgSelector.GetValue("uniselector"); if (selector != null) { // Bind an event handler on 'items selected' event selector.OnItemsSelected += CGSelector_OnItemsSelected; selector.ResourcePrefix = "contactgroupsubscriber"; } // Insert selector to the header plcSelectCG.Controls.Add(cgSelector); } } // Check read permission for contacts if (CMSContext.CurrentUser.IsAuthorizedPerResource(ModuleEntry.CONTACTMANAGEMENT, "ReadContacts")) { // Load selector control and initialize it cSelector = (FormEngineUserControl)Page.LoadUserControl("~/CMSModules/ContactManagement/FormControls/ContactSelector.ascx"); if (cSelector != null) { cSelector.ID = "slContact"; cSelector.ShortID = "sc"; // Set where condition to filter contacts with email addresses cSelector.SetValue("wherecondition", "NOT (ContactEmail IS NULL OR ContactEmail LIKE '')"); // Set site ID cSelector.SetValue("siteid", CMSContext.CurrentSiteID); // Get inner uniselector control UniSelector selector = (UniSelector)cSelector.GetValue("uniselector"); if (selector != null) { // Bind an event handler on 'items selected' event selector.OnItemsSelected += ContactSelector_OnItemsSelected; selector.SelectionMode = SelectionModeEnum.MultipleButton; selector.ResourcePrefix = "contactsubscriber"; selector.ButtonImage = GetImageUrl("/Objects/OM_Contact/add.png"); selector.DisplayNameFormat = "{%ContactFirstName%} {%ContactLastName%} ({%ContactEmail%})"; selector.AdditionalSearchColumns = "ContactFirstName,ContactMiddleName,ContactEmail"; } // Insert selector to the header plcSelectCG.Controls.Add(cSelector); } } } // Initialize mass actions if (drpActions.Items.Count == 0) { drpActions.Items.Add(new ListItem(GetString("general.selectaction"), SELECT)); drpActions.Items.Add(new ListItem(GetString("newsletter.unsubscribelink"), UNSUBSCRIBE)); drpActions.Items.Add(new ListItem(GetString("newsletter.renewsubscription"), SUBSCRIBE)); drpActions.Items.Add(new ListItem(GetString("newsletter.approvesubscription"), APPROVE)); drpActions.Items.Add(new ListItem(GetString("newsletter.rejectsubscription"), REJECT)); drpActions.Items.Add(new ListItem(GetString("newsletter.deletesubscription"), REMOVE)); } }