mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-26 03:30:48 +03:00
fix RSS комментариев
This commit is contained in:
parent
c502444e2a
commit
50df823c8d
|
@ -186,8 +186,8 @@ class ActionRss extends Action {
|
|||
/**
|
||||
* Получаем комментарии
|
||||
*/
|
||||
$aComments=$this->Comment_GetCommentsByTargetId($oTopic->getId(),'topic');
|
||||
$aComments=$aComments['comments'];
|
||||
$aResult=$this->Comment_GetCommentsByFilter(array('target_id'=>$oTopic->getId(),'target_type'=>'topic','delete'=>0),array('comment_id'=>'desc'),1,100);
|
||||
$aComments=$aResult['collection'];
|
||||
/**
|
||||
* Формируем данные канала RSS
|
||||
*/
|
||||
|
|
|
@ -934,5 +934,22 @@ class ModuleComment extends Module {
|
|||
public function RecalculateFavourite() {
|
||||
return $this->oMapper->RecalculateFavourite();
|
||||
}
|
||||
/**
|
||||
* Получает список комментариев по фильтру
|
||||
*
|
||||
* @param array $aFilter Фильтр выборки
|
||||
* @param array $aOrder Сортировка
|
||||
* @param int $iCurrPage Номер текущей страницы
|
||||
* @param int $iPerPage Количество элементов на одну страницу
|
||||
* @param array $aAllowData Список типов данных, которые нужно подтянуть к списку комментов
|
||||
* @return array
|
||||
*/
|
||||
public function GetCommentsByFilter($aFilter,$aOrder,$iCurrPage,$iPerPage,$aAllowData=null) {
|
||||
if (is_null($aAllowData)) {
|
||||
$aAllowData=array('target','user'=>array());
|
||||
}
|
||||
$aCollection=$this->oMapper->GetCommentsByFilter($aFilter,$aOrder,$iCount,$iCurrPage,$iPerPage);
|
||||
return array('collection'=>$this->GetCommentsAdditionalData($aCollection,$aAllowData),'count'=>$iCount);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -880,5 +880,68 @@ class ModuleComment_MapperComment extends Mapper {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получает список комментариев по фильтру
|
||||
*
|
||||
* @param array $aFilter Фильтр выборки
|
||||
* @param array $aOrder Сортировка
|
||||
* @param int $iCount Возвращает общее количество элментов
|
||||
* @param int $iCurrPage Номер текущей страницы
|
||||
* @param int $iPerPage Количество элементов на одну страницу
|
||||
* @return array
|
||||
*/
|
||||
public function GetCommentsByFilter($aFilter,$aOrder,&$iCount,$iCurrPage,$iPerPage) {
|
||||
$aOrderAllow=array('comment_id','comment_pid','comment_rating','comment_date');
|
||||
$sOrder='';
|
||||
foreach ($aOrder as $key=>$value) {
|
||||
if (!in_array($key,$aOrderAllow)) {
|
||||
unset($aOrder[$key]);
|
||||
} elseif (in_array($value,array('asc','desc'))) {
|
||||
$sOrder.=" {$key} {$value},";
|
||||
}
|
||||
}
|
||||
$sOrder=trim($sOrder,',');
|
||||
if ($sOrder=='') {
|
||||
$sOrder=' comment_id desc ';
|
||||
}
|
||||
|
||||
if (isset($aFilter['target_type']) and !is_array($aFilter['target_type'])) {
|
||||
$aFilter['target_type']=array($aFilter['target_type']);
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
comment_id
|
||||
FROM
|
||||
".Config::Get('db.table.comment')."
|
||||
WHERE
|
||||
1 = 1
|
||||
{ AND comment_id = ?d }
|
||||
{ AND user_id = ?d }
|
||||
{ AND target_parent_id = ?d }
|
||||
{ AND target_id = ?d }
|
||||
{ AND target_type IN (?a) }
|
||||
{ AND comment_delete = ?d }
|
||||
{ AND comment_publish = ?d }
|
||||
ORDER by {$sOrder}
|
||||
LIMIT ?d, ?d ;
|
||||
";
|
||||
$aResult=array();
|
||||
if ($aRows=$this->oDb->selectPage($iCount,$sql,
|
||||
isset($aFilter['id']) ? $aFilter['id'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['user_id']) ? $aFilter['user_id'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['target_parent_id']) ? $aFilter['target_parent_id'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['target_id']) ? $aFilter['target_id'] : DBSIMPLE_SKIP,
|
||||
(isset($aFilter['target_type']) and count($aFilter['target_type']) ) ? $aFilter['target_type'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['delete']) ? $aFilter['delete'] : DBSIMPLE_SKIP,
|
||||
isset($aFilter['publish']) ? $aFilter['publish'] : DBSIMPLE_SKIP,
|
||||
($iCurrPage-1)*$iPerPage, $iPerPage
|
||||
)) {
|
||||
foreach ($aRows as $aRow) {
|
||||
$aResult[]=$aRow['comment_id'];
|
||||
}
|
||||
}
|
||||
return $aResult;
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in a new issue