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: Different link color for comment of pic author  (Read 2012 times)

0 Members and 1 Guest are viewing this topic.

mahdi1234

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 60
Different link color for comment of pic author
« on: September 16, 2009, 09:58:43 pm »

hello,

Is there a way how to make picture owner to have a different profile link color in comments? What I mean is lets say it's underlined red and comments from other users in a normal way.

I've had a look into theme.php, but there doesn't seem to be a way how to execute query inside of $template_image_comments block, would you have some suggestion on how to achive this?

thanks,
mahdi
Logged

Joe Carver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1510
  • aka 'i-imagine'
    • Home Page
Re: Different link color for comment of pic author
« Reply #1 on: September 16, 2009, 10:43:25 pm »

I won't be able to provide you with more than this....

But look in sample/theme.php for:

Code: [Select]
// Displays comments for a specific picture
function theme_html_comments($pid)
{

And you will find $comment_body - where you might be able to apply your mod

Code: [Select]
       if ($CONFIG['enable_smilies']) {
            $comment_body = process_smilies(make_clickable($row['msg_body']));
            $smilies = generate_smilies("f{$row['msg_id']}", 'msg_body');
        } else {
            $comment_body = make_clickable($row['msg_body']);
            $smilies = '';

Remember to copy the complete function over to your theme.php. - all the way through to:

Code: [Select]
   return $html;
}

Good Luck!

Joe Carver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1510
  • aka 'i-imagine'
    • Home Page
Re: Different link color for comment of pic author
« Reply #2 on: September 16, 2009, 11:23:35 pm »

Now I have re-read your post, you want to mark/highlight the name, not the comment.

The message author's name is in the same function as above (function theme_html_comments)

Code: [Select]
$result = cpg_db_query("SELECT msg_id, msg_author, msg_body, UNIX_TIMESTAMP(msg_date) AS msg_date,
author_id, author_md5_id, msg_raw_ip, msg_hdr_ip, pid FROM {$CONFIG['TABLE_COMMENTS']} WHERE pid='$pid'
ORDER BY msg_id $comment_sort_order");

mahdi1234

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 60
Re: Different link color for comment of pic author
« Reply #3 on: September 17, 2009, 10:42:32 am »

Thanks for pointer i-imagine :)

Here we go (I'm not coding in php, so might be bit lame, but works) all edits are done in theme.php (in my case hardwired). Should not those be present in your theme, copy first from sample one.

function function theme_html_comments($pid)

add at the beginning of the fucntion:
Code: [Select]
    global $CURRENT_PIC_DATA;
    global $USER_DATA;
    $picture_owner = $CURRENT_PIC_DATA['owner_id'];
    $current_user = $USER_DATA['user_id'];

replace
Code: [Select]
    while ($row = mysql_fetch_array($result)) {
        $user_can_edit = (GALLERY_ADMIN_MODE) || (USER_ID && USER_ID == $row['author_id'] && USER_CAN_POST_COMMENTS) || (!USER_ID && USER_CAN_POST_COMMENTS && ($USER['ID'] == $row['author_md5_id']));
        $comment_buttons = $user_can_edit ? $tmpl_comments_buttons : '';
        $comment_edit_box = $user_can_edit ? $tmpl_comment_edit_box : '';
        $comment_ipinfo = ($row['msg_raw_ip'] && GALLERY_ADMIN_MODE)?$tmpl_comments_ipinfo : '';

with
Code: [Select]
    while ($row = mysql_fetch_array($result)) {
        $user_can_edit = (GALLERY_ADMIN_MODE) || (USER_ID && USER_ID == $row['author_id'] && USER_CAN_POST_COMMENTS) || (!USER_ID && USER_CAN_POST_COMMENTS && ($USER['ID'] == $row['author_md5_id']));
        $comment_buttons = $user_can_edit ? $tmpl_comments_buttons : '';
        $comment_edit_box = $user_can_edit ? $tmpl_comment_edit_box : '';
        $comment_ipinfo = ($row['msg_raw_ip'] && GALLERY_ADMIN_MODE)?$tmpl_comments_ipinfo : '';


# check comment author ID
$comment_author = $row['author_id'];

replace
Code: [Select]
if ($CONFIG['enable_smilies']) {
            $comment_body = process_smilies(make_clickable($row['msg_body']));
            $smilies = generate_smilies("f{$row['msg_id']}", 'msg_body');
        } else {
            $comment_body = make_clickable($row['msg_body']);
            $smilies = '';
with (now I don't have smilies enabled, so did not bother to define it for both cases, need to be adjusted in such case for other condition)
Code: [Select]
if ($CONFIG['enable_smilies']) {
            $comment_body = process_smilies(make_clickable($row['msg_body']));
            $smilies = generate_smilies("f{$row['msg_id']}", 'msg_body');
        } else {
            $comment_body = make_clickable($row['msg_body']);
            $smilies = '';

# define variableS
if ($current_user == $comment_author){
$author_color = '<font color=#111111>';
}
elseif ($picture_owner == $comment_author) {
$author_color = '<font color=#cccccc>';
}
else {
$author_color = '<font>';

}

        }

replace
Code: [Select]
        $params = array('{MSG_AUTHOR}' => stripslashes($row['msg_author']),
            '{MSG_ID}' => $row['msg_id'],
            '{MSG_AUTHOR_ID}' => $row['author_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'],
            );
with
Code: [Select]
        $params = array('{MSG_AUTHOR}' => stripslashes($row['msg_author']),
            '{MSG_ID}' => $row['msg_id'],
            '{MSG_AUTHOR_ID}' => $row['author_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'],
            '{AUTHOR_COLOR}' => $author_color
            );

in template $template_image_comments = <<<EOT

in relevant part add {AUTHOR_COLOR} and escape font e.g.
Code: [Select]
<a href ="profile.php?uid={MSG_AUTHOR_ID}"><b>{AUTHOR_COLOR}{MSG_AUTHOR}</font></b></a>
Logged
Pages: [1]   Go Up
 

Page created in 0.018 seconds with 21 queries.