Thread Rating:
  • 14 Vote(s) - 3.86 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[For 1.6] Thumbs Post Rating 1.3
(haven't bothered reading posts in this thread)

Hi there,
Firstly, thanks for creating and releasing this plugin tyyew.
I've been interested in adding something like this to my forum, however this isn't quite up to my personal standards. Rather than roll my own version of this plugin, I thought I'd update this and submit my changes to the official version (thanks for releasing this as GPL!) in the hopes that it may help at least someone else.
You also mentioned that you're new to PHP in your first post (from your coding style I'm guessing you've come from another language?) so maybe this might give you some ideas of what I think there.
If you want, feel free to take all/some/none of the changes I've put through. If you do like it though, it would be nice if you could credit me, but I don't mind if you don't want to. I've done quite a bit of changes, so maybe I've gone a little overboard (I'm somewhat a perfectionist), so don't be afraid to criticise, or question any changes made. I'm also happy to explain any part you don't quite understand (I don't visit these forums often though, so it might be a while before I respond).
If you don't want to take the changes in, I'll probably release my version as a fork.

Note that almost all of the changes made are "behind the scenes" - that is, the casual admin probably won't notice any difference.

Also note, for anyone wishing to try this code, there is no "upgrade path" to this version. If I feel like it, I could write an upgrade script, but as of now, if you've already installed the official version, installing this version requires you to uninstall your current copy, before uploading this new version.

I've made the changes using Git, so you can see every single commit I've made. Download and list of commits can be found here:

Here's a summary of the main changes

New Features
  • Option to allow users to update their rating of a post

Security Enhancements
  • Remove SQL injection vulnerability
  • Protect against CSRF attacks
  • Proper settings checks on rating submission (current possible, in official code, to do stuff like rating own posts (even if option is disabled), or rating in forums which are disabled etc, through request forging)
  • Ensure a valid pid is sent through on request, and also check for post visibility (eg, a non-moderator cannot rate an unapproved post) as well as forum permissions (eg trying to rate a post in a forum not visible to the user)

Performance Enhancements
  • No longer queries every time postbit is built - now uses a single cached query
  • Load language only once in showthread
  • Cache forum exclusion checks as well as usergroup permission checks
  • Faster installation (merged ALTER TABLE queries) + set_time_limit call to aid installation on bigger forums
  • Merge the thumbs up and thumbs down image into one (slightly less HTTP request overhead) + optimise PNG
  • The included .js and .css files are no longer loaded on every page - now only loaded on showthread
  • Add appropriate indexes to thumbspostrating table

Bug Fixes
  • Take into consideration user's secondary usergroups when considering the permission
  • Hard code block against guest rating (it won't work with your table setup)
  • The thread table's "thumbsup" and "thumbsdown" fields are now incremented properly via SQL (as opposed to PHP) to prevent issues with race conditions
  • Calculation of new rating after submission is done server side (more accurate), not client side

Other Enhancements/Tweaks
  • Post rating will now work with Javascript disabled
  • Disable post rating to non-moderators if thread is closed.
  • Delete rating records on thread/post delete
  • Disable rating functionality immediately after the user clicks it to prevent a double-click issue
  • Disable AJAX if MyBB's disable xmlhttp setting is set
  • Add/removing settings is now done in install/uninstall, rather than activate/deactivate
  • The thumbs HTML code has been exported to a template
  • Use $db->write_query for write queries
  • Remove unnecessary separation of up/down variables
  • Better support error conditions in AJAX submission
  • Various code simplifications
  • Redesigned the thumbspostrating SQL table

Hope this helps, and thanks again for your plugin.
I was planning to update the codes in few weeks time. And all of your feedback will definitely helped me a lot in the next release.

Special thanks to Yumi for all the changes you have made, I will definitely look into it and implement it in my next release (probably few weeks later).

I do appreciate your feedback as you have taught me a lot and contributed a better mod for the MyBB community. Shy
Where do i find the code to change it about so i can move it around in the post and place i where i want?
(2011-04-21, 10:15 PM)Doctors Companion Wrote: Where do i find the code to change it about so i can move it around in the post and place i where i want?

move the <div class="float_right">{$post['tprdsp']}</div> code in the postbit template.
but how can make it just for the first post ? not all replace... just be for the main or first post ?!
I have the same question so far. So any help would be very appreciated.

Also, I'm having some troubles with the position of the button:

That image shows where it's positioned, but instead, I'd like it to be displayed like this:

I tried inserting the
tag before the
one, but the result it's just the same.

Can you help us?

(if this isn't the right thread to ask for help, then excuse me please and just say it, so I'll post it in the right one)
^ If you're using my version of the code, edit your postbit_tpr template and remove "float_right"
I'm a bit confused as to what this plugin adds to. When a person thumbs up a person's post, does anything happen besides the post being +1'd?

I mean, does the post get featured, add to rep, or is it merely a showing of approval/disapproval form the community?
(2011-04-30, 06:14 PM)tgh Wrote: or is it merely a showing of approval/disapproval form the community?
(2011-04-30, 11:56 PM)Yumi Wrote: That

Exactly. Which is why I love this plugin, because it's totally different from giving a user reputation.

Reputation is a way to say "Hey, this post reminds me why you are a good member here!"

Whereas, the thumbs rating post is a way of saying "Hey, look everybody! I found a really GOOD or really BAD post!"

Two totally different contributions to a forum!

I'm excited to implement a future version of this once some of the bugs are worked out.
Click here to visit Time 2 Mobilize . Org and help your fellow citizens!

Forum Jump:

Users browsing this thread: 1 Guest(s)