Пример #1
0
    <?php 
ActiveForm::end();
?>
    
    </div><!-- form -->    
    
    
    <div class="bbii-box-top"><?php 
echo Yii::t('BbiiModule.bbii', 'Forum layout');
?>
</div>
    <div class="sortable">
    <?php 
$items = array();
foreach ($category as $data) {
    $forum = BbiiForum::find()->where(["cat_id" => $data->getAttribute('id')])->sorted()->forum()->all();
    $items['cat_' . $data->id] = $this->render('_category', array('forum' => $forum, 'data' => $data), true);
}
/*
        $this->widget('zii.widgets.jui.CJuiSortable', array(
            'id' => 'sortcategory',
            'items' => $items,
            'htmlOptions' => array('style' => 'list-style:none;;margin-top:1px'),
            'theme' => $this->module->juiTheme,
            'options' => array(
                'delay' => '100',
                'update' => 'js:function(){Sort(this,"' . $this->createAbsoluteUrl('setting/ajaxSort') . '");}',
            ),
        ));*/
echo Sortable::widget(['clientEvents' => ['update' => 'function( event, ui ) {
Пример #2
0
          ),
          'ip',
          'create_time',
          array(
              'class' => 'yii\grid\ActionColumn',
              'template' => '{view}{update}{delete}',
              'buttons' => array(
                  'view' => array(
                      'url' => 'array("forum/topic", "id" => $data->topic_id, "nav" => $data->id)',
                      'imageUrl' => $assets->baseUrl.'view.png',
                  ),
                  'update' => array(
                      'url' => 'array("forum/update", "id" => $data->id)',
                      'label' => Yii::t('BbiiModule.bbii','Update'),
                      'imageUrl' => $assets->baseUrl.'/images/update.png',
                      'options' => array('style' => 'margin-left:5px;'),
                  ),
                  'delete' => array(
                      'imageUrl' => $assets->baseUrl.'/images/delete.png',
                      'options' => array('style' => 'margin-left:5px;'),
                  ),
              )
          ),
      ),
  ));*/
?>
    <?php 
$dataProvider = $model->search();
echo GridView::widget(array('id' => 'bbii-post-grid', 'dataProvider' => $dataProvider, 'columns' => array(array('filter' => ArrayHelper::map(BbiiForum::getAllForumOptions(), 'id', 'name', 'group'), 'header' => 'Forum Name', 'value' => 'forum.name'), 'subject', 'create_time:datetime', ['class' => 'yii\\grid\\ActionColumn'])));
?>
</div>
Пример #3
0
<?php

use frontend\modules\bbii\models\BbiiForum;
use frontend\modules\bbii\models\BbiiMessage;
use yii\bootstrap\Nav;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\Breadcrumbs;
use frontend\modules\bbii\AppAsset;
$assets = AppAsset::register($this);
/* @var $this ForumController */
/* @var $item array */
?>

<?php 
echo Html::dropDownList('bbii-jumpto', null, ArrayHelper::map(BbiiForum::getForumOptions(), 'id', 'name'), array('prompt' => 'Jump to a Forum', 'class' => 'form-control', 'onchange' => "window.location.href = '" . \Yii::$app->urlManager->createAbsoluteUrl(array('forum')) . "/forum/forum?id='+\$(this).val()"));
?>

<br />

<div id = "bbii-header">
    <?php 
if (!\Yii::$app->user->isGuest) {
    ?>
        <?php 
    $messages = BbiiMessage::find()->where(['sendto' => \Yii::$app->user->identity->id])->inbox()->unread()->count();
    ?>
        <div class = "btn-group pull-right">
        <?php 
    if ($messages) {
        echo Html::a(Html::img($assets->baseUrl . '/images/newmail.png', array('title' => $messages . ' ' . Yii::t('BbiiModule.bbii', 'new messages'), 'style' => 'vertical-align:bottom;')), array('message/inbox'), array('class' => 'btn btn-default'));
Пример #4
0
 public function actionUpdate($id = null)
 {
     $id = is_numeric($id) ?: \Yii::$app->request->get('id');
     $post = BbiiPost::findOne($id);
     if ($post === null) {
         throw new HttpException(404, Yii::t('BbiiModule.bbii', 'The requested post does not exist.'));
     }
     if (($post->user_id != \Yii::$app->user->identity->id || $post->topic->locked) && !$this->isModerator()) {
         throw new HttpException(403, Yii::t('yii', 'You are not authorized to perform this action.'));
     }
     $forum = BbiiForum::findOne($post->forum_id);
     $topic = BbiiTopic::findOne($post->topic_id);
     if (\Yii::$app->request->post('BbiiPost')) {
         $post->attributes = \Yii::$app->request->post('BbiiPost');
         $post->change_id = \Yii::$app->user->identity->id;
         $post->change_time = date('Y-m-d H:m:i');
         if ($forum->moderated) {
             $post->approved = 0;
         } else {
             $post->approved = 1;
         }
         if ($post->validate() && $post->save()) {
             if (!$post->approved) {
                 $forum->updateCounters(array('num_posts' => -1));
                 // method since Yii 1.1.8
                 if ($topic->num_replies > 0) {
                     $topic->updateCounters(array('num_replies' => -1));
                     // method since Yii 1.1.8
                 } else {
                     $topic->approved = 0;
                     $topic->update();
                     $forum->updateCounters(array('num_topics' => -1));
                     // method since Yii 1.1.8
                 }
                 $post->poster->updateCounters(array('posts' => -1));
                 // method since Yii 1.1.8
             }
             return \Yii::$app->response->redirect(array('forum/forum/topic', 'id' => $post->topic_id));
         } else {
             \Yii::$app->session->addFlash('moderation', Yii::t('BbiiModule.bbii', 'Error saving data.'));
         }
     }
     return $this->render('update', array('forum' => $forum, 'topic' => $topic, 'post' => $post));
 }
Пример #5
0
            </div>

            <div>
                <?php 
echo $form->field($model, 'subtitle')->textInput();
?>
            </div>

            <?php 
if ($model->type != 0) {
    ?>
            <div>
                <div class="form-group field-bbiiforum-cateogry">
                    <label class="control-label" for="name">Category</label>
                    <?php 
    echo Html::activeDropDownList($model, 'cat_id', ArrayHelper::map(BbiiForum::find()->categories()->all(), 'id', 'name'), ['class' => 'form-control', 'id' => 'cateogry', 'prompt' => 'Choose One']);
    ?>
                </div>
            </div>
            <?php 
}
?>

            <div>
                <div class="form-group field-bbiiforum-public">
                    <label class="control-label" for="name">Public</label>
                    <?php 
echo Html::activeDropDownList($model, 'public', $booleanDDLOptions, ['class' => 'form-control', 'id' => 'public']);
?>
                </div>
            </div>
Пример #6
0
 /**
  * [update description]
  *
  * This is the way we should be writing the CRUD methods for V3
  * 
  * @version 3.0.5
  * @since  2.7.0
  * @param  [type] $id [description]
  * @return [type]     [description]
  */
 public function actionUpdateforum($id = null)
 {
     $model = BbiiForum::find()->where(['id' => (int) ($id ?: \Yii::$app->request->get('id'))])->one();
     if (\Yii::$app->request->post('BbiiForum') && $model->load(\Yii::$app->request->post())) {
         $success = $model->validate() && $model->save() ? true : false;
         \Yii::$app->getSession()->setFlash($success ? 'success' : 'warning', Yii::t('BbiiModule.bbii', 'Change ' . ($success ? '' : 'NOT') . 'saved.'));
     }
     return $this->render('update/forum', ['model' => $model]);
 }
Пример #7
0
 public function getForum()
 {
     return $this->hasOne(BbiiForum::className(), ['id' => 'forum_id']);
 }
Пример #8
0
 public static function getAllForumOptions()
 {
     $return = array();
     // $criteria = new CDbCriteria;
     // $criteria->condition = 'type = 0';
     // $criteria->order = 'sort';
     // $category = BbiiForum::find()->findAll($criteria);
     $category = BbiiForum::find()->where('type = 0')->orderBy('sort')->all();
     foreach ($category as $group) {
         //$criteria->condition = 'type = 1 and cat_id = ' . $group->id;
         //$forum = BbiiForum::find()->findAll($criteria);
         $forum = BbiiForum::find()->where('type = 1 and cat_id = ' . $group->id)->all();
         foreach ($forum as $option) {
             $return[] = array('id' => $option->id, 'name' => $option->name, 'group' => $group->name);
         }
     }
     return $return;
 }
Пример #9
0
 /**
  * Ajax call for change, move or merge topic
  */
 public function actionChangeTopic()
 {
     $json = array();
     if (isset(\Yii::$app->request->post()['BbiiTopic'])) {
         $model = BbiiTopic::find(\Yii::$app->request->post()['BbiiTopic']['id']);
         $move = false;
         $merge = false;
         $sourceTopicId = \Yii::$app->request->post()['BbiiTopic']['id'];
         $sourceForumId = $model->forum_id;
         if ($model->forum_id != \Yii::$app->request->post()['BbiiTopic']['forum_id']) {
             $move = true;
             $targetForumId = \Yii::$app->request->post()['BbiiTopic']['forum_id'];
         }
         if (!empty(\Yii::$app->request->post()['BbiiTopic']['merge']) && \Yii::$app->request->post()['BbiiTopic']['id'] != \Yii::$app->request->post()['BbiiTopic']['merge']) {
             $merge = true;
             $targetTopicId = \Yii::$app->request->post()['BbiiTopic']['merge'];
         }
         $model->load(\Yii::$app->request->post()['BbiiTopic']);
         if ($model->validate()) {
             $json['success'] = 'yes';
             if ($merge || $move) {
                 $numberOfPosts = BbiiPost::find()->where(['topic_id' => $sourceTopicId])->approved()->count();
                 if ($move) {
                     BbiiPost::find()->updateAll(array('forum_id' => $targetForumId), $criteria);
                     $forum = BbiiForum::find($sourceForumId);
                     $forum->updateCounters(array('num_topics' => -1));
                     $forum->updateCounters(array('num_posts' => -$numberOfPosts));
                     $forum = BbiiForum::find($targetForumId);
                     $forum->updateCounters(array('num_topics' => 1));
                     $forum->updateCounters(array('num_posts' => $numberOfPosts));
                     $this->resetLastForumPost($sourceForumId);
                     $this->resetLastForumPost($targetForumId);
                 }
                 if ($merge) {
                     BbiiPost::find()->updateAll(array('topic_id' => $targetTopicId), $criteria);
                     if ($move) {
                         $forum = BbiiForum::find($targetForumId);
                     } else {
                         $forum = BbiiForum::find($sourceForumId);
                     }
                     $forum->updateCounters(array('num_topics' => -1));
                     $topic = BbiiTopic::find($targetTopicId);
                     $topic->updateCounters(array('num_replies' => $numberOfPosts));
                     $model->delete();
                 } else {
                     $model->save();
                 }
             } else {
                 // no move or merge involved
                 $model->save();
             }
         } else {
             $json['error'] = json_decode(ActiveForm::validate($model));
         }
     }
     echo json_encode($json);
     \Yii::$app->end();
 }