Пример #1
0
 public static function catlist()
 {
     $model = ForumCategory::find()->where(['status' => 1])->all();
     $result = [];
     foreach ($model as $data) {
         $result[$data->id] = $data->name;
     }
     return $result;
 }
Пример #2
0
 public function actionPost($id)
 {
     $post = $this->loadModel($id);
     $model = new \app\models\ForumMessage();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $model->save(false);
         $model = new \app\models\ForumMessage();
     }
     $messages = \app\models\ForumMessage::find()->where(['status' => 1, 'post_id' => $id, 'answer' => 0])->orderBy('id asc')->all();
     $category = \app\models\ForumCategory::findOne($post->category);
     return $this->render('post', array('post' => $post, 'messages' => $messages, 'category' => $category, 'model' => $model));
 }
Пример #3
0
    <table class="table table-striped">
        <thead>
            <tr>
                <th class="col-lg-1">Тип</th>
                <th class="col-lg-7">Тема</th>
                <th class="col-lg-1">Сообщения</th>
                <th class="col-lg-2">Раздел</th>
                <th class="col-lg-1">Управление</th>
            </tr>
        </thead>
        <tbody>
            <?php 
foreach ($model as $post) {
    ?>
            <?php 
    $category = \app\models\ForumCategory::find()->where(['id' => $post->category])->one();
    $messagesCount = \app\models\ForumMessage::find()->where(['post_id' => $post->id])->count();
    $lastMessage = \app\models\ForumMessage::find()->where(['post_id' => $post->id])->orderBy('id desc')->select('dateadd')->one();
    if (!$lastMessage) {
        $lastMessage['dateadd'] = 1;
    }
    if ($lastMessage['dateadd'] == time()) {
        $mailIcon = 4;
        $mailTitle = 'Есть новые ответы';
    } else {
        if ($messagesCount > 50) {
            $mailIcon = 3;
            $mailTitle = 'Популярная тема';
        } else {
            if ($messagesCount > 10) {
                $mailIcon = 2;