public function Exec() { /** * Получаем список форумов, открытых для пользователя */ $aForumsId = $this->PluginForum_Forum_GetOpenForumsUser(LS::CurUsr(), true); /** * Получаем последние топики */ if ($aForumsId) { $aLastTopics = $this->PluginForum_Forum_GetTopicItemsAll(array('#where' => array('forum_id IN (?a)' => array($aForumsId)), '#order' => array('last_post_id' => 'desc'), '#page' => array(1, Config::Get('block.stream.row')))); if (!empty($aLastTopics['collection'])) { $this->Viewer_Assign('aLastTopics', $aLastTopics['collection']); } } }
/** * Обработка получения последних топиков * Используется в блоке "Прямой эфир" * */ protected function EventAjaxGetLastTopics() { /** * Устанавливаем формат Ajax ответа */ $this->Viewer_SetResponseAjax('json'); /** * Получаем список форумов */ if (!($aForumsId = $this->PluginForum_Forum_GetOpenForumsUser(LS::CurUsr(), true))) { $this->Message_AddErrorSingle($this->Lang_Get('plugin.forum.block_stream_empty'), $this->Lang_Get('attention')); return; } /** * Получаем последние топики */ $aLastTopics = $this->PluginForum_Forum_GetTopicItemsAll(array('#where' => array('forum_id IN (?a)' => array($aForumsId)), '#order' => array('last_post_date' => 'desc'), '#page' => array(1, Config::Get('block.stream.row')))); if (!empty($aLastTopics['collection'])) { $oViewer = $this->Viewer_GetLocalViewer(); $oViewer->Assign('aLastTopics', $aLastTopics['collection']); $sTextResult = $oViewer->Fetch($this->getTemplatePathPlugin() . 'blocks/block.stream_forum.tpl'); $this->Viewer_AssignAjax('sText', $sTextResult); return; } else { $this->Message_AddErrorSingle($this->Lang_Get('plugin.forum.block_stream_empty'), $this->Lang_Get('attention')); return; } }
/** * Вывод RSS последних записей с форума */ protected function RssForumStream() { /** * Получаем список форумов */ $aForumsId = $this->PluginForum_Forum_GetOpenForumsUser(LS::CurUsr(), true); /** * Получаем последние топики */ $aResult = $this->PluginForum_Forum_GetTopicItemsAll(array('#where' => array('forum_id IN (?a)' => array($aForumsId)), '#order' => array('last_post_id' => 'desc'), '#page' => array(1, 30))); $aTopics = $aResult['collection']; /** * Формируем данные канала RSS */ $aChannel['title'] = Config::Get('view.name'); $aChannel['link'] = Config::Get('path.root.web'); $aChannel['description'] = Config::Get('path.root.web') . ' / RSS channel'; $aChannel['language'] = 'ru'; $aChannel['managingEditor'] = Config::Get('general.rss_editor_mail'); $aChannel['generator'] = Config::Get('path.root.web'); /** * Формируем записи RSS */ $aItems = array(); foreach ($aTopics as $oTopic) { /** * Relation data */ $oPost = $oTopic->getPost(); $oUser = $oPost->getUser(); /** * Build record */ $aItem = array('title' => 'Latest topics: ' . $oTopic->getTitle(), 'guid' => $oTopic->getUrlFull() . '#post-' . $oPost->getId(), 'link' => $oTopic->getUrlFull() . '#post-' . $oPost->getId(), 'description' => $this->getPostText($oPost), 'pubDate' => $oPost->getDateAdd(), 'category' => 'topics'); if ($oUser) { $aItem['author'] = $oUser->getLogin(); } else { $aItem['author'] = $this->Lang_Get('plugin.forum.guest_prefix') . $oPost->getGuestName(); } $aItems[] = $aItem; } /** * Формируем ответ */ $this->InitRss(); $this->Viewer_Assign('aChannel', $aChannel); $this->Viewer_Assign('aItems', $aItems); $this->SetTemplateAction('index'); }