/** * Обновление сообщений в чате */ public function actionUpdateListChat() { if (Yii::app()->request->isAjaxRequest) { $listChat = ''; if (isset($_POST['lastMsgId'])) { // $lastId = (int)Chat::getLastId(); // if ($lastId != (int)$_POST['lastMsgId']) { $result = Chat::getListChat(); $listChat = $this->renderPartial('//chat/_listChat', array('dataProvider' => $result), true); // } } echo CJSON::encode(array('listChat' => $listChat)); exit; } }
/** * Конструктор * @return bool */ protected function beforeAction() { $this->layout = 'start_page'; $this->topMenu = Mainmenu::getMenu('top', 'site'); $this->middleMenu = Mainmenu::getMenu('middle', 'site'); $this->listChat = Chat::getListChat(); $this->randomArt = Articles::getRandomArticles(10); $this->tags = Tags::getMenu(Tags::model()->findAll()); $settingChat = Settings::model()->findByAttributes(array('parameter' => Yii::app()->params['parameter']['chat'])); $this->stateChat = null != $settingChat ? (int) $settingChat->value : 0; if (!Yii::app()->user->isGuest) { $this->_user = Users::model()->findByPk(Yii::app()->user->id); } else { $this->_loginModel = new LoginForm(); } return true; }