protected void Page_Load(object sender, EventArgs e) { TreeNode currentDocument = CMSContext.CurrentDocument; if (currentDocument != null) { // Get document type transformation string transformationName = currentDocument.NodeClassName + ".attachment"; TransformationInfo ti = TransformationInfoProvider.GetTransformation(transformationName); // If transformation not present, use default from the Root document type if (ti == null) { transformationName = "cms.root.attachment"; ti = TransformationInfoProvider.GetTransformation(transformationName); } if (ti == null) { throw new Exception("[DocumentAttachments]: Default transformation '" + transformationName + "' doesn't exist!"); } ucAttachments.TransformationName = transformationName; ucAttachments.SiteName = CMSContext.CurrentSiteName; ucAttachments.Path = currentDocument.NodeAliasPath; ucAttachments.CultureCode = currentDocument.DocumentCulture; ucAttachments.OrderBy = "AttachmentOrder, AttachmentName"; ucAttachments.PageSize = 0; ucAttachments.GetBinary = false; ucAttachments.CacheMinutes = SettingsKeyProvider.GetIntValue(CMSContext.CurrentSite + ".CMSCacheMinutes"); } }
/// <summary> /// Returns number of comments of given blog. /// </summary> /// <param name="postId">Post document id</param> /// <param name="postAliasPath">Post alias path</param> /// <param name="includingTrackbacks">Indicates if trackback comments should be included</param> public static int GetBlogCommentsCount(object postId, object postAliasPath, bool includingTrackbacks) { int docId = ValidationHelper.GetInteger(postId, 0); string aliasPath = ValidationHelper.GetString(postAliasPath, ""); CurrentUserInfo currentUser = CMSContext.CurrentUser; // There has to be the current site if (CMSContext.CurrentSite == null) { throw new Exception("[BlogFunctions.GetBlogCommentsCount]: There is no current site!"); } bool isOwner = false; // Is user authorized to manage comments? bool selectOnlyPublished = (CMSContext.ViewMode == ViewModeEnum.LiveSite); TreeNode blogNode = BlogHelper.GetParentBlog(aliasPath, CMSContext.CurrentSiteName, selectOnlyPublished); if (blogNode != null) { isOwner = (currentUser.UserID == ValidationHelper.GetInteger(blogNode.GetValue("NodeOwner"), 0)); } bool isUserAuthorized = (currentUser.IsAuthorizedPerResource("cms.blog", "Manage") || isOwner || BlogHelper.IsUserBlogModerator(currentUser.UserName, blogNode)); // Get post comments return(BlogCommentInfoProvider.GetPostCommentsCount(docId, !isUserAuthorized, isUserAuthorized, includingTrackbacks)); }
/// <summary> /// Log activity (subscribing) /// </summary> /// <param name="bsi"></param> private void LogActivity(BoardSubscriptionInfo bsi, BoardInfo bi) { string siteName = CMSContext.CurrentSiteName; if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || (bsi == null) || (bi == null) || !bi.BoardLogActivity || !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) || !ActivitySettingsHelper.MessageBoardSubscriptionEnabled(siteName)) { return; } TreeNode currentDoc = CMSContext.CurrentDocument; int contactId = ModuleCommands.OnlineMarketingGetCurrentContactID(); Dictionary <string, object> contactData = new Dictionary <string, object>(); contactData.Add("ContactEmail", bsi.SubscriptionEmail); ModuleCommands.OnlineMarketingUpdateContactFromExternalSource(contactData, false, contactId); var data = new ActivityData() { ContactID = contactId, SiteID = CMSContext.CurrentSiteID, Type = PredefinedActivityType.SUBSCRIPTION_MESSAGE_BOARD, TitleData = bi.BoardName, URL = URLHelper.CurrentRelativePath, NodeID = (currentDoc != null ? currentDoc.NodeID : 0), Culture = (currentDoc != null ? currentDoc.DocumentCulture : null), Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); }
/// <summary> /// Loads the data to the control. /// </summary> protected void LoadData() { SetContext(); string text = string.Empty; TreeNode node = null; if (Path == string.Empty) { node = CMSContext.CurrentDocument; } else { // Try to get data from cache using (CachedSection <TreeNode> cs = new CachedSection <TreeNode>(ref node, this.CacheMinutes, true, this.CacheItemName, "pagedtext", CacheHelper.GetBaseCacheKey(this.CheckPermissions, false), SiteName, Path, CultureCode, CombineWithDefaultCulture, SelectOnlyPublished)) { if (cs.LoadData) { // Ensure that the path is only for one single document Path = CMSContext.CurrentResolver.ResolvePath(Path.TrimEnd('%').TrimEnd('/')); node = TreeHelper.GetDocument(SiteName, Path, CultureCode, CombineWithDefaultCulture, null, SelectOnlyPublished, CheckPermissions, CMSContext.CurrentUser); // Prepare the cache dependency if (cs.Cached) { cs.CacheDependency = GetCacheDependency(); cs.Data = node; } } } } if ((node != null) && (ColumnName != string.Empty)) { text = ValidationHelper.GetString(node.GetValue(ColumnName), string.Empty); if (text != string.Empty) { textPager.TextSource = text; textPager.ReloadData(false); } else { Visible = false; } } else { Visible = false; } ReleaseContext(); }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); if (!IsCallback) { string action = QueryHelper.GetString("action", ""); switch (action.ToLower()) { case "movenode": case "movenodeposition": case "movenodefirst": { // Setup page title text and image CurrentMaster.Title.TitleText = GetString("dialogs.header.title.movedoc"); CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/titlemove.png"); } break; case "copynode": case "copynodeposition": case "copynodefirst": { // Setup page title text and image CurrentMaster.Title.TitleText = GetString("dialogs.header.title.copydoc"); CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/titlecopy.png"); } break; case "linknode": case "linknodeposition": case "linknodefirst": { // Setup page title text and image CurrentMaster.Title.TitleText = GetString("dialogs.header.title.linkdoc"); CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Content/Dialogs/titlelink.png"); } break; } TreeNode node = opDrag.Node; if (node != null) { string documentName = ValidationHelper.GetString(node.GetValue("DocumentLastVersionName"), node.DocumentName); CurrentMaster.Title.TitleText += " \"" + HTMLHelper.HTMLEncode(documentName) + "\""; } ((Panel)CurrentMaster.PanelBody.FindControl("pnlContent")).CssClass = string.Empty; } }
protected void Page_Load(object sender, EventArgs e) { ucAttachments = this.Page.LoadControl("~/CMSModules/Content/Controls/Attachments/AttachmentLightboxGallery.ascx") as CMSUserControl; ucAttachments.ID = "ctrlAttachments"; plcAttachmentLightBox.Controls.Add(ucAttachments); TreeNode currentDocument = CMSContext.CurrentDocument; if (currentDocument != null) { // Get document type transformation string transformationName = currentDocument.NodeClassName + ".AttachmentLightbox"; string selectedTransformationName = currentDocument.NodeClassName + ".AttachmentLightboxDetail"; TransformationInfo ti = TransformationInfoProvider.GetTransformation(transformationName); // If transformation not present, use default from the Root document type if (ti == null) { transformationName = "cms.root.AttachmentLightbox"; ti = TransformationInfoProvider.GetTransformation(transformationName); } if (ti == null) { throw new Exception("[DocumentAttachments]: Default transformation '" + transformationName + "' doesn't exist!"); } ti = TransformationInfoProvider.GetTransformation(selectedTransformationName); // If transformation not present, use default from the Root document type if (ti == null) { selectedTransformationName = "cms.root.AttachmentLightboxDetail"; ti = TransformationInfoProvider.GetTransformation(selectedTransformationName); } if (ti == null) { throw new Exception("[DocumentAttachments]: Default transformation '" + selectedTransformationName + "' doesn't exist!"); } ucAttachments.SetValue("TransformationName", transformationName); ucAttachments.SetValue("SelectedItemTransformationName", selectedTransformationName); ucAttachments.SetValue("SiteName", CMSContext.CurrentSiteName); ucAttachments.SetValue("Path", currentDocument.NodeAliasPath); ucAttachments.SetValue("CultureCode", currentDocument.DocumentCulture); ucAttachments.SetValue("OrderBy", "AttachmentOrder, AttachmentName"); ucAttachments.SetValue("PageSize", 0); ucAttachments.SetValue("GetBinary", false); ucAttachments.SetValue("CacheMinutes", SettingsKeyProvider.GetIntValue(CMSContext.CurrentSite + ".CMSCacheMinutes")); } }
protected void Page_Load(object sender, EventArgs e) { commentId = QueryHelper.GetInteger("commentID", 0); // Get comment info BlogCommentInfo commentObj = BlogCommentInfoProvider.GetBlogCommentInfo(commentId); EditedObject = commentObj; if (commentObj != null) { // Get parent blog TreeNode blogNode = BlogHelper.GetParentBlog(commentObj.CommentPostDocumentID, false); // Check site ID of edited blog if ((blogNode != null) && (blogNode.NodeSiteID != CMSContext.CurrentSiteID)) { EditedObject = null; } bool isAuthorized = BlogHelper.IsUserAuthorizedToManageComments(blogNode); // Check "manage" permission if (!isAuthorized) { RedirectToAccessDenied("cms.blog", "Manage"); } ctrlCommentEdit.CommentId = commentId; } btnOk.Click += btnOk_Click; btnOk.Text = GetString("General.OK"); btnOk.ValidationGroup = ctrlCommentEdit.ValidationGroup; ctrlCommentEdit.IsLiveSite = false; ctrlCommentEdit.OnAfterCommentSaved += new OnAfterCommentSavedEventHandler(ctrlCommentEdit_OnAfterCommentSaved); CurrentMaster.Title.TitleText = GetString("Blog.CommentEdit.Title"); CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Blog_Comment/object.png"); }
/// <summary> /// Helper method, set authentication cookie and redirect to return URL or default page. /// </summary> /// <param name="ui">User info</param> private void SetAuthCookieAndRedirect(UserInfo ui) { // Create autentification cookie if (ui.Enabled) { UserInfoProvider.SetAuthCookieWithUserData(ui.UserName, true, Session.Timeout, new string[] { "openidlogin" }); // Log activity string siteName = CMSContext.CurrentSiteName; if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) && ActivitySettingsHelper.UserLoginEnabled(siteName)) { int contactId = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui); ActivityLogHelper.UpdateContactLastLogon(contactId); if (ActivitySettingsHelper.ActivitiesEnabledForThisUser(ui)) { TreeNode currentDoc = CMSContext.CurrentDocument; ActivityLogProvider.LogLoginActivity(contactId, ui, URLHelper.CurrentRelativePath, currentDoc.NodeID, siteName, CMSContext.Campaign, currentDoc.DocumentCulture); } } string returnUrl = QueryHelper.GetString("returnurl", null); // Redirect to ReturnURL if (!String.IsNullOrEmpty(returnUrl)) { URLHelper.Redirect(ResolveUrl(HttpUtility.UrlDecode(returnUrl))); } // Redirect to default page else if (!String.IsNullOrEmpty(this.DefaultTargetUrl)) { URLHelper.Redirect(ResolveUrl(this.DefaultTargetUrl)); } // Otherwise refresh current page else { URLHelper.Redirect(URLRewriter.CurrentURL); } } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing rptRecentPosts.StopProcessing = true; } else { rptRecentPosts.ControlContext = ControlContext; // Get current page info PageInfo currentPage = CMSContext.CurrentPageInfo; // If recent posts is empty if (PathToRecentPosts == "") { // Get current parent blog TreeNode blogNode = BlogHelper.GetParentBlog(currentPage.NodeAliasPath, CMSContext.CurrentSiteName, false); // Set repeater path in accordance to blog node alias path if (blogNode != null) { rptRecentPosts.Path = blogNode.NodeAliasPath + "/%"; } } // If recent posts not empty else { rptRecentPosts.Path = PathToRecentPosts; } // Set repeater properties rptRecentPosts.TransformationName = TransformationName; rptRecentPosts.SelectTopN = SelectTopN; rptRecentPosts.HideControlForZeroRows = HideControlForZeroRows; rptRecentPosts.ZeroRowsText = ZeroRowsText; rptRecentPosts.CacheDependencies = CacheDependencies; } }
/// <summary> /// Process valid values of this step. /// </summary> public override bool ProcessStep() { if (this.plcAccount.Visible) { string siteName = CMSContext.CurrentSiteName; // Existing account if (radSignIn.Checked) { // Authenticate user UserInfo ui = UserInfoProvider.AuthenticateUser(txtUsername.Text.Trim(), txtPsswd1.Text, CMSContext.CurrentSiteName, false); if (ui == null) { lblError.Text = GetString("ShoppingCartCheckRegistration.LoginFailed"); lblError.Visible = true; return(false); } // Sign in customer with existing account CMSContext.AuthenticateUser(ui.UserName, false); // Registered user has already started shopping as anonymous user -> Drop his stored shopping cart ShoppingCartInfoProvider.DeleteShoppingCartInfo(ui.UserID, siteName); // Assign current user to the current shopping cart this.ShoppingCartInfoObj.UserInfoObj = ui; // Save changes to database if (!this.ShoppingCartControl.IsInternalOrder) { ShoppingCartInfoProvider.SetShoppingCartInfo(this.ShoppingCartInfoObj); } // Log "login" activity if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName)) { this.ContactID = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui); ActivityLogHelper.UpdateContactLastLogon(this.ContactID); if (ActivitySettingsHelper.ActivitiesEnabledForThisUser(ui) && ActivitySettingsHelper.UserLoginEnabled(siteName)) { TreeNode currentDoc = CMSContext.CurrentDocument; int nodeId = (currentDoc != null ? currentDoc.NodeID : 0); string culture = (currentDoc != null ? currentDoc.DocumentCulture : null); ActivityLogProvider.LogLoginActivity(this.ContactID, ui, URLHelper.CurrentRelativePath, nodeId, siteName, ui.UserCampaign, culture); } } LoadStep(true); // Return false to get to Edit customer page return(false); } // New registration else if (radNewReg.Checked) { txtEmail2.Text = txtEmail2.Text.Trim(); pnlCompanyAccount1.Visible = chkCorporateBody.Checked; // Check if user exists UserInfo ui = UserInfoProvider.GetUserInfo(txtEmail2.Text); if (ui != null) { lblError.Visible = true; lblError.Text = GetString("ShoppingCartUserRegistration.ErrorUserExists"); return(false); } // Check all sites where user will be assigned string checkSites = (String.IsNullOrEmpty(this.ShoppingCartControl.AssignToSites)) ? CMSContext.CurrentSiteName : this.ShoppingCartControl.AssignToSites; if (!UserInfoProvider.IsEmailUnique(txtEmail2.Text.Trim(), checkSites, 0)) { lblError.Visible = true; lblError.Text = GetString("UserInfo.EmailAlreadyExist"); return(false); } // Create new customer and user account and sign in // User ui = new UserInfo(); ui.UserName = txtEmail2.Text.Trim(); ui.Email = txtEmail2.Text.Trim(); ui.FirstName = txtFirstName1.Text.Trim(); ui.LastName = txtLastName1.Text.Trim(); ui.FullName = ui.FirstName + " " + ui.LastName; ui.Enabled = true; ui.UserIsGlobalAdministrator = false; ui.UserURLReferrer = CMSContext.CurrentUser.URLReferrer; ui.UserCampaign = CMSContext.Campaign; ui.UserSettings.UserRegistrationInfo.IPAddress = HTTPHelper.UserHostAddress; ui.UserSettings.UserRegistrationInfo.Agent = HttpContext.Current.Request.UserAgent; int nodeId = 0; string culture = null; try { UserInfoProvider.SetPassword(ui, passStrength.Text); string[] siteList; // If AssignToSites field set if (!String.IsNullOrEmpty(this.ShoppingCartControl.AssignToSites)) { siteList = this.ShoppingCartControl.AssignToSites.Split(';'); } else // If not set user current site { siteList = new string[] { siteName }; } foreach (string site in siteList) { UserInfoProvider.AddUserToSite(ui.UserName, site); // Add user to roles if (this.ShoppingCartControl.AssignToRoles != "") { AssignUserToRoles(ui.UserName, this.ShoppingCartControl.AssignToRoles, site); } } // Log registered user AnalyticsHelper.LogRegisteredUser(siteName, ui); // Log "user registered" activity if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) && ActivitySettingsHelper.ActivitiesEnabledForThisUser(ui) && ActivitySettingsHelper.UserRegistrationEnabled(siteName)) { TreeNode currentDoc = CMSContext.CurrentDocument; this.ContactID = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui); ModuleCommands.OnlineMarketingUpdateContactFromExternalData(ui, this.ContactID); nodeId = (currentDoc != null ? currentDoc.NodeID : 0); culture = (currentDoc != null ? currentDoc.DocumentCulture : null); ActivityLogProvider.LogRegistrationActivity(this.ContactID, ui, URLHelper.CurrentRelativePath, nodeId, siteName, ui.UserCampaign, culture); } } catch (Exception ex) { lblError.Visible = true; lblError.Text = ex.Message; return(false); } // Customer CustomerInfo ci = new CustomerInfo(); ci.CustomerFirstName = this.txtFirstName1.Text.Trim(); ci.CustomerLastName = this.txtLastName1.Text.Trim(); ci.CustomerEmail = this.txtEmail2.Text.Trim(); ci.CustomerCompany = ""; ci.CustomerOrganizationID = ""; ci.CustomerTaxRegistrationID = ""; if (chkCorporateBody.Checked) { ci.CustomerCompany = this.txtCompany1.Text.Trim(); if (mShowOrganizationIDField) { ci.CustomerOrganizationID = this.txtOrganizationID.Text.Trim(); } if (mShowTaxRegistrationIDField) { ci.CustomerTaxRegistrationID = this.txtTaxRegistrationID.Text.Trim(); } } ci.CustomerUserID = ui.UserID; ci.CustomerSiteID = 0; ci.CustomerEnabled = true; ci.CustomerCreated = DateTime.Now; CustomerInfoProvider.SetCustomerInfo(ci); // Track successful registration conversion string name = this.ShoppingCartControl.RegistrationTrackConversionName; ECommerceHelper.TrackRegistrationConversion(this.ShoppingCartInfoObj.SiteName, name); // Log "customer registration" activity and update profile if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) && ActivitySettingsHelper.ActivitiesEnabledForThisUser(ui) && ActivitySettingsHelper.CustomerRegistrationEnabled(siteName)) { if (this.ContactID <= 0) { this.ContactID = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui); } ModuleCommands.OnlineMarketingUpdateContactFromExternalData(ci, this.ContactID); this.ShoppingCartControl.TrackActivityCustomerRegistration(ci, ui, this.ContactID, siteName, URLHelper.CurrentRelativePath); } // Sign in if (ui.UserEnabled) { CMSContext.AuthenticateUser(ui.UserName, false); this.ShoppingCartInfoObj.UserInfoObj = ui; // Log "login" activity if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName)) { this.ContactID = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui); ActivityLogHelper.UpdateContactLastLogon(this.ContactID); if (ActivitySettingsHelper.ActivitiesEnabledForThisUser(ui) && ActivitySettingsHelper.UserLoginEnabled(siteName)) { if (nodeId <= 0) { TreeNode currentDoc = CMSContext.CurrentDocument; nodeId = (currentDoc != null ? currentDoc.NodeID : 0); culture = (currentDoc != null ? currentDoc.DocumentCulture : null); } ActivityLogProvider.LogLoginActivity(this.ContactID, ui, URLHelper.CurrentRelativePath, nodeId, siteName, ui.UserCampaign, culture); } } } this.ShoppingCartInfoObj.ShoppingCartCustomerID = ci.CustomerID; // Send new registration notification email if (this.ShoppingCartControl.SendNewRegistrationNotificationToAddress != "") { SendRegistrationNotification(ui); } } // Anonymous customer else if (radAnonymous.Checked) { CustomerInfo ci = null; if (this.ShoppingCartInfoObj.ShoppingCartCustomerID > 0) { // Update existing customer account ci = CustomerInfoProvider.GetCustomerInfo(this.ShoppingCartInfoObj.ShoppingCartCustomerID); } if (ci == null) { // Create new customer account ci = new CustomerInfo(); } ci.CustomerFirstName = this.txtFirstName2.Text.Trim(); ci.CustomerLastName = this.txtLastName2.Text.Trim(); ci.CustomerEmail = this.txtEmail3.Text.Trim(); ci.CustomerCompany = ""; ci.CustomerOrganizationID = ""; ci.CustomerTaxRegistrationID = ""; ci.CustomerCompany = this.txtCompany2.Text.Trim(); if (mShowOrganizationIDField) { ci.CustomerOrganizationID = this.txtOrganizationID2.Text.Trim(); } if (mShowTaxRegistrationIDField) { ci.CustomerTaxRegistrationID = this.txtTaxRegistrationID2.Text.Trim(); } ci.CustomerEnabled = true; ci.CustomerCreated = DateTime.Now; ci.CustomerSiteID = CMSContext.CurrentSiteID; CustomerInfoProvider.SetCustomerInfo(ci); // Log "customer registration" activity if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) && ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) && ActivitySettingsHelper.CustomerRegistrationEnabled(siteName)) { this.ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID(); this.ShoppingCartControl.TrackActivityCustomerRegistration(ci, CMSContext.CurrentUser, this.ContactID, siteName, URLHelper.CurrentRelativePath); } // Assign customer to shoppingcart this.ShoppingCartInfoObj.ShoppingCartCustomerID = ci.CustomerID; } else { return(false); } } else { // Save the customer data bool newCustomer = false; CustomerInfo ci = CustomerInfoProvider.GetCustomerInfoByUserID(this.ShoppingCartControl.UserInfo.UserID); if (ci == null) { ci = new CustomerInfo(); ci.CustomerUserID = this.ShoppingCartControl.UserInfo.UserID; ci.CustomerSiteID = 0; ci.CustomerEnabled = true; newCustomer = true; } // Old email address string oldEmail = ci.CustomerEmail.ToLower(); ci.CustomerFirstName = this.txtEditFirst.Text.Trim(); ci.CustomerLastName = this.txtEditLast.Text.Trim(); ci.CustomerEmail = this.txtEditEmail.Text.Trim(); pnlCompanyAccount2.Visible = chkEditCorpBody.Checked; ci.CustomerCompany = ""; ci.CustomerOrganizationID = ""; ci.CustomerTaxRegistrationID = ""; if (chkEditCorpBody.Checked) { ci.CustomerCompany = this.txtEditCompany.Text.Trim(); if (mShowOrganizationIDField) { ci.CustomerOrganizationID = this.txtEditOrgID.Text.Trim(); } if (mShowTaxRegistrationIDField) { ci.CustomerTaxRegistrationID = this.txtEditTaxRegID.Text.Trim(); } } // Update customer data CustomerInfoProvider.SetCustomerInfo(ci); // Update corresponding user email when required if (oldEmail != ci.CustomerEmail.ToLower()) { UserInfo user = UserInfoProvider.GetUserInfo(ci.CustomerUserID); if (user != null) { user.Email = ci.CustomerEmail; UserInfoProvider.SetUserInfo(user); } } // Log "customer registration" activity and update contact profile string siteName = CMSContext.CurrentSiteName; if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) && ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) && ActivitySettingsHelper.CustomerRegistrationEnabled(siteName)) { this.ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID(); ModuleCommands.OnlineMarketingUpdateContactFromExternalData(ci, this.ContactID); if (newCustomer) { this.ShoppingCartControl.TrackActivityCustomerRegistration(ci, CMSContext.CurrentUser, this.ContactID, siteName, URLHelper.CurrentRelativePath); } } // Set the shopping cart customer ID this.ShoppingCartInfoObj.ShoppingCartCustomerID = ci.CustomerID; } try { if (!this.ShoppingCartControl.IsInternalOrder) { ShoppingCartInfoProvider.SetShoppingCartInfo(this.ShoppingCartInfoObj); } return(true); } catch { return(false); } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { this.Visible = false; } else { if (QueryHelper.GetInteger("logout", 0) > 0) { // Sign out from CMS FormsAuthentication.SignOut(); CMSContext.ClearShoppingCart(); CMSContext.CurrentUser = null; Response.Cache.SetNoStore(); URLHelper.Redirect(URLHelper.RemoveParameterFromUrl(URLHelper.CurrentURL, "logout")); return; } string currentSiteName = CMSContext.CurrentSiteName; if (!String.IsNullOrEmpty(currentSiteName) && SettingsKeyProvider.GetBoolValue(currentSiteName + ".CMSEnableFacebookConnect")) { // Check Facebook Connect settings if (!FacebookConnectHelper.FacebookIsAvailable(currentSiteName)) { // Display warning message in "Design mode" if (DisplayMessage()) { return; } this.Visible = false; return; } // Try to retrieve return URL from query string returnUrl = QueryHelper.GetString("returnurl", null); // Init Facebook Connect if (this.Page is ContentPage) { // Adding XML namespace ((ContentPage)this.Page).XmlNamespace = FacebookConnectHelper.GetFacebookXmlNamespace(); } // Init FB connect ltlScript.Text = FacebookConnectHelper.GetFacebookInitScriptForSite(currentSiteName); // Return URL string currentUrl = URLHelper.AddParameterToUrl(URLHelper.CurrentURL, "logout", "1"); string additionalScript = "window.location.href=" + ScriptHelper.GetString(URLHelper.GetAbsoluteUrl(currentUrl)) + "; return false;"; // Logout script for FB connect string logoutScript = FacebookConnectHelper.GetFacebookLogoutScriptForSignOut(URLHelper.CurrentURL, FacebookConnectHelper.GetFacebookApiKey(currentSiteName), additionalScript); string facebookUserId = ""; bool facebookCookiesValid = FacebookConnectHelper.GetFacebookSessionInfo(currentSiteName, out facebookUserId) == FacebookValidationEnum.ValidSignature; // If user is already authenticated if (CMSContext.CurrentUser.IsAuthenticated()) { // Is user logged in using Facebook Connect? if (!facebookCookiesValid || ((CMSContext.CurrentUser.UserSettings != null) && (CMSContext.CurrentUser.UserSettings.UserFacebookID != facebookUserId))) { // no, user is not logged in by Facebook Connect logoutScript = additionalScript; } // Hide Facebook Connect button plcFBButton.Visible = false; // If signout should be visible and user has FacebookID registered if (ShowSignOut && !String.IsNullOrEmpty(CMSContext.CurrentUser.UserSettings.UserFacebookID)) { // If only text is set use text/button link if (!String.IsNullOrEmpty(SignOutText)) { // Button link if (ShowAsButton) { btnSignOut.OnClientClick = logoutScript; btnSignOut.Text = SignOutText; btnSignOut.Visible = true; } // Text link else { lnkSignOutLink.Text = SignOutText; lnkSignOutLink.Visible = true; lnkSignOutLink.Attributes.Add("onclick", logoutScript); lnkSignOutLink.Attributes.Add("style", "cursor:pointer;"); } } // Image link else { string signOutImageUrl = SignOutImageURL; // Use default image if none is specified if (String.IsNullOrEmpty(signOutImageUrl)) { signOutImageUrl = GetImageUrl("Others/FacebookConnect/signout.gif"); } imgSignOut.ImageUrl = ResolveUrl(signOutImageUrl); imgSignOut.Visible = true; imgSignOut.AlternateText = GetString("webparts_membership_signoutbutton.signout"); lnkSignOutImageBtn.Visible = true; lnkSignOutImageBtn.Attributes.Add("onclick", logoutScript); lnkSignOutImageBtn.Attributes.Add("style", "cursor:pointer;"); } } else { Visible = false; } } // Sign In else { if ((QueryHelper.GetInteger(CONFIRMATION_URLPARAMETER, 0) > 0) && facebookCookiesValid) { if (!String.IsNullOrEmpty(facebookUserId)) { UserInfo ui = UserInfoProvider.GetUserInfoByFacebookConnectID(facebookUserId); // Claimed Facebook ID is in DB if (ui != null) { // Login existing user if ((ui != null) && ui.Enabled) { // Ban IP addresses which are blocked for login BannedIPInfoProvider.CheckIPandRedirect(currentSiteName, BanControlEnum.Login); // Create autentification cookie UserInfoProvider.SetAuthCookieWithUserData(ui.UserName, true, Session.Timeout, new string[] { "facebooklogon" }); UserInfoProvider.SetPreferredCultures(ui); // Log activity if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(currentSiteName) && ActivitySettingsHelper.UserLoginEnabled(currentSiteName)) { int contactId = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui); ActivityLogHelper.UpdateContactLastLogon(contactId); if (ActivitySettingsHelper.ActivitiesEnabledForThisUser(ui)) { TreeNode currDoc = CMSContext.CurrentDocument; ActivityLogProvider.LogLoginActivity(contactId, ui, URLHelper.CurrentRelativePath, currDoc.NodeID, currentSiteName, CMSContext.Campaign, currDoc.DocumentCulture); } } // Redirect user if (String.IsNullOrEmpty(returnUrl)) { returnUrl = URLHelper.RemoveParameterFromUrl(URLHelper.CurrentURL, CONFIRMATION_URLPARAMETER); } URLHelper.Redirect(returnUrl); } // Otherwise is user disabled else { lblError.Text = GetString("membership.userdisabled"); lblError.Visible = true; } } // Claimed Facebook ID not found = save new user else { // Check whether additional user info page is set string additionalInfoPage = SettingsKeyProvider.GetStringValue(currentSiteName + ".CMSRequiredFacebookPage").Trim(); // No page set, user can be created if (String.IsNullOrEmpty(additionalInfoPage)) { // Register new user string error = null; ui = UserInfoProvider.AuthenticateFacebookConnectUser(facebookUserId, currentSiteName, false, true, ref error); // If user was found or successfuly created if (ui != null) { // If user is enabled if (ui.Enabled) { // Create authentification cookie UserInfoProvider.SetAuthCookieWithUserData(ui.UserName, true, Session.Timeout, new string[] { "facebooklogon" }); // Log activity if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(currentSiteName) && ActivitySettingsHelper.UserLoginEnabled(currentSiteName)) { int contactId = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui); ActivityLogHelper.UpdateContactLastLogon(contactId); if (ActivitySettingsHelper.ActivitiesEnabledForThisUser(ui)) { TreeNode currDoc = CMSContext.CurrentDocument; ActivityLogProvider.LogLoginActivity(contactId, ui, URLHelper.CurrentRelativePath, currDoc.NodeID, currentSiteName, CMSContext.Campaign, currDoc.DocumentCulture); } } } // Send registration e-mails // E-mail confirmation is not required as user already provided confirmation by successful login using Facebook connect UserInfoProvider.SendRegistrationEmails(ui, null, null, false, false); // Notify administrator if (this.NotifyAdministrator && !String.IsNullOrEmpty(this.FromAddress) && !String.IsNullOrEmpty(this.ToAddress)) { UserInfoProvider.NotifyAdministrator(ui, this.FromAddress, this.ToAddress); } // Log registration into analytics UserInfoProvider.TrackUserRegistration(this.TrackConversionName, this.ConversionValue, currentSiteName, ui); // Log activity if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(currentSiteName) && ActivitySettingsHelper.ActivitiesEnabledForThisUser(ui) && ActivitySettingsHelper.UserRegistrationEnabled(currentSiteName)) { int contactId = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui); ModuleCommands.OnlineMarketingUpdateContactFromExternalData(ui, contactId); TreeNode currDoc = CMSContext.CurrentDocument; ActivityLogProvider.LogRegistrationActivity(contactId, ui, URLHelper.CurrentRelativePath, currDoc.NodeID, currentSiteName, CMSContext.Campaign, currDoc.DocumentCulture); } } // Redirect when authentication was succesfull if (String.IsNullOrEmpty(error)) { if (!String.IsNullOrEmpty(returnUrl)) { URLHelper.Redirect(URLHelper.GetAbsoluteUrl(returnUrl)); } else { URLHelper.Redirect(URLHelper.RemoveParameterFromUrl(URLHelper.CurrentURL, CONFIRMATION_URLPARAMETER)); } } // Display error otherwise else { lblError.Text = error; lblError.Visible = true; } } // Additional information page is set else { // Store user object in session for additional info page SessionHelper.SetValue(SESSION_NAME_USERDATA, facebookUserId); // Redirect to additional info page string targetURL = URLHelper.GetAbsoluteUrl(additionalInfoPage); if (!String.IsNullOrEmpty(returnUrl)) { // Add return URL to parameter targetURL = URLHelper.AddParameterToUrl(targetURL, "returnurl", HttpUtility.UrlEncode(returnUrl)); } URLHelper.Redirect(targetURL); } } } } } } else { // Show warning message in "Design mode" this.Visible = DisplayMessage(); } } }
/// <summary> /// Page load. /// </summary> protected void Page_Load(object sender, EventArgs e) { // Initialize control directUpload.Form = Form; directUpload.OnUploadFile += Form.RaiseOnUploadFile; directUpload.OnDeleteFile += Form.RaiseOnDeleteFile; directUpload.CheckPermissions = false; if (this.FieldInfo != null) { directUpload.GUIDColumnName = this.FieldInfo.Name; directUpload.AllowDelete = this.FieldInfo.AllowEmpty; } // Set allowed extensions string extensions = ValidationHelper.GetString(GetValue("extensions"), null); string allowedExtensions = ValidationHelper.GetString(GetValue("allowed_extensions"), null); if (extensions == "custom") { directUpload.AllowedExtensions = !String.IsNullOrEmpty(allowedExtensions) ? allowedExtensions : ""; } // Set image auto resize configuration if (this.FieldInfo != null) { int width = 0; int height = 0; int maxSideSize = 0; ImageHelper.GetAutoResizeDimensions(FieldInfo.Settings, CMSContext.CurrentSiteName, out width, out height, out maxSideSize); directUpload.ResizeToWidth = width; directUpload.ResizeToHeight = height; directUpload.ResizeToMaxSideSize = maxSideSize; } // Set control properties from parent Form if (Form != null) { // Get node TreeNode node = (TreeNode)Form.EditedObject; // Insert mode if ((Form.Mode == FormModeEnum.Insert) || (Form.Mode == FormModeEnum.InsertNewCultureVersion)) { directUpload.FormGUID = Form.FormGUID; if ((Form.ParentObject != null) && (Form.ParentObject is TreeNode)) { directUpload.NodeParentNodeID = ((TreeNode)Form.ParentObject).NodeID; } else if (node != null) { directUpload.NodeParentNodeID = node.NodeParentID; } if (node != null) { directUpload.NodeClassName = node.NodeClassName; directUpload.SiteName = node.NodeSiteName; // Set document version history if (Form.Mode == FormModeEnum.InsertNewCultureVersion) { // Set document version history ID directUpload.VersionHistoryID = node.DocumentCheckedOutVersionHistoryID; directUpload.SiteName = node.NodeSiteName; } } } // Editing existing node else if (node != null) { // Set appropriate control settings directUpload.DocumentID = node.DocumentID; directUpload.NodeParentNodeID = node.NodeParentID; directUpload.NodeClassName = node.NodeClassName; directUpload.SiteName = node.NodeSiteName; // Get the node workflow WorkflowManager wm = new WorkflowManager(node.TreeProvider); WorkflowInfo wi = wm.GetNodeWorkflow(node); if (wi != null) { // Set document version history ID directUpload.VersionHistoryID = node.DocumentCheckedOutVersionHistoryID; } } } // Set style properties of control if (!String.IsNullOrEmpty(ControlStyle)) { directUpload.Attributes.Add("style", ControlStyle); this.ControlStyle = null; } if (!String.IsNullOrEmpty(CssClass)) { directUpload.CssClass = CssClass; this.CssClass = null; } CheckFieldEmptiness = false; }
/// <summary> /// Handles btnOkNew click, creates new user and joins it with openID token. /// </summary> protected void btnOkNew_Click(object sender, EventArgs e) { if ((openIDhelper != null) && (openIDhelper.GetResponseObject() != null)) { // Validate entered values string errorMessage = new Validator().IsRegularExp(txtUserNameNew.Text, "^([a-zA-Z0-9_\\-\\.@]+)$", GetString("mem.openid.fillcorrectusername")) .IsEmail(txtEmail.Text, GetString("mem.openid.fillvalidemail")).Result; string siteName = CMSContext.CurrentSiteName; string password = passStrength.Text; // If password is enabled to set, check it if (plcPasswordNew.Visible && (errorMessage == String.Empty)) { if (password == String.Empty) { errorMessage = GetString("mem.liveid.specifyyourpass"); } else if (password != txtConfirmPassword.Text.Trim()) { errorMessage = GetString("webparts_membership_registrationform.passwordonotmatch"); } // Check policy if (!passStrength.IsValid()) { errorMessage = UserInfoProvider.GetPolicyViolationMessage(CMSContext.CurrentSiteName); } } // Check whether email is unique if it is required if (string.IsNullOrEmpty(errorMessage) && !UserInfoProvider.IsEmailUnique(txtEmail.Text.Trim(), siteName, 0)) { errorMessage = GetString("UserInfo.EmailAlreadyExist"); } // Check reserved names if (string.IsNullOrEmpty(errorMessage) && UserInfoProvider.NameIsReserved(siteName, txtUserNameNew.Text.Trim())) { errorMessage = GetString("Webparts_Membership_RegistrationForm.UserNameReserved").Replace("%%name%%", HTMLHelper.HTMLEncode(txtUserNameNew.Text.Trim())); } if (string.IsNullOrEmpty(errorMessage)) { // Check if user with given username already exists UserInfo ui = UserInfoProvider.GetUserInfo(txtUserNameNew.Text.Trim()); // User with given username is already registered if (ui != null) { plcError.Visible = true; lblError.Text = GetString("mem.openid.usernameregistered"); } else { string error = this.DisplayMessage; // Register new user ui = UserInfoProvider.AuthenticateOpenIDUser(openIDhelper.ClaimedIdentifier, ValidationHelper.GetString(SessionHelper.GetValue(SESSION_NAME_URL), null), siteName, true, false, ref error); this.DisplayMessage = error; // If user successfuly created if (ui != null) { // Set additional information ui.UserName = ui.UserNickName = ui.FullName = txtUserNameNew.Text.Trim(); ui.Email = txtEmail.Text; // Load values submited by OpenID provider // Load date of birth if (openIDhelper.BirthDate != DateTime.MinValue) { ui.UserSettings.UserDateOfBirth = openIDhelper.BirthDate; } // Load default country if (openIDhelper.Culture != null) { ui.PreferredCultureCode = openIDhelper.Culture.Name; } // Nick name if (!String.IsNullOrEmpty(openIDhelper.Nickname)) { ui.UserSettings.UserNickName = openIDhelper.Nickname; } // User gender if (openIDhelper.UserGender != null) { ui.UserSettings.UserGender = (int)openIDhelper.UserGender; } UserInfoProvider.SetUserInfo(ui); // Set password if (plcPasswordNew.Visible) { UserInfoProvider.SetPassword(ui, password); // If user can choose password then is not considered external(external user can't login in common way) ui.IsExternal = false; } // Additional information which was provided by OpenID provider to user account // Birth date if (openIDhelper.BirthDate != DateTime.MinValue) { ui.UserSettings.UserDateOfBirth = openIDhelper.BirthDate; } // Full name if (!String.IsNullOrEmpty(openIDhelper.FullName)) { ui.FullName = openIDhelper.FullName; } // Nick name if (!String.IsNullOrEmpty(openIDhelper.Nickname)) { ui.UserNickName = openIDhelper.Nickname; } // Set user UserInfoProvider.SetUserInfo(ui); // Clear used session SessionHelper.Remove(SESSION_NAME_URL); SessionHelper.Remove(SESSION_NAME_USERDATA); UserInfoProvider.SendRegistrationEmails(ui, this.ApprovalPage, password, true, this.SendWelcomeEmail); // Notify administrator bool requiresConfirmation = SettingsKeyProvider.GetBoolValue(siteName + ".CMSRegistrationEmailConfirmation"); if (!requiresConfirmation && this.NotifyAdministrator && (this.FromAddress != String.Empty) && (this.ToAddress != String.Empty)) { UserInfoProvider.NotifyAdministrator(ui, this.FromAddress, this.ToAddress); } // Log registration into analytics UserInfoProvider.TrackUserRegistration(this.TrackConversionName, this.ConversionValue, siteName, ui); // Log activity if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) && ActivitySettingsHelper.UserRegistrationEnabled(siteName) && ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser)) { int contactId = ModuleCommands.OnlineMarketingGetCurrentContactID(); ModuleCommands.OnlineMarketingUpdateContactFromExternalData(ui, contactId); TreeNode currentDoc = CMSContext.CurrentDocument; ActivityLogProvider.LogRegistrationActivity(contactId, ui, URLHelper.CurrentRelativePath, currentDoc.NodeID, siteName, CMSContext.Campaign, currentDoc.DocumentCulture); } // Set authentication cookie and redirect to page SetAuthCookieAndRedirect(ui); if (!String.IsNullOrEmpty(this.DisplayMessage)) { lblInfo.Visible = true; lblInfo.Text = this.DisplayMessage; plcForm.Visible = false; } else { URLHelper.Redirect(ResolveUrl("~/Default.aspx")); } } } } // Validation failed - display error message else { lblError.Text = errorMessage; plcError.Visible = true; } } }
/// <summary> /// Sets additional context values to resolver. /// </summary> /// <param name="resolver">Context resolver</param> private static void SetContext(ContextResolver resolver) { resolver.CurrentDocument = TreeNode.New("CMS.root"); resolver.CurrentPageInfo = new PageInfo(); resolver.CurrentPageInfo.PageTemplateInfo = new PageTemplateInfo(); }
/// <summary> /// Page load. /// </summary> protected void Page_Load(object sender, EventArgs e) { // Initialize control documentAttachments.Form = this.Form; documentAttachments.CheckPermissions = false; documentAttachments.OnUploadFile += new EventHandler(this.Form.RaiseOnUploadFile); documentAttachments.OnDeleteFile += new EventHandler(this.Form.RaiseOnDeleteFile); documentAttachments.AllowChangeOrder = ValidationHelper.GetBoolean(GetValue("changeorder"), true); documentAttachments.AllowPaging = ValidationHelper.GetBoolean(GetValue("paging"), true); documentAttachments.PageSize = ValidationHelper.GetString(GetValue("pagingsize"), "5,10,25,50,100,##ALL##"); documentAttachments.DefaultPageSize = ValidationHelper.GetInteger(GetValue("defaultpagesize"), 5); if (this.FieldInfo != null) { documentAttachments.GroupGUID = this.FieldInfo.Guid; } // Set allowed extensions string extensions = ValidationHelper.GetString(GetValue("extensions"), null); string allowedExtensions = ValidationHelper.GetString(GetValue("allowed_extensions"), null); if ((extensions == "custom") && (!String.IsNullOrEmpty(allowedExtensions))) { documentAttachments.AllowedExtensions = allowedExtensions; } // Set image auto resize dimensions if (this.FieldInfo != null) { int attachmentsWidth = 0; int attachmentsHeight = 0; int attachmentsMaxSideSize = 0; ImageHelper.GetAutoResizeDimensions(FieldInfo.Settings, CMSContext.CurrentSiteName, out attachmentsWidth, out attachmentsHeight, out attachmentsMaxSideSize); documentAttachments.ResizeToWidth = attachmentsWidth; documentAttachments.ResizeToHeight = attachmentsHeight; documentAttachments.ResizeToMaxSideSize = attachmentsMaxSideSize; } // Get node CMS.TreeEngine.TreeNode node = (CMS.TreeEngine.TreeNode) this.Form.EditedObject; if ((Form.Mode == FormModeEnum.Insert) || (Form.Mode == FormModeEnum.InsertNewCultureVersion)) { documentAttachments.FormGUID = Form.FormGUID; if ((Form.ParentObject != null) && (Form.ParentObject is CMS.TreeEngine.TreeNode)) { documentAttachments.NodeParentNodeID = ((CMS.TreeEngine.TreeNode)Form.ParentObject).NodeID; } else if (node != null) { documentAttachments.NodeParentNodeID = node.NodeParentID; } if (node != null) { documentAttachments.NodeClassName = node.NodeClassName; } } else if (node != null) { // Set appropriate control settings documentAttachments.DocumentID = node.DocumentID; documentAttachments.NodeParentNodeID = node.NodeParentID; documentAttachments.NodeClassName = node.NodeClassName; documentAttachments.ActualNode = node; // Get the node workflow WorkflowManager wm = new WorkflowManager(node.TreeProvider); WorkflowInfo wi = wm.GetNodeWorkflow(node); if (wi != null) { // Ensure the document version documentAttachments.VersionHistoryID = node.DocumentCheckedOutVersionHistoryID; } } if ((node != null) && !string.IsNullOrEmpty(node.NodeSiteName)) { documentAttachments.SiteName = node.NodeSiteName; } // Set control styles if (!String.IsNullOrEmpty(ControlStyle)) { documentAttachments.Attributes.Add("style", ControlStyle); this.ControlStyle = null; } if (!String.IsNullOrEmpty(CssClass)) { documentAttachments.CssClass = CssClass; this.CssClass = null; } }
/// <summary> /// Initializes the control properties. /// </summary> public void SetupControl() { ltlIcons.Text = ""; // Fill hashtable with info about all bookmark services FillHashTable(); // Resolve path of images string imagesPath = ResolveUrl("SocialBookmarking_files"); // Get current document TreeNode node = CMSContext.CurrentDocument; if (node != null) { // Get url of current document string liveUrl = URLHelper.CurrentURL; liveUrl = URLHelper.GetAbsoluteUrl(liveUrl); // Encode url liveUrl = Server.UrlEncode(liveUrl); // Prepare target string target = ShowInNewWindow ? "target=\"_blank\"" : ""; string[] bookmarkInfo = new string[4]; // Get all keys from hashtable object[] keys = new object[bookmarkServices.Count]; bookmarkServices.Keys.CopyTo(keys, 0); StringBuilder sb = new StringBuilder(); // Loop thru all items in hashtable for (int i = 0; i != keys.Length; i++) { // Get structure bookmarkInfo = (string[])bookmarkServices[keys[i]]; string currentService = keys[i].ToString(); if (bookmarkInfo.Length != 0) { // If current service is enabled generate html code if (ValidationHelper.GetBoolean(GetValue(currentService), false)) { if (sb.Length > 0) { sb.Append(Separator); } sb.Append("<a href=\"", bookmarkInfo[1], liveUrl, bookmarkInfo[2], Server.UrlEncode(node.DocumentName), "\" title=\"", GetString("addtobook.addto"), " ", bookmarkInfo[0], "\" ", target, "><img src=\"", imagesPath, "/", currentService.ToLower(), ".gif", "\" alt=\"", GetString("addtobook.addto"), " ", bookmarkInfo[0], "\" style=\"border-style:none;\" /></a>"); } } } // If at least one bookmarking service was checked show title if (sb.Length > 0) { if (!string.IsNullOrEmpty(TitleClass)) { sb.Insert(0, "<span class=\"" + TitleClass + "\">" + Title + "</span>"); } else { sb.Insert(0, Title); } // Wrap with span with class sb.Insert(0, "<span class=\"SocialBookmarking\">"); sb.Append("</span>"); } ltlIcons.Text = sb.ToString(); } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (this.StopProcessing) { // Do nothing } else { this.partPlaceholder.CheckPermissions = this.CheckPermissions; this.partPlaceholder.CacheMinutes = this.CacheMinutes; // Load content only when default page template or path is defined string templateName = this.PageTemplate; string path = this.Path; if ((templateName != "") || (path != "")) { ViewModeEnum viewMode = ViewModeEnum.Unknown; // Process template only if the control is on the last hierarchy page PageInfo currentPage = this.PagePlaceholder.PageInfo; PageInfo usePage = null; PageTemplateInfo ti = null; if (String.IsNullOrEmpty(path)) { // Use the same page usePage = this.PagePlaceholder.PageInfo; if (this.UseDefaultTemplateOnSubPages || (currentPage.ChildPageInfo == null) || (currentPage.ChildPageInfo.PageTemplateInfo == null) || (currentPage.ChildPageInfo.PageTemplateInfo.PageTemplateId == 0)) { ti = PageTemplateInfoProvider.GetPageTemplateInfo(templateName); } } else { // Resolve the path first path = CMSContext.ResolveCurrentPath(path); // Get specific page usePage = PageInfoProvider.GetPageInfo(CMSContext.CurrentSiteName, path, CMSContext.PreferredCultureCode, null, false); if (this.PortalManager.ViewMode != ViewModeEnum.LiveSite) { viewMode = ViewModeEnum.Preview; // Get current document content if (usePage != null) { TreeNode node = DocumentHelper.GetDocument(usePage.DocumentId, null); if (node != null) { usePage.LoadVersion(node); } } } // Get the appropriate page template if (String.IsNullOrEmpty(templateName)) { ti = usePage.PageTemplateInfo; } else { ti = PageTemplateInfoProvider.GetPageTemplateInfo(templateName); } } if ((usePage != null) && (ti != null)) { // If same template as current page, avoid cycling if (ti.PageTemplateId == currentPage.PageTemplateInfo.PageTemplateId) { this.lblError.Text = GetString("WebPart.PagePlaceHolder.CurrentTemplateNotAllowed"); this.lblError.Visible = true; } else { usePage = usePage.Clone(); usePage.DocumentPageTemplateID = ti.PageTemplateId; usePage.PageTemplateInfo = ti; // Load the current page info with the template and document if (viewMode != ViewModeEnum.Unknown) { this.partPlaceholder.ViewMode = viewMode; } this.partPlaceholder.UsingDefaultPageTemplate = true; this.partPlaceholder.PageLevel = this.PagePlaceholder.PageLevel; this.partPlaceholder.LoadContent(usePage, true); } } } } }
/// <summary> /// Logged in handler. /// </summary> void loginElem_LoggedIn(object sender, EventArgs e) { // Set view mode to live site after login to prevent bar with "Close preview mode" CMSContext.ViewMode = CMS.PortalEngine.ViewModeEnum.LiveSite; // Ensure response cookie CookieHelper.EnsureResponseCookie(FormsAuthentication.FormsCookieName); // Set cookie expiration if (loginElem.RememberMeSet) { CookieHelper.ChangeCookieExpiration(FormsAuthentication.FormsCookieName, DateTime.Now.AddYears(1), false); } else { // Extend the expiration of the authentication cookie if required if (!UserInfoProvider.UseSessionCookies && (HttpContext.Current != null) && (HttpContext.Current.Session != null)) { CookieHelper.ChangeCookieExpiration(FormsAuthentication.FormsCookieName, DateTime.Now.AddMinutes(Session.Timeout), false); } } // Current username string userName = loginElem.UserName; // Get user name (test site prefix too) UserInfo ui = UserInfoProvider.GetUserInfoForSitePrefix(userName, CMSContext.CurrentSite); // Check whether safe user name is required and if so get safe username if (RequestHelper.IsMixedAuthentication() && UserInfoProvider.UseSafeUserName) { // User stored with safe name userName = ValidationHelper.GetSafeUserName(this.loginElem.UserName, CMSContext.CurrentSiteName); // Find user by safe name ui = UserInfoProvider.GetUserInfoForSitePrefix(userName, CMSContext.CurrentSite); if (ui != null) { // Authenticate user by site or global safe username CMSContext.AuthenticateUser(ui.UserName, this.loginElem.RememberMeSet); } } // Log activity (warning: CMSContext contains info of previous user) if (ui != null) { // If user name is site prefixed, authenticate user manually if (UserInfoProvider.IsSitePrefixedUser(ui.UserName)) { CMSContext.AuthenticateUser(ui.UserName, this.loginElem.RememberMeSet); } // Log activity string siteName = CMSContext.CurrentSiteName; if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) && ActivitySettingsHelper.UserLoginEnabled(siteName)) { int contactId = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui); ActivityLogHelper.UpdateContactLastLogon(contactId); if (ActivitySettingsHelper.ActivitiesEnabledForThisUser(ui)) { TreeNode currentDoc = CMSContext.CurrentDocument; ActivityLogProvider.LogLoginActivity(contactId, ui, URLHelper.CurrentRelativePath, (currentDoc != null ? currentDoc.NodeID : 0), CMSContext.CurrentSiteName, CMSContext.Campaign, (currentDoc != null ? currentDoc.DocumentCulture : null)); } } } // Redirect user to the return url, or if is not defined redirect to the default target url string url = QueryHelper.GetString("ReturnURL", string.Empty); if (!string.IsNullOrEmpty(url)) { if (url.StartsWith("~") || url.StartsWith("/") || QueryHelper.ValidateHash("hash")) { URLHelper.Redirect(ResolveUrl(ValidationHelper.GetString(Request.QueryString["ReturnURL"], ""))); } else { URLHelper.Redirect(ResolveUrl("~/CMSMessages/Error.aspx?title=" + ResHelper.GetString("general.badhashtitle") + "&text=" + ResHelper.GetString("general.badhashtext"))); } } else { if (DefaultTargetUrl != "") { URLHelper.Redirect(ResolveUrl(DefaultTargetUrl)); } else { URLHelper.Redirect(URLRewriter.CurrentURL); } } }
/// <summary> /// Checks status of current user. /// </summary> protected void CheckStatus() { // Get current site name string siteName = CMSContext.CurrentSiteName; string error = null; // Check return URL string returnUrl = QueryHelper.GetString("returnurl", null); returnUrl = HttpUtility.UrlDecode(returnUrl); // Get current URL string currentUrl = URLHelper.CurrentURL; currentUrl = URLHelper.RemoveParameterFromUrl(currentUrl, "oauth_token"); currentUrl = URLHelper.RemoveParameterFromUrl(currentUrl, "oauth_verifier"); // Get LinkedIn response status switch (linkedInHelper.CheckStatus(RequireFirstName, RequireLastName, RequireBirthDate, null)) { // User is authenticated case CMSOpenIDHelper.RESPONSE_AUTHENTICATED: // LinkedIn profile Id not found = save new user if (UserInfoProvider.GetUserInfoByLinkedInID(linkedInHelper.MemberId) == null) { string additionalInfoPage = SettingsKeyProvider.GetStringValue(siteName + ".CMSRequiredLinkedInPage").Trim(); // No page set, user can be created if (String.IsNullOrEmpty(additionalInfoPage)) { // Register new user UserInfo ui = UserInfoProvider.AuthenticateLinkedInUser(linkedInHelper.MemberId, linkedInHelper.FirstName, linkedInHelper.LastName, siteName, true, true, ref error); // If user was successfuly created if (ui != null) { if (linkedInHelper.BirthDate != DateTimeHelper.ZERO_TIME) { ui.UserSettings.UserDateOfBirth = linkedInHelper.BirthDate; } UserInfoProvider.SetUserInfo(ui); // If user is enabled if (ui.Enabled) { // Create autentification cookie UserInfoProvider.SetAuthCookieWithUserData(ui.UserName, true, Session.Timeout, new string[] { "linkedinlogin" }); // Log activity if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) && ActivitySettingsHelper.UserLoginEnabled(siteName)) { int contactId = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui); ActivityLogHelper.UpdateContactLastLogon(contactId); if (ActivitySettingsHelper.ActivitiesEnabledForThisUser(ui)) { TreeNode currentDoc = CMSContext.CurrentDocument; ActivityLogProvider.LogLoginActivity(contactId, ui, URLHelper.CurrentRelativePath, (currentDoc != null ? currentDoc.NodeID : 0), siteName, CMSContext.Campaign, (currentDoc != null ? currentDoc.DocumentCulture : null)); } } } // Notify administrator if (this.NotifyAdministrator && !String.IsNullOrEmpty(this.FromAddress) && !String.IsNullOrEmpty(this.ToAddress)) { UserInfoProvider.NotifyAdministrator(ui, this.FromAddress, this.ToAddress); } // Send registration e-mails // E-mail confirmation is not required as user already provided confirmation by successful login using OpenID UserInfoProvider.SendRegistrationEmails(ui, null, null, false, false); // Log registration into analytics UserInfoProvider.TrackUserRegistration(this.TrackConversionName, this.ConversionValue, siteName, ui); // Log activity if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) && ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) && ActivitySettingsHelper.UserRegistrationEnabled(siteName)) { int contactId = ModuleCommands.OnlineMarketingGetCurrentContactID(); ModuleCommands.OnlineMarketingUpdateContactFromExternalData(ui, contactId); TreeNode currentDoc = CMSContext.CurrentDocument; ActivityLogProvider.LogRegistrationActivity(contactId, ui, URLHelper.CurrentRelativePath, currentDoc.NodeID, siteName, CMSContext.Campaign, currentDoc.DocumentCulture); } } // Redirect when authentication was succesfull if (String.IsNullOrEmpty(error)) { if (!String.IsNullOrEmpty(returnUrl)) { URLHelper.Redirect(URLHelper.GetAbsoluteUrl(returnUrl)); } else { URLHelper.Redirect(currentUrl); } } // Display error otherwise else { lblError.Text = error; lblError.Visible = true; } } // Additional information page is set else { // Store user object in session for additional use SessionHelper.SetValue(SESSION_NAME_USERDATA, linkedInHelper.LinkedInResponse); // Redirect to additional info page string targetURL = URLHelper.GetAbsoluteUrl(additionalInfoPage); if (!String.IsNullOrEmpty(returnUrl)) { // Add return URL to parameter targetURL = URLHelper.AddParameterToUrl(targetURL, "returnurl", HttpUtility.UrlEncode(returnUrl)); } URLHelper.Redirect(targetURL); } } // LinkedIn profile id is in DB else { // Login existing user UserInfo ui = UserInfoProvider.AuthenticateLinkedInUser(linkedInHelper.MemberId, linkedInHelper.FirstName, linkedInHelper.LastName, siteName, false, true, ref error); if ((ui != null) && (ui.Enabled)) { // Create autentification cookie UserInfoProvider.SetAuthCookieWithUserData(ui.UserName, true, Session.Timeout, new string[] { "linkedinlogin" }); // Log activity if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) && ActivitySettingsHelper.UserLoginEnabled(siteName)) { int contactId = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui); ActivityLogHelper.UpdateContactLastLogon(contactId); if (ActivitySettingsHelper.ActivitiesEnabledForThisUser(ui)) { TreeNode currentDoc = CMSContext.CurrentDocument; ActivityLogProvider.LogLoginActivity(contactId, ui, URLHelper.CurrentRelativePath, currentDoc.NodeID, siteName, CMSContext.Campaign, currentDoc.DocumentCulture); } } // Redirect user if (!String.IsNullOrEmpty(returnUrl)) { URLHelper.Redirect(URLHelper.GetAbsoluteUrl(returnUrl)); } else { URLHelper.Redirect(currentUrl); } } // Display error which occured during authentication process else if (!String.IsNullOrEmpty(error)) { lblError.Text = error; lblError.Visible = true; } // Otherwise is user disabled else { lblError.Text = GetString("membership.userdisabled"); lblError.Visible = true; } } break; // No authentication, do nothing case LinkedInHelper.RESPONSE_NOTAUTHENTICATED: break; } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { calItems.StopProcessing = true; } else { calItems.ControlContext = repEvent.ControlContext = ControlContext; // Calendar properties calItems.CacheItemName = CacheItemName; calItems.CacheDependencies = CacheDependencies; calItems.CacheMinutes = CacheMinutes; calItems.CheckPermissions = CheckPermissions; calItems.ClassNames = ClassNames; calItems.CombineWithDefaultCulture = CombineWithDefaultCulture; calItems.CultureCode = CultureCode; calItems.MaxRelativeLevel = MaxRelativeLevel; calItems.OrderBy = OrderBy; calItems.WhereCondition = WhereCondition; calItems.Columns = Columns; calItems.Path = Path; calItems.SelectOnlyPublished = SelectOnlyPublished; calItems.SiteName = SiteName; calItems.FilterName = FilterName; calItems.RelationshipName = RelationshipName; calItems.RelationshipWithNodeGuid = RelationshipWithNodeGuid; calItems.RelatedNodeIsOnTheLeftSide = RelatedNodeIsOnTheLeftSide; calItems.TransformationName = TransformationName; calItems.NoEventTransformationName = NoEventTransformationName; calItems.DayField = DayField; calItems.EventEndField = EventEndField; calItems.HideDefaultDayNumber = HideDefaultDayNumber; calItems.TodaysDate = CMSContext.ConvertDateTime(DateTime.Now, this); bool detail = false; // If calendar event path is defined event is loaded in accordance to the selected path string eventPath = QueryHelper.GetString("CalendarEventPath", null); if (!String.IsNullOrEmpty(eventPath)) { detail = true; repEvent.Path = eventPath; // Set selected date to specific document TreeNode node = TreeHelper.GetDocument(SiteName, eventPath, CultureCode, CombineWithDefaultCulture, ClassNames, SelectOnlyPublished, CheckPermissions, CMSContext.CurrentUser); if (node != null) { object value = node.GetValue(DayField); if (ValidationHelper.GetDateTime(value, DataHelper.DATETIME_NOT_SELECTED) != DataHelper.DATETIME_NOT_SELECTED) { calItems.TodaysDate = CMSContext.ConvertDateTime((DateTime)value, this); } } } // By default select current event from current document value PageInfo currentPage = CMSContext.CurrentPageInfo; if ((currentPage != null) && (ClassNames.ToLower().Contains(currentPage.ClassName.ToLower()))) { detail = true; repEvent.Path = currentPage.NodeAliasPath; // Set selected date to current document object value = CMSContext.CurrentDocument.GetValue(DayField); if (ValidationHelper.GetDateTime(value, DataHelper.DATETIME_NOT_SELECTED) != DataHelper.DATETIME_NOT_SELECTED) { calItems.TodaysDate = CMSContext.ConvertDateTime((DateTime)value, this); // Get name of coupled class ID column string idColumn = CMSContext.CurrentDocument.CoupledClassIDColumn; if (!string.IsNullOrEmpty(idColumn)) { // Set selected item ID and the ID column name so it is possible to highlight specific event in the calendar calItems.SelectedItemIDColumn = idColumn; calItems.SelectedItemID = ValidationHelper.GetInteger(CMSContext.CurrentDocument.GetValue(idColumn), 0); } } } if (detail) { // Setup the detail repeater repEvent.Visible = true; repEvent.StopProcessing = false; repEvent.SelectedItemTransformationName = EventDetailTransformation; repEvent.ClassNames = ClassNames; repEvent.Columns = Columns; if (!String.IsNullOrEmpty(CacheItemName)) { repEvent.CacheItemName = CacheItemName + "|detail"; } repEvent.CacheDependencies = CacheDependencies; repEvent.CacheMinutes = CacheMinutes; repEvent.CheckPermissions = CheckPermissions; repEvent.CombineWithDefaultCulture = CombineWithDefaultCulture; repEvent.CultureCode = CultureCode; repEvent.SelectOnlyPublished = SelectOnlyPublished; repEvent.SiteName = SiteName; repEvent.WhereCondition = WhereCondition; } } }