Esempio n. 1
0
    /// <summary>
    /// Renders controls depending on current state.
    /// </summary>
    private void RenderControls()
    {
        chkEnabledFacebook.Visible = IsWorkflow;
        btnPostAtFacebook.Visible  = true;

        chkEnabledFacebook.Checked = dataElement.AutoPostAfterPublishing;
        txtTemplateFacebook.Text   = dataElement.Template;

        // Set info message
        if (dataElement.IsPublished)
        {
            lblFacebookIsPublished.Text    = ResHelper.GetString("socialnetworking.facebook.ispublished");
            lnkFacebookPostURL.NavigateUrl = dataElement.PostURL;
            lnkFacebookPostURL.Text        = dataElement.PostURL;
            lnkFacebookPostURL.Target      = "_blank";
            lnkFacebookPostURL.Visible     = true;
        }
        else
        {
            lblFacebookIsPublished.Text = ResHelper.GetString("socialnetworking.facebook.isnotpublished");
        }

        bool isSetting = SocialNetworkingHelper.IsSettingSet(CMSContext.CurrentSiteName, SocialNetworkType.Facebook);

        // Check the license
        string currentDomain = URLHelper.GetCurrentDomain();

        if (!String.IsNullOrEmpty(currentDomain))
        {
            if (!LicenseHelper.CheckFeature(currentDomain, FeatureEnum.SocialAutoPost))
            {
                Enabled   = false;
                isSetting = true;

                lblAccessDeniedWarning.Visible = true;
            }
        }

        // Disable button "Post at Facebook" if document wasn't saved yet.
        btnPostAtFacebook.Enabled   = (Enabled && (node.NodeID > 0) && isSetting);
        chkEnabledFacebook.Enabled  = (Enabled && isSetting);
        txtTemplateFacebook.Enabled = Enabled;

        if (!btnPostAtFacebook.Enabled)
        {
            btnPostAtFacebook.CssClass += "Disabled";
        }

        if (!isSetting)
        {
            lblFacebookMissingSetting.Visible = true;
        }

        if (FacebookProvider.IsAccessTokenExpired(CMSContext.CurrentSiteName))
        {
            lblExpirationWarning.Visible = true;
        }
    }