Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-14-2016, 03:07 AM
khininger khininger is offline
 
Join Date: Aug 2009
Posts: 33
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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!
Reply With Quote
  #2  
Old 03-14-2016, 03:15 AM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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'])) 
Reply With Quote
Благодарность от:
khininger
  #3  
Old 03-14-2016, 03:37 AM
khininger khininger is offline
 
Join Date: Aug 2009
Posts: 33
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thank you

how do i get the posts to the page though, before checking which of them to display and which to hide?
Reply With Quote
  #4  
Old 03-14-2016, 03:56 AM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
    
}

Reply With Quote
Благодарность от:
RaYdeN.ADM
  #5  
Old 03-14-2016, 01:41 PM
khininger khininger is offline
 
Join Date: Aug 2009
Posts: 33
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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...
Reply With Quote
  #6  
Old 03-14-2016, 01:54 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
"
); 
Reply With Quote
  #7  
Old 03-14-2016, 02:03 PM
khininger khininger is offline
 
Join Date: Aug 2009
Posts: 33
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

works perfectly, thank you so very much!
Reply With Quote
Благодарность от:
MarkFL
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 05:06 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04420 seconds
  • Memory Usage 2,247KB
  • Queries Executed 13 (?)
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)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (3)post_thanks_box_bit
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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_postinfo_query
  • fetch_postinfo
  • 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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete