deniz |
05-22-2004 02:59 PM |
Free Reviews Confirmation Addon
Hi anyone,
I ve tried to make a simple mode for xcart product review,
When a review sended , first admin should confirm.
Simple steps to make this mode. (Please change some values to as yours)
1.
make a template under admin/main/yorum.tpl
Code:
In this screen you can confirm your product reviews.
Mode Deniz made..
{capture name=dialog}
<table border=0 cellspacing=5>
<tr>
<td valign=top>Review Id </td>
<td valign=top>Email</td>
<td valign=top>Message</td>
<td valign=top>Product</td>
<td valign=top><div align="center">?</div></td>
</tr>
{section name=cust_num loop=$wl_data2}
<tr>
<td valign=top>{$wl_data2[cust_num].review_id}</td>
<td valign=top> {$wl_data2[cust_num].email}</td>
<td valign=top> {$wl_data2[cust_num].message}</td>
<td valign=top>{$wl_data2[cust_num].productid}</td>
<td valign=top>Confirm</td>
</tr>
{/section}
</table>
{/capture}
{include file="dialog.tpl" title="Reviews Confirmation Addon " content=$smarty.capture.dialog extra="width=100%"}
2.
create yorum.php under admin directory
admin/yorum.php
Code:
<?
require "../smarty.php";
require "../config.php";
require "./auth.php";
require "../include/security.php";
#
# Deniz Reviews modul...
#
$wl_data2= func_query("SELECT * FROM xcart_product_reviews WHERE confirm='N'");
{
if ($_GET['mode'] = 'update') {
mysql_query ("UPDATE xcart_product_reviews SET confirm ='Y' WHERE review_id='$_GET[review_id]'");
}
}
$smarty->assign("wl_data2",$wl_data2);
$smarty->assign("main","yorum");
@include "../modules/gold_display.php";
$smarty->display("admin/home.tpl");
?>
3. After you did , you have to add some lines to "include/vote.php" forexampe in SQL string " AND confirm='Y' "
Code:
<?php
$N="N";
if (($mode=='vote') and ($productid) and ($vote>=1) and ($vote<=5)) {
$result = func_query_first ("SELECT * FROM $sql_tbl[product_votes] WHERE remote_ip='$REMOTE_ADDR' AND productid='$productid'");
if ($result) {
header ("Location: error_message.php?error_already_voted");
exit;
} else {
db_query ("INSERT INTO $sql_tbl[product_votes] (remote_ip, vote_value, productid) VALUES ('$REMOTE_ADDR','$vote', '$productid')");
header ("Location: product.php?productid=$productid");
exit;
}
} elseif (($mode=='review') and ($productid)) {
$result = func_query_first ("SELECT * FROM $sql_tbl[product_reviews] WHERE remote_ip='$REMOTE_ADDR' AND productid='$productid' AND confirm='Y'");
if ($result) {
header ("Location: error_message.php?error_review_exists");
exit;
} else {
$review_author = htmlspecialchars($review_author);
$review_message = htmlspecialchars($review_message);
db_query ("INSERT INTO $sql_tbl[product_reviews] (remote_ip, email, message, productid, confirm) VALUES ('$REMOTE_ADDR', '$review_author', '$review_message', '$productid', '$N')");
header ("Location: product.php?productid=$productid");
exit;
}
}
$vote_result = func_query_first ("SELECT COUNT(remote_ip) as total, AVG(vote_value) as rating FROM $sql_tbl[product_votes] WHERE productid='$productid'");
if ($vote_result["total"] == 0)
$vote_result["rating"] = 0;
$smarty->assign ("vote_result", $vote_result);
$vote_max_cows = floor ($vote_result["rating"]);
$vote_little_cow = round (($vote_result["rating"]-$vote_max_cows) * 4);
$vote_free_cows = 5 - $vote_max_cows - (($vote_little_cow==0) ? 0 : 1);
$smarty->assign ("vote_max_cows", $vote_max_cows);
$smarty->assign ("vote_little_cow", $vote_little_cow);
$smarty->assign ("vote_free_cows", $vote_free_cows);
if(!empty($login)) {
$customer_info = func_userinfo($login,$login_type);
$smarty->assign ("customer_info", $customer_info);
}
$reviews = func_query ("SELECT * FROM $sql_tbl[product_reviews] WHERE productid='$productid' AND confirm='Y'");
if (!empty($reviews))
foreach ($reviews as $k => $val) {
$reviews[$k]["email"] = $val["email"];
$reviews[$k]["message"] = $val["message"];
}
$smarty->assign ("reviews", $reviews);
?>
4. Add field to SQL database.
in your xcart_product_reviews
add the field
"Confirm" With VarChar 1 Default "N"
the Sql string is: (3.3.5 ? I didnot test the other versions but I guess no diffrences in)
SQL executer is:
Code:
CREATE TABLE xcart_product_reviews (
review_id int(11) NOT NULL auto_increment,
remote_ip varchar(15) NOT NULL default '',
email varchar(128) NOT NULL default '',
message varchar(255) NOT NULL default '',
productid int(11) NOT NULL default '0',
confirm char(1) default 'N',
PRIMARY KEY (review_id),
KEY productid (productid),
KEY remote_ip (remote_ip)
) TYPE=MyISAM;
5.
add the lines to single/home.tpl
Code:
{elseif $main eq "yorum"}
{include file="admin/main/yorum.tpl"}
6.
Add the line under /admin/menu_admin.tpl
under the the line and save thatsall.
Yes this first step , I am not much time to improve the module , bu i will .
Have fun from Turkiye.....
Deniz.
|