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 07-10-2006, 01:13 AM
maximux1's Avatar
maximux1 maximux1 is offline
 
Join Date: Mar 2002
Posts: 89
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Update Post/Thread Count with DataManager

I've got a mod where I am inserting new threads. I am able to create the new threads in the forumid of choice, however I can't figure out how to update the thread counts and 'last thread posted' in the forum I am creating threads in.

Although the thread is created, if you visit the forum index the last thread posted is not updated. I'm sure there is a function I have overlooked to do this.

I can post further information if needed.

Thanks
Reply With Quote
  #2  
Old 07-10-2006, 02:32 AM
Code Monkey's Avatar
Code Monkey Code Monkey is offline
 
Join Date: May 2004
Posts: 1,080
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
build_forum_counters($foruminfo['forumid']); 
Reply With Quote
  #3  
Old 07-10-2006, 03:07 AM
maximux1's Avatar
maximux1 maximux1 is offline
 
Join Date: Mar 2002
Posts: 89
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by JumpD
PHP Code:
build_forum_counters($foruminfo['forumid']); 

Thank you for your prompt & direct answer to my query.

Unfortunately, I have continued problems that I would like to request your assistance with.

Here is the code snippet I am using to build the datamanager object;

Code:
$threaddm = new vB_DataManager_Thread_FirstPost($vbulletin, ERRTYPE_STANDARD);

$forumid = 2;
$postuserid = $userid;
$userid = $userid;
$pagetext = $article;
$allowsmilie = '1';
$visible = '1';

$threaddm->do_set('forumid', $forumid);
$threaddm->do_set('postuserid', $postuserid);
$threaddm->do_set('userid', $userid);
$threaddm->do_set('username', $username);
$threaddm->do_set('pagetext', $pagetext);
$threaddm->do_set('title', $title);
$threaddm->do_set('allowsmilie', $allowsmilie);
$threaddm->do_set('visible', $visible);
$done = $threaddm->save();

build_forum_counters($foruminfo["$forumid"]);
When I run this routine the post IS created, however the counters are not updated and the following error is presented;
Code:
Fatal error: Existing data passed is not an array
Called set_existing in /home/betamar/public_html/420/includes/functions_databuild.php on line 160
Called build_forum_counters in /home/betamar/public_html/420/post.php on line 76
in /includes/class_dm.php on line 235
I believe the problem lies with the way I have assigned $forumid, however I also dont seem to have a '$foruminfo" array that I probably should be working with.

If anyone could provide some assistance or a pointer I would greatly appreciate it.

Thanks again, JumpD.

Max

After posting and looking at the code on a new background I've made some changes and now have the build_forum_counters() function working correctly.

Here is the functioning rewrite of the code snipped above;

Code:
$threaddm = new vB_DataManager_Thread_FirstPost($vbulletin, ERRTYPE_STANDARD);
$foruminfo['forumid'] = '2';
$forumid = $foruminfo['forumid'];
$postuserid = $userid;
$userid = $userid;
$pagetext = $article;
$allowsmilie = '1';
$visible = '1';

$threaddm->do_set('forumid', $forumid);
$threaddm->do_set('postuserid', $postuserid);
$threaddm->do_set('userid', $userid);
$threaddm->do_set('username', $username);
$threaddm->do_set('pagetext', $pagetext);
$threaddm->do_set('title', $title);
$threaddm->do_set('allowsmilie', $allowsmilie);
$threaddm->do_set('visible', $visible);
$done = $threaddm->save();

build_forum_counters($foruminfo['forumid']);
I've got some further problems with the way I have set the userid/username causing the uri linking to be incorrect. I'll post if I can get a functioning object.

As always, any assistance is greatly appreciated.

Max
Reply With Quote
  #4  
Old 07-10-2006, 03:29 AM
Code Monkey's Avatar
Code Monkey Code Monkey is offline
 
Join Date: May 2004
Posts: 1,080
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try this
PHP Code:
$foruminfo = array();
$foruminfo['forumid'] = $forumid;
build_forum_counters($foruminfo['forumid']); 
EDIT: After reading your edit.
Why create all those variables in memory? Just do this

PHP Code:
$threaddm = new vB_DataManager_Thread_FirstPost($vbulletinERRTYPE_STANDARD);
$foruminfo['forumid'] = '2';

$threaddm->do_set('forumid'$foruminfo['forumid']);
$threaddm->do_set('postuserid'$userid);
$threaddm->do_set('userid'$userid);
$threaddm->do_set('username'$username);
$threaddm->do_set('pagetext'$article;
$threaddm->do_set('title'$title);
$threaddm->do_set('allowsmilie''1');
$threaddm->do_set('visible''1');
$done $threaddm->save();

build_forum_counters($foruminfo['forumid']); 
Reply With Quote
  #5  
Old 07-10-2006, 03:32 PM
maximux1's Avatar
maximux1 maximux1 is offline
 
Join Date: Mar 2002
Posts: 89
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks a lot JumpD - I really appreciate your assistance.

I've got everything working properly now with the exception of just one thing that I cant seem to find a function for.

I need something like, update_post_count() where the post count of the user is incrimented. As it is now, I dont believe it is doing anything. Post Count simply shows 0 even though the userid does have a few posts on it.

Something that would also be of service to me is if you have a link to a list of all vB functions - if such a beast exists. I've been through nearly all the programming articles at this point, and they are what has gotten me this far, however I still missing some information. I'll be going through the functions files to see if I can turn it up.

Any help is apprecaited!

Thanks
Reply With Quote
  #6  
Old 07-10-2006, 05:24 PM
CyberRanger's Avatar
CyberRanger CyberRanger is offline
 
Join Date: Mar 2004
Posts: 1,319
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by maximux1
I need something like, update_post_count() where the post count of the user is incrimented. As it is now, I dont believe it is doing anything. Post Count simply shows 0 even though the userid does have a few posts on it.
This isn't a neat function, but it will get it done!

PHP Code:
// update post count for user
    
$posts $vbulletin->db->query_first("
        SELECT posts
        FROM " 
TABLE_PREFIX "user
        WHERE userid = "
.$postuserid."
    "
);
    
    
$newpostcount $posts['posts'] + 1;
    
    
$vbulletin->db->free_result($posts);
    
    
$vbulletin->db->query_write("
        UPDATE " 
TABLE_PREFIX "user
        SET posts = "
.$newpostcount."
        WHERE userid = "
.$postuserid."
    "
); 
Edit: sorry ... you probably already knew that. That's not using the datamanager now is it.
Reply With Quote
  #7  
Old 07-10-2006, 08:20 PM
maximux1's Avatar
maximux1 maximux1 is offline
 
Join Date: Mar 2002
Posts: 89
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks buddy, that'll do the trick for now!

I appreciate your help!
Reply With Quote
  #8  
Old 07-11-2006, 01:59 AM
Code Monkey's Avatar
Code Monkey Code Monkey is offline
 
Join Date: May 2004
Posts: 1,080
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by maximux1
Thanks a lot JumpD - I really appreciate your assistance.

I've got everything working properly now with the exception of just one thing that I cant seem to find a function for.

I need something like, update_post_count() where the post count of the user is incrimented. As it is now, I dont believe it is doing anything. Post Count simply shows 0 even though the userid does have a few posts on it.

Something that would also be of service to me is if you have a link to a list of all vB functions - if such a beast exists. I've been through nearly all the programming articles at this point, and they are what has gotten me this far, however I still missing some information. I'll be going through the functions files to see if I can turn it up.

Any help is apprecaited!

Thanks
It should be updating your post counts. It does for me.

Anyway, you asked for a link to all functions. Here it is.

http://members.vbulletin.com/api/
Reply With Quote
  #9  
Old 07-11-2006, 02:02 AM
maximux1's Avatar
maximux1 maximux1 is offline
 
Join Date: Mar 2002
Posts: 89
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Wow - I can't believe I havent seen that yet.

Thanks for pointing out the link.
Reply With Quote
  #10  
Old 07-11-2006, 02:03 AM
Code Monkey's Avatar
Code Monkey Code Monkey is offline
 
Join Date: May 2004
Posts: 1,080
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I just realized your doing that a bit different then I do when it comes to inisializing the datamanager. I believe your are doing that wrong. You are accessing the threadpost class directly which might be why you are not geting post count updates.

Use this instead.

PHP Code:
$threaddm =& datamanager_init('Thread_FirstPost'$vbulletinERRTYPE_ARRAY'threadpost'); 
Also, when starting a new thread you should not be passing the forum id, you shoud be passing the foruminfo array.
PHP Code:
$forumid 2//Or however you are ariving at that.
$foruminfo fetch_foruminfo($forumid); 
And then in your datamanager instance use setinfo not set, as follows.

PHP Code:
$threaddm->set_info('forum'$foruminfo);
$threaddm->set_info('thread'$threadinfo); 
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 10:19 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.04467 seconds
  • Memory Usage 2,296KB
  • 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
  • (3)bbcode_code
  • (8)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete