From be22a58b56707447333df35b8ae592198bf1f6cb Mon Sep 17 00:00:00 2001 From: Mzhelskiy Maxim Date: Sat, 18 Oct 2008 12:32:24 +0000 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81=20=D1=83=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B1=D0=BB=D0=BE?= =?UTF-8?q?=D0=B3=D0=B0=D0=BC=D0=B8=20=D0=B8=20=D1=82=D0=BE=D0=BF=D0=B8?= =?UTF-8?q?=D0=BA=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/actions/ActionTopic.class.php | 4 +- .../topic/entity/Topic.entity.class.php | 3 + .../topic/mapper/Topic.mapper.class.php | 4 +- convert.php | 56 ++++++++++++++++++- templates/skin/habra/header.tpl | 1 + templates/skin/habra/topic.tpl | 2 +- templates/skin/habra/topic_list.tpl | 2 +- 7 files changed, 66 insertions(+), 6 deletions(-) diff --git a/classes/actions/ActionTopic.class.php b/classes/actions/ActionTopic.class.php index e6d83e0d..49029c71 100644 --- a/classes/actions/ActionTopic.class.php +++ b/classes/actions/ActionTopic.class.php @@ -98,7 +98,7 @@ class ActionTopic extends Action { $bIsAdministratorBlog=$oBlogUser ? $oBlogUser->getIsAdministrator() : false; $bIsModeratorBlog=$oBlogUser ? $oBlogUser->getIsModerator() : false; - if ($oTopic->getUserId()!=$this->oUserCurrent->getId() and !$this->oUserCurrent->isAdministrator() and !$bIsAdministratorBlog and !$bIsModeratorBlog) { + if ($oTopic->getUserId()!=$this->oUserCurrent->getId() and !$this->oUserCurrent->isAdministrator() and !$bIsAdministratorBlog and !$bIsModeratorBlog and $oTopic->getBlogOwnerId()!=$this->oUserCurrent->getId()) { return parent::EventNotFound(); } /** @@ -428,7 +428,7 @@ class ActionTopic extends Action { $bIsAdministratorBlog=$oBlogUser ? $oBlogUser->getIsAdministrator() : false; $bIsModeratorBlog=$oBlogUser ? $oBlogUser->getIsModerator() : false; - if (!$this->Blog_GetRelationBlogUserByBlogIdAndUserId($oBlog->getId(),$this->oUserCurrent->getId()) and !$this->oUserCurrent->isAdministrator() and !$bIsAdministratorBlog and !$bIsModeratorBlog) { + if (!$this->Blog_GetRelationBlogUserByBlogIdAndUserId($oBlog->getId(),$this->oUserCurrent->getId()) and !$this->oUserCurrent->isAdministrator() and !$bIsAdministratorBlog and !$bIsModeratorBlog and $oTopic->getBlogOwnerId()!=$this->oUserCurrent->getId()) { if ($oBlog->getOwnerId()!=$this->oUserCurrent->getId()) { $this->Message_AddErrorSingle('Вы не состоите в этом блоге!','Ошибка'); return false; diff --git a/classes/modules/topic/entity/Topic.entity.class.php b/classes/modules/topic/entity/Topic.entity.class.php index 70a36fa9..3fa605d3 100644 --- a/classes/modules/topic/entity/Topic.entity.class.php +++ b/classes/modules/topic/entity/Topic.entity.class.php @@ -135,6 +135,9 @@ class TopicEntity_Topic extends Entity public function getUserIsBlogModerator() { return $this->_aData['user_is_blog_moderator']; } + public function getBlogOwnerId() { + return $this->_aData['blog_owner_id']; + } /*************************************************************************************************************************************************** * методы расширения типов топика diff --git a/classes/modules/topic/mapper/Topic.mapper.class.php b/classes/modules/topic/mapper/Topic.mapper.class.php index 843a1c53..ae803a56 100644 --- a/classes/modules/topic/mapper/Topic.mapper.class.php +++ b/classes/modules/topic/mapper/Topic.mapper.class.php @@ -168,6 +168,7 @@ class Mapper_Topic extends Mapper { b.blog_type as blog_type, b.blog_url as blog_url, b.blog_title as blog_title, + b.user_owner_id as blog_owner_id, IF(tv.topic_id IS NULL,0,1) as user_is_vote, tv.vote_delta as user_vote_delta, IF(tqv.topic_id IS NULL,0,1) as user_question_is_vote, @@ -285,7 +286,8 @@ class Mapper_Topic extends Mapper { t.*, b.blog_title as blog_title, b.blog_type as blog_type, - b.blog_url as blog_url + b.blog_url as blog_url, + b.user_owner_id as blog_owner_id FROM ".DB_TABLE_TOPIC." as t, ".DB_TABLE_BLOG." as b diff --git a/convert.php b/convert.php index 2fe8fe73..93d34353 100644 --- a/convert.php +++ b/convert.php @@ -21,7 +21,7 @@ mysql_query("set collation_connection='utf8_bin'",$link); /** * Конвертирует топики из старой структуры в новую */ - +/* $sql = "SELECT * FROM @@ -37,4 +37,58 @@ while ($row=mysql_fetch_assoc($res)) { "; mysql_query($sql2,$link); } +*/ + +/** + * Конвертируем комментариии в новую структуру + * Если комментариев много, то может занять много времени + */ +$sql = "SELECT res.* FROM ( + + SELECT + c.*, + t.topic_title as topic_title, + t.topic_count_comment as topic_count_comment, + u.user_profile_avatar as user_profile_avatar, + u.user_profile_avatar_type as user_profile_avatar_type, + u.user_login as user_login, + b.blog_title as blog_title, + b.blog_type as blog_type, + b.blog_url as blog_url, + u_owner.user_login as blog_owner_login + FROM + ".DB_TABLE_TOPIC_COMMENT." as c, + ".DB_TABLE_TOPIC." as t, + ".DB_TABLE_USER." as u, + ".DB_TABLE_BLOG." as b, + ".DB_TABLE_USER." as u_owner + WHERE + c.comment_id=(SELECT comment_id FROM ".DB_TABLE_TOPIC_COMMENT." WHERE topic_id=t.topic_id AND t.topic_publish=1 ORDER BY comment_date DESC LIMIT 0,1) + AND + c.comment_delete = 0 + AND + c.topic_id=t.topic_id + AND + t.topic_publish = 1 + AND + c.user_id=u.user_id + AND + t.blog_id=b.blog_id + AND + b.user_owner_id=u_owner.user_id + ORDER by c.comment_date desc limit 0, 50 + + ) as res + ORDER BY comment_date asc + "; +$res=mysql_query($sql,$link); +while ($row=mysql_fetch_assoc($res)) { + //var_dump($row); + $sql2 = "INSERT INTO ".DB_TABLE_TOPIC_COMMENT_ONLINE." + (topic_id,comment_id) + values(".$row['topic_id'].",'".mysql_escape_string($row['comment_id'])."') + + "; + mysql_query($sql2,$link); +} ?> \ No newline at end of file diff --git a/templates/skin/habra/header.tpl b/templates/skin/habra/header.tpl index a6c49eb7..fd590f09 100644 --- a/templates/skin/habra/header.tpl +++ b/templates/skin/habra/header.tpl @@ -123,6 +123,7 @@ var msgNoticeBox=new Roar({ О проекте Скачать SVN + DEMO