Advertisement:

Author Topic: Time left for karma  (Read 35674 times)

Offline Lisah746

  • Semi-Newbie
  • *
  • Posts: 39
Time left for karma
« on: October 07, 2005, 08:05:42 AM »
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

Offline Oldiesmann

  • Developer
  • SMF Super Hero
  • *
  • Posts: 24,814
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • http://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: Time left for karma
« Reply #1 on: October 08, 2005, 08:36:17 PM »
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.
Michael Eshom
Webmaster / SMF Lead Developer
oldiesmann@simplemachines.org

Offline Elmacik

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,276
  • Gender: Male
  • = Human Draft =
    • IT Store
Re: Time left for karma
« Reply #2 on: October 08, 2005, 08:46:15 PM »
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
« Last Edit: October 08, 2005, 08:48:42 PM by elmacik »
Home of Elmacik

Offline Oldiesmann

  • Developer
  • SMF Super Hero
  • *
  • Posts: 24,814
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • http://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: Time left for karma
« Reply #3 on: October 08, 2005, 11:38:37 PM »
That's the wait time. It specifies how long (in hours) people have to wait between consecutive Karma actions on the same person.
Michael Eshom
Webmaster / SMF Lead Developer
oldiesmann@simplemachines.org

Offline Elmacik

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,276
  • Gender: Male
  • = Human Draft =
    • IT Store
Re: Time left for karma
« Reply #4 on: October 08, 2005, 11:40:10 PM »
and isnt this what Lisah746 asked for anyway?
i am confused now :P
Home of Elmacik

Offline Lisah746

  • Semi-Newbie
  • *
  • Posts: 39
Re: Time left for karma
« Reply #5 on: October 12, 2005, 09:17:13 AM »
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.

Offline Elmacik

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,276
  • Gender: Male
  • = Human Draft =
    • IT Store
Re: Time left for karma
« Reply #6 on: October 12, 2005, 01:38:01 PM »
hmm sorry, i newly got the point
Home of Elmacik

Offline Oldiesmann

  • Developer
  • SMF Super Hero
  • *
  • Posts: 24,814
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • http://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: Time left for karma
« Reply #7 on: October 12, 2005, 02:02:49 PM »
Sorry for not posting sooner Lisah. I forgot about this topic :)

Sources/Karma.php

Find
Code: [Select]
// 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
Code: [Select]
// 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
Code: [Select]
// If you are gonna try to repeat.... don't allow it.
if ($action == $dir)
fatal_error($txt['smf62'] . ' ' . $modSettings['karmaWaitTime'] . ' ' . $txt[578] . '.', false);

Replace
Code: [Select]
// 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.
Michael Eshom
Webmaster / SMF Lead Developer
oldiesmann@simplemachines.org

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: Time left for karma
« Reply #8 on: October 13, 2005, 12:06:27 AM »
I think this should be added to the Tips and tricks board.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Offline Elmacik

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,276
  • Gender: Male
  • = Human Draft =
    • IT Store
Re: Time left for karma
« Reply #9 on: October 13, 2005, 12:13:47 AM »
I think this should be added to the Tips and tricks board.
+1
Home of Elmacik

Offline Lisah746

  • Semi-Newbie
  • *
  • Posts: 39
Re: Time left for karma
« Reply #10 on: October 13, 2005, 10:06:30 AM »
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.

Offline Lisah746

  • Semi-Newbie
  • *
  • Posts: 39
Re: Time left for karma
« Reply #11 on: October 13, 2005, 04:50:17 PM »
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?

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: Time left for karma
« Reply #12 on: October 13, 2005, 06:21:54 PM »
Can you post the block of code from line 115 to 120?
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Offline Jack.R.Abbit™

  • SMF Friend
  • Sophist Member
  • *
  • Posts: 1,282
  • Gender: Male
Re: Time left for karma
« Reply #13 on: October 13, 2005, 06:34:55 PM »
This line looks to be the problem:
Code: [Select]
$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:
Code: [Select]
$waittime = round(($modSettings['karmaWaitTime'] * 60) - ((time() - $time) / 60));

Offline Oldiesmann

  • Developer
  • SMF Super Hero
  • *
  • Posts: 24,814
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • http://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: Time left for karma
« Reply #14 on: October 14, 2005, 10:13:10 AM »
Yep. It should be. Thanks Jack :)
Michael Eshom
Webmaster / SMF Lead Developer
oldiesmann@simplemachines.org

Offline Lisah746

  • Semi-Newbie
  • *
  • Posts: 39
Re: Time left for karma
« Reply #15 on: October 16, 2005, 08:39:37 AM »
This line looks to be the problem:
Code: [Select]
$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:
Code: [Select]
$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.

Offline Moocat

  • Semi-Newbie
  • *
  • Posts: 29
Re: Time left for karma
« Reply #16 on: October 25, 2005, 10:35:48 PM »
excellent trick :) i am using it now! ;D

Offline Hoochie Coochie Man

  • SMF Hero
  • ******
  • Posts: 5,135
  • Gender: Male
    • İstanblues.org
Re: Time left for karma
« Reply #17 on: November 18, 2007, 07:20:53 PM »
I've got the following error.  :-\


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

Any ideas?  :-\
İnadına SMF 1.1.X

Offline De4thPr00f

  • Semi-Newbie
  • *
  • Posts: 30
Re: Time left for karma
« Reply #18 on: November 30, 2007, 10:31:09 AM »
If you have karma description log mod, and want to use this trick, this is what you need to replace.
Sources/Karma.php

Find
Code: [Select]
// 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
Code: [Select]
// 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
Code: [Select]
                // If you are gonna try to repeat.... don't allow it.
                if ($restricttime < $timelog)
                        fatal_error($txt['smf62'] . ' ' . $modSettings['karmaWaitTime'] . ' ' . $txt[578] . '.', false);

Replace
Code: [Select]
// 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...

Offline Rumbaar

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 15,805
  • Gender: Male
  • Inherent Omniscience
    • Rumbaar.net
Re: Time left for karma
« Reply #19 on: December 14, 2007, 04:13:26 AM »
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.
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]