Showing posts with label 2007. Show all posts
Showing posts with label 2007. Show all posts

Monday, September 21, 2009

Personalization and Audience Targeting Reset Page Content Bug

Scenario
  • Personalization and Web Part Audience Targeting are both enabled on a MOSS 2007 page.
  • Some web parts are audience trimmed for a particular user
  • That user personalizes the page
  • The user selects "Reset Page Content" from the User Welcome Menu
    • Or they select "Reset Web Part Content" from the Web Part's "Edit" menu
Issue
  • The audience trimmed web parts are incorrectly shown to the user
    • This may be a security issue if the audience targeted web part has confidential information on it
  • After refreshing the page, the page displays correctly
Resolution
  • I developed the following simple workaround
Workaround
  • Add the following usercontrol (2 files) to the 12 Hive\Template\ControlTemplates folder
    • PersonalizationResetPageContentRefreshBugFix.ascx
    • <%@ Control Language="VB" AutoEventWireup="false" CodeFile="PersonalizationResetPageContentRefreshBugFix.ascx.vb" Inherits="UserControls_PersonalizationResetPageContentRefreshBugFix" %>
    • PersonalizationResetPageContentRefreshBugFix.ascx.vb
    • Partial Class UserControls_PersonalizationResetPageContentRefreshBugFix
          Inherits System.Web.UI.UserControl
      
          Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
              Dim strPageRestore As String = Request.Form.Get("MSOWebPartPage_RestorePageDefault")
              Dim strPartRestore As String = Request.Form.Get("MSO_RestoreSettings")
              If Not String.IsNullOrEmpty(strPageRestore) OrElse _
                      Not String.IsNullOrEmpty(strPartRestore) Then
                  'Force a client side redirect and end response so no untargeted info goes to client.
                  Response.Redirect(Page.Request.Url.AbsoluteUri, True)
                  'Response Ends
              End If
          End Sub
      End Class
  • Add the following lines to each master page where personalization and audiences are used
    • The following line goes with the other Register tags at the top of the master page
      <%@ Register TagPrefix="wssuc" TagName="PersonalizationResetBugFix" src="~/_controltemplates/PersonalizationResetPageContentRefreshBugFix.ascx" %>
      
    • The following line goes within the BODY/FORM section
    • <wssuc:PersonalizationResetBugFix id="IdPersonalizationResetBugFix" runat="server" EnableViewState="false"/>

Tuesday, September 8, 2009

SPUtility.SendEmail

Issues with SPUtility.SendEmail.
  • SPUtility.SendEmail subject parameter cannot contain a comma "," character.
    • If it does, the email will be delayed by several hours.
    • To workaround, use: strSubject.Replace(",", " ") for the subject parameter
    • I am not sure if this is an smtp issue or a SPUtility issue.
    • The function will return "True" indicating a successful send even if there is a comma.
  • The body text parameter must have a new line character at least every 2048 characters.
    • If not, the email body will be truncated at 2048 chars.
    • For example, when using an HTML formatted body, you may have all your encoding on one line within the body string/stringbuilder parameter. You will need to insert crlf chars every 2048 characters or less.