"Non AICTE book proposals",
"page callback" => "tbc_comments_all",
"access arguments" => array("tbc comments"),
"type" => MENU_NORMAL_ITEM
);
$items["comments/ajax"] = array(
"page callback" => "tbc_comments_ajax",
"access callback" => TRUE,
"type" => MENU_CALLBACK
);
$items["comments/books/ajax"] = array(
"page callback" => "tbc_comments_books_ajax",
"access callback" => TRUE,
"type" => MENU_CALLBACK
);
$items["comments/books/all/ajax"] = array(
"page callback" => "tbc_comments_books_all_ajax",
"access callback" => TRUE,
"type" => MENU_CALLBACK
);
$items["comments/forms/ajax"] = array(
"page callback" => "tbc_comments_forms_ajax",
"access callback" => TRUE,
"type" => MENU_CALLBACK
);
$items["comments/rand/ajax"] = array(
"page callback" => "tbc_comments_rand_refresh_ajax",
"access callback" => TRUE,
"type" => MENU_CALLBACK
);
return $items;
}
function tbc_comments_perm() {
return array(
"tbc comments",
);
}
function tbc_comments_all($type, $id, $count){
$page_content = "";
$page_content .= "";
$query= db_query("
SELECT pe.book as book, pe.author as author, pe.publisher as publisher, pe.year as year, pe.id as pe_id, pe.pLike, pe.pDislike, po.approval_date as approval_date, po.reason, po.reference
FROM {textbook_companion_preference} pe LEFT JOIN {textbook_companion_proposal} po ON pe.proposal_id = po.id
WHERE po.proposal_status = 0 AND pe.approval_status = 0 AND po.proposal_type = 1 ORDER BY pe.id DESC
");
$res=$query;
$countProduct= mysql_num_rows($res);
$page_content .= "
";
$base_url = $GLOBALS['base_url']. '/sites/all/modules/tbc_comments/image/';
if($countProduct > 0 ){
while ($preference_data = db_fetch_object($res)) {
$comment_query = db_query("
SELECT * FROM tbc_comments WHERE post_id = %d ORDER BY id DESC LIMIT 15
", $preference_data->pe_id);
$countComment= mysql_num_rows($comment_query);
$page_content .= "
";
$page_content .= "

";
$page_content .="
".$preference_data->book . "
by " . $preference_data->author .", ".$preference_data->publisher."
Reason(s):- ".$preference_data->reason ."
Reference(s):- ".$preference_data->reference ."
";
$page_content .= "
".$preference_data->pLike."";
$page_content .= "
".$preference_data->pDislike."";
$page_content .= " br>";
$page_content .= "";
$page_content .= " br>";
$page_content .= "";
$page_content .= "
";
}
} else{
$page_content .= "No proposals available";
}
$page_content .= "
";
return $page_content;
}
function tbc_comments_ajax($type, $id, $count) {
$data = "";
$type=$_POST['type'];
$id=$_POST['id'];
if(isset($_COOKIE['rateLikeChnage'."_".$id])){
if($type=='like'){
$fieldName='pLike';
} elseif($type=='dislike'){
$fieldName='pDislike';
} else{
//die();
}
$query= "select $fieldName from textbook_companion_preference where id= %d";
$res= db_query($query, $id);
$result= db_fetch_array($res);
$count= $result[$fieldName];
$data = $count;
echo $data;
exit();
} else{
if($type=='like'){
$fieldName='pLike';
} elseif($type=='dislike'){
$fieldName='pDislike';
} else{
//die();
}
$query= "
update textbook_companion_preference set $fieldName=$fieldName+1 where id= %d
";
$res= db_query($query, $id);
$query= "select $fieldName from textbook_companion_preference where id= %d";
$res= db_query($query, $id);
$result= db_fetch_array($res);
//result= mysql_fetch_array($res);
$count= $result[$fieldName];
$data = $count;
$expire=time()+60*60*24*30;
setcookie("rateLikeChnage"."_".$id, "rateLikeChnage"."_".$id, $expire);
echo $data;
exit();
}
}
function tbc_comments_books_ajax($name,$mail,$comment,$id,$notify) {
$base_url = $GLOBALS['base_url']. '/sites/all/modules/tbc_comments/image/';
$data = "";
if (!empty($_POST['name']) AND !empty($_POST['mail']) AND !empty($_POST['comment']) AND !empty($_POST['postid'])) {
$name = mysql_real_escape_string($_POST['name']);
$mail = mysql_real_escape_string($_POST['mail']);
$comment = mysql_real_escape_string($_POST['comment']);
$postId = mysql_real_escape_string($_POST['postid']);
$notify = mysql_real_escape_string($_POST['notify']);
mysql_query("INSERT INTO tbc_comments (name, mail, comment, post_id, notify) VALUES('{$name}', '{$mail}', '{$comment}', '{$postId}', '{$notify}')");
}
$data .= "";
$query = db_query("
SELECT DISTINCT pe.book as book, pe.author as author, pe.publisher as publisher, pe.year as year, tc.mail, tc.post_id, tc.name, tc.notify
FROM textbook_companion_preference pe JOIN tbc_comments tc ON pe.id = tc.post_id WHERE post_id = %s AND tc.notify = 1
", $postId);
while($row = db_fetch_object($query)){
$to = $row->mail;
// $to = "prashantsinalkar@gmail.com";
$subject = "New Comment On Non AICTE Book Proposal [Book: {$row->book}]";
$message = "
A new comment has been posted by {$row->name}.
Book: {$row->book}
Comment: {$_POST['comment']}
Link: http://scilab.in/comments
";
$from = "textbook@scilab.in";
$headers = "From: " . $from . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($to,$subject,$message,$headers);
}
echo $data;
exit();
}
function tbc_comments_books_all_ajax($id) {
$data = "";
$base_url = $GLOBALS['base_url']. '/sites/all/modules/tbc_comments/image/';
$comment_query = db_query("
SELECT * FROM tbc_comments WHERE post_id = %s ORDER BY id DESC
");
$data .= "Comments.....
";
$data .= "";
echo $data;
exit();
}
function tbc_comments_forms_ajax($id){
$id = $_POST['id'];
$data = "";
$base_url = $GLOBALS['base_url']. '/sites/all/modules/tbc_comments/image/';
$comment_query = db_query("
SELECT * FROM tbc_comments WHERE post_id = %d ORDER BY id DESC LIMIT 15
", $id);
$data .= "✖
";
$data .= "Comments.....
";
$data .= "";
$data .= "";
$data .= "";
$num1 =rand (1,5);
$num2 =rand (1,5);
$num3 = $num1 + $num2;
$data .= "";
$data .= "
";
$data .= "";
echo $data;
exit();
}
function tbc_comments_rand_refresh_ajax(){
$data = "";
$num1 =rand (1,5);
$num2 =rand (1,5);
$num3 = $num1 + $num2;
$data .= "";
$data .= "";
$data .= "
";
echo $data;
exit();
}
function tbc_comments_init() {
drupal_add_css(drupal_get_path("module", "tbc_comments") . "/css/tbc_comments_styles.css");
drupal_add_css(drupal_get_path("module", "tbc_comments") . "/css/tbc_comments.css");
drupal_add_js(drupal_get_path("module", "tbc_comments") . "/js/tbc_comment_ajax.js");
drupal_add_js(drupal_get_path("module", "tbc_comments") . "/js/jquery-1.4.1.min.js");
drupal_add_js(drupal_get_path("module", "tbc_comments") . "/js/jquery-1.2.6.min.js");
}
?>
". $name ." said....
".date('Y-m-d H:i:s')."
". $comment."
"; $data .= "