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)); }
public function actionDelete() { $type = $_POST['type']; switch ($_POST['type']) { case 'message': $model = ForumMessage::deleteAll(['id' => $_POST['id']]); return json_encode(['status' => 1]); break; case 'post': $model = \app\models\ForumPost::deleteAll(['id' => $_POST['id']]); return json_encode(['status' => 1]); break; default: break; } }
<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; $mailTitle = 'Набирает обороты'; } else {
" data-type="message" data-type="message" data-toggle="tooltip" data-placement="top" title="Ответить"> <span class="fa fa-share-square-o" aria-hidden="true"></span></button> <button type="button" class="transparent setQuote" data-dismiss="alert" aria-label="Close" data-id="<?php echo $message->id; ?> " data-type="message" data-type="message" data-toggle="tooltip" data-placement="top" title="Цитировать"><span class="fa fa-quote-left" aria-hidden="true"></span></button> </div> <div class="panel-body"><?php echo $message->message; ?> </div> <?php PrettyPhoto::widget(['target' => ".pretty", 'pluginOptions' => ['opacity' => 0.6, 'theme' => PrettyPhoto::THEME_DARK_SQUARE, 'social_tools' => true, 'autoplay_slideshow' => false, 'modal' => true]]); ?> </div> <?php $answers = \app\models\ForumMessage::find()->where(['status' => 1, 'post_id' => $post->id, 'answer' => $message->id])->orderBy('id asc')->all(); foreach ($answers as $answer) { $userNameAnswer = app\models\Users::findOne($answer->author)->login; ?> <div class="media answer" id='message-<?php echo $answer->id; ?> '> <div class="media-left"> <!--<a href="#">--> <!--<img class="media-object" data-src="holder.js/64x64" alt="64x64" style="width: 64px; height: 64px;" src="/img/avatars/<?php echo $answer->author; ?> .jpg" data-holder-rendered="true">--> <?php echo EasyThumbnailImage::thumbnailImg("img/avatars/{$answer->author}.png", 64, 64, EasyThumbnailImage::THUMBNAIL_OUTBOUND, ['alt' => $userNameAnswer, 'class' => 'media-object']);
<thead> <tr> <th>Тип</th> <th>Тема</th> <th>Сообщения</th> <th>Раздел</th> <th>Управление</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(); ?> <tr> <td><div class="fire"><img src="/img/icons/message/message.png"></div></td> <td><a href="<?php echo Url::to(['forum/post/', 'id' => $post->id]); ?> "><?php echo $post->name; ?> </a></td> <td><?php echo $messagesCount; ?> </td> <td><?php