diff --git a/classes/actions/ActionBlog.class.php b/classes/actions/ActionBlog.class.php index 0021aadd..3f4ff3a9 100644 --- a/classes/actions/ActionBlog.class.php +++ b/classes/actions/ActionBlog.class.php @@ -159,7 +159,7 @@ class ActionBlog extends Action { /** * Проверяем хватает ли рейтинга юзеру чтоб создать блог */ - if (!$this->ACL_CanCreateBlog($this->User_GetUserCurrent())) { + if (!$this->ACL_CanCreateBlog($this->oUserCurrent) and !$this->oUserCurrent->isAdministrator()) { $this->Message_AddErrorSingle('Вы еще не достаточно окрепли чтобы создавать свой блог','Ошибка'); return Router::Action('error'); } @@ -1092,14 +1092,14 @@ class ActionBlog extends Action { /** * Проверяем разрешено ли постить комменты */ - if (!$this->ACL_CanPostComment($this->oUserCurrent)) { + if (!$this->ACL_CanPostComment($this->oUserCurrent) and !$this->oUserCurrent->isAdministrator()) { $this->Message_AddError('Ваш рейтинг слишком мал для написания комментариев','Ошибка'); return false; } /** * Проверяем разрешено ли постить комменты по времени */ - if (!$this->ACL_CanPostCommentTime($this->oUserCurrent)) { + if (!$this->ACL_CanPostCommentTime($this->oUserCurrent) and !$this->oUserCurrent->isAdministrator()) { $this->Message_AddError('Вам нельзя писать комментарии слишком часто','Ошибка'); return false; } @@ -1173,6 +1173,16 @@ class ActionBlog extends Action { * Добавляем коммент */ if ($this->Comment_AddComment($oCommentNew)) { + if ($oTopic->getPublish()) { + /** + * Добавляем коммент в прямой эфир если топик не в черновиках + */ + $this->Comment_DeleteTopicCommentOnline($oCommentNew->getTopicId()); + $oTopicCommentOnline=new CommentEntity_TopicCommentOnline(); + $oTopicCommentOnline->setTopicId($oCommentNew->getTopicId()); + $oTopicCommentOnline->setCommentId($oCommentNew->getId()); + $this->Comment_AddTopicCommentOnline($oTopicCommentOnline); + } /** * Сохраняем дату последнего коммента для юзера */ diff --git a/classes/modules/comment/Comment.class.php b/classes/modules/comment/Comment.class.php index b8008c6b..5accabc4 100644 --- a/classes/modules/comment/Comment.class.php +++ b/classes/modules/comment/Comment.class.php @@ -160,14 +160,6 @@ class Comment extends Module { public function AddComment(CommentEntity_TopicComment $oComment) { if ($sId=$this->oMapperTopicComment->AddComment($oComment)) { $this->Topic_increaseTopicCountComment($oComment->getTopicId()); - /** - * Добавляем коммент в прямой эфир - */ - $this->oMapperTopicComment->deleteTopicCommentOnline($oComment->getTopicId()); - $oTopicCommentOnline=new CommentEntity_TopicCommentOnline(); - $oTopicCommentOnline->setTopicId($oComment->getTopicId()); - $oTopicCommentOnline->setCommentId($sId); - $this->oMapperTopicComment->AddTopicCommentOnline($oTopicCommentOnline); //чистим зависимые кеши $this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array('comment_new',"comment_new_user_{$oComment->getUserId()}","comment_new_topic_{$oComment->getTopicId()}")); $oComment->setId($sId); @@ -207,8 +199,16 @@ class Comment extends Module { * @param unknown_type $sTopicId * @return unknown */ - public function deleteTopicCommentOnline($sTopicId) { - return $this->oMapperTopicComment->deleteTopicCommentOnline($sTopicId); + public function DeleteTopicCommentOnline($sTopicId) { + return $this->oMapperTopicComment->DeleteTopicCommentOnline($sTopicId); + } + /** + * Добавляет новый коммент в прямой эфир + * + * @param CommentEntity_TopicCommentOnline $oTopicCommentOnline + */ + public function AddTopicCommentOnline(CommentEntity_TopicCommentOnline $oTopicCommentOnline) { + return $this->oMapperTopicComment->AddTopicCommentOnline($oTopicCommentOnline); } /** * Строит дерево комментариев diff --git a/classes/modules/comment/mapper/TopicComment.mapper.class.php b/classes/modules/comment/mapper/TopicComment.mapper.class.php index 32ae3055..008308f2 100644 --- a/classes/modules/comment/mapper/TopicComment.mapper.class.php +++ b/classes/modules/comment/mapper/TopicComment.mapper.class.php @@ -444,7 +444,7 @@ class Mapper_TopicComment extends Mapper { return false; } - public function deleteTopicCommentOnline($sTopicId) { + public function DeleteTopicCommentOnline($sTopicId) { $sql = "DELETE FROM ".DB_TABLE_TOPIC_COMMENT_ONLINE." WHERE topic_id = ?d "; if ($this->oDb->query($sql,$sTopicId)) {