Oryginalny tytuł [MOD] Show user's comments from his profile
Autor:
V@no
Wersja:
Kompatybilne z 4images wersją 1.7 - 1.7.9
Demo
Modyfikacja pozwala na wyświetlenie wszystkich komentarzy zredagowanych przez tego samego użytkownika. Link zainstalowany w profilu użytkownika, oraz w szablonach komentarzy wyświetlanych na stronach szczegółowych poszczególnych zdjęć pokaże wszystkie komentarze danego użytkownika.
Zmienione zostaną pliki:
member.php
/lang/polish/main.php
/templates/<yourtemplate>/member_profile.html
Nowe pliki:
member_comment_bit.html
Krok 1
Otwórz plik
member.php i odszukaj
$site_template->register_vars(array(
"user_id" => $user_row['user_id'],
"user_name" => (isset($user_row['user_name'])) ? format_text($user_row['user_name'], 2) : REPLACE_EMPTY,
i pod tym kodem dodaj
// ----------------------------------------------------------------
// ------- Start [Mod] Show user's comments from his profile ------
// ----------------------------------------------------------------
"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']),
// ----------------------------------------------------------------
// ------- End [Mod] Show user's comments from his profile --------
// ----------------------------------------------------------------
Dalej odszukaj
//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
Przed tym kodem dodaj
// ----------------------------------------------------------------
// ------- Start [Mod] Show user's comments from his profile ------
// ----------------------------------------------------------------
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 [Mod] Show user's comments from his profile --------
// ----------------------------------------------------------------
Krok 2
Otwórz plik
main.php, ścieżka
/lang/polish/main.php i odszukaj (na samym końcu)
Przed tym kodem dodaj
$lang['show_user_comments'] = "Wszystkie napisane komentarze";
$lang['member_comments'] = "Wszystkie napisane komentarze użytkownika ";
$lang['user_comments'] = "Wszystkie napisane komentarze użytkownika";
$lang['member_no_comments'] = "Ten użytkownik nie komentował jeszcze żadnego zdjęcia.";
Krok 3
Otwórz plik
member_profile.html, ścieżka
/templates/twoj_szablon/member_profile.html i wstaw poniższy link w dogodne miejsce.
<a href="{url_show_user_comments}"> {lang_show_user_comments} </a>
Krok 4
Stwórz nowy plik
member_comment_bit.html, ścieżka
templates/twoj_szablon/member_comment_bit.html
<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>
Ten obraz jest ukryty dla gości. Zaloguj się lub zarejestruj aby go zobaczyć.
Dalsza część modyfikacji jest uwarunkowany instalacją
MOD - Wszystkie komentarze
Krok 5
Otwórz plik
comments_all.php i odszukaj
$comment_user_profile_link = ($comment_user_profile_link) ? "<a href=\"".$comment_user_profile_link."\">".$comment_user_name."</a>" : $comment_user_name;
i zaraz pod nim dodaj
$lang_user_comments = "Alle Kommentare des Users"; //Hier Wortlaut des Links
if ( $user_info['user_level'] == GUEST ) {
$comment_user_comments_link = "";
} else {
$comment_user_comments_link = $site_sess->url(ROOT_PATH."member.php?action=showcomments&user_id=".$comment_user_id);
}
$comment_user_comments_link = ($comment_user_comments_link) ? "<a href=\"".$comment_user_comments_link."\">".$lang_user_comments."</a>" : $lang_user_comments ;
Dalej w
comments_all.php odszukaj
"comment_user_name" => $comment_user_profile_link,
i zaraz pod nim dodaj
"user_comments" => $comment_user_comments_link,
Krok 6
Otwórz plik
comments_all_bit.html, ścieżka
templates/twoj_szablo/comments_all_bit.html i odszukaj
{lang_com_by} : {comment_user_name} [{comment_user_info}]
następnie zmień go na
{lang_com_by} : {comment_user_name} [{comment_user_info}] [{user_comments}]
Ten obraz jest ukryty dla gości. Zaloguj się lub zarejestruj aby go zobaczyć.
Dalsza część modyfikacji pozwoli wyświetlić link
Komentarze użytkownika w komentarzach na stronie szczegółowej fotografii.
Krok 6
Otwórz plik
details.php i odszukaj
$comment_user_icq = (isset($comment_row[$i][$user_table_fields['user_icq']])) ? format_text($comment_row[$i][$user_table_fields['user_icq']]) : "";
if (!empty($comment_user_icq)) {
$comment_user_icq_button = "<a href=\"http://www.icq.com/people/about_me.php?uin=".$comment_user_icq."\" target=\"_blank\"><img src=\"http://status.icq.com/online.gif?icq=".$comment_user_icq."&img=5\" width=\"18\" height=\"18\" border=\"0\" alt=\"".$comment_user_icq."\" /></a>";
}
i zaraz pod nim dodaj
//------------------------------------------------------------
//----------- Start [Mod] Alle Kommentare des Users ---------
//------------------------------------------------------------
$lang_user_comments = $lang['user_comments']; //Hier Wortlaut des Links
if ( $user_info['user_level'] == GUEST ) {
$comment_user_comments_link = "";
} else {
$comment_user_comments_link = $site_sess->url(ROOT_PATH."member.php?action=showcomments&user_id=".$comment_user_id);
}
$comment_user_comments_link = ($comment_user_comments_link) ? "<a href=\"".$comment_user_comments_link."\">".$lang_user_comments."</a>" : $lang_user_comments ;
//------------------------------------------------------------
//----------- End [Mod] Alle Kommentare des Users ------------
//------------------------------------------------------------
Dalej w
details.php odszukaj
"comment_user_ip" => $comment_user_ip,
i zaraz pod nim dodaj
"user_comments" => $comment_user_comments_link,
Otwórz plik
comment_bit.html, ścieżka
/templates/twoj_szablon/comment_bit.html i odszukaj
{comment_user_icq_button}
i zaraz pod nim dodaj
Ten obraz jest ukryty dla gości. Zaloguj się lub zarejestruj aby go zobaczyć.
Ten obraz jest ukryty dla gości. Zaloguj się lub zarejestruj aby go zobaczyć.