4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: Lucifix on December 18, 2008, 08:26:33 AM

Title: [MOD REQ] Rate comments - good / bad
Post by: Lucifix on December 18, 2008, 08:26:33 AM
I remember that once someone already made this mod, but can't find it .

I'm looking for something like youtube has - rate comment (good / bad), but without page refreshing and base on IP tracking (new SQL table).

Anyone already made this or can find it on this forum?
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: SnaFy on December 18, 2008, 12:42:16 PM
i need too
If you want this mod   write a suspension of the programmers :)
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: Lucifix on January 06, 2009, 06:12:28 PM
I found one plugin for Wordpress but maybe anyone can optimize it for 4images:
http://www.cyber-knowledge.net/blog/2006/10/15/wordpress-plugin-rate-your-comments-comment-karma/

My lack of javascript knowledge doesn't allow me  :roll:
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: V@no on January 07, 2009, 05:18:19 AM
Good idea. Any takers on this one? (I filled up my computer time daily quota :lol:)

P.S.
hehe
Quote from: from ck-karma.js
alert("WTF ?");
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: Lucifix on January 07, 2009, 09:57:54 AM
I became totally addicted to this mod, I WANT IT!!!  :mrgreen:
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: Lucifix on January 07, 2009, 03:24:06 PM
Just to let you know that I have somehow modified this MOD for 4images. Later today I'll publish it here.

It still needed few modification and I hope someone will help me solve them.
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: Lucifix on January 07, 2009, 06:26:14 PM
Damn me! I thought I finished this mod, but now I see that I made too many mistakes in script is not working right.

I don't think I'll be able to modify it for 4images... sorry  :cry:
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: Lucifix on January 07, 2009, 11:02:22 PM
Believe it or not I made it! :)

Can anyone please first test this MOD if it's working and if it doesn't have any security holes in it.

Add new rows to existing table 4images_comment:
Code: [Select]
ALTER TABLE 4images_comments
ADD (
`ck_user_id` BLOB NOT NULL,
`ck_rating_up` INT,
`ck_rating_down` INT)

Open files functions.php (directory includes)
add before ?>
DON'T FORGET TO MODIFY THIS FILE!!!

Code: [Select]
function ck_display_karma($comment_idk)
{
  global $site_db, $user_info, $site_template;

$plugin_path = 'scripts/'; // DIRECTORY WITH SCRIPT FILES (ck-karma.js and ck-processkarma.php)
$ck_link = str_replace('http://www.yourdomain.com'); // HERE ADD YOUR DOMAIN NAME
$ck_comment_ID = $comment_idk; // get comment ID

$table_name = "4images_comments";
$ck_sql = "SELECT user_id, image_id, ck_user_id, comment_id, ck_rating_up, ck_rating_down FROM `$table_name` WHERE comment_id = $ck_comment_ID";

$ck_result = mysql_query($ck_sql);

if(!$ck_result)
{
mysql_error();
}
      else if(!$ck_row = mysql_fetch_array($ck_result, MYSQL_ASSOC))
{
mysql_error();
}
      else if(strstr($ck_row['ck_user_id'], $user_info['user_id']) || $user_info['user_level'] == GUEST || $user_info['user_id'] == $ck_row['user_id'])
{
if ($ck_row['ck_rating_up'] > 0) { $color = "style=\"color: green\"";}
if ($ck_row['ck_rating_down'] < 0) { $colord = "style=\"color: red\"";}
$vote_comment .= "&nbsp;<img style='background: #000; padding: 0px; border: none;' src=\"{$plugin_path}/images/gray_up.png\" />";
    $vote_comment .= "<small id=\"karma-{$ck_comment_ID}-up\" $color> {$ck_row['ck_rating_up']} </small>&nbsp;";
          $vote_comment .= "<img style='background: #000; padding: 0px; border: none;' src=\"{$plugin_path}/images/gray_down.png\" />";
        $vote_comment .= "<small id=\"karma-{$ck_comment_ID}-down\" $colord> {$ck_row['ck_rating_down']} </small>&nbsp;";
} else {
//Use onClick for the image instead, fixes the style link underline problem as well.
$vote_comment .= "&nbsp;Vote: <img style='background: #000; padding: 0px; border: none; cursor: pointer;' id=\"up-$ck_comment_ID\" src=\"{$plugin_path}images/up.png\"  alt=\"Good comment\" title=\"Good comment\" onclick=\"javascript:karma('$ck_comment_ID', 'add', 'www.yourdomain.com/scripts/');\" />";
$vote_comment .= "&nbsp;<small id=\"karma-{$ck_comment_ID}-up\">{$ck_row['ck_rating_up']}</small>&nbsp;";
$vote_comment .= "<img style='background: #000; padding: 0px; border: none; cursor: pointer;\' id=\"down-$ck_comment_ID\" src=\"{$plugin_path}images/down.png\" alt=\"Bad comment\" title=\"Bad comment\" onclick=\"javascript:karma('$ck_comment_ID', 'subtract', 'www.yourdomain.com/scripts/')\" />"; //Phew
    $vote_comment .= "&nbsp;<small id=\"karma-{$ck_comment_ID}-down\">&nbsp;{$ck_row['ck_rating_down']}</small>&nbsp;";
}

  $site_template->register_vars(array(
"vote_comment" => $vote_comment
  ));
}

Create new file and name it ck-processkarma.php. Create new directory scripts (root) and upload that file in it.

Code: [Select]
<?php
define
('ROOT_PATH''./');
include(
ROOT_PATH.'global.php');
require(
ROOT_PATH.'includes/sessions.php');

/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

global 
$site_db$user_info;

$k_id mysql_real_escape_string($_GET['id']);
$k_action mysql_real_escape_string($_GET['action']);
$k_path mysql_real_escape_string($_GET['path']);
$table_name '4images_comments';

if(
$k_id && $k_action && $k_path) {
    
//Check to see if the comment id exists and grab the rating
    
$query "SELECT * FROM `4images_comments` WHERE comment_id = $k_id";
    
$result mysql_query($query);

if(!$result) { die('error|mysql: '.mysql_error()); }

   if(
mysql_num_rows($result))
{
      if(
$row = @mysql_fetch_assoc($result))
      {
if(strstr($row['ck_user_id'], $user_info['user_id'])) {
            die(
'error|A vote has already been registered'); }
         
$ck_usd $row['ck_user_id'] . ',' $user_info['user_id']; // User IDs are separated by ','
      
}

      if(
$k_action == 'add') {
         
$rating $row['ck_rating_up'] + 1;
         
$direction 'up';
      }
      elseif(
$k_action == 'subtract')
      {
         
$rating $row['ck_rating_down'] - 1;
         
$direction 'down';
      } else {
            die(
'error|Try again later'); //No action given.
      
}

      
$query "UPDATE `$table_name` SET ck_rating_$direction = '$rating', ck_user_id = '" $ck_usd  "' WHERE comment_id = $k_id";
      
$result mysql_query($query); 
      if(!
$result)
{
// die('error|query '.$query);
         
die('error|Query error');
      }
        
if(!mysql_affected_rows())
{
         die(
'error|affected '$rating);
      }
   } else {
        die(
'error|Comment doesnt exist'); //Comment id not found in db, something wrong ?
   
}
} else {
    die(
'error|Fatal: html format error');
}

//This sends the data back to the js to process and show on the page
echo('done|'$k_id .'|'$rating .'|'$k_path .'|'$direction);
?>

Create new file and name it ck-karma.js. Upload this file in directory scripts

Code: [Select]
/*
Plugin Name: Comment Karma
Plugin URI: http://cyber-knowledge.net/blog/2006/10/15/wordpress-plugin-rate-your-comments-comment-karma/
Description: Allows you to rate comments up or down.
Author: Alex Bailey and Kirk
Author URI: http://cyber-knowledge.net
Version: 1.1
*/

/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

function createXMLHttpRequest(){
    var xmlhttp = null;
    try {
        // Moz supports XMLHttpRequest. IE uses ActiveX.
        // browser detction is bad. object detection works for any browser
        xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e) {
        // browser doesn’t support ajax. handle however you want
        //document.getElementById("errormsg").innerHTML = "Your browser doesnt support XMLHttpRequest.";
        alert("Your browser does not support the XMLHttpRequest Object!");
    }
    return xmlhttp;
}

var xhr = createXMLHttpRequest();

function karma(id, action, path){
    xhr.open('get', 'http\://'+ path +'ck-processkarma.php?id='+ id +'&action='+ action +'&path='+ path);
    xhr.onreadystatechange = handleResponse;
    xhr.send(null);
}

function handleResponse(){
    if(xhr.readyState == 4){
        var response = xhr.responseText.split('|');
       
        if(response[0] == 'done'){
            if(response[1]){
                //Changes the thumbs to dull gray and disable the action
                document.getElementById("down-"+response[1]).src        = "http://"+response[3]+'images/gray_down.png';
                document.getElementById("down-"+response[1]).onclick    = '';
                document.getElementById("up-"+response[1]).src          = "http://"+response[3]+'images/gray_up.png';
                document.getElementById("up-"+response[1]).onclick      = '';
                //Update the karma number display
                if(!response[2]){
                alert("Response has no value");
                }
                var karmanumber = response[2];
                //The below line is commented out because there is no karma number atm.
                document.getElementById("karma-"+response[1]+"-"+response[4]).innerHTML = karmanumber;
            } else {
                alert("WTF ?");
            }
        }
        else if(response[0] == 'error')
        {
            var error = 'Error: '+response[1];
            alert(error);
        } else {
        alert("Reponse: "+response[0]);
            alert("Karma not changed, please try again later.");
        }
    }
}

Create new subdirectory images in scripts directory and upload all images attached to this message (etc. root/scripts/images)

Open file comment_bit.html (template)
and add:
{vote_comment}
where ever you want ;)

Open file header.html and add after </script>
Code: [Select]
<script type="text/javascript" src="/scripts/ck-karma.js">
Open file details.php and find:
Code: [Select]
      $site_template->register_vars(array(
        "comment_id" => $comment_row[$i]['comment_id'],
add before:
Code: [Select]
ck_display_karma($comment_row[$i]['comment_id']);

Please note that I'm not author of that script, I have just modified original script for 4images from here:
http://www.cyber-knowledge.net/blog/2006/10/15/wordpress-plugin-rate-your-comments-comment-karma/
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: mawenzi on January 08, 2009, 12:01:52 AM
... nice modification ...
... but I can't get it to work right now ... but I'm in testing ... ;)
... in your mod descriptions are some mistakes ...
... in functions.php ... $plugin_path = 'scripts /'; ... and ... 'www.yourdomain.com/scripts/' ...
... and you say : Upload this file in directory script ...
... sripts is not script ... !


Title: Re: [MOD REQ] Rate comments - good / bad
Post by: V@no on January 08, 2009, 01:58:31 AM
I think it would be much better to code this mod from scratch...first of all, a slight modification of wordpress plugin will not do the trick, because you SHOULD use as much 4images existing functions, classes, etc as possible to make it compatible with any other modifications a user could implemented in the past.
In your code I already see conflict with not using 4images sessions, which could be a security risk and could possible reveal data a visitors not supposed to see, same with database access.
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: Lucifix on January 08, 2009, 07:47:24 AM
@mawenzi :
If you are having trouble with this mod try to use Firebug it will show you javascript errors:
http://getfirebug.com/

@v@no:
yes maybe mod from scratch will do better, but who'll do it? ;)

As I see only input is in ck-processkarma.php but it's protected with mysql_real_escape_string.

I'll try to implant session in it but I doubt that I can do it.
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: alekinna on January 08, 2009, 09:01:28 AM
Hi all,

maybe you will like my mod for rating comments.

1. in the file details.php

find
Code: [Select]
unset($random_cat_image);
add below
Code: [Select]
if ($action == "comrate_good" && $id) {
  if ($user_info['user_level'] != GUEST) {
    $sql = "SELECT who_rated
            FROM ".COMMENTS_TABLE."
            WHERE comment_id = $id";
    $row = $site_db->query_firstrow($sql);
    $who_rated_ids = $row['who_rated'];
    $who_rated_array = explode(" ", $who_rated_ids);
    if (!in_array($user_info['user_id'], $who_rated_array)) {
      $who_rated_ids .= " ".$user_info['user_id'];
      $sql = "UPDATE ".COMMENTS_TABLE."
              SET is_good = is_good+1, who_rated = '$who_rated_ids'
              WHERE comment_id = $id";
      if ($site_db->query($sql)) {
        $msg = $lang['voting_com_success'];
      }
      else {
        $msg = $lang['voting_error'];
      }
    }
  }
  else {
    $msg = $lang['only_for_registered'];
  }
}

if ($action == "comrate_bad" && $id) {
  if ($user_info['user_level'] != GUEST) {
    $sql = "SELECT who_rated
            FROM ".COMMENTS_TABLE."
            WHERE comment_id = $id";
    $row = $site_db->query_firstrow($sql);
    $who_rated_ids = $row['who_rated'];
    $who_rated_array = explode(" ", $who_rated_ids);
    if (!in_array($user_info['user_id'], $who_rated_array)) {
      $who_rated_ids .= " ".$user_info['user_id'];
      $sql = "UPDATE ".COMMENTS_TABLE."
              SET is_bad = is_bad+1, who_rated = '$who_rated_ids'
              WHERE comment_id = $id";
      if ($site_db->query($sql)) {
        $msg = $lang['voting_com_success'];
      }
      else {
        $msg = $lang['voting_error'];
      }
    }
  }
  else {
    $msg = $lang['only_for_registered'];
  }
}

1.1 find line with

Code: [Select]
$sql = "SELECT c.comment_id, c.image_id, c.user_id, c.user_name AS comment_user_name,
insert in
Code: [Select]
c.is_good, c.is_bad, c.who_rated,
1.2 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]
$comment_rank = "";
      if ($user_info['user_level'] == GUEST){
        $comrate_good = "<img src=\"".get_gallery_image("good_off.png")."\" border=\"0\" alt=\"\" title=\"".$lang['only_for_registered']."\" />";
        $comrate_bad = "<img src=\"".get_gallery_image("bad_off.png")."\" border=\"0\" alt=\"\" title=\"".$lang['only_for_registered']."\" />";
      }
      elseif ($user_info['user_id'] == $comment_row[$i]['user_id']) {
        $comrate_good = "<img src=\"".get_gallery_image("good_off.png")."\" border=\"0\" alt=\"\" title=\"".$lang['owner_vote']."\" />";
        $comrate_bad = "<img src=\"".get_gallery_image("bad_off.png")."\" border=\"0\" alt=\"\" title=\"".$lang['owner_vote']."\" />";
      }
      else {
        $comrate_url = $self_url;
        $comrate_url .= (!empty($mode)) ? ((strpos($comrate_url, '?') !== false) ? "&amp;" : "?")."mode=".$mode : "";
        $comrate_url .= strpos($comrate_url, '?') !== false ? "&amp;" : "?";
        $who_rated_array = explode(" ", $comment_row[$i]['who_rated']);
       
        if (!in_array($user_info['user_id'], $who_rated_array)) {
          $comrate_good_url = $comrate_url."action=comrate_good&amp;id=".$comment_row[$i]['comment_id'];
          $comrate_bad_url = $comrate_url."action=comrate_bad&amp;id=".$comment_row[$i]['comment_id'];
          $comrate_good = "<a href=\"".$site_sess->url($comrate_good_url)."\"><img src=\"".get_gallery_image("good.png")."\" border=\"0\" alt=\"\" title=\"".$lang['is_good']."\" /></a>";
          $comrate_bad = "<a href=\"".$site_sess->url($comrate_bad_url)."\"><img src=\"".get_gallery_image("bad.png")."\" border=\"0\" alt=\"\" title=\"".$lang['is_bad']."\" /></a>";
        }
        else {
          $comrate_good = "<img src=\"".get_gallery_image("good_off.png")."\" border=\"0\" alt=\"\" title=\"".$lang['already_com_voted']."\" />";
          $comrate_bad = "<img src=\"".get_gallery_image("bad_off.png")."\" border=\"0\" alt=\"\" title=\"".$lang['already_com_voted']."\" />";
        }
      }
      $comment_rank .= "+".$comment_row[$i]['is_good']." ".$comrate_good." ".$comrate_bad." ".$comment_row[$i]['is_bad']."-";
$site_template->register_vars("comment_rank", $comment_rank);

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

add before ?>
Code: [Select]
$lang['voting_com_success'] = "Thank you for rating this comment";
$lang['already_com_voted'] = "Sorry, you've already rated for this comment once recently.";
$lang['only_for_registered'] = "Only registered users can use this function";
$lang['is_good'] = "It is good comment";
$lang['is_bad'] = "It is bad comment";
$lang['owner_vote'] = "You can not rate your own comment";

3. in the file comment_bit.html

use
Code: [Select]
{comment_rank}
4. Add new rows to existing table 4images_comment

Code: [Select]
ALTER TABLE `4images_comments`
ADD `is_good` int(10) unsigned NOT NULL default '0',
ADD `is_bad` int(10) unsigned NOT NULL default '0',
ADD `who_rated` text

5. new images

You will need 4 images with the names: good.png, bad.png, good_off.png, bad_off.png
save them in the folder template/your_template/images


PS: Only registered users allowed to vote
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: mawenzi on January 08, 2009, 12:42:10 PM
Hi all,

and hi alekinna,

... thanks for your version of "Rate Comments" ...
... after little code changings your version works perfect for me ... and looks very cool ...  8)

here my changings ...

1. in the file details.php
after your ...
Code: [Select]
$comment_rank .= "+".$comment_row[$i]['is_good']." ".$comrate_good." ".$comrate_bad." ".$comment_row[$i]['is_bad']."-";

I added this...
Code: [Select]
$site_template->register_vars("comment_rank", $comment_rank);


2. and in /lang/deutsch/main.php I use the following ... ( :flag-de: ) ...
Code: [Select]
//-----------------------------------------------------
//--- Rate Comments -----------------------
//-----------------------------------------------------
$lang['voting_com_success'] = "Danke für deine Bewertung des Kommentars.";
$lang['already_com_voted'] = "Sorry, aber du hast diesen Kommentar bereits bewertet.";
$lang['only_for_registered'] = "Nur registrierte Benutzer können diese Funktion nutzen.";
$lang['is_good'] = "Deine Bewertung: Das ist ein guter Kommentar.";
$lang['is_bad'] = "Deine Bewertung: Das ist ein schlechter Kommentar.";

... I think, you should post your [MOD] Rate Comments in a new thread in Mods & Plugins (Requests & Discussions) ...
... and then we will move this thread to Mods & Plugins (Releases & Support) ...

... thanks again for this modification ...  :D

PS.
... and I use the following icons from Lucifix with new names ...
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: Lucifix on January 08, 2009, 12:54:11 PM
Yup this looks like the right MOD for rating comments :)

The only thing that bothers me is that every time user rate comment page refresh.  :roll:

I think it's time that someone starts thinking to integrate javascript (no page refreshing) in 4images (like Wordpress), which will bring lot less bandwith usage and it's much more user friendly.
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: mawenzi on January 08, 2009, 01:08:34 PM
The only thing that bothers me is that every time user rate comment page refresh.  :roll:

... you are right ...
... but in the way the mod from alekinna works right now ... it is perfect for me ... ;)
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: Lucifix on January 08, 2009, 01:18:04 PM
Can you please give me link where I can find demo just to see how it's working?
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: mawenzi on January 08, 2009, 01:27:06 PM
... e.g. ... here (http://klick.kl.funpic.de/details.php?image_id=4533) ... for a image comment ...
... or ... here (http://klick.kl.funpic.de/details.php?image_id=1617) ... for a guestbook comment ...
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: alekinna on January 08, 2009, 02:19:21 PM
here my changings ...

1. in the file details.php
after your ...
Code: [Select]
$comment_rank .= "+".$comment_row[$i]['is_good']." ".$comrate_good." ".$comrate_bad." ".$comment_row[$i]['is_bad']."-";

I added this...
Code: [Select]
$site_template->register_vars("comment_rank", $comment_rank);

Thank you mawenzi, I forgot to add this step.

Quote
... I think, you should post your [MOD] Rate Comments in a new thread in Mods & Plugins (Requests & Discussions) ...
... and then we will move this thread to Mods & Plugins (Releases & Support) ...

Am I need to create a new topic?

Also I think will be more interesting if some function will based on comment_rank.
For example:
user rate comment -> comment's author karma +point (or -point)
when comment's author will get karma = 20, he will allowed to download/upload more images
his karma can be again < 20, so it's good motivation for user to be an active member.
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: Loda on January 08, 2009, 03:07:21 PM
wow! thank you very much for this!
one question: where can i see who rate the comment?
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: mawenzi on January 08, 2009, 03:22:00 PM
Am I need to create a new topic?

... I think ... yes ... as a right MOD-Thread, that started with a full and complet mod installations description ...
... and there you can also update the mod-code or -description if it is necessary ...
... I mean ... this thread is only for testing ... then the most users can't find the right way for installation between all the code snippets here ... ;)

Also I think will be more interesting if some function will based on comment_rank.
... ok ... it can also used e.g. in Egly's [MOD] Small Credit System (http://www.4homepages.de/forum/index.php?topic=9811.0) ...
... so we wait for your new thread ...  :mrgreen:
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: mawenzi on January 08, 2009, 03:29:41 PM
@ Loda ...  8O ... f.u.g.n.J. ... ;)

... da in der Tab-Zeile "who_rated" die User-IDs gespeichert werden, sollte das auch möglich sein ...
... die Frage ist nur : In welcher Form soll das angezeigt werden ? ... und ... Für wen wir das angezeigt ? ...
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: Loda on January 08, 2009, 03:59:30 PM
@mawenzi... f.u.g.n.J. ..., too (ich lebe noch!)

...angezeigt für den admin!? zB.
.. und kann ich im profil auslesen, wie viele gute bzw. schlechte kommentare der user bekommen hat?

PS: bei dir hat sich ein fehler eingeschlichen: "...schlechten kommentar.." und nicht "schlachten"  :wink:
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: om6acw on January 08, 2009, 06:41:24 PM
great mod, would be nice to have this mod without page reloading ;)
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: mawenzi on January 08, 2009, 09:08:20 PM
one question: where can i see who rate the comment?
... and ...
Quote from: Loda
...angezeigt für den admin!? zB.

... a very fast solution ... ;)
... you can see who has rated but you can't edit who has rated ... in ACP via  website Commet-Admin-Link  ...

1. in admin/comments.php on the top find ...
Code: [Select]
$sql = "SELECT comment_id, image_id, user_id, user_name, comment_headline
and add after ...
Code: [Select]
, is_good, is_bad, who_rated

2. in admin/comments.php in section if ($action == "editcomment") find ...
Code: [Select]
show_form_footer($lang['save_changes'], $lang['reset'], 2);
and add above ...
Code: [Select]
//----
  show_input_row("Bewertung: Gut <span class=\"smalltext\">(nicht editierbar)</span>", "is_good", $comment['is_good'], $textinput_size);
  show_input_row("Bewertung: Schlecht <span class=\"smalltext\">(nicht editierbar)</span>", "is_bad", $comment['is_bad'], $textinput_size);
  show_input_row("Bewertung: Wer (User-ID) ? <span class=\"smalltext\">(nicht editierbar)</span>", "who_rated", $comment['who_rated'], $textinput_size);
//----

... for editing you need some more changes ... ;)
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: V@no on January 09, 2009, 04:09:55 AM
@alekinna:
You forgot include permission check, so members can vote only for comments they allowed to view.
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: alekinna on January 09, 2009, 08:14:41 AM
V@no, I don't understand.. If an user not allowed to view comment, how he can to rate it (how he will see the rate-images).

Also I forgot one important thing - users can't rate for their own comments.
So I changed step 1.2 and added line in step 2.
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: V@no on January 09, 2009, 08:38:01 AM
by using direct link, i.e.:
details.php?action=comrate_bad&id=1
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: mawenzi on January 09, 2009, 01:02:42 PM
@  alekinna

... for permission check I added in step 1 on the top the following ...
Code: [Select]
$allow_read_comments = (check_permission("auth_readcomment", $cat_id));
... and in step 1 I use this sql extension 2 times ...
Code: [Select]
if (($user_info['user_level'] != GUEST) and ($allow_read_comments == 1)) {
... and after tests ... I can say it works incl. error message if user has no permission to read the comments ...

@V@no
... any mistakes or hints ... ?
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: Loda on January 09, 2009, 02:35:04 PM
... a very fast solution ... ;)
... you can see who has rated but you can't edit who has rated ... in ACP via  website Commet-Admin-Link  ...

thank you very much, mawenzi!
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: Loda on January 09, 2009, 02:58:03 PM
Also I forgot one important thing - users can't rate for their own comments.
So I changed step 1.2 and added line in step 2.

...i cannot see any changes? please can you show me what you've change? thank you.
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: alekinna on January 09, 2009, 03:19:55 PM
You are right, it not saved.

Check now.
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: V@nо on January 09, 2009, 06:28:38 PM
the permissions for any manipulations with comments should be checked against auth_viewcat, auth_viewimage, auth_readcomment and image indivual allow_read_comments
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: mawenzi on January 09, 2009, 06:50:15 PM
... it is necessary to check all permissions ? ... I think to check "allow_read_comments" is enough ...
... mmm ... there may be a image that - not allow to view but allow to read the comments ...
... yes ... comments from such a image can be rated by direkt link ...
... but ofcourse it is possible to check all these permission first, before allow to rate ...
... so I will post a new code for check permissions ...

... thanks V@no for your statement ...

Title: Re: [MOD REQ] Rate comments - good / bad
Post by: V@nо on January 09, 2009, 07:39:38 PM
another thing could get some consideration is a requirement to open the details page before it'd allow to vote.
It can be done using built-in antileech protection for download image. A such method would prevent visitors using direct url to the comment vote.
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: V@no on January 13, 2009, 10:43:40 AM
Hi guys.
I have completed ajax comments mod, that also includes ajax comments rating, just didn't have time to publish it.

Maybe tomorrow or day after I'll be able to publish it.

You can test drive it here (http://4images.vano.org/ajaxcomments). You may find some demo settings on left side.

P.S.
The source code can be viewed by adding ?source to file you want to view
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: mawenzi on January 13, 2009, 11:44:21 AM
... great and fantastic job V@no ... !
... and thanks for publishing this modification ...
... I think it is possible to install this mod by using your "?source" code ... also great ...
... but I will wait till tomorrow or day after, it is faster for me ... ;)
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: Lucifix on January 13, 2009, 11:50:18 AM
This is what I'm talking about!!!  :mrgreen:

V@no if you'll modify javascript suitable for 4images I'll make few more MODs ;) (username check*, ....) :)

*I remember that someone posted this mod already but it wasn't working
Title: Re: [MOD REQ] Rate comments - good / bad
Post by: fermachado on November 03, 2011, 06:58:19 PM
Hi.

 Is possible with some changes use this code to rate the photos like as we rate the comments?

Thanks