/// <summary>
    /// Displays warning message in "Design mode".
    /// </summary>
    /// <param name="message">Message that will be displayed. Default misconfiration message is used when no parameter is given.</param>
    private bool DisplayMessage(string message = null)
    {
        // Error label is displayed in Design mode when LinkedIn is disabled
        if (PortalContext.IsDesignMode(PortalContext.ViewMode))
        {
            if (String.IsNullOrEmpty(message))
            {
                // Default message informing about misconfiguration is dispalyed.
                StringBuilder parameter = new StringBuilder();
                parameter.Append(UIElementInfoProvider.GetApplicationNavigationString("cms", "Settings") + " -> ");
                parameter.Append(GetString("settingscategory.cmsmembership") + " -> ");
                parameter.Append(GetString("settingscategory.cmsmembershipauthentication") + " -> ");
                parameter.Append(GetString("settingscategory.cmslinkedin"));
                if (MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin))
                {
                    // Make it link for Admin
                    parameter.Insert(0, "<a href=\"" + URLHelper.GetAbsoluteUrl(UIContextHelper.GetApplicationUrl("cms", "settings")) + "\" target=\"_top\">");
                    parameter.Append("</a>");
                }

                message = String.Format(GetString("mem.linkedin.disabled"), parameter.ToString());
            }
            lblError.Text    = message;
            lblError.Visible = true;
        }

        return(lblError.Visible);
    }
Example #2
0
    /// <summary>
    /// Prepares JSON object to be inserted to the breadcrumbs. This object will be used when updating breadcrumbs after changing display name of the campaign.
    /// </summary>
    /// <returns>List of objects containing breadcrumb for root element and single campaign.</returns>
    private object GetBreadcrumbsData()
    {
        var breadcrumbsList = new List <object>();
        var application     = UIContext.UIElement.Application;

        // Root application
        string rootRedirectUrl = URLHelper.ResolveUrl(UIContextHelper.GetApplicationUrl(application));

        breadcrumbsList.Add(new
        {
            text        = MacroResolver.Resolve(application.ElementDisplayName),
            redirectUrl = rootRedirectUrl,
            isRoot      = true
        });

        // (Campaign)
        breadcrumbsList.Add(new
        {
            suffix = ResHelper.GetString("analytics.campaign")
        });


        return(new
        {
            data = breadcrumbsList,
            pin = new
            {
                elementGuid = UIElementInfoProvider.GetUIElementInfo(UIContext.UIElement.ElementParentID).ElementGUID,
                applicationGuid = application.ElementGUID,
                objectType = CampaignInfo.OBJECT_TYPE
            }
        });
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            if (SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSEnableWindowsLiveID"))
            {
                plcPasswordNew.Visible  = AllowFormsAuthentication;
                pnlExistingUser.Visible = AllowExistingUser;

                liveUser = SessionHelper.GetValue("windowsliveloginuser") as WindowsLiveLogin.User;

                // There is no windows live user object stored in session - hide all
                if ((liveUser == null) && HideForNoLiveID)
                {
                    Visible = false;
                }

                // WAI validation
                lblPasswordNew.AssociatedControlClientID = passStrength.InputClientID;
            }
            else
            {
                // Error label is displayed in Design mode when Windows Live ID is disabled
                if (PortalContext.IsDesignMode(PortalContext.ViewMode))
                {
                    StringBuilder parameter = new StringBuilder();
                    parameter.Append(UIElementInfoProvider.GetApplicationNavigationString("cms", "Settings") + " -> ");
                    parameter.Append(GetString("settingscategory.cmsmembership") + " -> ");
                    parameter.Append(GetString("settingscategory.cmsmembershipauthentication") + " -> ");
                    parameter.Append(GetString("settingscategory.cmswindowsliveid"));
                    if (MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin))
                    {
                        // Make it link for Admin
                        parameter.Insert(0, "<a href=\"" + URLHelper.GetAbsoluteUrl(UIContextHelper.GetApplicationUrl("cms", "settings")) + "\" target=\"_top\">");
                        parameter.Append("</a>");
                    }

                    lblError.Text      = String.Format(GetString("mem.liveid.disabled"), parameter.ToString());
                    plcError.Visible   = true;
                    plcContent.Visible = false;
                }
                else
                {
                    Visible = false;
                }
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Try skip IIS http errors
        Response.TrySkipIisCustomErrors = true;
        // Set error state
        Response.StatusCode = 503;

        titleElem.TitleText = GetString("InvalidLicense.Header");
        lblRawUrl.Text      = GetString("InvalidLicense.RawUrl");
        lblResult.Text      = GetString("InvalidLicense.Result");

        // URL
        string rawUrl = QueryHelper.GetString("rawUrl", String.Empty).Trim();

        if (rawUrl != String.Empty)
        {
            lblRawUrlValue.Text = HttpUtility.HtmlEncode(rawUrl);
        }
        else
        {
            lblRawUrl.Visible      = false;
            lblRawUrlValue.Visible = false;
        }

        // Validation result
        LicenseValidationEnum mResult = (LicenseValidationEnum)QueryHelper.GetInteger("Result", Convert.ToInt32(LicenseValidationEnum.NotAvailable));

        lblResultValue.Text = LicenseHelper.GetValidationResultString(mResult);

        // URL 'Go to:'
        lnkGoToValue.NavigateUrl = UIContextHelper.GetApplicationUrl("Licenses", "Licenses");
        lblAddLicenseValue.Text  = RequestContext.CurrentDomain;

        // How to get license options
        lnkOpt1.NavigateUrl = CLIENT_PORTAL;
        lnkOpt1.ToolTip     = CLIENT_PORTAL;
        lnkOpt3.NavigateUrl = CLIENT_PORTAL;
        lnkOpt3.ToolTip     = CLIENT_PORTAL;

        if (mResult == LicenseValidationEnum.Expired)
        {
            genTrial.InnerHtml = GetString("invalidlicense.trialexpired");
            genTrial.Visible   = true;
        }
    }
Example #5
0
    /// <summary>
    /// Gets HTML list code representing the <paramref name="uiElement"/> where can visitors go after the import has finished.
    /// </summary>
    /// <param name="uiElement">UI element the caption, icon and link are loaded from</param>
    /// <param name="description">Description of the element (i.e. some clarification what the application is good for)</param>
    /// <returns>HTML list code representing the <paramref name="uiElement"/> with given <paramref name="description"/></returns>
    private string GetContinueToSmartTipListContent(UIElementInfo uiElement, string description)
    {
        string applicationUrl = UIContextHelper.GetApplicationUrl(UIContextHelper.GetResourceName(uiElement.ElementResourceID), uiElement.ElementName);

        return(string.Format(@"
<li>
    <div class=""om-import-csv-next-steps-initial"">
        <i aria-hidden=""true"" class=""{0} cms-icon-100""></i>
    </div>
    <div class=""om-import-csv-next-steps-description"">
        <p class=""lead"">
            <a href=""{1}"" target=""_blank"">{2}</a>
        </p>
        <p>
            {3}
        </p>
    </div>
</li>", uiElement.ElementIconClass, URLHelper.ResolveUrl(applicationUrl), MacroResolver.Resolve(uiElement.ElementCaption), description));
    }
Example #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Try skip IIS http errors
        Response.TrySkipIisCustomErrors = true;
        // Set error state
        Response.StatusCode = 503;

        string mPrefix = "http://";

        titleElem.TitleText = GetString("Message.InvalidWebSite");
        string mDomain = RequestContext.URL.Host;

        if (RequestContext.URL.Port != 80)
        {
            mDomain = mDomain + ":" + RequestContext.URL.Port.ToString();
        }

        if (RequestContext.IsSSL)
        {
            mPrefix = "https://";
        }

        lblMessage.Text    = GetString("Message.TextInvalidWebSite") + " ";
        lblMessageUrl.Text = mPrefix + mDomain + HttpUtility.HtmlEncode(RequestContext.CurrentURL);

        lblInfo1.Text      = GetString("Message.InfoInvalidWebSite1") + " ";
        lblInfo2.Text      = " " + GetString("Message.InfoInvalidWebSite2") + " ";
        lblInfoDomain.Text = mDomain;

        // Get the Sites page url
        lnkAdministration.Text        = GetString("Message.LinkInvalidWebSite");
        lnkAdministration.NavigateUrl = UIContextHelper.GetApplicationUrl("cms", "sites");

        if (LicenseContext.CurrentLicenseInfo == null)
        {
            pnlLicense.Visible = true;
        }
    }
Example #7
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            if (SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSEnableWindowsLiveID"))
            {
                string siteName = SiteContext.CurrentSiteName;
                if (!string.IsNullOrEmpty(siteName))
                {
                    // Get LiveID settings
                    string appId  = SettingsKeyInfoProvider.GetStringValue(siteName + ".CMSApplicationID");
                    string secret = SettingsKeyInfoProvider.GetStringValue(siteName + ".CMSApplicationSecret");

                    if (!WindowsLiveLogin.UseServerSideAuthorization)
                    {
                        // Add windows live ID script
                        ScriptHelper.RegisterClientScriptInclude(Page, typeof(string), "WLScript", LIVE_CONNECT_API_URL);

                        // Add login functions
                        String loginLiveIDClientScript = @"

                            function signUserIn() {
                                var scopesArr = ['wl.signin'];
                                WL.login({ scope: scopesArr });
                            }
                    
                            function refreshLiveID(param)
                            {
                                " + ControlsHelper.GetPostBackEventReference(btnHidden, "#").Replace("'#'", "param") + @" 
                            }                                       
                        ";

                        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ClientInitLiveIDScript", ScriptHelper.GetScript(loginLiveIDClientScript));
                    }

                    // Check valid Windows LiveID parameters
                    if ((appId == string.Empty) || (secret == string.Empty))
                    {
                        lblError.Visible = true;
                        lblError.Text    = GetString("liveid.incorrectsettings");
                        return;
                    }

                    WindowsLiveLogin wll = new WindowsLiveLogin(appId, secret);

                    // If user is already authenticated
                    if (AuthenticationHelper.IsAuthenticated())
                    {
                        // If signout should be visible and user has LiveID registered

                        if (ShowSignOut && !String.IsNullOrEmpty(MembershipContext.AuthenticatedUser.UserSettings.WindowsLiveID))
                        {
                            // Get data from auth cookie
                            string[] userData = AuthenticationHelper.GetUserDataFromAuthCookie();

                            // Check if user has truly logged in by LiveID
                            if ((userData != null) && (Array.IndexOf(userData, "liveidlogin") >= 0))
                            {
                                // Redirect to Windows Live and back to "home" page
                                string defaultAliasPath = SettingsKeyInfoProvider.GetStringValue(siteName + ".CMSDefaultAliasPath");
                                string url    = DocumentURLProvider.GetUrl(defaultAliasPath);
                                string navUrl = wll.GetLogoutUrl(URLHelper.GetAbsoluteUrl(url));

                                // If text is set use text/button link
                                if (!string.IsNullOrEmpty(SignOutText))
                                {
                                    // Button link
                                    if (ShowAsButton)
                                    {
                                        btnSignOut.CommandArgument = navUrl;
                                        btnSignOut.Text            = SignOutText;
                                        btnSignOut.Visible         = true;
                                    }
                                    // Text link
                                    else
                                    {
                                        btnSignOutLink.CommandArgument = navUrl;
                                        btnSignOutLink.Text            = SignOutText;
                                        btnSignOutLink.Visible         = true;
                                    }
                                }
                                // Image link
                                else
                                {
                                    btnSignOutImage.CommandArgument = navUrl;
                                    btnSignOutImage.ImageUrl        = ResolveUrl(SignOutImageURL);
                                    btnSignOutImage.Visible         = true;
                                    btnSignOut.Text = GetString("webparts_membership_signoutbutton.signout");
                                }
                            }
                        }
                        else
                        {
                            Visible = false;
                        }
                    }
                    // Sign In
                    else
                    {
                        // Create return URL
                        string returnUrl = QueryHelper.GetText("returnurl", "");
                        returnUrl = (returnUrl == String.Empty) ? RequestContext.CurrentURL : returnUrl;

                        // Create parameters for LiveID request URL
                        String[] parameters = new String[3];
                        parameters[0] = returnUrl;
                        parameters[1] = TrackConversionName;
                        parameters[2] = ConversionValue.ToString();
                        SessionHelper.SetValue("LiveIDInformtion", parameters);

                        returnUrl = wll.GetLoginUrl();

                        // Get App ID
                        appId = SettingsKeyInfoProvider.GetStringValue(siteName + ".CMSApplicationID");

                        // Create full LiveID request URL
                        string navUrl = AUTHORIZATION_URL + "?client_id=" + appId + "&redirect=true&scope=wl.signin&response_type=code&redirect_uri=" + HttpUtility.UrlEncode(returnUrl);

                        // If text is set use text/button link
                        if (!string.IsNullOrEmpty(SignInText))
                        {
                            // Button link
                            if (ShowAsButton)
                            {
                                AssignButtonControl(navUrl, returnUrl, appId);
                                btnSignIn.Text = SignInText;
                            }
                            // Text link
                            else
                            {
                                AssignHyperlinkControl(navUrl, returnUrl, appId);
                                lnkSignIn.Text = SignInText;
                            }
                        }
                        // Image link
                        else
                        {
                            AssignHyperlinkControl(navUrl, returnUrl, appId);
                            lnkSignIn.ImageUrl = ResolveUrl(SignInImageURL);
                            lnkSignIn.Text     = GetString("webparts_membership_signoutbutton.signin");
                        }
                    }
                }
            }
            else
            {
                // Error label is displayed in Design mode when Windows Live ID is disabled
                if (PortalContext.IsDesignMode(PortalContext.ViewMode))
                {
                    StringBuilder parameter = new StringBuilder();
                    parameter.Append(UIElementInfoProvider.GetApplicationNavigationString("cms", "Settings") + " -> ");
                    parameter.Append(GetString("settingscategory.cmsmembership") + " -> ");
                    parameter.Append(GetString("settingscategory.cmsmembershipauthentication") + " -> ");
                    parameter.Append(GetString("settingscategory.cmswindowsliveid"));
                    if (MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin))
                    {
                        // Make it link for Admin
                        parameter.Insert(0, "<a href=\"" + URLHelper.GetAbsoluteUrl(UIContextHelper.GetApplicationUrl("cms", "settings")) + "\" target=\"_top\">");
                        parameter.Append("</a>");
                    }

                    lblError.Text    = String.Format(GetString("mem.liveid.disabled"), parameter);
                    lblError.Visible = true;
                }
                else
                {
                    Visible = false;
                }
            }
        }
    }
Example #8
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (!StopProcessing)
        {
            plcError.Visible = false;

            // Check renamed DLL library
            if (!SystemContext.IsFullTrustLevel)
            {
                // Error label is displayed when OpenID library is not enabled
                lblError.ResourceString = "socialnetworking.fulltrustrequired";
                plcError.Visible        = true;
                plcContent.Visible      = false;
            }

            // Check if LinkedIn module is enabled
            if (!LinkedInHelper.LinkedInIsAvailable(SiteContext.CurrentSiteName) && !plcError.Visible)
            {
                // Error label is displayed only in Design mode
                if (PortalContext.IsDesignMode(PortalContext.ViewMode))
                {
                    StringBuilder parameter = new StringBuilder();
                    parameter.Append(UIElementInfoProvider.GetApplicationNavigationString("cms", "Settings") + " -> ");
                    parameter.Append(GetString("settingscategory.cmsmembership") + " -> ");
                    parameter.Append(GetString("settingscategory.cmsmembershipauthentication") + " -> ");
                    parameter.Append(GetString("settingscategory.cmslinkedin"));
                    if (MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin))
                    {
                        // Make it link for Admin
                        parameter.Insert(0, "<a href=\"" + URLHelper.GetAbsoluteUrl(UIContextHelper.GetApplicationUrl("cms", "settings")) + "\" target=\"_top\">");
                        parameter.Append("</a>");
                    }

                    lblError.Text      = String.Format(GetString("mem.linkedin.disabled"), parameter);
                    plcError.Visible   = true;
                    plcContent.Visible = false;
                }
                // In other modes is web part hidden
                else
                {
                    Visible = false;
                }
            }

            // Display web part when no error occurred
            if (!plcError.Visible && Visible)
            {
                // Hide web part if user is authenticated
                if (AuthenticationHelper.IsAuthenticated())
                {
                    Visible = false;
                    return;
                }

                plcPasswordNew.Visible  = AllowFormsAuthentication;
                pnlExistingUser.Visible = AllowExistingUser;

                // Load LinkedIn data from session
                linkedInHelper = new LinkedInHelper();
                string linkedInData = ValidationHelper.GetString(SessionHelper.GetValue(SESSION_NAME_USERDATA), string.Empty);
                if (!string.IsNullOrEmpty(linkedInData))
                {
                    var doc = new XmlDocument();
                    doc.LoadXml(linkedInData);
                    linkedInHelper.Initialize(doc);
                }

                // There is no LinkedIn user ID stored in session - hide all
                if (string.IsNullOrEmpty(linkedInHelper.MemberId) && HideForNoLinkedInUserID)
                {
                    Visible = false;
                }
                else if (!RequestHelper.IsPostBack())
                {
                    LoadData();
                }
            }
        }
        else
        {
            Visible = false;
        }
    }
Example #9
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            Visible = false;
        }
        else
        {
            if (SystemContext.IsFullTrustLevel)
            {
                // Check if OpenID module is enabled
                if (SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSEnableOpenID"))
                {
                    ltlScript.Text = ScriptHelper.GetIncludeScript(PROVIDERS_LOCATION + "OpenIDSelector.js");
                    lblError.Text  = GetString("openid.invalidid");

                    SetProviders();
                    DisplayButtons();

                    openIDhelper = new CMSOpenIDHelper();
                    CheckStatus();
                }
                else
                {
                    // Error label is displayed in Design mode when OpenID is disabled
                    if (PortalContext.IsDesignMode(PortalContext.ViewMode))
                    {
                        StringBuilder parameter = new StringBuilder();
                        parameter.Append(UIElementInfoProvider.GetApplicationNavigationString("cms", "Settings") + " -> ");
                        parameter.Append(GetString("settingscategory.cmsmembership") + " -> ");
                        parameter.Append(GetString("settingscategory.cmsmembershipauthentication") + " -> ");
                        parameter.Append(GetString("settingscategory.cmsopenid"));
                        if (MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin))
                        {
                            // Make it link for Admin
                            parameter.Insert(0, "<a href=\"" + URLHelper.GetAbsoluteUrl(UIContextHelper.GetApplicationUrl("cms", "settings")) + "\" target=\"_top\">");
                            parameter.Append("</a>");
                        }

                        lblError.Text    = String.Format(GetString("mem.openid.disabled"), parameter.ToString());
                        lblError.Visible = true;
                        txtInput.Visible = false;
                    }
                    else
                    {
                        Visible = false;
                    }
                }
            }
            // Error label is displayed in Design mode when OpenID library is not enabled
            else
            {
                lblError.Text    = ResHelper.GetString("socialnetworking.fulltrustrequired");
                lblError.Visible = true;
                txtInput.Visible = false;
            }
        }
    }
Example #10
0
 private void lnkSkipLicense_Click(object sender, EventArgs e)
 {
     AuthenticationHelper.AuthenticateUser("administrator", false);
     URLHelper.Redirect(UIContextHelper.GetApplicationUrl("cms", "sites", "action=new"));
 }
    /// <summary>
    /// Configures selectors.
    /// </summary>
    private void SetupSelectors()
    {
        // Setup role selector
        selectRole.CurrentSelector.SelectionMode    = SelectionModeEnum.MultipleButton;
        selectRole.CurrentSelector.OnItemsSelected += RolesSelector_OnItemsSelected;
        selectRole.CurrentSelector.ReturnColumnName = "RoleID";
        selectRole.CurrentSelector.ZeroRowsText     = string.Format(GetString("newsletter.subscribers.addroles.nodata"), URLHelper.ResolveUrl(UIContextHelper.GetApplicationUrl("CMS.Roles", "Administration.Roles")));
        selectRole.ShowSiteFilter = false;
        selectRole.CurrentSelector.ResourcePrefix = "addroles";
        selectRole.IsLiveSite = false;
        selectRole.UseCodeNameForSelection = false;
        selectRole.GlobalRoles             = false;

        // Setup user selector
        selectUser.SelectionMode = SelectionModeEnum.MultipleButton;
        selectUser.UniSelector.OnItemsSelected        += UserSelector_OnItemsSelected;
        selectUser.UniSelector.ReturnColumnName        = "UserID";
        selectUser.UniSelector.DisplayNameFormat       = "{%FullName%} ({%Email%})";
        selectUser.UniSelector.AdditionalSearchColumns = "UserName, Email";
        selectUser.UniSelector.ZeroRowsText            = string.Format(GetString("newsletter.subscribers.addusers.nodata"), URLHelper.ResolveUrl(UIContextHelper.GetApplicationUrl("CMS.Users", "Administration.Users")));
        selectUser.WhereCondition = new WhereCondition().WhereNotEmpty("Email").ToString(true);
        selectUser.ShowSiteFilter = false;
        selectUser.ResourcePrefix = "newsletteraddusers";
        selectUser.IsLiveSite     = false;

        // Setup subscriber selector
        selectSubscriber.UniSelector.SelectionMode    = SelectionModeEnum.MultipleButton;
        selectSubscriber.UniSelector.OnItemsSelected += SubscriberSelector_OnItemsSelected;
        selectSubscriber.UniSelector.ReturnColumnName = "SubscriberID";
        selectSubscriber.UniSelector.ZeroRowsText     = string.Format(GetString("newsletter.subscribers.addsubscribers.nodata"), URLHelper.ResolveUrl(UIContextHelper.GetApplicationUrl(ModuleName.NEWSLETTER, "Newsletter", "?tabname=AllSubscribers")));
        selectSubscriber.ShowSiteFilter = false;
        selectSubscriber.IsLiveSite     = false;
        selectSubscriber.UniSelector.RemoveMultipleCommas = true;

        // Setup contact group and contact selectors
        if (ModuleEntryManager.IsModuleLoaded(ModuleName.ONLINEMARKETING) && LicenseHelper.CheckFeature(RequestContext.CurrentDomain, FeatureEnum.ContactManagement))
        {
            plcSelectCG.Controls.Clear();

            // Check read permission for contact groups
            if (MembershipContext.AuthenticatedUser.IsAuthorizedPerResource(ModuleName.CONTACTMANAGEMENT, "ReadContactGroups"))
            {
                // Load selector control and initialize it
                cgSelector = (FormEngineUserControl)Page.LoadUserControl("~/CMSModules/ContactManagement/FormControls/ContactGroupSelector.ascx");
                if (cgSelector != null)
                {
                    cgSelector.ID      = "selectCG";
                    cgSelector.ShortID = "scg";
                    // Get inner uniselector control
                    UniSelector selector = (UniSelector)cgSelector.GetValue("uniselector");
                    if (selector != null)
                    {
                        // Bind an event handler on 'items selected' event
                        selector.OnItemsSelected += CGSelector_OnItemsSelected;
                        selector.ResourcePrefix   = "contactgroupsubscriber";
                        selector.ZeroRowsText     = string.Format(GetString("newsletter.subscribers.addcontactgroups.nodata"), URLHelper.ResolveUrl(UIContextHelper.GetApplicationUrl(ModuleName.ONLINEMARKETING, "ContactGroups")));
                    }
                    // Insert selector to the header
                    plcSelectCG.Controls.Add(cgSelector);
                }
            }

            // Check read permission for contacts
            if (MembershipContext.AuthenticatedUser.IsAuthorizedPerResource(ModuleName.CONTACTMANAGEMENT, "ReadContacts"))
            {
                // Load selector control and initialize it
                cSelector = (FormEngineUserControl)Page.LoadUserControl("~/CMSModules/ContactManagement/FormControls/ContactSelector.ascx");
                if (cSelector != null)
                {
                    cSelector.ID      = "slContact";
                    cSelector.ShortID = "sc";
                    // Set where condition to filter contacts with email addresses
                    cSelector.SetValue("wherecondition", "NOT (ContactEmail IS NULL OR ContactEmail LIKE '')");
                    // Set site ID
                    cSelector.SetValue("siteid", SiteContext.CurrentSiteID);
                    // Get inner uniselector control
                    UniSelector selector = (UniSelector)cSelector.GetValue("uniselector");
                    if (selector != null)
                    {
                        // Bind an event handler on 'items selected' event
                        selector.OnItemsSelected        += ContactSelector_OnItemsSelected;
                        selector.SelectionMode           = SelectionModeEnum.MultipleButton;
                        selector.ResourcePrefix          = "contactsubscriber";
                        selector.DisplayNameFormat       = "{%ContactFirstName%} {%ContactLastName%} ({%ContactEmail%})";
                        selector.AdditionalSearchColumns = "ContactFirstName,ContactMiddleName,ContactEmail";
                        selector.ZeroRowsText            = string.Format(GetString("newsletter.subscribers.addcontacts.nodata"), URLHelper.ResolveUrl(UIContextHelper.GetApplicationUrl(ModuleName.ONLINEMARKETING, "ContactsFrameset", "?tabname=contacts")));
                    }
                    // Insert selector to the header
                    plcSelectCG.Controls.Add(cSelector);
                }
            }
        }

        // Setup persona selectors
        if (ModuleEntryManager.IsModuleLoaded(ModuleName.PERSONAS) && LicenseHelper.CheckFeature(RequestContext.CurrentDomain, FeatureEnum.Personas))
        {
            // Check read permission for contact groups
            if (MembershipContext.AuthenticatedUser.IsAuthorizedPerResource(ModuleName.PERSONAS, "Read"))
            {
                // Load selector control and initialize it
                personaSelector = (UniSelector)Page.LoadUserControl("~/CMSAdminControls/UI/Uniselector/Uniselector.ascx");
                if (personaSelector != null)
                {
                    personaSelector.ID                = "personaSelector";
                    personaSelector.ShortID           = "ps";
                    personaSelector.ObjectType        = PredefinedObjectType.PERSONA;
                    personaSelector.ReturnColumnName  = "PersonaID";
                    personaSelector.WhereCondition    = "PersonaSiteID = " + SiteContext.CurrentSiteID;
                    personaSelector.SelectionMode     = SelectionModeEnum.MultipleButton;
                    personaSelector.DisplayNameFormat = "{%PersonaDisplayName%}";
                    personaSelector.ResourcePrefix    = "personasubscriber";
                    personaSelector.IsLiveSite        = false;
                    personaSelector.ZeroRowsText      = string.Format(GetString("newsletter.subscribers.addpersonas.nodata"), URLHelper.ResolveUrl(UIContextHelper.GetApplicationUrl(ModuleName.PERSONAS, "Personas")));

                    // Bind an event handler on 'items selected' event
                    personaSelector.OnItemsSelected += PersonaSelector_OnItemsSelected;

                    // Add selector to the header
                    plcSelectCG.Controls.Add(personaSelector);
                }
            }
        }

        // Initialize mass actions
        if (drpActions.Items.Count == 0)
        {
            drpActions.Items.Add(new ListItem(GetString("general.selectaction"), SELECT));
            drpActions.Items.Add(new ListItem(GetString("newsletter.approvesubscription"), APPROVE));
            drpActions.Items.Add(new ListItem(GetString("newsletter.deletesubscription"), REMOVE));
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        SiteInfo currentSite = SiteContext.CurrentSite;

        mBounceLimit         = NewsletterHelper.BouncedEmailsLimit(currentSite.SiteName);
        mBounceInfoAvailable = NewsletterHelper.MonitorBouncedEmails(currentSite.SiteName);

        // Initialize unigrid
        UniGrid.OnAction            += uniGrid_OnAction;
        UniGrid.OnExternalDataBound += uniGrid_OnExternalDataBound;
        UniGrid.WhereCondition       = "SubscriberSiteID = " + currentSite.SiteID;
        UniGrid.FilteredZeroRowsText = GetString("subscriber_list.nodata.filtered");

        if (LicenseContext.CurrentLicenseInfo.Edition == ProductEditionEnum.EnterpriseMarketingSolution)
        {
            UniGrid.ZeroRowsText = string.Format(GetString("subscriber_list.nodata.ems"), URLHelper.ResolveUrl(UIContextHelper.GetApplicationUrl(ModuleName.ONLINEMARKETING, "ContactsFrameset", "?tabname=Contacts")));
        }
        else
        {
            UniGrid.ZeroRowsText = GetString("subscriber_list.nodata.noems");
        }
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (!StopProcessing)
        {
            plcError.Visible = false;

            // Check renamed DLL library
            if (!SystemContext.IsFullTrustLevel)
            {
                // Error label is displayed when OpenID library is not enabled
                lblError.Text      = ResHelper.GetString("socialnetworking.fulltrustrequired");
                plcError.Visible   = true;
                plcContent.Visible = false;
            }

            // Check if OpenID module is enabled
            if (!SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSEnableOpenID") && !plcError.Visible)
            {
                // Error label is displayed only in Design mode
                if (PortalContext.IsDesignMode(PortalContext.ViewMode))
                {
                    StringBuilder parameter = new StringBuilder();
                    parameter.Append(UIElementInfoProvider.GetApplicationNavigationString("cms", "Settings") + " -> ");
                    parameter.Append(GetString("settingscategory.cmsmembership") + " -> ");
                    parameter.Append(GetString("settingscategory.cmsmembershipauthentication") + " -> ");
                    parameter.Append(GetString("settingscategory.cmsopenid"));
                    if (MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin))
                    {
                        // Make it link for Admin
                        parameter.Insert(0, "<a href=\"" + URLHelper.GetAbsoluteUrl(UIContextHelper.GetApplicationUrl("cms", "settings")) + "\" target=\"_top\">");
                        parameter.Append("</a>");
                    }

                    lblError.Text      = String.Format(GetString("mem.openid.disabled"), parameter.ToString());
                    plcError.Visible   = true;
                    plcContent.Visible = false;
                }
                // In other modes is webpart hidden
                else
                {
                    Visible = false;
                }
            }

            // Display webpart when no error occured
            if (!plcError.Visible && Visible)
            {
                if (!AuthenticationHelper.IsAuthenticated())
                {
                    plcPasswordNew.Visible  = AllowFormsAuthentication;
                    pnlExistingUser.Visible = AllowExistingUser;

                    // Initialize OpenID session
                    response = (Dictionary <string, object>)SessionHelper.GetValue(SESSION_NAME_USERDATA);

                    userProviderUrl = ValidationHelper.GetString(SessionHelper.GetValue(SESSION_NAME_URL), null);

                    // Check that OpenID is not already registered
                    if (response != null)
                    {
                        UserInfo ui = OpenIDUserInfoProvider.GetUserInfoByOpenID((string)response["ClaimedIdentifier"]);

                        // OpenID is already registered to some user
                        if (ui != null)
                        {
                            plcContent.Visible = false;
                            plcError.Visible   = true;
                            lblError.Text      = GetString("mem.openid.openidregistered");
                        }
                    }

                    // There is no OpenID response object stored in session - hide all
                    if (response == null)
                    {
                        if (HideForNoOpenID)
                        {
                            Visible = false;
                        }
                    }
                    else if (!RequestHelper.IsPostBack())
                    {
                        LoadData();
                    }
                }
                // Hide webpart for authenticated users
                else
                {
                    Visible = false;
                }
            }
        }
        // Hide control when StopProcessing = TRUE
        else
        {
            Visible = false;
        }
    }
Example #14
0
    /// <summary>
    /// Gets application path for dashboard tiles.
    /// </summary>
    /// <param name="resourceID">Resource ID</param>
    /// <param name="elementName">Element name</param>
    protected string GetApplicationPath(object resourceID, object elementName)
    {
        string path = UIContextHelper.GetApplicationUrl(UIContextHelper.GetResourceName(Convert.ToInt32(resourceID)), elementName.ToString());

        return(URLHelper.ResolveUrl(path));
    }