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:
Alexey Kachayev 2009-09-20 18:43:20 +00:00
parent d454247295
commit e089d38661
8 changed files with 92 additions and 51 deletions

View file

@ -570,7 +570,7 @@ class ActionBlog extends Action {
and (!$this->oUserCurrent
|| !in_array(
$oTopic->getBlog()->getId(),
array_keys((array)$this->Blog_GetOpenBlogsByUser($this->oUserCurrent))
array_keys($this->Blog_GetAccessibleBlogsByUser($this->oUserCurrent))
)
)
) {
@ -661,7 +661,7 @@ class ActionBlog extends Action {
and (!$this->oUserCurrent
|| !in_array(
$oBlog->getId(),
array_keys((array)$this->Blog_GetOpenBlogsByUser($this->oUserCurrent))
array_keys($this->Blog_GetAccessibleBlogsByUser($this->oUserCurrent))
)
)
) {

View file

@ -20,19 +20,11 @@
*
*/
class BlockTags extends Block {
public function Exec() {
/**
* Получаем список закрытых статей
*/
$oUserCurrent = $this->oEngine->User_GetUserCurrent();
$aCloseTopics = ($oUserCurrent)
? $this->oEngine->Topic_GetTopicsCloseByUser($oUserCurrent->getId())
: $this->oEngine->Topic_GetTopicsCloseByUser();
public function Exec() {
/**
* Получаем список тегов
*/
$aTags=$this->oEngine->Topic_GetTopicTags(70,$aCloseTopics);
$aTags=$this->oEngine->Topic_GetOpenTopicTags(70);
/**
* Расчитываем логарифмическое облако тегов
*/

View file

@ -629,7 +629,7 @@ class LsBlog extends Module {
* @param UserEntity_User $oUser
* @return array
*/
public function GetOpenBlogsByUser($oUser) {
public function GetAccessibleBlogsByUser($oUser) {
if ($oUser->isAdministrator()) {
return $this->GetBlogs();
}
@ -637,6 +637,7 @@ class LsBlog extends Module {
/**
* Заносим блоги, созданные пользователем
*/
$aOpenBlogsUser=array();
$aOpenBlogsUser=$this->GetBlogsByOwnerId($oUser->getId());
/**
@ -660,10 +661,11 @@ class LsBlog extends Module {
* @param UserEntity_User $oUser
* @return array
*/
public function GetCloseBlogsByUser($oUser=null) {
public function GetInaccessibleBlogsByUser($oUser=null) {
if ($oUser&&$oUser->isAdministrator()) {
return array();
}
$aCloseBlogs=array();
$aCloseBlogs = $this->oMapperBlog->GetCloseBlogs();
if(!$oUser) {

View file

@ -243,8 +243,8 @@ class LsComment extends Module {
* которые нужно исключить из выдачи
*/
$aCloseTopics = ($this->oUserCurrent)
? (array)$this->Topic_GetTopicsCloseByUser($this->oUserCurrent->getId())
: (array)$this->Topic_GetTopicsCloseByUser();
? $this->Topic_GetTopicsCloseByUser($this->oUserCurrent->getId())
: $this->Topic_GetTopicsCloseByUser();
$s=serialize($aCloseTopics);
@ -272,11 +272,12 @@ class LsComment extends Module {
*/
$aCloseTopics = ($this->oUserCurrent && $sId==$this->oUserCurrent->getId())
? array()
: (array)$this->Topic_GetTopicsCloseByUser();
if (false === ($data = $this->Cache_Get("comment_user_{$sId}_{$sTargetType}_{$iPage}_{$iPerPage}"))) {
$data = array('collection'=>$this->oMapper->GetCommentsByUserId($sId,$sTargetType,$aCloseTopics,$iCount,$iPage,$iPerPage),'count'=>$iCount);
$this->Cache_Set($data, "comment_user_{$sId}_{$sTargetType}_{$iPage}_{$iPerPage}", array("comment_new_user_{$sId}_{$sTargetType}","comment_update_status_{$sTargetType}"), 60*60*24*2);
: $this->Topic_GetTopicsCloseByUser();
$s=serialize($aCloseTopics);
if (false === ($data = $this->Cache_Get("comment_user_{$sId}_{$sTargetType}_{$iPage}_{$iPerPage}_{$s}"))) {
$data = array('collection'=>$this->oMapper->GetCommentsByUserId($sId,$sTargetType,$iCount,$iPage,$iPerPage,$aCloseTopics),'count'=>$iCount);
$this->Cache_Set($data, "comment_user_{$sId}_{$sTargetType}_{$iPage}_{$iPerPage}_{$s}", array("comment_new_user_{$sId}_{$sTargetType}","comment_update_status_{$sTargetType}"), 60*60*24*2);
}
$data['collection']=$this->GetCommentsAdditionalData($data['collection']);
return $data;
@ -290,9 +291,10 @@ class LsComment extends Module {
*/
$aCloseTopics = ($this->oUserCurrent && $sId==$this->oUserCurrent->getId())
? array()
: (array)$this->Topic_GetTopicsCloseByUser();
if (false === ($data = $this->Cache_Get("comment_count_user_{$sId}_{$sTargetType}"))) {
: $this->Topic_GetTopicsCloseByUser();
$s=serialize($aCloseTopics);
if (false === ($data = $this->Cache_Get("comment_count_user_{$sId}_{$sTargetType}_{$s}"))) {
$data = $this->oMapper->GetCountCommentsByUserId($sId,$sTargetType,$aCloseTopics);
$this->Cache_Set($data, "comment_count_user_{$sId}_{$sTargetType}", array("comment_new_user_{$sId}_{$sTargetType}","comment_update_status_{$sTargetType}"), 60*60*24*2);
}

View file

@ -178,7 +178,7 @@ class Mapper_Comment extends Mapper {
return $aComments;
}
public function GetCommentsByUserId($sId,$sTargetType,$aExcludeTarget,&$iCount,$iCurrPage,$iPerPage) {
public function GetCommentsByUserId($sId,$sTargetType,&$iCount,$iCurrPage,$iPerPage,$aExcludeTarget=array()) {
$sql = "SELECT
comment_id
FROM
@ -209,7 +209,7 @@ class Mapper_Comment extends Mapper {
return $aComments;
}
public function GetCountCommentsByUserId($sId,$sTargetType,$aExcludeTarget) {
public function GetCountCommentsByUserId($sId,$sTargetType,$aExcludeTarget=array()) {
$sql = "SELECT
count(comment_id) as count
FROM

View file

@ -61,7 +61,7 @@ class Mapper_Notify extends Mapper {
INSERT INTO ".Config::Get('db.table.notify_task')."
( user_login, user_mail, notify_subject, notify_text, date_created, notify_task_status )
VALUES
".implode(', ', (array)$aValues);
".implode(', ', $aValues);
return $this->oDb->query($sql);
}

View file

@ -427,8 +427,8 @@ class LsTopic extends Module {
* закрытые блоги в которых он состоит
*/
if($this->oUserCurrent) {
$aOpenBlogs = $this->Blog_GetOpenBlogsByUser($this->oUserCurrent);
$aFilter['blog_type']['close'] = array_keys((array)$aOpenBlogs);
$aOpenBlogs = $this->Blog_GetAccessibleBlogsByUser($this->oUserCurrent);
$aFilter['blog_type']['close'] = array_keys($aOpenBlogs);
}
return $this->GetTopicsByFilter($aFilter,$iPage,$iPerPage);
@ -455,8 +455,8 @@ class LsTopic extends Module {
* закрытые блоги в которых он состоит
*/
if($this->oUserCurrent) {
$aOpenBlogs = $this->Blog_GetOpenBlogsByUser($this->oUserCurrent);
$aFilter['blog_type']['close'] = array_keys((array)$aOpenBlogs);
$aOpenBlogs = $this->Blog_GetAccessibleBlogsByUser($this->oUserCurrent);
$aFilter['blog_type']['close'] = array_keys($aOpenBlogs);
}
return $this->GetTopicsByFilter($aFilter,$iPage,$iPerPage);
}
@ -479,8 +479,8 @@ class LsTopic extends Module {
* закрытые блоги в которых он состоит
*/
if($this->oUserCurrent) {
$aOpenBlogs = $this->Blog_GetOpenBlogsByUser($this->oUserCurrent);
$aFilter['blog_type']['close'] = array_keys((array)$aOpenBlogs);
$aOpenBlogs = $this->Blog_GetAccessibleBlogsByUser($this->oUserCurrent);
$aFilter['blog_type']['close'] = array_keys($aOpenBlogs);
}
$aReturn=$this->GetTopicsByFilter($aFilter,1,$iCount);
if (isset($aReturn['collection'])) {
@ -602,10 +602,10 @@ class LsTopic extends Module {
*/
public function GetTopicsCloseByUser($sUserId=null) {
if(!is_null($sUserId) && $oUser=$this->User_GetUserById($sUserId)) {
$aCloseBlogs=$this->Blog_GetCloseBlogsByUser($oUser);
$aCloseBlogs=$this->Blog_GetInaccessibleBlogsByUser($oUser);
$aFilter=array(
'topic_publish' => 1,
'blog_id' => (array)$aCloseBlogs,
'blog_id' => $aCloseBlogs,
);
} else {
$aFilter=array(
@ -615,7 +615,7 @@ class LsTopic extends Module {
}
$aTopics=$this->GetTopicsByFilter($aFilter);
return array_keys((array)$aTopics['collection']);
return array_keys($aTopics['collection']);
}
/**
@ -657,8 +657,8 @@ class LsTopic extends Module {
* закрытые блоги в которых он состоит
*/
if($this->oUserCurrent) {
$aOpenBlogs = $this->Blog_GetOpenBlogsByUser($this->oUserCurrent);
$aFilter['blog_type']['close'] = array_keys((array)$aOpenBlogs);
$aOpenBlogs = $this->Blog_GetAccessibleBlogsByUser($this->oUserCurrent);
$aFilter['blog_type']['close'] = array_keys($aOpenBlogs);
}
return $this->GetTopicsByFilter($aFilter,$iPage,$iPerPage);
}
@ -681,8 +681,8 @@ class LsTopic extends Module {
* закрытые блоги в которых он состоит
*/
if($this->oUserCurrent) {
$aOpenBlogs = $this->Blog_GetOpenBlogsByUser($this->oUserCurrent);
$aFilter['blog_type']['close'] = array_keys((array)$aOpenBlogs);
$aOpenBlogs = $this->Blog_GetAccessibleBlogsByUser($this->oUserCurrent);
$aFilter['blog_type']['close'] = array_keys($aOpenBlogs);
}
return $this->GetCountTopicsByFilter($aFilter);
}
@ -698,9 +698,8 @@ class LsTopic extends Module {
* Получаем список блогов, топики которых нужно исключить из выдачи
*/
$aCloseBlogs = ($this->oUserCurrent)
? $this->Blog_GetCloseBlogsByUser($this->oUserCurrent)
: $this->Blog_GetCloseBlogsByUser($oUser);
$aCloseBlogs = (array)$aCloseBlogs;
? $this->Blog_GetInaccessibleBlogsByUser($this->oUserCurrent)
: $this->Blog_GetInaccessibleBlogsByUser();
$s=serialize($aCloseBlogs);
@ -752,8 +751,8 @@ class LsTopic extends Module {
* закрытые блоги в которых он состоит
*/
if($this->oUserCurrent) {
$aOpenBlogs = $this->Blog_GetOpenBlogsByUser($this->oUserCurrent);
$aFilter['blog_type']['close'] = array_keys((array)$aOpenBlogs);
$aOpenBlogs = $this->Blog_GetAccessibleBlogsByUser($this->oUserCurrent);
$aFilter['blog_type']['close'] = array_keys($aOpenBlogs);
}
return $this->GetTopicsByFilter($aFilter,$iPage,$iPerPage);
}
@ -781,8 +780,8 @@ class LsTopic extends Module {
* закрытые блоги в которых он состоит
*/
if($this->oUserCurrent) {
$aOpenBlogs = $this->Blog_GetOpenBlogsByUser($this->oUserCurrent);
$aFilter['blog_type']['close'] = array_keys((array)$aOpenBlogs);
$aOpenBlogs = $this->Blog_GetAccessibleBlogsByUser($this->oUserCurrent);
$aFilter['blog_type']['close'] = array_keys($aOpenBlogs);
}
return $this->GetCountTopicsByFilter($aFilter);
@ -814,12 +813,26 @@ class LsTopic extends Module {
* @return unknown
*/
public function GetTopicTags($iLimit,$aExcludeTopic=array()) {
if (false === ($data = $this->Cache_Get("tag_{$iLimit}"))) {
$s=serialize($aExcludeTopic);
if (false === ($data = $this->Cache_Get("tag_{$iLimit}_{$s}"))) {
$data = $this->oMapperTopic->GetTopicTags($iLimit,$aExcludeTopic);
$this->Cache_Set($data, "tag_{$iLimit}", array('topic_update','topic_new'), 60*60*24*3);
$this->Cache_Set($data, "tag_{$iLimit}_{$s}", array('topic_update','topic_new'), 60*60*24*3);
}
return $data;
return $data;
}
/**
* Получает список тегов из топиков открытых блогов (open,personal)
*
* @param int $iLimit
* @return array
*/
public function GetOpenTopicTags($iLimit) {
if (false === ($data = $this->Cache_Get("tag_{$iLimit}_open"))) {
$data = $this->oMapperTopic->GetOpenTopicTags($iLimit);
$this->Cache_Set($data, "tag_{$iLimit}_open", array('topic_update','topic_new'), 60*60*24*3);
}
return $data;
}
/**
* Увеличивает у топика число комментов

View file

@ -297,7 +297,39 @@ class Mapper_Topic extends Mapper {
}
return $aReturnSort;
}
public function GetOpenTopicTags($iLimit) {
$sql = "
SELECT
tt.topic_tag_text,
count(tt.topic_tag_text) as count
FROM
".Config::Get('db.table.topic_tag')." as tt,
".Config::Get('db.table.blog')." as b
WHERE
tt.blog_id = b.blog_id
AND
b.blog_type IN ('open','personal')
GROUP BY
tt.topic_tag_text
ORDER BY
count desc
LIMIT 0, ?d
";
$aReturn=array();
$aReturnSort=array();
if ($aRows=$this->oDb->select($sql,$iLimit)) {
foreach ($aRows as $aRow) {
$aReturn[mb_strtolower($aRow['topic_tag_text'],'UTF-8')]=$aRow;
}
ksort($aReturn);
foreach ($aReturn as $aRow) {
$aReturnSort[]=Engine::GetEntity('Topic_TopicTag',$aRow);
}
}
return $aReturnSort;
}
public function increaseTopicCountComment($sTopicId) {
$sql = "UPDATE ".Config::Get('db.table.topic')."