Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Thema gestartet von: Lisah746 in Oktober 07, 2005, 08:05:42 VORMITTAG

Titel: Time left for karma
Beitrag von: Lisah746 in Oktober 07, 2005, 08:05:42 VORMITTAG
I have had this request from many of my users and thought it might be interesting to post here.

Once someone has given karma they are restricted from giving karma to the same person for one hour. (my settings)

How about having a time left display. Something like....

"Sorry, you can't repeat a karma action without waiting 1 hour, you have 25 minutes left."

Or something like that.

Thanks,
Lisa
Titel: Re: Time left for karma
Beitrag von: Oldiesmann in Oktober 08, 2005, 08:36:17 NACHMITTAGS
Shouldn't be too hard to do. Unfortunately I'm not at home right now so I don't have a copy of SMF to look at... I'll try to post something tomorrow though.
Titel: Re: Time left for karma
Beitrag von: Elmacik in Oktober 08, 2005, 08:46:15 NACHMITTAGS
thanks Oldiesmann, it should be really nice
and should be added as a feature i think

edit: whats this option in Karma settings?
   Set wait time in hours
Titel: Re: Time left for karma
Beitrag von: Oldiesmann in Oktober 08, 2005, 11:38:37 NACHMITTAGS
That's the wait time. It specifies how long (in hours) people have to wait between consecutive Karma actions on the same person.
Titel: Re: Time left for karma
Beitrag von: Elmacik in Oktober 08, 2005, 11:40:10 NACHMITTAGS
and isnt this what Lisah746 asked for anyway?
i am confused now :P
Titel: Re: Time left for karma
Beitrag von: Lisah746 in Oktober 12, 2005, 09:17:13 VORMITTAG
Zitat von: elmacik in Oktober 08, 2005, 11:40:10 NACHMITTAGS
and isnt this what Lisah746 asked for anyway?
i am confused now :P

I am asking for the time remaining before you can karma the same poster to be shown.
Titel: Re: Time left for karma
Beitrag von: Elmacik in Oktober 12, 2005, 01:38:01 NACHMITTAGS
hmm sorry, i newly got the point
Titel: Re: Time left for karma
Beitrag von: Oldiesmann in Oktober 12, 2005, 02:02:49 NACHMITTAGS
Sorry for not posting sooner Lisah. I forgot about this topic :)

Sources/Karma.php

Find
// Find out if this user has done this recently...
$request = db_query("
SELECT action
FROM {$db_prefix}log_karma
WHERE ID_TARGET = $_REQUEST[uid]
AND ID_EXECUTOR = $ID_MEMBER
LIMIT 1", __FILE__, __LINE__);
if (mysql_num_rows($request) > 0)
list ($action) = mysql_fetch_row($request);
mysql_free_result($request);


Replace
// Find out if this user has done this recently...
$request = db_query("
SELECT action, logTime
FROM {$db_prefix}log_karma
WHERE ID_TARGET = $_REQUEST[uid]
AND ID_EXECUTOR = $ID_MEMBER
LIMIT 1", __FILE__, __LINE__);
if (mysql_num_rows($request) > 0)
list ($action, $time) = mysql_fetch_row($request);
mysql_free_result($request);


Find
// If you are gonna try to repeat.... don't allow it.
if ($action == $dir)
fatal_error($txt['smf62'] . ' ' . $modSettings['karmaWaitTime'] . ' ' . $txt[578] . '.', false);


Replace
// If you are gonna try to repeat.... don't allow it.
if ($action == $dir)
{
// How much longer do they have to wait (in minutes)? Round to the nearest integer...
$waittime = round($modSettings['karmaWaitTime'] * 60) - ((time() - $time) / 60));
fatal_error($txt['smf62'] . ' ' . $modSettings['karmaWaitTime'] . ' ' . $txt[578] . ' (' . $waittime . ' more ' . $txt['totaltimelogged4'] . ')', false);
}


That will give them an (approximate) value. It rounds to the nearest integer, so the value could be off by as much as 30 seconds in either direction, but 30 seconds doesn't make that much of a difference anyway, so I don't think it's that important.
Titel: Re: Time left for karma
Beitrag von: JayBachatero in Oktober 13, 2005, 12:06:27 VORMITTAG
I think this should be added to the Tips and tricks board.
Titel: Re: Time left for karma
Beitrag von: Elmacik in Oktober 13, 2005, 12:13:47 VORMITTAG
Zitat von: JayBachatero in Oktober 13, 2005, 12:06:27 VORMITTAG
I think this should be added to the Tips and tricks board.
+1
Titel: Re: Time left for karma
Beitrag von: Lisah746 in Oktober 13, 2005, 10:06:30 VORMITTAG
Zitat von: elmacik in Oktober 13, 2005, 12:13:47 VORMITTAG
Zitat von: JayBachatero in Oktober 13, 2005, 12:06:27 VORMITTAG
I think this should be added to the Tips and tricks board.
+1
+2 and maybe intergrated into the karma mod itself. Thanks Oldiesmann. As soon as I get it intergrated I'll let you know.
Titel: Re: Time left for karma
Beitrag von: Lisah746 in Oktober 13, 2005, 04:50:17 NACHMITTAGS
I added the code exactly as it appears here and got the following error.

Parse error: parse error, unexpected ')' in /home/lisah/public_html/Sources/Karma.php on line 118


Any ideas?
Titel: Re: Time left for karma
Beitrag von: JayBachatero in Oktober 13, 2005, 06:21:54 NACHMITTAGS
Can you post the block of code from line 115 to 120?
Titel: Re: Time left for karma
Beitrag von: Jack.R.Abbit™ in Oktober 13, 2005, 06:34:55 NACHMITTAGS
This line looks to be the problem:
$waittime = round($modSettings['karmaWaitTime'] * 60) - ((time() - $time) / 60));

I'll assume that the entire result should be rounded and the line should look like this:
$waittime = round(($modSettings['karmaWaitTime'] * 60) - ((time() - $time) / 60));
Titel: Re: Time left for karma
Beitrag von: Oldiesmann in Oktober 14, 2005, 10:13:10 VORMITTAG
Yep. It should be. Thanks Jack :)
Titel: Re: Time left for karma
Beitrag von: Lisah746 in Oktober 16, 2005, 08:39:37 VORMITTAG
Zitat von: Jack.R.Abbit in Oktober 13, 2005, 06:34:55 NACHMITTAGS
This line looks to be the problem:
$waittime = round($modSettings['karmaWaitTime'] * 60) - ((time() - $time) / 60));

I'll assume that the entire result should be rounded and the line should look like this:
$waittime = round(($modSettings['karmaWaitTime'] * 60) - ((time() - $time) / 60));

Yep that did it! I did add to it 'Minutes Remaining' so it looks like.... Sorry you have 45 minutes remaining.

Thank-You everyone.
Titel: Re: Time left for karma
Beitrag von: Moocat in Oktober 25, 2005, 10:35:48 NACHMITTAGS
excellent trick :) i am using it now! ;D
Titel: Re: Time left for karma
Beitrag von: Hoochie Coochie Man in November 18, 2007, 07:20:53 NACHMITTAGS
I've got the following error.  :-\


8: Undefined index: totaltimelogged4
Dosya: /home/blues/public_html/forum/Sources/Karma.php
on line: 111

Any ideas?  :-\
Titel: Re: Time left for karma
Beitrag von: De4thPr00f in November 30, 2007, 10:31:09 VORMITTAG
If you have karma description log mod, and want to use this trick, this is what you need to replace.
Sources/Karma.php

Find
// Find out if this user has done this recently...
$request = db_query("
SELECT action
FROM {$db_prefix}log_karma
WHERE ID_TARGET = $_REQUEST[uid]
AND ID_EXECUTOR = $ID_MEMBER
LIMIT 1", __FILE__, __LINE__);
if (mysql_num_rows($request) > 0)
list ($action) = mysql_fetch_row($request);
mysql_free_result($request);


Replace
// Find out if this user has done this recently...
$request = db_query("
SELECT action, logTime
FROM {$db_prefix}log_karma
WHERE ID_TARGET = $_REQUEST[uid]
AND ID_EXECUTOR = $ID_MEMBER
LIMIT 1", __FILE__, __LINE__);
if (mysql_num_rows($request) > 0)
list ($action, $time) = mysql_fetch_row($request);
mysql_free_result($request);


Find
                // If you are gonna try to repeat.... don't allow it.
                if ($restricttime < $timelog)
                        fatal_error($txt['smf62'] . ' ' . $modSettings['karmaWaitTime'] . ' ' . $txt[578] . '.', false);


Replace
// If you are gonna try to repeat.... don't allow it.
if ($restricttime < $timelog)
{
// How much longer do they have to wait (in minutes)? Round to the nearest integer...
$waittime = $timelog - $restricttime;
$minutes = round(($waittime / 60));
fatal_error($txt['smf62'] . ' ' . $modSettings['karmaWaitTime'] . ' ' . $txt[578] . ' (' . $minutes . ' more minutes)', false);
}


Note: I had some troubles with the provided $waittime function referred a few posts ago, but this works perfect...
Titel: Re: Time left for karma
Beitrag von: Rumbaar in Dezember 14, 2007, 04:13:26 VORMITTAG
Zitat von: Hoochie Coochie Man in November 18, 2007, 07:20:53 NACHMITTAGS
I've got the following error.  :-\

8: Undefined index: totaltimelogged4
Dosya: /home/blues/public_html/forum/Sources/Karma.php
on line: 111

Any ideas?  :-\
Are you still experiencing this problem?

What is your current language settings.  Check you Index.english.php file to make sure it's present.  If you are using a language other than english, make sure you have the appropriate index.{language}.php file in your default language folder.
Titel: Re: Time left for karma
Beitrag von: Hoochie Coochie Man in Dezember 14, 2007, 05:20:17 VORMITTAG
Zitat von: Rumbaar in Dezember 14, 2007, 04:13:26 VORMITTAG
Zitat von: Hoochie Coochie Man in November 18, 2007, 07:20:53 NACHMITTAGS
I've got the following error.  :-\

8: Undefined index: totaltimelogged4
Dosya: /home/blues/public_html/forum/Sources/Karma.php
on line: 111

Any ideas?  :-\
Are you still experiencing this problem?

What is your current language settings.  Check you Index.english.php file to make sure it's present.  If you are using a language other than english, make sure you have the appropriate index.{language}.php file in your default language folder.

That was an old post :)
I solved my problem!
Thankyou very much anyway :)
Titel: Re: Time left for karma
Beitrag von: robinrobin in Februar 10, 2009, 09:03:19 VORMITTAG
But what about the function to be under a time-limit for each person You give a point separately, instead of not being able to give anyone else a point once You've given it to one person?
Titel: Re: Time left for karma
Beitrag von: folkandfaith in Februar 26, 2009, 09:49:15 NACHMITTAGS
on Vbulletin boards you can change it where it is not a specific amount of time that one has to wait, but that one "must pass some reputation around before giving it to ABC person again". Is there a way to do that on SMF?
Titel: Re: Time left for karma
Beitrag von: Rumbaar in Februar 26, 2009, 10:02:26 NACHMITTAGS
I can only think of a post count based option at the moment.

You might want to search some more or try the Mod Request section.