Hi,
Originally Posted by
riffster
I have VS 2.7 on my server and everything seems to be working fine expect for when someone posts a comment on a video. It doesn't send out an email to other commenters saying there is a reply. Does anyone know why or how to fix it so when a user replies to a video a email is sent out to anyone else that commented to a video?
This will fix the email issue (only for v2.7)
Open ajax/video_comment_add.php
Replace
With
Code:
$sql = "SELECT `video_title`, `video_seo_name` FROM `videos` WHERE
`video_id`='" . (int) $video_id . "'";
$video_result = mysql_query($sql) or mysql_die($sql);
$video_info = mysql_fetch_assoc($video_result);
$video_title = $video_info['video_title'];
$video_seo_name = $video_info['video_seo_name'];
$video_url = VSHARE_URL . '/view/' . $video_id . '/' . $video_seo_name . '/';
$sql = "SELECT * FROM `email_templates` WHERE
`email_id`='video_comment_mail'";
$result = mysql_query($sql) or mysql_die();
if (mysql_num_rows($result) == 0)
{
$email_subject = '[SITE_NAME] - [USERNAME] has commented a video.';
$email_body = '<p>Hi [RECIEVER_NAME],</p><p>[USERNAME] has commented a video \"[VIDEO_TITLE]\"</p><p>Click the following link to view the video and comments.</p><p><a href=\"[VIDEO_URL]\">[VIDEO_TITLE]</a></p><p>Thank you,</p><p><a href=\"[SITE_URL]\">[SITE_NAME]</a></p>';
$sql = "INSERT INTO `email_templates` SET
`email_id`='video_comment_mail',
`email_subject`='[SITE_NAME] - [USERNAME] has commented a video.',
`email_body`='<p>Hi [RECIEVER_NAME],</p><p>[USERNAME] has commented a video \"[VIDEO_TITLE]\"</p><p>Click the following link to view the video and comments.</p><p><a href=\"[VIDEO_URL]\">[VIDEO_TITLE]</a></p><p>Thank you,</p><p><a href=\"[SITE_URL]\">[SITE_NAME]</a></p>',
`comment`='Send mail when comment a video.'";
mysql_query($sql) or mysql_die();
}
else
{
$email_info = mysql_fetch_assoc($result);
$email_subject = $email_info['email_subject'];
$email_body = $email_info['email_body'];
}
$email_subject = str_replace('[USERNAME]', $_SESSION['USERNAME'], $email_subject);
$email_subject = str_replace('[SITE_NAME]', $config['site_name'], $email_subject);
$sql = "SELECT DISTINCT `comment_user_id` FROM `comments` WHERE
`comment_video_id`='" . (int) $video_id . "'";
$result = mysql_query($sql) or mysql_die();
if (mysql_num_rows($result) > 1)
{
while ($comment_info = mysql_fetch_assoc($result))
{
$video_commented_user_id = $comment_info['comment_user_id'];
if ($video_commented_user_id != $_SESSION['UID'])
{
$sql = "SELECT `user_name`,`user_email` FROM `users` WHERE
`user_id`='" . (int) $video_commented_user_id . "'";
$tmp = mysql_query($sql) or mysql_die();
if (mysql_num_rows($tmp) > 0)
{
$tmp_info = mysql_fetch_assoc($tmp);
$email_body_tmp = $email_body;
$email_body_tmp = str_replace('[USERNAME]', $_SESSION['USERNAME'], $email_body_tmp);
$email_body_tmp = str_replace('[VIDEO_TITLE]', $video_title, $email_body_tmp);
$email_body_tmp = str_replace('[VIDEO_URL]', $video_url, $email_body_tmp);
$email_body_tmp = str_replace('[SITE_URL]', VSHARE_URL, $email_body_tmp);
$email_body_tmp = str_replace('[SITE_NAME]', $config['site_name'], $email_body_tmp);
$email_body_tmp = str_replace('[RECIEVER_NAME]', $tmp_info['user_name'], $email_body_tmp);
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ' . $config['site_name'] . ' <' . $config['admin_email'] . '>' . "\r\n";
mail($tmp_info['user_email'], $email_subject, $email_body_tmp, $headers);
}
}
}
}
db_close();
You can edit email template(video_comment_mail) from admin area.
Thanks,
Buyscript Team
Bookmarks