Ejemplo n.º 1
0
    /// <summary>
    /// Runs the search.
    /// </summary>
    private void Search()
    {
        if (!string.IsNullOrEmpty(txtWord.Text))
        {
            string url = SearchResultsPageUrl;

            if (url.StartsWith("~"))
            {
                url = ResolveUrl(url.Trim());
            }

            if (url.Contains("?"))
            {
                url = URLHelper.RemoveParameterFromUrl(url, "searchtext");
                url = URLHelper.RemoveParameterFromUrl(url, "searchMode");
            }

            url = URLHelper.AddParameterToUrl(url, "searchtext", HttpUtility.UrlEncode(txtWord.Text));
            url = URLHelper.AddParameterToUrl(url, "searchMode", SearchMode.ToString());

            // Log activity
            string siteName = CMSContext.CurrentSiteName;
            if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) &&
                ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) &&
                ActivitySettingsHelper.SearchEnabled(siteName))
            {
                ActivityLogProvider.LogInternalSearchActivity(CMSContext.CurrentDocument, ModuleCommands.OnlineMarketingGetCurrentContactID(),
                                                              CMSContext.CurrentSiteID, URLHelper.CurrentRelativePath, txtWord.Text, CMSContext.Campaign);
            }

            URLHelper.Redirect(url.Trim());
        }
    }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string currSiteName = null;
        int    currSiteId   = 0;

        // Get current site ID/name
        if (ContactHelper.IsSiteManager)
        {
            currSiteId   = SiteID;
            currSiteName = SiteInfoProvider.GetSiteName(currSiteId);
        }
        else
        {
            currSiteName = SiteContext.CurrentSiteName;
            currSiteId   = SiteContext.CurrentSiteID;
        }

        bool globalObjectsSelected = (currSiteId == UniSelector.US_GLOBAL_RECORD);
        bool allSitesSelected      = (currSiteId == UniSelector.US_ALL_RECORDS);

        // Show warning if activity logging is disabled (do not show anything if global objects or all sites is selected)
        ucDisabledModule.SettingsKeys = "CMSEnableOnlineMarketing";
        ucDisabledModule.ParentPanel  = pnlDis;

        pnlDis.Visible = !globalObjectsSelected && !allSitesSelected && !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(currSiteName);

        if (CurrentMaster.HeaderActions.ActionsList.Count > 0)
        {
            CurrentMaster.HeaderActions.ActionsList[0].RedirectUrl += RequestContext.CurrentQueryString;
        }
    }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Visible)
        {
            EnableViewState = false;
        }

        // Hide code name edit for simple mode
        if (DisplayMode == ControlDisplayModeEnum.Simple)
        {
            plcCodeName.Visible = false;
            plcUseHtml.Visible  = false;
        }

        pnlGeneral.GroupingText  = GetString("general.general");
        pnlAdvanced.GroupingText = GetString("forums.advancedsettings");
        pnlSecurity.GroupingText = GetString("forums.securitysettings");
        pnlEditor.GroupingText   = GetString("forums.editorsettings");
        pnlOptIn.GroupingText    = GetString("general.OptIn");

        txtGroupDisplayName.IsLiveSite = IsLiveSite;
        txtGroupDescription.IsLiveSite = IsLiveSite;
        txtOptInURL.IsLiveSite         = IsLiveSite;

        // Control initializations
        rfvGroupDisplayName.ErrorMessage = GetString("general.requiresdisplayname");
        rfvGroupName.ErrorMessage        = GetString("general.requirescodename");

        lblGroupDisplayName.Text  = GetString("Group_General.GroupDisplayNameLabel");
        lblGroupName.Text         = GetString("Group_General.GroupNameLabel");
        lblForumBaseUrl.Text      = GetString("Group_General.ForumBaseUrlLabel");
        lblUnsubscriptionUrl.Text = GetString("Group_General.UnsubscriptionUrlLabel");

        // Show on-line marketing settings
        string siteName = CMSContext.CurrentSiteName;

        plcOnline.Visible = (ActivitySettingsHelper.ForumPostSubscriptionEnabled(siteName) || ActivitySettingsHelper.ForumPostsEnabled(siteName)) &&
                            ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName);

        chkEnableOptIn.NotSetChoice.Text = chkSendOptInConfirmation.NotSetChoice.Text = GetString("general.sitesettings") + " (##DEFAULT##)";
        chkEnableOptIn.SetDefaultValue(ForumGroupInfoProvider.EnableDoubleOptIn(siteName));
        chkSendOptInConfirmation.SetDefaultValue(ForumGroupInfoProvider.SendOptInConfirmation(siteName));

        // Fill editing form
        if (!IsLiveSite && !RequestHelper.IsPostBack())
        {
            ReloadData();
        }

        // Show/hide URL textboxes
        plcBaseAndUnsubUrl.Visible = (DisplayMode != ControlDisplayModeEnum.Simple);

        SetUrl();
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Logs activity.
    /// </summary>
    /// <param name="bci">Blog comment info</param>
    /// <param name="nodeId">Docuemnt node ID</param>
    /// <param name="culture">Docuemnt culture</param>
    private void LogCommentActivity(BlogCommentInfo bci, int nodeId, string culture)
    {
        if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || (bci == null) || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser))
        {
            return;
        }

        string siteName = CMSContext.CurrentSiteName;

        if (!ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) || !ActivitySettingsHelper.BlogPostCommentsEnabled(siteName))
        {
            return;
        }

        if (bci.CommentPostDocumentID > 0)
        {
            // Load blog post settings and check if logging is enabled for current post
            TreeProvider tree     = new TreeProvider();
            TreeNode     blogPost = DocumentHelper.GetDocument(bci.CommentPostDocumentID, tree);

            if ((blogPost != null) && ValidationHelper.GetBoolean(blogPost.GetValue("BlogLogActivity"), false))
            {
                TreeNode blogNode = BlogHelper.GetParentBlog(bci.CommentPostDocumentID, false);
                string   blogName = null;
                if (blogNode != null)
                {
                    blogName = blogNode.DocumentName;
                }

                int contactID = ModuleCommands.OnlineMarketingGetCurrentContactID();
                var data      = new ActivityData()
                {
                    ContactID    = contactID,
                    SiteID       = CMSContext.CurrentSiteID,
                    Type         = PredefinedActivityType.BLOG_COMMENT,
                    TitleData    = blogName,
                    ItemID       = bci.CommentID,
                    URL          = URLHelper.CurrentRelativePath,
                    ItemDetailID = (blogNode != null ? blogNode.NodeID : 0),
                    NodeID       = nodeId,
                    Culture      = culture,
                    Campaign     = CMSContext.Campaign
                };
                ActivityLogProvider.LogActivity(data);

                Dictionary <string, object> contactData = new Dictionary <string, object>();
                contactData.Add("ContactEmail", bci.CommentEmail);
                contactData.Add("ContactLastName", bci.CommentUserName);
                contactData.Add("ContactWebSite", bci.CommentUrl);
                ModuleCommands.OnlineMarketingUpdateContactFromExternalSource(contactData, false, contactID);
            }
        }
    }
Ejemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string currSiteName = null;

        // Get current site ID/name
        if (ContactHelper.IsSiteManager)
        {
            currSiteId   = SiteID;
            currSiteName = SiteInfoProvider.GetSiteName(currSiteId);
        }
        else
        {
            currSiteName = CMSContext.CurrentSiteName;
            currSiteId   = CMSContext.CurrentSiteID;
        }

        bool globalObjectsSelected = (currSiteId == UniSelector.US_GLOBAL_RECORD);
        bool allSitesSelected      = (currSiteId == UniSelector.US_ALL_RECORDS);

        // Show warning if activity logging is disabled (do not show anything if global objects or all sites is selected)
        ucDisabledModule.SettingsKeys = "CMSEnableOnlineMarketing";
        ucDisabledModule.InfoText     = GetString("om.onlinemarketing.disabled");
        ucDisabledModule.ParentPanel  = pnlDis;

        pnlDis.Visible = !globalObjectsSelected && !allSitesSelected && !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(currSiteName);

        // Initialize list and filter controls
        listElem.SiteID = currSiteId;

        // Show site name column if activities of all sites are displayed
        listElem.ShowSiteNameColumn  = allSitesSelected || globalObjectsSelected;
        listElem.ShowIPAddressColumn = ActivitySettingsHelper.IPLoggingEnabled(currSiteName);
        listElem.OrderBy             = "ActivityCreated DESC";

        if (QueryHelper.GetInteger("saved", 0) == 1)
        {
            ShowChangesSaved();
        }

        // Set header actions (add button)
        string url = ResolveUrl("New.aspx?siteId=" + currSiteId);

        if (IsSiteManager)
        {
            url = URLHelper.AddParameterToUrl(url, "isSiteManager", "1");
        }
        string[,] actions  = new string[1, 8];
        actions[0, 0]      = "HyperLink";
        actions[0, 1]      = GetString("om.activity.newcustom");
        actions[0, 3]      = url;
        actions[0, 5]      = GetImageUrl("Objects/OM_Activity/add.png");
        hdrActions.Actions = actions;
    }
Ejemplo n.º 6
0
    /// <summary>
    /// Logs activity.
    /// </summary>
    /// <param name="bpsi">Blog subscription info</param>
    /// <param name="nodeId">Docuemnt node ID</param>
    /// <param name="culture">Document culture</param>
    private void LogActivity(BlogPostSubscriptionInfo bpsi, int nodeId, string culture)
    {
        if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || (bpsi == null) || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser))
        {
            return;
        }

        string siteName = CMSContext.CurrentSiteName;

        if (!ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) ||
            !ActivitySettingsHelper.BlogPostSubscriptionEnabled(siteName))
        {
            return;
        }

        if (bpsi.SubscriptionPostDocumentID > 0)
        {
            TreeProvider tree     = new TreeProvider();
            TreeNode     blogPost = DocumentHelper.GetDocument(bpsi.SubscriptionPostDocumentID, tree);

            if ((blogPost != null) && ValidationHelper.GetBoolean(blogPost.GetValue("BlogLogActivity"), false))
            {
                string   blogName = null;
                TreeNode blogNode = BlogHelper.GetParentBlog(bpsi.SubscriptionPostDocumentID, false);
                if (blogNode != null)
                {
                    blogName = blogNode.DocumentName;
                }

                // Update contact info according to subscribtion
                int contactId = ModuleCommands.OnlineMarketingGetCurrentContactID();
                Dictionary <string, object> contactData = new Dictionary <string, object>();
                contactData.Add("ContactEmail", bpsi.SubscriptionEmail);
                ModuleCommands.OnlineMarketingUpdateContactFromExternalSource(contactData, false, contactId);

                var data = new ActivityData()
                {
                    ContactID    = contactId,
                    SiteID       = CMSContext.CurrentSiteID,
                    Type         = PredefinedActivityType.SUBSCRIPTION_BLOG_POST,
                    ItemDetailID = (blogNode != null ? blogNode.NodeID : 0),
                    TitleData    = bpsi.SubscriptionEmail,
                    URL          = URLHelper.CurrentRelativePath,
                    NodeID       = nodeId,
                    Value        = TextHelper.LimitLength(blogName, 250),
                    Culture      = culture,
                    Campaign     = CMSContext.Campaign
                };
                ActivityLogProvider.LogActivity(data);
            }
        }
    }
    protected void srchDialog_DoSearch()
    {
        // Log "internal search" activity
        string siteName = CMSContext.CurrentSiteName;

        if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) &&
            ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) &&
            ActivitySettingsHelper.SearchEnabled(siteName))
        {
            ActivityLogProvider.LogInternalSearchActivity(CMSContext.CurrentDocument, ModuleCommands.OnlineMarketingGetCurrentContactID(),
                                                          CMSContext.CurrentSiteID, URLHelper.CurrentRelativePath, this.srchDialog.SearchForTextBox.Text, CMSContext.Campaign);
        }
    }
Ejemplo n.º 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (EditedObject != null)
        {
            ContactInfo ci = (ContactInfo)EditedObject;

            ucDisabledModule.TestSettingKeys = "CMSEnableOnlineMarketing;CMSCMActivitiesEnabled";
            ucDisabledModule.ParentPanel     = pnlDis;

            pnlDis.Visible = !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(SiteContext.CurrentSiteID);

            listElem.ShowSiteNameColumn = true;
            listElem.SiteID             = UniSelector.US_ALL_RECORDS;
            listElem.ContactID          = ci.ContactID;
            listElem.OrderBy            = "ActivityCreated DESC";

            // Init header action for new custom activities only if contact is not global, a custom activity type exists and user is authorized to manage activities
            if (ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(SiteContext.CurrentSiteName) && MembershipContext.AuthenticatedUser.IsAuthorizedPerResource(ModuleName.ACTIVITIES, "ManageActivities"))
            {
                // Disable manual creation of activity if no custom activity type is available
                var activityType = ActivityTypeInfoProvider.GetActivityTypes()
                                   .WhereEquals("ActivityTypeIsCustom", 1)
                                   .WhereEquals("ActivityTypeEnabled", 1)
                                   .WhereEquals("ActivityTypeManualCreationAllowed", 1)
                                   .TopN(1)
                                   .Column("ActivityTypeID")
                                   .FirstOrDefault();

                if (activityType != null)
                {
                    // Prepare target URL
                    string url = ResolveUrl(string.Format("~/CMSModules/Activities/Pages/Tools/Activities/Activity/New.aspx?contactId={0}", ci.ContactID));

                    // Init header action
                    HeaderAction action = new HeaderAction()
                    {
                        Text        = GetString("om.activity.newcustom"),
                        RedirectUrl = url
                    };
                    CurrentMaster.HeaderActions.ActionsList.Add(action);
                }
            }

            if (!RequestHelper.IsPostBack() && QueryHelper.GetBoolean("saved", false))
            {
                // Display 'Save' message after new custom activity was created
                ShowChangesSaved();
            }
        }
    }
Ejemplo n.º 9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.Visible)
        {
            this.EnableViewState = false;
        }

        // Hide code name edit for simple mode
        if (DisplayMode == ControlDisplayModeEnum.Simple)
        {
            this.plcCodeName.Visible = false;
            this.plcUseHtml.Visible  = false;
        }

        txtGroupDisplayName.IsLiveSite = this.IsLiveSite;
        txtGroupDescription.IsLiveSite = this.IsLiveSite;

        // Control initializations
        this.rfvGroupDisplayName.ErrorMessage = GetString("general.requiresdisplayname");
        this.rfvGroupName.ErrorMessage        = GetString("general.requirescodename");

        this.lblGroupDisplayName.Text  = GetString("Group_General.GroupDisplayNameLabel");
        this.lblGroupName.Text         = GetString("Group_General.GroupNameLabel");
        this.lblForumBaseUrl.Text      = GetString("Group_General.ForumBaseUrlLabel");
        this.lblUnsubscriptionUrl.Text = GetString("Group_General.UnsubscriptionUrlLabel");

        this.btnOk.Text = GetString("General.OK");

        // Show on-line marketing settings
        string siteName = CMSContext.CurrentSiteName;

        plcOnline.Visible = (ActivitySettingsHelper.ForumPostSubscriptionEnabled(siteName) || ActivitySettingsHelper.ForumPostsEnabled(siteName)) &&
                            ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName);

        // Fill editing form
        if (!this.IsLiveSite && !RequestHelper.IsPostBack())
        {
            ReloadData();
        }

        // Show/hide URL textboxes
        plcBaseAndUnsubUrl.Visible = (DisplayMode != ControlDisplayModeEnum.Simple);

        if (plcBaseAndUnsubUrl.Visible)
        {
            SetUrl();
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        int currSiteId = SiteContext.CurrentSiteID;

        bool globalObjectsSelected = (currSiteId == UniSelector.US_GLOBAL_RECORD);
        bool allSitesSelected      = (currSiteId == UniSelector.US_ALL_RECORDS);

        // Show info if activity logging is disabled (do not show anything if global objects or all sites is selected)
        ucDisabledModule.ParentPanel = pnlDis;
        pnlDis.Visible = !globalObjectsSelected && !allSitesSelected && !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(SiteContext.CurrentSiteName);

        if (CurrentMaster.HeaderActions.ActionsList.Count > 0)
        {
            CurrentMaster.HeaderActions.ActionsList[0].RedirectUrl += RequestContext.CurrentQueryString;
        }
    }
Ejemplo n.º 11
0
    /// <summary>
    /// Logs rating activity
    /// </summary>
    /// <param name="value">Rating value</param>
    private void LogActivity(double value)
    {
        if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser))
        {
            return;
        }

        string siteName = CMSContext.CurrentSiteName;

        if (!ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) || !ActivitySettingsHelper.ContentRatingEnabled(siteName))
        {
            return;
        }

        bool     logActivity = false;
        TreeNode currentDoc  = CMSContext.CurrentDocument;

        if (currentDoc != null)
        {
            if (CMSContext.CurrentDocument.DocumentLogVisitActivity == null)
            {
                logActivity = ValidationHelper.GetBoolean(currentDoc.GetInheritedValue("DocumentLogVisitActivity", SiteInfoProvider.CombineWithDefaultCulture(siteName)), false);
            }
            else
            {
                logActivity = currentDoc.DocumentLogVisitActivity == true;
            }

            if (logActivity)
            {
                var data = new ActivityData()
                {
                    ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID(),
                    SiteID    = CMSContext.CurrentSiteID,
                    Type      = PredefinedActivityType.RATING,
                    TitleData = String.Format("{0} ({1})", value.ToString(), currentDoc.DocumentName),
                    URL       = URLHelper.CurrentRelativePath,
                    NodeID    = currentDoc.NodeID,
                    Value     = value.ToString(),
                    Culture   = currentDoc.DocumentCulture,
                    Campaign  = CMSContext.Campaign
                };
                ActivityLogProvider.LogActivity(data);
            }
        }
    }
Ejemplo n.º 12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (CMSPage.EditedObject != null)
        {
            ContactInfo ci = (ContactInfo)CMSPage.EditedObject;

            // Check permission
            this.CheckReadPermission(ci.ContactSiteID);

            bool isGlobal = (ci.ContactSiteID == 0);
            bool isMerged = (ci.ContactMergedWithContactID > 0);

            // Show warning if activity logging is disabled
            string siteName = SiteInfoProvider.GetSiteName(ci.ContactSiteID);
            if (!ActivitySettingsHelper.OnlineMarketingEnabled(siteName))
            {
                lblDis.ResourceString = "om.onlinemarketing.disabled";
            }
            pnlDis.Visible = !isGlobal && !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName);

            // Show IP addresses if enabled
            fltElem.ShowIPFilter         = ActivitySettingsHelper.IPLoggingEnabled(siteName);
            fltElem.ShowSiteFilter       = this.IsSiteManager && isGlobal;
            listElem.ShowIPAddressColumn = fltElem.ShowIPFilter;


            // Restrict WHERE condition for activities of current site (if not in site manager)
            if (!this.IsSiteManager)
            {
                fltElem.SiteID = CMSContext.CurrentSiteID;
            }

            listElem.ContactID       = ci.ContactID;
            listElem.IsMergedContact = isMerged;
            listElem.IsGlobalContact = isGlobal;

            fltElem.ShowContactSelector    = isGlobal;
            listElem.ShowContactNameColumn = isGlobal;
            listElem.ShowSiteNameColumn    = this.IsSiteManager && isGlobal;
            listElem.ShowRemoveButton      = !isMerged && !isGlobal;
            listElem.OrderBy        = "ActivityCreated DESC";
            listElem.WhereCondition = fltElem.WhereCondition;
        }
    }
Ejemplo n.º 13
0
    /// <summary>
    /// OnGo search click.
    /// </summary>
    protected void btnGo_Click(object sender, EventArgs e)
    {
        if (!String.IsNullOrEmpty(txtSearch.Text))
        {
            string contextQuery = String.Empty;

            if (this.SearchInCurrentContext)
            {
                if ((ForumContext.CurrentForum != null) && (ForumContext.CurrentThread != null) && (ForumContext.CurrentThread.PostForumID == ForumContext.CurrentForum.ForumID))
                {
                    contextQuery = "&searchforums=" + ForumContext.CurrentForum.ForumID + "&searchthread=" + ForumContext.CurrentThread.PostId;
                }
                else if (ForumContext.CurrentForum != null)
                {
                    contextQuery = "&searchforums=" + ForumContext.CurrentForum.ForumID;
                }
            }

            // Log "internal search" activity
            string siteName = CMSContext.CurrentSiteName;
            if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) &&
                ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) && ActivitySettingsHelper.SearchEnabled(siteName))
            {
                ActivityLogProvider.LogInternalSearchActivity(CMSContext.CurrentDocument, ModuleCommands.OnlineMarketingGetCurrentContactID(),
                                                              CMSContext.CurrentSiteID, URLHelper.CurrentRelativePath, txtSearch.Text, CMSContext.Campaign);
            }

            if (!String.IsNullOrEmpty(RedirectUrl.Trim()))
            {
                URLHelper.Redirect(ResolveUrl(RedirectUrl) + "?searchtext=" + HttpUtility.UrlEncode(txtSearch.Text) + contextQuery);
            }
            else //Redirect back to current page
            {
                string url = URLHelper.RemoveQuery(URLRewriter.CurrentURL);
                url  = URLHelper.UpdateParameterInUrl(url, "searchtext", HttpUtility.UrlEncode(txtSearch.Text));
                url  = URLHelper.RemoveParameterFromUrl(url, "searchforums");
                url  = URLHelper.RemoveParameterFromUrl(url, "searchthread");
                url += contextQuery;

                URLHelper.Redirect(url);
            }
        }
    }
Ejemplo n.º 14
0
    /// <summary>
    /// Checks if page visit activity logging is enabled, if so returns contact ID.
    /// </summary>
    /// <param name="file">File to be sent</param>
    /// <param name="contactId">Current contact ID</param>
    protected bool LoggingActivityEnabled(CMSOutputFile file, out int contactId)
    {
        contactId = 0;
        if ((file == null) || (file.FileNode == null))
        {
            return(false);
        }

        // Check if logging is enabled
        if (ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(CurrentSiteName) && ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) &&
            ActivitySettingsHelper.PageVisitsEnabled(CurrentSiteName))
        {
            if (file.Attachment != null)
            {
                // Get allowed extensions (if not specified log everything)
                bool   doLog   = true;
                string tracked = SettingsKeyProvider.GetStringValue(CurrentSiteName + ".CMSActivityTrackedExtensions");
                if (!String.IsNullOrEmpty(tracked))
                {
                    string extension = file.Attachment.AttachmentExtension;
                    if (extension != null)
                    {
                        string extensions = String.Format(";{0};", tracked.ToLower().Trim().Trim(';'));
                        extension = extension.TrimStart('.').ToLower();
                        doLog     = extensions.Contains(String.Format(";{0};", extension));
                    }
                }

                if (doLog)
                {
                    // Check if logging is enabled for current document
                    TreeNode fileNode = file.FileNode;
                    if ((fileNode != null) && ((fileNode.DocumentLogVisitActivity == true) ||
                                               (fileNode.DocumentLogVisitActivity == null) && ValidationHelper.GetBoolean(fileNode.GetInheritedValue("DocumentLogVisitActivity", SiteInfoProvider.CombineWithDefaultCulture(CurrentSiteName)), false)))
                    {
                        contactId = ModuleCommands.OnlineMarketingGetCurrentContactID();
                        return(contactId > 0);
                    }
                }
            }
        }
        return(false);
    }
Ejemplo n.º 15
0
    /// <summary>
    /// Fires at btn search click.
    /// </summary>
    /// <param name="sender">Sender</param>
    /// <param name="e">Arguments</param>
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string url = URLHelper.CurrentURL;

        // Remove pager query string
        url = URLHelper.RemoveParameterFromUrl(url, "page");

        // Update search text parameter
        url = URLHelper.UpdateParameterInUrl(url, "searchtext", HttpUtility.UrlEncode(txtSearchFor.Text));

        // Update search mode parameter
        url = URLHelper.RemoveParameterFromUrl(url, "searchmode");
        if (this.ShowSearchMode)
        {
            url = URLHelper.AddParameterToUrl(url, "searchmode", drpSearchMode.SelectedValue);
        }
        else
        {
            url = URLHelper.AddParameterToUrl(url, "searchmode", SearchHelper.GetSearchModeString(SearchMode));
        }

        // Add filter params to url
        foreach (string urlParam in FilterUrlParameters)
        {
            string[] urlParams = urlParam.Split('=');
            url = URLHelper.UpdateParameterInUrl(url, urlParams[0], urlParams[1]);
        }

        // Log "internal search" activity
        string siteName = CMSContext.CurrentSiteName;

        if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) && ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) &&
            ActivitySettingsHelper.SearchEnabled(siteName))
        {
            ActivityLogProvider.LogInternalSearchActivity(CMSContext.CurrentDocument, ModuleCommands.OnlineMarketingGetCurrentContactID(),
                                                          CMSContext.CurrentSiteID, URLHelper.CurrentRelativePath, txtSearchFor.Text, CMSContext.Campaign);
        }

        // Redirect
        URLHelper.Redirect(url);
    }
Ejemplo n.º 16
0
    /// <summary>
    /// Helper method, set authentication cookie and redirect to return URL or default page.
    /// </summary>
    /// <param name="ui">User info</param>
    /// <param name="user">Windows live user</param>
    private void SetAuthCookieAndRedirect(UserInfo ui)
    {
        // Create autentification cookie
        if (ui.Enabled)
        {
            UserInfoProvider.SetAuthCookieWithUserData(ui.UserName, true, Session.Timeout, new string[] { "facebooklogin" });

            // 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), siteName, CMSContext.Campaign, (currentDoc != null ? currentDoc.DocumentCulture : null));
                }
            }

            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);
            }
        }
    }
Ejemplo n.º 17
0
    /// <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[] { "liveidlogin" });

            // 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);
                }
            }

            // Redirect to default page
            if (!String.IsNullOrEmpty(this.DefaultTargetUrl))
            {
                URLHelper.Redirect(ResolveUrl(this.DefaultTargetUrl));
            }
            // If there is some return page redirect there
            else if ((liveUser != null) && !string.IsNullOrEmpty(liveUser.Context))
            {
                URLHelper.Redirect(liveUser.Context);
            }
            // Refresh current page to update see user signed in
            else
            {
                string url = URLRewriter.CurrentURL;
                URLHelper.Redirect(url);
            }
        }
    }
Ejemplo n.º 18
0
    /// <summary>
    /// Log activity
    /// </summary>
    /// <param name="ari">Report info</param>
    private void LogActivity(AbuseReportInfo ari)
    {
        if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) ||
            (ari == null) ||
            !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) ||
            !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(ari.ReportSiteID) ||
            !ActivitySettingsHelper.AbuseReportEnabled(ari.ReportSiteID))
        {
            return;
        }
        var data = new ActivityData()
        {
            ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID(),
            SiteID    = ari.ReportSiteID,
            Type      = PredefinedActivityType.ABUSE_REPORT,
            TitleData = ari.ReportTitle,
            ItemID    = ari.ReportID,
            URL       = URLHelper.CurrentRelativePath,
            Campaign  = CMSContext.Campaign
        };

        ActivityLogProvider.LogActivity(data);
    }
Ejemplo n.º 19
0
    /// <summary>
    /// Log activity
    /// </summary>
    /// <param name="gmi">Member info</param>
    /// <param name="logActivity">Determines whether activity logging is enabled for current group</param>
    /// <param name="groupDisplayName">Display name of the group</param>
    private void LogJoinActivity(GroupMemberInfo gmi, bool logActivity, string groupDisplayName)
    {
        string siteName = CMSContext.CurrentSiteName;

        if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || (gmi == null) || !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) ||
            !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) || !ActivitySettingsHelper.JoiningAGroupEnabled(siteName))
        {
            return;
        }

        var data = new ActivityData()
        {
            ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID(),
            SiteID    = CMSContext.CurrentSiteID,
            Type      = PredefinedActivityType.JOIN_GROUP,
            TitleData = groupDisplayName,
            ItemID    = gmi.MemberGroupID,
            URL       = URLHelper.CurrentRelativePath,
            Campaign  = CMSContext.Campaign
        };

        ActivityLogProvider.LogActivity(data);
    }
Ejemplo n.º 20
0
    /// <summary>
    /// Handles btnOkNew click, creates new user and joins it with liveid token.
    /// </summary>
    protected void btnOkNew_Click(object sender, EventArgs e)
    {
        if (liveUser != null)
        {
            // Validate entered values
            string errorMessage = new Validator().IsRegularExp(txtUserNameNew.Text, "^([a-zA-Z0-9_\\-\\.@]+)$", GetString("mem.liveid.fillcorrectusername"))
                                  .IsEmail(txtEmail.Text, GetString("mem.liveid.fillvalidemail")).Result;

            string password = passStrength.Text.Trim();

            // 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);
                }
            }

            string siteName = CMSContext.CurrentSiteName;

            // Check whether email is unique if it is required
            if ((errorMessage == String.Empty) && !UserInfoProvider.IsEmailUnique(txtEmail.Text.Trim(), siteName, 0))
            {
                errorMessage = GetString("UserInfo.EmailAlreadyExist");
            }

            // Check reserved names
            if ((errorMessage == String.Empty) && UserInfoProvider.NameIsReserved(siteName, txtUserNameNew.Text.Trim()))
            {
                errorMessage = GetString("Webparts_Membership_RegistrationForm.UserNameReserved").Replace("%%name%%", HTMLHelper.HTMLEncode(txtUserNameNew.Text.Trim()));
            }

            if (errorMessage == String.Empty)
            {
                string userName = txtUserNameNew.Text.Trim();
                // Check if user with given username already exists
                UserInfo ui     = UserInfoProvider.GetUserInfo(userName);
                UserInfo siteui = UserInfoProvider.GetUserInfo(UserInfoProvider.EnsureSitePrefixUserName(userName, CMSContext.CurrentSite));

                // User with given username is already registered
                if ((ui != null) || (siteui != null))
                {
                    plcError.Visible = true;
                    lblError.Text    = GetString("mem.openid.usernameregistered");
                }
                else
                {
                    // Register new user
                    string error = this.DisplayMessage;
                    ui = UserInfoProvider.AuthenticateWindowsLiveUser(liveUser.Id, siteName, false, ref error);
                    this.DisplayMessage = error;

                    if (ui != null)
                    {
                        // Set additional information
                        ui.UserName = ui.UserNickName = userName;

                        // Ensure site prefixes
                        if (UserInfoProvider.UserNameSitePrefixEnabled(siteName))
                        {
                            ui.UserName = UserInfoProvider.EnsureSitePrefixUserName(userName, CMSContext.CurrentSite);
                        }

                        ui.Email = txtEmail.Text;

                        // 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;
                        }

                        UserInfoProvider.SetUserInfo(ui);

                        // Remove live user object from session, won't be needed
                        Session.Remove("windowsliveloginuser");

                        // Send registration e-mails
                        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);
                        }

                        // Track registration into analytics
                        UserInfoProvider.TrackUserRegistration(this.TrackConversionName, this.ConversionValue, siteName, ui);

                        // Log registration activity
                        if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) && ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) &&
                            ActivitySettingsHelper.UserRegistrationEnabled(siteName))
                        {
                            int contactId = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui);
                            ModuleCommands.OnlineMarketingUpdateContactFromExternalData(ui, contactId);
                            TreeNode currentDoc = CMSContext.CurrentDocument;
                            ActivityLogProvider.LogRegistrationActivity(contactId,
                                                                        ui, URLHelper.CurrentRelativePath, (currentDoc != null ? currentDoc.NodeID : 0), siteName, CMSContext.Campaign, (currentDoc != null ? currentDoc.DocumentCulture : null));
                        }

                        // Set authentication cookie and redirect to page
                        SetAuthCookieAndRedirect(ui);

                        // Display error message
                        if (!String.IsNullOrEmpty(this.DisplayMessage))
                        {
                            lblInfo.Visible = true;
                            lblInfo.Text    = this.DisplayMessage;
                            plcForm.Visible = false;
                        }
                        else
                        {
                            URLHelper.Redirect(ResolveUrl("~/Default.aspx"));
                        }
                    }
                }
            }
            else
            {
                lblError.Text    = errorMessage;
                plcError.Visible = true;
            }
        }
    }
Ejemplo n.º 21
0
    /// <summary>
    /// Reloads the data of the editing forum.
    /// </summary>
    /// <param name="forumObj">Forum object</param>
    private void ReloadData(ForumInfo forumObj)
    {
        // Set main properties
        chkForumOpen.Checked     = forumObj.ForumOpen;
        chkForumLocked.Checked   = forumObj.ForumIsLocked;
        txtForumDescription.Text = forumObj.ForumDescription;
        txtForumDisplayName.Text = forumObj.ForumDisplayName;
        txtForumName.Text        = forumObj.ForumName;

        // Set other settings
        txtImageMaxSideSize.Text  = forumObj.ForumImageMaxSideSize.ToString();
        txtIsAnswerLimit.Text     = forumObj.ForumIsAnswerLimit.ToString();
        txtMaxAttachmentSize.Text = forumObj.ForumAttachmentMaxFileSize.ToString();
        txtBaseUrl.Text           = forumObj.ForumBaseUrl;
        txtUnsubscriptionUrl.Text = forumObj.ForumUnsubscriptionUrl;
        txtOptInURL.Text          = forumObj.ForumOptInApprovalURL;

        // Three state checkboxes
        chkForumRequireEmail.InitFromThreeStateValue(forumObj, "ForumRequireEmail");
        chkCaptcha.InitFromThreeStateValue(forumObj, "ForumUseCAPTCHA");
        chkForumDisplayEmails.InitFromThreeStateValue(forumObj, "ForumDisplayEmails");
        chkUseHTML.InitFromThreeStateValue(forumObj, "ForumHTMLEditor");
        chkAuthorDelete.InitFromThreeStateValue(forumObj, "ForumAuthorDelete");
        chkAuthorEdit.InitFromThreeStateValue(forumObj, "ForumAuthorEdit");
        chkEnableOptIn.InitFromThreeStateValue(forumObj, "ForumEnableOptIn");
        chkSendOptInConfirmation.InitFromThreeStateValue(forumObj, "ForumSendOptInConfirmation");

        // Check if is inherited value
        bool inheritImageMaxSideSize  = (forumObj.GetValue("ForumImageMaxSideSize") == null);
        bool inheritMaxAttachmentSize = (forumObj.GetValue("ForumAttachmentMaxFileSize") == null);
        bool inheritIsAnswerLimit     = (forumObj.GetValue("ForumIsAnswerLimit") == null);
        bool inheritType              = (forumObj.GetValue("ForumType") == null);
        bool inheritBaseUrl           = (forumObj.GetValue("ForumBaseUrl") == null);
        bool inheritUnsubscriptionUrl = (forumObj.GetValue("ForumUnsubscriptionUrl") == null);
        bool inheritLogActivity       = (forumObj.GetValue("ForumLogActivity") == null);
        bool inheritOptInApprovalUrl  = (forumObj.GetValue("ForumOptInApprovalURL") == null);
        // Discussion
        bool inheritDiscussion = (forumObj.GetValue("ForumDiscussionActions") == null);

        // Set properties
        txtImageMaxSideSize.Enabled         = !inheritImageMaxSideSize;
        chkInheritMaxSideSize.Checked       = inheritImageMaxSideSize;
        txtIsAnswerLimit.Enabled            = !inheritIsAnswerLimit;
        chkInheritIsAnswerLimit.Checked     = inheritIsAnswerLimit;
        chkInheritType.Checked              = inheritType;
        txtMaxAttachmentSize.Enabled        = !inheritMaxAttachmentSize;
        chkInheritMaxAttachmentSize.Checked = inheritMaxAttachmentSize;
        txtBaseUrl.Enabled               = !inheritBaseUrl;
        chkInheritBaseUrl.Checked        = inheritBaseUrl;
        txtUnsubscriptionUrl.Enabled     = !inheritUnsubscriptionUrl;
        chkInheritUnsubscribeUrl.Checked = inheritUnsubscriptionUrl;
        txtOptInURL.Enabled              = !inheritOptInApprovalUrl;
        chkInheritOptInURL.Checked       = inheritOptInApprovalUrl;

        plcOnline.Visible             = ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(SiteContext.CurrentSiteName);
        chkInheritLogActivity.Checked = inheritLogActivity;

        // Discussion
        chkInheritDiscussion.Checked = inheritDiscussion;

        // Create script for update inherit values
        ltrScript.Text += ScriptHelper.GetScript(
            "LoadSetting('" + chkLogActivity.ClientID + "', " + (forumObj.ForumLogActivity ? "true" : "false") + ", " + (inheritLogActivity ? "true" : "false") + ", 'chk');" +
            // Discussion
            "LoadSetting('" + radImageSimple.ClientID + "', " + (forumObj.ForumEnableImage ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'rad');" +
            "LoadSetting('" + radImageAdvanced.ClientID + "', " + (forumObj.ForumEnableAdvancedImage ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'rad');" +
            "LoadSetting('" + radImageNo.ClientID + "', " + (!(forumObj.ForumEnableAdvancedImage || forumObj.ForumEnableImage) ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'rad');" +
            "LoadSetting('" + radUrlSimple.ClientID + "', " + (forumObj.ForumEnableURL ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'rad');" +
            "LoadSetting('" + radUrlAdvanced.ClientID + "', " + (forumObj.ForumEnableAdvancedURL ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'rad');" +
            "LoadSetting('" + radUrlNo.ClientID + "', " + (!(forumObj.ForumEnableAdvancedURL || forumObj.ForumEnableURL) ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'rad');" +
            "LoadSetting('" + chkEnableQuote.ClientID + "', " + (forumObj.ForumEnableQuote ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'chk');" +
            "LoadSetting('" + chkEnableBold.ClientID + "', " + (forumObj.ForumEnableFontBold ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'chk');" +
            "LoadSetting('" + chkEnableItalic.ClientID + "', " + (forumObj.ForumEnableFontItalics ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'chk');" +
            "LoadSetting('" + chkEnableStrike.ClientID + "', " + (forumObj.ForumEnableFontStrike ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'chk');" +
            "LoadSetting('" + chkEnableUnderline.ClientID + "', " + (forumObj.ForumEnableFontUnderline ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'chk');" +
            "LoadSetting('" + chkEnableCode.ClientID + "', " + (forumObj.ForumEnableCodeSnippet ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'chk');" +
            "LoadSetting('" + chkEnableColor.ClientID + "', " + (forumObj.ForumEnableFontColor ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'chk');" +
            "LoadSetting('" + radTypeAnswer.ClientID + "', " + (forumObj.ForumType == 2 ? "true" : "false") + ", " + (inheritType ? "true" : "false") + ", 'rad');" +
            "LoadSetting('" + radTypeDiscussion.ClientID + "', " + (forumObj.ForumType == 1 ? "true" : "false") + ", " + (inheritType ? "true" : "false") + ", 'rad');" +
            "LoadSetting('" + radTypeChoose.ClientID + "', " + (forumObj.ForumType == 0 ? "true" : "false") + ", " + (inheritType ? "true" : "false") + ", 'rad');");

        ForumGroupInfo fgi = ForumGroupInfoProvider.GetForumGroupInfo(forumObj.ForumGroupID);

        chkInheritUnsubscribeUrl.Attributes.Add("onclick", "SetInheritance('" + txtUnsubscriptionUrl.ClientID + "', '" + fgi.GroupUnsubscriptionUrl.Replace("'", "\\\'") + "', 'txt');");
        chkInheritBaseUrl.Attributes.Add("onclick", "SetInheritance('" + txtBaseUrl.ClientID + "', '" + fgi.GroupBaseUrl.Replace("'", "\\\'") + "', 'txt');");
        chkInheritOptInURL.Attributes.Add("onclick", "SetInheritance('" + txtOptInURL.PathTextBox.ClientID + "', '" + fgi.GroupOptInApprovalURL.Replace("'", "\\\'") + "', 'txt');ChangeState_" + txtOptInURL.ClientID + "(!this.checked);");

        // Set default values
        chkForumRequireEmail.SetDefaultValue(fgi.GroupRequireEmail);
        chkForumDisplayEmails.SetDefaultValue(fgi.GroupDisplayEmails);
        chkUseHTML.SetDefaultValue(fgi.GroupHTMLEditor);
        chkCaptcha.SetDefaultValue(fgi.GroupUseCAPTCHA);
        chkAuthorDelete.SetDefaultValue(fgi.GroupAuthorDelete);
        chkAuthorEdit.SetDefaultValue(fgi.GroupAuthorEdit);
        chkEnableOptIn.SetDefaultValue(fgi.GroupEnableOptIn);
        chkSendOptInConfirmation.SetDefaultValue(fgi.GroupSendOptInConfirmation);

        // Settings inheritance
        chkInheritIsAnswerLimit.Attributes.Add("onclick", "SetInheritance('" + txtIsAnswerLimit.ClientID + "', '" + fgi.GroupIsAnswerLimit.ToString().Replace("'", "\\\'") + "', 'txt');");
        chkInheritMaxSideSize.Attributes.Add("onclick", "SetInheritance('" + txtImageMaxSideSize.ClientID + "', '" + fgi.GroupImageMaxSideSize.ToString().Replace("'", "\\\'") + "', 'txt');");
        chkInheritType.Attributes.Add("onclick", "SetInheritance('" + radTypeAnswer.ClientID + "', '" + (fgi.GroupType == 2 ? "true" : "false") + "', 'rad');" +
                                      "SetInheritance('" + radTypeDiscussion.ClientID + "', '" + (fgi.GroupType == 1 ? "true" : "false") + "', 'rad');" +
                                      "SetInheritance('" + radTypeChoose.ClientID + "', '" + (fgi.GroupType == 0 ? "true" : "false") + "', 'rad');");
        chkInheritMaxAttachmentSize.Attributes.Add("onclick", "SetInheritance('" + txtMaxAttachmentSize.ClientID + "','" + fgi.GroupAttachmentMaxFileSize.ToString().Replace("'", "\\\'") + "', 'txt');");
        chkInheritLogActivity.Attributes.Add("onclick", "SetInheritance('" + chkLogActivity.ClientID + "','" + fgi.GroupLogActivity.ToString().ToLowerCSafe() + "', 'chk');");

        // Discussion
        string chkList = "'" + radImageSimple.ClientID + ";" + chkEnableBold.ClientID + ";" + chkEnableCode.ClientID + ";" +
                         chkEnableColor.ClientID + ";" + radUrlSimple.ClientID + ";" + chkEnableItalic.ClientID + ";" +
                         radImageAdvanced.ClientID + ";" + radUrlAdvanced.ClientID + ";" + chkEnableQuote.ClientID + ";" +
                         chkEnableStrike.ClientID + ";" + chkEnableUnderline.ClientID + ";" + radImageNo.ClientID + ";" + radUrlNo.ClientID + "'";
        string chkListValues = "'" + fgi.GroupEnableImage.ToString() + ";" + fgi.GroupEnableFontBold.ToString() + ";" + fgi.GroupEnableCodeSnippet.ToString() + ";" +
                               fgi.GroupEnableFontColor.ToString() + ";" + fgi.GroupEnableURL.ToString() + ";" + fgi.GroupEnableFontItalics.ToString() + ";" +
                               fgi.GroupEnableAdvancedImage.ToString() + ";" + fgi.GroupEnableAdvancedURL.ToString() + ";" + fgi.GroupEnableQuote.ToString() + ";" +
                               fgi.GroupEnableFontStrike.ToString() + ";" + fgi.GroupEnableFontUnderline.ToString() + ";" +
                               !(fgi.GroupEnableAdvancedImage || fgi.GroupEnableImage) + ";" + !(fgi.GroupEnableAdvancedURL || fgi.GroupEnableURL) + "'";

        chkInheritDiscussion.Attributes.Add("onclick", "SetInheritance(" + chkList + ", " + chkListValues.ToLowerCSafe() + ", 'chk');");
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (EditedObject != null)
        {
            ContactInfo ci = (ContactInfo)EditedObject;

            // Check permission
            CheckReadPermission(ci.ContactSiteID);

            bool isGlobal = (ci.ContactSiteID == 0);
            bool isMerged = (ci.ContactMergedWithContactID > 0);

            // Show warning if activity logging is disabled
            string siteName = SiteInfoProvider.GetSiteName(ci.ContactSiteID);

            ucDisabledModule.SettingsKeys = "CMSEnableOnlineMarketing";
            ucDisabledModule.InfoText     = GetString("om.onlinemarketing.disabled");
            ucDisabledModule.ParentPanel  = pnlDis;

            pnlDis.Visible = !isGlobal && !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName);

            // Show IP addresses if enabled
            listElem.ShowIPAddressColumn = ActivitySettingsHelper.IPLoggingEnabled(siteName);
            listElem.ShowSiteNameColumn  = IsSiteManager && isGlobal;

            // Restrict WHERE condition for activities of current site (if not in site manager)
            if (!IsSiteManager)
            {
                listElem.SiteID = SiteContext.CurrentSiteID;
            }
            else
            {
                // Show all records in Site Manager
                listElem.SiteID = UniSelector.US_ALL_RECORDS;
            }

            listElem.ContactID             = ci.ContactID;
            listElem.IsMergedContact       = isMerged;
            listElem.IsGlobalContact       = isGlobal;
            listElem.ShowContactNameColumn = isGlobal;
            listElem.ShowSiteNameColumn    = IsSiteManager && isGlobal;
            listElem.ShowRemoveButton      = !isMerged && !isGlobal;
            listElem.OrderBy = "ActivityCreated DESC";

            // Init header action for new custom activities only if contact is not global, a custom activity type exists and user is authorized to manage activities
            if (!isGlobal && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) && MembershipContext.AuthenticatedUser.IsAuthorizedPerResource(ModuleName.CONTACTMANAGEMENT, "ManageActivities"))
            {
                // Disable manual creation of activity if no custom activity type is available
                var activityType = ActivityTypeInfoProvider.GetActivityTypes()
                                   .WhereEquals("ActivityTypeIsCustom", 1)
                                   .WhereEquals("ActivityTypeEnabled", 1)
                                   .WhereEquals("ActivityTypeManualCreationAllowed", 1)
                                   .TopN(1)
                                   .Column("ActivityTypeID")
                                   .FirstOrDefault();

                if (activityType != null)
                {
                    // Prepare target URL
                    string url = ResolveUrl(string.Format("~/CMSModules/ContactManagement/Pages/Tools/Activities/Activity/New.aspx?contactId={0}", ci.ContactID));
                    url = AddSiteQuery(url, ci.ContactSiteID);

                    // Init header action
                    HeaderAction action = new HeaderAction()
                    {
                        Text        = GetString("om.activity.newcustom"),
                        RedirectUrl = url
                    };
                    CurrentMaster.HeaderActions.ActionsList.Add(action);
                }
            }

            if (!RequestHelper.IsPostBack() && QueryHelper.GetBoolean("saved", false))
            {
                // Display 'Save' message after new custom activity was created
                ShowChangesSaved();
            }
        }
    }
Ejemplo n.º 23
0
    /// <summary>
    /// Saves order information from ShoppingCartInfo object to database as new order.
    /// </summary>
    public override bool ProcessStep()
    {
        // Load first step if there is no currency or no address
        if ((this.ShoppingCartInfoObj.ShoppingCartBillingAddressID <= 0) || (this.ShoppingCartInfoObj.ShoppingCartCurrencyID <= 0))
        {
            this.ShoppingCartControl.LoadStep(0);
            return(false);
        }

        // Deal with order note
        this.ShoppingCartControl.SetTempValue(ORDER_NOTE, null);
        this.ShoppingCartInfoObj.ShoppingCartNote = this.txtNote.Text.Trim();

        try
        {
            // Set order culture
            ShoppingCartInfoObj.ShoppingCartCulture = CMSContext.PreferredCultureCode;

            // Update customer preferences
            CustomerInfoProvider.SetCustomerPreferredSettings(ShoppingCartInfoObj);

            // Create order
            ShoppingCartInfoProvider.SetOrder(this.ShoppingCartInfoObj);
        }
        catch (Exception ex)
        {
            lblError.Text = GetString("Ecommerce.OrderPreview.ErrorOrderSave") + " (" + ex.Message + ")";
            return(false);
        }

        // Track order items conversions
        ECommerceHelper.TrackOrderItemsConversions(ShoppingCartInfoObj);

        // Track order conversion
        string name = this.ShoppingCartControl.OrderTrackConversionName;

        ECommerceHelper.TrackOrderConversion(ShoppingCartInfoObj, name);

        // Track order activity
        string siteName = CMSContext.CurrentSiteName;

        if (ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) && this.LogActivityForCustomer && (this.ContactID > 0))
        {
            // Track individual items
            if (ActivitySettingsHelper.PurchasedProductEnabled(siteName))
            {
                this.ShoppingCartControl.TrackActivityPurchasedProducts(ShoppingCartInfoObj, siteName, this.ContactID);
            }
            // Tack entire purchase
            if (ActivitySettingsHelper.PurchaseEnabled(siteName))
            {
                this.ShoppingCartControl.TrackActivityPurchase(ShoppingCartInfoObj.OrderId, this.ContactID,
                                                               CMSContext.CurrentSiteName, URLHelper.CurrentRelativePath,
                                                               ShoppingCartInfoObj.TotalPriceInMainCurrency, CurrencyInfoProvider.GetFormattedPrice(ShoppingCartInfoObj.TotalPriceInMainCurrency,
                                                                                                                                                    CurrencyInfoProvider.GetMainCurrency(CMSContext.CurrentSiteID)));
            }
        }

        // Raise finish order event
        this.ShoppingCartControl.RaiseOrderCompletedEvent();

        // When in CMSDesk
        if (this.ShoppingCartControl.IsInternalOrder)
        {
            if (chkSendEmail.Checked)
            {
                // Send order notification emails
                OrderInfoProvider.SendOrderNotificationToAdministrator(this.ShoppingCartInfoObj);
                OrderInfoProvider.SendOrderNotificationToCustomer(this.ShoppingCartInfoObj);
            }
        }
        // When on the live site
        else if (ECommerceSettings.SendOrderNotification(CMSContext.CurrentSite.SiteName))
        {
            // Send order notification emails
            OrderInfoProvider.SendOrderNotificationToAdministrator(this.ShoppingCartInfoObj);
            OrderInfoProvider.SendOrderNotificationToCustomer(this.ShoppingCartInfoObj);
        }

        return(true);
    }
Ejemplo n.º 24
0
    /// <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;
        }
    }
Ejemplo n.º 25
0
    /// <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, "token");
        currentUrl = URLHelper.RemoveParameterFromUrl(currentUrl, "openid.ns");
        currentUrl = URLHelper.RemoveParameterFromUrl(currentUrl, "openid.mode");
        currentUrl = URLHelper.RemoveParameterFromUrl(currentUrl, "openid.return_to");
        currentUrl = URLHelper.RemoveParameterFromUrl(currentUrl, "openid.claimed_id");
        currentUrl = URLHelper.RemoveParameterFromUrl(currentUrl, "openid.identity");
        currentUrl = URLHelper.RemoveParameterFromUrl(currentUrl, "openid.assoc_handle");
        currentUrl = URLHelper.RemoveParameterFromUrl(currentUrl, "openid.realm");
        currentUrl = URLHelper.RemoveParameterFromUrl(currentUrl, "openid.response_nonce");
        currentUrl = URLHelper.RemoveParameterFromUrl(currentUrl, "openid.signed");
        currentUrl = URLHelper.RemoveParameterFromUrl(currentUrl, "openid.op_endpoint");
        currentUrl = URLHelper.RemoveParameterFromUrl(currentUrl, "openid.pape.auth_level.nist");
        currentUrl = URLHelper.RemoveParameterFromUrl(currentUrl, "openid.sig");

        // Get OpenID response status
        switch (openIDhelper.CheckStatus())
        {
        // User is authenticated
        case CMSOpenIDHelper.RESPONSE_AUTHENTICATED:
            // Claimed ID not found  = save new user
            if (OpenIDUserInfoProvider.GetUserInfoByOpenID(openIDhelper.ClaimedIdentifier) == null)
            {
                // Check whether additional user info page is set
                string additionalInfoPage = SettingsKeyProvider.GetStringValue(siteName + ".CMSRequiredOpenIDPage").Trim();

                // No page set, user can be created
                if (String.IsNullOrEmpty(additionalInfoPage))
                {
                    // Register new user
                    UserInfo ui = UserInfoProvider.AuthenticateOpenIDUser(openIDhelper.ClaimedIdentifier, ValidationHelper.GetString(SessionHelper.GetValue(SESSION_NAME_URL), null), siteName, false, true, ref error);

                    // If user was found or successfuly created
                    if (ui != null)
                    {
                        // 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;
                        }
                        // Load e-mail
                        if (!String.IsNullOrEmpty(openIDhelper.Email))
                        {
                            ui.Email = openIDhelper.Email;
                        }
                        // 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);

                        // If user is enabled
                        if (ui.Enabled)
                        {
                            // Create autentification cookie
                            UserInfoProvider.SetAuthCookieWithUserData(ui.UserName, true, Session.Timeout, new string[] { "openidlogin" });
                            // 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);
                                }
                            }
                        }

                        // 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);

                        // Notify administrator
                        if (this.NotifyAdministrator && !String.IsNullOrEmpty(this.FromAddress) && !String.IsNullOrEmpty(this.ToAddress))
                        {
                            UserInfoProvider.NotifyAdministrator(ui, this.FromAddress, this.ToAddress);
                        }

                        // Track user registration
                        UserInfoProvider.TrackUserRegistration(this.TrackConversionName, this.ConversionValue, siteName, ui);

                        // Log activity
                        if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) && ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) &&
                            ActivitySettingsHelper.UserLoginEnabled(siteName))
                        {
                            int contactId = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui);
                            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, openIDhelper.GetResponseObject());

                    // 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);
                }
            }
            // Claimed OpenID is in DB
            else
            {
                // Login existing user
                UserInfo ui = UserInfoProvider.AuthenticateOpenIDUser(openIDhelper.ClaimedIdentifier, ValidationHelper.GetString(SessionHelper.GetValue(SESSION_NAME_URL), null), siteName, false, true, ref error);

                if ((ui != null) && (ui.Enabled))
                {
                    // Create autentification cookie
                    UserInfoProvider.SetAuthCookieWithUserData(ui.UserName, true, Session.Timeout, new string[] { "openilogin" });

                    // 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;

        // Authentication was canceled
        case CMSOpenIDHelper.RESPONSE_CANCELED:
            lblError.Text    = GetString("openid.logincanceled");
            lblError.Visible = true;
            break;

        // Authentication failed
        case CMSOpenIDHelper.RESPONSE_FAILED:
            lblError.Text    = GetString("openid.loginfailed");
            lblError.Visible = true;
            break;
        }
    }
Ejemplo n.º 26
0
    /// <summary>
    /// Logs activity.
    /// </summary>
    /// <param name="bci">Forum subscription</param>
    private void LogSubscriptionActivity(ForumSubscriptionInfo fsi, ForumInfo fi)
    {
        string siteName = CMSContext.CurrentSiteName;

        if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || (fsi == null) || (fi == null) || !fi.ForumLogActivity || !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) ||
            !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) || !ActivitySettingsHelper.ForumPostSubscriptionEnabled(siteName))
        {
            return;
        }

        int contactId = ModuleCommands.OnlineMarketingGetCurrentContactID();
        Dictionary <string, object> contactData = new Dictionary <string, object>();

        contactData.Add("ContactEmail", fsi.SubscriptionEmail);
        ModuleCommands.OnlineMarketingUpdateContactFromExternalSource(contactData, false, contactId);
        var data = new ActivityData()
        {
            ContactID    = contactId,
            SiteID       = CMSContext.CurrentSiteID,
            Type         = PredefinedActivityType.SUBSCRIPTION_FORUM_POST,
            TitleData    = fi.ForumName,
            ItemID       = fi.ForumID,
            ItemDetailID = fsi.SubscriptionID,
            URL          = URLHelper.CurrentRelativePath,
            NodeID       = CMSContext.CurrentDocument.NodeID,
            Culture      = CMSContext.CurrentDocument.DocumentCulture,
            Campaign     = CMSContext.Campaign
        };

        ActivityLogProvider.LogActivity(data);
    }
Ejemplo n.º 27
0
    /// <summary>
    /// Get user information and logs user (register if no user found)
    /// </summary>
    private void ProcessLiveIDLogin()
    {
        // Get authorization code from URL
        String code = QueryHelper.GetString("code", String.Empty);

        // Additional info page for login
        string additionalInfoPage = SettingsKeyProvider.GetStringValue(siteName + ".CMSLiveIDRequiredUserDataPage");

        // Create windows login object
        WindowsLiveLogin wwl = new WindowsLiveLogin(siteName);

        // Windows live User
        WindowsLiveLogin.User liveUser = null;
        if (!WindowsLiveLogin.UseServerSideAuthorization)
        {
            if (!RequestHelper.IsPostBack())
            {
                // If client authentication, get token displayed in url after # from window.location
                String script = ControlsHelper.GetPostBackEventReference(this, "#").Replace("'#'", "window.location");
                ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "PostbackScript", ScriptHelper.GetScript(script));
            }
            else
            {
                // Try to get full url from event argument
                string fullurl = Request["__EVENTARGUMENT"];

                // Authentication token - use to get uid
                String token = ParseToken(fullurl, @"authentication_token=([\w\d.-]+)&");

                // User token - this token is used in server auth. scenario. It's stored in user object (for possible further use) so parse it too and store it
                String accessToken = ParseToken(fullurl, @"access_token=([%\w\d.-]+)&");

                if (token != String.Empty)
                {
                    // Return context from session
                    GetLoginInformation();

                    // Authenticate user by found token
                    liveUser = wwl.AuthenticateClientToken(token, relativeURL, accessToken);
                    if (liveUser != null)
                    {
                        // Set info to refresh to parent page
                        ScriptHelper.RegisterWOpenerScript(Page);
                        CreateCloseScript("");
                    }
                }
            }
        }
        else
        {
            GetLoginInformation();

            // Process login via Live ID
            liveUser = wwl.ProcessLogin(code, relativeURL);
        }

        // Authorization sucesfull
        if (liveUser != null)
        {
            // Find user by ID
            UserInfo winUser = UserInfoProvider.GetUserInfoByWindowsLiveID(liveUser.Id);

            string error = String.Empty;

            // Register new user
            if (winUser == null)
            {
                // Check whether additional user info page is set
                // No page set, user can be created/sign
                if (additionalInfoPage == String.Empty)
                {
                    // Create new user user
                    UserInfo ui = UserInfoProvider.AuthenticateWindowsLiveUser(liveUser.Id, siteName, true, ref error);

                    // Remove live user object from session, won't be needed
                    Session.Remove("windowsliveloginuser");

                    // If user was found or successfuly created
                    if ((ui != null) && (ui.Enabled))
                    {
                        // Send registration e-mails
                        // E-mail confirmation is not required as user already provided confirmation by successful login using LiveID
                        UserInfoProvider.SendRegistrationEmails(ui, null, null, false, false);

                        // Track registration into analytics
                        double val = ValidationHelper.GetDouble(CMSContext.CurrentResolver.ResolveMacros(conversionValue), 0);
                        UserInfoProvider.TrackUserRegistration(conversionName, val, siteName, ui);

                        // Log registration activity
                        if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) && ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) &&
                            ActivitySettingsHelper.UserRegistrationEnabled(siteName))
                        {
                            int      contactId  = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui);
                            TreeNode currentDoc = CMSContext.CurrentDocument;
                            ActivityLogProvider.LogRegistrationActivity(contactId,
                                                                        ui, URLHelper.CurrentRelativePath, (currentDoc != null ? currentDoc.NodeID : 0), siteName, CMSContext.Campaign, (currentDoc != null ? currentDoc.DocumentCulture : null));
                        }

                        SetAuthCookieAndRedirect(ui);
                    }
                    // User not created
                    else
                    {
                        if (WindowsLiveLogin.UseServerSideAuthorization)
                        {
                            WindowsLiveLogin.ClearCookieAndRedirect(loginPage);
                        }
                        else
                        {
                            CreateCloseScript("clearcookieandredirect");
                        }
                    }
                }
                // Required data page exists
                else
                {
                    // Store user object in session for additional info page
                    SessionHelper.SetValue("windowsliveloginuser", liveUser);

                    if (WindowsLiveLogin.UseServerSideAuthorization)
                    {
                        // Redirect to additional info page
                        URLHelper.Redirect(URLHelper.ResolveUrl(additionalInfoPage));
                    }
                    else
                    {
                        CreateCloseScript("redirectToAdditionalPage");
                    }
                }
            }
            else
            {
                UserInfo ui = UserInfoProvider.AuthenticateWindowsLiveUser(liveUser.Id, siteName, true, ref error);

                // If user was found
                if ((ui != null) && (ui.Enabled))
                {
                    SetAuthCookieAndRedirect(ui);
                }
            }
        }
    }
Ejemplo n.º 28
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // If StopProcessing flag is set, do nothing
        if (StopProcessing)
        {
            Visible = false;
            return;
        }

        string subscriptionHash = QueryHelper.GetString("subscriptionhash", string.Empty);
        string requestTime      = QueryHelper.GetString("datetime", string.Empty);

        DateTime datetime = DateTimeHelper.ZERO_TIME;

        // Get date and time
        if (!string.IsNullOrEmpty(requestTime))
        {
            try
            {
                datetime = DateTime.ParseExact(requestTime, SecurityHelper.EMAIL_CONFIRMATION_DATETIME_FORMAT, null);
            }
            catch
            {
                lblInfo.Text = ResHelper.GetString("newsletter.approval_failed");
                return;
            }
        }

        if (string.IsNullOrEmpty(subscriptionHash))
        {
            this.Visible = false;
            return;
        }

        // Try to approve subscription
        SubscriberProvider.ApprovalResult result = SubscriberProvider.ApproveSubscription(subscriptionHash, false, CMSContext.CurrentSiteName, datetime);

        switch (result)
        {
        // Approving subscription was successful
        case SubscriberProvider.ApprovalResult.Success:
            if (!String.IsNullOrEmpty(this.SuccessfulApprovalText))
            {
                lblInfo.Text = this.SuccessfulApprovalText;
            }
            else
            {
                lblInfo.Text = ResHelper.GetString("newsletter.successful_approval");
            }

            // Log newsletter subscription activity
            if ((CMSContext.ViewMode == ViewModeEnum.LiveSite))
            {
                SubscriberNewsletterInfo sni = SubscriberNewsletterInfoProvider.GetSubscriberNewsletterInfo(subscriptionHash);
                if (sni != null)
                {
                    // Load subscriber info and make sure activity modul is enabled
                    Subscriber sb = SubscriberProvider.GetSubscriber(sni.SubscriberID);
                    if ((sb != null) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(sb.SubscriberSiteID))
                    {
                        int        siteId = sb.SubscriberSiteID;
                        Newsletter news   = NewsletterProvider.GetNewsletter(sni.NewsletterID);
                        if (news.NewsletterLogActivity && ActivitySettingsHelper.NewsletterSubscribeEnabled(siteId))
                        {
                            // Under what contacs this subscriber belogs to?
                            int contactId = ActivityTrackingHelper.GetContactID(sb);

                            if (contactId > 0)
                            {
                                ModuleCommands.OnlineMarketingUpdateContactFromExternalData(sb, contactId);
                                ModuleCommands.OnlineMarketingCreateRelation(sb.SubscriberID, MembershipType.NEWSLETTER_SUBSCRIBER, contactId);
                                var data = new ActivityData()
                                {
                                    ContactID = contactId,
                                    SiteID    = sb.SubscriberSiteID,
                                    Type      = PredefinedActivityType.NEWSLETTER_SUBSCRIBING,
                                    TitleData = news.NewsletterName,
                                    ItemID    = news.NewsletterID,
                                    URL       = URLHelper.CurrentRelativePath,
                                    Campaign  = CMSContext.Campaign
                                };
                                ActivityLogProvider.LogActivity(data);
                            }
                        }
                    }
                }
            }
            break;

        // Subscription was already approved
        case SubscriberProvider.ApprovalResult.Failed:
            if (!String.IsNullOrEmpty(this.UnsuccessfulApprovalText))
            {
                lblInfo.Text = this.UnsuccessfulApprovalText;
            }
            else
            {
                lblInfo.Text = ResHelper.GetString("newsletter.approval_failed");
            }
            break;

        case SubscriberProvider.ApprovalResult.TimeExceeded:
            if (!String.IsNullOrEmpty(this.UnsuccessfulApprovalText))
            {
                lblInfo.Text = this.UnsuccessfulApprovalText;
            }
            else
            {
                lblInfo.Text = ResHelper.GetString("newsletter.approval_timeexceeded");
            }
            break;


        // Subscription not found
        default:
        case SubscriberProvider.ApprovalResult.NotFound:
            if (!String.IsNullOrEmpty(this.UnsuccessfulApprovalText))
            {
                lblInfo.Text = this.UnsuccessfulApprovalText;
            }
            else
            {
                lblInfo.Text = ResHelper.GetString("newsletter.approval_invalid");
            }
            break;
        }
    }
Ejemplo n.º 29
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Visible)
        {
            EnableViewState = false;
        }

        if (StopProcessing)
        {
            // Do nothing
            Visible = false;
            groupPictureEdit.StopProcessing = true;
            groupPageURLElem.StopProcessing = true;
        }
        else
        {
            string currSiteName = SiteContext.CurrentSiteName;
            plcGroupLocation.Visible             = DisplayAdvanceOptions;
            plcAdvanceOptions.Visible            = DisplayAdvanceOptions;
            groupPageURLElem.EnableSiteSelection = false;
            plcOnline.Visible = ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(currSiteName);

            ctrlSiteSelectStyleSheet.CurrentSelector.ReturnColumnName = "StyleSheetID";
            ctrlSiteSelectStyleSheet.SiteId             = SiteContext.CurrentSiteID;
            ctrlSiteSelectStyleSheet.AllowEditButtons   = false;
            ctrlSiteSelectStyleSheet.IsLiveSite         = IsLiveSite;
            lblStyleSheetName.AssociatedControlClientID = ctrlSiteSelectStyleSheet.CurrentSelector.ClientID;

            // Is allow edit display name is set on live site
            if ((AllowChangeGroupDisplayName) && (IsLiveSite))
            {
                if (!plcAdvanceOptions.Visible)
                {
                    plcCodeName.Visible = false;
                }
                plcAdvanceOptions.Visible = true;
            }

            // Web parts theme selector visibility
            if ((!AllowSelectTheme) && (IsLiveSite))
            {
                plcStyleSheetSelector.Visible = false;
            }

            RaiseOnCheckPermissions(PERMISSION_READ, this);

            if (StopProcessing)
            {
                return;
            }

            if ((GroupID == 0) && HideWhenGroupIsNotSupplied)
            {
                Visible = false;
                return;
            }

            InitializeForm();

            groupInfo = GroupInfoProvider.GetGroupInfo(GroupID);
            if (groupInfo != null)
            {
                if (!RequestHelper.IsPostBack())
                {
                    // Handle existing Group editing - prepare the data
                    if (GroupID > 0)
                    {
                        HandleExistingGroup();
                    }
                }

                groupPictureEdit.GroupInfo = groupInfo;

                // UI Tools theme selector visibility
                if ((!IsLiveSite) && (groupInfo.GroupNodeGUID == Guid.Empty))
                {
                    plcStyleSheetSelector.Visible = false;
                }

                // Init theme selector
                if (plcStyleSheetSelector.Visible)
                {
                    if (!URLHelper.IsPostback())
                    {
                        TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);
                        if (groupInfo.GroupNodeGUID != Guid.Empty)
                        {
                            TreeNode node = tree.SelectSingleNode(groupInfo.GroupNodeGUID, TreeProvider.ALL_CULTURES, SiteContext.CurrentSiteName);
                            if (node != null)
                            {
                                ctrlSiteSelectStyleSheet.Value = node.DocumentStylesheetID;
                            }
                        }
                    }
                }
            }
            else
            {
                plcStyleSheetSelector.Visible = false;
            }

            txtDescription.IsLiveSite   = IsLiveSite;
            groupPictureEdit.IsLiveSite = IsLiveSite;
            groupPageURLElem.IsLiveSite = IsLiveSite;
        }
    }
Ejemplo n.º 30
0
    /// <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);
        }
    }