4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: FreDyz on June 10, 2003, 02:10:13 AM

Title: [MOD-Request] Comment & Vote system
Post by: FreDyz on June 10, 2003, 02:10:13 AM
The vote and comment system of 4images is good, but I would prefer other system, I try to explain my ideas:

I would like a form to vote and comment  simultaneously (you write your comment and rate the image and then click on send button to send all data).
Then my comment and my vote are listed together (my vote no longer would be anonymous).

P.E.:
----------------
FreDyz - 5 points
Hey your photo is really nice!!
----------------
JhonDoe - 1 point
I don't like this photo...
----------------
=====================

It would be very difficult?
Title: [MOD-Request] Comment & Vote system
Post by: Apollo13 on June 10, 2003, 08:36:28 AM
well no and i think v@no did something like that.
Title: [MOD-Request] Comment & Vote system
Post by: FreDyz on June 10, 2003, 02:33:43 PM
Quote from: Cr@zy Sash
well no and i think v@no did something like that.


where can I find it? I've searched in the forum but I haven't found anything about this
Title: Re: [MOD-Request] Comment & Vote system
Post by: Lysander on January 29, 2007, 10:45:11 AM
I am searching same MOD on the forum but i can't find it too... Can someone help please???
Title: Re: [MOD-Request] Comment & Vote system
Post by: trez on February 02, 2007, 06:46:30 PM
I can make a MOD like this, but i won't do it for free since i have no use for it on my site. If you're interested PM me ;)
Title: Re: [MOD-Request] Comment & Vote system
Post by: Acidgod on February 02, 2007, 07:43:42 PM
details.php
search for:
Code: [Select]
if ($comment_text == "")  {
$msg .= (($msg != "") ? "<br />" : "").$lang['comment_required'];
$error = 1;
}

replace with:
Code: [Select]
if ($comment_text == "")  {
$msg .= (($msg != "") ? "<br />" : "").$lang['comment_required'];
$error = 1;
}
if (!$error)  {

$rating = intval($HTTP_POST_VARS['rating']);
if ($rating != "" && $id) {
//-----------------------------------------------------
//--- Save Rating -------------------------------------
//-----------------------------------------------------
$cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME : "4images_";
$cookie_rated = isset($HTTP_COOKIE_VARS[$cookie_name.'rated']) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name.'rated'])) : array();
if ($rating && $rating <= MAX_RATING && $id) {
if (!isset($session_info['rated_imgs'])) {
$session_info['rated_imgs'] = $site_sess->get_session_var("rated_imgs");
}
$split_list = array();
if (!empty($session_info['rated_imgs'])) {
$split_list = explode(" ", $session_info['rated_imgs']);
}
if (!in_array($id, $split_list) && !in_array($id, $cookie_rated)) {
$session_info['rated_imgs'] .= " ".$id;
$session_info['rated_imgs'] = trim($session_info['rated_imgs']);
$site_sess->set_session_var("rated_imgs", $session_info['rated_imgs']);
$cookie_rated[] = $id;
$cookie_expire = time() + 60 * 60 * 24 * 4;
setcookie($cookie_name.'rated', serialize($cookie_rated), $cookie_expire, COOKIE_PATH, COOKIE_DOMAIN, COOKIE_SECURE);
update_image_rating($id, $rating);
$msg = $lang['voting_success'];
}
else {
$msg = $lang['already_voted'];
$vote_error = 1;
}
}
else {
$msg = $lang['voting_error'];
$vote_error = 1;
}
}


if ($rating != "" && $vote_error != 1)  {
$comment_headline = $comment_headline." ".$lang['user_rating'].$rating;
}
}

lang/XXXX/main.php
add:
Code: [Select]
$lang['user_rating'] = " | Vote: ";(the text you will find in the comment_headline - for example "This ist the Headline | Vote: 5")

templates/XXXXX/comment_form.html
search for:
Code: [Select]
                <tr>
                  <td width="90" valign="top">&nbsp;</td>
                  <td>{bbcode}</td>
                </tr>

repleace with:
Code: [Select]
                <tr>
                  <td width="90" valign="top">&nbsp;</td>
                  <td>{bbcode}</td>
                </tr>
                 <tr>
                  <td width="90" valign="top">&nbsp;</td>
                  <td><select name="rating" class="select">
                <option value="">--</option>
                <option value="5">5</option>
                <option value="4">4</option>
                <option value="3">3</option>
                <option value="2">2</option>
                <option value="1">1</option>
              </select>
              <input type="hidden" name="action" value="rateimage" />
              <input type="hidden" name="id" value="{image_id}" /></td>
                </tr>

templates/XXXXX/details.html
delete:
Code: [Select]
  {if rate_form}
  <div align="center">{rate_form}</div>
  {endif rate_form}

Only quick and dirty but one hour hard work...
For donations via Paypal use spende@owl-techno.de.... *g*
Title: Re: [MOD-Request] Comment & Vote system
Post by: om6acw on February 03, 2007, 03:35:12 AM
xxx
Title: Re: [MOD-Request] Comment & Vote system
Post by: Acidgod on February 03, 2007, 09:09:16 AM
               $sql = "SELECT user_id, image_id, vote
               FROM ".IMAGES_TABLE."
               WHERE image_id = ".$id." AND user_id = ".$user_info['user_id'];
               $rated = $site_db->query_firstrow($sql);
               $rating = ($rated['vote']) ? $rated['vote'] : $rating;

Do you save the voting in the image table?  :?
Title: Re: [MOD-Request] Comment & Vote system
Post by: om6acw on February 03, 2007, 10:39:09 AM
               $sql = "SELECT user_id, image_id, vote
               FROM ".IMAGES_TABLE."
               WHERE image_id = ".$id." AND user_id = ".$user_info['user_id'];
               $rated = $site_db->query_firstrow($sql);
               $rating = ($rated['vote']) ? $rated['vote'] : $rating;

Do you save the voting in the image table?  :?

yes, its saved in image table in field image_votes because I dont have any voted table in my db and I dont think so if somebody has this table on new instaled gallery.
I'm tryng change vote in sql query to image_votes but nothing happend vote : 5 doesnt show.
Title: Re: [MOD-Request] Comment & Vote system
Post by: Acidgod on February 03, 2007, 11:06:13 AM
Test it now...

On my Demo Site it works:
http://fw-shop.flash-webdesign.de/details.php?image_id=50
Title: Re: [MOD-Request] Comment & Vote system
Post by: om6acw on February 03, 2007, 11:10:37 AM
Test it now...

On my Demo Site it works:
http://fw-shop.flash-webdesign.de/details.php?image_id=50

now works great, thanks acidgod