[ABD] Topic Points 0.6.4 (MMW) (Updated 2006-11-20)

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
Locked
User avatar
drathbun
Former Team Member
Posts: 12204
Joined: Thu Jun 06, 2002 3:51 pm
Location: TOPICS_TABLE
Contact:

[ABD] Topic Points 0.6.4 (MMW) (Updated 2006-11-20)

Post by drathbun » Fri Jul 21, 2006 12:15 pm

MOD Title: Topic Points
MOD Description: Allows board members to rate a topic (-1, 0, +1)
MOD Version: 0.6.4 (BETA)

MOD Download: Download 0.6.4 zip
Last Code Update: 2006-11-20

Before downloading and using the code at the link above, be sure to understand the following:

There will be NO UPGRADE from the current version (0.6.4 BETA) to any subsequent version. The MOD has had basic functionality verified on my test board, but there is no guarantee that I have captured all of the MOD install instructions accurately or completely. USE AT YOUR OWN RISK.

Again, I repeat, there will be NO UPGRADE from this version to ANY following version. If you are not comfortable with that situation, then please do not download or install this MOD. I'm releasing the code now to give folks the opportunity to try it out, and to ask for help in verifying that I have captured all of the required installation steps.

Thanks.

**** Update Notes Nov 20, 2006 ****
I discovered a security issue with this MOD that would allow users to rate topics that they did not have access to view, or even rate topics that did not exist. That has been fixed in 0.6.4 and I would encourage everyone that has tested this MOD to download the update.

Updates include:
  • New search on the index: Show Top "n" Rated Topics, here "n" is a parameter set in the ACP. If the parameter is not set it defaults to 10.
  • Fixed topicpoints so that data passed on the URL is not only sanitized but validated. Users can no longer hack the URL to vote for topics they can't see, vote for topics that don't exist, vote for topics despite forum permissions, or vote for topics even when topic points have been disabled via the ACP.
  • Code now checks for "auth" status before displaying topics that a user has rated. So if a user has rated a topic in a private forum, and you don't have access to view that private forum, you won't see the topic title (or the rating) on the user list. I still need to fix the user profile view, but viewpoints.php has been updated.

Original MOD Post
This MOD will allow board members to rate a topic with a "thumbs up" or "thumbs down" style of rating. I will provide a basic graphic with the MOD download. I understand that thumbs up/down may be offensive in some cultures, so you're on your own to create different graphics if that's the case.

What this MOD does:
  • Logged in members will be able to rate a topic up or down
  • Logged in members will be allowed to change their rating
  • Admins / Mods can view who rated a topic and how they rated
  • Admins / Mods can remove a rating. Note that I will not be providing a way for Admins / Mods to edit a rating. I don't believe that's appropriate, you can remove it but you may not alter a user's rating.
  • Optionally see a graphic that represents a relative rating of the topic
What this MOD might do in the future:
  • Weight search results by topic points
  • Other features as suggested
What this MOD will not do, ever. :-)
  • Allow users to rate posts, it's for topics only
  • Allow users to rate users, that's "karma" and that's a different MOD
I have written this MOD for one of my own boards, so it should be a fairly quick write-up to get to BETA status. Screen shots coming shortly.
Last edited by drathbun on Tue Nov 21, 2006 5:17 am, edited 6 times in total.
I blog about phpBB: phpBBDoctor blog
Still using phpbb2? So am I! Click below for details
Image

User avatar
drathbun
Former Team Member
Posts: 12204
Joined: Thu Jun 06, 2002 3:51 pm
Location: TOPICS_TABLE
Contact:

Post by drathbun » Fri Jul 21, 2006 12:15 pm

The following screen shots are from one of my boards that currently uses what will become the baseline code for this MOD. On this board, points are always positive, never negative. The MOD as released here will provide + and - points.

viewforum.php
The viewforum page will include (optionally) an extra column that displays the relative points rank. I envision having the graphics I already have for subSilver "positive" ranks. I will do something inverted, or perhaps red, for negative point ranks. This step will be optional, and will include the display on viewforum and search results. The mouse-over "tool tip" will provide the exact point / rating value for the topic, the graphic is used to show a relative rating, not an exact number.
Image

viewtopic.php
While viewing a topic a user will be notified as to the total rating of the topic. Note that in the screen shot below the rating mentions the number of points. The MOD will allow the points to be positive or negative. If no points have been assigned, this text is not displayed. If points are assigned but the net (+/-) is zero then this text will be displayed. The text for the MOD as released here will be different, it will say something like "This topic has an overall rating of X provided by Y members." That way you can tell the difference between a topic that has a zero rating with 2 users and a topic with a rating of zero with 50 users.
Image

Finally, here are the graphics that will be used and included within the MOD. While coding this MOD I tried to come up with a graphical way to show the topic points on the viewforum and search pages, and I was watching TV and saw one of those cell phone company advertisements where they brag about their signal strength. I figured most everyone is familiar with the "signal bars" on their phone, and it seemed like a workable idea. You're free to come up with your own graphics, of course.

Admins will be able to specify the break points on the points, meaning when does a topic change from the first graphic (no points) to the second (1 point) to the third (5 points) and so on. Here's a screen shot of that admin page (now completed)

Image

All of the graphics above will probably work for subSilver or similar light themes. They will not work for darker themes. I do not have the graphics skills or the time to develop alternate graphics, but I will happily host any graphics sets provided once the topic is released and in the MOD-DB.

As mentioned later in this topic, the following rating icons are no longer used...
Image Image

Here's a screen shot showing the admin page, this is an update to the forum insert / edit screen where it shows the board admin can activate topic ratings on a forum by forum basis:

Image
Last edited by drathbun on Sun Jul 23, 2006 5:49 am, edited 1 time in total.
I blog about phpBB: phpBBDoctor blog
Still using phpbb2? So am I! Click below for details
Image

gamerxgirl
Registered User
Posts: 379
Joined: Tue Feb 22, 2005 4:13 pm

Post by gamerxgirl » Fri Jul 21, 2006 2:52 pm

Sounds great! Can't wait to see what you come up :) I'll be sure to keep checking this out.

User avatar
kber
Registered User
Posts: 986
Joined: Sun May 07, 2006 9:22 am
Location: Egypt
Contact:

Post by kber » Fri Jul 21, 2006 4:19 pm

seems 2 be a very helpfull mod
waiting 4 it :D

User avatar
*=Matt=*
Registered User
Posts: 389
Joined: Mon Dec 20, 2004 11:56 pm
Location: Oakdale, Wisconsin

Post by *=Matt=* » Fri Jul 21, 2006 5:54 pm

Just an idea for you drathbun. Maybe have like umm a max topic rating a day so users of the forum can't just rate topics after topics. Instead just have like a max of like 10 topics in an hour or something like that.

mattlilly
Registered User
Posts: 13
Joined: Mon Jan 02, 2006 8:06 am
Location: USA

Post by mattlilly » Fri Jul 21, 2006 5:59 pm

I am looking forward to this mod. But, maybe only allow certain forums to have this rating. For my particular site, only 2 out of 13 of the forums would benefit from such a mod. Thanks.

mattlilly
Registered User
Posts: 13
Joined: Mon Jan 02, 2006 8:06 am
Location: USA

Post by mattlilly » Fri Jul 21, 2006 6:01 pm

*=Matt=* wrote: Just an idea for you drathbun. Maybe have like umm a max topic rating a day so users of the forum can't just rate topics after topics. Instead just have like a max of like 10 topics in an hour or something like that.


If you do this, maybe have it as an option to allow the user to rate as many topics as they want. I dont care if they rate over and over as long as the same person doesnt rate the same topic more then once.

User avatar
drathbun
Former Team Member
Posts: 12204
Joined: Thu Jun 06, 2002 3:51 pm
Location: TOPICS_TABLE
Contact:

Post by drathbun » Fri Jul 21, 2006 9:37 pm

*=Matt=* wrote: Just an idea for you drathbun. Maybe have like umm a max topic rating a day so users of the forum can't just rate topics after topics. Instead just have like a max of like 10 topics in an hour or something like that.

Hmm, okay. I'll think about that. To be clear, each person will be able to rate a topic once and exactly once. So you won't have a "spam" effect of someone rating the same topic 20 different times. To be honest, do you really think someone will go through the board just rating topics?

I'll have to think about whether the added complexity is worth the code. Your point it taken, but I really don't see where it's an issue. If someone wants to rate topics, why is that a problem? In order to put in a flood control, I have to add a date/time to each topic rating, and then every time someone wants to rate a topic I have to count how many topics they've rated in the past 24 hours. I'm not sure the added complexity and overhead is worth it. I'll think about it, but it was not in my original plan. We'll see. :-)
mattlilly wrote: I am looking forward to this mod. But, maybe only allow certain forums to have this rating. For my particular site, only 2 out of 13 of the forums would benefit from such a mod. Thanks.

There's another good idea, and this one has a better chance of making it into the specification. One challenge, though, is how to handle moved topics. If you move a topic into a forum where ratings are not allowed, what happens to existing ratings? I'll have to think about it. It's easy enough to implement the forum by forum activation of the feature, I've done plenty of MODs that use that technique. I think this idea will be included.
mattlilly wrote:
*=Matt=* wrote:Just an idea for you drathbun. Maybe have like umm a max topic rating a day so users of the forum can't just rate topics after topics. Instead just have like a max of like 10 topics in an hour or something like that.


If you do this, maybe have it as an option to allow the user to rate as many topics as they want. I dont care if they rate over and over as long as the same person doesnt rate the same topic more then once.

A user can rate a topic exactly once. And at their option, they may change or remove their rating. That's the way I intend to have it work. :-)

Thanks, everyone, for the ideas. Now is the best time to get them in before I do too much coding. ;-)
I blog about phpBB: phpBBDoctor blog
Still using phpbb2? So am I! Click below for details
Image

Prince of phpbb
Registered User
Posts: 286
Joined: Mon Jun 13, 2005 12:29 pm
Location: UK
Contact:

Post by Prince of phpbb » Sat Jul 22, 2006 1:03 am

Just one word .. 'awesome' :lol: keep up the good work .. we do badly need a rating MOD ..
just a tiny suggestion .. from the screen shots the topics have to be rated from viewforum .. it would be nice to have a topic being rated from viewtopic .. so users can rate it after reading it without having to go back to viewforum

other than that I find it great :wink:

pierro78
Registered User
Posts: 58
Joined: Thu Aug 29, 2002 9:09 am
Contact:

Post by pierro78 » Sat Jul 22, 2006 2:07 am

My "Feeds and Discussions over Feeds" mod allows users to discuss on a list of "favorite web pages"
(example : http://clipmarks.com/clipmark/3F7F0883- ... 9CF995BF2/ )
With this "topic ratings" mod phpbb will have about the same functionalities as digg ;-) ...
Last edited by pierro78 on Sat Jul 22, 2006 2:40 am, edited 1 time in total.

User avatar
igorw
Former Team Member
Posts: 8024
Joined: Fri Dec 16, 2005 12:23 pm
Location: {postrow.POSTER_FROM}
Name: Igor Wiedler

Post by igorw » Sat Jul 22, 2006 2:17 am

I know they won't, but phpBB.com should add this. Then we wouldn't have so many Polls in the MOD release forums, but some nice topic ratings in viewforum :)

This is a cool MOD! Thanks a lot drathbun/dave :)
Igor Wiedler | area51 | GitHub | trashbin | Formerly known as evil less than three

deny
Registered User
Posts: 565
Joined: Wed May 14, 2003 9:14 am
Location: Find-Ip-Address.org
Contact:

Post by deny » Sat Jul 22, 2006 4:47 am

Just one suggestion.Try to keep number of queries on viewforum and viewtopic to the minimum.
I know from past some interesting similair mods that add sometimes 10 (if they are more replies inside viewtopic then count one query per member) and in worst cases 30 queries (where 1 query count for each thread in viewforum).
Apart from that not extra suggestions.It looks interesting.Just do not understand why option to revoke voting.
If someone voted once i do not see any reason why option to change or remove own rating later.One done is done.Maybe as alternativ give a adjustable time for changing voting (1h for example )
Geolocation of any IP address including detection of hostname,
browser, country and country code with ip address range web tool.

IP Address Locator | Email Tracking | IP Address | Check Email

User avatar
drathbun
Former Team Member
Posts: 12204
Joined: Thu Jun 06, 2002 3:51 pm
Location: TOPICS_TABLE
Contact:

Post by drathbun » Sat Jul 22, 2006 1:55 pm

@prince, the rating is performed in viewtopic. It would not - in my opinion - make sense to perform the rating on viewforum as you might not have read the topic. The rating is (optionally) displayed on viewforum so you get an idea of the rating (points) for the topic before you read it, but nothing is set there.

@deny, the code as I have written it for my own adds zero new queries to the page for guests, and one new query for registered users only. Is that okay? :lol: Anyone that adds 30 queries to a page deserves to be flogged with a wet noodle. ;-)

I accomplish this task by storing the total topic rating right on the topic table itself. Strictly speaking this is not the best database design as it (the net topic rating) could get out of sync from the actual ratings, depending on how reliable or overloaded your database is. I will provide a "resync" option for admins to fix this. So when a guest views the topic, I'll simply be retrieving the net rating.

Now when a logged in user views a topic, I will need to run one query to see if they have rated the topic so I can build the page links accordingly. Think of the way the "watched topic" code works. If you are watching the topic, the link says "Stop watching". If you are not watching, it says "Start watching". That takes one extra query, but only for registered users. Something similar happens here.

There are, of course, additional queries that are executed during the actual rating process. One will either insert / update the topic rating for the specific user, and the other will reset (increment / decrement) the total topic rating on the topic table.

Remember this is a topic rating, not a post or user rating.
I blog about phpBB: phpBBDoctor blog
Still using phpbb2? So am I! Click below for details
Image

User avatar
drathbun
Former Team Member
Posts: 12204
Joined: Thu Jun 06, 2002 3:51 pm
Location: TOPICS_TABLE
Contact:

Post by drathbun » Sat Jul 22, 2006 1:59 pm

I went back and looked at the screen shots, and I realize where the confusion as to where the rating is performed might be coming from. I did not provide a screen shot of the actual "rating screen" yet, as I don't intend to do it here the way I did it on my board.

For my rating topic, I decided that (for my board) you get to provide only positive ratings. You either like a topic, or you don't. If you don't, you don't rate it. So for my board the rating process is simple, you click a "thumbs up" icon and the topic gets a point. Click it again, and you remove your rating. So it's a binary setting.

I don't think I can make that same decision for every other board owner out there. :-) So the rating as will be released here will allow + and - ratings, so the interface will be different. I am still thinking about how to apply the ratings (meaning what the interface looks like). Once I get some ideas I will post them for feedback.

But it will definitely be done on the viewtopic page. viewforum and search results will (optionally) display the ratings, but you have to view the topic to rate it, or to change your rating. Does that help?
I blog about phpBB: phpBBDoctor blog
Still using phpbb2? So am I! Click below for details
Image

User avatar
drathbun
Former Team Member
Posts: 12204
Joined: Thu Jun 06, 2002 3:51 pm
Location: TOPICS_TABLE
Contact:

Post by drathbun » Sat Jul 22, 2006 2:04 pm

Another follow-up per deny's question about query count... the viewforum and search pages add zero queries, for guests and registered users. That's again because I will be storing the net "total" topic rating on the topics table. If I didn't do that (for efficiency) then you would either have to run one extra query (get all topic ratings for those topics on the page) or join to the topic ratings table (which would have to be an outer join, which is less efficient) or - yes, if you were not optimizing your code - you could run one query per topic that's displayed. That's the worst possible case, and it's not what I do. 8)

I'm a database consultant in "real life". I might be an average php-coder, but I do know databases. 8)
I blog about phpBB: phpBBDoctor blog
Still using phpbb2? So am I! Click below for details
Image

Locked

Return to “[2.0.x] MODs in Development”