Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: [Solved]: Avatar in comments  (Read 7208 times)

0 Members and 1 Guest are viewing this topic.

MadMaxx

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 23
[Solved]: Avatar in comments
« on: July 10, 2008, 03:58:31 am »

hi
the title is not very clear but this is what i want to do:

I want avatars but i can't install Stramm's mod pack, i changed so many files i wouln't know where to begin,
anyway i don't need the other functions of the mod pack, only the avatars.
So i hacked my own (down and dirty :D) avatar system (at least i tried), far from perfect because the user can't upload his own avatar,
has to host it on another site  :-[ but it works.
 i used the custom profile 6 (like it says in the help files) and bbcode to put an avatar in the side menu (attached pic1) and made it work with foulu's forum plugin (pic2)
but i can't ad it to the comments (pic3), i spent hour trying but i just don't know where to put the code.
i want to reduce the text box size (pic3-black box) and put the avatar on the left (pic3-red box).
I'm really new to php and by reading the manuals i was able to do part of it, but this is over my head.

i used this code in 'init.inc.php' in Stramm's 'CPG PMS v1.1' to show the avatar in the side menu and similar code for foulu's forum:
Code: [Select]
//loginForm data ... the statistics, pms status
if (USER_ID) {
$loginFormHtml = '<div align=\"left\" class=\"smallfont\"><h2>My Account</h2><hr />'.$lang_pms_sys['welcome'].' <br><strong><a href="profile.php?uid=' .(USER_ID). '">'.(USER_NAME).'</a></strong>';
        //begin avatar
$result =  mysql_query("SELECT user_profile6 FROM {$CONFIG['TABLE_USERS']} WHERE user_id = '".(USER_ID)."'");
    $row = mysql_fetch_array( $result );
  $avatar_url = $row['user_profile6'];
if ($avatar_url !="") $avatar_url = $avatar_url;
else $avatar_url="";
$loginFormHtml .= bb_decode($avatar_url);
        //end avatar
something similar would probably work in the comments (maybe), if i just knew where to put it.
So any help would be really really appreciated.

i use the Giallo theme, just tell me if you need access to my site or for me to upload any files.

Thanks

Jorge

« Last Edit: July 11, 2008, 06:03:19 pm by Joachim Müller »
Logged

MadMaxx

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 23
Re: Avatar in comments
« Reply #1 on: July 10, 2008, 04:08:31 am »

forgot to give a link to the site:

http://www.customcoversdb.com

test account:
user: test
pass: test

registered account.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: Avatar in comments
« Reply #2 on: July 10, 2008, 08:50:25 am »

Code: [Select]
//loginForm data ... the statistics, pms status
if (USER_ID) {
$loginFormHtml = '<div align=\"left\" class=\"smallfont\"><h2>My Account</h2><hr />'.$lang_pms_sys['welcome'].' <br><strong><a href="profile.php?uid=' .(USER_ID). '">'.(USER_NAME).'</a></strong>';
        //begin avatar
$result =  mysql_query("SELECT user_profile6 FROM {$CONFIG['TABLE_USERS']} WHERE user_id = '".(USER_ID)."'");
    $row = mysql_fetch_array( $result );
  $avatar_url = $row['user_profile6'];
if ($avatar_url !="") $avatar_url = $avatar_url;
else $avatar_url="";
$loginFormHtml .= bb_decode($avatar_url);
        //end avatar

I used the 'user_profile6' field for the user signature in cpgforum! The path to the avatar is stored in 'avatar_url'.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: Avatar in comments
« Reply #3 on: July 10, 2008, 09:09:00 am »

Just edit function theme_html_comments().

Copy the whole function
Code: [Select]
// Displays comments for a specific picture
function theme_html_comments($pid)
{
to your theme.php

Search
Code: [Select]
        $params = array('{MSG_AUTHOR}' => stripslashes($row['msg_author']),
            '{MSG_ID}' => $row['msg_id'],
            '{PID}' => $row['pid'],
            '{EDIT_TITLE}' => &$lang_display_comments['edit_title'],
            '{CONFIRM_DELETE}' => &$lang_display_comments['confirm_delete'],
            '{MSG_DATE}' => localised_date($row['msg_date'], $comment_date_fmt),
            '{MSG_BODY}' => bb_decode($comment_body),
            '{MSG_BODY_RAW}' => $row['msg_body'],
            '{OK}' => &$lang_display_comments['OK'],
            '{SMILIES}' => $smilies,
            '{IP}' => $ip,
            '{REPORT_COMMENT_TITLE}' => &$lang_display_comments['report_comment_title'],
            '{WIDTH}' => $CONFIG['picture_table_width']
            );

add after it
Code: [Select]
        $result_a = cpg_db_query("SELECT avatar_url FROM {$CONFIG['TABLE_USERS']} WHERE user_id={$row['author_id']}");
        $avatar = mysql_fetch_array($result_a);
        $params['{MSG_BODY}'] = "<img src={$avatar[0]} />".$params['{MSG_BODY}'];


Result can be seen in the attachment. It's a very simple solution and could be optimized :D
« Last Edit: July 11, 2008, 07:37:33 am by eenemeenemuu »
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Avatar in comments
« Reply #4 on: July 10, 2008, 12:54:14 pm »

... i changed so many files i wouln't know where to begin...


that is not an excuse as you always should upgrade to the newest version. With what you say, you intend to skip future security releases.

If you heavily modded your gallery, then use a diff viewer to find exactly what you've changed. These changes you can port to the newest coppermine version (as easy as with a mouse click).

I suggest to use WinMerge as it's free and working excellent.

MadMaxx

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 23
Re: Avatar in comments
« Reply #5 on: July 10, 2008, 06:28:41 pm »


@Stramm, i didn't know about that, so i would install the updates and the program would find the changes i made, very nice i'm gonna check it out, thanks for the info.


@eenemeenemuu, thanks it works, just a small problem, it only shows the last comment not the ones before, if i have 4 comments it only shows the 4th one.

Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: Avatar in comments
« Reply #6 on: July 11, 2008, 06:17:34 am »

Oops :o i will check this 8)
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: Avatar in comments
« Reply #7 on: July 11, 2008, 07:43:18 am »

Use:
Code: [Select]
        $result_a = cpg_db_query("SELECT avatar_url FROM {$CONFIG['TABLE_USERS']} WHERE user_id={$row['author_id']}");
        $avatar = mysql_fetch_array($result_a);
        $params['{MSG_BODY}'] = "<img src={$avatar[0]} />".$params['{MSG_BODY}'];

instead of
Code: [Select]
        $result = cpg_db_query("SELECT avatar_url FROM {$CONFIG['TABLE_USERS']} WHERE user_id={$row['author_id']}");
        $avatar = mysql_fetch_array($result);
        $params['{MSG_BODY}'] = "<img src={$avatar[0]} />".$params['{MSG_BODY}'];


(Code updated in first post)
Logged

MadMaxx

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 23
Re: Avatar in comments
« Reply #8 on: July 11, 2008, 08:16:48 am »

great, works perfect now  ;D

thank you so much !
Logged

ibanez

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 47
  • Thanks Coppermine
    • Foto Kafe
Re: Avatar in comments
« Reply #9 on: January 10, 2009, 03:17:04 am »

Just edit function theme_html_comments().

Copy the whole function
Code: [Select]
// Displays comments for a specific picture
function theme_html_comments($pid)
{
to your theme.php

Search
Code: [Select]
        $params = array('{MSG_AUTHOR}' => stripslashes($row['msg_author']),
            '{MSG_ID}' => $row['msg_id'],
            '{PID}' => $row['pid'],
            '{EDIT_TITLE}' => &$lang_display_comments['edit_title'],
            '{CONFIRM_DELETE}' => &$lang_display_comments['confirm_delete'],
            '{MSG_DATE}' => localised_date($row['msg_date'], $comment_date_fmt),
            '{MSG_BODY}' => bb_decode($comment_body),
            '{MSG_BODY_RAW}' => $row['msg_body'],
            '{OK}' => &$lang_display_comments['OK'],
            '{SMILIES}' => $smilies,
            '{IP}' => $ip,
            '{REPORT_COMMENT_TITLE}' => &$lang_display_comments['report_comment_title'],
            '{WIDTH}' => $CONFIG['picture_table_width']
            );

add after it
Code: [Select]
        $result_a = cpg_db_query("SELECT avatar_url FROM {$CONFIG['TABLE_USERS']} WHERE user_id={$row['author_id']}");
        $avatar = mysql_fetch_array($result_a);
        $params['{MSG_BODY}'] = "<img src={$avatar[0]} />".$params['{MSG_BODY}'];


Result can be seen in the attachment. It's a very simple solution and could be optimized :D
great work thanks, if user is not loaded avatar? How to make default avatar?
Thanks
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: [Solved]: Avatar in comments
« Reply #10 on: January 10, 2009, 10:36:21 am »

the path to the avatar is stored in $avatar[0] ... check if it's empty
Code: [Select]
if ($avatar[0] == '')
{
$avatar[0] = 'here_is/the_path/to_the/default_avatar.jpg';
}

ibanez

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 47
  • Thanks Coppermine
    • Foto Kafe
Re: [Solved]: Avatar in comments
« Reply #11 on: January 11, 2009, 01:10:04 am »

the path to the avatar is stored in $avatar[0] ... check if it's empty
Code: [Select]
if ($avatar[0] == '')
{
$avatar[0] = 'here_is/the_path/to_the/default_avatar.jpg';
}
Thanks stramm thanks..
Logged

ibanez

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 47
  • Thanks Coppermine
    • Foto Kafe
Re: [Solved]: Avatar in comments
« Reply #12 on: January 14, 2009, 12:29:45 am »

Hi again,
It is possible?
Thanks

Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: [Solved]: Avatar in comments
« Reply #13 on: January 14, 2009, 07:50:07 am »

include/themes.inc.php find the $template_image_comments

copy it into the theme.php of the theme you're actually using (themes/your_theme/theme.php). First lines should be
Code: [Select]
// HTML template for the display of comments
if (!isset($template_image_comments)) {  //{THEMES}
till the next ending
Code: [Select]
EOT;
Now edit it to your needs

somewhere here add your avatar
Code: [Select]
                        <table width="100%" cellpadding="0" cellspacing="0">
                           <tr>
                                <td class="tableh2_compact" nowrap="nowrap">
                                        <b>{MSG_AUTHOR}</b><a name="comment{MSG_ID}"></a>&nbsp;
$pm_link
and remove it from there
Code: [Select]
        <tr>
                <td class="tableb_compact">
<p>
                        <div id="cbody{MSG_ID}" style="display:block">

                        {AVATAR} {MSG_BODY}</div>
                        </div>
</p>
                        <div id="cedit{MSG_ID}" style="display:none">

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: [Solved]: Avatar in comments
« Reply #14 on: January 14, 2009, 07:56:10 am »

Hi again,
It is possible?
Thanks

In theme_html_comments($pid), search
Code: [Select]
        $params = array('{MSG_AUTHOR}' => stripslashes($row['msg_author']),and replace with
Code: [Select]
        $avatar_url = mysql_result(cpg_db_query("SELECT avatar_url FROM {$CONFIG['TABLE_USERS']} WHERE user_id={$row['author_id']}"),0);
        $params = array('{MSG_AUTHOR}' => "<img src=\"{$avatar_url}\" />".stripslashes($row['msg_author']),
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: [Solved]: Avatar in comments
« Reply #15 on: January 14, 2009, 08:01:03 am »

ibanez doesn't need to edit the function anymore as it is already prepared to query the avatar and his special version even to replace the avatar with a default one if the user hasn't uploaded an avatar
« Last Edit: January 14, 2009, 01:24:04 pm by Stramm »
Logged

ibanez

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 47
  • Thanks Coppermine
    • Foto Kafe
Re: [Solved]: Avatar in comments
« Reply #16 on: January 14, 2009, 01:14:54 pm »

Thank you very much for your effort. It works and seems very good.
Best Regards
Logged
Pages: [1]   Go Up
 

Page created in 0.023 seconds with 16 queries.