The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
help.. permission check for "last 5 posts.."
Hi
Could someone urgently amend this query for me to exclude posts the viewing user does not have permission to view? $threads = $vbulletin->db->query_read("SELECT threadid, title, lastpost, lastposter FROM " . TABLE_PREFIX . "thread WHERE visible = '1' AND open = '1' ORDER BY lastpost DESC LIMIT 5 "); Thanks Simon |
#2
|
|||
|
|||
This gets the last 5 threads. I would've edit it to show the last 5 posts but I'll let you do that.
PHP Code:
|
#3
|
||||
|
||||
2 tips:
-Do the forum permission checking prior to the query (generating a comma-delimited list of forumids they can or can't see): WHERE forumid NOT IN ($ids) -Only show posts from the past few days, which would utilize the date index (greatly reducing the amount of juice it will take to bring up the records) |
#4
|
|||
|
|||
Thanks guys
I've changed it to the following (which I've taken from somewhere, can't remember where now!) .. Code:
$blockforums = ""; foreach($vbulletin->forumcache AS $forum) { $forumid = $forum['forumid']; $forumperms =& $vbulletin->userinfo['forumpermissions']["$forumid"]; if (!isset($vbulletin->forumcache["$forumid"]) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) OR !verify_forum_password($forumid, $vbulletin->forumcache["$forumid"]['password'], false)) { $blockforums .= ','.$forum['forumid']; } } $threads = $vbulletin->db->query_read("SELECT threadid, title, lastpost, lastposter FROM " . TABLE_PREFIX . "thread WHERE visible = '1' AND open = '1' AND forumid NOT IN (0$blockforums) ORDER BY lastpost DESC LIMIT 5 "); Thanks again Simon |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|