1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-05-17 08:18:18 +03:00

добавлен хак на очистку старого кеша + подправлена работа избранного, теперь в нём видно полный текст топика, но пока некорректно работает со скрытыми топиками

This commit is contained in:
Mzhelskiy Maxim 2008-10-26 20:04:05 +00:00
parent 604f238574
commit 60c7ff3937
2 changed files with 71 additions and 3 deletions

View file

@ -85,6 +85,13 @@ class Cache extends Module {
throw new Exception("Неверный тип кеширования: ".$this->sCacheType." Доступны: file, memory");
}
$this->oBackendCache = new Dklab_Cache_Backend_TagEmuWrapper(new Dklab_Cache_Backend_Profiler($oCahe,array($this,'CalcStats')));
/**
* Дабы не засорять место протухшим кешем, удаляем его в случайном порядке, например 1 из 50 раз
*/
if (rand(1,50)==33) {
$this->Clean(Zend_Cache::CLEANING_MODE_OLD);
}
}

View file

@ -807,16 +807,77 @@ class Mapper_Topic extends Mapper {
ORDER BY t.topic_date_add desc
LIMIT ?d, ?d ;
";
$aTopics=array();
if ($aRows=$this->oDb->selectPage($iCount,$sql,$iCurrentUserId,$sUserId,($iCurrPage-1)*$iPerPage, $iPerPage)) {
$sql = " SELECT
t.*,
tc.*,
u.user_login as user_login,
b.blog_title as blog_title,
b.blog_type as blog_type,
b.blog_url as blog_url,
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
FROM (
SELECT
topic_id
FROM
".DB_TABLE_FAVOURITE_TOPIC."
WHERE
user_id = ?
ORDER BY topic_id DESC
LIMIT ?d, ?d
) as tt
JOIN ".DB_TABLE_TOPIC." AS t ON tt.topic_id=t.topic_id
JOIN ".DB_TABLE_USER." AS u ON t.user_id=u.user_id
JOIN ".DB_TABLE_BLOG." AS b ON t.blog_id=b.blog_id
LEFT JOIN (
SELECT
topic_id,
vote_delta
FROM ".DB_TABLE_TOPIC_VOTE."
WHERE user_voter_id = ?d
) AS tv ON tt.topic_id=tv.topic_id
LEFT JOIN (
SELECT
topic_id
FROM ".DB_TABLE_TOPIC_QUESTION_VOTE."
WHERE user_voter_id = ?d
) AS tqv ON tt.topic_id=tqv.topic_id
LEFT JOIN ".DB_TABLE_TOPIC_CONTENT." AS tc ON tt.topic_id=tc.topic_id
;
";
$aTopics=array();
if ($aRows=$this->oDb->select($sql,$sUserId,($iCurrPage-1)*$iPerPage, $iPerPage,$iCurrentUserId,$iCurrentUserId)) {
foreach ($aRows as $aTopic) {
$aTopics[]=new TopicEntity_Topic($aTopic);
}
$iCount=$this->GetCountTopicsFavouriteByUserId($sUserId);
}
return $aTopics;
}
public function GetCountTopicsFavouriteByUserId($sUserId) {
public function GetCountTopicsFavouriteByUserId($sUserId) {
$sql = "SELECT
count(topic_id) as count
FROM
".DB_TABLE_FAVOURITE_TOPIC."
WHERE
user_id = ?;
";
if ($aRow=$this->oDb->selectRow($sql,$sUserId)) {
return $aRow['count'];
}
return false;
}
public function GetCountTopicsFavouriteByUserId_($sUserId) {
$sql = "SELECT
count(t.topic_id) as count
FROM