coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 miscellaneous => Topic started by: lurkalot on February 01, 2009, 01:38:14 PM

Title: Edit Rating within 5 minutes.
Post by: lurkalot on February 01, 2009, 01:38:14 PM
Hi guys,

Had one or two members clicking the wrong rating for the pics, and then can't change their minds, (no edit rating function).  So not to leave them feeling guilty,  Is there a way to set a edit time, say five minutes?  so they can change the rating they gave.

Any help would be appreciated.
Title: Re: Edit Rating within 5 minutes.
Post by: Nibbler on February 01, 2009, 04:47:41 PM
Change ratepic.php


$sql = "SELECT * " . "FROM {$CONFIG['TABLE_VOTES']} " . "WHERE pic_id = '$pic' AND user_md5_id = '$user_md5_id'";


Make that something like this:


$sql = "SELECT * " . "FROM {$CONFIG['TABLE_VOTES']} " . "WHERE pic_id = '$pic' AND user_md5_id = '$user_md5_id' AND vote_time < UNIX_TIMESTAMP() - 5 * 60";
Title: Re: Edit Rating within 5 minutes.
Post by: lurkalot on February 01, 2009, 05:25:09 PM
Quote from: Nibbler on February 01, 2009, 04:47:41 PM
Change ratepic.php


$sql = "SELECT * " . "FROM {$CONFIG['TABLE_VOTES']} " . "WHERE pic_id = '$pic' AND user_md5_id = '$user_md5_id'";


Make that something like this:


$sql = "SELECT * " . "FROM {$CONFIG['TABLE_VOTES']} " . "WHERE pic_id = '$pic' AND user_md5_id = '$user_md5_id' AND vote_time < UNIX_TIMESTAMP() - 5 * 60";


Thanks Nibbler.

Just tried changing the code you gave me, but if I vote on a pic that goes ok.  If I click on the rating to change it it gives me the error below,

"Critical error
There was an error while processing a database query"

I did this three times, and now the image has three votes, all from me.  Any ideas? 


Title: Re: Edit Rating within 5 minutes.
Post by: Nibbler on February 01, 2009, 05:32:20 PM
Enable debug mode in config and post the mysql error message you get when you try to vote.
Title: Re: Edit Rating within 5 minutes.
Post by: Nibbler on February 01, 2009, 05:38:27 PM
Oh, change


$sql = "INSERT INTO {$CONFIG['TABLE_VOTES']} " . "VALUES ('$pic', '$user_md5_id', '$curr_time')";


to


$sql = "REPLACE INTO {$CONFIG['TABLE_VOTES']} " . "VALUES ('$pic', '$user_md5_id', '$curr_time')";
Title: Re: Edit Rating within 5 minutes.
Post by: lurkalot on February 01, 2009, 05:51:49 PM
Thanks again Nibbler, that has fixed the error, but it's still counting each edit as an additional vote.   ;)  I voted, then changed the vote, and now it has two votes. by me.
Title: Re: Edit Rating within 5 minutes.
Post by: lurkalot on February 02, 2009, 05:54:55 PM
I seem to have been left in the middle of this.  :-[

Got any more thoughts on a solution please,  Nibbler?
Title: Re: Edit Rating within 5 minutes.
Post by: Nibbler on February 02, 2009, 08:04:27 PM
Sorry. It's not the easy change I thought it was going to be.
Title: Re: Edit Rating within 5 minutes.
Post by: lurkalot on February 02, 2009, 11:19:27 PM
Thanks trying Nibbler, should I give up on this? or are you working on a solution. 

Title: Re: Edit Rating within 5 minutes.
Post by: Nibbler on February 03, 2009, 01:11:18 AM
Not working on it. You'd need to store what the original rating was (Coppermine doesn't do this) in order to recalculate the rating when the vote is edited. This is more effort that it's worth I think.
Title: Re: Edit Rating within 5 minutes.
Post by: lurkalot on February 03, 2009, 10:05:04 AM
OK Nibbler, thanks for trying.  ;)

I'll restore the ratepic.php code back to it's original.   Might be a good idea to include this function in future releases, if that would be easier.

Cheers.
Title: Re: Edit Rating within 5 minutes.
Post by: Joachim Müller on February 04, 2009, 12:32:39 PM
I strongly doubt that a feature to undo someone's rating within a certain period will go into the release. Much ado about nothing if you ask me.