function makeforumjump()
{
// this generates the jump to box
global $DB_site,$forumid,$optionselected,$usecategories, $jumpforumid,$jumpforumtitle, $jumpforumbits,$curforumid;
global $hideprivateforums,$defaultselected, $forumjump,$bbuserid,$bbusergroupid;
if ($forumid!="")
{
$curforumid=$forumid;
}
else
{
if ($threadid!="")
{
$getforumid=$DB_site->query_first("SELECT forumid FROM thread WHERE threadid=$threadid");
$curforumid=$getforumid[forumid];
}
}
$forums=$DB_site->query("SELECT category.categoryid, category.title AS categorytitle,
forumid, forum.title AS forumtitle
FROM category
LEFT JOIN forum ON (category.categoryid = forum.categoryid)
WHERE category.displayorder<>0 AND forum.displayorder <> 0 AND active=1
ORDER BY category.displayorder, forum.displayorder");
$firstcat = 0;
while ($forum=$DB_site->fetch_array($forums))
{
$currentcat = $forum[categoryid];
if ($usecategories == 1)
{
$optionselected="";
if ($firstcat != $currentcat) // Print Category
{
$firstcat = $forum[categoryid];
// This creates our "blank line" in the dropdown
$jumpforumid="";
$jumpforumtitle="";
eval("\$jumpforumbits .= \"".gettemplate("jumpforumbit")."\";");
$jumpforumid="cat$forum[categoryid]";
$jumpforumtitle="Category: $forum[categorytitle]";
eval("\$jumpforumbits .= \"".gettemplate("jumpforumbit")."\";");
$jumpforumid="";
$jumpforumtitle="--------------------";
eval("\$jumpforumbits .= \"".gettemplate("jumpforumbit")."\";");
}
}
if ($hideprivateforums==1)
{
$getperms=getpermissions($bbuserid,$bbusergroupid,$forum[forumid]);
}
else
{
$getperms[canview]=1;
}
if ($getperms[canview]==1)
{
$jumpforumid=$forum[forumid];
$jumpforumtitle=" $forum[forumtitle]";
if ($curforumid==$jumpforumid)
{
$optionselected="selected";
$selectedone=1;
}
eval("\$jumpforumbits .= \"".gettemplate("jumpforumbit")."\";");
}
}
if ($selectedone!=1)
{
$defaultselected="selected";
}
eval("\$forumjump = \"".gettemplate("forumjump")."\";");
}
For the record the current forumjump retrieves a list of categories. Then for each record in that result set it runs a query of the forums that belong to that category. Have 50 categories, you have 51 queries. Now you would have 2. We still need to do something about that "getperms" function as it will run a query each time per forum. How about we retrieve that information along with the bbusername, bbpassword, bbuserid and have it available instead of constantly retrieveing it all the time. Just a thought.
[Edited by Ed Sullivan on 10-27-2000 at 05:45 PM]
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
Or does it improve a different area. I'm assuming its different, since you had posted in the other thread before, but don't have the time to run through the code atm.
Oh it achieves the same but mine makes a hell of a lot more sense. I posted alot of questions about errors and such with his hack and he never responded.
In reality, someone on vbulletin.org asked for an optimization of forumjump and I had forgot fodder had made one.