vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   latest posts from private forums on external page? (https://vborg.vbsupport.ru/showthread.php?t=322102)

khininger 03-14-2016 03:07 AM

latest posts from private forums on external page?
 
hi.

i have an external page thats not a vbulletin page (same domain, parent directory). it includes global.php, greets the user by name and displays dynamic content based on their usergroup. on this page i have the external js with latest posts. the problem is that most of our forums are private, and this js only lists posts from the one public forum we got. i want to show latest posts from whatever forums the user has access to read, since the page knows which usergroup they belong to. can it be done with this external js somehow, or i need to do it differently? any pointers if so?

thank you very much!

MarkFL 03-14-2016 03:15 AM

I use the following condition to determine whether a user has permission to view a post or not:

PHP Code:

($vbulletin->userinfo['forumpermissions'][$post['forumid']] & $vbulletin->bf_ugp_forumpermissions['canview']) AND (($tpost['visible'] == 1) OR can_moderate($post['forumid'])) 


khininger 03-14-2016 03:37 AM

thank you :)

how do i get the posts to the page though, before checking which of them to display and which to hide?

MarkFL 03-14-2016 03:56 AM

If you want to get the latest posts, along with the titles of the threads to which they belong (and the thread icons/prefixes), then I suggest this query:

PHP Code:

$recent_posts $vbulletin->db->query_read("
    SELECT post.*, thread.title, thread.forumid, thread.prefixid, thread.iconid, icon.iconpath, icon.title AS icon_title, phrase.text
    FROM " 
TABLE_PREFIX "post AS post
    INNER JOIN " 
TABLE_PREFIX "thread AS thread
    ON thread.threadid = post.threadid
    LEFT JOIN " 
TABLE_PREFIX "icon AS icon
    ON icon.iconid = thread.iconid
    LEFT JOIN " 
TABLE_PREFIX "phrase AS phrase
    ON phrase.varname = CONCAT('prefix_', thread.prefixid, '_title_rich')
    ORDER BY post.dateline DESC
"
); 

Then, you could use a while loop to get each post:

PHP Code:

$pcount 0;
$number_of_posts 15//this will grab 15 posts

while ($tpost $db->fetch_array($recent_posts) AND $pcount $number_of_posts)
{
    if ((
$vbulletin->userinfo['forumpermissions'][$tpost['forumid']] & $vbulletin->bf_ugp_forumpermissions['canview']) AND (($tpost['visible'] == 1) OR can_moderate($tpost['forumid'])))
    {
        
$pcount++;
        
//build links to posts here
    
}



khininger 03-14-2016 01:41 PM

thank you very much mark, this is perfect, much more than i expected!

only one question - i didnt mention it, my bad, but i also need forumtitle, in addition to forumid. i tried googling, but i never used queries before, and it looks like forumtitle is in a different table, so im not sure how to get it...

MarkFL 03-14-2016 01:54 PM

Okay, try changing the query to:

PHP Code:

$recent_posts $vbulletin->db->query_read("
    SELECT post.*, thread.title, thread.forumid, thread.prefixid, thread.iconid, icon.iconpath, icon.title AS icon_title, phrase.text, forum.title AS forum_title
    FROM " 
TABLE_PREFIX "post AS post
    INNER JOIN " 
TABLE_PREFIX "thread AS thread
    ON thread.threadid = post.threadid
    LEFT JOIN " 
TABLE_PREFIX "icon AS icon
    ON icon.iconid = thread.iconid
    LEFT JOIN " 
TABLE_PREFIX "phrase AS phrase
    ON phrase.varname = CONCAT('prefix_', thread.prefixid, '_title_rich')
    LEFT JOIN " 
TABLE_PREFIX "forum AS forum
    ON forum.forumid = thread.forumid
    ORDER BY post.dateline DESC
"
); 


khininger 03-14-2016 02:03 PM

works perfectly, thank you so very much!


All times are GMT. The time now is 04:01 AM.

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.01028 seconds
  • Memory Usage 1,746KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete