phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

showing/adding avatars also in PM's

Goto page 1, 2  Next
 
Search this topic... | Search MOD Requests... | Search Box
Register or Login to Post    Index » MOD Requests  Previous TopicPrint TopicNext Topic
Author Message
dondino
Board Member



Joined: 09 Dec 2008

Posts: 144


flag
PostPosted: Mon Mar 07, 2011 8:03 am 
Post subject: showing/adding avatars also in PM's

Hello,
unfortunately I couldnt find any mod for this in phpbbhacks...
Basically I would like to show username avatars also in private messages... in the "READ" post view, just like you see in ordinary forum posts.
is it safe to do that and...how? Do you have any hacks for that? It should be not that hard... icon_rolleyes.gif
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Mon Mar 07, 2011 6:43 pm 
Post subject: Re: showing/adding avatars also in PM's

I had a look at privmsg.php and apparently the template var is already set, so it's just a matter of your template using it or not. Basically all you have to do is edit your template's privmsgs_read_body.tpl and put {POSTER_AVATAR} where you want it to appear.
Back to top
dondino
Board Member



Joined: 09 Dec 2008

Posts: 144


flag
PostPosted: Mon Mar 07, 2011 11:31 pm 
Post subject: Re: showing/adding avatars also in PM's

Hi Salvatos,
and thanks for the help.
I have tried to add {POSTER_AVATAR}
among the other variables in privmsgs_read_body.tpl

Code:
      <div style="padding: 3px;"><span class="name">{MESSAGE_FROM}</span><br />{POSTER_AVATAR}</div>
      <br />
      <table width="100%" cellspacing="5" cellpadding="0">
         <tr>
            <td align="left" nowrap="nowrap"><span class="postdetails">{L_POSTED}:<br />{POST_DATE}<br /><br />{L_TO}:<br />{MESSAGE_TO}<br />{POSTER_TO_ONLINE_STATUS}<br /><br /></span></td>
         </tr>
      </table>


I have tried to put it as in the example above, but I tried also other places, like besides {POST_DATE}
But it doesn't work... nothing shows up icon_sad.gif
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Tue Mar 08, 2011 5:34 pm 
Post subject: Re: showing/adding avatars also in PM's

Hm... that's strange, $poster_avatar is actually not defined. I wonder why they left it there. Guess they changed their mind at some point and forgot to remove some code. You'll need to add one line in privmsg.php, the actual position does not matter a whole lot, but here's where I placed it:

Code:
FIND
   //
   // Dump it to the templating engine
   //


Code:
BEFORE, ADD
$poster_avatar = "<img src='" . $phpbb_root_path . "images/avatars/" . $privmsg['user_avatar'] . "' />";


Not tested with avatars from the gallery nor the preview mode. Let me know how it goes!


Edit: Actually you probably don't want an ugly "no image" box to appear when the user doesn't have an avatar, so you can use this code instead:

Code:
if ($privmsg['user_avatar'] != "") {
      $poster_avatar = "<img src='" . $phpbb_root_path . "images/avatars/" . $privmsg['user_avatar'] . "' />";
   }
Back to top
dondino
Board Member



Joined: 09 Dec 2008

Posts: 144


flag
PostPosted: Fri Mar 11, 2011 8:55 am 
Post subject: Re: showing/adding avatars also in PM's

Thanks so much for your snippet Salvatos!
I've just tried it,
and it works... for uploaded avatars icon_smile.gif

For avatars picked up from the gallery, it doesn't show anything.

By the way, I've just found this mod:
http://www.phpbbhacks.com/download/6813
which shows avatar just in the main pm page, in the pm list...

see (when you have time!) if you can somehow adapt the part:
Code:
      $msg_avatar = '';
      if ( $row['user_avatar_type'] && $row['user_allowavatar'] )
      {
         switch( $row['user_avatar_type'] )
         {
            case USER_AVATAR_UPLOAD:
               $msg_avatar = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $row['user_avatar'] . '" height="40" alt="" border="0" />' : '';
               break;
            case USER_AVATAR_REMOTE:
               $msg_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $row['user_avatar'] . '" height="40" alt="" border="0" />' : '';
               break;
            case USER_AVATAR_GALLERY:
               $msg_avatar = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $row['user_avatar'] . '" height="40" alt="" border="0" />' : '';
               break;
         }
      }


...to your little mod... so that we can see also pm avatars from the avatar gallery
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Fri Mar 11, 2011 3:45 pm 
Post subject: Re: showing/adding avatars also in PM's

Ah, I'm glad you found this, it will definitely save me the research part icon_smile.gif

So, our previous mod would be something like this instead:

Code:
      if ( $privmsg['user_avatar_type'] && $privmsg['user_allowavatar'] )
      {
         switch( $privmsg['user_avatar_type'] )
         {
            case USER_AVATAR_UPLOAD:
               $poster_avatar = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $privmsg['user_avatar'] . '" border="0" />' : '';
               break;
            case USER_AVATAR_REMOTE:
               $poster_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $privmsg['user_avatar'] . '" border="0" />' : '';
               break;
            case USER_AVATAR_GALLERY:
               $poster_avatar = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $privmsg['user_avatar'] . '" alt="" border="0" />' : '';
               break;
         }
      }

Plus:
REPLACE
Code:
   $sql = "SELECT u.username AS username_1, u.user_id AS user_id_1, u2.username AS username_2, u2.user_id AS user_id_2, u.user_sig_bbcode_uid, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_avatar, pm.*, pmt.privmsgs_bbcode_uid, pmt.privmsgs_text

WITH
Code:
   $sql = "SELECT u.username AS username_1, u.user_id AS user_id_1, u2.username AS username_2, u2.user_id AS user_id_2, u.user_sig_bbcode_uid, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_avatar, u.user_avatar_type, u.user_allowavatar, pm.*, pmt.privmsgs_bbcode_uid, pmt.privmsgs_text



I didn't test this one since I'm a little busy today, but if the MOD worked, this should as well. Otherwise we'll do the troubleshooting later icon_wink.gif
Back to top
dondino
Board Member



Joined: 09 Dec 2008

Posts: 144


flag
PostPosted: Fri Mar 11, 2011 9:13 pm 
Post subject: Re: showing/adding avatars also in PM's

Thanks so much Salvatos!
it works perfectly now! icon_wink.gif *approved & tested*

I have another "small" request related to this mod you have just made, but I will probably try to explain this attempt later... I don't wanna ruin you the weekend 4 now icon_mrgreen.gif
Back to top
dogs and things
Board Member



Joined: 18 Nov 2008

Posts: 621
Location: Spain


flag
PostPosted: Fri Mar 11, 2011 11:06 pm 
Post subject: Re: showing/adding avatars also in PM's

Works fine on my board too.

Thanks, greetings! icon_biggrin.gif

_________________
phpBB2 will never die, I hope!
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Sat Mar 12, 2011 2:47 am 
Post subject: Re: showing/adding avatars also in PM's

Well I'm glad I could help!

And don't hesitate to ask for the rest, I should be free for most of the weekend ^^
Back to top
dondino
Board Member



Joined: 09 Dec 2008

Posts: 144


flag
PostPosted: Sat Mar 12, 2011 9:01 am 
Post subject: Re: showing/adding avatars also in PM's

Hi again icon_smile.gif
Okay, I will try to explain my possible addon request for this mod...

In my board I have installed the modification by 3Di (the well known IP Country Flag mod) do you remember it, right?
http://phpbb2refugees.com/viewtopic.php?t=149
Well, this mod somehow affects also avatars because when you apply for registration, and you don't select any avatar, you have automatically a cute avatar with the flag location chosen at registration.

The problem is that in private messages, the avatar of the users with the "FLAG AVATAR" is not displayed... thats probably because this mod needs another "CASE" addition... to display them as well.

I have tried to take some random parts added by this mod, so that you can see if you can find a trick to add that CASE part in order to try to show also these strange flag avatars in PM's.... icon_wink.gif

Code:
//-- mod : IP Country Flag II ----------------------------------------------
if ( ($profiledata['user_active'] == 1) && ($profiledata['user_avatar_type'] == 0) )
{
   $avatar_img = '<img src="images/avatars/gallery/ipcf_flags/' . $profiledata['user_cf_iso3661_1'] . '.gif" alt="' .  $lang['IP2Country'][$profiledata['user_cf_iso3661_1']] . '" title="' .  $lang['IP2Country'][$profiledata['user_cf_iso3661_1']] . '" border="0" />';
}


Code:
//-- mod : IP Country Flag II ----------------------------------------------
   'COUNTRY' => $lang['IP2Country'][$profiledata['user_cf_iso3661_1']],
   'FLAG' => $profiledata['user_cf_iso3661_1'],
   'L_COUNTRY' => $lang['Country'],
   'L_USER_COUNTRY' => $lang['User_Country'],
   'USER_FLAG' => $profiledata['user_from_flag_cf_iso3661_1'],
   'USER_COUNTRY' => $lang['IP2Country'][$profiledata['user_from_flag_cf_iso3661_1']],
//-- end mod : IP Country Flag II ----------------------------------------------


Code:
//--  mod : IP Country Flag II ------------------------------------------
   $ipcfguest = $lang['IPCF_Guest'];

   if ($postrow[$i]['user_id'] == ANONYMOUS)
      {
         $poster_avatar = '<img src="images/avatars/gallery/ipcf_flags/' . $ipcfguest . '.gif" alt="' . $ipcfguest . '" title="' . $ipcfguest . '" border="0" />';
      }
      else if ($postrow[$i]['user_avatar_type'] == 0)
      {
         $poster_avatar = '<img src="images/avatars/gallery/ipcf_flags/' . $postrow[$i]['user_cf_iso3661_1'] . '.gif" alt="' . $lang['IP2Country'][$postrow[$i]['user_cf_iso3661_1']] . '" title="' . $lang['IP2Country'][$postrow[$i]['user_cf_iso3661_1']] . '" border="0" />';
      }
//-- end mod : IP Country Flag II ------------------------------------------


Otherwise If you need to have a look at the entire mod, I have just pasted the whole codechanges here
http://pastebin.com/88dCnqTM
If you look at it, you can see that also privmsg.php has been modified by this mod... maybe everything is already set up there, it just needs a little help to show up icon_smile.gif
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Sat Mar 12, 2011 4:14 pm 
Post subject: Re: showing/adding avatars also in PM's

Hm, let's see. To be honest I don't know where the switch gets its upper-case cases, so this is not going to be as elegant, but I guess it should work:

Code:
      if ( $privmsg['user_avatar_type'] && $privmsg['user_allowavatar'] )
      {
         switch( $privmsg['user_avatar_type'] )
         {
            case USER_AVATAR_UPLOAD:
               $poster_avatar = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $privmsg['user_avatar'] . '" border="0" />' : '';
               break;
            case USER_AVATAR_REMOTE:
               $poster_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $privmsg['user_avatar'] . '" border="0" />' : '';
               break;
            case USER_AVATAR_GALLERY:
               $poster_avatar = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $privmsg['user_avatar'] . '" alt="" border="0" />' : '';
               break;
         }
      }
      else
      {
         $poster_avatar = ( $board_config['user_allowavatar'] ) ? '<img src="images/avatars/gallery/ipcf_flags/' . $postrow[$i]['user_cf_iso3661_1'] . '.gif" alt="' . $lang['IP2Country'][$postrow[$i]['user_cf_iso3661_1']] . '" title="' . $lang['IP2Country'][$postrow[$i]['user_cf_iso3661_1']] . '" border="0" />' : '';
      }


I don't have the config to test this, so let me know how it goes! icon_smile.gif
Back to top
dondino
Board Member



Joined: 09 Dec 2008

Posts: 144


flag
PostPosted: Fri Mar 18, 2011 4:20 pm 
Post subject: Re: showing/adding avatars also in PM's

Hi Salvatos! sorry for the late in reply!!
Thanks for your kind help.
I have just tested ur addon custom made, but unfortunately it doesn't work... it shows no avatar in pm's which instead appear as a flag in profiles and viewtopics, for those users who didn't chose anything as avatar, at registration.

But anyway, its not a problem, I can understand its somehow hard to adapt a mod complex like this one, for another behaviour...
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Fri Mar 18, 2011 5:09 pm 
Post subject: Re: showing/adding avatars also in PM's

Then let's try option #2.

Code:
      if ( $privmsg['user_avatar_type'] && $privmsg['user_allowavatar'] )
      {
if ($privmsg['user_avatar_type'] == 0)
{
         $poster_avatar = ( $board_config['user_allowavatar'] ) ? '<img src="images/avatars/gallery/ipcf_flags/' . $postrow[$i]['user_cf_iso3661_1'] . '.gif" alt="' . $lang['IP2Country'][$postrow[$i]['user_cf_iso3661_1']] . '" title="' . $lang['IP2Country'][$postrow[$i]['user_cf_iso3661_1']] . '" border="0" />' : '';
}
else
{
         switch( $privmsg['user_avatar_type'] )
         {
            case USER_AVATAR_UPLOAD:
               $poster_avatar = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $privmsg['user_avatar'] . '" border="0" />' : '';
               break;
            case USER_AVATAR_REMOTE:
               $poster_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $privmsg['user_avatar'] . '" border="0" />' : '';
               break;
            case USER_AVATAR_GALLERY:
               $poster_avatar = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $privmsg['user_avatar'] . '" alt="" border="0" />' : '';
               break;
         }
      }
}


Excuse the lack of indentation, I'm not on my own computer.
Back to top
dondino
Board Member



Joined: 09 Dec 2008

Posts: 144


flag
PostPosted: Thu Apr 07, 2011 12:47 pm 
Post subject: Re: showing/adding avatars also in PM's

sorry for the late Salvatos!

it doesn't work... icon_cry.gif
but don't worry anymore ok? I dont wanna give you pressure over this!
I can understand its difficult,

Maybe I should set you up a test board with a vanilla phpbb2 with ONLY the IPflag mod installed, so that we can test these code-changes there, rather than my heavily modded board which might prevent this to work...
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Fri Apr 08, 2011 5:09 pm 
Post subject: Re: showing/adding avatars also in PM's

Well, sure, or if you can just zip up your forum directory and database and send it to me I can test it on my home server and find out what changes need to be done instead of having you try them blindly.

Make sure you remove sensitive information like passwords, of course.
Back to top
Display posts from previous:   
Register or Login to Post    Index » MOD Requests  Previous TopicPrint TopicNext Topic
Page 1 of 2 All times are GMT
Goto page 1, 2  Next
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0197 seconds using 15 queries. (SQL 0.0013 Parse 0.0007 Other 0.0177)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo