Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > General > Member Archives
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Hide private forums from this MySQL query...very hard Details »»
Hide private forums from this MySQL query...very hard
Version: , by Jungleman Jungleman is offline
Developer Last Online: Jan 2005 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 08-05-2002 Last Update: Never Installs: 0
 
No support by the author.

I am working on a hack which breaks down a users posts into forums they have posted in..

Example, if a user has 1000 posts, it shows 500 in Off Topic, 300 in Hardware Support, 150 in Software Support, 50 in Web Design, etc.

So far the hack works great, one little problem-- it shows names of private forums to people who aren't supposed to have access to them, and I want to avoid that.

Here is the query that I am using:

SELECT COUNT(p.postid) AS post_count, f.title, f.forumid FROM forum f, post p, thread t, user u WHERE f.forumid = t.forumid AND t.threadid = p.threadid AND p.userid = u.userid AND u.userid = $userid AND t.visible = 1 GROUP BY f.forumid ORDER BY post_count DESC

How can I eliminate forums NOT accessible to regular users?

BTW, if you wanna run that query on your forum to see how it works, replace $userid with the user ID of your choice.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 08-05-2002, 05:46 PM
filburt1 filburt1 is offline
 
Join Date: Feb 2002
Location: Maryland, US
Posts: 6,144
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

...WHERE forumid NOT IN(comma-delimited list of private forumids)

Beyond that, don't know
Reply With Quote
  #3  
Old 08-05-2002, 05:52 PM
Jungleman Jungleman is offline
 
Join Date: Nov 2001
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yep...well, that'd work just for my forum, but I wanted to release this hack.

Just gotta finish this up...OK I can do it
Reply With Quote
  #4  
Old 08-05-2002, 08:42 PM
Logician's Avatar
Logician Logician is offline
 
Join Date: Nov 2001
Location: inside vb code
Posts: 4,449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can ask the users to edit that part of the hack according to their forums so filburt1's solution is good.

But if you are determined to code your hack so that it will automaticly detect this, you can get the help of the function getpermissions like:

$getperms=getpermissions($forumid,-1,-1,$forum['parentlist']);

if (!$getperms['canview'] OR !$getperms['canviewothers'])
{
//user dont have permission for this forum skip it
}
Reply With Quote
  #5  
Old 08-05-2002, 09:27 PM
Jungleman Jungleman is offline
 
Join Date: Nov 2001
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Logician, what would be the usage of that code? Where should I put it?

Thanks
Reply With Quote
  #6  
Old 08-05-2002, 10:39 PM
Logician's Avatar
Logician Logician is offline
 
Join Date: Nov 2001
Location: inside vb code
Posts: 4,449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did I get you wrong?

I thought you are trying to find out if forum X is closed for the user so that you can exclude it from your query. If this is correct the function I refered makes this check so you can call it before your query so that you can detect private forums for the board viewer.

I'm assuming you required global.php" in your script..
Reply With Quote
  #7  
Old 08-05-2002, 11:51 PM
Jungleman Jungleman is offline
 
Join Date: Nov 2001
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I put the require global.php in.

I put the block of code you told me to put right before my query and it did nothing, and I logged in as a test user that has no access to special forums to verify. It kept showing the hidden forums.

I think I'm doing something wrong.
Reply With Quote
  #8  
Old 08-12-2002, 01:08 AM
Jungleman Jungleman is offline
 
Join Date: Nov 2001
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Bump
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:38 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04266 seconds
  • Memory Usage 2,264KB
  • Queries Executed 21 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (7)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete