1

I would like to utilize some of the social collaboration features in Sharepoint 2010, such as the Noteboard webpart and tagging, but do not want to use the My Site profile pages.

I have already built a custom control that redirects from the userdisp.aspx page to a custom user profile page. I would like to continue to use that custom profile page. However, it seems like user profile links that are generated by the Noteboard webpart, for example, go directly to the /Sites/MySites/person.aspx page without being routed through the /_layouts/userdisp.aspx page. So my profile redirect control doesn't catch it.

In Sharepoint Central Admin, under Manage Service Applications > User Profile Service Application > Manage User Permissions, I have only checked the box for "Use Social Features", not "Create Personal Site," so I am not sure why the profile page is not linking to the old userdisp.aspx page.

Is it possible to redirect these links back to the userdisp.aspx page?

1 Answer 1

1

It appears to be hardcoded into the webpart.

I looked at Microsoft.SharePoint.Portal.WebControls.SocialCommentControl and the link comes from UserProfile.PublicUrl, which is defined as:

public override Uri PublicUrl
{
  get
  {
    string userProfileUrl = UserProfileGlobal.GetUserProfileURL(
        this.m_objManager.UserProfileApplicationProxy, 
        this.m_objManager.PartitionID, 
        "?accountname=", 
        this.m_UserProfileFields["AccountName"].ToString());
    if (!string.IsNullOrEmpty(userProfileUrl))
      return new Uri(userProfileUrl);
    else
      return (Uri) null;
  }
}

which eventually calls:

internal static string GetUserProfileURL(string profileWebUrl, string strIdentifier, string strValue)
{
  if (string.IsNullOrEmpty(profileWebUrl))
    return (string) null;
  else
    return PersonalSpaceGlobal.EnsureTrailingSlash(profileWebUrl) 
        + "Person.aspx" 
        + strIdentifier 
        + (strIdentifier.Equals("?accountname=", StringComparison.OrdinalIgnoreCase) 
            ? SPHttpUtility.UrlKeyValueEncode(strValue).Replace(":", "%3A") 
            : SPHttpUtility.UrlKeyValueEncode(strValue));
}   

I can think of two workarounds:

  1. Add jQuery to your page to change the URL (selector = span.socialcomment-username > a)
  2. Create your own webpart containing a custom control that inherits from SocialCommentControl, which overrides RenderComment.

Overriding RenderComment is probably going to be messy. You will need to copy the decompiled code for the method just to change the following into your own code:

SocialCommentControl._GetProperty(
    comment, 
    SocialCommentControl.SocialCommentProperty.PublicPage)

Hopefully, there are no internal method calls within RenderComment's 67 lines of code. Otherwise, it is going to be a lot more difficult to implement. It would be a lot easier if you could simply override _GetProperty, but unfortunately, it is a static method.

All of that to say, I would probably recommend the jQuery option over extending SocialCommentControl.

3
  • Thank you for the response Rich. I wish I'd seen this sooner, but my email notifications from stackoverflow seem to have stopped working... I've decided to try the jQuery route. I've modified my existing redirect control to handle the "accountname" query parameter, and am going to use jQuery to redirect the url to the userdisp.aspx page. I'll let you know how it works. Thanks again for the help! Feb 5, 2012 at 20:21
  • Rich, Can you override _GetProperty? I'm getting an error saying it is not marked virtual, abstract, or override so you can't. Do you know any other way to "override" that as an inherited control? I like that idea better than trolling all spans or links on the page.
    – Paul
    Feb 8, 2012 at 0:42
  • @P-Dub: I'm not sure what I was thinking. You can't override a static method. So this isn't nearly as clean and simple. I've changed my answer to override RenderComment instead of _GetProperty. Feb 8, 2012 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.