1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-26 03:30:48 +03:00

Модуль подписок пользователей на различные уведомления + подписка на комментарии к топику

This commit is contained in:
Mzhelskiy Maxim 2012-03-10 17:40:59 +04:00
parent c7e1058f53
commit 57dd36802b
19 changed files with 648 additions and 23 deletions

View file

@ -1021,20 +1021,28 @@ class ActionBlog extends Action {
*/
$this->oUserCurrent->setDateCommentLast(date("Y-m-d H:i:s"));
$this->User_Update($this->oUserCurrent);
/**
* Список емайлов на которые не нужно отправлять уведомление
*/
$aExcludeMail=array($this->oUserCurrent->getMail());
/**
* Отправляем уведомление тому на чей коммент ответили
*/
if ($oCommentParent and $oCommentParent->getUserId()!=$oTopic->getUserId() and $oCommentNew->getUserId()!=$oCommentParent->getUserId()) {
$oUserAuthorComment=$oCommentParent->getUser();
$aExcludeMail[]=$oUserAuthorComment->getMail();
$this->Notify_SendCommentReplyToAuthorParentComment($oUserAuthorComment,$oTopic,$oCommentNew,$this->oUserCurrent);
}
/**
* Отправка уведомления автору топика
*/
$oUserTopic=$oTopic->getUser();
if ($oCommentNew->getUserId()!=$oUserTopic->getId()) {
$this->Notify_SendCommentNewToAuthorTopic($oUserTopic,$oTopic,$oCommentNew,$this->oUserCurrent);
}
/**
* Отправляем уведомление тому на чей коммент ответили
*/
if ($oCommentParent and $oCommentParent->getUserId()!=$oTopic->getUserId() and $oCommentNew->getUserId()!=$oCommentParent->getUserId()) {
$oUserAuthorComment=$oCommentParent->getUser();
$this->Notify_SendCommentReplyToAuthorParentComment($oUserAuthorComment,$oTopic,$oCommentNew,$this->oUserCurrent);
}
$this->Subscribe_Send('topic_new_comment',$oTopic->getId(),'notify.comment_new.tpl',$this->Lang_Get('notify_subject_comment_new'),array(
'oTopic' => $oTopic,
'oComment' => $oCommentNew,
'oUserComment' => $this->oUserCurrent,
),$aExcludeMail);
/**
* Добавляем событие в ленту
*/

View file

@ -318,6 +318,10 @@ class ActionLink extends Action {
* Обновляем количество топиков в блоге
*/
$this->Blog_RecalculateCountTopicByBlogId($oTopic->getBlogId());
/**
* Добавляем автора топика в подписчики на новые комментарии к этому топику
*/
$this->Subscribe_AddSubscribeSimple('topic_new_comment',$oTopic->getId(),$this->oUserCurrent->getMail());
//Делаем рассылку спама всем, кто состоит в этом блоге
if ($oTopic->getPublish()==1 and $oBlog->getType()!='personal') {
$this->Topic_SendNotifyTopicNew($oBlog,$oTopic,$this->oUserCurrent);

View file

@ -534,6 +534,10 @@ class ActionPhotoset extends Action {
* Обновляем количество топиков в блоге
*/
$this->Blog_RecalculateCountTopicByBlogId($oTopic->getBlogId());
/**
* Добавляем автора топика в подписчики на новые комментарии к этому топику
*/
$this->Subscribe_AddSubscribeSimple('topic_new_comment',$oTopic->getId(),$this->oUserCurrent->getMail());
//Делаем рассылку спама всем, кто состоит в этом блоге
if ($oTopic->getPublish()==1 and $oBlog->getType()!='personal') {
$this->Topic_SendNotifyTopicNew($oBlog,$oTopic,$this->oUserCurrent);

View file

@ -299,6 +299,10 @@ class ActionQuestion extends Action {
* Обновляем количество топиков в блоге
*/
$this->Blog_RecalculateCountTopicByBlogId($oTopic->getBlogId());
/**
* Добавляем автора топика в подписчики на новые комментарии к этому топику
*/
$this->Subscribe_AddSubscribeSimple('topic_new_comment',$oTopic->getId(),$this->oUserCurrent->getMail());
//Делаем рассылку спама всем, кто состоит в этом блоге
if ($oTopic->getPublish()==1 and $oBlog->getType()!='personal') {
$this->Topic_SendNotifyTopicNew($oBlog,$oTopic,$this->oUserCurrent);

View file

@ -0,0 +1,124 @@
<?php
/*-------------------------------------------------------
*
* LiveStreet Engine Social Networking
* Copyright © 2008 Mzhelskiy Maxim
*
*--------------------------------------------------------
*
* Official site: www.livestreet.ru
* Contact e-mail: rus.engine@gmail.com
*
* GNU General Public License, version 2:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
---------------------------------------------------------
*/
class ActionSubscribe extends Action {
/**
* Инициализация
*
*/
public function Init() {
$this->oUserCurrent=$this->User_GetUserCurrent();
}
/**
* Регистрация евентов
*
*/
protected function RegisterEvent() {
$this->AddEventPreg('/^unsubscribe$/i','/^\w{32}$/i','EventUnsubscribe');
$this->AddEvent('ajax-subscribe-toggle','EventAjaxSubscribeToggle');
}
/**********************************************************************************
************************ РЕАЛИЗАЦИЯ ЭКШЕНА ***************************************
**********************************************************************************
*/
/**
* Отписка от подписки
*/
protected function EventUnsubscribe() {
if ($oSubscribe=$this->Subscribe_GetSubscribeByKey($this->getParam(0)) and $oSubscribe->getStatus()==1) {
$oSubscribe->setStatus(0);
$oSubscribe->setDateRemove(date("Y-m-d H:i:s"));
$this->Subscribe_UpdateSubscribe($oSubscribe);
$this->Message_AddNotice($this->Lang_Get('subscribe_change_ok'),null,true);
}
/**
* Получаем URL для редиректа
*/
if ((!$sUrl=$this->Subscribe_GetUrlTarget($oSubscribe->getTargetType(),$oSubscribe->getTargetId()))) {
$sUrl=Router::GetPath('index');
}
Router::Location($sUrl);
}
/**
* Изменение состояния подписки
*/
protected function EventAjaxSubscribeToggle() {
$this->Viewer_SetResponseAjax('json');
/**
* Получаем емайл подписки и проверяем его на валидность
*/
$sMail=getRequest('mail');
if ($this->oUserCurrent) {
$sMail=$this->oUserCurrent->getMail();
}
if (!func_check($sMail,'mail')) {
$this->Message_AddError($this->Lang_Get('registration_mail_error'),$this->Lang_Get('error'));
return ;
}
/**
* Получаем тип объекта подписки
*/
$sTargetType=getRequest('target_type');
if (!$this->Subscribe_IsAllowTargetType($sTargetType)) {
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
return ;
}
$sTargetId=getRequest('target_id') ? getRequest('target_id') : null;
$iValue=getRequest('value') ? 1 : 0;
$oSubscribe=null;
/**
* Есть ли доступ к подписке гостям?
*/
if (!$this->oUserCurrent and !$this->Subscribe_IsAllowTargetForGuest($sTargetType)) {
$this->Message_AddError($this->Lang_Get('need_authorization'),$this->Lang_Get('error'));
return ;
}
/**
* Проверка объекта подписки
*/
if (!$this->Subscribe_CheckTarget($sTargetType,$sTargetId,$iValue)) {
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
return ;
}
/**
* Если подписка еще не существовала, то создаем её
*/
$oSubscribe=$this->Subscribe_AddSubscribeSimple($sTargetType,$sTargetId,$sMail);
if ($oSubscribe) {
$oSubscribe->setStatus($iValue);
$this->Subscribe_UpdateSubscribe($oSubscribe);
$this->Message_AddNotice($this->Lang_Get('subscribe_change_ok'),$this->Lang_Get('attention'));
return ;
}
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
return ;
}
}
?>

View file

@ -349,6 +349,10 @@ class ActionTopic extends Action {
* Обновляем количество топиков в блоге
*/
$this->Blog_RecalculateCountTopicByBlogId($oTopic->getBlogId());
/**
* Добавляем автора топика в подписчики на новые комментарии к этому топику
*/
$this->Subscribe_AddSubscribeSimple('topic_new_comment',$oTopic->getId(),$this->oUserCurrent->getMail());
/**
* Делаем рассылку спама всем, кто состоит в этом блоге
*/

View file

@ -0,0 +1,271 @@
<?php
/*-------------------------------------------------------
*
* LiveStreet Engine Social Networking
* Copyright © 2008 Mzhelskiy Maxim
*
*--------------------------------------------------------
*
* Official site: www.livestreet.ru
* Contact e-mail: rus.engine@gmail.com
*
* GNU General Public License, version 2:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
---------------------------------------------------------
*/
/**
* Модуль Subscribe - подписки пользователей
*
*/
class ModuleSubscribe extends Module {
protected $oMapper;
protected $oUserCurrent;
/**
* Список доступных объектов подписок с параметрами
* На данный момент допустим параметр allow_for_guest=>1 - указывает на возможность создавать подписку для гостя
*
* @var array
*/
protected $aTargetTypes=array(
'topic_new_comment' => array(),
);
/**
* Инициализация
*
*/
public function Init() {
$this->oMapper=Engine::GetMapper(__CLASS__);
$this->oUserCurrent=$this->User_GetUserCurrent();
}
/**
* Возвращает список типов объектов для облаты
*/
public function GetTargetTypes() {
return $this->aTargetTypes;
}
/**
* Добавляет в разрешенные новый тип
* @param unknown_type $sTargetType
*/
public function AddTargetType($sTargetType,$aParams=array()) {
if (!array_key_exists($sTargetType,$this->aTargetTypes)) {
$this->aTargetTypes[$sTargetType]=$aParams;
return true;
}
return false;
}
/**
* Проверяет разрешен ли данный тип в подписке
*
* @param $sTargetType
* @return bool
*/
public function IsAllowTargetType($sTargetType) {
return in_array($sTargetType,array_keys($this->aTargetTypes));
}
/**
* Проверка объекта подписки
*
* @param string $sTargetType
* @param int $iTargetId
* @param int $iCheckType
*/
public function CheckTarget($sTargetType,$iTargetId,$iStatus=null) {
$sMethod = 'CheckTarget'.func_camelize($sTargetType);
if (method_exists($this,$sMethod)) {
return $this->$sMethod($iTargetId,$iStatus);
}
return false;
}
/**
* Возвращает URL страницы с объектом подписки
* Актуально при переходе по ссылки с отпиской от рассылки и последующим редиректом
*
* @param string $sTargetType
* @param int $iTargetId
*/
public function GetUrlTarget($sTargetType,$iTargetId) {
$sMethod = 'GetUrlTarget'.func_camelize($sTargetType);
if (method_exists($this,$sMethod)) {
return $this->$sMethod($iTargetId);
}
return false;
}
/**
* Проверка на подписку для гостей
*
* @param $sTargetType
* @return bool
*/
public function IsAllowTargetForGuest($sTargetType) {
if ($this->IsAllowTargetType($sTargetType)) {
if (isset($this->aTargetTypes[$sTargetType]['allow_for_guest']) and $this->aTargetTypes[$sTargetType]['allow_for_guest']) {
return true;
}
}
return false;
}
/**
* Добавляет подписку в БД
*
* @param $oSubscribe
* @return ModuleSubscribe_EntitySubscribe | bool
*/
public function AddSubscribe($oSubscribe) {
if ($sId=$this->oMapper->AddSubscribe($oSubscribe)) {
$oSubscribe->setId($sId);
return $oSubscribe;
}
return false;
}
/**
* Создает подписку, если уже есть, то возвращает существующую
*
* @param $sTargetType
* @param $sTargetId
* @param $sMail
* @return ModuleSubscribe_EntitySubscribe
*/
public function AddSubscribeSimple($sTargetType,$sTargetId,$sMail) {
if (!($oSubscribe=$this->Subscribe_GetSubscribeByTargetAndMail($sTargetType,$sTargetId,$sMail))) {
$oSubscribe=Engine::GetEntity('Subscribe');
$oSubscribe->setTargetType($sTargetType);
$oSubscribe->setTargetId($sTargetId);
$oSubscribe->setMail($sMail);
$oSubscribe->setDateAdd(date("Y-m-d H:i:s"));
$oSubscribe->setKey(func_generator(32));
$oSubscribe->setIp(func_getIp());
$oSubscribe->setStatus(1);
$this->Subscribe_AddSubscribe($oSubscribe);
}
return $oSubscribe;
}
public function UpdateSubscribe($oSubscribe) {
return $this->oMapper->UpdateSubscribe($oSubscribe);
}
/**
* Возвращает список подписок по фильтру
*
* @param $aFilter
* @param $aOrder
* @param $iCurrPage
* @param $iPerPage
* @return array
*/
public function GetSubscribes($aFilter,$aOrder,$iCurrPage,$iPerPage) {
return array('collection'=>$this->oMapper->GetSubscribes($aFilter,$aOrder,$iCount,$iCurrPage,$iPerPage),'count'=>$iCount);
}
/**
* Возвращает подписку по объекту подписки и емайлу
*
* @param $sTargetType
* @param $iTargetId
* @param $sMail
* @return ModuleSubscribe_EntitySubscribe
*/
public function GetSubscribeByTargetAndMail($sTargetType,$iTargetId,$sMail) {
$aRes=$this->GetSubscribes(array('target_type'=>$sTargetType,'target_id'=>$iTargetId,'mail'=>$sMail),array(),1,1);
if (isset($aRes['collection'][0])) {
return $aRes['collection'][0];
}
return null;
}
/**
* Возвращает подписку по ключу
*
* @param $sKey
* @return ModuleSubscribe_EntitySubscribe
*/
public function GetSubscribeByKey($sKey) {
$aRes=$this->GetSubscribes(array('key'=>$sKey),array(),1,1);
if (isset($aRes['collection'][0])) {
return $aRes['collection'][0];
}
return null;
}
/**
* Производит отправку писем по подписчикам подписки
*
* @param $sTargetType Тип объекта подписки
* @param $iTargetId ID объекта подписки
* @param $sTemplate Имя шаблона письма, например, notify.mail.tpl
* @param $sTitle Заголовок письма
* @param array $aParams Параметра для передачи в шаблон письма
* @param array $aExcludeMail Список емайлов на которые НЕ нужно отправлять
*/
public function Send($sTargetType,$iTargetId,$sTemplate,$sTitle,$aParams=array(),$aExcludeMail=array(),$sPluginName=null) {
$iPage=1;
$aSubscribes=$this->Subscribe_GetSubscribes(array('target_type'=>$sTargetType,'target_id'=>$iTargetId,'status'=>1,'exclude_mail'=>$aExcludeMail),array(),$iPage,20);
while ($aSubscribes['collection']) {
$iPage++;
foreach ($aSubscribes['collection'] as $oSubscribe) {
$aParams['sSubscribeKey']=$oSubscribe->getKey();
$this->Notify_Send(
$oSubscribe->getMail(),
$sTemplate,
$sTitle,
$aParams,
$sPluginName
);
}
$aSubscribes=$this->Subscribe_GetSubscribes(array('target_type'=>$sTargetType,'target_id'=>$iTargetId,'status'=>1),array(),$iPage,20);
}
}
/**
* Проверка объекта подписки с типом "topic_new_comment"
* Название метода формируется автоматически
*
* @param int $iTargetId
* @param int $iStatus
*/
public function CheckTargetTopicNewComment($iTargetId,$iStatus) {
if ($oTopic=$this->Topic_GetTopicById($iTargetId)) {
/**
* Топик может быть в закрытом блоге, поэтому необходимо разрешить подписку только если пользователь в нем состоит
* Отписываться разрешаем с любого топика
*/
if ($iStatus==1 and $oTopic->getBlog()->getType()=='close') {
if (!$this->oUserCurrent or !$this->Blog_GetBlogUserByBlogIdAndUserId($oTopic->getBlogId(),$this->oUserCurrent->getId())) {
return false;
}
}
return true;
}
return false;
}
/**
* Возвращает URL на страницы объекта подписки с типом "topic_new_comment"
* Название метода формируется автоматически
*
* @param $iTargetId
* @return bool
*/
public function GetUrlTargetTopicNewComment($iTargetId) {
if ($oTopic=$this->Topic_GetTopicById($iTargetId) and $oTopic->getPublish()) {
return $oTopic->getUrl();
}
return false;
}
}
?>

View file

@ -0,0 +1,21 @@
<?php
/*-------------------------------------------------------
*
* LiveStreet Engine Social Networking
* Copyright © 2008 Mzhelskiy Maxim
*
*--------------------------------------------------------
*
* Official site: www.livestreet.ru
* Contact e-mail: rus.engine@gmail.com
*
* GNU General Public License, version 2:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
---------------------------------------------------------
*/
class ModuleSubscribe_EntitySubscribe extends Entity {
}
?>

View file

@ -0,0 +1,102 @@
<?php
/*-------------------------------------------------------
*
* LiveStreet Engine Social Networking
* Copyright © 2008 Mzhelskiy Maxim
*
*--------------------------------------------------------
*
* Official site: www.livestreet.ru
* Contact e-mail: rus.engine@gmail.com
*
* GNU General Public License, version 2:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
---------------------------------------------------------
*/
class ModuleSubscribe_MapperSubscribe extends Mapper {
public function AddSubscribe($oSubscribe) {
$sql = "INSERT INTO ".Config::Get('db.table.subscribe')." SET ?a ";
if ($iId=$this->oDb->query($sql,$oSubscribe->_getData())) {
return $iId;
}
return false;
}
public function GetSubscribeByTypeAndMail($sType,$sMail) {
$sql = "SELECT * FROM ".Config::Get('db.table.subscribe')." WHERE target_type = ? and mail = ?";
if ($aRow=$this->oDb->selectRow($sql,$sType,$sMail)) {
return Engine::GetEntity('Subscribe',$aRow);
}
return null;
}
public function UpdateSubscribe($oSubscribe) {
$sql = "UPDATE ".Config::Get('db.table.subscribe')."
SET
status = ?,
date_remove = ?
WHERE id = ?d
";
return $this->oDb->query($sql,$oSubscribe->getStatus(),
$oSubscribe->getDateRemove(),
$oSubscribe->getId());
}
public function GetSubscribes($aFilter,$aOrder,&$iCount,$iCurrPage,$iPerPage) {
$aOrderAllow=array('id','date_add','status');
$sOrder='';
foreach ($aOrder as $key=>$value) {
if (!in_array($key,$aOrderAllow)) {
unset($aOrder[$key]);
} elseif (in_array($value,array('asc','desc'))) {
$sOrder.=" {$key} {$value},";
}
}
$sOrder=trim($sOrder,',');
if ($sOrder=='') {
$sOrder=' id desc ';
}
if (isset($aFilter['exclude_mail']) and !is_array($aFilter['exclude_mail'])) {
$aFilter['exclude_mail']=array($aFilter['exclude_mail']);
}
$sql = "SELECT
*
FROM
".Config::Get('db.table.subscribe')."
WHERE
1 = 1
{ AND target_type = ? }
{ AND target_id = ?d }
{ AND mail = ? }
{ AND mail not IN (?a) }
{ AND `key` = ? }
{ AND status = ?d }
ORDER by {$sOrder}
LIMIT ?d, ?d ;
";
$aResult=array();
if ($aRows=$this->oDb->selectPage($iCount,$sql,
isset($aFilter['target_type']) ? $aFilter['target_type'] : DBSIMPLE_SKIP,
isset($aFilter['target_id']) ? $aFilter['target_id'] : DBSIMPLE_SKIP,
isset($aFilter['mail']) ? $aFilter['mail'] : DBSIMPLE_SKIP,
(isset($aFilter['exclude_mail']) and count($aFilter['exclude_mail']) ) ? $aFilter['exclude_mail'] : DBSIMPLE_SKIP,
isset($aFilter['key']) ? $aFilter['key'] : DBSIMPLE_SKIP,
isset($aFilter['status']) ? $aFilter['status'] : DBSIMPLE_SKIP,
($iCurrPage-1)*$iPerPage, $iPerPage
)) {
foreach ($aRows as $aRow) {
$aResult[]=Engine::GetEntity('Subscribe',$aRow);
}
}
return $aResult;
}
}
?>

View file

@ -142,6 +142,12 @@ class ModuleTopic_EntityTopic extends Entity
public function getCountFavourite() {
return $this->_aData['topic_count_favourite'];
}
public function getSubscribeNewComment() {
if (!($oUserCurrent=$this->User_GetUserCurrent())) {
return null;
}
return $this->Subscribe_GetSubscribeByTargetAndMail('topic_new_comment',$this->getId(),$oUserCurrent->getMail());
}
/***************************************************************************************************************************************************
* методы расширения типов топика

View file

@ -314,10 +314,11 @@ $config['db']['table']['notify_task'] = '___db.table.prefix___notify_tas
$config['db']['table']['userfeed_subscribe'] = '___db.table.prefix___userfeed_subscribe';
$config['db']['table']['stream_subscribe'] = '___db.table.prefix___stream_subscribe';
$config['db']['table']['stream_event'] = '___db.table.prefix___stream_event';
$config['db']['table']['stream_user_type'] = '___db.table.prefix___stream_user_type';
$config['db']['table']['user_field'] = '___db.table.prefix___user_field';
$config['db']['table']['user_field_value'] = '___db.table.prefix___user_field_value';
$config['db']['table']['topic_photo'] = '___db.table.prefix___topic_photo';
$config['db']['table']['stream_user_type'] = '___db.table.prefix___stream_user_type';
$config['db']['table']['user_field'] = '___db.table.prefix___user_field';
$config['db']['table']['user_field_value'] = '___db.table.prefix___user_field_value';
$config['db']['table']['topic_photo'] = '___db.table.prefix___topic_photo';
$config['db']['table']['subscribe'] = '___db.table.prefix___subscribe';
$config['db']['tables']['engine'] = 'InnoDB'; // InnoDB или MyISAM
/**
@ -362,7 +363,8 @@ $config['router']['page']['admin'] = 'ActionAdmin';
$config['router']['page']['ajax'] = 'ActionAjax';
$config['router']['page']['feed'] = 'ActionUserfeed';
$config['router']['page']['stream'] = 'ActionStream';
$config['router']['page']['photoset'] = 'ActionPhotoset';
$config['router']['page']['photoset'] = 'ActionPhotoset';
$config['router']['page']['subscribe'] = 'ActionSubscribe';
// Глобальные настройки роутинга
$config['router']['config']['action_default'] = 'index';
$config['router']['config']['action_not_found'] = 'error';
@ -490,6 +492,7 @@ $config['head']['default']['js'] = array(
"___path.root.engine_lib___/internal/template/js/talk.js",
"___path.root.engine_lib___/internal/template/js/vote.js",
"___path.root.engine_lib___/internal/template/js/poll.js",
"___path.root.engine_lib___/internal/template/js/subscribe.js",
"___path.root.engine_lib___/internal/template/js/comments.js",
"___path.root.engine_lib___/internal/template/js/blog.js",
"___path.root.engine_lib___/internal/template/js/friend.js",

View file

@ -0,0 +1,27 @@
var ls = ls || {};
/**
* Подписка
*/
ls.subscribe = (function ($) {
/**
* Подписка/отписка
*/
this.toggle = function(sTargetType, iTargetId, sMail, iValue) {
var url = aRouter['subscribe']+'ajax-subscribe-toggle/';
var params = {target_type: sTargetType, target_id: iTargetId, mail: sMail, value: iValue};
'*toggleBefore*'; '*/toggleBefore*';
ls.ajax(url, params, function(result) {
if (result.bStateError) {
ls.msg.error(null, result.sMsg);
} else {
ls.msg.notice(null, result.sMsg);
ls.hook.run('ls_subscribe_toggle_after',[sTargetType, iTargetId, sMail, iValue, result]);
}
});
return false;
}
return this;
}).call(ls.subscribe || {},jQuery);

View file

@ -7,3 +7,22 @@ ADD `topic_count_vote_abstain` INT NOT NULL DEFAULT '0' AFTER `topic_count_vote_
ALTER TABLE `prefix_blog` ADD `blog_count_topic` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `blog_count_user` ,
ADD INDEX ( `blog_count_topic` );
CREATE TABLE IF NOT EXISTS `prefix_subscribe` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`target_type` varchar(20) NOT NULL,
`target_id` int(11) DEFAULT NULL,
`mail` varchar(50) NOT NULL,
`date_add` datetime NOT NULL,
`date_remove` datetime DEFAULT NULL,
`ip` varchar(20) NOT NULL,
`key` varchar(32) DEFAULT NULL,
`status` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`),
KEY `type` (`target_type`),
KEY `mail` (`mail`),
KEY `status` (`status`),
KEY `key` (`key`),
KEY `target_id` (`target_id`),
KEY `ip` (`ip`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View file

@ -344,6 +344,7 @@ return array(
'comment_add' => 'Add',
'comment_preview' => 'Preview',
'comment_unregistered' => 'Only registered users can comment.',
'comment_subscribe' => 'subscribe to new comments',
/**
* Comment votes
*/
@ -832,7 +833,7 @@ return array(
/**
* Notifications
*/
'notify_subject_comment_new' => 'New comment added to your topic',
'notify_subject_comment_new' => 'New comment on topic',
'notify_subject_comment_reply' => 'You\'ve recieved reply to your comment',
'notify_subject_topic_new' => 'New topic in the blog',
'notify_subject_registration_activate' => 'Registration',
@ -890,6 +891,10 @@ return array(
'validate_required_must_be' => 'Field %%field%% must be %%value%%',
'validate_required_cannot_blank' => 'Field %%field%% cannot be blank',
'validate_url_not_valid' => 'Field %%field%% is not a valid URL',
/**
* Подписка
*/
'subscribe_change_ok' => 'Change the subscription was successful',
/**
* System
*/

View file

@ -344,6 +344,7 @@ return array(
'comment_add' => 'добавить',
'comment_preview' => 'предпросмотр',
'comment_unregistered' => 'Только зарегистрированные и авторизованные пользователи могут оставлять комментарии.',
'comment_subscribe' => 'подписаться на новые комментарии',
/**
* Голосование за комментарий
*/
@ -832,7 +833,7 @@ return array(
/**
* Уведомления
*/
'notify_subject_comment_new' => 'К вашему топику оставили новый комментарий',
'notify_subject_comment_new' => 'Новый комментарий к топику',
'notify_subject_comment_reply' => 'Вам ответили на ваш комментарий',
'notify_subject_topic_new' => 'Новый топик в блоге',
'notify_subject_registration_activate' => 'Регистрация',
@ -890,6 +891,10 @@ return array(
'validate_required_must_be' => 'Поле %%field%% должно иметь значение %%value%%',
'validate_required_cannot_blank' => 'Поле %%field%% не может быть пустым',
'validate_url_not_valid' => 'Поле %%field%% не соотвествует формату URL адреса',
/**
* Подписка
*/
'subscribe_change_ok' => 'Изменение подписки прошло успешно',
/**
* Системные сообщения
*/

View file

@ -11,7 +11,9 @@
bAllowNewComment=$oTopic->getForbidComment()
sNoticeNotAllow=$aLang.topic_comment_notallow
sNoticeCommentAdd=$aLang.topic_comment_add
aPagingCmt=$aPagingCmt}
bAllowSubscribe=true
oSubscribeComment=$oTopic->getSubscribeNewComment()
aPagingCmt=$aPagingCmt}
{include file='footer.tpl'}

View file

@ -6,6 +6,10 @@
}
<div class="comments" id="comments">
{if $bAllowSubscribe and $oUserCurrent}
<input {if $oSubscribeComment and $oSubscribeComment->getStatus()}checked="checked"{/if} type="checkbox" id="comment_subscribe" onchange="ls.subscribe.toggle('{$sTargetType}_new_comment','{$iTargetId}','',this.checked);"> &mdash; <label for="comment_subscribe">{$aLang.comment_subscribe}</label>
{/if}
<header class="comments-header">
<h3>{$iCountComment} {$iCountComment|declension:$aLang.comment_declension:'russian'}</h3>
<a name="comments"></a>

View file

@ -1,6 +1,12 @@
The user <a href="{$oUserComment->getUserWebPath()}">{$oUserComment->getLogin()}</a> left a new comment to your topic <b>«{$oTopic->getTitle()|escape:'html'}»</b>, you can read it by clicking on <a href="{if $oConfig->GetValue('module.comment.nested_per_page')}{router page='comments'}{else}{$oTopic->getUrl()}#comment{/if}{$oComment->getId()}">this link</a><br>
The user <a href="{$oUserComment->getUserWebPath()}">{$oUserComment->getLogin()}</a> left a new comment to topic <b>«{$oTopic->getTitle()|escape:'html'}»</b>, you can read it by clicking on <a href="{if $oConfig->GetValue('module.comment.nested_per_page')}{router page='comments'}{else}{$oTopic->getUrl()}#comment{/if}{$oComment->getId()}">this link</a><br>
{if $oConfig->GetValue('sys.mail.include_comment')}
Message: <i>{$oComment->getText()}</i>
{/if}
{/if}
{if $sSubscribeKey}
<br><br>
<a href="{router page='subscribe'}unsubscribe/{$sSubscribeKey}/">Unsubscribe from new comments to this topic</a>
{/if}
<br><br>
Best regards, site administration <a href="{cfg name='path.root.web'}">{cfg name='view.name'}</a>

View file

@ -1,6 +1,12 @@
Пользователь <a href="{$oUserComment->getUserWebPath()}">{$oUserComment->getLogin()}</a> оставил новый комментарий к вашему топику <b>«{$oTopic->getTitle()|escape:'html'}»</b>, прочитать его можно перейдя по <a href="{if $oConfig->GetValue('module.comment.nested_per_page')}{router page='comments'}{else}{$oTopic->getUrl()}#comment{/if}{$oComment->getId()}">этой ссылке</a><br>
Пользователь <a href="{$oUserComment->getUserWebPath()}">{$oUserComment->getLogin()}</a> оставил новый комментарий к топику <b>«{$oTopic->getTitle()|escape:'html'}»</b>, прочитать его можно перейдя по <a href="{if $oConfig->GetValue('module.comment.nested_per_page')}{router page='comments'}{else}{$oTopic->getUrl()}#comment{/if}{$oComment->getId()}">этой ссылке</a><br>
{if $oConfig->GetValue('sys.mail.include_comment')}
Текст сообщения: <i>{$oComment->getText()}</i>
{/if}
{/if}
{if $sSubscribeKey}
<br><br>
<a href="{router page='subscribe'}unsubscribe/{$sSubscribeKey}/">Отписаться от новых комментариев к этому топику</a>
{/if}
<br><br>
С уважением, администрация сайта <a href="{cfg name='path.root.web'}">{cfg name='view.name'}</a>