I was trying to get MaxUsers to function on my server when I noticed that the value is retrieved out of the BoadSettings context.
The problem here is that as long as the server never resets, the BoardSettings stay the same, until they are manually changed by saving them in the Host Settings.
What I was thinking was to include MaxUsers and MaxUsersWhen as values passed back by yaf_board_poststats stored procedure.
BEGIN
SELECT
Posts = (select count(1) from [dbo].[yaf_Message] a join [dbo].[yaf_Topic] b on b.TopicID=a.TopicID join [dbo].[yaf_Forum] c on c.ForumID=b.ForumID join [dbo].[yaf_Category] d on d.CategoryID=c.CategoryID where d.BoardID=@BoardID AND (a.Flags & 24)=16),
Topics = (select count(1) from [dbo].[yaf_Topic] a join [dbo].[yaf_Forum] b on b.ForumID=a.ForumID join [dbo].[yaf_Category] c on c.CategoryID=b.CategoryID where c.BoardID=@BoardID AND (a.Flags & 😎 <> 😎,
Forums = (select count(1) from [dbo].[yaf_Forum] a join [dbo].[yaf_Category] b on b.CategoryID=a.CategoryID where b.BoardID=@BoardID),
Members = (select count(1) from [dbo].[yaf_User] a where a.BoardID=@BoardID AND (Flags & 2) = 2 AND (a.Flags & 4) = 0),
MaxUsers = (SELECT [Value] FROM [dbo].[yaf_Registry] WHERE LOWER(Name) = LOWER('maxusers') and BoardID=@BoardID),
MaxUsersWhen = (SELECT [Value] FROM [dbo].[yaf_Registry] WHERE LOWER(Name) = LOWER('maxuserswhen') and BoardID=@BoardID),
LastPostInfo.*,
LastMemberInfo.*
FROM .....
Then in the ForumStatistics Control
if (!statisticsDataRow.IsNull("MaxUsers"))
MostUsersCount.Text = String.Format(PageContext.Localization.GetText("MAX_ONLINE"), statisticsDataRow["MaxUsers"], YafDateTime.FormatDateTimeTopic(statisticsDataRow["MaxUsersWhen"]));
else
MostUsersCount.Text = String.Format(PageContext.Localization.GetText("MAX_ONLINE"), activeStats["ActiveUsers"], YafDateTime.FormatDateTimeTopic(DateTime.Now));
This way the MaxUser stats are loaded with the other statistics and saved in the cache with them and fall under their expiry.
The only problem encountered so far is that if you add the above code to the control after your server has been already running, then the cache needs to be reset otherwise there won't be a "MaxUsers" field in the row. I added the IsNull in case it doesn't come back with values, then at least it will show the current number of users instead of just 1.