Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: nend on September 22, 2012, 01:10:38 PM

Title: Post Karma
Post by: nend on September 22, 2012, 01:10:38 PM
Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=3474)

This mod adds two new links to the Karma system which you can see in each post. These links contain the number of smites and applauds a post has.

This mod has no configuration since it relies on SMF's karma system settings.

License
QuoteCopyright (c) 2012, Russell Najar (SiberInc)
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the SiberInc nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Releases
0.1
- First build and initial upload

0.2
* Small change in installation. Doesn't affect modification once installed.
Title: Re: Post Karma
Post by: NanoSector on September 22, 2012, 01:11:45 PM
Nice mod, I'm going to use this on my own site :)

Going to make a small change to it though to only show/work on the first post of a topic. That'll make it ideal for my site :)
Title: Re: Post Karma
Post by: tMicky on September 22, 2012, 11:08:01 PM
congrats nend :)
Title: Re: Post Karma
Post by: nend on September 26, 2012, 10:45:39 AM
Thanks,

Expected a little more comments with all the downloads. Later on when I have enough time I will post my "Trending" block which looks at the karma per post and displays which post are trending. You can add this in a PHP block in your portal. Will post later though because I have to go soon.
Title: Re: Post Karma
Post by: nend on September 28, 2012, 12:42:23 PM
Here is the trending post function.

function mini_trendingPosts($num_recent = 5)
{
global $context, $settings, $scripturl, $txt, $db_prefix, $user_info;
global $modSettings, $smcFunc;

//Check cache
if($context['user']['is_logged'] && ($data = cache_get_data('g'.$user_info['groupString'].'trendingPostscache', 1800)) != null) {
return $data;
} else if (!$context['user']['is_logged'] && ($data = cache_get_data('uguesttrendingPostscache', 1800)) != null) {
return  $data;
}

// Find all the posts in distinct topics.  Newer ones will have higher IDs.
$request = $smcFunc['db_query']('substring', '
SELECT
m.poster_time, m.id_topic, m.id_member, m.id_msg, b.id_board, b.name AS board_name, t.num_replies, t.num_views,
IFNULL(mem.real_name, m.poster_name) AS poster_name, mem.avatar, m.body AS body, m.smileys_enabled, m.icon, tb.subject, tb.body AS tbody,
IFNULL(a.id_attach, 0) AS ID_ATTACH, a.filename, a.attachment_type as attachmentType
FROM {db_prefix}messages AS m
INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member AND a.attachment_type!=3)
LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
LEFT JOIN {db_prefix}messages AS tb ON (tb.id_msg = t.id_first_msg)
WHERE m.poster_time > {int:time_back}
AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? '
AND t.approved = {int:is_approved}
AND m.approved = {int:is_approved}' : '') . '
ORDER BY m.karma_good - m.karma_bad DESC
LIMIT {int:numrecent}' ,
array(
'current_member' => $user_info['id'],
'include_boards' => empty($include_boards) ? '' : $include_boards,
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
'min_message_id' => $modSettings['maxMsgID'] - 35 * min($num_recent, 5),
'is_approved' => 1,
'numrecent' => $num_recent,
'time_back' => time() - 2599277,
)
);

$posts = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$shortSub = null;
$row['body'] = strip_tags(str_replace('<br />', ' ', parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg'])));
if ($smcFunc['strlen']($row['body']) > 170)
$row['body'] = $smcFunc['substr']($row['body'], 0, 170) . '...';
if ($smcFunc['strlen']($row['subject']) > 45)
$shortSub = $smcFunc['substr']($row['subject'], 0, 45) . '...';

// Censor the subject.
censorText($row['subject']);
censorText($row['body']);

if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

// Build the array.
$posts[] = array(
'board' => array(
'id' => $row['id_board'],
'name' => $row['board_name'],
'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['board_name'] . '</a>',
),
'topic' => $row['id_topic'],
'poster' => array(
'id' => $row['id_member'],
'name' => $row['poster_name'],
'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>'
),
'readmore' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#new">Read More</a>',
'avatar' => $row['avatar'] == '' ? ($row['ID_ATTACH'] > 0 ? '<img src="' . (empty($row['attachmentType']) ? $scripturl . '?action=dlattach;attach=' . $row['ID_ATTACH'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="&nbsp;"  />' : '') : (stristr($row['avatar'], 'http://') ? '<img src="' . $row['avatar'] . '" alt="&nbsp;" />' : '<img src="' . $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($row['avatar']) . '" alt="&nbsp;" />'),
'subject' => $row['subject'],
'replies' => $row['num_replies'],
'views' => $row['num_views'],
'short_subject' => shorten_subject($row['subject'], 25),
'preview' => $row['body'],
'time' => protimeformat($row['poster_time']),
'timestamp' => forum_time(true, $row['poster_time']),
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '" rel="nofollow"' . (isset($shortSub) ? ' title="' . $row['subject'] .'">' . $shortSub : '>' . $row['subject']) . '</a>',
// Retained for compatibility - is technically incorrect!
'new' => !empty($row['is_read']),
'is_new' => empty($row['is_read']),
'new_from' => $row['new_from'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '"  />',
);
}
$smcFunc['db_free_result']($request);

// Make cache
if($context['user']['is_logged']) {
cache_put_data('g'.$user_info['groupString'].'trendingPostscache', $posts, 1800);
} else {
cache_put_data('uguesttrendingPostscache', $posts, 1800);
}

return $posts;
}


You can use this function to return the trending post within the time frame of time_back.
Title: Re: Post Karma
Post by: Jade Elizabeth on September 30, 2012, 03:01:35 AM
OH MY GOD I LOVE YOU SO MUCH.

BUT how does it work? Will it work with Karma Description and Limit Karma?
http://mods.simplemachines.org/index.php?mod=192
http://custom.simplemachines.org/mods/index.php?mod=1308
Title: Re: Post Karma
Post by: tMicky on September 30, 2012, 05:17:21 AM
Quote from: nend on September 28, 2012, 12:42:23 PM
Here is the trending post function.

You can use this function to return the trending post within the time frame of time_back.

Thank you. I do have a question, are we supposed to change something in the time_back area, to make the posts show. I added the block, but no post is listed?
Title: Re: Post Karma
Post by: CreativeITWorld.com on October 12, 2012, 07:33:03 PM
Had a problem:

Quote1.   Execute Code   db.php   
   2.   Execute Modification   ./Sources/Karma.php   Test successful
   3.   Execute Modification   ./Sources/Display.php   Test failed
      1.   Add After   ./Sources/Display.php   Test successful
      2.   Add After   ./Sources/Display.php   Test failed

   4.   Execute Modification   ./Themes/default/Display.template.php   Test successful

This is a heavily modified forum, so if nobody else reports the same problem, you will know that the installation problem is due to conflicts.
Title: Re: Post Karma
Post by: Arantor on October 12, 2012, 07:41:04 PM
Well, the conflicts aren't there on a vanilla 2.0 install, which means it's due to conflicts...
Title: Re: Post Karma
Post by: nend on October 13, 2012, 01:12:22 AM
Quote from: CreativeITWorld.com on October 12, 2012, 07:33:03 PM
Had a problem:

Quote1.   Execute Code   db.php   
   2.   Execute Modification   ./Sources/Karma.php   Test successful
   3.   Execute Modification   ./Sources/Display.php   Test failed
      1.   Add After   ./Sources/Display.php   Test successful
      2.   Add After   ./Sources/Display.php   Test failed

   4.   Execute Modification   ./Themes/default/Display.template.php   Test successful

This is a heavily modified forum, so if nobody else reports the same problem, you will know that the installation problem is due to conflicts.
The install code was tested on a vanilla 2.0 board without any problems.

The two lines in Display.php is the portion added to the query and the portion to add the information to the array. The mod will not display karma per post without this.

I recommend to do a manual install or pay someone to manually install it for you.

I don't recommend to go further with the install via the package manager, I doubt it would cause any problems but it wouldn't add any benefits/features without that portion of the code working.

The choice is yours.
Title: Re: Post Karma
Post by: rlh2006 on October 13, 2012, 04:42:25 PM
I started using this mod about a week ago. I like it but there are some minor issues that need a coding fix.

Issue I: Guest Browsers

Logged-in users see post karma (normally) as:

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FsfLNi.jpg%3F1&hash=498d315577325cd65fcdb77699ff9730334c3609)

Guests sees the post karma in an odd way:

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FDRWmf.jpg%3F1&hash=f0f88e454645dd96b6ac7916c50e944b1592d9d4)


And there is an error constantly showing up in my log, which I think is related to guests browsing topics

Error: 8: Undefined index: karma
File: forum/Themes/default/Display.template.php (main sub template - eval?)
Line: 498
Line Text ==>498: if ($message['member']['karma']['allow'])


Issue II: Posts that Remain from Deleted User Accounts

When logged-in users browse a post left over from a deleted account the following error is generated:

Error: 8: Undefined index: karma
File: forum/Themes/default/Display.template.php (main sub template - eval?)
Line: 498
Line Text ==>498: if ($message['member']['karma']['allow'])


If any Simple Machines Hero could give a possible coding fix here I would surely appreciate it.

Title: Re: Post Karma
Post by: nend on October 14, 2012, 01:14:05 PM
Your theme may be using a custom Display.template.php which may be causing the errors and causing the text to miss align.

Basically saying, post your Display.template.php, something is wrong in it.  ;D
Title: Re: Post Karma
Post by: Jade Elizabeth on October 14, 2012, 06:42:29 PM
Quote from: Jade Elizabeth on September 30, 2012, 03:01:35 AM
OH MY GOD I LOVE YOU SO MUCH.

BUT how does it work? Will it work with Karma Description and Limit Karma?
http://mods.simplemachines.org/index.php?mod=192
http://custom.simplemachines.org/mods/index.php?mod=1308

Yay/Nae?
Title: Re: Post Karma
Post by: NanoSector on October 15, 2012, 03:47:50 AM
Set up a test installation and see :P

Looking at the code it doesn't appear to do anything special with them.
Title: Re: Post Karma
Post by: rlh2006 on October 15, 2012, 11:40:32 AM
Quote from: nend on October 14, 2012, 01:14:05 PM
Your theme may be using a custom Display.template.php which may be causing the errors and causing the text to miss align.

Basically saying, post your Display.template.php, something is wrong in it.  ;D
Ok. I had a coder look this over and these changes were applied to my site.
Note: on my site guests can't post or give karma.

Open Themes/default/Display.template.php  its the default theme (because the theme I am using doesn't have its own and loads the file from the default theme).

find:



// Karma Per Post
if ($message['member']['karma']['allow'])
echo '
<li style="background: url(', $settings['images_url'], '/post/thumbup.gif) no-repeat 0 0;"><a href="', $scripturl, '?action=modifykarma;sa=applaud;uid=', $message['member']['id'], ';topic=', $context['current_topic'], '.' . $context['start'], ';m=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $modSettings['karmaApplaudLabel'], $message['karma']['good'], '</a></li>
<li style="background: url(', $settings['images_url'], '/post/thumbdown.gif) no-repeat 0 0;"><a href="', $scripturl, '?action=modifykarma;sa=smite;uid=', $message['member']['id'], ';topic=', $context['current_topic'], '.' . $context['start'], ';m=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $modSettings['karmaSmiteLabel'], $message['karma']['bad'], '</a></li>';


and below that part, add the following:


elseif ($context['user']['is_guest'])
echo '
<ul class="reset smalltext quickbuttons"><li style="background: url(', $settings['images_url'], '/post/thumbup.gif) no-repeat 0 0;"><a href="', $scripturl, '?action=login">', $modSettings['karmaApplaudLabel'], $message['karma']['good'], '</a></li>
<li style="background: url(', $settings['images_url'], '/post/thumbdown.gif) no-repeat 0 0;"><a href="', $scripturl, '?action=login">', $modSettings['karmaSmiteLabel'], $message['karma']['bad'], '</a></li></ul>';



So the final product looks like this:



// Karma Per Post
if ($message['member']['karma']['allow'])
echo '
<li style="background: url(', $settings['images_url'], '/post/thumbup.gif) no-repeat 0 0;"><a href="', $scripturl, '?action=modifykarma;sa=applaud;uid=', $message['member']['id'], ';topic=', $context['current_topic'], '.' . $context['start'], ';m=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $modSettings['karmaApplaudLabel'], $message['karma']['good'], '</a></li>
<li style="background: url(', $settings['images_url'], '/post/thumbdown.gif) no-repeat 0 0;"><a href="', $scripturl, '?action=modifykarma;sa=smite;uid=', $message['member']['id'], ';topic=', $context['current_topic'], '.' . $context['start'], ';m=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $modSettings['karmaSmiteLabel'], $message['karma']['bad'], '</a></li>';

elseif ($context['user']['is_guest'])
echo '
<ul class="reset smalltext quickbuttons"><li style="background: url(', $settings['images_url'], '/post/thumbup.gif) no-repeat 0 0;"><a href="', $scripturl, '?action=login">', $modSettings['karmaApplaudLabel'], $message['karma']['good'], '</a></li>
<li style="background: url(', $settings['images_url'], '/post/thumbdown.gif) no-repeat 0 0;"><a href="', $scripturl, '?action=login">', $modSettings['karmaSmiteLabel'], $message['karma']['bad'], '</a></li></ul>';

else
echo '
<li style="background: url(', $settings['images_url'], '/post/thumbup.gif) no-repeat 0 0;"><span style="padding-left:20px;display:block;height:20px;line-height:18px;float:left;">', $modSettings['karmaApplaudLabel'], $message['karma']['good'], '</span></li>
<li style="background: url(', $settings['images_url'], '/post/thumbdown.gif) no-repeat 0 0;"><span style="padding-left:20px;display:block;height:20px;line-height:18px;float:left;">', $modSettings['karmaSmiteLabel'], $message['karma']['bad'], '</span></li>';
// Can we restore topics?
Title: Re: Post Karma
Post by: rlh2006 on October 15, 2012, 02:16:28 PM
Also, if you do not allow guest posting and you have deleted accounts from prior members but left their posts then you will receive an error related to that, so this fix will resolve that:

// Karma Per Post
if (!$message['member']['is_guest'] && $message['member']['karma']['allow'])
echo '
<li style="background: url(', $settings['images_url'], '/post/thumbup.gif) no-repeat 0 0;"><a href="', $scripturl, '?action=modifykarma;sa=applaud;uid=', $message['member']['id'], ';topic=', $context['current_topic'], '.' . $context['start'], ';m=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $modSettings['karmaApplaudLabel'], $message['karma']['good'], '</a></li>
<li style="background: url(', $settings['images_url'], '/post/thumbdown.gif) no-repeat 0 0;"><a href="', $scripturl, '?action=modifykarma;sa=smite;uid=', $message['member']['id'], ';topic=', $context['current_topic'], '.' . $context['start'], ';m=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $modSettings['karmaSmiteLabel'], $message['karma']['bad'], '</a></li>';

elseif (!$message['member']['is_guest'] && $context['user']['is_guest'])
echo '
<ul class="reset smalltext quickbuttons"><li style="background: url(', $settings['images_url'], '/post/thumbup.gif) no-repeat 0 0;"><a href="', $scripturl, '?action=login">', $modSettings['karmaApplaudLabel'], $message['karma']['good'], '</a></li>
<li style="background: url(', $settings['images_url'], '/post/thumbdown.gif) no-repeat 0 0;"><a href="', $scripturl, '?action=login">', $modSettings['karmaSmiteLabel'], $message['karma']['bad'], '</a></li></ul>';

elseif (!$message['member']['is_guest'])
echo '
<li style="background: url(', $settings['images_url'], '/post/thumbup.gif) no-repeat 0 0;"><span style="padding-left:20px;display:block;height:20px;line-height:18px;float:left;">', $modSettings['karmaApplaudLabel'], $message['karma']['good'], '</span></li>
<li style="background: url(', $settings['images_url'], '/post/thumbdown.gif) no-repeat 0 0;"><span style="padding-left:20px;display:block;height:20px;line-height:18px;float:left;">', $modSettings['karmaSmiteLabel'], $message['karma']['bad'], '</span></li>';

// Can we restore topics?
Title: Re: Post Karma
Post by: impreza on October 16, 2012, 07:18:59 PM
Nice addition, for sure come in handy. thanks
Title: Re: Post Karma
Post by: nend on October 22, 2012, 11:41:13 PM
Quote from: rlh2006 on October 15, 2012, 02:16:28 PM
Also, if you do not allow guest posting and you have deleted accounts from prior members but left their posts then you will receive an error related to that, so this fix will resolve that:

// Karma Per Post
if (!$message['member']['is_guest'] && $message['member']['karma']['allow'])
echo '
<li style="background: url(', $settings['images_url'], '/post/thumbup.gif) no-repeat 0 0;"><a href="', $scripturl, '?action=modifykarma;sa=applaud;uid=', $message['member']['id'], ';topic=', $context['current_topic'], '.' . $context['start'], ';m=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $modSettings['karmaApplaudLabel'], $message['karma']['good'], '</a></li>
<li style="background: url(', $settings['images_url'], '/post/thumbdown.gif) no-repeat 0 0;"><a href="', $scripturl, '?action=modifykarma;sa=smite;uid=', $message['member']['id'], ';topic=', $context['current_topic'], '.' . $context['start'], ';m=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $modSettings['karmaSmiteLabel'], $message['karma']['bad'], '</a></li>';

elseif (!$message['member']['is_guest'] && $context['user']['is_guest'])
echo '
<ul class="reset smalltext quickbuttons"><li style="background: url(', $settings['images_url'], '/post/thumbup.gif) no-repeat 0 0;"><a href="', $scripturl, '?action=login">', $modSettings['karmaApplaudLabel'], $message['karma']['good'], '</a></li>
<li style="background: url(', $settings['images_url'], '/post/thumbdown.gif) no-repeat 0 0;"><a href="', $scripturl, '?action=login">', $modSettings['karmaSmiteLabel'], $message['karma']['bad'], '</a></li></ul>';

elseif (!$message['member']['is_guest'])
echo '
<li style="background: url(', $settings['images_url'], '/post/thumbup.gif) no-repeat 0 0;"><span style="padding-left:20px;display:block;height:20px;line-height:18px;float:left;">', $modSettings['karmaApplaudLabel'], $message['karma']['good'], '</span></li>
<li style="background: url(', $settings['images_url'], '/post/thumbdown.gif) no-repeat 0 0;"><span style="padding-left:20px;display:block;height:20px;line-height:18px;float:left;">', $modSettings['karmaSmiteLabel'], $message['karma']['bad'], '</span></li>';

// Can we restore topics?


Been a little busy to go over the code but yeah guest posting and deleted members may throw some errors. Will look into that to see what needs to be done to fix it if a fix is needed.  ;)
Title: Re: Post Karma
Post by: Lazarevics on November 11, 2012, 03:23:25 PM
here the full corrected package (tested)
thx rlh2006!
Title: Re: Post Karma
Post by: nend on November 19, 2012, 12:43:37 AM
Thanks,

I completely forgot about that bug. I have been doing this one off from memory as I haven't set up any tracking for such mods. I might set up a repo, anybody is welcomed to add to this mod, hence the open source license.

However to avoid confusion if anyone does want to release a variant on the mod site of any of my mods please make sure it adds a completely new feature, otherwise don't because it may cause too much confusion.

That being said, please feel free to modify, distribute or whatever you like. Remember you can't sell the code due to the license. Anyways have fun with it.
Title: Re: Post Karma
Post by: phue on December 16, 2012, 08:35:21 AM
Hi nend,

I am using your mod and it works perfect! Just wanted to ask if you know a technique to get a list of posts sorted by upvotes.

Thanks for this great mod, and happy holidays!
Title: Re: Post Karma
Post by: TCRoss on December 23, 2012, 09:32:49 AM
I installed post karma several days ago and after running into the error noted earlier in the thread with messy text and karma images instead of just images, uninstalled it.  It couldn't uninstall and disabled my forum.  I reinstalled it so I could keep the forum up.  NOW it's duplicated itself.  I've gone in and deleted the duplicate code to try to only get one to show until it could be fixed, but I'm assuming the problem is the extra db column - which I can't find to delete. 

I tried the code fix mentioned, but it didn't fix mine.

How do I uninstall it?!  Where are the columns I need to delete?

*Edit*  Manually fixed the text issue, but still have the duplicate icons.

Title: Re: Post Karma
Post by: nend on December 23, 2012, 01:55:55 PM
In the version .3 repo currently I have rlh2006 fixed code for deleted members. I also plan to add hooks in it for the template before releasing it to prevent user error or any visual problems.

@TCRoss

That isn't a error but more than likely a incompatibility with your theme. I am going to see about using hooks in the template so we can hopefully avoid any of those incompatibilities.

Your going to have to go to the listing on the mod site and select the manual install for 2.0.2 to remove any duplicate code.

As for the tables in the database being a problem it shouldn't be.
Title: Re: Post Karma
Post by: nend on December 23, 2012, 02:22:41 PM
Added to Github, any contributions welcomed. Fork and play around.  ;D
Title: Re: Post Karma
Post by: wildcat180 on January 09, 2013, 12:30:59 PM
This is a great mod and works wonderfully!  Is there anyway to make it to where you can see who is changing the karma? 
Title: Re: Post Karma
Post by: adisz on January 29, 2013, 05:51:47 PM
Quote from: tMicky on September 30, 2012, 05:17:21 AM
Quote from: nend on September 28, 2012, 12:42:23 PM
Here is the trending post function.

You can use this function to return the trending post within the time frame of time_back.

Thank you. I do have a question, are we supposed to change something in the time_back area, to make the posts show. I added the block, but no post is listed?
Hello,
it looks like the same problem.
I've pasted this code to php block, but I don't understand what is time_back area. What must I do to see list of posts?
Title: Re: Post Karma
Post by: chereneb on April 24, 2013, 02:54:16 AM
Hi,

I have installed this mod to my site. Without a problem. I am using SMF 2.0.4 with the Gray style theme. The thumbs up and thumbs down appears above each post, but it is not clickable. Any ideas why this might be?
Title: Re: Post Karma
Post by: chereneb on May 03, 2013, 06:48:41 AM
Still no response?
Title: Re: Post Karma
Post by: tMicky on May 12, 2013, 11:01:16 AM
I keep getting an error:

"Field 'karma_bad' doesn't have a default value"
Title: Re: Post Karma
Post by: nend on May 19, 2013, 01:13:23 AM
Compatible and tested with SMF 2.0.2 using default theme.

Haven't had much time lately to update it for compatibility with any newer versions. However the modification is open source so anyone is free to contribute or fork as they please.
Title: Re: Post Karma
Post by: Shrink on May 20, 2013, 02:31:23 AM
i have 1 suggestion for next upgrade. add a filter like accending or desending within a topic!!!
Title: Re: Post Karma
Post by: FrankiGoode on May 26, 2013, 05:27:30 AM
Hi,

We had the mod installed but recently uninstalled it while trying a few things out. Trouble is the thumps up [applaud] and thumbs down [smite] remain at the top of each post. See attached file.

Can you please let me know how these can be deleted as it is now affecting the re-installation of this and other mods.

many thanks
Title: Re: Post Karma
Post by: f00ty on February 11, 2014, 05:14:14 PM
Any example on how to use trending function? Where to place it eg.?
Title: Re: Post Karma
Post by: Yoss on June 02, 2014, 04:21:55 PM
Quote from: nend on May 19, 2013, 01:13:23 AM
Compatible and tested with SMF 2.0.2 using default theme.

Haven't had much time lately to update it for compatibility with any newer versions. However the modification is open source so anyone is free to contribute or fork as they please.
hi, I'm testing the mod with smf 2.07 and it works properly and smoothly.

Quote from: phue on December 16, 2012, 08:35:21 AM
Hi nend,

I am using your mod and it works perfect! Just wanted to ask if you know a technique to get a list of posts sorted by upvotes.

Thanks for this great mod, and happy holidays!
+1, it would be nice  :)  im thinking about the code for a block "best posts of the week" Can anyone try it?
Edited: The code is at 4th post, sry :-[ I paste the code in a simple portal php block but nothing is showed  :'(

...and I have another request for future versions of this interesting mod:

is possible to limit the change of karma for each user once for each post? I think it's interesting that you can not repeat the action so that the numbers on the post are more representative of the number of people who liked

Thanks for the work nend


Title: Re: Post Karma
Post by: jack_1985 on August 28, 2014, 03:14:42 PM
Hi all,

I have stumbled upon the following bug in this mod:

It's possible to smite a post (by using the thumb icon) and then applaud another post of that same member, within the karma waiting time. If you do this, the first karma action gets undone, but the counter next to the thumb doesn't change back. So you can keep pressing the thumb icon to smite post A, then applaud in post B, then smite post A, applaud post B, etc. And the counter just keeps adding up.

In other words, I guess a user should only be able to use the thumbs up/down once per post.

This bug defies the purpose of the mod a bit. Anybody any idea on how to fix this?

Using SMF 2.0.8 btw.
Title: Re: Post Karma
Post by: Gwenwyfar on November 14, 2014, 06:04:01 PM
Any news on the problem above? Or anyone know of another mod that does the same thing as this one? I basically just want something to add positive/negative points to individual posts and to show the total negative/positive in a user's profile, if possible to also see which posts received what or a notification to the user who got it. I've been looking on some other mods but this one still seems the best, but this bug... =/

I guess it could take a while to someone to find this bug but it could be easily abused once that happens.
Title: Re: Post Karma
Post by: Squash on November 14, 2014, 07:01:47 PM
Is there a way to not have the text at all, just the thumbs up and down? How do I remove it, what file? I'll try doing it on my own if I just knew the file to look for.
Title: Re: Post Karma
Post by: Gwenwyfar on November 14, 2014, 07:06:32 PM
I haven't installed the mod yet so this is a guess, but you could try looking on your display.template.php file.
Title: Re: Post Karma
Post by: Neek on August 05, 2016, 08:45:08 AM
Quote from: jack_1985 on August 28, 2014, 03:14:42 PM
Hi all,

I have stumbled upon the following bug in this mod:

It's possible to smite a post (by using the thumb icon) and then applaud another post of that same member, within the karma waiting time. If you do this, the first karma action gets undone, but the counter next to the thumb doesn't change back. So you can keep pressing the thumb icon to smite post A, then applaud in post B, then smite post A, applaud post B, etc. And the counter just keeps adding up.

In other words, I guess a user should only be able to use the thumbs up/down once per post.

This bug defies the purpose of the mod a bit. Anybody any idea on how to fix this?

Using SMF 2.0.8 btw.

Indeed, this bug ruins the mod. :(

Quote from: Gwenwyfar on November 14, 2014, 06:04:01 PM
Any news on the problem above? Or anyone know of another mod that does the same thing as this one? I basically just want something to add positive/negative points to individual posts and to show the total negative/positive in a user's profile, if possible to also see which posts received what or a notification to the user who got it. I've been looking on some other mods but this one still seems the best, but this bug... =/

I guess it could take a while to someone to find this bug but it could be easily abused once that happens.

Exactly what I want too. I'll try to figure out a solution but don't hold your breath. Anyone willing and able to offer some guidance, please?
Title: Re: Post Karma
Post by: Gwenwyfar on August 05, 2016, 09:47:55 AM
What I have done after this is install like posts, duplicate it, and call the new one dislikes, so that there are the two.

But it doesn't have notifications or anything else, so you have to modify that yourself, and the above has to be done manually after the first install.

There's also good post bad post, I don't recall what was wrong with that one though, only that it can't be automatically uninstalled and I still have bits of its corpse to throw out.
Title: Re: Post Karma
Post by: confuseamuse on August 07, 2017, 05:15:02 AM
Hilariously, every part of this mod failed the installation. I'm using 2.0.14 on a not-so-heavily modded forum.
Title: Re: Post Karma
Post by: addlife on February 21, 2019, 03:58:53 AM
Quote from: rlh2006 on October 13, 2012, 04:42:25 PM
I started using this mod about a week ago. I like it but there are some minor issues that need a coding fix.

Issue I: Guest Browsers

Logged-in users see post karma (normally) as:

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FsfLNi.jpg%3F1&hash=498d315577325cd65fcdb77699ff9730334c3609)

Guests sees the post karma in an odd way:

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FDRWmf.jpg%3F1&hash=f0f88e454645dd96b6ac7916c50e944b1592d9d4)


And there is an error constantly showing up in my log, which I think is related to guests browsing topics

Error: 8: Undefined index: karma
File: forum/Themes/default/Display.template.php (main sub template - eval?)
Line: 498
Line Text ==>498: if ($message['member']['karma']['allow'])


Issue II: Posts that Remain from Deleted User Accounts

When logged-in users browse a post left over from a deleted account the following error is generated:

Error: 8: Undefined index: karma
File: forum/Themes/default/Display.template.php (main sub template - eval?)
Line: 498
Line Text ==>498: if ($message['member']['karma']['allow'])


If any Simple Machines Hero could give a possible coding fix here I would surely appreciate it.

I seem to have a similar problem with how the post karma looks for guests. I'm also using the karma button mod so theres a thumbs up and a button that aren't displaying properly. Here's screenshots of guests view and logged in view

My question is would the fix that this user posted below also work for my theme or is it a custom fix for his site?

Also I have like 30,000 errors in my log (which I just checked for the first time due to OP's post) that says

"8192: Function create_function() is deprecated

File: /home/........../public_html/Sources/Subs.php "

Does this have anything to do with that?


Title: Re: Post Karma
Post by: addlife on February 27, 2019, 02:43:29 AM
Quote from: addlife on February 21, 2019, 03:58:53 AM
I seem to have a similar problem with how the post karma looks for guests. I'm also using the karma button mod so theres a thumbs up and a button that aren't displaying properly. Here's screenshots of guests view and logged in view

My question is would the fix that this user posted below also work for my theme or is it a custom fix for his site?

So just an update in case this will help anyone.

I used this updated package from this post and it's working for my site perfectly
Quote from: Lazarevics on November 11, 2012, 03:23:25 PM
here the full corrected package (tested)
thx rlh2006!

There was one issue though. My site has a responsive theme and the buttons covered the post timestamp when in mobile view. All I had to do to fix that was locate the buttons responsive css and change the position property from absolute to relative. That moved the buttons to the right corner of the post area and made it look good.

Heres a screenshot of mobile and desktop version of a guests view