[RC1] Thank Post by User v0.3.2

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! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
Tumbo
Registered User
Posts: 294
Joined: Wed Jun 01, 2005 7:20 pm
Location: Malmo/Sweden
Contact:

Re: [BETA] Thank Post by User 0.2.5a

Post by Tumbo » Wed Apr 02, 2008 11:40 am

Is this possible to modify this, that you see thanks by thanks instead?
I mean, maybe the last 20 thanks.

- User1 thanked you in the "post1" at 22/3,08 18.22 CET
- User2 thanked you in the "post3" at 22/3,08 18.22 CET
- User1 thanked you in the "post4" at 22/3,08 18.00 CET
- User4 thanked you in the "post1" at 21/3,08 22.00 CET
and so on....

Do you understand what I meant?
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'; 

User avatar
alexi02
Registered User
Posts: 271
Joined: Fri Mar 05, 2004 2:15 am
Location: Australia
Contact:

Re: Re:

Post by alexi02 » Wed Apr 02, 2008 11:59 am

Tumbo wrote:I tried this on the eZportal. It worked, but it got repeated 5 times.. Any ideas why?
You may have placed the code inside a loop. Check for any while or for statements.

Tumbo wrote:Is this possible to modify this, that you see thanks by thanks instead?
I mean, maybe the last 20 thanks.

- User1 thanked you in the "post1" at 22/3,08 18.22 CET
- User2 thanked you in the "post3" at 22/3,08 18.22 CET
- User1 thanked you in the "post4" at 22/3,08 18.00 CET
- User4 thanked you in the "post1" at 21/3,08 22.00 CET
and so on....

Do you understand what I meant?
Unforunately the way it's coded it doesn't store the time the post was thanked. I'll see if I can create a new table which has the time a post was thanked, recode this mod it and provide you with some code changes.

Tumbo
Registered User
Posts: 294
Joined: Wed Jun 01, 2005 7:20 pm
Location: Malmo/Sweden
Contact:

Re: Re:

Post by Tumbo » Wed Apr 02, 2008 12:07 pm

alexi02 wrote: Unforunately the way it's coded it doesn't store the time the post was thanked. I'll see if I can create a new table which has the time a post was thanked, recode this mod it and provide you with some code changes.
That would be great. Please let me know when you do
Thank you again!

Tumbo
Registered User
Posts: 294
Joined: Wed Jun 01, 2005 7:20 pm
Location: Malmo/Sweden
Contact:

Re: Re:

Post by Tumbo » Wed Apr 02, 2008 12:18 pm

alexi02 wrote:
Tumbo wrote:I tried this on the eZportal. It worked, but it got repeated 5 times.. Any ideas why?
You may have placed the code inside a loop. Check for any while or for statements.
How do I know if I placed it in a loop...?

User avatar
alexi02
Registered User
Posts: 271
Joined: Fri Mar 05, 2004 2:15 am
Location: Australia
Contact:

Re: Re:

Post by alexi02 » Wed Apr 02, 2008 12:24 pm

Tumbo wrote:
alexi02 wrote:
Tumbo wrote:I tried this on the eZportal. It worked, but it got repeated 5 times.. Any ideas why?
You may have placed the code inside a loop. Check for any while or for statements.
How do I know if I placed it in a loop...?
Check for any brackets like { or }. Follow the ending bracket } to the corresponding opening bracket { and see if it says anything like for ($x = 0; $x < $something; $x++) { or while ($x < $something) { }. PM me the php file if you need to.

Tumbo
Registered User
Posts: 294
Joined: Wed Jun 01, 2005 7:20 pm
Location: Malmo/Sweden
Contact:

Re: Re:

Post by Tumbo » Wed Apr 02, 2008 12:30 pm

Tumbo wrote:
alexi02 wrote:
Tumbo wrote:I tried this on the eZportal. It worked, but it got repeated 5 times.. Any ideas why?
You may have placed the code inside a loop. Check for any while or for statements.
How do I know if I placed it in a loop...?

Tumbo
Registered User
Posts: 294
Joined: Wed Jun 01, 2005 7:20 pm
Location: Malmo/Sweden
Contact:

Re: Re:

Post by Tumbo » Wed Apr 02, 2008 12:32 pm

Okay, now I have fixed the loop.
Here is how it looks now:
http://www.euro-rap.com/forum/portal.php
(scroll down on the left side)

How do i:
- get rid of the "," before the usernames 2-5
- have a number there instead
- change from 5 to top 10 ?

Here are my codes:
portal.php

Code: Select all

//
        // Start Top 5 Thanked Users
        //

        $lang['Top_5_thanked'] = 'Top 5 thanked users';

        $sql = "SELECT user_id, username, user_thanks_received
                FROM " . USERS_TABLE . "
                WHERE user_id <> " . ANONYMOUS . "
                ORDER BY user_thanks_received DESC";

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

        $row = $db->sql_fetchrowset($result);
        $db->sql_freeresult($result);
        $row_count = count($row);

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

           if ($row[$x]['user_id']) {
           if ($x >= 1) { $top_5_thanked_users .= ", "; }

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

        //
        // End Top 5 Thanked Users
        //
portal_body.tpl

Code: Select all

<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline">
              <tr>
                <td height="25" colspan="2" class="catHead"><span class="newmed"><b>Top thanked users </b></span></td>
              </tr>

              <tr>
                <td align="center" class="row1"><div align="left" class="style7">{L_TOP_5_THANKED_TEXT}: </div></td>
                <td width="68%" align="center" class="row1"><div align="left" class="style7"> {L_TOP_5_THANKED_USERS}</div></td>
              </tr>
            </table>

User avatar
alexi02
Registered User
Posts: 271
Joined: Fri Mar 05, 2004 2:15 am
Location: Australia
Contact:

Re: Re:

Post by alexi02 » Wed Apr 02, 2008 1:12 pm

Tumbo wrote:How do i:
- get rid of the "," before the usernames 2-5
- have a number there instead
- change from 5 to top 10 ?
To get rid of the "," and have a number there instead like 1 <user> 2 <user>:

Find

Code: Select all

if ($x >= 1) { $top_5_thanked_users .= ", "; }
Replace with

Code: Select all

$top_5_thanked_users .= $x . " ";
To change to top 10:

Find

Code: Select all

for ($x = 0; $x <5; $x++) {
Replace with

Code: Select all

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

Tumbo
Registered User
Posts: 294
Joined: Wed Jun 01, 2005 7:20 pm
Location: Malmo/Sweden
Contact:

Re: Re:

Post by Tumbo » Wed Apr 02, 2008 1:36 pm

Thank you! How can I add the numbers than?
I mean:

1. User 1 - 41
2. User 2 - 33
3.
alexi02 wrote:
Tumbo wrote:How do i:
- get rid of the "," before the usernames 2-5
- have a number there instead
- change from 5 to top 10 ?
To get rid of the "," and have a number there instead like 1 <user> 2 <user>:

Find

Code: Select all

if ($x >= 1) { $top_5_thanked_users .= ", "; }
Replace with

Code: Select all

$top_5_thanked_users .= $x . " ";
To change to top 10:

Find

Code: Select all

for ($x = 0; $x <5; $x++) {
Replace with

Code: Select all

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

Tumbo
Registered User
Posts: 294
Joined: Wed Jun 01, 2005 7:20 pm
Location: Malmo/Sweden
Contact:

Re: Re:

Post by Tumbo » Wed Apr 02, 2008 1:55 pm

This is how I made it look now:
Image

And this is how I would like to have it:
Image

What must I do?

User avatar
alexi02
Registered User
Posts: 271
Joined: Fri Mar 05, 2004 2:15 am
Location: Australia
Contact:

Re: Re:

Post by alexi02 » Wed Apr 02, 2008 2:12 pm

Tumbo wrote:This is how I made it look now:
Image

And this is how I would like to have it:
Image

What must I do?
All you need to do is create a table with three columns. An example is below.

Find:

Code: Select all

$row_count = count($row);
After add:

Code: Select all

echo '<table width="100%" cellpadding="2" cellspacing="1" border="0"><tr>';
Find:

Code: Select all

if ($row[$x]['user_id']) {
           $top_5_thanked_users .= $x . " ";

           // Add user to thanked list
           $temp_url = "profile.$phpEx?mode=viewprofile&u=" . $row[$x]['user_id'];
           $top_5_thanked_users .= '<a href="' . $temp_url . '">' . $row[$x]['username'] . '</a> (' . $row[$x]['user_thanks_received'] . ')<br>';
           }
Replace with:

Code: Select all

$temp_url = "profile.$phpEx?mode=viewprofile&u=" . $row[$x]['user_id'];
$thanked_username = '<a href="' . $temp_url . '">' . $row[$x]['username'] . '</a>';

echo "<td width='76'>$x</td>
<td width='112'>$thanked_username</td>
<td>" . $row[$x]['user_thanks_received'] . "</td>";
Find:

Code: Select all

        //
        // End Top 5 Thanked Users
        //
Before add:

Code: Select all

echo '</tr></table>';

Tumbo
Registered User
Posts: 294
Joined: Wed Jun 01, 2005 7:20 pm
Location: Malmo/Sweden
Contact:

Re: Re:

Post by Tumbo » Wed Apr 02, 2008 2:19 pm

It didn't work.... I got an error message.
alexi02 wrote:
Tumbo wrote:This is how I made it look now:
Image

And this is how I would like to have it:
Image

What must I do?
All you need to do is create a table with three columns. An example is below.

Find:

Code: Select all

$row_count = count($row);
After add:

Code: Select all

echo '<table width="100%" cellpadding="2" cellspacing="1" border="0"><tr>';
Find:

Code: Select all

if ($row[$x]['user_id']) {
           $top_5_thanked_users .= $x . " ";

           // Add user to thanked list
           $temp_url = "profile.$phpEx?mode=viewprofile&u=" . $row[$x]['user_id'];
           $top_5_thanked_users .= '<a href="' . $temp_url . '">' . $row[$x]['username'] . '</a> (' . $row[$x]['user_thanks_received'] . ')<br>';
           }
Replace with:

Code: Select all

$temp_url = "profile.$phpEx?mode=viewprofile&u=" . $row[$x]['user_id'];
$thanked_username = '<a href="' . $temp_url . '">' . $row[$x]['username'] . '</a>';

echo "<td width='76'>$x</td>
<td width='112'>$thanked_username</td>
<td>" . $row[$x]['user_thanks_received'] . "</td>";
Find:

Code: Select all

        //
        // End Top 5 Thanked Users
        //
Before add:

Code: Select all

echo '</tr></table>';

User avatar
alexi02
Registered User
Posts: 271
Joined: Fri Mar 05, 2004 2:15 am
Location: Australia
Contact:

Re: Re:

Post by alexi02 » Wed Apr 02, 2008 2:51 pm

Tumbo wrote:It didn't work.... I got an error message.
Ah I forgot to assign it to the thanked variable instead of echo'ing.

Find

Code: Select all

echo '<table width="100%" cellpadding="2" cellspacing="1" border="0"><tr>';
Replace with

Code: Select all

$top_5_thanked_users .= '<table width="100%" cellpadding="2" cellspacing="1" border="0"><tr>';
Find

Code: Select all

$temp_url = "profile.$phpEx?mode=viewprofile&u=" . $row[$x]['user_id'];
$thanked_username = '<a href="' . $temp_url . '">' . $row[$x]['username'] . '</a>';

echo "<td width='76'>$x</td>
<td width='112'>$thanked_username</td>
<td>" . $row[$x]['user_thanks_received'] . "</td>";
Replace with

Code: Select all

if ($row[$x]['user_id']) {
$temp_url = "profile.$phpEx?mode=viewprofile&u=" . $row[$x]['user_id'];
$thanked_username = '<a href="' . $temp_url . '">' . $row[$x]['username'] . '</a>';

$top_5_thanked_users .= "<td width='76'>$x</td>
<td width='112'>$thanked_username</td>
<td>" . $row[$x]['user_thanks_received'] . "</td>";
Find

Code: Select all

echo '</tr></table>';
Replace with

Code: Select all

$top_5_thanked_users .= '</tr></table>';

Tumbo
Registered User
Posts: 294
Joined: Wed Jun 01, 2005 7:20 pm
Location: Malmo/Sweden
Contact:

Re: Re:

Post by Tumbo » Wed Apr 02, 2008 4:18 pm

Code: Select all

Parse error: syntax error, unexpected $end in .../forum/portal.php on line 672 

User avatar
alexi02
Registered User
Posts: 271
Joined: Fri Mar 05, 2004 2:15 am
Location: Australia
Contact:

Re: [BETA] Thank Post by User 0.3

Post by alexi02 » Thu Apr 03, 2008 8:39 am

2008-04-3 - Version 0.3
- New thanks table created
- Thanked x times in y posts now only shows y posts as the posts which users have thanked and not the total posts the user has
- Ability to enable / disable this mod on each forum via the ACP

Thank Post by User v0.3 (10.5KB)


Update from v0.2.6 to v0.3
Thank Post by User update from v0.2.6 to v0.3 (6.5KB)

Post Reply

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

Who is online

Users browsing this forum: No registered users and 8 guests