/// <summary>
 /// Displays warning if there is no default account set on the site.
 /// </summary>
 private void DisplayWarningIfNoDefaultAccount()
 {
     if (FacebookAccountInfoProvider.GetDefaultFacebookAccount(SiteContext.CurrentSiteID) == null)
     {
         Control.ShowWarning(ResHelper.GetString("sm.facebook.nodefaultpage"));
     }
 }
Exemplo n.º 2
0
    /// <summary>
    /// Initializes inner controls to its default state.
    /// </summary>
    private void InitializeControls()
    {
        chkPostAfterDocumentPublish.Checked = false;

        string content = String.Empty;

        if (mBackCompatibilityValue.HasValue)
        {
            // Pre fill form with old data
            chkPostAfterDocumentPublish.Checked = mBackCompatibilityValue.Value.AutoPostAfterPublishing;
            content = mBackCompatibilityValue.Value.Template;
        }
        else if (!String.IsNullOrWhiteSpace(mDefaultValue))
        {
            // Default content given as control's string Value
            content = mDefaultValue;
        }
        else if ((FieldInfo != null) && !String.IsNullOrWhiteSpace(FieldInfo.DefaultValue))
        {
            // Default content from field info
            content = FieldInfo.DefaultValue;
        }
        txtPost.Text = content;

        if (!chkPostAfterDocumentPublish.Checked)
        {
            publishDateTime.Value = DateTime.Now;
        }

        pageSelector.ObjectSiteName = SiteIdentifier;
        FacebookAccountInfo defaultAccountInfo = FacebookAccountInfoProvider.GetDefaultFacebookAccount(SiteIdentifier);

        if (defaultAccountInfo != null)
        {
            pageSelector.Value = defaultAccountInfo.FacebookAccountID;
        }

        ClearPostState();
        urlShortenerSelector.SiteID         = SiteIdentifier;
        urlShortenerSelector.Value          = URLShortenerHelper.GetDefaultURLShortenerForSocialNetwork(SocialNetworkTypeEnum.Facebook, SiteIdentifier);
        chkPostAfterDocumentPublish.Visible = (Document != null);
        campaingSelector.Value          = null;
        campaingSelector.ObjectSiteName = SiteIdentifier;

        if ((FieldInfo != null) && !FieldInfo.AllowEmpty)
        {
            // Post must be created because field doesn't allow an empty value
            chkPostToFacebook.Enabled = false;
            DisplayForm = true;
        }
        else
        {
            // Form is displayed if it is pre filled with old data
            DisplayForm = mBackCompatibilityValue.HasValue;
        }
    }
    /// <summary>
    /// OnBeforeDataLoad event - Ensures default account is pre-selected.
    /// </summary>
    private void Control_OnBeforeDataLoad(object sender, EventArgs e)
    {
        var facebookPost = Control.EditedObject as FacebookPostInfo;

        if (facebookPost == null)
        {
            return;
        }

        // if the post is newly created fill in default page
        if (facebookPost.FacebookPostID == 0)
        {
            FacebookAccountInfo defaultFacebookAccountInfo = FacebookAccountInfoProvider.GetDefaultFacebookAccount(Control.ObjectSiteID);
            if (defaultFacebookAccountInfo != null)
            {
                facebookPost.FacebookPostFacebookAccountID = defaultFacebookAccountInfo.FacebookAccountID;
            }
        }
    }