[DEV] Thank Post Mod (hide MOD compatible ) 0.2.0

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment!
Get Involved
Locked
User avatar
Garettyrox
Registered User
Posts: 94
Joined: Mon Feb 18, 2008 9:28 pm
Location: Missouri, USA
Contact:

Re: [DEV] Thank Post Mod (hide MOD compatible ) 0.2.0

Post by Garettyrox »

Mahoney wrote:Hello
AquariusPL wrote:so... if someone gave a 'thanks' will see hidden message
but... when he comes to the topic later and look up hidden message - is still hidden, cause

Try this
  • SQL:

    Code: Select all

    ALTER TABLE `phpbb_thanks` ADD `topic_id` mediumint(8) unsigned NOT NULL DEFAULT '0';
  • open viewtopic.php
    • Search:

      Code: Select all

      // Check if the topic viewer has posted in a topic
      $unhide = false;
      $sql = 'SELECT post_thanked
         FROM ' . POSTS_TABLE . '
         WHERE post_id = ' . $post_id;
      $result = $db->sql_query($sql);
      $post_thanked = $db->sql_fetchfield('post_thanked');
      $db->sql_freeresult($result);
      if ($user->data['user_id'] != ANONYMOUS)
      {
         // If moderator or admin, skip reply check, auto unhide
         if ($auth->acl_get('m_', $forum_id))
         {
            $unhide = true;
         }
         
         else if ($post_thanked > 0)
         {
            $unhide = true;
         }
         else
         {
         $sql = "SELECT poster_id, topic_id
            FROM " . POSTS_TABLE . "
            WHERE topic_id = $topic_id
            AND poster_id = " . $user->data['user_id'];
      
         $result = $db->sql_query($sql);
         $unhide = $db->sql_affectedrows($result) ? true : false;
         $db->sql_freeresult($result);
         }
      }
      Replace with

      Code: Select all

      // Unhide Check
      $unhide = false;
      if ($user->data['user_id'] != ANONYMOUS)
      {
         // If moderator or admin, skip reply check, auto unhide
         if ($auth->acl_get('m_', $forum_id))
         {
            $unhide = true;
         }
         else
         {
      	   // Check if the topic viewer has said thanks in that topic
      	   $sql = "SELECT topic_id, thanks_from
      		  FROM " . THANKS_TABLE . "
      		  WHERE topic_id = $topic_id
      		  AND thanks_from = " . $user->data['user_id'];
      
      	   $result = $db->sql_query($sql);
      	   $unhide = $db->sql_affectedrows($result) ? true : false;
      	   $db->sql_freeresult($result);
      
      	   // Check if the topic viewer has posted in that topic
      	   if ($unhide == false) 
      	   {
      	      $sql = "SELECT poster_id, topic_id
      		     FROM " . POSTS_TABLE . "
      		     WHERE topic_id = $topic_id
      		     AND poster_id = " . $user->data['user_id'];
      
      	      $result = $db->sql_query($sql);
      	      $unhide = $db->sql_affectedrows($result) ? true : false;
      	      $db->sql_freeresult($result);
             }
         }
      }
    • Search:

      Code: Select all

      'U_THANKS'			=> (!$give_thanks) ? append_sid("{$phpbb_root_path}thanks.$phpEx", 'p=' . $row['post_id'] . '&mode=thanks') : append_sid("{$phpbb_root_path}thanks.$phpEx", 'p=' . $row['post_id'] . '&mode=remove'),
      Replace with:

      Code: Select all

      'U_THANKS'			=> (!$give_thanks) ? append_sid("{$phpbb_root_path}thanks.$phpEx", 'p=' . $row['post_id'] . '&t=' . $topic_id .'&mode=thanks') : append_sid("{$phpbb_root_path}thanks.$phpEx", 'p=' . $row['post_id'] . '&mode=remove'),
  • thanks.php öffnen.
    • Search:

      Code: Select all

      $post_id	= request_var('p', 0);
      Add after:

      Code: Select all

      $topic_id	= request_var('t', 0);
    • Search:

      Code: Select all

      'post_id'		=> $post_id,
      Add after:

      Code: Select all

      'topic_id'		=> $topic_id,
[/size]
I have enabled this MOD on all of my forums. I still cannot see the Thank Post image or anything.
Clear the cache.


best regards Mahoney
I tried that. It didn't work.
User avatar
Mahoney
Registered User
Posts: 196
Joined: Sun Mar 16, 2008 4:07 pm
Contact:

Re: [DEV] Thank Post Mod (hide MOD compatible ) 0.2.0

Post by Mahoney »

Hello
I tried that. It didn't work.
Have you clear the cache?


best regards Mahoney
User avatar
Garettyrox
Registered User
Posts: 94
Joined: Mon Feb 18, 2008 9:28 pm
Location: Missouri, USA
Contact:

Re: [DEV] Thank Post Mod (hide MOD compatible ) 0.2.0

Post by Garettyrox »

Mahoney wrote:Hello
I tried that. It didn't work.
Have you clear the cache?


best regards Mahoney
That's what you just told me to do. :)

Here is what I have done:
  • Installed MOD, did everything the install file said to.
  • Ran the db_install.php file.
  • Enabled this MOD on all forums.
  • Cleared the Cache, Refreshed templates,imagesets, and themes.
  • Deleted all files in root/cache except for .htaccess and index.php
There may be more.
User avatar
spaceace
Registered User
Posts: 1999
Joined: Wed Jan 30, 2008 8:50 pm
Contact:

Re: [DEV] Thank Post Mod (hide MOD compatible ) 0.2.0

Post by spaceace »

Garettyrox wrote:Here is what I have done:
  • Installed MOD, did everything the install file said to.
  • Ran the db_install.php file.
  • Enabled this MOD on all forums.
  • Cleared the Cache, Refreshed templates,imagesets, and themes.
  • Deleted all files in root/cache except for .htaccess and index.php
There may be more.
i don't know if this will have anything to do with it or not, but when you uploaded files to your language folder, do you happen to have a en_us folder?
AquariusPL
Registered User
Posts: 16
Joined: Mon Aug 25, 2008 10:31 am

Re: [DEV] Thank Post Mod (hide MOD compatible ) 0.2.0

Post by AquariusPL »

yep, it's working Mahoney - checked, thank you very much :)
that I was thinking... needed new column in database
I was rather thinking about post based thanks, U know - I thanked to user C and only user C's hidden message is showing up in this one topic, hidden message user A and B are still hidden
that would be wonderful :)
User avatar
Garettyrox
Registered User
Posts: 94
Joined: Mon Feb 18, 2008 9:28 pm
Location: Missouri, USA
Contact:

Re: [DEV] Thank Post Mod (hide MOD compatible ) 0.2.0

Post by Garettyrox »

spaceace wrote:
Garettyrox wrote:Here is what I have done:
  • Installed MOD, did everything the install file said to.
  • Ran the db_install.php file.
  • Enabled this MOD on all forums.
  • Cleared the Cache, Refreshed templates,imagesets, and themes.
  • Deleted all files in root/cache except for .htaccess and index.php
There may be more.
i don't know if this will have anything to do with it or not, but when you uploaded files to your language folder, do you happen to have a en_us folder?
Yes, but I only have en enabled on my forum. Not en_us.
hdhieu
Registered User
Posts: 33
Joined: Tue Apr 07, 2009 3:37 am

Re: [DEV] Thank Post Mod (hide MOD compatible ) 0.2.0

Post by hdhieu »

I installed it successful before, but after I backed up my forum because of some other problems, I couldn't use this mod anymore. when I edit forum, and enable thanks_mod, it has an error.

I tried to removed everything and then reinstalled it, but it said that phpbb_thanks already exist.

How can I fix that, any ideas please?

Code: Select all

SQL ERROR [ mysql4 ]

Unknown column 'enable_thanks' in 'field list' [1054]

SQL

UPDATE phpbb_forums SET parent_id = 3, forum_type = 1, forum_status = 0, forum_parents = '', forum_name = 'm-HD movies', forum_link = '', forum_desc = 'Post all m-HD movies here.', forum_desc_uid = '', forum_desc_options = 7, forum_desc_bitfield = '', forum_rules = '', forum_rules_uid = '', forum_rules_options = 7, forum_rules_bitfield = '', forum_rules_link = '', forum_image = '', forum_style = 0, display_subforum_list = 1, display_on_index = 1, forum_topics_per_page = 0, enable_indexing = 1, enable_icons = 1, enable_prune = 0, enable_thanks = 1, prune_days = 7, prune_viewed = 7, prune_freq = 1, forum_flags = 32 WHERE forum_id = 4

BACKTRACE


FILE: includes/db/mysql.php
LINE: 174
CALL: dbal->sql_error()

FILE: includes/acp/acp_forums.php
LINE: 1256
CALL: dbal_mysql->sql_query()

FILE: includes/acp/acp_forums.php
LINE: 182
CALL: acp_forums->update_forum_data()

FILE: includes/functions_module.php
LINE: 507
CALL: acp_forums->main()

FILE: adm/index.php
LINE: 74
CALL: p_master->load_active()
hdhieu
Registered User
Posts: 33
Joined: Tue Apr 07, 2009 3:37 am

Re: [DEV] Thank Post Mod (hide MOD compatible ) 0.2.0

Post by hdhieu »

Problem above was solved, I dropped the table in database, and then reinstalled it. Now it works like a charm :)
User avatar
Mahoney
Registered User
Posts: 196
Joined: Sun Mar 16, 2008 4:07 pm
Contact:

Re: [DEV] Thank Post Mod (hide MOD compatible ) 0.2.0

Post by Mahoney »

Hello spaceace
Forget the fix from here -> http://www.phpbb.com/community/viewtopi ... 5#p9157655.
It was not optimal.


Here is a better solution for the "undefined index" problem.


Open includes/functions_user.php

Search

Code: Select all

function user_delete($mode, $user_id, $post_username = false)
{
    global $cache, $config, $db, $user, $auth;
    global $phpbb_root_path, $phpEx;  
Add after

Code: Select all

//Begin Thanks Post MOD
    $sql = 'UPDATE ' . THANKS_TABLE . '
                    SET thanks_from = ' . ANONYMOUS . "
                    WHERE thanks_from = $user_id";
                $db->sql_query($sql);
                
    $sql = 'UPDATE ' . THANKS_TABLE . '
                    SET thanks_to = ' . ANONYMOUS . "
                    WHERE thanks_to = $user_id";
                $db->sql_query($sql);
    //End Thanks Post MOD             
Search

Code: Select all

$sql = 'SELECT *
        FROM ' . USERS_TABLE . '
        WHERE user_id = ' . $user_id;
    $result = $db->sql_query($sql);
    $user_row = $db->sql_fetchrow($result);
    $db->sql_freeresult($result);

    if (!$user_row)
    {
        return false;
    }  
Add after

Code: Select all

//Begin Thanks Post MOD
    if ($user_row['user_thanked'])
                {
                    $sql = 'UPDATE ' . USERS_TABLE . '
                        SET user_thanked = user_thanked + ' . $user_row['user_thanked'] . '
                        WHERE user_id = ' . ANONYMOUS;
                    $db->sql_query($sql);
                }
                
                if ($user_row['user_thanks'])
                {
                    $sql = 'UPDATE ' . USERS_TABLE . '
                        SET user_thanks = user_thanks + ' . $user_row['user_thanks'] . '
                        WHERE user_id = ' . ANONYMOUS;
                    $db->sql_query($sql);
                }
                
                if ($user_row['user_thanks_post'])
                {
                    $sql = 'UPDATE ' . USERS_TABLE . '
                        SET user_thanks_post = user_thanks_post + ' . $user_row['user_thanks_post'] . '
                        WHERE user_id = ' . ANONYMOUS;
                    $db->sql_query($sql);
                }
                //End Thanks Post MOD             
Open viewtopic.php

Search

Code: Select all

if ($poster_id == ANONYMOUS)
        {
            $user_cache[$poster_id] = array(
                'joined'        => '',
                'posts'            => '',
                'from'            => '', 
Add after

Code: Select all

//Begin Thank Post MOD
                'thanks'        => (isset($row['user_thanks'])) ? $row['user_thanks'] : '',
                'thanked'        => (isset($row['user_thanked'])) ? $row['user_thanked'] : '',
                'thanks_post'    => (isset($row['user_thanks_post'])) ? $row['user_thanks_post'] : '',
                //End Thank Post MOD             
Search

Code: Select all

//Begin Thank Post MOD
                'thanks'        => $row['user_thanks'],
                'thanked'        => $row['user_thanked'],
                'thanks_post'    => $row['user_thanks_post'],
                //End Thank Post MOD             
Replace with

Code: Select all

//Begin Thank Post MOD
                'thanks'        => (isset($row['user_thanks'])) ? $row['user_thanks'] : '',
                'thanked'        => (isset($row['user_thanked'])) ? $row['user_thanked'] : '',
                'thanks_post'    => (isset($row['user_thanks_post'])) ? $row['user_thanks_post'] : '',
                //End Thank Post MOD             
spaceace wrote: that's not what i mean :lol:

the member was removed almost 6 months prior to installing the mod "[DEV] Thank Post Mod (hide MOD compatible ) 0.2.0". that is what i meant ;)

unfortunately i have changed the author of all of that members posts, so now i can't even test the fix :roll:
With these changes then the problems with deleted users are completely eliminated.

Here is a fix so that a user does not have the URL to himself can Thank.

Open thanks.php
Search

Code: Select all

$sql = 'SELECT thanks_from
    FROM ' . THANKS_TABLE . '
    WHERE post_id = ' . $post_id . '
        AND thanks_from = ' . $user->data['user_id'];
$result = $db->sql_query($sql);
$thanked_post = $db->sql_fetchfield('thanks_from');
$db->sql_freeresult($result);  
Add after

Code: Select all

//Begin NEW The user can not thank himself.
$poster_id = $row['poster_id'];
//End NEW The user can not thank himself.          
Search

Code: Select all

switch ($mode)
{
    case 'thanks':
        if($thanked_post)
        {
            trigger_error('THANKS_CANT_ADD');
        }  
Add after

Code: Select all

//Begin NEW The user can not thank himself.
        if($user->data['user_id'] == $poster_id)
        {
            trigger_error('THANKS_DISALLOW');
        }
        //End NEW The user can not thank himself.    





best regards Mahony
User avatar
Greight
Registered User
Posts: 163
Joined: Sun Jan 18, 2009 12:10 pm

Re: [DEV] Thank Post Mod (hide MOD compatible ) 0.2.0

Post by Greight »

I wanna remove REMOVE THANKS button and put its link just there. How is it possible ?
User avatar
Greight
Registered User
Posts: 163
Joined: Sun Jan 18, 2009 12:10 pm

Re: [DEV] Thank Post Mod (hide MOD compatible ) 0.2.0

Post by Greight »

Is it really that hard ? Cant anyone help me ? :cry:
User avatar
cornnfedd
Registered User
Posts: 124
Joined: Thu Mar 16, 2006 1:54 pm
Location: Adelaide, Australia
Contact:

Re: [DEV] Thank Post Mod (hide MOD compatible ) 0.2.0

Post by cornnfedd »

is this mod ok to use yet? safe?

can i see a forum with this working please, cheers..?
Mazda Rotary Videos Online Free braptv.com
User avatar
Manhattan
Registered User
Posts: 211
Joined: Fri Nov 28, 2008 7:55 pm

Re: [DEV] Thank Post Mod (hide MOD compatible ) 0.2.0

Post by Manhattan »

Hi dear Mahoney
I'm still waiting for new version of your MOD with Ajax. :roll:
User avatar
cornnfedd
Registered User
Posts: 124
Joined: Thu Mar 16, 2006 1:54 pm
Location: Adelaide, Australia
Contact:

Re: [DEV] Thank Post Mod (hide MOD compatible ) 0.2.0

Post by cornnfedd »

cornnfedd wrote:is this mod ok to use yet? safe?

can i see a forum with this working please, cheers..?
demo forum in english is what i meant or any other forum that has it.. :mrgreen:
Mazda Rotary Videos Online Free braptv.com
User avatar
Greight
Registered User
Posts: 163
Joined: Sun Jan 18, 2009 12:10 pm

Re: [DEV] Thank Post Mod (hide MOD compatible ) 0.2.0

Post by Greight »

Seems no support is available here !
Locked

Return to “[3.0.x] MODs in Development”