/** * Возвращает модель по указанному идентификатору * Если модель не будет найдена - возникнет HTTP-исключение. * * @param integer идентификатор нужной модели * @return ForumMessage $model * @throws CHttpException */ public function loadModel($id) { $model = ForumMessage::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, Yii::t('ForumModule.forum', 'Page was not found!')); } return $model; }
public function getTopics($limit = -1) { $criteria = new CDbCriteria(); $criteria->select = "`t`.*"; $criteria->compare('forum_id', $this->id); $criteria->join = 'LEFT JOIN ' . ForumMessage::model()->tableName() . ' AS `fm` ON `fm`.topic_id=`t`.id'; $criteria->order = '`fm`.topic_id DESC'; $criteria->group = '`t`.id'; $criteria->limit = $limit; return new CActiveDataProvider('ForumTopic', array('criteria' => $criteria)); //return ForumTopic::model()->findAll($criteria); }
public function getLastMessage() { return ForumMessage::model()->findByAttributes(array('topic_id' => $this->id), array('order' => 'id DESC', 'limit' => '1')); }
<?php $this->breadcrumbs = [Yii::t('ForumModule.forum', 'Forums') => ['/forum/forumBackend/index'], Yii::t('ForumModule.forum', 'Topics') => ['/forum/messageBackend/index'], Yii::t('ForumModule.forum', 'Manage')]; $this->pageTitle = Yii::t('ForumModule.forum', 'Messages - manage'); $this->menu = Yii::app()->getModule('forum')->getNavigation(); ?> <div class="page-header"> <h1> <?php echo Yii::t('ForumModule.forum', 'Messages'); ?> <small><?php echo Yii::t('ForumModule.forum', 'manage'); ?> </small> </h1> </div> <p><?php echo Yii::t('ForumModule.forum', 'This section describes forum management'); ?> </p> <?php $this->widget('yupe\\widgets\\CustomGridView', ['id' => 'forum-message-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => [['name' => 'id', 'htmlOptions' => ['style' => 'width:20px'], 'type' => 'raw', 'value' => 'CHtml::link($data->id, ["/forum/forumBackend/update", "id" => $data->id])', 'filter' => CHtml::activeTextField($model, 'id', ['class' => 'form-control', 'style' => 'width:20px'])], ['name' => 'topic_id', 'value' => '$data->getTopicTitle()', 'filter' => CHtml::activeDropDownList($model, 'topic_id', ForumTopic::model()->getFormattedList(), ['empty' => '', 'class' => 'form-control'])], ['name' => 'user_id', 'value' => '$data->getUserNickname()', 'filter' => CHtml::activeDropDownList($model, 'user_id', ForumMessage::model()->getUserList(), ['empty' => '', 'class' => 'form-control'])], ['name' => 'message', 'type' => 'ntext'], ['name' => 'date', 'htmlOptions' => ['style' => 'width:150px'], 'filter' => false], ['class' => 'bootstrap.widgets.TbButtonColumn']]]);
<?php $this->breadcrumbs = array(Yii::t('ForumModule.forum', 'Forums') => array('/forum/forumBackend/index'), Yii::t('ForumModule.forum', 'Topics') => array('/forum/messageBackend/index'), Yii::t('ForumModule.forum', 'Manage')); $this->pageTitle = Yii::t('ForumModule.forum', 'Messages - manage'); $this->menu = Yii::app()->getModule('forum')->getNavigation(); ?> <div class="page-header"> <h1> <?php echo Yii::t('ForumModule.forum', 'Messages'); ?> <small><?php echo Yii::t('ForumModule.forum', 'manage'); ?> </small> </h1> </div> <p><?php echo Yii::t('ForumModule.forum', 'This section describes forum management'); ?> </p> <?php $this->widget('yupe\\widgets\\CustomGridView', array('id' => 'forum-message-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'id', 'htmlOptions' => array('style' => 'width:20px'), 'type' => 'raw', 'value' => 'CHtml::link($data->id, array("/forum/forumBackend/update", "id" => $data->id))'), array('name' => 'topic_id', 'value' => '$data->getTopicTitle()', 'filter' => CHtml::activeDropDownList($model, 'topic_id', ForumTopic::model()->getFormattedList(), array('encode' => false, 'empty' => ''))), array('name' => 'user_id', 'value' => '$data->getUserNickname()', 'filter' => CHtml::activeDropDownList($model, 'user_id', ForumMessage::model()->getUserList(), array('encode' => false, 'empty' => ''))), array('name' => 'message', 'type' => 'ntext'), 'date', array('class' => 'bootstrap.widgets.TbButtonColumn'))));
public function getTopics($limit = -1) { $criteria = new CDbCriteria(); $criteria->compare('forum_id', $this->id); $criteria->join = 'LEFT JOIN ' . ForumMessage::model()->tableName() . ' AS fm ON fm.topic_id=t.id'; $criteria->order = 'fm.topic_id DESC'; $criteria->group = 't.id'; $criteria->limit = $limit; return ForumTopic::model()->findAll($criteria); }