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.phpFind:
$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
:
"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:
//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
Add before (
above it):
//-----------------------------------------------------
//---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&comment_id=".$comment_row[$i]['comment_id']))."\" target=\"admin_edit\">".$lang['edit']."</a> ";
$admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("comments.php?action=removecomment&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&".URL_COMMENT_ID."=".$comment_row[$i]['comment_id'])."\">".$lang['edit']."</a> ";
$admin_links .= ($config['user_delete_comments'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=removecomment&".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)) ? "&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&" . URL_USER_ID . "=" . $user_id)) . '">' . $comment_user_name . '</a>');
}
//---End Member Comments----
Step 2.Open
/lang/<yourlanguage>/main.phpAdd at the end of file, just before
?> :
$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.htmlAdd this tag, whereever u want to display link for comments:
<A href="{url_show_user_comments}"> {lang_show_user_comments} </a>
Step 4.Create new file in
/templates/<yourtemplate>/. Name it as
member_comment_bit.htmlInsert this code (this is just an example, you'll need udjust it for your layout):
<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 ...