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 02-10-2008, 02:41 AM
AngelBlue AngelBlue is offline
 
Join Date: Jun 2007
Posts: 125
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default php/sql : get number X, remove X points of rep from single person

Here's what I want to do:

(1) Delete all reputation scorings where a reason was not provided.

I think the SQL for this is : "'DELETE from '.TABLE_PREFIX.'reputation where reason = \'\';'".

(2) Remove the deleted scores from those peoples reputations. e.g. if they had a total of +2 reputation points from scores with no reason, after those scores were deleted, they should lose two points of rep on the display.

I think I might have to do a "SELECT reputationid,postid,score from '.TABLE_PREFIX.'reputation where reason = \'\';" first, to get the IDs of the posts. Then another query to find out who owns the posts. Then a third query to remove those scores from those users.
All this in a for loop for each score without a reason.


Please tell me there is an easier way?
For example : a way for the forum to notice those records were deleted, and to update the user's score accordingly without me manually having to rebuild the reputation records for every user... or even that specific person by hand?

I have tried requiring people to enter a reason when they give rep. That doesn't work, they just enter junk as the reason, and my forum is too big for me to review all the rep by hand.
I have tried altering the reputation.php code so that any rep given with no reason is automatically assigned a score/power of 0, no matter what score the sender intended.
To do that, edit reputation.php, find :
PHP Code:
$userdata->pre_save(); 
add after :
PHP Code:
       if (empty($vbulletin->GPC['reason'])) {
                
$score=0;
        } 
Unfortunately, that solution doesn't work either. Users get wise to it after a short period of time.

So, my current solution is to let them post rep with no reason, and let the rep stick around for a week, but then to use a cron task to delete that rep from the person who got it, in effect reversing it automatically. Thing is I'm not sure that this method will actually decrease the rep count in the user table. So yeah, any help would be appreciated.
Reply With Quote
  #2  
Old 02-10-2008, 10:40 PM
Eikinskjaldi's Avatar
Eikinskjaldi Eikinskjaldi is offline
 
Join Date: Feb 2006
Location: Hell, never looked better
Posts: 572
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In admincp there is a rebuild reputation option, you could follow the code and see what functions are called to do that

Alternatively you could set up a trigger that deletes from the total when an entry in reputation is deleted.
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:17 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.03742 seconds
  • Memory Usage 2,171KB
  • 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_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (2)post_thanks_box
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit_info
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)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