Page 17 of 17

Re: [BETA] Thank Post by User 0.2.5a

Posted: Sun Sep 28, 2008 7:15 am
by sorryno
I'm using version thank_post_by_user_v0.2.6 and have added this to my test forum on localhost before moving into production. It works good but was hoping you would help me out by tweaking it so that regular members can not see topics in private or hidden forums. It will show all thanks ever given. Some topics I do not want the normal members able to view. If they try to view the topic of course they get denied. Thanks you for your time.
alexi02 wrote:To view all the users and the topics who have thanked a user in their profile follow the instructions below. In the profile you will firstly see a link on the "Thanked x times in x posts". This links back to the profile page and then displays the Thanked Listing which shows the users whom have thanked the post, the topic title and the post number (all with links of course).

1. Modify the Thank Post by User 0.2.5a as per this post
http://www.phpbb.com/community/viewtopi ... 7#p2938797

2. Then follow the modifications below.

Open includes/usercp_profile.php

Find

Code: Select all

$thanked_post_count = $db->sql_fetchrow($result);
$db->sql_freeresult($result);

$thanks_given = $user_row['user_thanks_given'];
$thanks_received = $user_row['user_thanks_received'] . ' ' . $lang['Thanks_thanked_2'] . ' ' . $thanked_post_count['thanks_count'] . ' ' . $lang['Thanks_thanked_3'];

}
else {
   $thanks_given = "";
   $thanks_received = "";
}

//
// End Thank Post by User Mod
//
Replace with

Code: Select all

$thanked_post_count = $db->sql_fetchrow($result);
$db->sql_freeresult($result);

$temp_url = "profile.$phpEx?mode=viewprofile&u=" . $profiledata['user_id'] . "&thankslist=1";
$thanks_given = $user_row['user_thanks_given'];
$thanks_received = '<a href="' . $temp_url . '">' . $user_row['user_thanks_received'] . ' ' . $lang['Thanks_thanked_2'] . ' ' . $thanked_post_count['thanks_count'] . ' ' . $lang['Thanks_thanked_3'] . '</a>';

}
else {
   $thanks_given = "";
   $thanks_received = "";
}

//
// End Thank Post by User Mod
//


// Thanks Listing
if ( isset($HTTP_GET_VARS['thankslist']) || $HTTP_GET_VARS['thankslist'] ) {

   // Thanked Listing SQL
   $sql = "SELECT thanks_from_user_id, thanks_count, topic_id, post_id
           FROM " . POSTS_TABLE . "
           WHERE poster_id = " . $profiledata['user_id'] . " AND thanks_count <> 0";

   if ( !($result = $db->sql_query($sql)) ) {
   message_die(GENERAL_ERROR, "Could not obtain posts information", '', __LINE__, __FILE__, $sql);
   }

   $thanked_listing = $db->sql_fetchrowset($result);
   $db->sql_freeresult($result);
   $thanked_listing_count = count($thanked_listing);

   for ($i = 0; $i < $thanked_listing_count; $i++) {

      $thanked_users = explode("|",$thanked_listing[$i]['thanks_from_user_id']);
      $thanked_count = $thanked_listing[$i]['thanks_count'];

      // Loop through all users who thanked the post
      for ($x = 0; $x < $thanked_count; $x++) {

         // Users SQL
         $sql = "SELECT user_id, username
                 FROM " . USERS_TABLE . "
                 WHERE user_id = " . $thanked_users[$x];

         if ( !($result = $db->sql_query($sql)) ) {
            message_die(GENERAL_ERROR, "Could not obtain user information", '', __LINE__, __FILE__, $sql);
         }

         $user_row = $db->sql_fetchrow($result);
         $db->sql_freeresult($result);

         if ($x >= 1) { $thanks_compiled .= ", "; }

            // Add user to thanked by list
            $temp_url = "profile.$phpEx?mode=viewprofile&u=" . $user_row['user_id'];
            $thanks_compiled .= '<a href="' . $temp_url . '">' . $user_row['username'] . '</a>';
      }

      // Topic SQL
      $sql = "SELECT topic_title
              FROM " . TOPICS_TABLE . "
              WHERE topic_id = " . $thanked_listing[$i]['topic_id'];

      if ( !($result = $db->sql_query($sql)) ) {
         message_die(GENERAL_ERROR, "Could not obtain user information", '', __LINE__, __FILE__, $sql);
      }

      $topic_row = $db->sql_fetchrow($result);
      $db->sql_freeresult($result);


      $temp_url_post = "viewtopic.$phpEx?p=" . $thanked_listing[$i]['post_id'] . "#" . $thanked_listing[$i]['post_id'];
      $temp_url_topic = "viewtopic.$phpEx?t=" . $thanked_listing[$i]['topic_id'];
      $thanks_post = '<a href="' . $temp_url_post . '"> (Post #' . $thanked_listing[$i]['post_id'] . ')</a>';
      $thanks_topic = '<a href="' . $temp_url_topic . '">' . $topic_row['topic_title'] . '</a>';
      $thanks_listing .= "Thanked by $thanks_compiled in $thanks_topic - $thanks_post<br/>";

      $thanks_compiled = '';
   }

   $template->assign_block_vars('thankslist', array(
      'THANKS_LISTING' => $thanks_listing,
      'L_THANKS_LISTING' => $lang['Thanks_listing'])
   );
}

Open templates/subSilver/profile_view_body.tpl

Find

Code: Select all

                <tr>
                  <td valign="top" align="right" nowrap="nowrap"><span class="gen">{L_THANKS_RECEIVED}:</span></td>
                  <td> <b><span class="gen">{THANKS_RECEIVED}</span></b></td>
                </tr>
After add

Code: Select all

                <!-- BEGIN thankslist -->
                <tr>
                  <td valign="top" align="right" nowrap="nowrap"><span class="gen">{thankslist.L_THANKS_LISTING}:</span></td>
                  <td> <span class="gen">{thankslist.THANKS_LISTING}</span></td>
                </tr>
                <!-- END thankslist -->

Open language/lang_english/lang_main.php

Find

Code: Select all

$lang['Thanks_thanks'] = 'Thanks';
$lang['Thanks_thanked_1'] = 'Thanked';
$lang['Thanks_thanked_2'] = 'Times in';
$lang['Thanks_thanked_3'] = 'Posts';
After add

Code: Select all

$lang['Thanks_listing'] = 'Thanked Listing'; 

Re: [RC1] Thank Post by User v0.3.2

Posted: Thu Oct 02, 2008 6:34 pm
by teman
sorry ,on your .txt installation guide you mentioned to find modcp.php,i can't find this file.did you mean mcp.php?

Re: [RC1] Thank Post by User v0.3.2

Posted: Fri Oct 03, 2008 8:34 am
by alexi02
For phpBB2 it should be modcp.php, looks like you might be using a different version though mcp.php sounds like it.

Re: Re:

Posted: Sun Nov 09, 2008 10:39 pm
by Tuning
Hi
that would like would list looks in such a way

Image

Here is my Code

Code: Select all

 // 
        // Start Top 5 Thanked Users 
        // 

        $sql = "SELECT t.thanked_user, u.username 
                FROM forum_thanksmod t LEFT JOIN " . USERS_TABLE . " u 
                ON t.thanked_user = u.user_id 
                WHERE thanked_user <> " . ANONYMOUS . " 
                ORDER BY thanked_user DESC"; 

        if ( !($result = $db->sql_query($sql)) ) { 
           message_die(GENERAL_ERROR, 'Could not query users table', '', __LINE__, __FILE__, $sql); 
        } 

        $thanked_count = 1; 
        $old_user_id = 0; 
        $x = 0; 
        while ($row = mysql_fetch_array($result)) { 
           $user_id = $row['thanked_user']; 
           $username = $row['username']; 

           if ($row['thanked_user'] != $old_user_id) { 
              $thanked_count = 0; 
              $x++; 
           } 

           $old_user_id = $row['thanked_user']; 
           $thanked_count++; 

           $thankslist[$x]['count'] = $thanked_count; 
           $thankslist[$x]['user_id'] = $user_id; 
           $thankslist[$x]['username'] = $username; 
        } 

        rsort($thankslist); 


        for ($x = 0; $x < 10; $x++) { 

           if ($thankslist[$x]['user_id']) { 
              if ($x >= 1) { $top_5_thanked_users .= "<br /> "; } 

              // Add user to thanked list 
              $temp_url = "profile.$phpEx?mode=viewprofile&u=" . $thankslist[$x]['user_id']; 
              $top_5_thanked_users .= '<a href="' . $temp_url . '">' . $thankslist[$x]['username'] . '</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (' . $thankslist[$x]['count'] . ')'; 
           } 
        } 


        // 
        // End Top 5 Thanked Users 
        //
Helpme Pls

Re: [RC1] Thank Post by User v0.3.2

Posted: Thu Nov 13, 2008 11:25 am
by Tuning
Hello , Helpme PLS :oops:

Re: [RC1] Thank Post by User v0.3.2

Posted: Sun Nov 23, 2008 10:20 am
by Tuning
Hello Helpme :!: :!: :!:

Re: [RC1] Thank Post by User v0.3.2

Posted: Mon Jan 12, 2009 5:12 pm
by james1111
Hi,

I noticed that you changed the sql information from:

Code: Select all

ALTER TABLE `phpbb_posts` ADD `thanks_count` MEDIUMINT( 8 ) NOT NULL DEFAULT '0';
ALTER TABLE `phpbb_posts` ADD `thanks_from_user_id` TEXT NULL;
ALTER TABLE `phpbb_users` ADD `user_thanks_received` MEDIUMINT( 8 ) NOT NULL DEFAULT '0';
ALTER TABLE `phpbb_users` ADD `user_thanks_given` MEDIUMINT( 8 ) NOT NULL DEFAULT '0';
to

Code: Select all

CREATE TABLE `phpbb_thanksmod` (
  `post_id` mediumint(8) unsigned NOT NULL default '0',
  `thanked_user` mediumint(8) NOT NULL default '0',
  `thanks_by` mediumint(8) NOT NULL default '0',
  `thanked_time` int(10) NOT NULL default '0'
);
In this post http://www.phpbb.com/community/viewtopi ... 0#p3233853 where you gave us the codes to have a list of topics who have thanked a user in their profile, you used the sql query from the old sql information.

I was wondering if you can help modify the codes from http://www.phpbb.com/community/viewtopi ... 0#p3233853 to work with the current (v0.3.2) sql information?

thank you!

Re: [RC1] Thank Post by User v0.3.2

Posted: Tue Jan 13, 2009 10:26 am
by alexi02
Hi,

Please follow all changes which are specified in the posts you have linked to and then please open user_viewprofile.php, remove any Thank Post by User code before$avatar_img = '';

Find

Code: Select all

$avatar_img = '';
Before Add:

Code: Select all

//
// Start Thank Post by User Mod
//

// Thanks by
$sql = "SELECT COUNT(thanks_by) AS thanks_by
        FROM phpbb_thanksmod
        WHERE thanks_by = '" . $profiledata['user_id'] . "'";

if ( !($result = $db->sql_query($sql)) ) {
  message_die(GENERAL_ERROR, "Could not obtain thanks information", '', __LINE__, __FILE__, $sql);
}

$thanks_by_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);

// Thanked user
$sql = "SELECT post_id, thanked_user
       FROM phpbb_thanksmod
       WHERE thanked_user = '" . $profiledata['user_id'] . "'
       ORDER BY post_id";

if ( !($result = $db->sql_query($sql)) ) {
  message_die(GENERAL_ERROR, "Could not obtain thanks information", '', __LINE__, __FILE__, $sql);
}

// Calculate the user's thanks given and thanks received
$thanked_count = 0;
$thanked_posts = 0;
$old_post_id = 0;
while ($row = mysql_fetch_array($result)) {
  if ($row['post_id'] != $old_post_id) {
     $thanked_posts++;
  }
  $old_post_id = $row['post_id'];
  $thanked_count++;
}

$temp_url = "profile.$phpEx?mode=viewprofile&u=" . $profiledata['user_id'] . "&thankslist=1";
$thanks_given = $thanks_by_row['thanks_by'];
$thanks_received = '<a href="' . $temp_url . '">' .  $thanked_count . ' ' . $lang['Thanks_thanked_2'] . ' ' . $thanked_posts . ' ' . $lang['Thanks_thanked_3'] . '</a>';

//
// End Thank Post by User Mod
//

// Thanks Listing
if ( isset($HTTP_GET_VARS['thankslist']) || $HTTP_GET_VARS['thankslist'] ) {

  // Thanked Listing SQL
  $sql = "SELECT *
          FROM phpbb_thanksmod
          WHERE thanked_user = '" . $profiledata['user_id'] . "'";

  if ( !($result = $db->sql_query($sql)) ) {
     message_die(GENERAL_ERROR, "Could not obtain posts information", '', __LINE__, __FILE__, $sql);
  }

  $thanked_listing = $db->sql_fetchrowset($result);
  $db->sql_freeresult($result);
  $thanked_listing_count = count($thanked_listing);

  // Loop through all users who thanked the post
  for ($x = 0; $x < $thanked_listing_count; $x++) {

      // Users SQL
      $sql = "SELECT user_id, username
              FROM " . USERS_TABLE . "
              WHERE user_id = " . $thanked_listing[$x]['thanks_by'];

      if ( !($result = $db->sql_query($sql)) ) {
         message_die(GENERAL_ERROR, "Could not obtain user information", '', __LINE__, __FILE__, $sql);
      }

      $user_row = $db->sql_fetchrow($result);
      $db->sql_freeresult($result);


      // Posts SQL
      $sql = "SELECT topic_id
             FROM " . POSTS_TABLE . "
             WHERE post_id = " . $thanked_listing[$x]['post_id'];

        if ( !($result = $db->sql_query($sql)) ) {
           message_die(GENERAL_ERROR, "Could not obtain user information", '', __LINE__, __FILE__, $sql);
        }

        $post_topic_row = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);

            // Topic SQL
        $sql = "SELECT topic_title
                FROM " . TOPICS_TABLE . "
                WHERE topic_id = '" . $post_topic_row['topic_id'] . "'";

        if ( !($result = $db->sql_query($sql)) ) {
           message_die(GENERAL_ERROR, "Could not obtain user information", '', __LINE__, __FILE__, $sql);
        }

        $topic_row = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);


        $temp_url_post = "viewtopic.$phpEx?p=" . $thanked_listing[$x]['post_id'] . "#" . $thanked_listing[$x]['post_id'];
        $temp_url_topic = "viewtopic.$phpEx?t=" . $post_topic_row['topic_id'];
        $thanks_post = '<a href="' . $temp_url_post . '"> (Post #' . $thanked_listing[$x]['post_id'] . ')</a>';
        $thanks_topic = '<a href="' . $temp_url_topic . '">' . $topic_row['topic_title'] . '</a>';
        $thanks_listing .= "Thanked by " . $user_row['username'] . " in $thanks_topic - $thanks_post<br/>";
  }

}

$template->assign_block_vars('thankslist', array(
'THANKS_LISTING' => $thanks_listing,
'L_THANKS_LISTING' => "Thanks Listing")
);
It's quickly written code which should work.

Re: [RC1] Thank Post by User v0.3.2

Posted: Wed Jan 14, 2009 9:02 pm
by AcuteAngel
Hi,
I'm new in this forum and I need your help guys. I make a forum using a free phpBB3 template with a directory of http://www.domain.com/phpBB3 but I wish to to put a "Thank You" button which that I have found in this forum.
My question is... can someone guide me of how to install it in my board or my phpBB3 template?
I've already installed 3 different templates Acidtech_Tiger, eTech, & Hermes.
Which folder do I need to upload the "Thank You" folder and which file do I need to edit?

Thank in Advance

Re: [RC1] Thank Post by User v0.3.2

Posted: Thu Jan 15, 2009 8:27 am
by alexi02
This Thanks mod is for phpBB2. Try this one for phpBB3.