Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Try skip IIS http errors
        Response.TrySkipIisCustomErrors = true;

        btnSignOut.OnClientClick = FacebookConnectHelper.FacebookConnectInitForSignOut(CMSContext.CurrentSiteName, ltlScript);

        titleElem.TitleImage = GetImageUrl("Others/Messages/denied.png");

        string title   = GetString("CMSDesk.AccessDenied");
        string message = GetString("CMSMessages.AccessDenied");

        GetTexts(ref message, ref title);

        lblMessage.Text     = message;
        titleElem.TitleText = title;

        // Display SignOut button
        if (CMSContext.CurrentUser.IsAuthenticated())
        {
            if (!RequestHelper.IsWindowsAuthentication())
            {
                btnSignOut.Visible = true;
            }
        }
        else
        {
            btnLogin.Visible = true;
        }
    }
Пример #2
0
    /// <summary>
    /// Signs in user or registers a new user.
    /// </summary>
    private void SetupControlForPublicUser()
    {
        RegisterFacebookScript();

        // Validate FB access token against FB server
        string facebookUserId       = null;
        bool   facebookCookiesValid = false;

        string confirmToken = QueryHelper.GetString(CONFIRMATION_URLPARAMETER, null);

        if (!String.IsNullOrEmpty(confirmToken))
        {
            facebookCookiesValid = FacebookConnectHelper.ValidateFBAccessToken(confirmToken, out facebookUserId);
        }

        // If user has signed in
        if (!String.IsNullOrEmpty(facebookUserId) && facebookCookiesValid)
        {
            UserInfo ui = UserInfoProvider.GetUserInfoByFacebookConnectID(facebookUserId);

            // Claimed Facebook ID is in DB
            if (ui != null)
            {
                SignInUser(ui, facebookUserId, confirmToken);
            }
            // Claimed Facebook ID not found  = save new user
            else
            {
                RegisterNewUser(facebookUserId, confirmToken);
            }
        }
    }
Пример #3
0
    /// <summary>
    /// Checks Sign out link settings.
    /// </summary>
    private bool EnsureSignOut()
    {
        if (RequestHelper.IsWindowsAuthentication())
        {
            // Hide sign out link
            lnkSignOut.Visible = false;
            return(false);
        }

        // Init Facebook Connect and join logout script to sign out button
        string logoutScript = FacebookConnectHelper.FacebookConnectInitForSignOut(SiteContext.CurrentSiteName, ltlFBConnectScript);

        if (!String.IsNullOrEmpty(logoutScript))
        {
            // If Facebook Connect initialized include 'CheckChanges()' to logout script
            logoutScript = "if (CheckChanges()) { " + logoutScript + " } return false; ";
        }
        else
        {
            // If Facebook Connect not initialized just return 'CheckChanges()' script
            logoutScript = "return CheckChanges();";
        }
        lnkSignOut.OnClientClick = logoutScript;

        return(true);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        btnSignOut.OnClientClick = FacebookConnectHelper.FacebookConnectInitForSignOut(CMSContext.CurrentSiteName, ltlScript);

        // Setup page title text and image
        CurrentMaster.Title.TitleImage = GetImageUrl("Others/Messages/denied.png");

        string title   = GetString("CMSDesk.AccessDenied");
        string message = GetString("CMSDesk.IsNotEditorMsg");

        bool hideLinks = GetTexts(ref message, ref title);

        lblMessage.Text = message;
        CurrentMaster.Title.TitleText = title;

        if (!hideLinks)
        {
            lnkGoBack.Text = GetString("CMSDesk.GoBack");

            // Hide for windows authentication
            if (RequestHelper.IsWindowsAuthentication())
            {
                btnSignOut.Visible = false;
            }
        }
        else
        {
            btnSignOut.Visible = false;
            lnkGoBack.Visible  = false;
        }
    }
    /// <summary>
    /// Sets up the control.
    /// </summary>
    protected override void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            // Get page's URL
            string pageUrl = String.Empty;
            if (string.IsNullOrEmpty(Url))
            {
                if (DocumentContext.CurrentDocument != null)
                {
                    TreeNode node = DocumentContext.CurrentDocument;
                    pageUrl = DocumentURLProvider.GetUrl(node.NodeAliasPath, node.DocumentUrlPath, SiteContext.CurrentSiteName);
                }
                else
                {
                    pageUrl = RequestContext.CurrentURL;
                }
            }
            else
            {
                pageUrl = ResolveUrl(Url);
            }
            pageUrl = URLHelper.GetAbsoluteUrl(HTMLHelper.HTMLEncode(pageUrl));

            string fbApiKey = FacebookConnectHelper.GetFacebookApiKey(SiteContext.CurrentSiteName);
            if (String.IsNullOrEmpty(fbApiKey))
            {
                ShowError(lblErrorMessage, "socialnetworking.facebook.apikeynotset");
            }
            // Register Facebook javascript SDK
            ScriptHelper.RegisterFacebookJavascriptSDK(Page, LocalizationContext.PreferredCultureCode, fbApiKey);

            // Get FB code
            StringBuilder sb = new StringBuilder();
            if (UseHTML5)
            {
                sb.Append("<div class=\"fb-send\" data-href=\"", pageUrl, "\" data-colorscheme=\"", ColorScheme, "\"");
                if (!string.IsNullOrEmpty(Font))
                {
                    sb.Append(" data-font=\"", Font, "\"");
                }
                sb.Append("></div>");
            }
            else
            {
                sb.Append("<fb:send href=\"", pageUrl, "\" font=\"", Font, "\" colorscheme=\"", ColorScheme, "\"></fb:send>");
            }
            ltlSendButtonCode.Text = sb.ToString();
        }
    }
    /// <summary>
    /// Registers Facebook javascript SDK to the page.
    /// </summary>
    private void RegisterFacebookScript()
    {
        if (Page is ContentPage)
        {
            // Adding XML namespace
            ((ContentPage)Page).XmlNamespace = FacebookConnectHelper.GetFacebookXmlNamespace();
        }

        // Init FB connect
        string initscr = FacebookConnectHelper.GetFacebookInitScriptForSite(SiteContext.CurrentSiteName) + " " + FacebookConnectHelper.GetFacebookLoginHandlerScript();

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "FBConnectLogon" + ClientID, initscr);
    }
Пример #7
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected override void SetupControl()
    {
        if (StopProcessing)
        {
            // Do not process
        }
        else
        {
            string pageUrl = String.Empty;
            if (string.IsNullOrEmpty(Url))
            {
                // If parameter URL is empty, set URL of current document
                if (DocumentContext.CurrentDocument != null)
                {
                    TreeNode node = DocumentContext.CurrentDocument;
                    pageUrl = DocumentURLProvider.GetUrl(node.NodeAliasPath, node.DocumentUrlPath, SiteContext.CurrentSiteName);
                }
                else
                {
                    // Query string will be removed
                    pageUrl = URLHelper.RemoveQuery(RequestContext.CurrentURL);
                }
            }
            else
            {
                pageUrl = ResolveUrl(Url);
            }
            pageUrl = URLHelper.GetAbsoluteUrl(HTMLHelper.HTMLEncode(pageUrl));
            pageUrl = HandlePreferredProtocol(pageUrl);

            string fbApiKey = FacebookConnectHelper.GetFacebookApiKey(SiteContext.CurrentSiteName);
            if (String.IsNullOrEmpty(fbApiKey))
            {
                ShowError(lblErrorMessage, "socialnetworking.facebook.apikeynotset");
            }
            // Register Facebook javascript SDK
            ScriptHelper.RegisterFacebookJavascriptSDK(Page, LocalizationContext.PreferredCultureCode, fbApiKey);

            if (UseHTML5)
            {
                ltlComments.Text = "<div class=\"fb-comments\" data-href=\"" + URLHelper.GetAbsoluteUrl(pageUrl) + "\" data-num-posts=\"" + Posts + "\" data-width=\"" + Width + "\"" + (!string.IsNullOrEmpty(ColorScheme) ? " data-colorscheme=\"" + ColorScheme + "\"" : "") + "></div>";
            }
            else
            {
                ltlComments.Text = "<fb:comments href=\"" + URLHelper.GetAbsoluteUrl(pageUrl) + "\" num_posts=\"" + Posts + "\" width=\"" + Width + "\"" + (!string.IsNullOrEmpty(ColorScheme) ? " colorscheme=\"" + ColorScheme + "\"" : "") + "></fb:comments>";
            }
        }
    }
    /// <summary>
    /// Initializes the control properties
    /// </summary>
    protected override void SetupControl()
    {
        if (StopProcessing)
        {
            // Do not process
        }
        else
        {
            if (UseHTML5)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("<div class=\"fb-facepile\" data-href=\"", URLHelper.EncodeQueryString(FBPageUrl),
                          "\" data-size=\"", Size, "\" data-max-rows=\"", RowsNumber, "\" data-width=\"",
                          Width, "\" data-colorscheme=\"", ColorScheme, "\"></div>");

                string fbApiKey = FacebookConnectHelper.GetFacebookApiKey(SiteContext.CurrentSiteName);
                if (String.IsNullOrEmpty(fbApiKey))
                {
                    ShowError(lblErrorMessage, "socialnetworking.facebook.apikeynotset");
                }
                // Register Facebook javascript SDK
                ScriptHelper.RegisterFacebookJavascriptSDK(Page, LocalizationContext.PreferredCultureCode, fbApiKey);
                ltlFacePile.Text = sb.ToString();
            }
            else
            {
                // Iframe code
                string query = null;
                string src   = "http://www.facebook.com/plugins/facepile.php";

                query = URLHelper.AddUrlParameter(query, "href", URLHelper.EncodeQueryString(FBPageUrl));
                query = URLHelper.AddUrlParameter(query, "size", Size);
                query = URLHelper.AddUrlParameter(query, "width", Width.ToString());
                query = URLHelper.AddUrlParameter(query, "max_rows", RowsNumber.ToString());
                query = URLHelper.AddUrlParameter(query, "colorscheme", ColorScheme);

                src = URLHelper.EncodeQueryString(URLHelper.AppendQuery(src, query));

                ltlFacePile.Text  = "<iframe src=\"" + src + "\"";
                ltlFacePile.Text += " scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:" + Width + "px;\"></iframe>";
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        CurrentMaster.Title.HideTitle = false;
        btnSignOut.OnClientClick      = FacebookConnectHelper.FacebookConnectInitForSignOut(SiteContext.CurrentSiteName, ltlScript);

        // Setup page title text and image
        string title   = GetString("CMSDesk.AccessDenied");
        string message = GetString("CMSDesk.IsNotEditorMsg");

        bool hideLinks = GetTexts(ref message, ref title);

        lblMessage.Text    = message;
        hdnPermission.Text = PageTitle.TitleText = title;

        // hide signout button for not authenticated users
        if (!AuthenticationHelper.IsAuthenticated())
        {
            btnSignOut.Visible = false;
        }

        if (!hideLinks)
        {
            lnkGoBack.Text = GetString("CMSDesk.GoBack");

            // Hide for windows authentication
            if (RequestHelper.IsWindowsAuthentication())
            {
                btnSignOut.Visible = false;
            }
        }
        else
        {
            btnSignOut.Style.Add("display", "none");
            lnkGoBack.Visible = false;
        }
    }
    /// <summary>
    /// Setups control for authenticated users.
    /// </summary>
    private void SetupControlForAuthenticatedUser()
    {
        EnsureBackwardCompatibility();

        // If signout should not be visible or user has not FacebookID registered
        if ((ShowSignOutAs == ShowSignOutEnum.DoNotShow) || String.IsNullOrEmpty(MembershipContext.AuthenticatedUser.UserSettings.UserFacebookID))
        {
            Visible = false;
            return;
        }

        RegisterFacebookScript();

        // Get logout script for FB connect
        string currentUrlLogout = URLHelper.AddParameterToUrl(RequestContext.CurrentURL, "logout", "1");

        currentUrlLogout = URLHelper.AddParameterToUrl(currentUrlLogout, "logout_hash", QueryHelper.GetHash(currentUrlLogout));
        string additionalScript = "window.location.href=" + ScriptHelper.GetString(URLHelper.GetAbsoluteUrl(currentUrlLogout)) + "; return false;";
        string logoutScript     = FacebookConnectHelper.GetFacebookLogoutScriptForSignOut(RequestContext.CurrentURL, FacebookConnectHelper.GetFacebookApiKey(SiteContext.CurrentSiteName), additionalScript);

        // Hide Facebook Connect button
        plcFBButton.Visible = false;
        if (String.IsNullOrEmpty(SignOutText))
        {
            SignOutText = ResHelper.GetString("webparts_membership_signoutbutton.signout");
        }

        switch (ShowSignOutAs)
        {
        // Show as image
        case ShowSignOutEnum.Image:
            string signOutImageUrl = SignOutImageURL;

            // Use default image if none is specified
            if (String.IsNullOrEmpty(signOutImageUrl))
            {
                signOutImageUrl = GetImageUrl("Others/FacebookConnect/signout.gif");
            }
            imgSignOut.ImageUrl        = ResolveUrl(signOutImageUrl);
            imgSignOut.Visible         = true;
            imgSignOut.AlternateText   = GetString("webparts_membership_signoutbutton.signout");
            lnkSignOutImageBtn.Visible = true;
            lnkSignOutImageBtn.Attributes.Add("onclick", logoutScript);
            lnkSignOutImageBtn.Attributes.Add("style", "cursor:pointer;");
            break;

        // Show as link
        case ShowSignOutEnum.Link:
            lnkSignOutLink.Text    = SignOutText;
            lnkSignOutLink.Visible = true;
            lnkSignOutLink.Attributes.Add("onclick", logoutScript);
            lnkSignOutLink.Attributes.Add("style", "cursor:pointer;");
            break;

        // Show as button
        case ShowSignOutEnum.Button:
            btnSignOut.OnClientClick = logoutScript;
            btnSignOut.Text          = SignOutText;
            btnSignOut.Visible       = true;
            break;
        }
    }
Пример #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckUserImpersonate();

        // Facebook Connect sign out
        if (CMSContext.CurrentUser.IsAuthenticated())
        {
            if (QueryHelper.GetInteger("logout", 0) > 0)
            {
                btnSignOut_Click(this, EventArgs.Empty);
                return;
            }
        }

        InitializeVersion();

        lblUser.Text           = GetString("Header.User");
        lblUserInfo.Text       = HTMLHelper.HTMLEncode(CMSContext.CurrentUser.FullName);
        lnkCmsDesk.Text        = GetString("Header.CMSDesk");
        lnkCmsDesk.NavigateUrl = "~/CMSDesk/default.aspx";
        lnkCmsDesk.Target      = "_parent";

        lnkTestingMode.Text        = GetString("cmstesting.headerlink");
        lnkTestingMode.Visible     = SettingsKeyProvider.TestingMode;
        lnkTestingMode.NavigateUrl = "~/CMSPages/GetTestingModeReport.aspx";

        string url = "~/CMSSiteManager/default.aspx";

        lnkCmsDeskLogo.NavigateUrl = url;
        lnkCmsDeskLogo.Target      = "_parent";

        elemLinks.RedirectURL = "~/CMSMessages/Redirect.aspx?frame=top&url=" + url;

        // Include 'Buy' tab if only trial and free licenses are present
        int buy = 1;

        if (!LicenseKeyInfoProvider.OnlyTrialLicenseKeys)
        {
            buy = 0;
        }

        string[,] tabs = new string[8 + buy, 4];
        tabs[0, 0]     = GetString("general.sites");
        tabs[0, 2]     = "sites/site_list.aspx";
        tabs[1, 0]     = GetString("Header.Administration");
        tabs[1, 2]     = "administration/default.aspx";
        tabs[2, 0]     = GetString("Header.Settings");
        tabs[2, 2]     = ResolveUrl("~/CMSModules/Settings/SiteManager/Default.aspx");
        tabs[3, 0]     = GetString("Header.Development");
        tabs[3, 2]     = "development/default.aspx";
        tabs[4, 0]     = GetString("Header.Tools");
        tabs[4, 2]     = "tools/default.aspx";
        tabs[5, 0]     = GetString("Header.Dashboard");
        tabs[5, 2]     = URLHelper.EnsureHashToQueryParameters("Dashboard.aspx?dashboardName=SiteManagerDashboard&templateName=Administratordashboard&{hash}");
        tabs[6, 0]     = GetString("Header.Licenses");
        tabs[6, 2]     = ResolveUrl("~/CMSModules/licenses/Pages/License_List.aspx");
        tabs[7, 0]     = GetString("Header.Support");
        tabs[7, 2]     = ResolveUrl("~/CMSModules/Support/Pages/default.aspx");

        // Add 'Buy' tab if needed
        if (buy > 0)
        {
            tabs[8, 0] = GetString("Header.Buy");
            tabs[8, 2] = BUY_PAGE;
        }

        BasicTabControlHeader.Tabs = tabs;

        string section     = ValidationHelper.GetString(Request.QueryString["section"], "sites").ToLower();
        int    selectedTab = 0;

        switch (section)
        {
        case "sites":
            selectedTab = 0;
            break;

        case "administration":
            selectedTab = 1;
            break;

        case "settings":
            selectedTab = 2;
            break;

        case "development":
            selectedTab = 3;
            break;

        case "tools":
            selectedTab = 4;
            break;

        case "dashboard":
            selectedTab = 5;
            break;

        case "licenses":
            selectedTab = 6;
            break;

        default:
            selectedTab = 0;
            break;
        }

        BasicTabControlHeader.SelectedTab = selectedTab;
        BasicTabControlHeader.UrlTarget   = "cmsdesktop";

        if (RequestHelper.IsWindowsAuthentication())
        {
            pnlSignOut.Visible   = false;
            PanelRight.CssClass += " HeaderWithoutSignOut";
        }
        else
        {
            pnlSignOut.BackImageUrl = GetImageUrl("Design/Buttons/SignOutButton.png");
            lblSignOut.Text         = GetString("signoutbutton.signout");

            lnkSignOut.OnClientClick = FacebookConnectHelper.FacebookConnectInitForSignOut(CMSContext.CurrentSiteName, ltlFBConnectScript);
        }

        // Displays windows azure and EMS icons
        if (AzureHelper.IsRunningOnAzure && SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSShowAzureLogo"))
        {
            imgWindowsAzure.Visible  = true;
            imgWindowsAzure.ImageUrl = GetImageUrl("General/IconWindowsAzure.png");
            pnlExtraIcons.Visible    = true;
        }
        if (LicenseHelper.CurrentEdition == ProductEditionEnum.EnterpriseMarketingSolution)
        {
            imgEnterpriseSolution.Visible  = true;
            imgEnterpriseSolution.ImageUrl = GetImageUrl("General/IconEnterpriseSolution.png");
            pnlExtraIcons.Visible          = true;
        }
    }
Пример #12
0
    /// <summary>
    /// Initializes the control.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            Visible = false;

            return;
        }

        if (!LicenseHelper.CheckFeature(RequestContext.CurrentDomain, FeatureEnum.FaceBookConnect))
        {
            Visible = DisplayMessage(String.Format(GetString("licenselimitation.featurenotavailable"), FeatureEnum.FaceBookConnect));

            return;
        }

        // Check Facebook Connect settings
        string currentSiteName = SiteContext.CurrentSiteName;

        if (String.IsNullOrEmpty(currentSiteName) || !SettingsKeyInfoProvider.GetBoolValue(currentSiteName + ".CMSEnableFacebookConnect") || !FacebookConnectHelper.FacebookIsAvailable(currentSiteName))
        {
            // Show warning message in "Design mode"
            Visible = DisplayMessage();

            return;
        }

        // If user is already authenticated
        if (AuthenticationHelper.IsAuthenticated())
        {
            SetupControlForAuthenticatedUser();
        }
        else
        {
            SetupControlForPublicUser();
        }
    }
Пример #13
0
    /// <summary>
    /// Maps the values of Facebook user profile attributes to the values of CMS user fields depending on the current settings.
    /// </summary>
    /// <param name="mappingTrigger">Specifies when the mapping of Facebook user profile occurs.</param>
    /// <param name="user">The CMS user.</param>
    /// <param name="userProfileId">The Facebook user profile identifier.</param>
    /// <param name="facebookAccessToken">The Facebook access token.</param>
    /// <remarks>
    /// The CMS user name is updated only if it was generated by the CMS.
    /// </remarks>
    private void MapFacebookUserProfile(FacebookUserProfileMappingTriggerEnum mappingTrigger, UserInfo user, string userProfileId, string facebookAccessToken)
    {
        var  facebookUserProvider = new FacebookUserProvider();
        var  facebookUser         = facebookUserProvider.GetFacebookUser(userProfileId, facebookAccessToken, FacebookConnectHelper.GetFacebookAppSecretKey(SiteContext.CurrentSiteName));
        bool userChanged          = false;

        // Change user's full name if it is in default format
        if (String.IsNullOrEmpty(user.FullName) || (user.FullName == UserInfoProvider.FACEBOOKID_FULLNAME_PREFIX + userProfileId))
        {
            user.FullName = facebookUser.FacebookName;
            userChanged   = true;
        }

        // Map Facebook user on appropriate action
        if (FacebookMappingHelper.GetUserProfileMappingTrigger(SiteContext.CurrentSiteName) >= mappingTrigger)
        {
            FacebookMappingHelper.MapUserProfile(facebookUser, user);
            userChanged = true;
        }

        if (userChanged)
        {
            user.Update();
        }
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do not process
        }
        else
        {
            // Facebook Connect sign out
            if (CMSContext.CurrentUser.IsAuthenticated())
            {
                if (QueryHelper.GetInteger("logout", 0) > 0)
                {
                    // Sign out from CMS

                    // Remove Facebook user object from session
                    SessionHelper.Remove(SESSION_NAME_USERDATA);

                    FormsAuthentication.SignOut();
                    CMSContext.ClearShoppingCart();
                    CMSContext.CurrentUser = null;
                    Response.Cache.SetNoStore();
                    URLHelper.Redirect(URLHelper.RemoveParameterFromUrl(URLHelper.CurrentURL, "logout"));
                    return;
                }
            }

            // Show only desired button
            btnSignOut.Visible     = !ShowAsLink;
            btnSignOutLink.Visible = ShowAsLink;

            if (!CMSContext.CurrentUser.IsPublic())
            {
                // Hide for windows authentication
                if (RequestHelper.IsWindowsAuthentication())
                {
                    Visible = false;
                }
                else
                {
                    // Set signout text
                    btnSignOutLink.Text = SignOutText;
                    btnSignOut.Text     = SignOutText;
                }
            }
            else
            {
                // Set signin text
                btnSignOutLink.Text = SignInText;
                btnSignOut.Text     = SignInText;
            }

            // Facebook Connect initialization
            btnSignOut.OnClientClick = FacebookConnectHelper.FacebookConnectInitForSignOut(CMSContext.CurrentSiteName, ltlScript);
        }

        if (!StandAlone && (PageCycle < PageCycleEnum.Initialized) && (ValidationHelper.GetString(Page.StyleSheetTheme, "") == ""))
        {
            btnSignOut.SkinID = SkinID;
        }


        // if user is not authenticated and ShowOnlyWhenAuthenticated is set
        if (CMSContext.CurrentUser.IsPublic() && ShowOnlyWhenAuthenticated)
        {
            Visible = false;
        }
    }
Пример #15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckUserImpersonate();

        // Facebook Connect sign out
        if (CMSContext.CurrentUser.IsAuthenticated())
        {
            if (QueryHelper.GetInteger("logout", 0) > 0)
            {
                btnSignOut_Click(this, EventArgs.Empty);
                return;
            }
        }

        InitializeVersion();

        // Make 'Site manager' link visible for global administrators
        CurrentUserInfo ui = CMSContext.CurrentUser;

        if ((ui != null) && (ui.UserSettings != null))
        {
            lnkSiteManager.Visible = ui.UserSiteManagerAdmin;
        }

        // Site selector settings
        siteSelector.DropDownSingleSelect.CssClass = "HeaderSiteDrop";
        siteSelector.UpdatePanel.RenderMode        = UpdatePanelRenderMode.Inline;
        siteSelector.AllowAll = false;
        siteSelector.UniSelector.OnSelectionChanged   += SiteSelector_OnSelectionChanged;
        siteSelector.UniSelector.OnBeforeClientChanged = "if (!CheckChanges()) { this.value = this.originalValue; return false; }";
        siteSelector.DropDownSingleSelect.AutoPostBack = true;
        siteSelector.OnlyRunningSites = true;

        if (!RequestHelper.IsPostBack())
        {
            siteSelector.Value = CMSContext.CurrentSiteID;
        }

        // Show only assigned sites for not global admins
        if (!CMSContext.CurrentUser.IsGlobalAdministrator)
        {
            siteSelector.UserId = CMSContext.CurrentUser.UserID;
        }

        section = QueryHelper.GetString("section", string.Empty).ToLower();

        lblUser.Text     = GetString("Header.User");
        lblUserInfo.Text = HTMLHelper.HTMLEncode(CMSContext.CurrentUser.FullName);

        lnkLiveSite.Text = ResHelper.GetString("Header.LiveSite");

        lnkTestingMode.Text        = GetString("cmstesting.headerlink");
        lnkTestingMode.Visible     = SettingsKeyProvider.TestingMode;
        lnkTestingMode.NavigateUrl = "~/CMSPages/GetTestingModeReport.aspx";

        // Initialize variables from query string
        int    nodeId  = QueryHelper.GetInteger("nodeid", 0);
        string culture = QueryHelper.GetText("culture", null);
        string url     = "~";

        // Set url to node from which CMSDesk was opened
        if ((nodeId > 0) && !String.IsNullOrEmpty(culture))
        {
            TreeProvider treeProvider = new TreeProvider(CMSContext.CurrentUser);
            TreeNode     node         = treeProvider.SelectSingleNode(nodeId, culture, false, false);
            if (node != null)
            {
                url = CMSContext.GetUrl(node.NodeAliasPath, node.DocumentUrlPath);
            }
        }
        // Resolve Url and add live site view mode
        url = ResolveUrl(url);
        url = URLHelper.AddParameterToUrl(url, "viewmode", "livesite");

        lnkLiveSite.NavigateUrl = url;
        lnkLiveSite.Target      = "_parent";

        lnkSiteManager.Text        = GetString("Header.SiteManager");
        lnkSiteManager.NavigateUrl = "~/CMSSiteManager/default.aspx";
        lnkSiteManager.Target      = "_parent";

        lnkSiteManagerLogo.NavigateUrl = "~/CMSDesk/default.aspx";
        lnkSiteManagerLogo.Target      = "_parent";

        elemLinks.RedirectURL = URLHelper.CurrentURL;

        BasicTabControlHeader.OnTabCreated += tabElem_OnTabCreated;
        BasicTabControlHeader.UrlTarget     = "cmsdesktop";

        BasicTabControlHeader.QueryParameterName = "section";

        if (RequestHelper.IsWindowsAuthentication())
        {
            pnlSignOut.Visible = false;
            pnlRight.CssClass += " HeaderWithoutSignOut";
        }
        else
        {
            pnlSignOut.BackImageUrl = GetImageUrl("Design/Buttons/SignOutButton.png");
            lblSignOut.Text         = GetString("signoutbutton.signout");

            // Init Facebook Connect and join logout script to sign out button
            string logoutScript = FacebookConnectHelper.FacebookConnectInitForSignOut(CMSContext.CurrentSiteName, ltlFBConnectScript);
            if (!String.IsNullOrEmpty(logoutScript))
            {
                // If Facebook Connect initialized include 'CheckChanges()' to logout script
                logoutScript = "if (CheckChanges()) { " + logoutScript + " } return false; ";
            }
            else
            {
                // If Facebook Connect not initialized just return 'CheckChanges()' script
                logoutScript = "return CheckChanges();";
            }
            lnkSignOut.OnClientClick = logoutScript;
        }

        // Displays windows azure and EMS icons
        if (AzureHelper.IsRunningOnAzure && SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSShowAzureLogo"))
        {
            imgWindowsAzure.Visible  = true;
            imgWindowsAzure.ImageUrl = GetImageUrl("General/IconWindowsAzure.png");
            pnlExtraIcons.Visible    = true;
        }
        if (LicenseHelper.CurrentEdition == ProductEditionEnum.EnterpriseMarketingSolution)
        {
            imgEnterpriseSolution.Visible  = true;
            imgEnterpriseSolution.ImageUrl = GetImageUrl("General/IconEnterpriseSolution.png");
            pnlExtraIcons.Visible          = true;
        }
    }
Пример #16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Logging out of Facebook
        if (QueryHelper.GetInteger("logout", 0) > 0)
        {
            btnSignOut_Click(this, EventArgs.Empty);
        }
        btnSignOut.OnClientClick = FacebookConnectHelper.FacebookConnectInitForSignOut(CMSContext.CurrentSiteName, ltlScript);

        // Setup page title text and image
        this.CurrentMaster.Title.TitleText  = GetString("CMSDesk.AccessDenied");
        this.CurrentMaster.Title.TitleImage = GetImageUrl("Others/Messages/denied.png");

        bool hideLinks = false;

        this.LabelMessage.Text = GetString("CMSDesk.IsNotEditorMsg");

        // If specification parameters given, display custom message
        string resourceName = QueryHelper.GetString("resource", null);
        int    nodeId       = QueryHelper.GetInteger("nodeid", 0);
        string message      = QueryHelper.GetText("message", null);

        if (!String.IsNullOrEmpty(resourceName))
        {
            // Access denied to resource
            ResourceInfo ri = ResourceInfoProvider.GetResourceInfo(resourceName);
            if (ri != null)
            {
                this.CurrentMaster.Title.TitleText = String.Format(GetString("CMSSiteManager.AccessDeniedOnResource"), HTMLHelper.HTMLEncode(ri.ResourceDisplayName));
            }
        }
        else if (nodeId > 0)
        {
            // Access denied to document
            TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
            TreeNode     node = tree.SelectSingleNode(nodeId);
            if (node != null)
            {
                this.CurrentMaster.Title.TitleText = String.Format(GetString("CMSSiteManager.AccessDeniedOnNode"), HTMLHelper.HTMLEncode(node.DocumentName));
            }
        }
        // Add custom message
        else if (!String.IsNullOrEmpty(message))
        {
            this.LabelMessage.Text = message;
            hideLinks = true;
        }

        // Add missing permission name message
        string permission = QueryHelper.GetText("permission", null);
        string uielement  = QueryHelper.GetText("uielement", null);

        if (!String.IsNullOrEmpty(permission))
        {
            if (permission.Contains("|"))
            {
                permission = String.Join(GetString("CMSSiteManager.AccessDeniedOr"), permission.Split('|'));
            }

            this.LabelMessage.Text = String.Format(GetString("CMSSiteManager.AccessDeniedOnPermissionName"), permission);
            hideLinks = true;
        }
        // Add missing UI element name message
        else if (!String.IsNullOrEmpty(uielement))
        {
            if (uielement.Contains("|"))
            {
                uielement = String.Join(GetString("CMSSiteManager.AccessDeniedOr"), uielement.Split('|'));
            }

            this.LabelMessage.Text = String.Format(GetString("CMSSiteManager.AccessDeniedOnUIElementName"), uielement);
            hideLinks = true;
        }

        if (!hideLinks)
        {
            this.lnkGoBack.Text = GetString("CMSDesk.GoBack");

            // Hide for windows authentication
            if (RequestHelper.IsWindowsAuthentication())
            {
                btnSignOut.Visible = false;
            }
        }
        else
        {
            btnSignOut.Visible = false;
            lnkGoBack.Visible  = false;
        }
    }
Пример #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Logging out of Facebook
        if (QueryHelper.GetInteger("logout", 0) > 0)
        {
            btnSignOut_Click(this, EventArgs.Empty);
        }
        btnSignOut.OnClientClick = FacebookConnectHelper.FacebookConnectInitForSignOut(CMSContext.CurrentSiteName, LiteralScript);

        this.LabelMessage.Text    = GetString("CMSMessages.AccessDenied");
        this.titleElem.TitleText  = GetString("CMSDesk.AccessDenied");
        this.titleElem.TitleImage = GetImageUrl("Others/Messages/denied.png");

        // If specification parameters given, display custom message
        string resourceName = QueryHelper.GetString("resource", null);
        int    nodeId       = QueryHelper.GetInteger("nodeid", 0);
        string message      = QueryHelper.GetText("message", null);

        if (!String.IsNullOrEmpty(resourceName))
        {
            // Access denied to resource
            ResourceInfo ri = ResourceInfoProvider.GetResourceInfo(resourceName);
            if (ri != null)
            {
                this.titleElem.TitleText = String.Format(GetString("CMSSiteManager.AccessDeniedOnResource"), ri.ResourceDisplayName);
            }
        }
        else if (nodeId > 0)
        {
            // Access denied to document
            TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
            TreeNode     node = tree.SelectSingleNode(nodeId);
            if (node != null)
            {
                this.titleElem.TitleText = String.Format(GetString("CMSSiteManager.AccessDeniedOnNode"), HTMLHelper.HTMLEncode(node.DocumentName));
            }
        }
        else if (!String.IsNullOrEmpty(message))
        {
            // Custom message
            this.LabelMessage.Text = ResHelper.LocalizeString(message);
        }

        // Add missing permission name message
        string permission = QueryHelper.GetText("permission", null);

        if (!String.IsNullOrEmpty(permission))
        {
            this.LabelMessage.Text = String.Format(GetString("CMSSiteManager.AccessDeniedOnPermissionName"), permission);
        }

        // Display SignOut button
        if (CMSContext.CurrentUser.IsAuthenticated())
        {
            if (!RequestHelper.IsWindowsAuthentication())
            {
                this.btnSignOut.Visible = true;
            }
        }
        else
        {
            this.btnLogin.Visible = true;
        }

        this.lnkGoBack.Text = GetString("CMSDesk.GoBack");
    }
Пример #18
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected override void SetupControl()
    {
        if (StopProcessing)
        {
            // Do not process
        }
        else
        {
            // Default height if nothing additional is shown
            int height = heightDefault;

            // If faces and stream are shown
            if (ShowFaces && ShowStream)
            {
                height = heightStreamFaces;
            }
            // If only stream is shown
            else if (ShowStream)
            {
                height = heightStream;
            }
            // If only faces are shown
            else if (ShowFaces)
            {
                height = heightFaces;
            }

            // If stream or faces are shown and header is too
            if (ShowHeader && (ShowFaces || ShowStream))
            {
                height = height + 35;
            }

            if (UseHTML5)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("<div class=\"fb-like-box\" data-href=\"", HTMLHelper.EncodeForHtmlAttribute(FBPageUrl),
                          "\" data-width=\"", Width, "\" data-height=\"", height, "\" data-header=\"",
                          ShowHeader, "\" data-stream=\"", ShowStream, "\" data-show-faces=\"",
                          ShowFaces, "\" data-colorscheme=\"", ColorScheme, "\" data-force-wall=\"",
                          ForceWall, "\" data-show-border=\"", ShowBorder, "\"");
                sb.Append("></div>");
                string fbApiKey = FacebookConnectHelper.GetFacebookApiKey(SiteContext.CurrentSiteName);
                if (String.IsNullOrEmpty(fbApiKey))
                {
                    ShowError(lblErrorMessage, "socialnetworking.facebook.apikeynotset");
                }
                // Register Facebook javascript SDK
                ScriptHelper.RegisterFacebookJavascriptSDK(Page, LocalizationContext.PreferredCultureCode, fbApiKey);
                ltlLikeBox.Text = sb.ToString();
            }
            else
            {
                // Iframe code
                string src = "http://www.facebook.com/plugins/likebox.php";

                string query = URLHelper.AddUrlParameter(null, "href", FBPageUrl);
                query = URLHelper.AddUrlParameter(query, "header", ShowHeader.ToString());
                query = URLHelper.AddUrlParameter(query, "width", Width.ToString());
                query = URLHelper.AddUrlParameter(query, "show_faces", ShowFaces.ToString());
                query = URLHelper.AddUrlParameter(query, "stream", ShowStream.ToString());
                query = URLHelper.AddUrlParameter(query, "colorscheme", ColorScheme);
                query = URLHelper.AddUrlParameter(query, "height", height.ToString());
                query = URLHelper.AddUrlParameter(query, "force_wall", ForceWall.ToString());
                query = URLHelper.AddUrlParameter(query, "show_border", ShowBorder.ToString());

                src = HTMLHelper.EncodeForHtmlAttribute(URLHelper.AppendQuery(src, query));

                ltlLikeBox.Text  = "<iframe src=\"" + src + "\"";
                ltlLikeBox.Text += " scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:" + Width + "px; height:" + height + "px;\"></iframe>";
            }
        }
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            Visible = false;
        }
        else
        {
            if (QueryHelper.GetInteger("logout", 0) > 0)
            {
                // Sign out from CMS
                CMSContext.LogoutUser();

                CMSContext.CurrentUser = null;
                Response.Cache.SetNoStore();
                URLHelper.Redirect(URLHelper.RemoveParameterFromUrl(URLHelper.CurrentURL, "logout"));
                return;
            }

            string currentSiteName = CMSContext.CurrentSiteName;
            if (!String.IsNullOrEmpty(currentSiteName) && SettingsKeyProvider.GetBoolValue(currentSiteName + ".CMSEnableFacebookConnect"))
            {
                // Check Facebook Connect settings
                if (!FacebookConnectHelper.FacebookIsAvailable(currentSiteName))
                {
                    // Display warning message in "Design mode"
                    if (DisplayMessage())
                    {
                        return;
                    }

                    Visible = false;
                    return;
                }

                // Try to retrieve return URL from query
                string returnUrl = QueryHelper.GetString("returnurl", null);

                // Init Facebook Connect
                if (Page is ContentPage)
                {
                    // Adding XML namespace
                    ((ContentPage)Page).XmlNamespace = FacebookConnectHelper.GetFacebookXmlNamespace();
                }

                // Init FB connect
                string initscr = FacebookConnectHelper.GetFacebookInitScriptForSite(currentSiteName) + " " + FacebookConnectHelper.GetFacebookLoginHandlerScript();
                ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "FBConnectLogon" + ClientID, initscr);
                // Return URL
                string currentUrl       = URLHelper.AddParameterToUrl(URLHelper.CurrentURL, "logout", "1");
                string additionalScript = "window.location.href=" + ScriptHelper.GetString(URLHelper.GetAbsoluteUrl(currentUrl)) + "; return false;";
                // Logout script for FB connect
                string logoutScript = FacebookConnectHelper.GetFacebookLogoutScriptForSignOut(URLHelper.CurrentURL, FacebookConnectHelper.GetFacebookApiKey(currentSiteName), additionalScript);

                // Validate FB access token against FB server
                string facebookUserId       = null;
                bool   facebookCookiesValid = false;
                string confirmToken         = QueryHelper.GetString(CONFIRMATION_URLPARAMETER, null);
                if (!String.IsNullOrEmpty(confirmToken))
                {
                    facebookCookiesValid = FacebookConnectHelper.ValidateFBAccessToken(confirmToken, out facebookUserId);
                }

                // If user is already authenticated
                if (CMSContext.CurrentUser.IsAuthenticated())
                {
                    // Is user logged in using Facebook Connect?
                    if ((CMSContext.CurrentUser.UserSettings != null) && String.IsNullOrEmpty(CMSContext.CurrentUser.UserSettings.UserFacebookID))
                    {
                        // no, user is not logged in by Facebook Connect
                        logoutScript = additionalScript;
                    }

                    // Hide Facebook Connect button
                    plcFBButton.Visible = false;

                    // If signout should be visible and user has FacebookID registered
                    if (ShowSignOut && !String.IsNullOrEmpty(CMSContext.CurrentUser.UserSettings.UserFacebookID))
                    {
                        // If only text is set use text/button link
                        if (!String.IsNullOrEmpty(SignOutText))
                        {
                            // Button link
                            if (ShowAsButton)
                            {
                                btnSignOut.OnClientClick = logoutScript;
                                btnSignOut.Text          = SignOutText;
                                btnSignOut.Visible       = true;
                            }
                            // Text link
                            else
                            {
                                lnkSignOutLink.Text    = SignOutText;
                                lnkSignOutLink.Visible = true;
                                lnkSignOutLink.Attributes.Add("onclick", logoutScript);
                                lnkSignOutLink.Attributes.Add("style", "cursor:pointer;");
                            }
                        }
                        // Image link
                        else
                        {
                            string signOutImageUrl = SignOutImageURL;
                            // Use default image if none is specified
                            if (String.IsNullOrEmpty(signOutImageUrl))
                            {
                                signOutImageUrl = GetImageUrl("Others/FacebookConnect/signout.gif");
                            }
                            imgSignOut.ImageUrl        = ResolveUrl(signOutImageUrl);
                            imgSignOut.Visible         = true;
                            imgSignOut.AlternateText   = GetString("webparts_membership_signoutbutton.signout");
                            lnkSignOutImageBtn.Visible = true;
                            lnkSignOutImageBtn.Attributes.Add("onclick", logoutScript);
                            lnkSignOutImageBtn.Attributes.Add("style", "cursor:pointer;");
                        }
                    }
                    else
                    {
                        Visible = false;
                    }
                }
                // Sign In
                else
                {
                    if (facebookCookiesValid)
                    {
                        if (!String.IsNullOrEmpty(facebookUserId))
                        {
                            UserInfo ui = UserInfoProvider.GetUserInfoByFacebookConnectID(facebookUserId);
                            // Claimed Facebook ID is in DB
                            if (ui != null)
                            {
                                // Login existing user
                                if ((ui != null) && ui.Enabled)
                                {
                                    // Ban IP addresses which are blocked for login
                                    BannedIPInfoProvider.CheckIPandRedirect(currentSiteName, BanControlEnum.Login);

                                    // Create autentification cookie
                                    AuthenticationHelper.SetAuthCookieWithUserData(ui.UserName, true, Session.Timeout, new string[] { "facebooklogon" });
                                    UserInfoProvider.SetPreferredCultures(ui);

                                    int      contactId = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui);
                                    Activity activity  = new ActivityUserLogin(contactId, ui, CMSContext.CurrentDocument, CMSContext.ActivityEnvironmentVariables);
                                    activity.Log();

                                    // Redirect user
                                    if (String.IsNullOrEmpty(returnUrl))
                                    {
                                        returnUrl = URLHelper.RemoveParameterFromUrl(URLHelper.CurrentURL, CONFIRMATION_URLPARAMETER);
                                    }

                                    URLHelper.Redirect(returnUrl);
                                }
                                // Otherwise is user disabled
                                else
                                {
                                    lblError.Text    = GetString("membership.userdisabled");
                                    lblError.Visible = true;
                                }
                            }
                            // Claimed Facebook ID not found  = save new user
                            else
                            {
                                // Check whether additional user info page is set
                                string additionalInfoPage = SettingsKeyProvider.GetStringValue(currentSiteName + ".CMSRequiredFacebookPage").Trim();

                                // No page set, user can be created
                                if (String.IsNullOrEmpty(additionalInfoPage))
                                {
                                    // Register new user
                                    string error = null;
                                    ui = AuthenticationHelper.AuthenticateFacebookConnectUser(facebookUserId, currentSiteName, false, true, ref error);

                                    // If user was found or successfuly created
                                    if (ui != null)
                                    {
                                        // If user is enabled
                                        if (ui.Enabled)
                                        {
                                            // Create authentification cookie
                                            AuthenticationHelper.SetAuthCookieWithUserData(ui.UserName, true, Session.Timeout, new string[] { "facebooklogon" });

                                            int      contactID     = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui);
                                            Activity activityLogin = new ActivityUserLogin(contactID, ui, CMSContext.CurrentDocument, CMSContext.ActivityEnvironmentVariables);
                                            activityLogin.Log();
                                        }

                                        // Send registration e-mails
                                        // E-mail confirmation is not required as user already provided confirmation by successful login using Facebook connect
                                        AuthenticationHelper.SendRegistrationEmails(ui, null, null, false, false);

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

                                        // Log registration into analytics
                                        AuthenticationHelper.TrackUserRegistration(TrackConversionName, ConversionValue, currentSiteName, ui);

                                        Activity activity = new ActivityRegistration(ui, CMSContext.CurrentDocument, CMSContext.ActivityEnvironmentVariables);
                                        if (activity.Data != null)
                                        {
                                            activity.Data.ContactID = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui);
                                            activity.Log();
                                        }
                                    }
                                    // Redirect when authentication was succesfull
                                    if (String.IsNullOrEmpty(error))
                                    {
                                        if (!String.IsNullOrEmpty(returnUrl))
                                        {
                                            URLHelper.Redirect(URLHelper.GetAbsoluteUrl(returnUrl));
                                        }
                                        else
                                        {
                                            URLHelper.Redirect(URLHelper.RemoveParameterFromUrl(URLHelper.CurrentURL, CONFIRMATION_URLPARAMETER));
                                        }
                                    }
                                    // Display error otherwise
                                    else
                                    {
                                        lblError.Text    = error;
                                        lblError.Visible = true;
                                    }
                                }
                                // Additional information page is set
                                else
                                {
                                    // Store user object in session for additional info page
                                    SessionHelper.SetValue(SESSION_NAME_USERDATA, facebookUserId);

                                    // Redirect to additional info page
                                    string targetURL = URLHelper.GetAbsoluteUrl(additionalInfoPage);

                                    if (!String.IsNullOrEmpty(returnUrl))
                                    {
                                        // Add return URL to parameter
                                        targetURL = URLHelper.AddParameterToUrl(targetURL, "returnurl", HttpUtility.UrlEncode(returnUrl));
                                    }
                                    URLHelper.Redirect(targetURL);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                // Show warning message in "Design mode"
                Visible = DisplayMessage();
            }
        }
    }
Пример #20
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckUserImpersonate();
        CheckTrial();

        // Facebook Connect sign out
        if (CMSContext.CurrentUser.IsAuthenticated())
        {
            if (QueryHelper.GetInteger("logout", 0) > 0)
            {
                // Stop processing for all controls during logout
                ucUsers.StopProcessing      = true;
                siteSelector.StopProcessing = true;
                ucUICultures.StopProcessing = true;
                btnSignOut_Click(this, EventArgs.Empty);
                return;
            }
        }

        // Display the techPreview info if there is a key in the web.config
        pnlTechPreview.Visible = ValidationHelper.GetBoolean(SettingsHelper.AppSettings["CMSUseTechnicalPreview"], false);

        InitializeVersion();

        lnkTestingMode.Text        = GetString("cmstesting.headerlink");
        lnkTestingMode.Visible     = SettingsKeyProvider.TestingMode;
        lnkTestingMode.NavigateUrl = "~/CMSPages/GetTestingModeReport.aspx";

        lblUserInfo.Text = HTMLHelper.HTMLEncode(CMSContext.CurrentUser.FullName);

        pnlBody.CssClass = IsAPIExampleHeader ? "APIExamplesHeader" : (IsCMSDesk ? "CMSDeskHeader" : "SMHeader");

        tabControl.Visible = !IsCMSDesk && !IsAPIExampleHeader || IsCMSDesk;

        lblSignOut.Text = GetString("signoutbutton.signout");

        lnkCMSDesk.Text        = GetString("Header.CMSDesk");
        lnkCMSDesk.NavigateUrl = EnsureViewModeParam("~/CMSDesk/default.aspx", "returnviewmode");
        lnkCMSDesk.Target      = "_parent";

        lnkCMSSiteManager.Text        = GetString("Header.SiteManager");
        lnkCMSSiteManager.NavigateUrl = EnsureViewModeParam("~/CMSSiteManager/default.aspx", "returnviewmode");
        lnkCMSSiteManager.Target      = "_parent";

        string eventLogText = GetString("administration.ui.eventlog");

        lnkLog.NavigateUrl   = ResolveUrl("~/CMSModules/EventLog/EventLog.aspx");
        lnkLog.ToolTip       = eventLogText;
        imgLog.ImageUrl      = GetImageUrl("Objects/CMS_EventLog/list.png");
        imgLog.AlternateText = eventLogText;

        string debugText = GetString("administration-system.debug");

        lnkDebug.NavigateUrl   = ResolveUrl("~/CMSModules/System/Debug/System_DebugFrameset.aspx");
        lnkDebug.ToolTip       = debugText;
        imgDebug.ImageUrl      = GetImageUrl("CMSModules/CMS_System/debug.png");
        imgDebug.AlternateText = debugText;

        pwdExpiration.ShowChangePasswordLink      = true;
        pwdExpiration.ExpirationTextBefore        = GetString("passwordexpiration.expired");
        pwdExpiration.ExpirationWarningTextBefore = string.Format(GetString("passwordexpiration.willexpire"), CMSContext.CurrentUser.UserPasswordExpiration);

        // Displays windows azure and EMS icons
        if (AzureHelper.IsRunningOnAzure && SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSShowAzureLogo"))
        {
            imgWindowsAzure.Visible  = true;
            imgWindowsAzure.ImageUrl = GetImageUrl("General/IconWindowsAzure.png");
            pnlExtraIcons.Visible    = true;
        }
        if (LicenseHelper.CurrentEdition == ProductEditionEnum.EnterpriseMarketingSolution)
        {
            imgEnterpriseSolution.Visible  = true;
            imgEnterpriseSolution.ImageUrl = GetImageUrl("General/IconEnterpriseSolution.png");
            pnlExtraIcons.Visible          = true;
        }
        if (!CMSContext.CurrentUser.UserSiteManagerAdmin)
        {
            plcLog.Visible   = false;
            plcDebug.Visible = false;
        }
        string redirectURL = null;

        string scHideWarning = @"
function HideWarning() {
  var panel = document.getElementById('" + pnlPwdExp.ClientID + @"');
  if(panel)
  {
    panel.style.display = ""none"";
    window.top.layouts[0].resizeAll(); 
  }
}";

        ScriptHelper.RegisterStartupScript(this, typeof(string), "HideHeaderWarning", scHideWarning, true);

        SiteInfo si = CMSContext.CurrentSite;

        if ((si != null) && (!si.SiteIsOffline))
        {
            // Initialize variables from query string
            int    nodeId      = QueryHelper.GetInteger("nodeid", 0);
            string culture     = QueryHelper.GetText("culture", null);
            string liveSiteUrl = "~";

            // Set url to node from which CMSDesk was opened
            if (IsCMSDesk && (nodeId > 0) && !String.IsNullOrEmpty(culture))
            {
                TreeProvider treeProvider = new TreeProvider(CMSContext.CurrentUser);
                TreeNode     node         = treeProvider.SelectSingleNode(nodeId, culture, false, false);
                if (node != null)
                {
                    liveSiteUrl = CMSContext.GetUrl(node.NodeAliasPath, node.DocumentUrlPath);
                }
            }
            // Resolve Url and add live site view mode
            liveSiteUrl             = ResolveUrl(liveSiteUrl);
            liveSiteUrl             = URLHelper.AddParameterToUrl(liveSiteUrl, "viewmode", "livesite");
            liveSiteUrl             = EnsureViewModeParam(liveSiteUrl, "viewmode");
            lnkLiveSite.Text        = ResHelper.GetString("Header.LiveSite");
            lnkLiveSite.NavigateUrl = liveSiteUrl;
            lnkLiveSite.Target      = "_parent";
        }

        if (IsCMSDesk)
        {
            // Make 'Site manager' link visible for global administrators
            CurrentUserInfo ui = CMSContext.CurrentUser;
            if (ui.UserSettings != null)
            {
                plcSiteManagerRedirect.Visible = ui.UserSiteManagerAdmin;
            }

            // Site selector settings
            siteSelector.DropDownSingleSelect.CssClass = "HeaderSiteDrop";
            siteSelector.UpdatePanel.RenderMode        = UpdatePanelRenderMode.Inline;
            siteSelector.AllowAll = false;
            siteSelector.UniSelector.OnSelectionChanged   += SiteSelector_OnSelectionChanged;
            siteSelector.UniSelector.OnBeforeClientChanged = "if (!CheckChanges()) { this.value = this.originalValue; return false; }";
            siteSelector.DropDownSingleSelect.AutoPostBack = true;
            siteSelector.OnlyRunningSites = true;

            if (!RequestHelper.IsPostBack())
            {
                siteSelector.Value = CMSContext.CurrentSiteID;
            }

            // Show only assigned sites for not global admins
            if (!CMSContext.CurrentUser.IsGlobalAdministrator)
            {
                siteSelector.UserId = CMSContext.CurrentUser.UserID;
            }

            StringBuilder script = new StringBuilder();
            script.Append(
                @"function SetActivePage() {}
  function SiteRedirect(url) { parent.location = url; }
  function CheckChanges() {
    try { if (!parent.frames['cmsdesktop'].CheckChanges()) return false; } catch (ex) { }
    return true;
  }
");
            ScriptHelper.RegisterStartupScript(this, typeof(string), "headerScript", ScriptHelper.GetScript(script.ToString()));

            lnkLogo.NavigateUrl = "~/CMSDesk/default.aspx";
            lnkLogo.Target      = "_parent";

            redirectURL = URLHelper.CurrentURL;

            tabControl.UrlTarget          = "cmsdesktop";
            tabControl.QueryParameterName = "section";
            tabControl.ModuleName         = "CMS.Desk";
            tabControl.ModuleAvailabilityForSiteRequired = true;
            tabControl.OnTabCreated += tabControl_OnTabCreated;

            if (RequestHelper.IsWindowsAuthentication())
            {
                pnlSignOut.Visible = false;
                pnlRight.CssClass += " HeaderWithoutSignOut";
            }
            else
            {
                // Init Facebook Connect and join logout script to sign out button
                string logoutScript = FacebookConnectHelper.FacebookConnectInitForSignOut(CMSContext.CurrentSiteName, ltlFBConnectScript);
                if (!String.IsNullOrEmpty(logoutScript))
                {
                    // If Facebook Connect initialized include 'CheckChanges()' to logout script
                    logoutScript = "if (CheckChanges()) { " + logoutScript + " } return false; ";
                }
                else
                {
                    // If Facebook Connect not initialized just return 'CheckChanges()' script
                    logoutScript = "return CheckChanges();";
                }
                lnkSignOut.OnClientClick = logoutScript;
            }
        }
        else
        {
            plcSiteSelector.Visible = false;
            pnlSeparator.Visible    = true;

            lblUserInfo.Text               = HTMLHelper.HTMLEncode(CMSContext.CurrentUser.FullName);
            plcCMSDeskRedirect.Visible     = true;
            plcSiteManagerRedirect.Visible = IsAPIExampleHeader;

            lnkTestingMode.Text        = GetString("cmstesting.headerlink");
            lnkTestingMode.Visible     = SettingsKeyProvider.TestingMode;
            lnkTestingMode.NavigateUrl = "~/CMSPages/GetTestingModeReport.aspx";

            string url = null;
            if (IsAPIExampleHeader)
            {
                url = "~/CMSAPIExamples/default.aspx";
            }
            else
            {
                url = "~/CMSSiteManager/default.aspx";
            }
            lnkLogo.NavigateUrl = url;
            lnkLogo.Target      = "_parent";

            redirectURL = "~/CMSMessages/Redirect.aspx?frame=top&url=" + url;

            tabControl.OnTabCreated      += new UITabs.TabCreatedEventHandler(tabControl_OnTabCreated);
            tabControl.UrlTarget          = "cmsdesktop";
            tabControl.QueryParameterName = "section";
            tabControl.ModuleName         = "CMS.SiteManager";
            tabControl.UseClientScript    = true;

            if (RequestHelper.IsWindowsAuthentication())
            {
                pnlSignOut.Visible = false;
                pnlRight.CssClass += " HeaderWithoutSignOut";
            }
            else
            {
                lblSignOut.Text          = GetString("signoutbutton.signout");
                lnkSignOut.OnClientClick = FacebookConnectHelper.FacebookConnectInitForSignOut(CMSContext.CurrentSiteName, ltlFBConnectScript);
            }
        }

        CheckUICultureChange(redirectURL);

        if (ModuleEntry.IsModuleRegistered("CMS.Chat") && ModuleEntry.IsModuleLoaded("CMS.Chat") && (CMSContext.CurrentSiteID > 0))
        {
            CMSUserControl supportChatControl = Page.LoadUserControl("~/CMSModules/Chat/Controls/SupportChatHeader.ascx") as CMSUserControl;
            if (supportChatControl != null)
            {
                plcSupportChatControl.Controls.Add(supportChatControl);
                pnlSupportChat.Visible = true;
            }
        }
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected override void SetupControl()
    {
        if (StopProcessing)
        {
            // Do not process
        }
        else
        {
            if (string.IsNullOrEmpty(Domain))
            {
                Domain = SiteContext.CurrentSite.DomainName;
            }

            if (UseHTML5)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("<div class=\"fb-recommendations\" data-width=\"", Width, "\" data-height=\"", Height, "\" data-site=\"",
                          Domain, "\" data-header=\"", ShowHeader, "\" data-colorscheme=\"", ColorScheme, "\"");

                if (!string.IsNullOrEmpty(Font))
                {
                    sb.Append(" data-font=\"", Font, "\"");
                }
                if (!string.IsNullOrEmpty(RefParameter))
                {
                    sb.Append(" data-ref=\"", RefParameter, "\"");
                }
                sb.Append("></div>");

                string fbApiKey = FacebookConnectHelper.GetFacebookApiKey(SiteContext.CurrentSiteName);
                if (String.IsNullOrEmpty(fbApiKey))
                {
                    ShowError(lblErrorMessage, "socialnetworking.facebook.apikeynotset");
                }
                // Register Facebook javascript SDK
                ScriptHelper.RegisterFacebookJavascriptSDK(Page, LocalizationContext.PreferredCultureCode, fbApiKey);
                ltlRecommendations.Text = sb.ToString();
            }
            else
            {
                // Iframe code
                string query = null;
                string src   = "http://www.facebook.com/plugins/recommendations.php";

                if (!string.IsNullOrEmpty(Font))
                {
                    query = URLHelper.AddUrlParameter(query, "font", Font);
                }

                if (!string.IsNullOrEmpty(RefParameter))
                {
                    query = URLHelper.AddUrlParameter(query, "ref", RefParameter);
                }

                query = URLHelper.AddUrlParameter(query, "site", Domain);
                query = URLHelper.AddUrlParameter(query, "header", ShowHeader.ToString());
                query = URLHelper.AddUrlParameter(query, "width", Width.ToString());
                query = URLHelper.AddUrlParameter(query, "colorscheme", ColorScheme);
                query = URLHelper.AddUrlParameter(query, "height", Height.ToString());

                src = URLHelper.EncodeQueryString(URLHelper.AppendQuery(src, query));

                ltlRecommendations.Text  = "<iframe src=\"" + src + "\"";
                ltlRecommendations.Text += " scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:" + Width + "px; height:" + Height + "px;\"></iframe>";
            }
        }
    }
Пример #22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Logging out of Facebook
        if (QueryHelper.GetInteger("logout", 0) > 0)
        {
            btnSignOut_Click(this, EventArgs.Empty);
        }
        btnSignOut.OnClientClick = FacebookConnectHelper.FacebookConnectInitForSignOut(CMSContext.CurrentSiteName, ltlScript);

        bool hideLinks = false;

        // Default message
        this.lblMessage.Text = GetString("CMSSiteManager.IsNotAdminMsg");

        CurrentMaster.Title.TitleText  = GetString("CMSSiteManager.AccessDenied");
        CurrentMaster.Title.TitleImage = GetImageUrl("Others/Messages/denied.png");

        // Resource access denied
        string resourceName = QueryHelper.GetString("resource", null);

        if (resourceName != null)
        {
            switch (resourceName.ToLower())
            {
            // Not enabled admin interface
            case "cms.adminui":
            {
                this.lblMessage.Text = GetString("CMSSiteManager.AdminUINotEnabled");
            }
            break;

            // Standard resource permission
            default:
            {
                ResourceInfo ri = ResourceInfoProvider.GetResourceInfo(resourceName);
                if (ri != null)
                {
                    CurrentMaster.Title.TitleText = String.Format(GetString("CMSSiteManager.AccessDeniedOnResource"), ri.ResourceDisplayName);
                }
            }
            break;
            }
        }

        // Access denied to document
        int nodeId = QueryHelper.GetInteger("nodeid", 0);

        if (nodeId > 0)
        {
            TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
            TreeNode     node = tree.SelectSingleNode(nodeId);
            if (node != null)
            {
                CurrentMaster.Title.TitleText = String.Format(GetString("CMSSiteManager.AccessDeniedOnNode"), HTMLHelper.HTMLEncode(node.DocumentName));
            }
        }

        // Custom message
        string message = QueryHelper.GetText("message", null);

        if (message != null)
        {
            this.lblMessage.Text = ResHelper.LocalizeString(message);
            hideLinks            = true;
        }

        // Add missing permission name message
        string permission = QueryHelper.GetText("permission", null);

        if (permission != null)
        {
            this.lblMessage.Text = String.Format(GetString("CMSSiteManager.AccessDeniedOnPermissionName"), permission);
            hideLinks            = true;
        }

        // Override displaying of links
        hideLinks = QueryHelper.GetBoolean("hidelinks", hideLinks);

        if (!hideLinks)
        {
            this.lnkGoBack.Text = GetString("CMSSiteManager.GoBack");

            // Hide for windows authentication
            if (RequestHelper.IsWindowsAuthentication())
            {
                btnSignOut.Visible = false;
            }
        }
        else
        {
            btnSignOut.Visible = false;
            lnkGoBack.Visible  = false;
        }
    }