Author Topic: [MOD] Answers in Comments like on YouTube  (Read 28253 times)

0 Members and 1 Guest are viewing this topic.

Offline Lunat

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
    • В объективе - МИР!
[MOD] Answers in Comments like on YouTube
« on: December 05, 2008, 05:59:00 PM »
Whether it is possible, that users could answer concrete comments to a photo?
I'm need the following: that user could answer each other in comments to photos like on youtube





The answer and solution by alekinna here :
http://www.4homepages.de/forum/index.php?topic=23498.msg130641#msg130641
« Last Edit: September 25, 2009, 10:28:14 AM by mawenzi »

Offline batu544

  • Sr. Member
  • ****
  • Posts: 336
    • View Profile
    • Free Celebrity wallpapers
Re: Answers in comments
« Reply #1 on: December 06, 2008, 12:17:21 PM »
Oh !! yes.. by posting a new comment  :mrgreen:


Offline Lunat

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
    • В объективе - МИР!
Re: Answers in comments
« Reply #2 on: December 10, 2008, 02:16:12 PM »
so, hwo can help?

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: Answers in comments
« Reply #3 on: December 10, 2008, 02:41:54 PM »
Lunat,

in 4images user can post comments to the photo..

or do you mean comments for comment?
cheers
Nicky
Your first three "must do" before you ask a question ! ( by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi

Offline Lunat

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
    • В объективе - МИР!
Re: Answers in comments
« Reply #4 on: December 10, 2008, 02:46:19 PM »
oh ok. I'm know it!  :lol:

I'm need the following: that user could answer each other in comments to photos

P.S. Sorry,for my bad english, I try as I can  :!: :mrgreen:

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
Re: Answers in comments
« Reply #5 on: December 10, 2008, 03:08:53 PM »
Something like on youtube?
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 Lunat

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
    • В объективе - МИР!
Re: Answers in comments
« Reply #6 on: December 10, 2008, 03:14:04 PM »
Something like on photosight.ru (for example)

V@no русский ты наш человек)) Спасибо за прошлую помощь. Пока ты тут, перехожу на русский. Вот смотри как на фотосайте например тут. в 7 и 9 комментарии. То есть например автор фотки может ответить на конкретный коммент. И получается градация некая...

Offline Lunat

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
    • В объективе - МИР!
Re: Answers in comments
« Reply #7 on: December 12, 2008, 04:33:24 PM »
and like on youtube. yes.

Offline Lunat

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
    • В объективе - МИР!
Re: Answers in comments
« Reply #8 on: December 15, 2008, 12:18:55 PM »
People wish to communicate, but often pass answers to the comments. BECAUSE there are no notices  :(

Offline alekinna

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
    • Gallery of cross-stitching
Re: Answers in comments
« Reply #9 on: January 13, 2009, 09:02:18 PM »
Hi all,

I know that Lunat already use my solution on his site, but we don't shure that found all bugs.
I trust on your help.

1. in the file member.php

find line with
Code: [Select]
$sql = "SELECT c.comment_id, c.user_id AS comment_user_id,
insert into
Code: [Select]
c.response, c.comment_response,
1.1 find
Code: [Select]
if ($comment_row['comment_user_id'] != GUEST) {
add above
Code: [Select]
if ($comment_row['comment_response'] != 0 && $comment_row['response'] != 0) {
    $sql = "UPDATE ".COMMENTS_TABLE."
            SET comment_response = ".$comment_row['comment_response']."
            WHERE comment_response = ".$comment_row['comment_id'];
    $site_db->query($sql);
  }
  elseif ($comment_row['response'] && $comment_row['comment_response'] == 0) {
    $sql = "UPDATE ".COMMENTS_TABLE."
            SET comment_response = 0
            WHERE comment_response = ".$comment_row['comment_id'];
    $site_db->query($sql);
  }
  elseif ($comment_row['comment_response'] && $comment_row['response'] == 0) {
    $response_id = $comment_row['comment_response'];
      while ($response_id != 0) {
        $sql = "SELECT comment_id, user_id, comment_response
                FROM ".COMMENTS_TABLE."
                WHERE comment_id = $response_id";
        $row = $site_db->query_firstrow($sql);
        $response_id = $row['comment_response'];
        $com_id = $row['comment_id'];

        $sql = "DELETE FROM ".COMMENTS_TABLE."
                WHERE comment_id = $com_id";
        $site_db->query($sql);
        update_comment_count($comment_row['image_id'], $row['user_id']);
      }
  }


2. in the file details.php

find
Code: [Select]
$comment_text = un_htmlspecialchars(trim($HTTP_POST_VARS['comment_text']));
add below
Code: [Select]
$response_to = (isset($HTTP_POST_VARS['response_to'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['response_to'])) : "";
2.1 find
Code: [Select]
if (!$error)  {
      $sql = "INSERT INTO ".COMMENTS_TABLE."
              (image_id, user_id, user_name, comment_headline, comment_text, comment_ip, comment_date)
              VALUES
              ($id, ".$user_info['user_id'].", '$user_name', '$comment_headline', '$comment_text', '".$session_info['session_ip']."', ".time().")";
      $site_db->query($sql);
      $commentid = $site_db->get_insert_id();
      update_comment_count($id, $user_info['user_id']);
      $msg = $lang['comment_success'];

replace with
Code: [Select]
if (!$error)  {
      if ($response_to) {
        $response = 1;
      } else {$response = 0;}
      $sql = "INSERT INTO ".COMMENTS_TABLE."
              (image_id, user_id, user_name, comment_headline, comment_text, comment_ip, comment_date, response)
              VALUES
              ($id, ".$user_info['user_id'].", '$user_name', '$comment_headline', '$comment_text', '".$session_info['session_ip']."', ".time().", '$response')";
      $site_db->query($sql);
      $commentid = $site_db->get_insert_id();
      update_comment_count($id, $user_info['user_id']);
      $msg = $lang['comment_success'];

      if ($response_to) {
        $sql = "UPDATE ".COMMENTS_TABLE."
                SET comment_response = '$commentid'
                WHERE comment_id = $response_to";
        $site_db->query($sql);
      }

2.2 find line with
Code: [Select]
$sql = "SELECT c.comment_id, c.image_id, c.user_id, c.user_name AS comment_user_name,
insert into
Code: [Select]
c.comment_response, c.response,
2.3 find
Code: [Select]
WHERE c.image_id = $image_id
replace with
Code: [Select]
WHERE c.image_id = $image_id AND c.response = 0
2.4 find
Code: [Select]
$comment_user_info = $lang['userlevel_guest'];
add below
Code: [Select]
$comment_headline = format_text($comment_row[$i]['comment_headline'], 0, $config['wordwrap_comments'], 0, 0);
2.5 find
Code: [Select]
$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=\"_blank\">".$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=\"_blank\">".$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>";
      }

add below
Code: [Select]
$responses = "";
    $response_comment_id = "";
      if ($comment_row[$i]['comment_response'] != 0) {
        $bg_number = $bgcounter;
        $response_bg = ($bg_number++ % 2 == 0) ? 1 : 2;
        $responses .= "<br /><table width=\"90%\" align=\"center\" cellpadding=\"5\" cellspacing=\"0\" style=\"border: 1px solid #004C75;\">\n";

        $response_row['comment_response'] = $comment_row[$i]['comment_response'];
        while ($response_row['comment_response'] != 0) {
          $sql = "SELECT c.comment_id, c.image_id, c.user_id, c.user_name AS response_user_name, c.comment_headline, c.comment_text, c.comment_ip, c.comment_date, c.comment_response".get_user_table_field(", u.", "user_level").get_user_table_field(", u.", "user_name")."
                  FROM ".COMMENTS_TABLE." c
                  LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = c.user_id)
                  WHERE c.comment_id = ".$response_row['comment_response'];
          $response_row = $site_db->query_firstrow($sql);

          $response_user_name = format_text($response_row['response_user_name'], 2);
          $response_user_info = $lang['userlevel_guest'];
          $response_user_id = $response_row['user_id'];
          $response_date = format_date($config['date_format']." ".$config['time_format'], $response_row['comment_date']);
          $response_text = format_text($response_row['comment_text'], $config['html_comments'], $config['wordwrap_comments'], $config['bb_comments'], $config['bb_img_comments']);
          $response_comment_id = $response_row['comment_id'];

          if (isset($response_row[$user_table_fields['user_name']]) && $response_user_id != GUEST) {
            $response_user_profile_link = !empty($url_show_profile) ? $site_sess->url(preg_replace("/{user_id}/", $response_user_id, $url_show_profile)) : $site_sess->url(ROOT_PATH."member.php?action=showprofile&amp;".URL_USER_ID."=".$response_user_id);
            $response_user_name = "<a href=\"".$response_user_profile_link."\">".format_text($response_row[$user_table_fields['user_name']], 2)."</a>";

            if (!isset($response_row[$user_table_fields['user_level']]) || (isset($response_row[$user_table_fields['user_level']]) && $response_row[$user_table_fields['user_level']] == USER)) {
              $response_user_info = $lang['userlevel_user'];
            }
            elseif ($response_row[$user_table_fields['user_level']] == ADMIN) {
              $response_user_info = $lang['userlevel_admin'];
            }
          }

          $response_user_ip = ($user_info['user_level'] == ADMIN) ? $response_row['comment_ip'] : "";

          $response_admin_links = "";
          if ($user_info['user_level'] == ADMIN) {
            $response_admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("comments.php?action=editcomment&amp;comment_id=".$response_row['comment_id']))."\" target=\"_blank\">".$lang['edit']."</a>&nbsp;";
            $response_admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("comments.php?action=removecomment&amp;comment_id=".$response_row['comment_id']))."\" target=\"_blank\">".$lang['delete']."</a>";
          }
          elseif ($is_image_owner) {
            $response_admin_links .= ($config['user_edit_comments'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=editcomment&amp;".URL_COMMENT_ID."=".$response_row['comment_id'])."\">".$lang['edit']."</a>&nbsp;";
            $response_admin_links .= ($config['user_delete_comments'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=removecomment&amp;".URL_COMMENT_ID."=".$response_row['comment_id'])."\">".$lang['delete']."</a>";
          }
          $responses .= "<tr>\n<a name=\"comment".$response_comment_id."\"></a>\n<td class=\"commentrow".$response_bg."\">\n";
          $responses .= "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
          $responses .= "<tr>\n<td><b>".$lang['response'].$response_user_name."</b> (".$response_user_info.")</td>\n";
          $responses .= "<td align=\"right\">".$response_date."</td>\n</tr>\n";
          $responses .= "<tr>\n<td colspan=\"2\"><hr>\n".$response_text."</td>\n</tr>\n";
          $responses .= "<tr>\n<td>".$response_user_ip."</td>\n";
          $responses .= "<td align=\"right\">".$response_admin_links."</td>\n</tr>\n";
          $responses .= "</table>\n</td>\n</tr>\n";

          $response_bg = ($bg_number++ % 2 == 0) ? 1 : 2;
        }

        $responses .= "</table>\n";
      }

      $response_to_id = "";
      if ($response_comment_id) {
        $response_to_id .= $response_comment_id;
      } else {
        $response_to_id .= $comment_row[$i]['comment_id'];
      }

2.6 find
Code: [Select]
"comment_headline" => format_text($comment_row[$i]['comment_headline'], 0, $config['wordwrap_comments'], 0, 0),
replace with
Code: [Select]
"comment_headline" => $comment_headline,
        "responses" => $responses,
        "response_to_id" => $response_to_id,
        "lang_post_response" => $lang['post_response'],

2.7 find
Code: [Select]
$comment_text = (isset($HTTP_POST_VARS['comment_text']) && $error) ? format_text(trim(stripslashes($HTTP_POST_VARS['comment_text'])), 2) : "";
add below
Code: [Select]
$response_to = (isset($HTTP_POST_VARS['response_to']) && $error) ? format_text(trim(stripslashes($HTTP_POST_VARS['response_to'])), 2) : "";
2.8 find
Code: [Select]
"comment_text" => $comment_text,
add below
Code: [Select]
"response_to" => $response_to,
      "lang_clear" => $lang['clear'],
      "lang_clear_desc" => $lang['clear_desc'],


3. in the file lang/your_lang/main.php

add
Code: [Select]
//-----------------------------------------------------
//--- Mod Responses to Comment -------------------------
// ----------------------------------------------------
  $lang['response'] = "Response: ";
  $lang['post_response'] = "Post response";
  $lang['clear'] = "Clear";
  $lang['clear_desc'] = "<span class=\"small\"> - will saved as a new comment (not response)</span>";


4. in the file admin/comments.php

find
Code: [Select]
$sql = "SELECT comment_id, image_id, user_id, user_name, comment_headline
          FROM ".COMMENTS_TABLE."
          WHERE comment_id IN ($comment_ids)";
  $comment_result = $site_db->query($sql);
  while ($comment_row = $site_db->fetch_array($comment_result)) {

replace with
Code: [Select]
$sql = "SELECT comment_id, image_id, user_id, user_name, comment_headline, response, comment_response
          FROM ".COMMENTS_TABLE."
          WHERE comment_id IN ($comment_ids)";
  $comment_result = $site_db->query($sql);
  while ($comment_row = $site_db->fetch_array($comment_result)) {
    if ($comment_row['comment_response'] != 0 && $comment_row['response'] != 0) {
      $sql = "UPDATE ".COMMENTS_TABLE."
              SET comment_response = ".$comment_row['comment_response']."
              WHERE comment_response = ".$comment_row['comment_id'];
      $site_db->query($sql);
    }
    elseif ($comment_row['response'] && $comment_row['comment_response'] == 0) {
      $sql = "UPDATE ".COMMENTS_TABLE."
              SET comment_response = 0
              WHERE comment_response = ".$comment_row['comment_id'];
      $site_db->query($sql);
    }
    elseif ($comment_row['comment_response'] && $comment_row['response'] == 0) {
      $response_id = $comment_row['comment_response'];
      while ($response_id != 0) {
        $sql = "SELECT comment_id, user_id, comment_response
                FROM ".COMMENTS_TABLE."
                WHERE comment_id = $response_id";
        $row = $site_db->query_firstrow($sql);
        $response_id = $row['comment_response'];
        $com_id = $row['comment_id'];

        $sql = "DELETE FROM ".COMMENTS_TABLE."
                WHERE comment_id = $com_id";
        $site_db->query($sql);
        update_comment_count($comment_row['image_id'], $row['user_id']);
      }
    }


5. in the file comment_bit.html

find
Code: [Select]
{comment_text}
add below
Code: [Select]
{if responses}<br />{responses}<br />{endif responses}
5.1 for the link "post response" use:
Code: [Select]
<a href="#comment_form" onClick="get_link('{comment_headline}', '{response_to_id}')" /><b>{lang_post_response}</b></a>

6. in the file comment_form.html

before all content add
Code: [Select]
<script language="javascript" type="text/javascript">

function get_link(headline, hidden_id){
document.commentform.comment_headline.value=headline
document.commentform.response_to.value=hidden_id
}

function clear_link() {
document.commentform.comment_headline.value=""
document.commentform.response_to.value=""
}
</script>

<a name="comment_form"></a>

6.1 find
Code: [Select]
<form name="commentform" action="{self}" method="post" onsubmit="postbutton.disabled=true;">
add below
Code: [Select]
<input type="hidden" name="response_to" value="{response_to}" />
6.2 find
Code: [Select]
<input type="text" name="comment_headline" size="30" value="{comment_headline}" class="commentinput" />
after add
Code: [Select]
<br /><a href="#comment_form" onClick="clear_link()">{lang_clear}</a>{lang_clear_desc}

7. install mod

upload to root directory the atached file responses_install.php, install mod and delete this file from your server.
« Last Edit: February 01, 2009, 09:44:15 AM by V@no »

Offline om6acw

  • Full Member
  • ***
  • Posts: 187
    • View Profile
    • My Animal's World
Re: Answers in comments
« Reply #10 on: February 01, 2009, 05:44:13 AM »
Nice mod alekinna, but I have problem with your responses_install.php its giving me this error

Code: [Select]
Parse error: syntax error, unexpected ')' in /home/XXXXX/XXXXXXX/responses_install.php on line 16

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
Re: Answers in comments
« Reply #11 on: February 01, 2009, 09:44:34 AM »
Please re-download the package again. should be fixed now.
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 fermachado

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Re: Answers in comments
« Reply #12 on: September 25, 2009, 10:19:52 AM »
Hi,

Is possible the response to a comment don't count to the number of comments?

Thanks   
 
www.globalfoto.net

Sintra - Portugal

Offline alekseyn1

  • Full Member
  • ***
  • Posts: 102
    • View Profile
    • My Project
Re: [MOD] Answers in Comments like on YouTube
« Reply #13 on: November 24, 2009, 04:44:36 PM »
МОD Works great!!

http://www.fotodvor.com/details.php?image_id=191
it's a test site )) no not want it indexed.

Thank you very much!
« Last Edit: January 12, 2010, 12:03:50 AM by alekseyn1 »

Offline alekseyn1

  • Full Member
  • ***
  • Posts: 102
    • View Profile
    • My Project
Re: Answers in comments
« Reply #14 on: November 26, 2009, 03:06:57 PM »
Guys, it is possible to indent every reply further right? so that it would look like a discussion tree?
« Last Edit: November 27, 2009, 01:28:50 AM by alekseyn1 »