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 06-08-2009, 07:29 AM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to decrease count in database automatically?

Hi all,
Currently i have two plug-ins to count "Top Tips" that are submitted by a form to a specific forum, every member of my forums has a "My Top Tips" count in their info bar along with a button to submit more if they wish.

My problem is they can submit a tip and the count increases fine, so mine shows 5, joe bloggs will show 3....etc however if the post is deleted the figure doesn't decrease and i have to go to the database and change the count manually, can anyone tweak my plugins to do this automatic please?

Quote:
Originally Posted by 1st plugin:
PRODUCT: VBulletin
HOOK LOCATION: postbit_display_start
EXECUTION ORDER: 5
PHP Code:
eval('$template_hook[postbit_userinfo_right] .= " ' fetch_template('postbit_ctoptip') . '";'); 
Quote:
Originally Posted by 2nd plugin
PRODUCT: VBulletin
HOOK LOCATION: newthread_post_complete
EXECUTION ORDER: 5
PHP Code:
if (in_array($foruminfo['forumid'], array('52'))) { 
    
$db->query_write("UPDATE vb_user SET ctoptip = ctoptip + 1 WHERE userid=" $vbulletin->userinfo['userid']); 

and this is the content of the template postbit_ctoptip
PHP Code:
<if condition="$post['ctoptip']>= '1'">$post[ctoptipTop Tips<br /></if> 
Reply With Quote
  #2  
Old 06-08-2009, 03:45 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You'll need to add a plugin that is called when the post is deleted and then change the count there. When in debug mode, go to delete a post and all the hook locations that are available on that page will be listed on the bottom of the page.
Reply With Quote
  #3  
Old 06-08-2009, 04:09 PM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
You'll need to add a plugin that is called when the post is deleted and then change the count there. When in debug mode, go to delete a post and all the hook locations that are available on that page will be listed on the bottom of the page.
Lynne how do i set vbulletin in debug mode?
Reply With Quote
  #4  
Old 06-08-2009, 04:28 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Add this at the top of your config.php file right under <?php :
HTML Code:
    $config['Misc']['debug'] = true;
I would suggest only doing this on your test site, or putting a condition around that to only show it to your IP.
Reply With Quote
  #5  
Old 06-08-2009, 04:38 PM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
Add this at the top of your config.php file right under <?php :
HTML Code:
    $config['Misc']['debug'] = true;
I would suggest only doing this on your test site, or putting a condition around that to only show it to your IP.
Thanks for that, i don't have a test site and i think it will be ok as it will only be for a few minutes

--------------- Added [DATE]1244483578[/DATE] at [TIME]1244483578[/TIME] ---------------

Lynne, could you tell me which hook i should use for the plugin?
Hooks Called:
init_startup
fetch_userinfo_query

style_fetch
cache_templates
global_start
parse_templates

notifications_list
global_setup_complete

I have this line to remove from the count:
PHP Code:
 if (in_array($foruminfo['forumid'], array('52'))) {  
    
$db->query_write("UPDATE vb_user SET ctoptip = ctoptip -1 WHERE userid=" $vbulletin->userinfo['userid'] . " and ctoptip > 0"); 
--------------- Added [DATE]1244485448[/DATE] at [TIME]1244485448[/TIME] ---------------

The above were the hooks called prior to me choosing soft or permanent delete!
Reply With Quote
  #6  
Old 06-09-2009, 04:49 PM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lynne any thoughts with this?
Reply With Quote
  #7  
Old 06-09-2009, 05:04 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What script is it you are calling to delete the post? Are you talking about a user deleting it or a mod deleting it? Both of those are different scripts. You'll have different hooks called for each. If a user is doing it in the post, perhaps an editpost_ hook. Go see where those are and if one of them makes sense to use (do a search through your files for "editpost_"). If it's the Moderator dropdown box (so a moderator), then that takes you to the inlinemoderation.php page. Take a look at that page for which hooks are used.
Reply With Quote
  #8  
Old 06-09-2009, 05:21 PM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
What script is it you are calling to delete the post? Are you talking about a user deleting it or a mod deleting it? Both of those are different scripts. You'll have different hooks called for each. If a user is doing it in the post, perhaps an editpost_ hook. Go see where those are and if one of them makes sense to use (do a search through your files for "editpost_"). If it's the Thread Tools (so a moderator), then that takes you to the inlinemoderation.php page. Take a look at that page for which hooks are used.
Its when a mod or admin deletes the post.....users do not hav ethe permissions to delete. If your sure its an editpost_...etc hook i'll try a few of them until it works
Thanks!

--------------- Added [DATE]1244572968[/DATE] at [TIME]1244572968[/TIME] ---------------

im going to try this hook: inlinemod_deletethread

--------------- Added [DATE]1244573206[/DATE] at [TIME]1244573206[/TIME] ---------------

It didnt work with the plugin code but didn't cause an error
Reply With Quote
  #9  
Old 06-09-2009, 08:17 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What did you put in the inlinemod_deletethread plugin? Did you find that hook location in the code and verify the variables you are using are correct? (And I thought you were deleting a post, not a thread.)
Reply With Quote
  #10  
Old 06-10-2009, 07:02 PM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi Lynne, the post/thread will be un answerable the thread is created by a form, users do not have permission to reply or post, so in effect im deleting the thread, im using this in the plugin
PHP Code:
if (in_array($foruminfo['forumid'], array('52'))) {   
    
$db->query_write("UPDATE vb_user SET ctoptip = ctoptip -1 WHERE userid=" $vbulletin->userinfo['userid'] . " and ctoptip > 0"); 
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 11:16 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07947 seconds
  • Memory Usage 2,277KB
  • 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
  • (2)bbcode_html
  • (5)bbcode_php
  • (5)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_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