vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Simple newsportal / thread overview to add to your board... (https://vborg.vbsupport.ru/showthread.php?t=38334)

KuraFire 05-07-2002 11:15 AM

I made this script basically just for my own needs, but figured others might appreciate it as well. :)

Man, this permissions thing is giving me a headache. Nakkid, I can't say exactly why that part of code of yours is adding 1 query for every thread, but it does suck and it's hell trying to get around it. :(

Xenon 05-07-2002 04:37 PM

well i'm not sure, why there is sometimes an error and sometimes not

i think you can solve this problem, with making an extra query for each message news, i have made it so an it works:

PHP Code:

$newsql $DB_site->query("SELECT thread.threadid as tid, thread.title as ttitle, thread.replycount as treply, thread.postusername as user, thread.postuserid as userid, thread.dateline as dateline FROM thread WHERE forumid=$newsforum GROUP BY thread.threadid ORDER BY thread.threadid DESC LIMIT $newslimit");
if (!
$newsql) {
  
// use this only to check whether it works on your board, 
  // after all tests turn successful you can remove it if you want (remove entire IF-statement of course)
  
echo "<p>Could not get news records.";
  exit;
}

while (
$news=$DB_site->fetch_array($newsql)) {
    
$newstext=$DB_site->query_first("SELECT post.pagetext FROM post    WHERE post.threadid='$news[tid]' ORDER BY postid LIMIT 1");
    
$pagetext=$newstext['pagetext']; 

instead of

PHP Code:

$newsql $DB_site->query("SELECT thread.threadid as tid, thread.title as ttitle, thread.replycount as treply, thread.postusername as user, thread.postuserid as userid, thread.dateline as dateline, post.pagetext as pagetext FROM thread LEFT JOIN post USING (threadid) WHERE forumid=$newsforum GROUP BY thread.threadid ORDER BY thread.threadid DESC LIMIT $newslimit");

if (!
$newsql) {
  
// use this only to check whether it works on your board, 
  // after all tests turn successful you can remove it if you want (remove entire IF-statement of course)
  
echo "<p>Could not get news records.";
  exit;
}

while (
$news=$DB_site->fetch_array($newsql)) { 

i think it should work, but i dont tested it, just compared with my files ;)

try it and say it to me if it works or not. If not, i will check it a more :)

KuraFire 05-07-2002 04:42 PM

That should work fine, from what I see, but it adds a query for each news item, and I'm trying to get rid of that since I _know_ this can be done using only 2 queries.

With your code, the default setup would add 8 queries to the 10~12 that global.php runs already. Seems to me as not very efficient. :(

Besides, that's how my _old_ script was run. One query for the newsforum, and one for each news item..... I was hoping to _advance_ :(

Thanks though. Well-appreciated :):up:

AndyTSJ 05-07-2002 05:33 PM

How can I pull news from more than one forum

Code:

$newsforum = 5;

Parker Clack 05-07-2002 05:43 PM

Kurafire:

To get the permissions issued addressed on my site I used

Code:

if (ismoderator($forumid) or $getperms['canopenclose'] or $getperms['candeletethread'] or $getperms['canmove']) {
$threadsql = $DB_site->query("SELECT lastposter, threadid, title, replycount FROM thread WHERE forumid ORDER BY lastpost DESC LIMIT $threadslimit");
} else {
$threadsql = $DB_site->query("SELECT lastposter, threadid, title, replycount FROM thread WHERE forumid $forumexclude ORDER BY lastpost DESC LIMIT $threadslimit");
}

in the threads section just above the array.

Parker

KuraFire 05-07-2002 05:53 PM

AndyTSJ:

try replacing that line with

PHP Code:

$newsforum "5 OR forumid=6"

where 5 and 6 are the id's of the two newsforums. I'm not sure if this really works, but it's worth a try. Let us know if it works, eh? :):up:

Parker: have you tried that out as a normal registered member?

come to think of it, would this piece of code work?

PHP Code:

if ( $getperms['canview']) {
 
$threadsql DB_site->query("SELECT lastposter, threadid, title, replycount FROM thread WHERE forumid ORDER BY lastpost DESC LIMIT $threadslimit");
} else {
$threadsql $DB_site->query("SELECT lastposter, threadid, title, replycount FROM thread WHERE forumid $forumexclude ORDER BY lastpost DESC LIMIT $threadslimit"); 


? I'll test this later on, but if someone else wants to test this right away, be my guest and let us know :)

(I'm off for some things so I can't test it myself right now :()

AndyTSJ 05-07-2002 05:57 PM

That works !!!!!!!!!!!!!!!!! COOL :) :)

Parker Clack 05-07-2002 06:50 PM

Kurafire:

I tried the $getperms['canview'] before I tried what I suggested above and that didn't work.

The code that I suggested works on my board just fine and it will only allow those admins, etc. that are allowed to view a private forum see the thread listed. If you are a regular member you will not see the ones that you set up in $forumexclude.

Parker

KuraFire 05-07-2002 07:59 PM

Parker: ah yes, I saw that already but the thing is, I'm one of those people who have more than the default usergroups. I have 1 category with 4 forums in it that is only accessible to users in a certain usergroup, and 1 forum elsewhere that is only accessible to users in yet Another special usergroup.
Using your code wouldn't help at all for my board, nor for people who have something similar.

However, it DOES indeed work on boards where there's only admins, S-mods and normal members, I guess. Thanks for that addition, therefore, because it will at least allow people with such board-setups to include permissions in this script already. :)

TECK 05-07-2002 08:24 PM

kura, PPN rewrote the perms code i had there in a much more elegant way. take a look and insert it also in your script:
https://vborg.vbsupport.ru/showthrea...924#post248924


All times are GMT. The time now is 04:58 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.01127 seconds
  • Memory Usage 1,758KB
  • 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
  • (2)bbcode_code_printable
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete