Author Topic: [Mod] Show user's comments from his profile  (Read 128005 times)

0 Members and 2 Guests are viewing this topic.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[Mod] Show user's comments from his profile
« on: February 14, 2003, 01:15:06 AM »
This mod will work "almost" same as "Display all images added by user" in user's profile.

---------------------------
Modifyed files:
member.php
/lang/<yourlanguage>/main.php
/templates/<yourtemplate>/member_profile.html


New template:
member_comment_bit.html
---------------------------


Step 1.
Open member.php

Find:
Code: [Select]
   $site_template->register_vars(array(
      "user_id" => $user_row['user_id'],
      "user_name" => (isset($user_row['user_name'])) ? htmlspecialchars($user_row['user_name']) : REPLACE_EMPTY,
Insert below :below::
Code: [Select]
 "lang_show_user_comments" => $lang['show_user_comments'],
      "url_show_user_comments" => $site_sess->url(ROOT_PATH."member.php?action=showcomments&user_id=".$user_row['user_id']),

1.2.
Find:
Code: [Select]
//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
Add before (:above: above it):
Code: [Select]
//-----------------------------------------------------
//---Show Member Comments-------------------------------
//-----------------------------------------------------

if ($action == "showcomments") {

  if (isset($HTTP_GET_VARS[URL_USER_ID]) || isset($HTTP_POST_VARS[URL_USER_ID])) {
    $user_id = (isset($HTTP_GET_VARS[URL_USER_ID])) ? intval($HTTP_GET_VARS[URL_USER_ID]) : intval($HTTP_POST_VARS[URL_USER_ID]);
    if (!$user_id) {
      $user_id = GUEST;
    }
  }
  else {
    $user_id = GUEST;
  }

    $additional_sql = "";
      $table_fields = $site_db->get_table_fields(USERS_TABLE);
      foreach ($additional_user_fields as $key => $val) {
        if (isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key])) {
          $additional_sql .= ", $key = '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
        }
      }
  $sql = "SELECT c.comment_id, c.image_id, c.user_id, c.user_name AS comment_user_name, c.comment_headline, c.comment_text, c.comment_ip, c.comment_date".get_user_table_field(", u.", "user_level").get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_email").get_user_table_field(", u.", "user_showemail").get_user_table_field(", u.", "user_invisible").get_user_table_field(", u.", "user_joindate").get_user_table_field(", u.", "user_lastaction").get_user_table_field(", u.", "user_comments").get_user_table_field(", u.", "user_homepage").get_user_table_field(", u.", "user_icq").$additional_sql."
          FROM ".COMMENTS_TABLE." c
          LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = c.user_id)
          WHERE c.user_id = $user_id
          ORDER BY c.comment_date DESC, c.image_id ASC";
  $result = $site_db->query($sql);
  $comment_row = array();
  while ($row = $site_db->fetch_array($result)) {
    $comment_row[] = $row;
  }
  $site_db->free_result($result);
  $num_comments = sizeof($comment_row);
  if (!$num_comments) {
    $comments = "<TABLE width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"bordercolor\"><tr><td class=\"commentrow1\" colspan=\"2\">".$lang['member_no_comments']."</td></tr></table>";
  }
  else {
    $comments = "";
    $bgcounter = 0;
$comments ="<TABLE width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"bordercolor\">\n<TR>\n<TD>\n<TABLE width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\">\n";
$current = "";
    for ($i = 0; $i < $num_comments; $i++) {
 $image_id = $comment_row[$i]['image_id'];
      $sql = "SELECT i.image_id, i.cat_id, i.image_name, c.cat_name, i.image_media_file, i.image_thumb_file, i.image_allow_comments
            FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
            LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
            WHERE i.image_id = $image_id AND c.cat_id = i.cat_id";
      $image_row = $site_db->query_firstrow($sql);
      $cat_id = (isset($image_row['cat_id'])) ? $image_row['cat_id'] : 0;
 $image_allow_comments = (check_permission("auth_readcomment", $cat_id)) ? $image_row['image_allow_comments'] : 0;
     if ($image_allow_comments == 1){
 if ($current != $comment_row[$i]['image_id']) {
$comments .= ($i == 0) ? "" : "</TABLE>\n</TD>\n</TR>\n</TABLE>\n<br>\n<TABLE width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"bordercolor\">\n<TR>\n<TD>\n<TABLE width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\">\n";
$same = 1;
 }else{
$same = 0;
 }
      $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;

      $comment_user_name = htmlspecialchars($comment_row[$i]['comment_user_name']);
      $comment_user_info = $lang['userlevel_guest'];

      $comment_user_id = $comment_row[$i]['user_id'];
 $user_row_comment = get_user_info($comment_user_id);
      if (isset($comment_row[$i][$user_table_fields['user_name']]) && $comment_user_id != GUEST) {
        $comment_user_name = htmlspecialchars($comment_row[$i][$user_table_fields['user_name']]);

        $comment_user_info .= "<br />";
      }

      $comment_user_ip = ($user_info['user_level'] == ADMIN) ? $comment_row[$i]['comment_ip'] : "";

      $admin_links = "";
      if ($user_info['user_level'] == ADMIN) {
        $admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("comments.php?action=editcomment&amp;comment_id=".$comment_row[$i]['comment_id']))."\" target=\"admin_edit\">".$lang['edit']."</a>&nbsp;";
        $admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("comments.php?action=removecomment&amp;comment_id=".$comment_row[$i]['comment_id']))."\" target=\"admin_edit\">".$lang['delete']."</a>";
      }
      elseif ($is_image_owner) {
        $admin_links .= ($config['user_edit_comments'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=editcomment&amp;".URL_COMMENT_ID."=".$comment_row[$i]['comment_id'])."\">".$lang['edit']."</a>&nbsp;";
        $admin_links .= ($config['user_delete_comments'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=removecomment&amp;".URL_COMMENT_ID."=".$comment_row[$i]['comment_id'])."\">".$lang['delete']."</a>";
      }
 $show_link = (!check_permission("auth_viewcat", $cat_id) || !check_permission("auth_viewimage", $cat_id)) ? 0 : 1;
      $site_template->register_vars(array(
"comment_image" => ($same) ? get_thumbnail_code($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, 0, 1) : "",
"comment_image_name" => (!$show_link) ? $image_row['image_name'] : "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$comment_row[$i]['image_id'].((!empty($mode)) ? "&amp;mode=".$mode : ""))."\">".$image_row['image_name']."</a>",
"comment_cat_name" => (!check_permission("auth_viewcat", $cat_id)) ? $image_row['cat_name'] : "<a href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id)."\" class=\"smalltext\">".$image_row['cat_name']."</a>",
        "comment_id" => $comment_row[$i]['comment_id'],
        "comment_user_id" => $comment_user_id,
        "comment_user_name" => $comment_user_name,
        "comment_user_info" => $comment_user_info,
        "comment_user_ip" => $comment_user_ip,
        "comment_headline" => format_text($comment_row[$i]['comment_headline'], 0, $config['wordwrap_comments'], 0, 0),
        "comment_text" => format_text($comment_row[$i]['comment_text'], $config['html_comments'], $config['wordwrap_comments'], $config['bb_comments'], $config['bb_img_comments']),
        "comment_date" => format_date($config['date_format']." ".$config['time_format'], $comment_row[$i]['comment_date']),
        "row_bg_number" => $row_bg_number,
        "admin_links" => $admin_links
      ));
      $comments .= $site_template->parse_template("member_comment_bit");

 $current = $comment_row[$i]['image_id'];
}
    } // end while
  } //end else
  $comments .= "</TABLE>\n</TD>\n</TR>\n</TABLE>\n";
  $content = $comments;
  $txt_clickstream = $lang['member_comments'].(($user_id == GUEST) ? $lang['userlevel_guest'] : '<a href="' . (!empty($url_show_profile) ? str_replace("{user_id}", $user_id, $url_show_profile) : $site_sess->url(ROOT_PATH."member.php?action=showprofile&amp;" . URL_USER_ID . "=" . $user_id)) . '">' . $comment_user_name . '</a>');
}
//---End Member Comments----


Step 2.
Open /lang/<yourlanguage>/main.php

Add at the end of file, just before ?> :
Code: [Select]
$lang['show_user_comments'] = "Show user's comments";
$lang['member_comments'] = "Comments added by ";
$lang['member_no_comments'] = "There are no comments for this user";


Step 3.
Open /templates/<yourtemplate>/member_profile.html

Add this tag, whereever u want to display link for comments:
Code: [Select]
<A href="{url_show_user_comments}">&nbsp;&nbsp;{lang_show_user_comments}&nbsp;&nbsp;</a>

Step 4.
Create new file in /templates/<yourtemplate>/. Name it as member_comment_bit.html

Insert this code (this is just an example, you'll need udjust it for your layout):
Code: [Select]
<TR>
  <TD class="commentrow{row_bg_number}" valign="top">
    <B> {comment_image_name}</B><BR />
{comment_cat_name}<BR />
<TABLE border="0" cellpadding="0" cellspacing="0" width="100" height="100" align="center">
<TR>
<TD valign="middle" align="center">
{comment_image}
</TD>
</TR>
</TABLE>
{if comment_user_ip}<BR /><BR /><B>IP:</B> {comment_user_ip}{endif comment_user_ip}
  </TD>
  <TD width="100%" class="commentrow{row_bg_number}" valign="top">
    <TABLE width="100%" >
      <TR>
        <TD valign="top"><B>{comment_headline}</B></TD>
        <TD valign="top" align="right">{if admin_links}{admin_links}{endif admin_links}</TD>
      </TR>
    </TABLE>
<BR /><BR />
    {comment_text}
  </TD>
</TR>
<TR>
  <TD class="commentrow{row_bg_number}" nowrap="nowrap" colspan="2">
    {comment_date}
  </TD>
</TR>


-----------------------------------------------------------
edited by mawenzi 15.06.2007 :
- is now compatible with MySQL 5 ...
« Last Edit: July 31, 2010, 09:59:32 PM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Jasondavis

  • Full Member
  • ***
  • Posts: 157
    • View Profile
lil problem
« Reply #1 on: February 14, 2003, 02:51:58 AM »
Hey V@no thank you I love this MOD...i have 1 small problem, well 2 small problems...

When i go to /member.php?action=showprofile&user_id=5 it shows the page and everything looks great....

Problem i'm having;
1) On my user profile page it has the link....but it doesn't show any text...I did add it to the lang file but it doesnt' show up/
2) Beside the text not being there the link points to my gallery's homepage instead of member.php?action=showprofile&user_id=5


Thanks again,
Jason

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[Mod] Show user's commets from his profile
« Reply #2 on: February 14, 2003, 03:07:04 AM »
did u do step 1?
it needs insert this code:
Code: [Select]
    "lang_show_user_comments" => $lang['show_user_comments'],
      "url_show_user_comments" => $site_sess->url(ROOT_PATH."member.php?action=showcomments&user_id=".$user_row['user_id']),

make sure u inserted in
"Show profile" part in member.php, not "Edit profile"[/b]
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Jasondavis

  • Full Member
  • ***
  • Posts: 157
    • View Profile
thank u
« Reply #3 on: February 14, 2003, 03:44:36 AM »
make sure u inserted in
"Show profile" part in member.php, not "Edit profile"[/b]
  Thats where my mistake was, thanks!  

Also I added it next to the # of comments people have in there profile :)

drhtm

  • Guest
[Mod] Show user's commets from his profile
« Reply #4 on: February 14, 2003, 04:46:30 AM »
Wow, V@no,

this is great!

I had a problem at first and it was because of the avatar mod that i implemented on my site.  I couldn't find the first step but after troubleshooting around, I figured it out...maybe you might want to include that in the direction of the mod.  Anyhow,  This is a great mod and I think people could really use this one.

Two other requests:

1) is it possible to show top commentor (like who comments the most) maybe in the top.php file.

2) is there a way to add a side box like under the random image box, the last 5 comments.  I tried the one you created on a different thread, but its real hard to follow.  Maybe create it again using the directions like here.  I really like your directions and its easy to follow.

Just a suggestion...again, if you or anyone else is interested in creating a site devoted to mod's (not just a forum) i could possibly entertain this idea with a small space on my server.  mycrazyhosting.com is my new company (it's still underproduction !) but the space is available!  just get a domain name and i'll do the rest!  email me or PM if you or anyone else is interested!  this might be a good idea to consolidate all the mod's on one site instead of people fishing around in the forum! which at times can be very fustrating!

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
[Mod] Show user's commets from his profile
« Reply #5 on: February 14, 2003, 10:17:19 AM »
V@no, I'm afraid, there's a mistake in the script... it shows all comments of yourself (currently logged in user), not of the current profile owner. I believe something wrong with WHERE c.user_id = $user_id query (or something wrong with me :) )

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[Mod] Show user's commets from his profile
« Reply #6 on: February 14, 2003, 11:12:55 AM »
Quote from: SLL
V@no, I'm afraid, there's a mistake in the script... it shows all comments of yourself (currently logged in user), not of the current profile owner. I believe something wrong with WHERE c.user_id = $user_id query (or something wrong with me :) )

are u sure about that?
the only reason I could think it happens to u, because u added something else in the script...
$user_id is taken from the url.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
[Mod] Show user's commets from his profile
« Reply #7 on: February 14, 2003, 11:26:17 AM »
well... check yourself at http://faces.dalnet.ru
your mod is there already

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[Mod] Show user's commets from his profile
« Reply #8 on: February 14, 2003, 11:38:28 AM »
strange...
maybe u added something that messing up with it?
any integrations with message boards? any other mods?
I've checked my step-by-step installation on fresh 4images and it worked just fine.
if nothing helped, try to go through the code of this mod, and change user_id to something else, like user_id2... :?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[Mod] Show user's commets from his profile
« Reply #9 on: February 14, 2003, 12:05:02 PM »
Ah, sorry, that was my misstake  :oops:
I just corrected step 1.2

Add after
Code: [Select]
if ($action == "showcomments") {
this:
Code: [Select]
 if (isset($HTTP_GET_VARS[URL_USER_ID]) || isset($HTTP_POST_VARS[URL_USER_ID])) {
    $user_id = (isset($HTTP_GET_VARS[URL_USER_ID])) ? intval($HTTP_GET_VARS[URL_USER_ID]) : intval($HTTP_POST_VARS[URL_USER_ID]);
    if (!$user_id) {
      $user_id = GUEST;
    }
  }
  else {
    $user_id = GUEST;
  }


Also, little correction:
Code: [Select]
 $txt_clickstream = $lang['member_comments'].$comment_user_name;
change to this:
Code: [Select]
 $txt_clickstream = $lang['member_comments'].(($user_id == GUEST) ? $lang['userlevel_guest'] : $comment_user_name);
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
[Mod] Show user's commets from his profile
« Reply #10 on: February 14, 2003, 12:07:41 PM »
just added
Code: [Select]
$user_id = (isset($HTTP_GET_VARS[URL_USER_ID])) ? intval($HTTP_GET_VARS[URL_USER_ID]) : intval($HTTP_POST_VARS[URL_USER_ID]);
before query, now it works fine

Offline bag53

  • Jr. Member
  • **
  • Posts: 62
    • View Profile
[Mod] Show user's commets from his profile
« Reply #11 on: February 16, 2003, 06:44:43 AM »
Is there a way to add a title to the top of the generated comment page? I know I have to modify member_comment_bit.html, but which html variable tag do I use? {user_name}?

What I'm saying is, after you click the link to view all that user's comments, the generated page does not contain that user's name at all. How would I be able to put "Comments Posted By {user_name}"  at the top of the page?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[Mod] Show user's commets from his profile
« Reply #12 on: February 16, 2003, 06:57:21 AM »
Quote from: bag53
Is there a way to add a title to the top of the generated comment page? I know I have to modify member_comment_bit.html, but which html variable tag do I use? {user_name}?

What I'm saying is, after you click the link to view all that user's comments, the generated page does not contain that user's name at all. How would I be able to put "Comments Posted By {user_name}"  at the top of the page?

use {comment_user_name}
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline IngoT

  • Newbie
  • *
  • Posts: 49
    • View Profile
Userīs Name
« Reply #13 on: February 18, 2003, 02:49:38 PM »
An idea like the name to be represented can:

/lang/<yourlanguage>/main.php  (german example)

$lang['show_user_comments'] = "Alle Kommentare von ";
$lang['member_comments'] = "Kommentare von ";
$lang['member_no_comments'] = "Keine Kommentare von diesem User";

/lang/<yourlanguage>/main.php  (english example)

$lang['show_user_comments'] = "Show comments from ";
$lang['member_comments'] = "Comments added by ";
$lang['member_no_comments'] = "There are no comments for this user";


/templates/<yourtemplate>/member_profile.html

<tr>
<td valign="top" class="head1"></td>
<td valign="top" class="head1" align="right"><a href="{url_show_user_comments}" class="head1">{lang_show_user_comments}{user_name}</a></td>
</tr>

CU Ingo

See here:
http://www.digitalfotograf.com/bilderkiste/member.php?action=showprofile&user_id=2

Offline irishblue

  • Pre-Newbie
  • Posts: 8
    • View Profile
[Mod] Show user's commets from his profile
« Reply #14 on: February 25, 2003, 02:30:51 PM »
Quote from: V@no
Also, little correction:
Code: [Select]
 $txt_clickstream = $lang['member_comments'].$comment_user_name;
change to this:
Code: [Select]
 $txt_clickstream = $lang['member_comments'].(($user_id == GUEST) ? $lang['userlevel_guest'] : $comment_user_name);


Where can I find this bit? I did a find in the member.php and language main.php and the html files but I didn't get to find the first line to replace.