Esempio n. 1
0
use sourcetoad\bbii2\models\BbiiPost;
use sourcetoad\bbii2\models\BbiiMessage;
use yii\bootstrap\ActiveForm;
use yii\helpers\Html;
use yii\widgets\ListView;
/* @var $this ForumController */
/* @var $forum BbiiForum */
/* @var $dataProvider ArrayDataProvider */
/* $this->context->bbii_breadcrumbs = array(
    Yii::t('BbiiModule.bbii', 'Forum') => array('forum/index'),
    $forum->name,
); */
$this->title = Yii::t('forum', $forum->name);
$this->params['breadcrumbs'][] = $this->title;
$approvals = BbiiPost::find()->unapproved()->count();
$reports = BbiiMessage::find()->report()->count();
$item = array(array('label' => Yii::t('BbiiModule.bbii', 'Forum'), 'url' => array('forum/index')), array('label' => Yii::t('BbiiModule.bbii', 'Members'), 'url' => array('member/index')), array('label' => Yii::t('BbiiModule.bbii', 'Approval') . ' (' . $approvals . ')', 'url' => array('moderator/approval'), 'visible' => $this->context->isModerator()), array('label' => Yii::t('BbiiModule.bbii', 'Reports') . ' (' . $reports . ')', 'url' => array('moderator/report'), 'visible' => $this->context->isModerator()));
?>

<?php 
foreach (\Yii::$app->session->getAllFlashes() as $key => $message) {
    echo '<div class="alert alert-' . $key . '">' . $message . '</div>';
}
\Yii::$app->session->removeAllFlashes();
?>

<div id="bbii-wrapper" class="well clearfix">
    <div class="row">
        <div class="col col-md-12">
            <?php 
Esempio n. 2
0
 public function showUpvote($post_id)
 {
     $url = \Yii::$app->urlManager->createAbsoluteUrl('forum/upvote');
     $post = BbiiPost::find($post_id);
     if ($post === null || $post->user_id == \Yii::$app->user->identity->id) {
         return '';
     }
     $criteria = new CDbCriteria();
     $criteria->condition = "member_id = :userid and post_id = {$post_id}";
     $criteria->params = array(':userid' => \Yii::$app->user->identity->id);
     // @todo this should be moved to the VW - DJE : 2015-05-14
     $assets = AppAsset::register($this);
     if (BbiiUpvoted::find()->exists($criteria)) {
         $html = Html::img($asset->baseUrl . '/images/down.gif', 'upvote', array('title' => Yii::t('BbiiModule.bbii', 'Remove your vote'), 'id' => 'upvote_' . $post_id, 'style' => 'cursor:pointer;', 'onclick' => 'upvotePost(' . $post_id . ',"' . $url . '")'));
     } else {
         $html = Html::img($asset->baseUrl . '/images/up.gif', 'upvote', array('title' => Yii::t('BbiiModule.bbii', 'Vote this post up'), 'id' => 'upvote_' . $post_id, 'style' => 'cursor:pointer;', 'onclick' => 'upvotePost(' . $post_id . ',"' . $url . '")'));
     }
     return $html;
 }
Esempio n. 3
0
            <ul class="list-group">
                <li class="list-group-item">
                    <?php 
echo Yii::t('BbiiModule.bbii', 'Total topics');
?>
                    <div class="badge pull-right"><?php 
echo BbiiTopic::find()->count();
?>
</div>
                </li>
                <li class="list-group-item">
                    <?php 
echo Yii::t('BbiiModule.bbii', 'Total posts');
?>
                    <div class="badge pull-right"><?php 
echo BbiiPost::find()->count();
?>
</div>
                </li>
                <li class="list-group-item">
                    <?php 
echo Yii::t('BbiiModule.bbii', 'Total members');
?>
                    <div class="badge pull-right"><?php 
echo BbiiMember::find()->count();
?>
</div>
                </li>
                <li class="list-group-item">
                    <?php 
echo Yii::t('BbiiModule.bbii', 'Newest member');
Esempio n. 4
0
 public function actionBanIp($id)
 {
     $post = BbiiPost::find($id);
     if ($post === null) {
         throw new HttpException(404, Yii::t('BbiiModule.bbii', 'The requested post does not exist.'));
     }
     $ip = new BbiiIpaddress();
     $ip->ip = $post->ip;
     $ip->save();
     return;
 }
Esempio n. 5
0
 /**
  * [actionView description]
  *
  * @version  2.2.0
  * @param  [type] $id [description]
  * @return [type]     [description]
  */
 public function actionView($id = null)
 {
     $object = new BbiiTopicRead();
     $read = BbiiTopicRead::find($id);
     if (isset(\Yii::$app->request->get()['unwatch']) && ($this->isModerator() || $id == \Yii::$app->user->identity->id)) {
         if ($read !== null) {
             $object->unserialize($read->data);
             foreach (\Yii::$app->request->get()['unwatch'] as $topicId => $val) {
                 $object->unsetFollow($topicId);
             }
             $read->data = $object->serialize();
             $read->save();
         }
     }
     if (($this->isModerator() || $id == \Yii::$app->user->identity->id) && isset($read->data)) {
         if ($read === null) {
             $in = array(0);
         } else {
             $object->unserialize($read->data);
             $in = array_keys($object->getFollow());
         }
     } else {
         $in = array(0);
     }
     // @todo Need to figure out the Yii2 version of `'with' => 'forum',` for ADP - DJE : 2015-05-15
     $dataProvider = new ActiveDataProvider(['pagination' => false, 'query' => BbiiPost::find()->where(['approved' => 1, 'user_id' => \Yii::$app->user->identity->id])->orderBy('create_time DESC')->limit(10)]);
     // @todo Need to figure out the Yii2 version of `'with' => 'forum',` for ADP - DJE : 2015-05-15
     $topicProvider = new ActiveDataProvider(['pagination' => false, 'query' => BbiiTopic::find()->where(['id' => $in])->orderBy('id ASC')]);
     return $this->render('view', array('dataProvider' => $dataProvider, 'topicProvider' => $topicProvider, 'userData' => BbiiMember::find()->where(['id' => is_numeric($id) ? $id : \Yii::$app->request->get('id')])->one()));
 }
Esempio n. 6
0
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * 
  * @param  [type] $params [description]
  * @return ActiveDataProvider The data provider that can return the models based on the search/filter conditions.
  */
 public function search($params = null)
 {
     $query = BbiiPost::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $this->with = array('poster');
     $this->addCondition('approved', $this->approved);
     $this->addCondition('change_id', $this->change_id, true);
     $this->addCondition('change_reason', $this->change_reason, true);
     $this->addCondition('change_time', $this->change_time, true);
     $this->addCondition('content', $this->content, true);
     $this->addCondition('create_time', $this->create_time, true);
     $this->addCondition('forum_id', $this->forum_id, true);
     $this->addCondition('id', $this->id, true);
     $this->addCondition('ip', $this->ip, true);
     $this->addCondition('poster.member_name', $this->search, true);
     $this->addCondition('subject', $this->subject, true);
     $this->addCondition('topic_id', $this->topic_id, true);
     $this->addCondition('user_id', $this->user_id, true);
     return $dataProvider;
 }
Esempio n. 7
0
 /**
  * Returns the css class when a member has posted in a topic
  */
 public function hasPostedClass()
 {
     if (!\Yii::$app->user->isGuest && BbiiPost::find()->where("topic_id = " . $this->id . " and user_id = " . \Yii::$app->user->identity->id)) {
         return 'posted';
     }
     return '';
 }