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);