vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Update Post/Thread Count with DataManager (https://vborg.vbsupport.ru/showthread.php?t=120781)

maximux1 07-10-2006 01:13 AM

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

Code Monkey 07-10-2006 02:32 AM

PHP Code:

build_forum_counters($foruminfo['forumid']); 


maximux1 07-10-2006 03:07 AM

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

Code Monkey 07-10-2006 03:29 AM

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']); 


maximux1 07-10-2006 03:32 PM

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

CyberRanger 07-10-2006 05:24 PM

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.

maximux1 07-10-2006 08:20 PM

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

I appreciate your help!

Code Monkey 07-11-2006 01:59 AM

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/

maximux1 07-11-2006 02:02 AM

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

Thanks for pointing out the link.

Code Monkey 07-11-2006 02:03 AM

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); 



All times are GMT. The time now is 10:03 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.01170 seconds
  • Memory Usage 1,775KB
  • 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
  • (3)bbcode_code_printable
  • (8)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (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