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

fix move topics

This commit is contained in:
Mzhelskiy Maxim 2010-04-17 17:55:22 +00:00
parent 82228ebe91
commit 4c085d085f
4 changed files with 123 additions and 4 deletions

View file

@ -378,7 +378,7 @@ class LsComment extends Module {
public function UpdateComment(CommentEntity_Comment $oComment) {
if ($this->oMapper->UpdateComment($oComment)) {
//чистим зависимые кеши
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array("comment_update","comment_update_{$oComment->getTargetType()}","comment_update_{$oComment->getTargetType()}_{$oComment->getTargetId()}"));
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array("comment_update","comment_update_{$oComment->getTargetType()}_{$oComment->getTargetId()}"));
$this->Cache_Delete("comment_{$oComment->getId()}");
return true;
}
@ -728,7 +728,7 @@ class LsComment extends Module {
public function UpdateTargetParentByTargetId($sParentId, $sTargetType, $aTargetId) {
if(!is_array($aTargetId)) $aTargetId = array($aTargetId);
// чистим зависимые кеши
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array("comment_update_{$sTargetType}"));
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array("comment_new_{$sTargetType}"));
return $this->oMapper->UpdateTargetParentByTargetId($sParentId, $sTargetType, $aTargetId);
}
@ -749,5 +749,31 @@ class LsComment extends Module {
return $this->oMapper->UpdateTargetParentByTargetIdOnline($sParentId, $sTargetType, $aTargetId);
}
/**
* Меняет target parent на новый
*
* @param string $sParentId
* @param string $sTargetType
* @param string $sParentIdNew
* @return bool
*/
public function MoveTargetParent($sParentId, $sTargetType, $sParentIdNew) {
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array("comment_new_{$sTargetType}"));
return $this->oMapper->MoveTargetParent($sParentId, $sTargetType, $sParentIdNew);
}
/**
* Меняет target parent на новый в прямом эфире
*
* @param string $sParentId
* @param string $sTargetType
* @param string $sParentIdNew
* @return bool
*/
public function MoveTargetParentOnline($sParentId, $sTargetType, $sParentIdNew) {
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array("comment_online_update_{$sTargetType}"));
return $this->oMapper->MoveTargetParentOnline($sParentId, $sTargetType, $sParentIdNew);
}
}
?>

View file

@ -387,5 +387,37 @@ class Mapper_Comment extends Mapper {
}
return false;
}
public function MoveTargetParent($sParentId, $sTargetType, $sParentIdNew) {
$sql = "
UPDATE ".Config::Get('db.table.comment')."
SET
target_parent_id = ?d
WHERE
target_parent_id = ?d
AND
target_type = ?
";
if ($this->oDb->query($sql,$sParentIdNew,$sParentId,$sTargetType)) {
return true;
}
return false;
}
public function MoveTargetParentOnline($sParentId, $sTargetType, $sParentIdNew) {
$sql = "
UPDATE ".Config::Get('db.table.comment_online')."
SET
target_parent_id = ?d
WHERE
target_parent_id = ?d
AND
target_type = ?
";
if ($this->oDb->query($sql,$sParentIdNew,$sParentId,$sTargetType)) {
return true;
}
return false;
}
}
?>

View file

@ -1281,7 +1281,16 @@ class LsTopic extends Module {
*/
public function MoveTopicsByArrayId($aTopics,$sBlogId) {
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array("topic_update", "topic_new_blog_{$sBlogId}"));
return $this->oMapperTopic->MoveTopicsByArrayId($aTopics,$sBlogId);
if ($res=$this->oMapperTopic->MoveTopicsByArrayId($aTopics,$sBlogId)) {
// перемещаем теги
$this->oMapperTopic->MoveTopicsTagsByArrayId($aTopics,$sBlogId);
// меняем target parent у комментов
$this->Comment_UpdateTargetParentByTargetId($sBlogId, 'topic', $aTopics);
// меняем target parent у комментов в прямом эфире
$this->Comment_UpdateTargetParentByTargetIdOnline($sBlogId, 'topic', $aTopics);
return $res;
}
return false;
}
/**
@ -1293,7 +1302,16 @@ class LsTopic extends Module {
*/
public function MoveTopics($sBlogId,$sBlogIdNew) {
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,array("topic_update", "topic_new_blog_{$sBlogId}", "topic_new_blog_{$sBlogIdNew}"));
return $this->oMapperTopic->MoveTopics($sBlogId,$sBlogIdNew);
if ($res=$this->oMapperTopic->MoveTopics($sBlogId,$sBlogIdNew)) {
// перемещаем теги
$this->oMapperTopic->MoveTopicsTags($sBlogId,$sBlogIdNew);
// меняем target parent у комментов
$this->Comment_MoveTargetParent($sBlogId, 'topic', $sBlogIdNew);
// меняем target parent у комментов в прямом эфире
$this->Comment_MoveTargetParentOnline($sBlogId, 'topic', $sBlogIdNew);
return $res;
}
return false;
}
/**

View file

@ -621,5 +621,48 @@ class Mapper_Topic extends Mapper {
}
return false;
}
/**
* Перемещает теги топиков в другой блог
*
* @param string $sBlogId
* @param string $sBlogIdNew
* @return bool
*/
public function MoveTopicsTags($sBlogId,$sBlogIdNew) {
$sql = "UPDATE ".Config::Get('db.table.topic_tag')."
SET
blog_id= ?d
WHERE
blog_id = ?d
";
if ($this->oDb->query($sql,$sBlogIdNew,$sBlogId)) {
return true;
}
return false;
}
/**
* Перемещает теги топиков в другой блог
*
* @param array $aTopics
* @param string $sBlogId
* @return bool
*/
public function MoveTopicsTagsByArrayId($aTopics,$sBlogId) {
if(!is_array($aTopics)) $aTopics = array($aTopics);
$sql = "UPDATE ".Config::Get('db.table.topic_tag')."
SET
blog_id= ?d
WHERE
topic_id IN(?a)
";
if ($this->oDb->query($sql,$sBlogId,$aTopics)) {
return true;
}
return false;
}
}
?>