Topic: [extension release] pun_karma

Here is description of the extension.
Download links:

Or you can download pun_karma with help of pun_repository extension.
Feel free to report any bugs.

Re: [extension release] pun_karma

Great...we were awaiting this release for quite a while.

Works perfectly.

Can i replace the + and - Karma buttons with images?

Last edited by TwincamSam (2009-09-07 14:43:28)

Re: [extension release] pun_karma

thanks

Re: [extension release] pun_karma

I've had this in use for many many months. is this a new version or something?

Re: [extension release] pun_karma

TwincamSam wrote:

Great...we were awaiting this release for quite a while.

Works perfectly.

Can i replace the + and - Karma buttons with images?

It is planned in the next pun_karma release.

esupergood wrote:

I've had this in use for many many months. is this a new version or something?

It is the first official release of extension. I suppose you use the extension "user_karma". It was the base for pun_karma. The major changes from user_karma:

  • Table "user_karma" was renamed to "pun_karma"

  • Added a new field "karma" to table "posts"

  • Added SEF-support

  • Added posibility to disable the down mark to posts

  • Added posibility to set the number of minutes users have to wait before voting for a post (two options for down and up mark)

  • Added protection from CSRF attacks.

If you want to migrate to pun_karma extension, do the following:

  • Make a backup of table "<DB_PREFIX>user_karma"

  • Disable the extension "user_karma"

  • Rename the "user_karma" table to "pun_karma"

  • Run this script:

<?php

if (!defined('FORUM_ROOT'))
    define('FORUM_ROOT', './');
require FORUM_ROOT.'include/common.php';

$forum_db->add_field('posts', 'karma', 'INT(10)', TRUE);

$pun_karma_query = array(
    'SELECT'    =>    'post_id, SUM(mark) AS sum_mark',
    'FROM'        =>    'pun_karma',
    'GROUP BY'    =>    'post_id'
);
$pun_karma_res = $forum_db->query_build($pun_karma_query) or error(__FILE__, __LINE__);

while ($cur_karma = $forum_db->fetch_assoc($pun_karma_res))
{
    $pun_karma_query = array(
        'UPDATE'    =>    'posts',
        'SET'        =>    'karma = '.$cur_karma['sum_mark'],
        'WHERE'        =>    'id = '.$cur_karma['post_id']
    );
    $forum_db->query_build($pun_karma_query) or error(__FILE__, __LINE__);
}

echo 'Done.';

?>

Re: [extension release] pun_karma

The new version of pun_karma 1.1 has been released.
Changes from previous version:

  • Added icons instead of +, -, X characters

  • Added calculating of users karma.

Re: [extension release] pun_karma

Has anyone here migrated from old karma to new karma? Was it easy?
How do you "run" the above script?

Re: [extension release] pun_karma

Here the script for migration from user_karma to pun_karma 1.1. Other instructions are the same.

<?php

if (!defined('FORUM_ROOT'))
    define('FORUM_ROOT', './');
require FORUM_ROOT.'include/common.php';

@set_time_limit(0);

$forum_db->add_field('posts', 'karma', 'INT(10)', TRUE);

$pun_karma_query = array(
    'SELECT'    =>    'post_id, SUM(mark) AS sum_mark',
    'FROM'        =>    'pun_karma',
    'GROUP BY'    =>    'post_id'
);
$pun_karma_res = $forum_db->query_build($pun_karma_query) or error(__FILE__, __LINE__);

while ($cur_karma = $forum_db->fetch_assoc($pun_karma_res))
{
    $pun_karma_query = array(
        'UPDATE'    =>    'posts',
        'SET'        =>    'karma = '.$cur_karma['sum_mark'],
        'WHERE'        =>    'id = '.$cur_karma['post_id']
    );
    $forum_db->query_build($pun_karma_query) or error(__FILE__, __LINE__);
}

$forum_db->add_field('users', 'karma', 'INT(10)', TRUE);
$pun_karma_query = array(
    'SELECT'    =>    'poster_id, SUM(mark) AS user_karma',
    'FROM'        =>    $forum_db->prefix.'posts AS p, '.$forum_db->prefix.'pun_karma AS pk',
    'WHERE'        =>    'p.id = pk.post_id',
    'GROUP BY'    =>    'poster_id',
    'PARAMS'    =>    array(
        'NO_PREFIX'    =>    true
    )
);
$pun_karma_res = $forum_db->query_build($pun_karma_query) or error(__FILE__, __LINE__);

if ($forum_db->num_rows($pun_karma_res) > 0)
{
    while ($cur_karma = $forum_db->fetch_assoc($pun_karma_res))
    {
    $pun_karma_update_query = array(
        'UPDATE'    =>    'users',
        'SET'        =>    'karma = '.$cur_karma['user_karma'],
        'WHERE'        =>    'id = '.$cur_karma['poster_id']
       );
       $forum_db->query_build($pun_karma_update_query) or error(__FILE__, __LINE__);
    }
}

echo 'Done.';
?>
esupergood wrote:

How do you "run" the above script?

  • Copy/paste this script to the file "<FORUM_ROOT>/migration_user_karma_to_pun_karma.php"

  • Request the page "<FORUM_URL>/migration_user_karma_to_pun_karma.php"

  • Remove the file "<FORUM_ROOT>/migration_user_karma_to_pun_karma.php".

Re: [extension release] pun_karma

Excellent work Slavok. This is a fantastic addon!

Some users have requested a feature possibly in thier profile where they can view which of their posts were rated and who rated them.

Could you possibly add this on in a new version update? This would make an already great extension even better.   wink

Re: [extension release] pun_karma

Add your request to the extension's Wiki page, please.

Re: [extension release] pun_karma

Done. Thanks