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

Reply
 
Thread Tools Display Modes
  #1  
Old 10-20-2010, 08:14 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Trying to get this to work... (lightbulb function)

So working backwards from the threadbit templates I've been trying to figure out the code that controls which status icon is shown on forumdisplay (old posts, old posts locked, new posts, new posts locked...) and I want to use that code elsewhere, specifically on the navnar so I can show a notice if a particular forum has an unread message in it.

I've tracked this down to the forum_fetch_lightbulb function in the functions_forumlist.php file. The function takes 3 parameters, two of which are the forum id of the forum and one of which is an array which also is the forum id and the parent id of the forum... why this function needs 3 things with the same info I'm not sure but that isn't the issue.

I am passing it the correct info (I believe) but I'm always only getting the same return value: "old" - Even when there are new posts in the forum with the id I specify. I confirm this by going to forumdisplay and seeing the "new posts" status icon is indeed there.

Any thoughts on what I might need to get this to work? I am temporarily outputting the text to the navbar for now but will obviously be doing something more with it once I can get it to work.

plugin code:
Code:
include('includes/functions_forumlist.php'); 

//set forumid
$checkfid = $checkfid2 = 4;
//build array
$checkarray["forumid"] = $checkfid;
$checkarray["parentid"] = 1;

$sico = fetch_forum_lightbulb($checkfid, $checkarray, $checkfid2);

eval('$template_hook[navbar_buttons_left] .= "' ."<td>" .$sico.  "</td>" . '";');
Reply With Quote
  #2  
Old 10-20-2010, 09:47 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Looking in functions_forumlist.php, it looks like the parameters to fetch_forum_lightbulb should be forumid, lastpostinfo, foruminfo. Stealing some code from that file, you might be able to do something like this (assuming $forumid is already set):

Code:
global $vbulletin, $lastpostarray;

// call fetch_last_post_array() first to get last post info for forums
if (!is_array($lastpostarray))
{
	fetch_last_post_array(-1);
}

// grab the appropriate forum from the $vbulletin->forumcache
$forum = $vbulletin->forumcache["$forumid"];

$lastpostinfo = (empty($lastpostarray[$forumid]) ? array() : $vbulletin->forumcache["$lastpostarray[$forumid]"]);

$sioc = fetch_forum_lightbulb($forumid, $lastpostinfo, $forum);
And then if you look in functions_forumlist after fetch_forum_lightbulb is called you can see there's some additional code to add the lock for locked threads, if you care about that.

I didin't try any of this so I'm not sure if there might be something else you need to do.
Reply With Quote
  #3  
Old 10-20-2010, 11:26 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK I think the issue is that this needs to be in the navbar so a specific forum won't really be available, I want to seed it with the forum id's I need to check.

Also I have it on global_start, not sure if there is a better hook...

I don'r care about locked or not, just "new" or "old"

Integrating your code and my needs I get:

Code:
include('includes/functions_forumlist.php'); 
global $vbulletin, $lastpostarray;
// call fetch_last_post_array() first to get last post info for forums
if (!is_array($lastpostarray))
{
	fetch_last_post_array(-1);
}


// setthe appropriate forum id
$forumck = 4;
$forumxx = 4;

$lastpostinfo = (empty($lastpostarray[4]) ? array() : $vbulletin->forumcache["$lastpostarray[4]"]);

$sico = fetch_forum_lightbulb($forumck, $lastpostinfo, $forumxx);
eval('$template_hook[navbar_buttons_left] .= "' ."<td>" .$sico.  "</td>" . '";');
This still produces "old" and only "old" for output.

I'm thinking the issue might be in $forumxx (in your code it was just $forum) - what type of info is in this variable? From my looking at the code I thought it was simply the forumid of the forum I'm checking on, but that should be the same as $forumid ($forumck in my code) so that doesn't make too much sense to me.
Reply With Quote
  #4  
Old 10-21-2010, 12:15 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yeah, $foruminfo (the third parameter) is an array that has all the info about a forum (or at least everything that's needed to display the page). If you look at the actual code for fetch_forum_lightbulb you can see how it's used. Anyway, I'm not sure if the forumcache is available at global_start or not. Probably it is.
Reply With Quote
  #5  
Old 10-21-2010, 01:37 AM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ahhh... thanks... don't know how I missed that.

OK so it's an array... looking at the definition of the fetch_light_bulb function it uses two parts of the array $foruminfo['forumid'] which is no problem, that's something I'm going to set... But it also uses $foruminfo['forumread']... Now I had to find what was in this...

In forumdisplay.php is the line:
$foruminfo['forumread'] = $vbulletin->forumcache["$foruminfo[forumid]"]['forumread'];

So once again the forumid I can again provide since it will be a value I set... but now there's this ['forumread'] thing... I searched though all the text of all the vb files... "['forumread']" occurs 28 times, but is never on the left side of the "equals" (=) sign... Now I know it's not a variable but I don't understand how to figure out what info it's supposed to contain...
It does appear on the left side once but it's in the install files mysql schema and I don't think it's what I'm looking for.

Do you know what is in ['forumread'] ? Is it a date?
Reply With Quote
  #6  
Old 10-21-2010, 04:46 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BirdOPrey5 View Post
Do you know what is in ['forumread'] ? Is it a date?
I think it's a date that comes out of the table "forumread" (the readtime column).

Did you try using "$forum = $vbulletin->forumcache["$forumid"];"? Maybe the forumcache is already set up with that info. If not, it looks like the user-specific info is added by the function cache_ordered_forums in includes/function.php, so maybe you could call that with a 1 for the first parameter. Like

Code:
// cache_ordered_forums(1); // uncomment this if it doesn't work without it 
$forum = $vbulletin->forumcache["$forumid"];
Then use $forum as the 3rd param to fetch_forum_lightbulb.

If I had time I'd try it out on my test site, but I don't right now.


ETA: Now that I'm more awake...if you just want the forumread field you might be able to do something like:

Code:
$forum = $vbulletin->db->query_first("SELECT readtime from ".TABLE_PREFIX."forumread AS forumread
                                        WHERE userid =".$vbulletin->userinfo['userid']." 
                                        AND forumid=".$forumid);

$forum['forumid'] = $forumid;
Although it would probably be more efficient to check if the info is already being filled in.
Reply With Quote
  #7  
Old 10-21-2010, 04:52 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK Thanks... the first bit of code was a big help- definitely needed to use: cache_ordered_forums(1); for it to work... now I have data in the $forum variable... but still not working. I've narrowed it down to the $lastpostinfo - it's always an empty array.

Current code: (note I had to change the name of $forumid and $forum because the names were interfering with existing code and the forum wouldn't display properly until I changed them so I added an 'x' to the end of each:

Code:
include('includes/functions_forumlist.php'); 
global $vbulletin, $lastpostarray;
// call fetch_last_post_array() first to get last post info for forums
if (!is_array($lastpostarray))
{
	fetch_last_post_array(-1);
}

$lastpostinfo = (empty($lastpostarray[4]) ? array() : $vbulletin->forumcache["$lastpostarray[4]"]);

$forumidx = 4;

cache_ordered_forums(1);  
$forumx = $vbulletin->forumcache["$forumidx"];

$sico = fetch_forum_lightbulb($forumidx, $lastpostinfo, $forumx);
eval('$template_hook[navbar_buttons_left] .= "' ."<td>" .$sico.  $forumx['forumid']. "-" . $forumx['forumread'] . $lastpostinfo['lastpost'] ."</td>" . '";');
The output of this is: old4-1287669138
$lastpostinfo['lastpost'] is empty.
Reply With Quote
  #8  
Old 10-21-2010, 05:00 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm...$lastpostarray comes from $vbulletin->iforumcache which should be filled in by the call to cache_ordered_forums - maybe try passing a second "1" like:

cache_ordered_forums(1, 1);

ETA: oh...try calling cache_ordered_fourms *before* fetch_last_post_array.
Reply With Quote
  #9  
Old 10-21-2010, 07:43 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

O M G... THANK YOU!!!! That was it (calling cache_ordered_forums first) !!!
Reply With Quote
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 07:12 PM.


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.04012 seconds
  • Memory Usage 2,253KB
  • Queries Executed 11 (?)
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
  • (6)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)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_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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete