Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Active Topics
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Active Topics

 Post Reply Post Reply Page  12>
Author
glypher View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 25 March 2003
Location: United States
Status: Offline
Points: 38
Post Options Post Options   Thanks (0) Thanks(0)   Quote glypher Quote  Post ReplyReply Direct Link To This Post Topic: Active Topics
    Posted: 08 October 2003 at 5:50pm

Hi all...

This isn't really a bug but a question of functionality.  The active topics page doesn't show all of the active topics! mainly in the case of forums being locked for members (registered users) only.

What's strange to me is that if i'm logged in as a member, i should be able to see all of the posts that i have access to... not just the ones that the "guests" can see...

Well i found some mods that were supposed to do this but they just went and grabbed the group permissions and didn't take into account "guest" (read = 1) "members" (read<=2) and "admin" (read=all) in the forums themselves.

so i decided to work out some fancy SQL statement that would fix it... and it works great! (passing in the userID and the ActiveFrom)

CREATE PROCEDURE  [dbo].[wwfspActiveTopics] (
@AuthorID int,
@dblActiveFrom int
)
as

set nocount on

IF  @AuthorID = 1 --admin (get everything)
 SELECT    
  --dbo.tblCategory.Cat_ID AS Cat_ID,dbo.tblCategory.Cat_name AS Cat_name,
  dbo.tblForum.Forum_name AS Forum_name, dbo.tblForum.Password AS Password,
  dbo.tblForum.Forum_code AS Forum_code, dbo.tblForum.[Read] AS [Read], dbo.tblTopic.*
 FROM dbo.tblCategory RIGHT OUTER JOIN
   dbo.tblForum ON dbo.tblCategory.Cat_ID = dbo.tblForum.Cat_ID RIGHT OUTER JOIN
    dbo.tblTopic ON dbo.tblForum.Forum_ID = dbo.tblTopic.Forum_ID
 WHERE
  AND (tblTopic.Last_entry_date > GetDate() - @dblActiveFrom )
 ORDER BY
      tblCategory.Cat_order ASC, tblForum.Forum_Order ASC, tblTopic.Last_entry_date DESC

ELSE IF  @AuthorID = 2  --guest (only get read = 1 for all)
 SELECT    
  --dbo.tblCategory.Cat_ID AS Cat_ID,dbo.tblCategory.Cat_name AS Cat_name,
  dbo.tblForum.Forum_name AS Forum_name, dbo.tblForum.Password AS Password,
  dbo.tblForum.Forum_code AS Forum_code, dbo.tblForum.[Read] AS [Read], dbo.tblTopic.*
 FROM dbo.tblCategory RIGHT OUTER JOIN
   dbo.tblForum ON dbo.tblCategory.Cat_ID = dbo.tblForum.Cat_ID RIGHT OUTER JOIN
    dbo.tblTopic ON dbo.tblForum.Forum_ID = dbo.tblTopic.Forum_ID
 WHERE
  (tblForum.[Read] = 1 OR (tblTopic.Forum_ID in (select Forum_ID from tblPermissions where Author_ID=@AuthorID or Group_ID in (select Group_ID from tblAuthor where Author_ID= @AuthorID)  and [Read]=1)))
  AND (tblTopic.Last_entry_date > GetDate() - @dblActiveFrom )
  AND NOT tblForum.Forum_ID in (select Forum_ID from tblPermissions where Author_ID=@AuthorID or Group_ID in (select Group_ID from tblAuthor where Author_ID= @AuthorID)  and [Read]=0)
 ORDER BY
      tblCategory.Cat_order ASC, tblForum.Forum_Order ASC, tblTopic.Last_entry_date DESC

ELSE IF @AuthorID  > 2 --Registered user (only get read =< 2 applies)

 SELECT    
  --dbo.tblCategory.Cat_ID AS Cat_ID,dbo.tblCategory.Cat_name AS Cat_name,
  dbo.tblForum.Forum_name AS Forum_name, dbo.tblForum.Password AS Password,
  dbo.tblForum.Forum_code AS Forum_code, dbo.tblForum.[Read] AS [Read], dbo.tblTopic.*
 FROM dbo.tblCategory RIGHT OUTER JOIN
   dbo.tblForum ON dbo.tblCategory.Cat_ID = dbo.tblForum.Cat_ID RIGHT OUTER JOIN
    dbo.tblTopic ON dbo.tblForum.Forum_ID = dbo.tblTopic.Forum_ID
 WHERE
  (tblForum.[Read] <= 2 OR (tblTopic.Forum_ID in (select Forum_ID from tblPermissions where Author_ID=@AuthorID or Group_ID in (select Group_ID from tblAuthor where Author_ID= @AuthorID)  and [Read]<=2)))
  AND (tblTopic.Last_entry_date > GetDate() - @dblActiveFrom )
  AND NOT tblForum.Forum_ID in (select Forum_ID from tblPermissions where Author_ID=@AuthorID or Group_ID in (select Group_ID from tblAuthor where Author_ID= @AuthorID)  and [Read]=0)
 ORDER BY
      tblCategory.Cat_order ASC, tblForum.Forum_Order ASC, tblTopic.Last_entry_date DESC

ELSE
 SELECT    
  --dbo.tblCategory.Cat_ID AS Cat_ID,dbo.tblCategory.Cat_name AS Cat_name,
  dbo.tblForum.Forum_name AS Forum_name, dbo.tblForum.Password AS Password,
  dbo.tblForum.Forum_code AS Forum_code, dbo.tblForum.[Read] AS [Read], dbo.tblTopic.*
 FROM dbo.tblCategory RIGHT OUTER JOIN
   dbo.tblForum ON dbo.tblCategory.Cat_ID = dbo.tblForum.Cat_ID RIGHT OUTER JOIN
    dbo.tblTopic ON dbo.tblForum.Forum_ID = dbo.tblTopic.Forum_ID
 WHERE
  (tblForum.[Read] = 1 OR (tblTopic.Forum_ID in (select Forum_ID from tblPermissions where Author_ID=@AuthorID or Group_ID in (select Group_ID from tblAuthor where Author_ID= @AuthorID)  and [Read]=1)))
  AND (tblTopic.Last_entry_date > GetDate() - @dblActiveFrom )
  AND NOT tblForum.Forum_ID in (select Forum_ID from tblPermissions where Author_ID=@AuthorID or Group_ID in (select Group_ID from tblAuthor where Author_ID= @AuthorID)  and [Read]=0)
 ORDER BY
      tblCategory.Cat_order ASC, tblForum.Forum_Order ASC, tblTopic.Last_entry_date DESC
GO

note: that you can add this Stored procedure without too much trouble because of the fact that the original is named wwfspActiveToipcs.

alright... test it in Query Analyzer...

EXECUTE wwfSpActiveTopics '1','1'    (admin)

EXECUTE wwfSpActiveTopics '2','1'    (guest)

EXECUTE wwfSpActiveTopics '24','1'    (a random member)

 

beautiful!

now fix the ASP to pass the new variable... on line 258 of active_topics.asp, comment out the old one and add the new one: (both lines shown here)

 'strSQL = "EXECUTE " & strDbProc & "ActiveToipcs @dblActiveFrom = " & dblActiveFrom
 strSQL = "EXECUTE " & strDbProc & "ActiveTopics " & lngLoggedInUserID & "," & dblActiveFrom & "" 

AND SAVE IT AS active_topics2.asp or something... dont screw up your original!

alright... now is where it gets funky... I get an ERROR?!?

ADODB.Recordset error '800a0cb3'

Current Recordset does not support bookmarks. This may be a limitation of the provider or of the selected cursortype.

/forumtest/active_topics4.asp, line 315

alright... at this point i'm confused...  but i managed to narrow it down to one thing:

code removed to avoid confusion with the mod.

whenever you put in a conditional into the SQL code, it doesn't return the recordset correctly.

I've tried BEGIN ... END with the if blocks, set nocount on ... set nocount off,  but nothing seems to send back the recordset properly.

can someone PLEASE EXPLAIN this to me!!!

glypher

Edited by glypher
glypher said so.

GainesvilleBands.com
Back to Top
glypher View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 25 March 2003
Location: United States
Status: Offline
Points: 38
Post Options Post Options   Thanks (0) Thanks(0)   Quote glypher Quote  Post ReplyReply Direct Link To This Post Posted: 08 October 2003 at 5:52pm
or of course you could just fix the active topics thing ;)
glypher said so.

GainesvilleBands.com
Back to Top
glypher View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 25 March 2003
Location: United States
Status: Offline
Points: 38
Post Options Post Options   Thanks (0) Thanks(0)   Quote glypher Quote  Post ReplyReply Direct Link To This Post Posted: 09 October 2003 at 11:51pm

hey lookie there... it's a bump.

anyone?   borg?  this stuff is broke and i would love to fix it!

 

glypher said so.

GainesvilleBands.com
Back to Top
dhill View Drop Down
Newbie
Newbie


Joined: 10 October 2003
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote dhill Quote  Post ReplyReply Direct Link To This Post Posted: 10 October 2003 at 1:07am

Active Topics in 7.5 shows forums that are hidden, guests can not read the topic text but can view the topics. Does anyone know a work around.

Cheers

Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post Posted: 10 October 2003 at 2:43am
I am still working on a new stored procedure for this for the next version.
Back to Top
glypher View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 25 March 2003
Location: United States
Status: Offline
Points: 38
Post Options Post Options   Thanks (0) Thanks(0)   Quote glypher Quote  Post ReplyReply Direct Link To This Post Posted: 10 October 2003 at 10:42am

Well borg... i figured out the issue. It has to do with the cursorlocation being set BEFORE the DB was queried (it doesn't work when you put in the actual recordset.open).  stupid, i know.

The stored procedures work great now.  If you want to use/mod it be my guest.

for those that want to use this... grab the SP from above (all of that works) and modify active_topics.asp (at line 256):

(changes in BLUE, comments in PURPLE)

'Initalise the strSQL variable with an SQL statement to query the database to get the Author and subject from the database for the topic
If strDatabaseType = "SQLServer" Then
 'strSQL = "EXECUTE " & strDbProc & "ActiveToipcs @dblActiveFrom = " & dblActiveFrom
 strSQL = "EXECUTE " & strDbProc & "ActiveTopics " & lngLoggedInUserID & "," & dblActiveFrom & "" 
Else
' all of the Access stuff needs to be fixed... but since i dont use it i dont care.
 strSQL = "SELECT " & strDbTable & "Forum.Forum_name, " & strDbTable & "Forum.Password, " & strDbTable & "Forum.Forum_code, " & strDbTable & "Forum.[Read], " & strDbTable & "Topic.* "
 strSQL = strSQL & "FROM " & strDbTable & "Category, " & strDbTable & "Forum, " & strDbTable & "Topic "
 strSQL = strSQL & "WHERE ((" & strDbTable & "Category.Cat_ID = " & strDbTable & "Forum.Cat_ID AND " & strDbTable & "Forum.Forum_ID = " & strDbTable & "Topic.Forum_ID) AND (" & strDbTable & "Forum.[Read] = True) AND (" & strDbTable & "Topic.Last_entry_date > " & strDatabaseDateFunction & " - " & dblActiveFrom & "))"
 strSQL = strSQL & "ORDER BY " & strDbTable & "Category.Cat_order ASC, " & strDbTable & "Forum.Forum_Order ASC, " & strDbTable & "Topic.Last_entry_date DESC;"
End If

' ADDED BY glyph
rsForum.Cursorlocation = 3  

'Query the database
rsForum.Open strSQL, adoCon

that's it... everything seems to be working like a champ!!!

(oh, and i still you borg )

glypher said so.

GainesvilleBands.com
Back to Top
glypher View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 25 March 2003
Location: United States
Status: Offline
Points: 38
Post Options Post Options   Thanks (0) Thanks(0)   Quote glypher Quote  Post ReplyReply Direct Link To This Post Posted: 12 October 2003 at 10:41am

Hey i tweaked the Stored Procedure a bit I wanted to post it here.

CREATE PROCEDURE  [dbo].[wwfspActiveTopics] (
@AuthorID int,
@dblActiveFrom int
)
as

set nocount on

IF  @AuthorID = 1 --admin (get everything)
 SELECT    
  --dbo.tblCategory.Cat_ID AS Cat_ID,dbo.tblCategory.Cat_name AS Cat_name,
  dbo.tblForum.Forum_name AS Forum_name, dbo.tblForum.Password AS Password,
  dbo.tblForum.Forum_code AS Forum_code, dbo.tblForum.[Read] AS [Read], dbo.tblTopic.*
 FROM dbo.tblCategory RIGHT OUTER JOIN
   dbo.tblForum ON dbo.tblCategory.Cat_ID = dbo.tblForum.Cat_ID RIGHT OUTER JOIN
    dbo.tblTopic ON dbo.tblForum.Forum_ID = dbo.tblTopic.Forum_ID
 WHERE
  (tblTopic.Last_entry_date > GetDate() - @dblActiveFrom )
 ORDER BY
      tblCategory.Cat_order ASC, tblForum.Forum_Order ASC, tblTopic.Last_entry_date DESC

ELSE IF  @AuthorID = 2  --guest (only get read = 1 for all)
 SELECT    
  --dbo.tblCategory.Cat_ID AS Cat_ID,dbo.tblCategory.Cat_name AS Cat_name,
  dbo.tblForum.Forum_name AS Forum_name, dbo.tblForum.Password AS Password,
  dbo.tblForum.Forum_code AS Forum_code, dbo.tblForum.[Read] AS [Read], dbo.tblTopic.*
 FROM dbo.tblCategory RIGHT OUTER JOIN
   dbo.tblForum ON dbo.tblCategory.Cat_ID = dbo.tblForum.Cat_ID RIGHT OUTER JOIN
    dbo.tblTopic ON dbo.tblForum.Forum_ID = dbo.tblTopic.Forum_ID
 WHERE
  (tblForum.[Read] = 1 OR (tblTopic.Forum_ID in (select Forum_ID from tblPermissions where Author_ID=@AuthorID or Group_ID in (select Group_ID from tblAuthor where Author_ID= @AuthorID)  and [Read]=1)))
  AND (tblTopic.Last_entry_date > GetDate() - @dblActiveFrom )
  AND NOT tblForum.Forum_ID in (select Forum_ID from tblPermissions where Group_ID in (select Group_ID from tblAuthor where Author_ID= @authorID and [Read]=0))
  AND NOT tblForum.Forum_ID in (select Forum_ID from tblPermissions where Author_ID = @AuthorID and [Read]=0)
 ORDER BY
      tblCategory.Cat_order ASC, tblForum.Forum_Order ASC, tblTopic.Last_entry_date DESC

ELSE IF @AuthorID  > 2 --Registered user (get read =< 2 applies)

 SELECT    
  --dbo.tblCategory.Cat_ID AS Cat_ID,dbo.tblCategory.Cat_name AS Cat_name,
  dbo.tblForum.Forum_name AS Forum_name, dbo.tblForum.Password AS Password,
  dbo.tblForum.Forum_code AS Forum_code, dbo.tblForum.[Read] AS [Read], dbo.tblTopic.*
 FROM dbo.tblCategory RIGHT OUTER JOIN
   dbo.tblForum ON dbo.tblCategory.Cat_ID = dbo.tblForum.Cat_ID RIGHT OUTER JOIN
    dbo.tblTopic ON dbo.tblForum.Forum_ID = dbo.tblTopic.Forum_ID
 WHERE
  (tblForum.[Read] <= 2 OR (tblTopic.Forum_ID in (select Forum_ID from tblPermissions where Author_ID=@AuthorID or Group_ID in (select Group_ID from tblAuthor where Author_ID= @AuthorID)  and [Read]<=2)))
  AND (tblTopic.Last_entry_date > GetDate() - @dblActiveFrom )
  AND NOT tblForum.Forum_ID in (select Forum_ID from tblPermissions where Group_ID in (select Group_ID from tblAuthor where Author_ID= @authorID and [Read]=0))
  AND NOT tblForum.Forum_ID in (select Forum_ID from tblPermissions where Author_ID = @AuthorID and [Read]=0)

 ORDER BY
      tblCategory.Cat_order ASC, tblForum.Forum_Order ASC, tblTopic.Last_entry_date DESC

ELSE
 SELECT    
  --dbo.tblCategory.Cat_ID AS Cat_ID,dbo.tblCategory.Cat_name AS Cat_name,
  dbo.tblForum.Forum_name AS Forum_name, dbo.tblForum.Password AS Password,
  dbo.tblForum.Forum_code AS Forum_code, dbo.tblForum.[Read] AS [Read], dbo.tblTopic.*
 FROM dbo.tblCategory RIGHT OUTER JOIN
   dbo.tblForum ON dbo.tblCategory.Cat_ID = dbo.tblForum.Cat_ID RIGHT OUTER JOIN
    dbo.tblTopic ON dbo.tblForum.Forum_ID = dbo.tblTopic.Forum_ID
 WHERE
  (tblForum.[Read] = 1 OR (tblTopic.Forum_ID in (select Forum_ID from tblPermissions where Author_ID=@AuthorID or Group_ID in (select Group_ID from tblAuthor where Author_ID= @AuthorID)  and [Read]=1)))
  AND (tblTopic.Last_entry_date > GetDate() - @dblActiveFrom )
  AND NOT tblForum.Forum_ID in (select Forum_ID from tblPermissions where Group_ID in (select Group_ID from tblAuthor where Author_ID= @authorID and [Read]=0))
  AND NOT tblForum.Forum_ID in (select Forum_ID from tblPermissions where Author_ID = @AuthorID and [Read]=0)
 ORDER BY
      tblCategory.Cat_order ASC, tblForum.Forum_Order ASC, tblTopic.Last_entry_date DESC
GO

glypher said so.

GainesvilleBands.com
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post Posted: 13 October 2003 at 5:24am
I've come up with the following for the next version:-

CREATE PROCEDURE [dbo].[wwfSpActiveTopics] (
@AuthorID int,
@GroupID int,
@GroupPerm int,
@dblActiveFrom datetime

)
AS
SELECT tblForum.Forum_name, tblForum.Password, tblForum.Forum_code, tblTopic.*
FROM tblCategory, tblForum, tblTopic
WHERE ((tblCategory.Cat_ID = tblForum.Cat_ID AND tblForum.Forum_ID = tblTopic.Forum_ID) AND (tblTopic.Last_entry_date > GetDate() - @dblActiveFrom))
 AND (tblForum.[Read] <= @GroupPerm OR (tblTopic.Forum_ID IN (
    SELECT tblPermissions.Forum_ID
    FROM tblPermissions
    WHERE tblPermissions.Author_ID = @AuthorID OR tblPermissions.Group_ID = @GroupID AND tblPermissions.[Read]=1))
    )
ORDER BY tblCategory.Cat_order ASC, tblForum.Forum_Order ASC, tblTopic.Last_entry_date DESC;
GO


You need to pass 4 bits of data to the sp.
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.