ddrake
01-23-2010, 07:38 PM
I'm using a PHP direct execution widget to find "Posts Needing Replies". These are defined as visible, non-sticky posts in a specific set of forums with 0 replies. But some of the forums are not available to all users, so I want to modify the query to hide any posts that are not accessible by the current user. Can anyone help?
ob_start();
require_once('./includes/functions_user.php');
require_once('./includes/functions_bigthree.php');
// Get Popular Threads
$need_replies_get = vB::$db->query_read("
SELECT * FROM ".TABLE_PREFIX."thread
WHERE visible=1 AND replycount=0 AND forumid in(9,10,12,15,16) AND sticky = 0
ORDER BY replycount DESC
LIMIT 5");
$output_bits = '';
while($need_replies = vB::$db->fetch_array($need_replies_get))
{
$output_bits .= '<a target="_self" href="showthread.php?t='.$need_replies[threadid].'">'.$need_replies[title].'</a><br />';
}
$output = $output_bits;
ob_end_clean();
--------------- Added 1264365438 at 1264365438 ---------------
My problem is really just that I don't know how to get the id of the current user or a userinfo object from inside the PHP widget. I'm sure it's really simple, but I can't find an API for vb4...
--------------- Added 1264368772 at 1264368772 ---------------
Ok, after floundering a bit, this seems to work: vB::$vbulletin->userinfo['userid']
Please, anyone feel free to correct me if I'm making this harder than it needs to be...
ob_start();
require_once('./includes/functions_user.php');
require_once('./includes/functions_bigthree.php');
// Get Popular Threads
$need_replies_get = vB::$db->query_read("
SELECT * FROM ".TABLE_PREFIX."thread
WHERE visible=1 AND replycount=0 AND forumid in(9,10,12,15,16) AND sticky = 0
ORDER BY replycount DESC
LIMIT 5");
$output_bits = '';
while($need_replies = vB::$db->fetch_array($need_replies_get))
{
$output_bits .= '<a target="_self" href="showthread.php?t='.$need_replies[threadid].'">'.$need_replies[title].'</a><br />';
}
$output = $output_bits;
ob_end_clean();
--------------- Added 1264365438 at 1264365438 ---------------
My problem is really just that I don't know how to get the id of the current user or a userinfo object from inside the PHP widget. I'm sure it's really simple, but I can't find an API for vb4...
--------------- Added 1264368772 at 1264368772 ---------------
Ok, after floundering a bit, this seems to work: vB::$vbulletin->userinfo['userid']
Please, anyone feel free to correct me if I'm making this harder than it needs to be...