/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { formElem.StopProcessing = StopProcessing; Visible = false; } else { isAuthenticated = (CurrentUser != null) && AuthenticationHelper.IsAuthenticated(); if (AllowUserSubscribers && isAuthenticated && (CurrentUser != null) && (!string.IsNullOrEmpty(CurrentUser.Email))) { // Hide form for authenticated user who has an email formElem.StopProcessing = true; formElem.Visible = false; } else { // Get alternative form info AlternativeFormInfo afi = AlternativeFormInfoProvider.GetAlternativeFormInfo(AlternativeForm); if (afi != null) { // Init subscriber object SubscriberInfo sb = new SubscriberInfo(); if (AllowUserSubscribers && isAuthenticated) { // Prepare user subscriber object for authenticated user without an email // Try to get existing user subscriber sb = SubscriberInfoProvider.GetSubscriberInfo(UserInfo.OBJECT_TYPE, CurrentUser.UserID, SiteContext.CurrentSiteID); if (sb == null) { // Prepare new user subscriber with pre-filled data sb = new SubscriberInfo() { SubscriberFirstName = CurrentUser.FirstName, SubscriberLastName = CurrentUser.LastName, SubscriberFullName = (CurrentUser.FirstName + " " + CurrentUser.LastName).Trim(), SubscriberType = UserInfo.OBJECT_TYPE, SubscriberRelatedID = CurrentUser.UserID }; } } // Init the form formElem.AlternativeFormFullName = AlternativeForm; formElem.Info = sb; formElem.ClearAfterSave = false; formElem.Visible = true; formElem.ValidationErrorMessage = SubscriptionErrorMessage; formElem.IsLiveSite = true; // Reload form if not in PortalEngine environment and if post back if ((StandAlone) && (RequestHelper.IsPostBack())) { formElem.ReloadData(); } } else { lblError.Text = String.Format(GetString("altform.formdoesntexists"), AlternativeForm); lblError.Visible = true; pnlSubscription.Visible = false; } } // Display/hide captcha plcCaptcha.Visible = DisplayCaptcha; lblCaptcha.ResourceString = CaptchaText; lblCaptcha.AssociatedControlClientID = scCaptcha.InputClientID; // Init submit buttons if ((UseImageButton) && (!String.IsNullOrEmpty(ImageButtonURL))) { pnlButtonSubmit.Visible = false; pnlImageSubmit.Visible = true; btnImageSubmit.ImageUrl = ImageButtonURL; } else { pnlButtonSubmit.Visible = true; pnlImageSubmit.Visible = false; btnSubmit.Text = ButtonText; } lblInfo.CssClass = "EditingFormInfoLabel"; lblError.CssClass = "EditingFormErrorLabel"; if (formElem != null) { // Set the live site context formElem.ControlContext.ContextName = CMS.ExtendedControls.ControlContext.LIVE_SITE; } // Init newsletter selector InitNewsletterSelector(); } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { plcOther.Controls.Clear(); if (AuthenticationHelper.IsAuthenticated()) { // Set the layout of tab menu tabMenu.TabControlLayout = BasicTabControl.GetTabMenuLayout(TabControlLayout); // Remove 'saved' parameter from query string string absoluteUri = URLHelper.RemoveParameterFromUrl(RequestContext.CurrentURL, "saved"); var currentUser = MembershipContext.AuthenticatedUser; // Get customer info GeneralizedInfo customer = null; int customerId = 0; var emptyCustomer = ModuleManager.GetReadOnlyObject(PredefinedObjectType.CUSTOMER); if (emptyCustomer != null) { var q = emptyCustomer.Generalized.GetDataQuery( true, s => s .WhereEquals("CustomerUserID", currentUser.UserID) .OrderBy("CustomerCreated") .TopN(1), false ); var result = q.Result; if (!DataHelper.DataSourceIsEmpty(result)) { customer = ModuleManager.GetObject(result.Tables[0].Rows[0], PredefinedObjectType.CUSTOMER); customerId = customer.ObjectID; } } // Get friends enabled setting bool friendsEnabled = UIHelper.IsFriendsModuleEnabled(SiteContext.CurrentSiteName); // Selected page URL string selectedPage = string.Empty; // Menu initialization tabMenu.UrlTarget = "_self"; ArrayList activeTabs = new ArrayList(); // Handle 'Notifications' tab displaying bool showNotificationsTab = (DisplayMyNotifications && LicenseHelper.IsFeatureAvailableInUI(FeatureEnum.Notifications, ModuleName.NOTIFICATIONS)); bool isWindowsAuthentication = RequestHelper.IsWindowsAuthentication(); string tabName; // Personal tab if (DisplayMyPersonalSettings) { tabName = personalTab; activeTabs.Add(tabName); tabMenu.TabItems.Add(new TabItem() { Text = GetString("MyAccount.MyPersonalSettings"), RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, personalTab) }); if (currentUser != null) { selectedPage = tabName; } } // These items can be displayed only for customer if ((customer != null) && ModuleEntryManager.IsModuleLoaded(ModuleName.ECOMMERCE)) { if (DisplayMyDetails) { // Try to load the control dynamically (if available) ucMyDetails = Page.LoadUserControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyDetails.ascx") as CMSAdminControl; if (ucMyDetails != null) { ucMyDetails.ID = "ucMyDetails"; plcOther.Controls.Add(ucMyDetails); // Set new tab tabName = detailsTab; activeTabs.Add(tabName); tabMenu.TabItems.Add(new TabItem() { Text = GetString("MyAccount.MyDetails"), RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, detailsTab) }); if (selectedPage == string.Empty) { selectedPage = tabName; } } } if (DisplayMyAddresses) { // Try to load the control dynamically (if available) ucMyAddresses = Page.LoadUserControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyAddresses.ascx") as CMSAdminControl; if (ucMyAddresses != null) { ucMyAddresses.ID = "ucMyAddresses"; plcOther.Controls.Add(ucMyAddresses); // Set new tab tabName = addressesTab; activeTabs.Add(tabName); tabMenu.TabItems.Add(new TabItem() { Text = GetString("MyAccount.MyAddresses"), RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, addressesTab) }); if (selectedPage == string.Empty) { selectedPage = tabName; } } } if (DisplayMyOrders) { // Try to load the control dynamically (if available) ucMyOrders = Page.LoadUserControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyOrders.ascx") as CMSAdminControl; if (ucMyOrders != null) { ucMyOrders.ID = "ucMyOrders"; plcOther.Controls.Add(ucMyOrders); // Set new tab tabName = ordersTab; activeTabs.Add(tabName); tabMenu.TabItems.Add(new TabItem() { Text = GetString("MyAccount.MyOrders"), RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, ordersTab) }); if (selectedPage == string.Empty) { selectedPage = tabName; } } } if (DisplayMyCredits) { // Try to load the control dynamically (if available) ucMyCredit = Page.LoadUserControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyCredit.ascx") as CMSAdminControl; if (ucMyCredit != null) { ucMyCredit.ID = "ucMyCredit"; plcOther.Controls.Add(ucMyCredit); // Set new tab tabName = creditTab; activeTabs.Add(tabName); tabMenu.TabItems.Add(new TabItem() { Text = GetString("MyAccount.MyCredit"), RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, creditTab) }); if (selectedPage == string.Empty) { selectedPage = tabName; } } } } if (DisplayChangePassword && !currentUser.IsExternal && !isWindowsAuthentication) { // Set new tab tabName = passwordTab; activeTabs.Add(tabName); tabMenu.TabItems.Add(new TabItem() { Text = GetString("MyAccount.ChangePassword"), RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, passwordTab) }); if (selectedPage == string.Empty) { selectedPage = tabName; } } if ((ucMyNotifications == null) && showNotificationsTab) { // Try to load the control dynamically (if available) ucMyNotifications = Page.LoadUserControl("~/CMSModules/Notifications/Controls/UserNotifications.ascx") as CMSAdminControl; if (ucMyNotifications != null) { ucMyNotifications.ID = "ucMyNotifications"; plcOther.Controls.Add(ucMyNotifications); // Set new tab tabName = notificationsTab; activeTabs.Add(tabName); tabMenu.TabItems.Add(new TabItem() { Text = GetString("MyAccount.MyNotifications"), RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, notificationsTab) }); if (selectedPage == string.Empty) { selectedPage = tabName; } } } if ((ucMyMessages == null) && DisplayMyMessages && ModuleManager.IsModuleLoaded(ModuleName.MESSAGING)) { // Try to load the control dynamically (if available) ucMyMessages = Page.LoadUserControl("~/CMSModules/Messaging/Controls/MyMessages.ascx") as CMSAdminControl; if (ucMyMessages != null) { ucMyMessages.ID = "ucMyMessages"; plcOther.Controls.Add(ucMyMessages); // Set new tab tabName = messagesTab; activeTabs.Add(tabName); tabMenu.TabItems.Add(new TabItem() { Text = GetString("MyAccount.MyMessages"), RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, messagesTab) }); if (selectedPage == string.Empty) { selectedPage = tabName; } } } if ((ucMyFriends == null) && DisplayMyFriends && ModuleManager.IsModuleLoaded(ModuleName.COMMUNITY) && friendsEnabled) { // Try to load the control dynamically (if available) ucMyFriends = Page.LoadUserControl("~/CMSModules/Friends/Controls/MyFriends.ascx") as CMSAdminControl; if (ucMyFriends != null) { ucMyFriends.ID = "ucMyFriends"; plcOther.Controls.Add(ucMyFriends); // Set new tab tabName = friendsTab; activeTabs.Add(tabName); tabMenu.TabItems.Add(new TabItem() { Text = GetString("MyAccount.MyFriends"), RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, friendsTab) }); if (selectedPage == string.Empty) { selectedPage = tabName; } } } if ((ucMyAllSubscriptions == null) && DisplayMySubscriptions) { // Try to load the control dynamically (if available) ucMyAllSubscriptions = Page.LoadUserControl("~/CMSModules/Membership/Controls/Subscriptions.ascx") as CMSAdminControl; if (ucMyAllSubscriptions != null) { // Set control ucMyAllSubscriptions.Visible = false; ucMyAllSubscriptions.SetValue("ShowBlogs", DisplayBlogs); ucMyAllSubscriptions.SetValue("ShowMessageBoards", DisplayMessageBoards); ucMyAllSubscriptions.SetValue("ShowNewsletters", DisplayNewsletters); ucMyAllSubscriptions.SetValue("ShowForums", DisplayForums); ucMyAllSubscriptions.SetValue("ShowReports", DisplayReports); ucMyAllSubscriptions.SetValue("sendconfirmationemail", SendConfirmationEmails); ucMyAllSubscriptions.ID = "ucMyAllSubscriptions"; plcOther.Controls.Add(ucMyAllSubscriptions); // Set new tab tabName = subscriptionsTab; activeTabs.Add(tabName); tabMenu.TabItems.Add(new TabItem() { Text = GetString("MyAccount.MyAllSubscriptions"), RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, subscriptionsTab) }); if (selectedPage == string.Empty) { selectedPage = tabName; } } } // My memberships if ((ucMyMemberships == null) && DisplayMyMemberships) { // Try to load the control dynamically ucMyMemberships = Page.LoadUserControl("~/CMSModules/Membership/Controls/MyMemberships.ascx") as CMSAdminControl; if (ucMyMemberships != null) { ucMyMemberships.SetValue("UserID", currentUser.UserID); if (!String.IsNullOrEmpty(MembershipsPagePath)) { ucMyMemberships.SetValue("BuyMembershipURL", DocumentURLProvider.GetUrl(MembershipsPagePath)); } plcOther.Controls.Add(ucMyMemberships); // Set new tab tabName = membershipsTab; activeTabs.Add(tabName); tabMenu.TabItems.Add(new TabItem() { Text = GetString("myaccount.mymemberships"), RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, membershipsTab) }); if (selectedPage == String.Empty) { selectedPage = tabName; } } } if ((ucMyCategories == null) && DisplayMyCategories) { // Try to load the control dynamically (if available) ucMyCategories = Page.LoadUserControl("~/CMSModules/Categories/Controls/Categories.ascx") as CMSAdminControl; if (ucMyCategories != null) { ucMyCategories.Visible = false; ucMyCategories.SetValue("DisplaySiteCategories", false); ucMyCategories.SetValue("DisplaySiteSelector", false); ucMyCategories.ID = "ucMyCategories"; plcOther.Controls.Add(ucMyCategories); // Set new tab tabName = categoriesTab; activeTabs.Add(tabName); tabMenu.TabItems.Add(new TabItem() { Text = GetString("MyAccount.MyCategories"), RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, categoriesTab) }); if (selectedPage == string.Empty) { selectedPage = tabName; } } } // Set CSS class pnlBody.CssClass = CssClass; // Get page URL page = QueryHelper.GetString(ParameterName, selectedPage); // Set controls visibility ucChangePassword.Visible = false; ucChangePassword.StopProcessing = true; if (ucMyAddresses != null) { ucMyAddresses.Visible = false; ucMyAddresses.StopProcessing = true; } if (ucMyOrders != null) { ucMyOrders.Visible = false; ucMyOrders.StopProcessing = true; } if (ucMyDetails != null) { ucMyDetails.Visible = false; ucMyDetails.StopProcessing = true; } if (ucMyCredit != null) { ucMyCredit.Visible = false; ucMyCredit.StopProcessing = true; } if (ucMyAllSubscriptions != null) { ucMyAllSubscriptions.Visible = false; ucMyAllSubscriptions.StopProcessing = true; ucMyAllSubscriptions.SetValue("CacheMinutes", CacheMinutes); } if (ucMyNotifications != null) { ucMyNotifications.Visible = false; ucMyNotifications.StopProcessing = true; } if (ucMyMessages != null) { ucMyMessages.Visible = false; ucMyMessages.StopProcessing = true; } if (ucMyFriends != null) { ucMyFriends.Visible = false; ucMyFriends.StopProcessing = true; } if (ucMyMemberships != null) { ucMyMemberships.Visible = false; ucMyMemberships.StopProcessing = true; } if (ucMyCategories != null) { ucMyCategories.Visible = false; ucMyCategories.StopProcessing = true; } tabMenu.SelectedTab = activeTabs.IndexOf(page); // Select current page switch (page) { case personalTab: if (myProfile != null) { // Get alternative form info AlternativeFormInfo afi = AlternativeFormInfoProvider.GetAlternativeFormInfo(AlternativeFormName); if (afi != null) { myProfile.StopProcessing = false; myProfile.Visible = true; myProfile.AllowEditVisibility = AllowEditVisibility; myProfile.AlternativeFormName = AlternativeFormName; } else { lblError.Text = String.Format(GetString("altform.formdoesntexists"), AlternativeFormName); lblError.Visible = true; myProfile.Visible = false; } } break; // My details tab case detailsTab: if (ucMyDetails != null) { ucMyDetails.Visible = true; ucMyDetails.StopProcessing = false; ucMyDetails.SetValue("Customer", customer); } break; // My addresses tab case addressesTab: if (ucMyAddresses != null) { ucMyAddresses.Visible = true; ucMyAddresses.StopProcessing = false; ucMyAddresses.SetValue("CustomerId", customerId); } break; // My orders tab case ordersTab: if (ucMyOrders != null) { ucMyOrders.Visible = true; ucMyOrders.StopProcessing = false; ucMyOrders.SetValue("CustomerId", customerId); ucMyOrders.SetValue("ShowOrderTrackingNumber", ShowOrderTrackingNumber); ucMyOrders.SetValue("ShowOrderToShoppingCart", ShowOrderToShoppingCart); } break; // My credit tab case creditTab: if (ucMyCredit != null) { ucMyCredit.Visible = true; ucMyCredit.StopProcessing = false; ucMyCredit.SetValue("CustomerId", customerId); } break; // Password tab case passwordTab: ucChangePassword.Visible = true; ucChangePassword.StopProcessing = false; ucChangePassword.AllowEmptyPassword = AllowEmptyPassword; break; // Notification tab case notificationsTab: if (ucMyNotifications != null) { ucMyNotifications.Visible = true; ucMyNotifications.StopProcessing = false; ucMyNotifications.SetValue("UserId", currentUser.UserID); ucMyNotifications.SetValue("UnigridImageDirectory", UnigridImageDirectory); } break; // My messages tab case messagesTab: if (ucMyMessages != null) { ucMyMessages.Visible = true; ucMyMessages.StopProcessing = false; } break; // My friends tab case friendsTab: if (ucMyFriends != null) { ucMyFriends.Visible = true; ucMyFriends.StopProcessing = false; ucMyFriends.SetValue("UserID", currentUser.UserID); } break; // My subscriptions tab case subscriptionsTab: if (ucMyAllSubscriptions != null) { ucMyAllSubscriptions.Visible = true; ucMyAllSubscriptions.StopProcessing = false; ucMyAllSubscriptions.SetValue("userid", currentUser.UserID); ucMyAllSubscriptions.SetValue("siteid", SiteContext.CurrentSiteID); } break; // My memberships tab case membershipsTab: if (ucMyMemberships != null) { ucMyMemberships.Visible = true; ucMyMemberships.StopProcessing = false; } break; // My categories tab case categoriesTab: if (ucMyCategories != null) { ucMyCategories.Visible = true; ucMyCategories.StopProcessing = false; } break; } } else { // Hide control if current user is not authenticated Visible = false; } } }
/// <summary> /// Saves form layout. /// </summary> protected void SaveData() { bool saved = false; bool deleted = false; // Get form layout string layout = FormLayout; // Delete layout if editor is hidden if (!CustomLayoutEnabled) { deleted = LayoutIsSet; layout = null; } if (DataClassID > 0) { if (!IsAlternative) { classInfo = DataClassInfoProvider.GetDataClassInfo(DataClassID); UIContext.EditedObject = classInfo; if (classInfo != null) { // Update dataclass form layout and save object classInfo.ClassFormLayout = layout; classInfo.ClassFormLayoutType = LayoutHelper.GetLayoutTypeEnum(drpLayoutType.SelectedValue); DataClassInfoProvider.SetDataClassInfo(classInfo); saved = true; } } else { altFormInfo = AlternativeFormInfoProvider.GetAlternativeFormInfo(ObjectID); UIContext.EditedObject = altFormInfo; if (altFormInfo != null) { // Update alternative form layout and save object altFormInfo.FormLayout = layout; altFormInfo.FormLayoutType = LayoutHelper.GetLayoutTypeEnum(drpLayoutType.SelectedValue); AlternativeFormInfoProvider.SetAlternativeFormInfo(altFormInfo); saved = true; } } // Display info if successfully saved if (saved) { if (!deleted) { ShowChangesSaved(); } else { ShowConfirmation(GetString("DocumentType_Edit_Form.LayoutDeleted")); } } } else { UIContext.EditedObject = null; } }
/// <summary> /// Fills field list with available fields. /// </summary> protected void FillFieldsList() { drpAvailableFields.Items.Clear(); DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(DataClassID); if (dci != null) { // Load form definition string formDefinition = dci.ClassFormDefinition; if (IsAlternative) { // Get alternative form definition and merge if with the original one AlternativeFormInfo afi = AlternativeFormInfoProvider.GetAlternativeFormInfo(ObjectID); if (afi.FormCoupledClassID > 0) { // If coupled class is defined combine form definitions DataClassInfo coupledDci = DataClassInfoProvider.GetDataClassInfo(afi.FormCoupledClassID); if (coupledDci != null) { formDefinition = FormHelper.MergeFormDefinitions(formDefinition, coupledDci.ClassFormDefinition); } } // Merge class and alternative form definitions formDefinition = FormHelper.MergeFormDefinitions(formDefinition, afi.FormDefinition); } FormInfo fi = new FormInfo(formDefinition); // Get visible fields var visibleFields = fi.GetFields(true, false); drpAvailableFields.Items.Clear(); // Prepare arrays for JavaScript functions string script = "var formControlName = new Array(); var formControlCssClass = new Array();\n"; if (FormLayoutType == FormLayoutTypeEnum.Document) { if (string.IsNullOrEmpty(dci.ClassNodeNameSource)) //if node name source is not set { string docName = "DocumentName"; drpAvailableFields.Items.Add(new ListItem(GetString("DocumentType_Edit_Form.DocumentName"), docName)); // Add document name field form control to the script script += String.Format("formControlName['{0}'] = '{1}';\n", docName, "TextBoxControl"); script += String.Format("formControlCssClass['{0}'] = '';\n", docName); } } if (visibleFields != null) { // Add public visible fields to the list foreach (FormFieldInfo ffi in visibleFields) { drpAvailableFields.Items.Add(new ListItem(ffi.GetDisplayName(MacroResolver.GetInstance()), ffi.Name)); // Add fields' form controls to the script script += String.Format("formControlName['{0}'] = '{1}';\n", ffi.Name, ffi.Settings["controlname"]); script += String.Format("formControlCssClass['{0}'] = '{1}';\n", ffi.Name, ffi.GetPropertyValue(FormFieldPropertyEnum.ControlCssClass)); } } if (FormLayoutType == FormLayoutTypeEnum.Document) { if (dci.ClassUsePublishFromTo) { // Add publish from/to fields if they are not already in predefined fields if (drpAvailableFields.Items.FindByValue("DocumentPublishFrom", true) == null) { string publishFrom = "DocumentPublishFrom"; drpAvailableFields.Items.Add(new ListItem(GetString("DocumentType_Edit_Form.DocumentPublishFrom"), publishFrom)); // Add Publish From field form control to the script script += String.Format("formControlName['{0}'] = '{1}';\n", publishFrom, "CalendarControl"); script += String.Format("formControlCssClass['{0}'] = '';\n", publishFrom); } if (drpAvailableFields.Items.FindByValue("DocumentPublishTo", true) == null) { string publishTo = "DocumentPublishTo"; drpAvailableFields.Items.Add(new ListItem(GetString("DocumentType_Edit_Form.DocumentPublishTo"), publishTo)); // Add Publish To field form control to the script script += String.Format("formControlName['{0}'] = '{1}';\n", publishTo, "CalendarControl"); script += String.Format("formControlCssClass['{0}'] = '';\n", publishTo); } } } // Set script - it is registered on pre-render FormControlScript = script; } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { formElem.StopProcessing = StopProcessing; Visible = false; } else { if (AllowUserSubscribersIsAuthenticated && (!string.IsNullOrEmpty(CurrentUser.Email))) { // Hide form for authenticated user who has an email formElem.StopProcessing = true; formElem.Visible = false; } else { // Get alternative form info AlternativeFormInfo afi = AlternativeFormInfoProvider.GetAlternativeFormInfo(AlternativeForm); if (afi != null) { subscriber = new SubscriberInfo(); // Init the form formElem.Data = subscriber; formElem.FormInformation = FormHelper.GetFormInfo(AlternativeForm, true); formElem.AltFormInformation = afi; formElem.MessagesPlaceHolder = plcMess; formElem.Visible = true; formElem.ValidationErrorMessage = SubscriptionErrorMessage; formElem.IsLiveSite = true; // Reload form if not in PortalEngine environment if (StandAlone) { formElem.ReloadData(); } } else { lblError.Text = String.Format(GetString("altform.formdoesntexists"), AlternativeForm); lblError.Visible = true; pnlSubscription.Visible = false; } } // Display/hide CAPTCHA plcCaptcha.Visible = DisplayCaptcha; lblCaptcha.ResourceString = CaptchaText; lblCaptcha.AssociatedControlClientID = scCaptcha.InputClientID; // Init submit buttons if ((UseImageButton) && (!String.IsNullOrEmpty(ImageButtonURL))) { pnlButtonSubmit.Visible = false; pnlImageSubmit.Visible = true; btnImageSubmit.ImageUrl = ImageButtonURL; } else { pnlButtonSubmit.Visible = true; pnlImageSubmit.Visible = false; btnSubmit.Text = ButtonText; } lblInfo.CssClass = "EditingFormInfoLabel"; lblError.CssClass = "EditingFormErrorLabel"; if (formElem != null) { // Set the live site context formElem.ControlContext.ContextName = CMS.Base.Web.UI.ControlContext.LIVE_SITE; } InitNewsletterSelector(); } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { if (this.ViewMode == ViewModeEnum.LiveSite) { if (CMS.Helpers.RequestContext.IsUserAuthenticated) { Response.Redirect("~/sso/ssohandler.aspx", true); } } // Set default visibility pnlRegForm.Visible = true; lblInfo.Visible = false; // WAI validation lblCaptcha.AssociatedControlClientID = captchaElem.InputClientID; // Get alternative form info AlternativeFormInfo afi = AlternativeFormInfoProvider.GetAlternativeFormInfo(AlternativeForm); if (afi != null) { formUser.AlternativeFormFullName = AlternativeForm; formUser.Info = new UserInfo(); formUser.Info.ClearData(); formUser.ClearAfterSave = false; formUser.Visible = true; formUser.ValidationErrorMessage = RegistrationErrorMessage; formUser.IsLiveSite = true; // Reload form if not in PortalEngine environment and if post back if ((StandAlone) && (RequestHelper.IsPostBack())) { formUser.ReloadData(); } captchaElem.Visible = DisplayCaptcha; lblCaptcha.Visible = DisplayCaptcha; plcCaptcha.Visible = DisplayCaptcha; btnRegister.Text = ButtonText; btnRegister.Click += btnRegister_Click; lblInfo.CssClass = "EditingFormInfoLabel"; lblError.CssClass = "EditingFormErrorLabel"; lblError.ForeColor = System.Drawing.Color.Red; if (formUser != null) { // Set the live site context formUser.ControlContext.ContextName = CMS.ExtendedControls.ControlContext.LIVE_SITE; } } else { lblError.Text = String.Format(GetString("altform.formdoesntexists"), AlternativeForm); lblError.Visible = true; pnlRegForm.Visible = false; } } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { plcOther.Controls.Clear(); if (MembershipContext.AuthenticatedUser.IsAuthenticated()) { // Set the layout of tab menu tabMenu.TabControlLayout = BasicTabControl.GetTabMenuLayout(TabControlLayout); // Remove 'saved' parameter from query string string absoluteUri = URLHelper.RemoveParameterFromUrl(URLRewriter.CurrentURL, "saved"); CurrentUserInfo currentUser = MembershipContext.AuthenticatedUser; // Get customer info GeneralizedInfo customer = ModuleCommands.ECommerceGetCustomerInfoByUserId(currentUser.UserID); bool userIsCustomer = (customer != null); // Get friends enabled setting bool friendsEnabled = UIHelper.IsFriendsModuleEnabled(SiteContext.CurrentSiteName); // Get customer ID int customerId = 0; if (userIsCustomer) { customerId = ValidationHelper.GetInteger(customer.ObjectID, 0); } // Selected page URL string selectedPage = string.Empty; // Menu initialization tabMenu.UrlTarget = "_self"; ArrayList activeTabs = new ArrayList(); string tabName = string.Empty; // Set array size of tab control int arraySize = 0; if (DisplayMyPersonalSettings) { arraySize++; } if (DisplayMyMessages) { arraySize++; } // Handle 'Notifications' tab displaying bool hideUnavailableUI = SettingsKeyInfoProvider.GetBoolValue("CMSHideUnavailableUserInterface"); bool showNotificationsTab = (DisplayMyNotifications && ModuleEntryManager.IsModuleLoaded(ModuleEntry.NOTIFICATIONS) && (!hideUnavailableUI || LicenseHelper.CheckFeature(URLHelper.GetCurrentDomain(), FeatureEnum.Notifications))); bool isWindowsAuthentication = RequestHelper.IsWindowsAuthentication(); // Notification tab if (showNotificationsTab) { arraySize++; } // Friends tab if (DisplayMyFriends && friendsEnabled) { arraySize++; } // User password tab if (DisplayChangePassword && !currentUser.IsExternal && !isWindowsAuthentication) { arraySize++; } // Subscriptions tab if (DisplayMySubscriptions) { arraySize++; } // Memberships tab if (DisplayMyMemberships) { arraySize++; } // Categories tab if (DisplayMyCategories) { arraySize++; } // Ecommerce tabs if (DisplayMyCredits && userIsCustomer) { arraySize++; } if (DisplayMyDetails && userIsCustomer) { arraySize++; } if (DisplayMyAddresses && userIsCustomer) { arraySize++; } if (DisplayMyOrders && userIsCustomer) { arraySize++; } tabMenu.Tabs = new string[arraySize, 5]; // Personal tab if (DisplayMyPersonalSettings) { // Set new tab tabName = personalTab; activeTabs.Add(tabName); tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyPersonalSettings"); tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, personalTab)); if (currentUser != null) { selectedPage = tabName; } } // These items can be displayed only for customer if (userIsCustomer && ModuleEntryManager.IsModuleLoaded(ModuleEntry.ECOMMERCE)) { if (DisplayMyDetails) { // Try to load the control dynamically (if available) ucMyDetails = Page.LoadUserControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyDetails.ascx") as CMSAdminControl; if (ucMyDetails != null) { ucMyDetails.ID = "ucMyDetails"; plcOther.Controls.Add(ucMyDetails); // Set new tab tabName = detailsTab; activeTabs.Add(tabName); tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyDetails"); tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, detailsTab)); if (selectedPage == string.Empty) { selectedPage = tabName; } } } if (DisplayMyAddresses) { // Try to load the control dynamically (if available) ucMyAddresses = Page.LoadUserControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyAddresses.ascx") as CMSAdminControl; if (ucMyAddresses != null) { ucMyAddresses.ID = "ucMyAddresses"; plcOther.Controls.Add(ucMyAddresses); // Set new tab tabName = addressesTab; activeTabs.Add(tabName); tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyAddresses"); tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, addressesTab)); if (selectedPage == string.Empty) { selectedPage = tabName; } } } if (DisplayMyOrders) { // Try to load the control dynamically (if available) ucMyOrders = Page.LoadUserControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyOrders.ascx") as CMSAdminControl; if (ucMyOrders != null) { ucMyOrders.ID = "ucMyOrders"; plcOther.Controls.Add(ucMyOrders); // Set new tab tabName = ordersTab; activeTabs.Add(tabName); tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyOrders"); tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, ordersTab)); if (selectedPage == string.Empty) { selectedPage = tabName; } } } if (DisplayMyCredits) { // Try to load the control dynamically (if available) ucMyCredit = Page.LoadUserControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyCredit.ascx") as CMSAdminControl; if (ucMyCredit != null) { ucMyCredit.ID = "ucMyCredit"; plcOther.Controls.Add(ucMyCredit); // Set new tab tabName = creditTab; activeTabs.Add(tabName); tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyCredit"); tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, creditTab)); if (selectedPage == string.Empty) { selectedPage = tabName; } } } } if (DisplayChangePassword && !currentUser.IsExternal && !isWindowsAuthentication) { // Set new tab tabName = passwordTab; activeTabs.Add(tabName); tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.ChangePassword"); tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, passwordTab)); if (selectedPage == string.Empty) { selectedPage = tabName; } } if ((ucMyNotifications == null) && showNotificationsTab) { // Try to load the control dynamically (if available) ucMyNotifications = Page.LoadUserControl("~/CMSModules/Notifications/Controls/UserNotifications.ascx") as CMSAdminControl; if (ucMyNotifications != null) { ucMyNotifications.ID = "ucMyNotifications"; plcOther.Controls.Add(ucMyNotifications); // Set new tab tabName = notificationsTab; activeTabs.Add(tabName); tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyNotifications"); tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, notificationsTab)); if (selectedPage == string.Empty) { selectedPage = tabName; } } } if ((ucMyMessages == null) && DisplayMyMessages && ModuleEntryManager.IsModuleLoaded(ModuleEntry.MESSAGING)) { // Try to load the control dynamically (if available) ucMyMessages = Page.LoadUserControl("~/CMSModules/Messaging/Controls/MyMessages.ascx") as CMSAdminControl; if (ucMyMessages != null) { ucMyMessages.ID = "ucMyMessages"; plcOther.Controls.Add(ucMyMessages); // Set new tab tabName = messagesTab; activeTabs.Add(tabName); tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyMessages"); tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, messagesTab)); if (selectedPage == string.Empty) { selectedPage = tabName; } } } if ((ucMyFriends == null) && DisplayMyFriends && ModuleEntryManager.IsModuleLoaded(ModuleEntry.COMMUNITY) && friendsEnabled) { // Try to load the control dynamically (if available) ucMyFriends = Page.LoadUserControl("~/CMSModules/Friends/Controls/MyFriends.ascx") as CMSAdminControl; if (ucMyFriends != null) { ucMyFriends.ID = "ucMyFriends"; plcOther.Controls.Add(ucMyFriends); // Set new tab tabName = friendsTab; activeTabs.Add(tabName); tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyFriends"); tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, friendsTab)); if (selectedPage == string.Empty) { selectedPage = tabName; } } } if ((ucMyAllSubscriptions == null) && DisplayMySubscriptions) { // Try to load the control dynamically (if available) ucMyAllSubscriptions = Page.LoadUserControl("~/CMSModules/Membership/Controls/Subscriptions.ascx") as CMSAdminControl; if (ucMyAllSubscriptions != null) { // Set control ucMyAllSubscriptions.Visible = false; ucMyAllSubscriptions.SetValue("ShowBlogs", DisplayBlogs); ucMyAllSubscriptions.SetValue("ShowMessageBoards", DisplayMessageBoards); ucMyAllSubscriptions.SetValue("ShowNewsletters", DisplayNewsletters); ucMyAllSubscriptions.SetValue("ShowForums", DisplayForums); ucMyAllSubscriptions.SetValue("ShowReports", DisplayReports); ucMyAllSubscriptions.SetValue("sendconfirmationemail", SendConfirmationEmails); ucMyAllSubscriptions.ID = "ucMyAllSubscriptions"; plcOther.Controls.Add(ucMyAllSubscriptions); // Set new tab tabName = subscriptionsTab; activeTabs.Add(tabName); tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyAllSubscriptions"); tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, subscriptionsTab)); if (selectedPage == string.Empty) { selectedPage = tabName; } } } // My memberships if ((ucMyMemberships == null) && DisplayMyMemberships) { // Try to load the control dynamically ucMyMemberships = Page.LoadUserControl("~/CMSModules/Membership/Controls/MyMemberships.ascx") as CMSAdminControl; if (ucMyMemberships != null) { ucMyMemberships.SetValue("UserID", currentUser.UserID); if (!String.IsNullOrEmpty(MembershipsPagePath)) { ucMyMemberships.SetValue("BuyMembershipURL", DocumentURLProvider.GetUrl(MembershipsPagePath)); } plcOther.Controls.Add(ucMyMemberships); // Set new tab tabName = membershipsTab; activeTabs.Add(tabName); tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("myaccount.mymemberships"); tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, membershipsTab)); if (selectedPage == String.Empty) { selectedPage = tabName; } } } if ((ucMyCategories == null) && DisplayMyCategories) { // Try to load the control dynamically (if available) ucMyCategories = Page.LoadUserControl("~/CMSModules/Categories/Controls/Categories.ascx") as CMSAdminControl; if (ucMyCategories != null) { ucMyCategories.Visible = false; ucMyCategories.SetValue("DisplaySiteCategories", false); ucMyCategories.SetValue("DisplaySiteSelector", false); ucMyCategories.ID = "ucMyCategories"; plcOther.Controls.Add(ucMyCategories); // Set new tab tabName = categoriesTab; activeTabs.Add(tabName); tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyCategories"); tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, categoriesTab)); if (selectedPage == string.Empty) { selectedPage = tabName; } } } // Set CSS class pnlBody.CssClass = CssClass; // Get page URL page = QueryHelper.GetString(ParameterName, selectedPage); // Set controls visibility ucChangePassword.Visible = false; ucChangePassword.StopProcessing = true; if (ucMyAddresses != null) { ucMyAddresses.Visible = false; ucMyAddresses.StopProcessing = true; } if (ucMyOrders != null) { ucMyOrders.Visible = false; ucMyOrders.StopProcessing = true; } if (ucMyDetails != null) { ucMyDetails.Visible = false; ucMyDetails.StopProcessing = true; } if (ucMyCredit != null) { ucMyCredit.Visible = false; ucMyCredit.StopProcessing = true; } if (ucMyAllSubscriptions != null) { ucMyAllSubscriptions.Visible = false; ucMyAllSubscriptions.StopProcessing = true; ucMyAllSubscriptions.SetValue("CacheMinutes", CacheMinutes); } if (ucMyNotifications != null) { ucMyNotifications.Visible = false; ucMyNotifications.StopProcessing = true; } if (ucMyMessages != null) { ucMyMessages.Visible = false; ucMyMessages.StopProcessing = true; } if (ucMyFriends != null) { ucMyFriends.Visible = false; ucMyFriends.StopProcessing = true; } if (ucMyMemberships != null) { ucMyMemberships.Visible = false; ucMyMemberships.StopProcessing = true; } if (ucMyCategories != null) { ucMyCategories.Visible = false; ucMyCategories.StopProcessing = true; } tabMenu.SelectedTab = activeTabs.IndexOf(page); // Select current page switch (page) { case personalTab: if (myProfile != null) { // Get alternative form info AlternativeFormInfo afi = AlternativeFormInfoProvider.GetAlternativeFormInfo(AlternativeFormName); if (afi != null) { myProfile.StopProcessing = false; myProfile.Visible = true; myProfile.AllowEditVisibility = AllowEditVisibility; myProfile.AlternativeFormName = AlternativeFormName; } else { lblError.Text = String.Format(GetString("altform.formdoesntexists"), AlternativeFormName); lblError.Visible = true; myProfile.Visible = false; } } break; // My details tab case detailsTab: if (ucMyDetails != null) { ucMyDetails.Visible = true; ucMyDetails.StopProcessing = false; ucMyDetails.SetValue("Customer", customer); } break; // My addresses tab case addressesTab: if (ucMyAddresses != null) { ucMyAddresses.Visible = true; ucMyAddresses.StopProcessing = false; ucMyAddresses.SetValue("CustomerId", customerId); } break; // My orders tab case ordersTab: if (ucMyOrders != null) { ucMyOrders.Visible = true; ucMyOrders.StopProcessing = false; ucMyOrders.SetValue("CustomerId", customerId); ucMyOrders.SetValue("ShowOrderTrackingNumber", ShowOrderTrackingNumber); } break; // My credit tab case creditTab: if (ucMyCredit != null) { ucMyCredit.Visible = true; ucMyCredit.StopProcessing = false; ucMyCredit.SetValue("CustomerId", customerId); } break; // Password tab case passwordTab: ucChangePassword.Visible = true; ucChangePassword.StopProcessing = false; ucChangePassword.AllowEmptyPassword = AllowEmptyPassword; break; // Notification tab case notificationsTab: if (ucMyNotifications != null) { ucMyNotifications.Visible = true; ucMyNotifications.StopProcessing = false; ucMyNotifications.SetValue("UserId", currentUser.UserID); ucMyNotifications.SetValue("UnigridImageDirectory", UnigridImageDirectory); } break; // My messages tab case messagesTab: if (ucMyMessages != null) { ucMyMessages.Visible = true; ucMyMessages.StopProcessing = false; } break; // My friends tab case friendsTab: if (ucMyFriends != null) { ucMyFriends.Visible = true; ucMyFriends.StopProcessing = false; ucMyFriends.SetValue("UserID", currentUser.UserID); } break; // My subscriptions tab case subscriptionsTab: if (ucMyAllSubscriptions != null) { ucMyAllSubscriptions.Visible = true; ucMyAllSubscriptions.StopProcessing = false; ucMyAllSubscriptions.SetValue("userid", currentUser.UserID); ucMyAllSubscriptions.SetValue("siteid", CMSContext.CurrentSiteID); } break; // My memberships tab case membershipsTab: if (ucMyMemberships != null) { ucMyMemberships.Visible = true; ucMyMemberships.StopProcessing = false; } break; // My categories tab case categoriesTab: if (ucMyCategories != null) { ucMyCategories.Visible = true; ucMyCategories.StopProcessing = false; } break; } } else { // Hide control if current user is not authenticated Visible = false; } } }
/// <summary> /// Saves form layout. /// </summary> protected void SaveData() { bool saved = false; bool deleted = false; // Get form layout string layout = FormLayout; // Delete layout if editor is hidden if (!CustomLayoutEnabled) { deleted = LayoutIsSet; layout = null; } if (DataClassID > 0) { if (!IsAlternative) { DataClassInfo dci = DataClassInfoProvider.GetDataClass(DataClassID); CMSPage.EditedObject = dci; if (dci != null) { // Update dataclass form layout and save object dci.ClassFormLayout = layout; DataClassInfoProvider.SetDataClass(dci); saved = true; } } else { AlternativeFormInfo afi = AlternativeFormInfoProvider.GetAlternativeFormInfo(ObjectID); CMSPage.EditedObject = afi; if (afi != null) { // Update alternative form layout and save object afi.FormLayout = layout; AlternativeFormInfoProvider.SetAlternativeFormInfo(afi); saved = true; } } // Display info if successfully saved if (saved) { lblInfo.Visible = true; if (!deleted) { lblInfo.Text = GetString("general.changessaved"); } else { lblInfo.Text = GetString("DocumentType_Edit_Form.LayoutDeleted"); } } } else { CMSPage.EditedObject = null; } }
/// <summary> /// Fills list of available fields. /// </summary> protected void FillFieldsList() { FormInfo fi = null; FormFieldInfo[] visibleFields = null; DataClassInfo dci = DataClassInfoProvider.GetDataClass(DataClassID); if (dci != null) { // Load form definition string formDefinition = dci.ClassFormDefinition; if (IsAlternative) { // Get alternative form definition and merge if with the original one AlternativeFormInfo afi = AlternativeFormInfoProvider.GetAlternativeFormInfo(ObjectID); if (afi.FormCoupledClassID > 0) { // If coupled class is defined combine form definitions DataClassInfo coupledDci = DataClassInfoProvider.GetDataClass(afi.FormCoupledClassID); if (coupledDci != null) { formDefinition = FormHelper.MergeFormDefinitions(formDefinition, coupledDci.ClassFormDefinition, true); } } // Merge class and alternative form definitions formDefinition = FormHelper.MergeFormDefinitions(formDefinition, afi.FormDefinition); } fi = new FormInfo(formDefinition); // Get visible fields visibleFields = fi.GetFields(true, false); lstAvailableFields.Items.Clear(); if (FormType == FORMTYPE_DOCUMENT) { if (dci.ClassNodeNameSource == "") //if node name source is not set { lstAvailableFields.Items.Add(new ListItem(GetString("DocumentType_Edit_Form.DocumentName"), "DocumentName")); } } if (visibleFields != null) { // Add public visible fields to the list foreach (FormFieldInfo ffi in visibleFields) { lstAvailableFields.Items.Add(new ListItem(ffi.Name, ffi.Name)); } } if (FormType == FORMTYPE_DOCUMENT) { if (dci.ClassUsePublishFromTo) { lstAvailableFields.Items.Add(new ListItem(GetString("DocumentType_Edit_Form.DocumentPublishFrom"), "DocumentPublishFrom")); lstAvailableFields.Items.Add(new ListItem(GetString("DocumentType_Edit_Form.DocumentPublishTo"), "DocumentPublishTo")); } } lstAvailableFields.SelectedIndex = 0; } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { // Set default visibility pnlRegForm.Visible = true; lblCaptcha.ResourceString = "webparts_membership_registrationform.captcha"; // WAI validation lblCaptcha.AssociatedControlClientID = captchaElem.InputClientID; // Get alternative form info AlternativeFormInfo afi = AlternativeFormInfoProvider.GetAlternativeFormInfo(AlternativeForm); if (afi != null) { formUser.Data = new UserInfo(); formUser.FormInformation = FormHelper.GetFormInfo(AlternativeForm, true); formUser.AltFormInformation = afi; formUser.Visible = true; formUser.ValidationErrorMessage = RegistrationErrorMessage; formUser.IsLiveSite = true; formUser.UseColonBehindLabel = DisplayColons; formUser.DefaultFormLayout = FormLayout.ToEnum <FormLayoutEnum>(); formUser.DefaultFieldLayout = FieldLayout.ToEnum <FieldLayoutEnum>(); formUser.MessagesPlaceHolder = plcMess; formUser.InfoLabel = plcMess.InfoLabel; formUser.ErrorLabel = plcMess.ErrorLabel; formUser.OnAfterSave += formUser_OnAfterSave; // Reload form if not in PortalEngine environment and if post back if (StandAlone) { formUser.ReloadData(); } captchaElem.Visible = DisplayCaptcha; lblCaptcha.Visible = DisplayCaptcha; plcCaptcha.Visible = DisplayCaptcha; btnRegister.Text = ButtonText; btnRegister.AddCssClass(ButtonCSS); btnRegister.Click += btnRegister_Click; InfoLabel.CssClass = "EditingFormInfoLabel"; ErrorLabel.CssClass = "EditingFormErrorLabel ErrorLabel"; if (formUser != null) { // Set the live site context formUser.ControlContext.ContextName = CMS.Base.Web.UI.ControlContext.LIVE_SITE; } } else { ShowError(String.Format(GetString("altform.formdoesntexists"), AlternativeForm)); pnlRegForm.Visible = false; } } }
// Contains initialization code that is executed when the application starts protected override void OnInit() { base.OnInit(); // Custom Relationship Name logging since adhoc is disabled in staging by default (since usually tied to page type) RelationshipNameInfo.TYPEINFO.Events.Insert.After += RelationshipName_Insert_After; RelationshipNameInfo.TYPEINFO.Events.Update.After += RelationshipName_Update_After; RelationshipNameInfo.TYPEINFO.Events.Delete.After += RelationshipName_Delete_After; RelationshipNameSiteInfo.TYPEINFO.Events.Insert.After += RelationshipNameSiteInfo_Insert_After; RelationshipNameSiteInfo.TYPEINFO.Events.Delete.After += RelationshipNameSiteInfo_Delete_After; // Since normally a page is "Saved" (changed) when you handle ad-hoc relationships, must also handle triggering the update on the document RelationshipInfo.TYPEINFO.Events.Insert.After += Relationship_Insert_Or_Delete_After; RelationshipInfo.TYPEINFO.Events.Delete.After += Relationship_Insert_Or_Delete_After; // Add in events to handle Document-bound node categories, or adjust to synchronize manually if (DataHelper.GetNotEmpty(SettingsKeyInfoProvider.GetValue(new SettingsKeyName("NodeCategoryStagingMode")), "WithDocument") == "WithDocument") { // Similar to Relationships, a Node Category needs to touch the Node, however this really is touching the 'document' not the node, so must manually trigger TreeCategoryInfo.TYPEINFO.Events.Insert.After += TreeCategory_Insert_Or_Delete_After; TreeCategoryInfo.TYPEINFO.Events.Delete.After += TreeCategory_Insert_Or_Delete_After; // Need to add TreeCategories to document data set and then processes it since sadly isn't doing it automatically :( StagingEvents.LogTask.Before += LogTask_Before; StagingEvents.ProcessTask.After += ProcessTask_After; } else { // Add some custom logic to create a more readable Task Title StagingEvents.LogTask.Before += NonBindingLogTask_Before; // Handle object deletions, additions work but removals don't for node object relationships StagingEvents.ProcessTask.After += NonBindingNodeDocument_ProcessTask_After; } // Handle any tasks that need to be deleted due to originating from another server StagingEvents.LogTask.After += LogTask_After; // Also make sure that the foreign key exists for the class try { ConnectionHelper.ExecuteQuery("CMS.TreeCategory.EnsureForeignKeys", null); } catch (Exception ex) { EventLogProvider.LogException("RelationshipsExtended", "ErrorSettingForeignKeys", ex, additionalMessage: "Make sure the Query CMS.TreeCategory.EnsureForeignKey exists. IGNORE if you just installed the module as this will run before the class installs on the first application start after installation."); } // Registers "CustomNamespace" into the macro engine MacroContext.GlobalResolver.SetNamedSourceData("RelationshipsExtended", RelationshipsExtendedMacroNamespace.Instance); MacroContext.GlobalResolver.SetNamedSourceData("RelHelper", RelHelperMacroNamespace.Instance); MacroContext.GlobalResolver.SetNamedSourceData("RelEnums", EnumMacroEvaluator.EnumMacroObjects()); /* Check to make sure the 2 forms exist */ if (AlternativeFormInfoProvider.GetAlternativeFormInfo("cms.relationshipname.NewForm") == null) { int ClassID = DataClassInfoProvider.GetDataClassInfo("cms.relationshipname").ClassID; AlternativeFormInfo RelationshipNewForm = new AlternativeFormInfo() { FormClassID = ClassID, FormName = "NewForm", FormDisplayName = "New Form", FormDefinition = "<form version=\"2\"><field column=\"RelationshipNameID\" guid=\"47839bd6-f19c-4cfd-b67f-1ca754694d46\" /><field column=\"RelationshipDisplayName\" guid=\"6515b190-003a-44b6-b541-8814760de218\" /><field column=\"RelationshipName\" guid=\"42221f4a-30fa-47a6-bc80-3f99ee81f8a5\" /><field column=\"RelationshipAllowedObjects\" guid=\"2a02c9d5-f0f9-4a19-be8d-9a007f4464ac\" /><field column=\"RelationshipNameIsAdHoc\" guid=\"f1d3667d-77eb-47de-9ad0-5f22ad63e082\" visible=\"true\"><settings><controlname>CheckBoxControl</controlname></settings><properties><fieldcaption>Relationship Is AdHoc (Sortable)</fieldcaption><fielddescription>Must be true if you wish to use sorting.</fielddescription></properties></field><field column=\"RelationshipGUID\" guid=\"03ad948a-2bb7-44b2-b580-b05abf3a2a8b\" /><field column=\"RelationshipLastModified\" guid=\"ea7edf35-ed86-4cef-91c5-7bfdde27c389\" /><field column=\"ReltionshipSite\" guid=\"a733ba02-3675-481a-b586-b87c49e23268\" /></form>", FormHideNewParentFields = false, FormIsCustom = true }; AlternativeFormInfoProvider.SetAlternativeFormInfo(RelationshipNewForm); } if (AlternativeFormInfoProvider.GetAlternativeFormInfo("cms.relationshipname.EditForm") == null) { int ClassID = DataClassInfoProvider.GetDataClassInfo("cms.relationshipname").ClassID; AlternativeFormInfo RelationshipNewForm = new AlternativeFormInfo() { FormClassID = ClassID, FormName = "EditForm", FormDisplayName = "Edit Form", FormDefinition = "<form version=\"2\"><field column=\"RelationshipNameID\" guid=\"47839bd6-f19c-4cfd-b67f-1ca754694d46\" /><field column=\"RelationshipDisplayName\" guid=\"6515b190-003a-44b6-b541-8814760de218\" /><field column=\"RelationshipName\" guid=\"42221f4a-30fa-47a6-bc80-3f99ee81f8a5\" /><field column=\"RelationshipAllowedObjects\" guid=\"2a02c9d5-f0f9-4a19-be8d-9a007f4464ac\" /><field column=\"RelationshipNameIsAdHoc\" guid=\"f1d3667d-77eb-47de-9ad0-5f22ad63e082\" visible=\"true\"><settings><controlname>CheckBoxControl</controlname></settings><properties><fieldcaption>Relationship Is AdHoc (Sortable)</fieldcaption><fielddescription>Must be true if you wish to use sorting.</fielddescription></properties></field><field column=\"RelationshipGUID\" guid=\"03ad948a-2bb7-44b2-b580-b05abf3a2a8b\" /><field column=\"RelationshipLastModified\" guid=\"ea7edf35-ed86-4cef-91c5-7bfdde27c389\" /><field column=\"ReltionshipSite\" guid=\"a733ba02-3675-481a-b586-b87c49e23268\" /></form>", FormHideNewParentFields = false, FormIsCustom = true }; AlternativeFormInfoProvider.SetAlternativeFormInfo(RelationshipNewForm); } }