Topic: Om Thanks Extension

I need some help with the 'Thanks' extension - http://punbb.informer.com/forums/topic/ … on-thanks/

I am looking to relocate where the option to thank a post is shown.

I want to move it from here -
http://s16.postimg.org/og2cg57j9/Screenshot_1.png


To here -
http://s2.postimg.org/tscybrc1l/Screenshot_2.png

This must be done through either the php or the XML file. I will post both.

Re: Om Thanks Extension

Here is the PHP -

<?php
/**
 * om_thanks functions: database
 *
 * @copyright (C) 2014 PunBB
 * @license http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
 * @package om_thanks
 */

if (!defined('FORUM'))
    die();

// refreshes thanks cache for given posts
function om_thanks_rebuild_post_cache($post_id)
{
    global $forum_db;

    ($hook = get_hook('om_thanks_fn_rebuild_cache_start')) ? eval($hook) : null;

    // Fetch list of thanks for these posts
    $query = array(
        'SELECT'    => 'u.id, u.username',
        'FROM'        => 'users AS u',
        'JOINS'        => array(
            array(
                'INNER JOIN'    => 'om_thanks AS t',
                'ON'            => 't.user_id=u.id'
            )
        ),
        'WHERE'        => 't.post_id = '.$post_id,
        'ORDER BY'    => 't.added DESC, t.post_id, t.user_id',
    );
    ($hook = get_hook('om_thanks_fn_rebuild_cache_qr_get_users')) ? eval($hook) : null;
    $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);

    $post_cache = array();
    while (($cur_thank = $forum_db->fetch_assoc($result))) {
        $post_cache[$cur_thank['id']] = $cur_thank['username'];
    }

    // Update post cache one by one
    $query = array(
        'UPDATE'    => 'posts',
        'SET'        => 'om_thanks_cache = \''.$forum_db->escape(serialize($post_cache)).'\'',
        'WHERE'        => 'id = '.$post_id
    );
    ($hook = get_hook('om_thanks_fn_rebuild_cache_qr_update_cache')) ? eval($hook) : null;
    $forum_db->query_build($query) or error(__FILE__, __LINE__);
}

// refreshes number of thanks of specified user
function om_thanks_update_thanks_count($poster_id)
{
    global $forum_db;

    if ($poster_id <= 1)
        return;

    // Count post with thanks
    $query = array(
        'SELECT'    => 'count(*)',
        'FROM'        => 'om_thanks AS t',
        'WHERE'        => 'poster_id='.$poster_id
    );
    ($hook = get_hook('om_thanks_fn_rebuild_cache_qr_get_poster')) ? eval($hook) : null;
    $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
    $thanks_count = $forum_db->result($result);

    // Update number of thanks for that user
    $query = array(
        'UPDATE'    => 'users',
        'SET'        => 'om_thanks_count = '.$thanks_count,
        'WHERE'        => 'id = '.$poster_id
    );
    ($hook = get_hook('om_thanks_fn_rebuild_cache_qr_update_user')) ? eval($hook) : null;
    $forum_db->query_build($query) or error(__FILE__, __LINE__);
}

// delete thanks together with posts
function om_thanks_delete_post($posts)
{
    global $forum_db;

    if (!is_array($posts)) {
        $posts = array($posts);
    }

    ($hook = get_hook('om_thanks_fn_delete_post_start')) ? eval($hook) : null;

    // Count post with thanks
    $query = array(
        'SELECT'    => 'poster_id',
        'FROM'        => 'om_thanks AS t',
        'WHERE'        => 'post_id IN ('.implode(',', $posts).')',
    );
    $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
    $posters = array();
    while (($cur_thank = $forum_db->fetch_assoc($result))) {
        $posters[] = $cur_thank['poster_id'];
    }

    // Remove him/her from the online list (if they happen to be logged in)
    $query = array(
        'DELETE'    => 'om_thanks',
        'WHERE'        => 'post_id IN ('.implode(',', $posts).')'
    );

    ($hook = get_hook('om_thanks_fn_delete_post_qr_delete_post')) ? eval($hook) : null;
    $forum_db->query_build($query) or error(__FILE__, __LINE__);

    foreach($posters as $poster_id) {
        om_thanks_update_thanks_count($poster_id);
    }
}

// delete thanks together with topics
function om_thanks_delete_topic($topics)
{
    global $forum_db;

    if (!is_array($topics)) {
        $topics = array($topics);
    }

    ($hook = get_hook('om_thanks_fn_delete_post_start')) ? eval($hook) : null;

    // Count post with thanks
    $query = array(
        'SELECT'    => 't.post_id, t.poster_id',
        'FROM'        => 'om_thanks AS t',
        'JOINS'        => array(
            array(
                'INNER JOIN'    => 'posts AS p',
                'ON'        => 't.post_id = p.id'
            )
        ),
        'WHERE'        => 'topic_id IN ('.implode(',', $topics).')',
    );
    $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
    $posters = array();
    $posts = array();
    while (($cur_thank = $forum_db->fetch_assoc($result))) {
        $posters[$cur_thank['poster_id']] = $cur_thank['poster_id'];
        $posts[$cur_thank['post_id']] = $cur_thank['post_id'];
    }

    // Remove him/her from the online list (if they happen to be logged in)
    if ($posts) {
        $query = array(
            'DELETE'    => 'om_thanks',
            'WHERE'        => 'post_id IN ('.implode(',', $posts).')'
        );

        ($hook = get_hook('om_thanks_fn_delete_post_qr_delete_post')) ? eval($hook) : null;
        $forum_db->query_build($query) or error(__FILE__, __LINE__);
    }

    foreach($posters as $poster_id) {
        om_thanks_update_thanks_count($poster_id);
    }
}

// delete thanks together with users
function om_thanks_delete_user($user_id)
{
    global $forum_db;

    ($hook = get_hook('om_thanks_fn_delete_post_start')) ? eval($hook) : null;

    // Count post with thanks
    $query = array(
        'SELECT'    => 'post_id, poster_id',
        'FROM'        => 'om_thanks',
        'WHERE'        => 'user_id = '. $user_id,
    );
    $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
    $posters = array();
        $posts = array();
    while (($cur_thank = $forum_db->fetch_assoc($result))) {
            $posts[$cur_thank['post_id']] = $cur_thank['post_id'];
        $posters[$cur_thank['poster_id']] = $cur_thank['poster_id'];
    }

    // Remove him/her from the online list (if they happen to be logged in)
    $query = array(
        'DELETE'    => 'om_thanks',
        'WHERE'        => 'user_id = '. $user_id,
    );

    ($hook = get_hook('om_thanks_fn_delete_post_qr_delete_post')) ? eval($hook) : null;
    $forum_db->query_build($query) or error(__FILE__, __LINE__);

    foreach ($posts as $post_id) {
        om_thanks_rebuild_post_cache($post_id);
    }
    foreach ($posters as $poster_id) {
        om_thanks_update_thanks_count($poster_id);
    }
}

// handle nick change of user
function om_thanks_rebuild_user_cache($user_id)
{
    global $forum_db;

    ($hook = get_hook('om_thanks_fn_rebuild_user_start')) ? eval($hook) : null;

    // Find all posts made by this user
    $query = array(
        'SELECT'    => 'post_id',
        'FROM'        => 'om_thanks AS t',
        'WHERE'        => 'user_id='.$user_id
    );

    ($hook = get_hook('om_thanks_fn_rebuild_user_qr_get_user_posts')) ? eval($hook) : null;
    $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
    while ($cur_post = $forum_db->fetch_assoc($result))
    {
        om_thanks_rebuild_post_cache($cur_post['post_id']);
    }
}


define('OM_THANKS_FUNCTION_LOADED', 1);

Re: Om Thanks Extension

Here is the XML -

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE extension SYSTEM "ext-1.0.dtd">

<extension engine="1.0">
    <id>om_thanks</id>
    <title>Thanks</title>
    <version>0.0.2</version>
    <description>Say "thanks" below intresting posts.</description>
    <author>om</author>

    <minversion>1.4RC1</minversion>
    <maxtestedon>1.4.2</maxtestedon>

    <install>
        $schema = array(
            'FIELDS' => array(
                'post_id' => array(
                    'datatype' => 'INT(10) UNSIGNED',
                    'allow_null' => false,
                    'default' => '0'
                ),
                'user_id' => array(
                    'datatype' => 'INT(10) UNSIGNED',
                    'allow_null' => false,
                    'default' => '0'
                ),
                'poster_id' => array(
                    'datatype' => 'INT(10) UNSIGNED',
                    'allow_null' => false,
                    'default' => '0'
                )
            ),
            'PRIMARY KEY' => array('post_id', 'user_id')
        );
        $forum_db->create_table('om_thanks', $schema);

        if(!$forum_db->field_exists('posts', 'om_thanks_cache'))
            $forum_db->add_field('posts', 'om_thanks_cache', 'TEXT', false, '');

        if(!$forum_db->field_exists('users', 'om_thanks_count'))
            $forum_db->add_field('users', 'om_thanks_count', 'INT', false, '0');

        // Required from version 0.0.2
        if(!$forum_db->field_exists('om_thanks', 'added'))
            $forum_db->add_field('om_thanks', 'added', 'INT(10) UNSIGNED', false, '0');

        // Add extension options to the config table
        $om_images_config = array(
            'o_om_thanks_show_profile' => '1', // true
            'o_om_thanks_show_post' => '1', // true
            'o_om_thanks_allow_take' => '1', // true
            'o_om_thanks_max_thanks' => '50',
        );

        foreach ($om_images_config as $conf_name => $conf_value) {
            forum_config_add($conf_name, $conf_value);
        }
    </install>

    <uninstall><![CDATA[
        $forum_db->drop_field('posts', 'om_thanks_cache');

        $forum_db->drop_field('users', 'om_thanks_count');

        $forum_db->drop_table('om_thanks');

        // Delete extension options from the config
        forum_config_remove(array(
            'o_om_thanks_show_profile',
            'o_om_thanks_show_post',
            'o_om_thanks_allow_take',
            'o_om_thanks_max_thanks',
        ));
    ]]></uninstall>

    <hooks>
        <hook id="vt_pre_header_load"><![CDATA[
            // Incuding styles for om_thanks
            if ($forum_user['style'] != 'Oxygen' && file_exists($ext_info['path'].'/css/'.$forum_user['style'].'/om_thanks.min.css'))
                $forum_loader->add_css($ext_info['url'].'/css/'.$forum_user['style'].'/om_thanks.min.css', array('type' => 'url', 'media' => 'screen'));
            else
                $forum_loader->add_css($ext_info['url'].'/css/Oxygen/om_thanks.min.css', array('type' => 'url', 'media' => 'screen'));
            
            if (!isset($lang_om_thanks)) {
                if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php'))
                    include $ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php';
                else
                    include $ext_info['path'].'/lang/English/'.$ext_info['id'].'.php';
            }
        ]]></hook>

        <hook id="vt_qr_get_posts"><![CDATA[
            $query['SELECT'] .= ', p.om_thanks_cache, u.om_thanks_count';
        ]]></hook>

        <hook id="vt_post_loop_start"><![CDATA[
            if ($cur_post['om_thanks_cache']) {
                $cur_post['om_thanks_cache'] = unserialize($cur_post['om_thanks_cache']);
            } else {
                $cur_post['om_thanks_cache'] = array();
            }
        ]]></hook>

        <hook id="vt_row_pre_post_actions_merge"><![CDATA[
            if ($cur_post['poster_id'] > 1 && $cur_post['om_thanks_count'] > 0 && $forum_config['o_om_thanks_show_profile'] == '1')
                $forum_page['author_info']['om_thanks_count'] = '<li><span>'.$lang_om_thanks['Thanks count'].': <strong>'.forum_number_format($cur_post['om_thanks_count']).'</strong></span></li>';

            if (!$forum_user['is_guest'] && $cur_post['poster_id'] != $forum_user['id']) {
                if (!array_key_exists($forum_user['id'], $cur_post['om_thanks_cache'])) {
                    $forum_page['author_info']['om_thanks'] = '<li><span><a href="'.forum_link($forum_url['om_thanks_add'], array($cur_post['id'], generate_form_token('om_thanks_add'.$cur_post['id'].$forum_user['id']))).'">'.$lang_om_thanks['Give thanks'].'</a></span></li>';
                } elseif ($forum_config['o_om_thanks_allow_take'] == '1') {
                    $forum_page['author_info']['om_thanks'] = '<li><span><a href="'.forum_link($forum_url['om_thanks_del'], array($cur_post['id'], generate_form_token('om_thanks_del'.$cur_post['id'].$forum_user['id']))).'">'.$lang_om_thanks['Take thanks'].'</a></span></li>';
                }
            }
        ]]></hook>
    
        <hook id="vt_row_pre_display"><![CDATA[
            // List of thankers
            if ($cur_post['om_thanks_cache'] && $forum_config['o_om_thanks_show_post'] == '1')
            {
                $om_thanks_users = array();
                $om_thanks_more = 0;
                foreach ($cur_post['om_thanks_cache'] as $user_id => $username) {
                    $om_thanks_users[] = '<a href='.forum_link($forum_url['user'], $user_id).'>'.$username.'</a>';
                    
                    $om_thanks_more++;
                    if ($forum_config['o_om_thanks_max_thanks'] > 0 && $om_thanks_more >= $forum_config['o_om_thanks_max_thanks']) {
                        break;
                    }
                }
                $om_thanks_more = (count($cur_post['om_thanks_cache']) > $om_thanks_more ? count($cur_post['om_thanks_cache']) - $om_thanks_more : 0);

                $forum_page['post_options']['om_thanks'] = '<p class="post-om_thanks">'.$lang_om_thanks['Thankers'].': '.implode(', ', $om_thanks_users)
                    .($om_thanks_more ? ' '.sprintf($lang_om_thanks['and more'], $om_thanks_more) : '').'</p>';
            }
        ]]></hook>

        <hook id="mi_new_action"><![CDATA[
            if (isset($_GET['om_thanks_add']))
            {
                if ($forum_user['is_guest'])
                    message($lang_common['No permission']);

                $post_id = intval($_GET['om_thanks_add']);
                if ($post_id < 1)
                    message($lang_common['Bad request']);

                // We validate the CSRF token. If it's set in POST and we're at this point, the token is valid.
                // If it's in GET, we need to make sure it's valid.
                if (!isset($_POST['csrf_token']) && (!isset($_GET['csrf_token']) || $_GET['csrf_token'] !== generate_form_token('om_thanks_add'.$post_id.$forum_user['id'])))
                    csrf_confirm_form();

                // Get poster id
                $query = array(
                    'SELECT'    => 'p.poster_id',
                    'FROM'        => 'posts AS p',
                    'WHERE'        => 'id = '.$post_id
                );
                ($hook = get_hook('om_thanks_fn_rebuild_cache_qr_get_poster')) ? eval($hook) : null;
                $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
                $poster_id = $forum_db->result($result);

                // don't thank yourself
                if ($poster_id == $forum_user['id'])
                    message($lang_common['Bad request']);

                if (!isset($lang_om_thanks)) {
                    if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php'))
                        include $ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php';
                    else
                        include $ext_info['path'].'/lang/English/'.$ext_info['id'].'.php';
                }

                // Fetch some info about the forum
                $query = array(
                    'SELECT'    => 'COUNT(t.post_id)',
                    'FROM'        => 'om_thanks AS t',
                    'WHERE'        => 't.post_id = '.$post_id.' AND t.user_id='.$forum_user['id'],
                );

                ($hook = get_hook('mi_om_thanks_add_qr_get_count')) ? eval($hook) : null;
                $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
                $om_thanks_count = $forum_db->result($result);
                if ($om_thanks_count)
                    message($lang_common['Bad request']);

                $query = array(
                    'INSERT'    => 'post_id, user_id, poster_id, added',
                    'INTO'        => 'om_thanks',
                    'VALUES'    => $post_id.', '.$forum_user['id'].', '.$poster_id.', '.time(),
                );
                ($hook = get_hook('mi_om_thanks_add_qr_add_thanks')) ? eval($hook) : null;
                $forum_db->query_build($query) or error(__FILE__, __LINE__);

                if (!defined('OM_THANKS_FUNCTION_LOADED')) {
                    require $ext_info['path'] . '/functions.php';
                }

                om_thanks_rebuild_post_cache($post_id);

                if ($poster_id > 1)
                    om_thanks_update_thanks_count($poster_id);

                redirect(forum_link($forum_url['post'], $post_id), $lang_om_thanks['Thanks added']);
            }

            elseif (isset($_GET['om_thanks_del']))
            {
                if ($forum_config['o_om_thanks_allow_take'] != '1' || $forum_user['is_guest'])
                    message($lang_common['No permission']);

                $post_id = intval($_GET['om_thanks_del']);
                if ($post_id < 1)
                    message($lang_common['Bad request']);

                // We validate the CSRF token. If it's set in POST and we're at this point, the token is valid.
                // If it's in GET, we need to make sure it's valid.
                if (!isset($_POST['csrf_token']) && (!isset($_GET['csrf_token']) || $_GET['csrf_token'] !== generate_form_token('om_thanks_del'.$post_id.$forum_user['id'])))
                    csrf_confirm_form();

                // Get poster id
                $query = array(
                    'SELECT'    => 'p.poster_id',
                    'FROM'        => 'posts AS p',
                    'WHERE'        => 'id = '.$post_id
                );
                ($hook = get_hook('om_thanks_fn_rebuild_cache_qr_get_poster')) ? eval($hook) : null;
                $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
                $poster_id = $forum_db->result($result);

                // don't thank yourself
                if ($poster_id == $forum_user['id'])
                    message($lang_common['Bad request']);

                if (!isset($lang_om_thanks)) {
                    if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php'))
                        include $ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php';
                    else
                        include $ext_info['path'].'/lang/English/'.$ext_info['id'].'.php';
                }

                $query = array(
                    'DELETE'    => 'om_thanks',
                    'WHERE'        => 'post_id = '.$post_id.' AND user_id='.$forum_user['id'],
                );
                $forum_db->query_build($query) or error(__FILE__, __LINE__);

                if (!defined('OM_THANKS_FUNCTION_LOADED')) {
                    require $ext_info['path'] . '/functions.php';
                }

                om_thanks_rebuild_post_cache($post_id);

                if ($poster_id > 1)
                    om_thanks_update_thanks_count($poster_id);

                redirect(forum_link($forum_url['post'], $post_id), $lang_om_thanks['Thanks taken']);
            }
        ]]></hook>

        <hook id="pf_change_details_username_changed"><![CDATA[
            // don't forget to update thanks when username changed
            if (!defined('OM_THANKS_FUNCTION_LOADED'))
                require $ext_info['path'] . '/functions.php';

            om_thanks_rebuild_user_cache($id);
        ]]></hook>

        <hook id="fn_delete_user_qr_delete_user"><![CDATA[
            // don't forget to update thanks when deleting user
            if (!defined('OM_THANKS_FUNCTION_LOADED'))
                require $ext_info['path'] . '/functions.php';

            om_thanks_delete_user($user_id);
        ]]></hook>

        <hook id="mr_confirm_delete_posts_qr_delete_posts"><![CDATA[
            // don't forget to remove thanks when deleting posts
            if (!defined('OM_THANKS_FUNCTION_LOADED'))
                require $ext_info['path'] . '/functions.php';

            om_thanks_delete_post($posts);
        ]]></hook>
        
        <hook id="fn_delete_post_qr_delete_post"><![CDATA[
            // don't forget to remove thanks when deleting posts
            if (!defined('OM_THANKS_FUNCTION_LOADED'))
                require $ext_info['path'] . '/functions.php';

            om_thanks_delete_post($post_id);
        ]]></hook>
        
        <hook id="mr_confirm_delete_topics_qr_get_deleted_posts"><![CDATA[
            // don't forget to remove thanks when deleting posts
            if (!defined('OM_THANKS_FUNCTION_LOADED'))
                require $ext_info['path'] . '/functions.php';

            om_thanks_delete_topic($topics);
        ]]></hook>
        
        <hook id="ca_fn_prune_qr_prune_posts"><![CDATA[
            // don't forget to remove thanks when deleting posts
            if (!defined('OM_THANKS_FUNCTION_LOADED'))
                require $ext_info['path'] . '/functions.php';

            om_thanks_delete_topic($topic_ids);
        ]]></hook>
        
        <hook id="fn_delete_topic_qr_delete_topic_posts"><![CDATA[
            // don't forget to remove thanks when deleting posts
            if (!defined('OM_THANKS_FUNCTION_LOADED'))
                require $ext_info['path'] . '/functions.php';

            om_thanks_delete_topic($topic_id);
        ]]></hook>

        <hook id="pf_change_details_about_pre_header_load, pf_view_details_pre_header_load"><![CDATA[
            // don't forget to update thanks when username changed
            if (!defined('OM_THANKS_FUNCTION_LOADED'))
                require $ext_info['path'] . '/functions.php';

            if (!isset($lang_om_thanks)) {
                if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php'))
                    include $ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php';
                else
                    include $ext_info['path'].'/lang/English/'.$ext_info['id'].'.php';
            }

            if ($forum_config['o_om_thanks_show_profile'] == '1')
                $forum_page['user_info']['om_thanks'] = '<li><span>'.$lang_om_thanks['Thanks count'].': <strong>'.forum_number_format($user['om_thanks_count']).'</strong></span></li>';

            if ($forum_config['o_om_thanks_show_profile'] == '1' && $forum_user['g_search'] == '1') {
                $forum_page['user_activity']['om_thanks'] = '<li><a href="'.forum_link($forum_url['search_om_thanks'], $id).'">'.sprintf($lang_om_thanks['View user thanks'], forum_htmlencode($user['username'])).'</a></li>';
            }
        ]]></hook>

        <hook id="aop_features_avatars_fieldset_end"><![CDATA[
            // forum settings

            // load language file
            if (!isset($lang_om_thanks))
            {
                if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php'))
                    include $ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php';
                else
                    include $ext_info['path'].'/lang/English/'.$ext_info['id'].'.php';
            }
                    
            $forum_page['group_count'] = $forum_page['item_count'] = 0;
?>
            <div class="content-head">
                <h2 class="hn"><span><?php echo $lang_om_thanks['Thanks settings'] ?></span></h2>
            </div>
            <fieldset class="frm-group group<?php echo ++$forum_page['group_count'] ?>">
                <legend class="group-legend"><span><?php echo $lang_om_thanks['Features title'] ?></span></legend>


                <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
                    <div class="sf-box text">
                        <label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_om_thanks['Max thanks'] ?></span><small><?php echo $lang_om_thanks['Max thanks info'] ?></small></label><br />
                        <span class="fld-input"><input type="text" id="fld<?php echo $forum_page['fld_count'] ?>" name="form[om_thanks_max_thanks]" size="6" maxlength="6" value="<?php echo $forum_config['o_om_thanks_max_thanks'] ?>" /></span>
                    </div>
                </div>

                <fieldset class="mf-set set<?php echo ++$forum_page['item_count'] ?>">
                    <legend><span><?php echo $lang_om_thanks['Additional options'] ?></span></legend>
                    <div class="mf-box">
                        <div class="mf-item">
                            <span class="fld-input"><input type="checkbox" id="fld<?php echo ++$forum_page['fld_count'] ?>" name="form[om_thanks_show_profile]" value="1"<?php if ($forum_config['o_om_thanks_show_profile'] == '1') echo ' checked="checked"' ?> /></span>
                            <label for="fld<?php echo $forum_page['fld_count'] ?>"><?php echo $lang_om_thanks['Show profile'] ?></label>
                        </div>
                    </div>
                    <div class="mf-box">
                        <div class="mf-item">
                            <span class="fld-input"><input type="checkbox" id="fld<?php echo ++$forum_page['fld_count'] ?>" name="form[om_thanks_show_post]" value="1"<?php if ($forum_config['o_om_thanks_show_post'] == '1') echo ' checked="checked"' ?> /></span>
                            <label for="fld<?php echo $forum_page['fld_count'] ?>"><?php echo $lang_om_thanks['Show post'] ?></label>
                        </div>
                    </div>
                    <div class="mf-box">
                        <div class="mf-item">
                            <span class="fld-input"><input type="checkbox" id="fld<?php echo ++$forum_page['fld_count'] ?>" name="form[om_thanks_allow_take]" value="1"<?php if ($forum_config['o_om_thanks_allow_take'] == '1') echo ' checked="checked"' ?> /></span>
                            <label for="fld<?php echo $forum_page['fld_count'] ?>"><?php echo $lang_om_thanks['Allow take'] ?></label>
                        </div>
                    </div>
                </fieldset>
<?php ($hook = get_hook('om_thanks_aop_fieldset_end')) ? eval($hook) : null; ?>
            </fieldset>
            <?php
        ]]></hook>
    
        <hook id="sf_fn_no_search_results_start"><![CDATA[
            if ($action == 'om_thanks') {
                if (!isset($lang_om_thanks)) {
                    if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php'))
                        include $ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php';
                    else
                        include $ext_info['path'].'/lang/English/'.$ext_info['id'].'.php';
                }
                message($lang_om_thanks['No user posts'], $forum_page['search_again'], $lang_search['Posts by user']);
                return true;
            }
        ]]></hook>

        <hook id="aop_features_validation"><![CDATA[
            // validate forum settings
            $form['om_thanks_max_thanks'] = (!isset($form['om_thanks_max_thanks']) || (int) $form['om_thanks_max_thanks'] <= 0) ? '0' : (string)(int) $form['om_thanks_max_thanks'];

            if (!isset($form['om_thanks_show_profile']) || $form['om_thanks_show_profile'] != '1')
                $form['om_thanks_show_profile'] = '0';

            if (!isset($form['om_thanks_show_post']) || $form['om_thanks_show_post'] != '1')
                $form['om_thanks_show_post'] = '0';

            if (!isset($form['om_thanks_allow_take']) || $form['om_thanks_allow_take'] != '1')
                $form['om_thanks_allow_take'] = '0';

            ($hook = get_hook('om_thanks_aop_validation_end')) ? eval($hook) : null;
        ]]></hook>

        <hook id="sf_fn_validate_actions_start"><![CDATA[
            // add om_thanks to valid search actions
            $valid_actions[] = 'om_thanks';
        ]]></hook>

        <hook id="se_additional_quicksearch_variables"><![CDATA[
            // default value for om_thanks search = one day
            if ($action == 'om_thanks') {
                $value = isset($_GET['user_id']) ? intval($_GET['user_id']) : 0;
                if ($value < 2)
                    message($lang_common['Bad request']);
            }
        ]]></hook>

        <hook id="sf_fn_generate_action_search_query_end"><![CDATA[
            // generate_action_search_query
            // show all posts made by our friends in the last day
            if ($action == 'om_thanks') {
                $query = array(
                    'SELECT'    => 'DISTINCT p.id AS pid, p.poster AS pposter, p.posted AS pposted, p.poster_id, p.message, p.hide_smilies, t.id AS tid, t.poster, t.subject, t.first_post_id, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.forum_id, f.forum_name',
                    'FROM'        => 'posts AS p',
                    'JOINS'        => array(
                        array(
                            'INNER JOIN'    => 'topics AS t',
                            'ON'            => 't.id=p.topic_id'
                        ),
                        array(
                            'INNER JOIN'    => 'forums AS f',
                            'ON'            => 'f.id=t.forum_id'
                        ),
                        array(
                            'LEFT JOIN'        => 'forum_perms AS fp',
                            'ON'            => '(fp.forum_id=f.id AND fp.group_id='.$forum_user['g_id'].')'
                        ),
                        array(
                            'INNER JOIN'        => 'om_thanks AS ot',
                            'ON'            => 'p.id=ot.post_id',
                        )
                    ),
                    'WHERE'        => '(fp.read_forum IS NULL OR fp.read_forum=1) AND ot.poster_id='.$value,
                    'ORDER BY'    => 'pposted DESC'
                );

                $url_type = $forum_url['search_om_thanks'];
                $search_id = $value;
                $show_as = 'posts';
                ($hook = get_hook('om_thanks_generate_action_qr_search')) ? eval($hook) : null;
            }
        ]]></hook>

        <hook id="sf_fn_generate_search_crumbs_start"><![CDATA[
            if ($action == 'om_thanks') {
                if (!isset($lang_om_thanks)) {
                    if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php'))
                        include $ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php';
                    else
                        include $ext_info['path'].'/lang/English/'.$ext_info['id'].'.php';
                }

                $forum_page['crumbs'][] = sprintf($lang_om_thanks['Thanks by'], $search_set[0]['pposter']);
                $forum_page['items_info'] = generate_items_info($lang_search['Posts found'], ($forum_page['start_from'] + 1), $num_hits);
                $forum_page['main_head_options']['user_posts'] = '<span'.(empty($forum_page['main_head_options']) ? ' class="first-item"' : '').'><a href="'.forum_link($forum_url['search_user_posts'], $search_id).'">'.sprintf($lang_search['Posts by'], forum_htmlencode($search_set[0]['poster'])).'</a></span>';
                $forum_page['main_head_options']['defined_search'] = '<span'.(empty($forum_page['main_head_options']) ? ' class="first-item"' : '').'><a href="'.forum_link($forum_url['search']).'">'.$lang_search['User defined search'].'</a></span>';
                return true;
            }
        ]]></hook>

        <hook id="co_modify_url_scheme"><![CDATA[
            if ($forum_config['o_sef'] != 'Default' && file_exists($ext_info['path'].'/url/'.$forum_config['o_sef'].'.php'))
                require $ext_info['path'].'/url/'.$forum_config['o_sef'].'.php';
            else
                require $ext_info['path'].'/url/Default.php';

        ]]></hook>

        <hook id="re_rewrite_rules"><![CDATA[
            $forum_rewrite_rules['/^om_thanks_(add|del)[\/_-]?([0-9]+)[\/_-]?([a-z0-9]+)?(\.html?|\/)?$/i'] = 'misc.php?om_thanks_$1=$2&csrf_token=$3';
            $forum_rewrite_rules['/^search[\/_-]?(om_thanks)[\/_-]([0-9]+)(\.html?|\/)?$/i'] = 'search.php?action=om_thanks&user_id=$2';
            $forum_rewrite_rules['/^search[\/_-]?(om_thanks)[\/_-]([0-9]+)[\/_-]p(age)?[\/_-]?([0-9]+)(\.html?|\/)?$/i'] = 'search.php?action=om_thanks&user_id=$2&p=$4';

            ($hook = get_hook('om_thanks_after_rewrite_rules_set')) ? eval($hook) : null;
        ]]></hook>

    </hooks>
</extension>

Re: Om Thanks Extension

BUMP

Is anybody still hanging around these days?

Re: Om Thanks Extension

BUMP

Still looking for some help on this one.

Re: Om Thanks Extension

outweigh the need to code on another hook.

that is, the hook is in charge of the output information in the signature.

Re: Om Thanks Extension

PanBB.Ru wrote:

outweigh the need to code on another hook.

that is, the hook is in charge of the output information in the signature.

Thanks for the response PanBB.Ru.

So the hooks give the relation to where it ends up on the post?

How do I identify the differences in the hooks as there are 3 separate instances in the XML?

Re: Om Thanks Extension

it is hook

       <hook id="vt_row_pre_display"><![CDATA[
            // List of thankers
            if ($cur_post['om_thanks_cache'] && $forum_config['o_om_thanks_show_post'] == '1')
            {
                $om_thanks_users = array();
                $om_thanks_more = 0;
                foreach ($cur_post['om_thanks_cache'] as $user_id => $username) {
                    $om_thanks_users[] = '<a href='.forum_link($forum_url['user'], $user_id).'>'.$username.'</a>';
                    
                    $om_thanks_more++;
                    if ($forum_config['o_om_thanks_max_thanks'] > 0 && $om_thanks_more >= $forum_config['o_om_thanks_max_thanks']) {
                        break;
                    }
                }
                $om_thanks_more = (count($cur_post['om_thanks_cache']) > $om_thanks_more ? count($cur_post['om_thanks_cache']) - $om_thanks_more : 0);

                $forum_page['post_options']['om_thanks'] = '<p class="post-om_thanks">'.$lang_om_thanks['Thankers'].': '.implode(', ', $om_thanks_users)
                    .($om_thanks_more ? ' '.sprintf($lang_om_thanks['and more'], $om_thanks_more) : '').'</p>';
            }
        ]]></hook>

replace to

        <hook id="vt_row_pre_post_actions_merge"><![CDATA[
            if ($cur_post['poster_id'] > 1 && $cur_post['om_thanks_count'] > 0 && $forum_config['o_om_thanks_show_profile'] == '1')
                $forum_page['post_actions']['om_thanks_count'] = '<li><span>'.$lang_om_thanks['Thanks count'].': <strong>'.forum_number_format($cur_post['om_thanks_count']).'</strong></span></li>';

            if (!$forum_user['is_guest'] && $cur_post['poster_id'] != $forum_user['id']) 
            {
                if (!array_key_exists($forum_user['id'], $cur_post['om_thanks_cache'])) 
                {
                    $forum_page['post_actions']['om_thanks'] = '<li><span><a href="'.forum_link($forum_url['om_thanks_add'], array($cur_post['id'], generate_form_token('om_thanks_add'.$cur_post['id'].$forum_user['id']))).'">'.$lang_om_thanks['Give thanks'].'</a></span></li>';
                } 
                else if ($forum_config['o_om_thanks_allow_take'] == '1') 
                {
                    $forum_page['post_actions']['om_thanks'] = '<li><span><a href="'.forum_link($forum_url['om_thanks_del'], array($cur_post['id'], generate_form_token('om_thanks_del'.$cur_post['id'].$forum_user['id']))).'">'.$lang_om_thanks['Take thanks'].'</a></span></li>';
                }
            }
        ]]></hook>

Re: Om Thanks Extension

PanBB.Ru wrote:

it is hook

       <hook id="vt_row_pre_display"><![CDATA[
            // List of thankers
            if ($cur_post['om_thanks_cache'] && $forum_config['o_om_thanks_show_post'] == '1')
            {
                $om_thanks_users = array();
                $om_thanks_more = 0;
                foreach ($cur_post['om_thanks_cache'] as $user_id => $username) {
                    $om_thanks_users[] = '<a href='.forum_link($forum_url['user'], $user_id).'>'.$username.'</a>';
                    
                    $om_thanks_more++;
                    if ($forum_config['o_om_thanks_max_thanks'] > 0 && $om_thanks_more >= $forum_config['o_om_thanks_max_thanks']) {
                        break;
                    }
                }
                $om_thanks_more = (count($cur_post['om_thanks_cache']) > $om_thanks_more ? count($cur_post['om_thanks_cache']) - $om_thanks_more : 0);

                $forum_page['post_options']['om_thanks'] = '<p class="post-om_thanks">'.$lang_om_thanks['Thankers'].': '.implode(', ', $om_thanks_users)
                    .($om_thanks_more ? ' '.sprintf($lang_om_thanks['and more'], $om_thanks_more) : '').'</p>';
            }
        ]]></hook>

replace to

        <hook id="vt_row_pre_post_actions_merge"><![CDATA[
            if ($cur_post['poster_id'] > 1 && $cur_post['om_thanks_count'] > 0 && $forum_config['o_om_thanks_show_profile'] == '1')
                $forum_page['post_actions']['om_thanks_count'] = '<li><span>'.$lang_om_thanks['Thanks count'].': <strong>'.forum_number_format($cur_post['om_thanks_count']).'</strong></span></li>';

            if (!$forum_user['is_guest'] && $cur_post['poster_id'] != $forum_user['id']) 
            {
                if (!array_key_exists($forum_user['id'], $cur_post['om_thanks_cache'])) 
                {
                    $forum_page['post_actions']['om_thanks'] = '<li><span><a href="'.forum_link($forum_url['om_thanks_add'], array($cur_post['id'], generate_form_token('om_thanks_add'.$cur_post['id'].$forum_user['id']))).'">'.$lang_om_thanks['Give thanks'].'</a></span></li>';
                } 
                else if ($forum_config['o_om_thanks_allow_take'] == '1') 
                {
                    $forum_page['post_actions']['om_thanks'] = '<li><span><a href="'.forum_link($forum_url['om_thanks_del'], array($cur_post['id'], generate_form_token('om_thanks_del'.$cur_post['id'].$forum_user['id']))).'">'.$lang_om_thanks['Take thanks'].'</a></span></li>';
                }
            }
        ]]></hook>

Hmmm....    this doesn't work. Nothing changes.

10 (edited by PanBB.Ru 2016-02-04 10:07)

Re: Om Thanks Extension

then upgrade or reinstall the extension hooks .
I checked and I have worked.

Attention! After reinstalling all thanks zeroed!
First , try to update the hooks .

Good luck  )

Re: Om Thanks Extension

PanBB.Ru wrote:

then upgrade or reinstall the extension hooks .
I checked and I have worked.

Attention! After reinstalling all thanks zeroed!
First , try to update the hooks .

Good luck  )

Thanks! I got it working now.

Something else I am trying to do is create a 'new post' feed for a sidebar in my forums. I've looked at the Punbb guide on how to do this but it is kind of vague in its interpretation.

Is there a simple way to do this?

12

Re: Om Thanks Extension

paulcambull wrote:

Something else I am trying to do is create a 'new post' feed for a sidebar in my forums. I've looked at the Punbb guide on how to do this but it is kind of vague in its interpretation.

Is there a simple way to do this?

Hi Paul,

You could add

<!-- forum_include "http://yourforum.tld/extern-1.php" -->

in yourforum.tld/include/template/maintenance.tpl

Forum, Art, Architecture, Passion.

Have you ever visited the textpattern forum?

Re: Om Thanks Extension

colak wrote:
paulcambull wrote:

Something else I am trying to do is create a 'new post' feed for a sidebar in my forums. I've looked at the Punbb guide on how to do this but it is kind of vague in its interpretation.

Is there a simple way to do this?

Hi Paul,

You could add

<!-- forum_include "http://yourforum.tld/extern-1.php" -->

in yourforum.tld/include/template/maintenance.tpl

Thanks colak, I'm going to try this out today. smile

Another question - is there a way to make it so that someone could copy a spreadsheet into a post and it would line up in correctly in columns? We have a lot of analytical style information that gets presented and being able to copy directly from microsoft word or apache open office would be a huge asset.

Re: Om Thanks Extension

Is there anybody that has successfully made it so that they can post spreadsheets and tables in their forums?

15 (edited by PanBB.Ru 2016-02-23 21:42)

Re: Om Thanks Extension

you want to make a backup copy of the table thanks?
and then to restore it ?

Re: Om Thanks Extension

PanBB.Ru wrote:

you want to make a backup copy of the table thanks?
and then to restore it ?

Sorry for the confusion, but no.

I am trying to copy and paste a spreadsheet from Microsoft Office into a post and have it format correctly so that the information is easily readable.

I have a sports forum and a lot of people include statistics in their posts.

Basically, I need it to show up in the post like it does in this screenshot -

http://www.sportsbookbonus.ca/wp-content/uploads/Screenshot-50.png

Re: Om Thanks Extension

I did not try bbcode_table by Abir?

Re: Om Thanks Extension

PanBB.Ru wrote:

I did not try bbcode_table by Abir?


Thanks Pan, as always you are a huge help!

Re: Om Thanks Extension

paulcambull wrote:
colak wrote:
paulcambull wrote:

Something else I am trying to do is create a 'new post' feed for a sidebar in my forums. I've looked at the Punbb guide on how to do this but it is kind of vague in its interpretation.

Is there a simple way to do this?

Hi Paul,

You could add

<!-- forum_include "http://yourforum.tld/extern-1.php" -->

in yourforum.tld/include/template/maintenance.tpl

Thanks colak, I'm going to try this out today. smile

I'm still struggling to get this to work.

Are there additional steps that you did not post?