/// <summary>
    /// Gets a link control that opens post details dialog when clicked. Post's content is used as link text.
    /// </summary>
    /// <param name="postId">Facebook post identifier.</param>
    private object GetFacebookPostDetailLink(int postId)
    {
        FacebookPostInfo post = FacebookPostInfoProvider.GetFacebookPostInfo(postId);

        if (LicenseKeyInfoProvider.IsFeatureAvailable(FeatureEnum.SocialMarketingInsights))
        {
            string dialogUrl = String.Format(mFacebookPostDetailsUrlFormat, post.FacebookPostID);
            return(String.Format("<a href=\"{0}\" onclick=\"modalDialog('{0}', 'PostDetails', 480, 570); return false;\" title=\"{1}\">{2}</a>",
                                 dialogUrl,
                                 ResHelper.GetString("sm.facebook.posts.detail.tooltip"),
                                 HTMLHelper.HTMLEncode(TextHelper.LimitLength(post.FacebookPostText, 80))
                                 ));
        }
        return(HTMLHelper.HTMLEncode(TextHelper.LimitLength(post.FacebookPostText, 80)));
    }
    /// <summary>
    /// Gets localized message describing post state.
    /// </summary>
    /// <param name="postId">Post id.</param>
    private object GetPostState(int postId)
    {
        switch (Control.ObjectType)
        {
        // Facebook post
        case FacebookPostInfo.OBJECT_TYPE:
            FacebookPostInfo facebookPost = FacebookPostInfoProvider.GetFacebookPostInfo(postId);
            return(FacebookPostInfoProvider.GetPostPublishStateMessage(facebookPost, MembershipContext.AuthenticatedUser, SiteContext.CurrentSite, true));

        // Twitter post
        case TwitterPostInfo.OBJECT_TYPE:
            TwitterPostInfo twitterPost = TwitterPostInfoProvider.GetTwitterPostInfo(postId);
            return(TwitterPostInfoProvider.GetPostPublishStateMessage(twitterPost, MembershipContext.AuthenticatedUser, SiteContext.CurrentSite, true));
        }

        return(String.Empty);
    }
示例#3
0
    /// <summary>
    /// OnAction for Facebook post object type.
    /// </summary>
    private void OnAction_Facebook(string actionName, object actionArgument)
    {
        switch (actionName)
        {
        case "delete":
            try
            {
                int postId   = ValidationHelper.GetInteger(actionArgument, 0);
                var postInfo = FacebookPostInfoProvider.GetFacebookPostInfo(postId);

                if (VerifyPermissionsAndObjectAvailability(postInfo))
                {
                    FacebookPostInfoProvider.DeleteFacebookPostInfo(postInfo);
                }
            }
            catch (Exception ex)
            {
                EventLogProvider.LogWarning("Social marketing - Facebook post", "DELETEPOST", ex, SiteContext.CurrentSiteID, "Facebook post could not be deleted.");
                Control.ShowError(Control.GetString("sm.facebook.posts.msg.deleteerror"));
            }
            break;
        }
    }