CS Nuggets

This blog is for addons, bugs, fixes, and issues pertaining to Community Server.

CS2007: Inbox notification feature

Hey All,

I'm just getting started with CS 2007, so I thought I'd pick something rather simple.  Even though it is possible to implement this mod without making any changes to the SDK, there is a bug that the last change corrects and does require changing the SDK.  The bug is that unread message count is cached for 3600 seconds (1 hour), when it should only be cached for about 20 seconds at the most.

This mod will modify one of the new theme controls so that the Inbox indicator will turn red and show the number of new messages when you have new messages in your inbox.  If you can't make the SDK changes, then the indicator will only update once every hour.  Here are the changes:

File: CommunityServerWeb20 (Internal)/Themes/default/Common/UserWelcome.ascx:

Insert the following line at line 2:

<%@ Import Namespace="CommunityServer.Components" %>

Replace the following line around line 35:

<CSControl:UserData runat="server" LinkTo="UserPrivateMessages" ResourceName="PrivateMessage_Unread"><LeaderTemplate>| </LeaderTemplate></CSControl:UserData>

with:

<CSControl:ConditionalContent runat="server">
    <ContentConditions>
        <CSControl:CustomCondition runat="server" CustomResult="<%# UserMessages.UnreadMessagesCount(CSContext.Current.User.UserID) > 0 %>" />
    </ContentConditions>
    <LeaderTemplate>| </LeaderTemplate>
    <TrueContentTemplate><CSControl:UserData runat="server" LinkTo="UserPrivateMessages" LinkCssClass="NewPrivateMessage"><ContentTemplate><%# string.Format(ResourceManager.GetString("PrivateMessage_Unread"), UserMessages.UnreadMessagesCount(CSContext.Current.User.UserID)) %></ContentTemplate></CSControl:UserData></TrueContentTemplate>
    <FalseContentTemplate><CSControl:UserData runat="server" LinkTo="UserPrivateMessages" ResourceName="PrivateMessages_Messages" /></FalseContentTemplate>
</CSControl:ConditionalContent>

File: CommunityServerWeb20 (Internal)/Themes/default/Style/Common.css:

After the following (around line 121):

#CommonHeaderUserWelcome
{
    font-size: 80%;
    font-weight: bold;
}

insert:

#CommonHeaderUserWelcome A.NewPrivateMessage, #CommonHeaderUserWelcome A.NewPrivateMessage:VISITED, #CommonHeaderUserWelcome A.NewPrivateMessage:ACTIVE, #CommonHeaderUserWelcome A.NewPrivateMessage:HOVER
{
 color: #FF0000;
}

File: CommunityServerWeb20 (Internal)/Languages/en-US/Resources.xml:

Replace the following 2 lines around line 955:

<resource name = "PrivateMessages_Messages"> Inbox</resource>
<resource name = "PrivateMessage_Unread">Inbox</resource>

with:

<resource name = "PrivateMessages_Messages">Inbox</resource>
<resource name = "PrivateMessage_Unread">Inbox ({0})</resource>

File: CommunityServerComponents20/UserMessages.cs:

NOTE: This is the SDK change.  If you are unable to make this change, the indicator will only update once every 3600 seconds (1 hour).

Replace the following line around line 48:

CSCache.Insert(key, unreadCount, 3600);

with:

CSCache.Insert(key, unreadCount, 20);

Comments

Qingsong said:

Hi,

I am keeping get the following error messages in the exception report:

User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; FunWebPr

Path: /themes/default/forums/threadlist.aspx?ForumID=169 as HTTP GET

Referrer: /forums/default.aspx?GroupID=24

Message: Object reference not set to an instance of an object.

Any clue?

# July 5, 2007 11:54 PM

Bill Bosacker said:

Make sure that you didn't change something by accident (i.e. typo) and that you followed the instructions exactly as they are written.  Does this occur on every page?  If you only see this in the logs, then it is either a hacker or some one who has disabled cookies.

# July 6, 2007 5:08 PM

Torgus said:

This should be included in 2007! It's a bug that it's not!

# July 27, 2007 8:19 PM

Keith Saunders said:

Do you have the same INBOX notification solution for CS2008.3 ?

# March 12, 2010 5:20 AM

Bill Bosacker said:

CS2008 has this built-in, but I think it only updates like once every hour and it is a completely different system than it was in previous versions.  I stopped supporting Community Server over a year ago, so I really can't tell you any more than that.

# March 12, 2010 10:18 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)