[ABD] Topic and Post Rating Mod

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.
enginemike
Registered User
Posts: 162
Joined: Thu Oct 20, 2005 7:35 am

[ABD] Topic and Post Rating Mod

Post by enginemike »

PROJECT UPDATE 11/03/07

Project Purpose:

This is a modification to phpBB V2.0.22.

This modification adds the functionality to rate topics and posts to the phpBB forum software.

Version 0.0.3 - revised 10/31/07

This modification has been updated based on review comments.
Changes are:
11/03/07
1. Corrected typographical errors in the mod file

2. Added screen shots

10/31/07
1. Input has been secured via use of the intval() and floatval() functions

2. The earned credits display functionality has been improved. Details can be found in the mod file

3. Two new fields have been added to the database to enhance the capability to use this mod with other
mods that may wish to make use of the user earned credits. Details can be found in the mod file

Download

If you have previously downloaded this mod (rate002.zip) please download the new version identified in the following link:

http://www.kometkommunications.com/projects/rate003.zip

Screenshots
http://www.kometkommunications.com/proj ... _shots.htm

Project Description:

The modification provides the capability for a User to rate a Topic or Post. A User must be logged in to submit a Topic or Post rating. A User may rate any given Topic or Post only once.

The rating submission values range from 1 to 5. A graphic associated with the Topic or Post provides a visual indication of the accumulated rating score; the accumulated rating score is an average of all submitted rating scores.

When a Topic or Post is rated the both the Initiator and the Submitter receive credit points. The points are stored in the database. Accumulated points are accessible for use by other MODS.

When a Topic or Post is originated the Originator can receive credit points. The ability to select or de-select the capability to receive credit points is provided to the System Administrator via the ACP. Accumulated points are accessible for use by other MODS.

The ability to select or de-select the capability to rate Topics and Posts is provided to the System Administrator via the ACP. The System Administrator may select or deselect the ability to rate Topics and Posts at any time. The ability to rate topics and posts are independent of each other; Topics, Posts, both, or none may be selected. Selection or de-selection does not impact previous rating activity or point accumulation.

The ability to assign a credit point value is provided to the System Administrator via the ACP. Credit point values range from 1 to 5. The capability to assign a fractional value is provided. The fractional value ranges from 0.1 to 1.0 for Topic or Post rating submissions and 0.0 to 1.0 for Topic or Post origination submissions. Use of the fractional value allows a wide range of credit point possibilities. The point and fractional values may be revised at any time. Revision of credit point value assignments does not impact previous point accumulation.

The ability to assign a minimum number of posts required to rate a topic or post is provided to the System Administrator via the ACP. The default value is zero.

Points accumulated by/available to the User may be displayed on the Membership and Member Profile pages. The capability to select or de-select the display of user’s accumulated points is provided to the System Administrator via the ACP. Selection or de-selection does not impact previous rating activity or point accumulation.

When a User is deleted information related specifically to the User is removed from the database. The rating scores for Topics and Posts are retained to preclude skewing existing rating scores.

If a Topic or Post is pruned all rating associated with the Topic or Post is removed from the database. Credit points earned by Users for posting or rating submissions are retained.
Last edited by enginemike on Sun Nov 04, 2007 4:30 pm, edited 3 times in total.
User avatar
tokyojihen
Registered User
Posts: 7
Joined: Fri Sep 14, 2007 1:37 pm

Re: [BETA] Topic and Post Rating Mod

Post by tokyojihen »

Is this works with easyMOD? and do u have any screenshots or demo forum?
enginemike
Registered User
Posts: 162
Joined: Thu Oct 20, 2005 7:35 am

Re: [BETA] Topic and Post Rating Mod

Post by enginemike »

I do not know about easymod. I might have to look into it; I have never used it and suspect that some of my comments my gum up the works; there are a couple of spots in posting.php where adding the new code is a bit tricky. I will take a look.

Regarding screen shots I will post some this evening.
otpuser
Registered User
Posts: 7
Joined: Wed Sep 26, 2007 8:58 pm

Re: [BETA] Topic and Post Rating Mod

Post by otpuser »

I tried installing it with EasyMod and it failed. Not to say that with a few tweeks in might work--but I went ahead and manually installed it. It is running, but I cannot get to the configuration settings--they are not displaying in the AP. I assume they should be appearing under the forum admin, but maybe thats wrong. I havw double checked the code mods.

So far this looks like it will do the trick for what I need to do with posting ratings, can't wait to really test it out. I will keep troubleshooting but could use some suggestions...

Thanks for all the heard work--this looks really good.
enginemike
Registered User
Posts: 162
Joined: Thu Oct 20, 2005 7:35 am

Re: [BETA] Topic and Post Rating Mod

Post by enginemike »

Thanks for the input!

I have never used easymod but suppose I should look into it. Not sure if is is a condition for validation. Any error information or observations you can pass on will be helpful. Some of the stuff that goes into the posting.php and functions_posting.php can be a bit tricky. There are some places where I had to insert conditonals within existing condtionals and it's easy to miss a bracket (or two) :shock:

Not sure I understand what you mean by the problems with configuration settings. Are you refering the option selection that shows up on the ACP? Again any detail you can provide would be really helpful. If you can provide some additional detail I can think it thru and see if I can provide some suggestions.

I am on travel this week so cannot get back to the project code until the weekend.

Anyway, I am really glad that you are looking at it and may find it useful. I'm really looking forward to any comments and suggestions you might have once it is up and running. I'm sure there is room for improvement. I would like to have some folks look the thing over before I submit it for validation.
otpuser
Registered User
Posts: 7
Joined: Wed Sep 26, 2007 8:58 pm

Re: [BETA] Topic and Post Rating Mod

Post by otpuser »

I am prototyping my own site that is going to include a bbs. I like phpbb, and with your mod I think It is exaclty the ticket, especially with the points for users--so I am glad to help--it is OK if we find things along the way as my other development work on my site will need a good workout for awhile also.

My question is this: Your project description describes the ability to select or deselect the use of the credit points option, capability to use topics & posts, etc, as option settings in the ACP, along with a lot of other admin type settings. When I log into the phpbb admin control panel, I have the oroginal screens and options--there are no new options for the rating mod.

I re checked the code mods again and it seems to be OK. Is it possible that some initial database values might have some affect on the display of the options in the ACP? Since I am new to phpbb, I am not sure which php modules to look at again to see if there is a problem with my code inserts. Originally I had a few errors but that was exactly what you mentioned, my insert being a bracket or a semicolon "off".

Also, I had forgot to copy in the post_rate_body.cpl and had not placed the graphics files in the correct folder path the first time, but got that fixed.

Anyway, let me know if you need further details. I will keep plugging away at it as well...

Thanks!
enginemike
Registered User
Posts: 162
Joined: Thu Oct 20, 2005 7:35 am

Re: [BETA] Topic and Post Rating Mod

Post by enginemike »

I downloaded the mod package to check it out and make sure I did not mess it up.

Regarding the ACP

The database config file needs to be updated. The queries can be found on lines 116 thru 124 of the mod file

There are two files that need to be edited for the acp.

The first is admin_board.php. The mode code can be found at line 294 in the mod file

The second file is board_config.tpl and can be found at line 1160 in the mod

If you get this bit the control features should show up.

When you open the ACP you should find a new section added on the configuration page. This is where you can control all the options.
otpuser
Registered User
Posts: 7
Joined: Wed Sep 26, 2007 8:58 pm

Re: [BETA] Topic and Post Rating Mod

Post by otpuser »

I re-checked the two files per your direction. I had all the code there, but I decided to re-ftp the files up to the server again, and I now have the new section on the configuration page. I think it might have been an FTP snafu. Thanks for the quick responses. I will do some testing and drop a note to you with an update.
otpuser
Registered User
Posts: 7
Joined: Wed Sep 26, 2007 8:58 pm

Re: [BETA] Topic and Post Rating Mod

Post by otpuser »

I have encountered a problem with the mod to memberlist_body.tpl. When I use the modified file, the following error appears when displaying the member list:

Parse error: syntax error, unexpected '}' in /public_html/bb/includes/template.php(127) : eval()'d code on line 53

If I put back the original file it displays the list (but without the ratings of course).

I have narrowed it down to this:

<!-- begin KK rating mod -->
<td class="catBottom" colspan="{L_COL_SPAN}" height="28">&nbsp;</td>
<!-- END switch_display_credit_row -->

If I cut out the above mod code--it works without an error (but no credits displayed).

I think it may have something to to with the variable L_COL_SPAN. I traced it through its initialization in memberlist.php, but that code looks OK. I also tried substituting a whole number (5) in place of the variable L_COL_SPAN and it stopped the error, but ended up having some white space written below the lest member entry on the screen, but still no credit values displayed.

Also, when I display user profiles, none of the credit or posting data displays. I have re-checked profile_view_body and usercp_viewprofile.php. But, then again, some of the other variables are not showing uo in the profile either, such as L_JOINED, L_TOTAL_POSTS, and these were previously in the code for profile_view_body.tpl. Is it possible that my config of phpbb is not using that template? This may be my limited understanding of how phpBB works. I am displaying the profile by clicking on "profile" in the header at the top of the screen of an index page. Also, I am displaying the user profile in admin panel by clicking on management under user admin, then pulling up a user with the look up user button.

Any help will be appreciated.
enginemike
Registered User
Posts: 162
Joined: Thu Oct 20, 2005 7:35 am

Re: [BETA] Topic and Post Rating Mod

Post by enginemike »

Good catch.

The first item is caused by an error in the mod file

use this code:

<!-- begin KK rating mod -->
<!-- BEGIN switch_display_credit_row -->
<td class="catBottom" colspan="{L_COL_SPAN}" height="28">&nbsp;</td>
<!-- END switch_display_credit_row -->
<!-- end KK rating mod -->

Note: if the user has no accumulated credit points the displayed value is blank rather than zero; once a user begins to accumulate credit points then the actual credit value wil be displayed. I thought it looked better that way and also seemed most consistent with the orginal phpBB format.

On the second item, give me a bit of time to take a look.
otpuser
Registered User
Posts: 7
Joined: Wed Sep 26, 2007 8:58 pm

Re: [BETA] Topic and Post Rating Mod

Post by otpuser »

Thanks for the quick reply. I replaced the code. I do not have the } error now, but I still do not have credit displayed in the memberlist. The test user has 5 credits in the table (USER_CREDIT). Is there supposed to be an additional column in the table? I am not seeing one.
enginemike
Registered User
Posts: 162
Joined: Thu Oct 20, 2005 7:35 am

Re: [BETA] Topic and Post Rating Mod

Post by enginemike »

I am now going from memory. Unfortunately I will not be able to actually access the code until the weekend.

A couple of things

1. Is there a column to display the credit? I think it's title is "Credit" of all things? You see the column but no value is displayed?

2. You said the user has 5 points. Did you verify that by looking at the record in the database?

3. Can you verify the following code is in the file includes/usercp_viewprofile.php:

//begin KK rating mod
if ($board_config['display_credit'])
{
$template -> assign_block_vars('switch_display_credit', array());
}

$user_credit_points = '';
if ($profiledata['user_credit'] > 0)
{
$user_credit_points = $profiledata['user_credit'];
}
//end KK rating mod

4. On the ACP have you enabled user credit display?

The answers should be valuable in helping to figure this out.
otpuser
Registered User
Posts: 7
Joined: Wed Sep 26, 2007 8:58 pm

Re: [BETA] Topic and Post Rating Mod

Post by otpuser »

I have verified the code in in the file includes/usercp_viewprofile.php.

I have made progress--I decided to delete all the code comments from the inserted code in the tpl files and anywhere code was initializing variables or if they were in an array. I now have credits displaying in member list. Still do not have anything showing in profile.

To answer your question about the five credits, I pulled up the table in MySQL.

I have to go out for awhile, will get back to this later.

We are getting there! I am sure it is something simple...
enginemike
Registered User
Posts: 162
Joined: Thu Oct 20, 2005 7:35 am

Re: [BETA] Topic and Post Rating Mod

Post by enginemike »

I will be unable to respond any more today.

I am really interested in the comments you removed. Which ones? Were they comments whose source is the mod file? I would like to make sure that there is not maybe a comment in the mod file that was causing a problem. There were one or two instances where I had a coding problem apparently caused by comment placement and actually reworked the mod code around comment inclusion (a vanity thing, not a coding thing I suppose...)

Also
<!-- begin KK rating mod --> (as an example)
is a comment

whereas
<!-- BEGIN switch_display_credit --> (as an example)
is code

In case you didn't know
otpuser
Registered User
Posts: 7
Joined: Wed Sep 26, 2007 8:58 pm

Re: [BETA] Topic and Post Rating Mod

Post by otpuser »

Well--that is a good question. I only removed the comments before and after the code inserts in the following cases:

If it was an insert between Variables that were seperated by commas,
If it was inserted in HTML code (TPL files) anywhere it was a table, or if it seemed like the comments could confuse the processing of the code, or
If it was any kind of an in-line insertion.

Since I did not do the changes one at a time (due to time considerations) I can't be specific on which ones actually caused a problem, but I do know that just about any inserts into the TPL files were problematic if I left in the comments. Must have something to do with how the code is read in those files.

Also, I am noticing a difference in behavior of the code going from my "in house" testing server to a real remote webserver--it seems that my local server is more tolerant with PHP code. I need to look at that more also, perhaps a difference in PHP versions or something... Both servers are running Apache, MySQL, etc. Only other thing possibly is that it is something to do with FTP...

At some point you might be interested in what I am developing that needs the rating capabilites, and the credits are important to me too. This is looking very promising, and I am thrilled that you have done this mod.

I appreciate your time on this--I will keep working on other stuff in my project. If I come up with anything more specific I will let you know. When you have some time to look at this let me know.

Regards.
Locked

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