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

0 Members and 1 Guest 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 commets from his profile
« Reply #15 on: February 26, 2003, 12:42:43 AM »
Quote from: irishblue
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.

if u installed this mod after my "corrections" post, then dont worry about it, I already fixed in the MOD code.

Also, little hint:
if someone asked u to find for example
Code: [Select]
 $txt_clickstream = $lang['member_comments'].$comment_user_name;and u can not find it, then try to search for just a part of it, like
Code: [Select]
$txt_clickstream = because there maybe difference in extra space at the front or end. :wink:
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 irishblue

  • Pre-Newbie
  • Posts: 8
    • View Profile
[Mod] Show user's commets from his profile
« Reply #16 on: February 26, 2003, 02:21:33 AM »
ah ok I already had the corrected version. thanks :)
I followed all the steps but I'm not sure why the comments link isn't appearing in the profile area. there's a blank space where it is supposed to be and the space links to my main gallery 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 #17 on: February 26, 2003, 12:20:26 PM »
make sure u did changes in /lang/<yourlanguage>/main.php and /templates/<yourtemplate>/member_prifile.html (step 2 and step 3)
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 jengwen

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
    • http://www.jenrichardsphotography.com
[Mod] Show user's commets from his profile
« Reply #18 on: March 16, 2003, 06:56:02 AM »
Just wanted to note that you have to be careful with step 1 of member.php changes.  If you have implemented other mods, like show user's lightbox, the code doesn't look like that anymore and you can't just replace it with what is provided or you will get errors.

Offline rustynet

  • Addicted member
  • ******
  • Posts: 1.031
  • {if msg}{msg}{endif msg}
    • View Profile
    • rustynet.de
[Mod] Show user's commets from his profile
« Reply #19 on: March 17, 2003, 03:41:49 PM »
Sorry because my english is very bad, but i'll try:

I have a question.

What about, if there is one user who had more than 100 comments?

Is it possible to just showing 15 comments per page?

Thank you  :D

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 #20 on: March 17, 2003, 06:50:33 PM »
Quote from: boti
Is it possible to just showing 15 comments per page?

Sure ;)
In my code, find:
Quote
         ORDER BY c.comment_date DESC, c.image_id ASC";

Replace with:
Quote
         ORDER BY c.comment_date DESC, c.image_id ASC
          LIMIT 15";
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 rustynet

  • Addicted member
  • ******
  • Posts: 1.031
  • {if msg}{msg}{endif msg}
    • View Profile
    • rustynet.de
[Mod] Show user's commets from his profile
« Reply #21 on: March 17, 2003, 07:09:39 PM »
V@no, thank you very much :D

but is it possible to make something like this?



so that there are 15 comments for every page?



boti :D

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 #22 on: March 18, 2003, 04:50:03 AM »
Quote from: boti
V@no, thank you very much :D

but is it possible to make something like this?



so that there are 15 comments for every page?



boti :D

Here u go:

In Step 1.2 find:
Code: [Select]
   $additional_sql = "";
Add before:
Code: [Select]
if (isset($HTTP_POST_VARS['commentsetperpage']) || isset($HTTP_GET_VARS['commentsetperpage'])) {
  $commentsetperpage = (intval($HTTP_POST_VARS['commentsetperpage']) ) ? intval($HTTP_POST_VARS['commentsetperpage']) : intval($HTTP_GET_VARS['commentsetperpage']);
  if ($commentsetperpage) {
    $site_sess->set_session_var("commentperpage", $commentsetperpage);
    $session_info['commentperpage'] = $commentsetperpage;
  }
}

if (isset($session_info['commentperpage'])) {
  $commentperpage = $session_info['commentperpage'];
}
else {
  $commentperpage = 5;
}
      $sql = "SELECT COUNT(user_id) AS comments
          FROM ".COMMENTS_TABLE."
          WHERE user_id = ".$user_id;
  $result = $site_db->query_firstrow($sql);
  $num_comments = $result['comments'];
$site_db->free_result();
$num_rows_all = (isset($num_comments)) ? $num_comments : 0;
$link_arg = $site_sess->url(ROOT_PATH."member.php?action=showcomments&user_id=$user_id");
include(ROOT_PATH.'includes/paging.php');
$getpaging = new Paging($page, $commentperpage, $num_rows_all, $link_arg);
$offset = $getpaging->get_offset();
$site_template->register_vars(array(
 "paging" => $getpaging->get_paging(),
 "paging_stats" => $getpaging->get_paging_stats()
));

then, little bit down, u should find:
Code: [Select]
         ORDER BY c.comment_date DESC, c.image_id ASC";
Replace with:
Code: [Select]
         ORDER BY c.comment_date DESC, c.image_id ASC
          LIMIT $offset, $commentperpage";


then, open /templates/<yourtemplate>/member.html
use this tags:
Code: [Select]
{if paging}{paging}{endif paging}
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 rustynet

  • Addicted member
  • ******
  • Posts: 1.031
  • {if msg}{msg}{endif msg}
    • View Profile
    • rustynet.de
[Mod] Show user's commets from his profile
« Reply #23 on: March 18, 2003, 07:38:11 AM »
Strange,

i always see the same comments in every 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 #24 on: March 18, 2003, 01:58:55 PM »
Quote from: boti
Strange,

i always see the same comments in every page.  :?

Oops, sry, missed one step. I just corrected my post.
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 rustynet

  • Addicted member
  • ******
  • Posts: 1.031
  • {if msg}{msg}{endif msg}
    • View Profile
    • rustynet.de
[Mod] Show user's commets from his profile
« Reply #25 on: March 18, 2003, 02:43:50 PM »
V@no,

there is a problem,

DB Error: Bad SQL Query: 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, u.user_level, u.user_name, u.user_email, u.user_showemail, u.user_invisible, u.user_joindate, u.user_lastaction, u.user_comments, u.user_homepage, u.user_icq FROM 4images_comments c LEFT JOIN 4images_users u ON (u.user_id = c.user_id) WHERE c.user_id = 12 ORDER BY c.comment_date DESC, c.image_id ASC LIMIT ,
You have an error in your SQL syntax near ' ' at line 6


boti

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 #26 on: March 18, 2003, 09:52:02 PM »
I think u did something not right. here is the code from Step 1.2. I have:
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) {
      $num_comments = "";
      $user_id = GUEST;
    }
if (isset($HTTP_POST_VARS['commentsetperpage']) || isset($HTTP_GET_VARS['commentsetperpage'])) {
  $commentsetperpage = (intval($HTTP_POST_VARS['commentsetperpage']) ) ? intval($HTTP_POST_VARS['commentsetperpage']) : intval($HTTP_GET_VARS['commentsetperpage']);
  if ($commentsetperpage) {
    $site_sess->set_session_var("commentperpage", $commentsetperpage);
    $session_info['commentperpage'] = $commentsetperpage;
  }
}

if (isset($session_info['commentperpage'])) {
  $commentperpage = $session_info['commentperpage'];
}
else {
  $commentperpage = 5;
}
      $sql = "SELECT COUNT(user_id) AS comments
          FROM ".COMMENTS_TABLE."
          WHERE user_id = ".$user_id;
  $result = $site_db->query_firstrow($sql);
  $num_comments = $result['comments'];
$site_db->free_result();
$num_rows_all = (isset($num_comments)) ? $num_comments : 0;
$link_arg = $site_sess->url(ROOT_PATH."member.php?action=showcomments&user_id=$user_id");
include(ROOT_PATH.'includes/paging.php');
$getpaging = new Paging($page, $commentperpage, $num_rows_all, $link_arg, $lang['comment_stats']);
$offset = $getpaging->get_offset();
$site_template->register_vars(array(
 "paging" => $getpaging->get_paging(),
 "paging_stats" => $getpaging->get_paging_stats()
));

    $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
          LIMIT $offset, $commentperpage";
  $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);
}
  else {
    $num_comments = "";
}
  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 = $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 = $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;
      $text = $comment_row[$i]['comment_text'];
if (strlen($text) > 100) {
$text = substr($text, 0, 100)."...";
}
      $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>",
      "lang_control_panel" => $lang['comments'],
      "lang_comments_per_page" => $lang['comments_per_page'],
        "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($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'].$comment_user_name;
$control_panel = $lang['comments'];
}
//---End Member Comments----
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 rustynet

  • Addicted member
  • ******
  • Posts: 1.031
  • {if msg}{msg}{endif msg}
    • View Profile
    • rustynet.de
[Mod] Show user's commets from his profile
« Reply #27 on: March 18, 2003, 10:06:21 PM »
V@no, it' work,

it's very nice, perfect.

Thank's V@no  :D

Offline Art1977

  • Newbie
  • *
  • Posts: 37
    • View Profile
    • http://www.d-mack.de
sorry i only see the last comment
« Reply #28 on: May 28, 2003, 01:38:09 AM »
with all your code , i only see the last comment of the user and can navigate through his comments with paging ,but how could i see for example 15 comments per 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 #29 on: May 28, 2003, 02:55:23 AM »
4 should be by default:
$commentperpage = 5;
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)