Пример #1
0
use frontend\modules\bbii\models\BbiiPost;
use frontend\modules\bbii\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 
echo $this->render('_header', array('item' => $item));
Пример #2
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 = BbiiMessage::find();
     $dataProvider = new ActiveDataProvider(['pagination' => false, 'query' => $query, 'sort' => ['defaultOrder' => ['create_time' => SORT_ASC, 'subject' => SORT_ASC]]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $this->addCondition('content', $this->content, true);
     $this->addCondition('id', $this->id, true);
     $this->addCondition('inbox', $this->inbox);
     $this->addCondition('ip', $this->ip, true);
     $this->addCondition('outbox', $this->outbox);
     $this->addCondition('post_id', $this->post_id, true);
     $this->addCondition('read_indicator', $this->read_indicator);
     $this->addCondition('sendfrom', $this->sendfrom, true);
     $this->addCondition('sendto', $this->sendto, true);
     $this->addCondition('subject', $this->subject, true);
     $this->addCondition('type', $this->type);
     $criteria->limit = 100;
     return $dataProvider;
 }
Пример #3
0
/* @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'));
    } else {
        echo Html::a(Html::img($assets->baseUrl . '/images/mail.png', array('title' => Yii::t('BbiiModule.bbii', 'no new messages'), 'style' => 'vertical-align:bottom;')), array('message/inbox'), array('class' => 'btn btn-default'));
    }
    echo Html::a(Html::img($assets->baseUrl . '/images/settings.png', array('title' => Yii::t('BbiiModule.bbii', 'My settings'), 'style' => 'vertical-align:bottom;')), array('member/view', 'id' => \Yii::$app->user->identity->id), array('class' => 'btn btn-default'));
    if ($this->context->isModerator()) {
        echo Html::a(Html::img($assets->baseUrl . '/images/moderator.png', array('title' => Yii::t('BbiiModule.bbii', 'Moderate'), 'style' => 'vertical-align:bottom;')), array('moderator/approval'), array('class' => 'btn btn-default'));
        echo Html::a(Html::img($assets->baseUrl . '/images/config.png', array('title' => Yii::t('BbiiModule.bbii', 'Forum settings'), 'style' => 'vertical-align:bottom;')), array('setting/index'), array('class' => 'btn btn-default'));
    }
    ?>
        </div>
Пример #4
0
 /**
  * [getMessageMDL description]
  * @param  [type] $param [description]
  * @return [type]        [description]
  */
 private function getMessageMDL($param)
 {
     return BbiiMessage::find()->where(['id' => $this->getMessageID($param)])->one();
 }
Пример #5
0
use yii\bootstrap\Nav;
use yii\widgets\Breadcrumbs;
use frontend\modules\bbii\AppAsset;
$assets = AppAsset::register($this);
/* @var $this ModeratorController */
/* @var $item array */
$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', 'Posts'), 'url' => array('moderator/admin'), 'visible' => $this->context->isModerator()), array('label' => Yii::t('BbiiModule.bbii', 'Send mail'), 'url' => array('moderator/sendmail'), 'visible' => $this->context->isModerator()));
?>
<div id = "bbii-header">
    <?php 
if (!\Yii::$app->user->isGuest) {
    ?>
    <?php 
    $messages = BbiiMessage::find()->inbox()->unread()->count('sendto = ' . \Yii::$app->user->identity->id);
    ?>
        <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'));
    } else {
        echo Html::a(Html::img($assets->baseUrl . '/images/mail.png', array('title' => Yii::t('BbiiModule.bbii', 'no new messages'), 'style' => 'vertical-align:bottom;')), array('message/inbox'), array('class' => 'btn btn-default'));
    }
    echo Html::a(Html::img($assets->baseUrl . '/images/settings.png', array('title' => Yii::t('BbiiModule.bbii', 'My settings'), 'style' => 'vertical-align:bottom;')), array('member/view', 'id' => \Yii::$app->user->identity->id), array('class' => 'btn btn-default'));
    echo Html::a(Html::img($assets->baseUrl . '/images/moderator.png', array('title' => Yii::t('BbiiModule.bbii', 'Moderate'), 'style' => 'vertical-align:bottom;')), array('moderator/approval'), array('class' => 'btn btn-default'));
    echo Html::a(Html::img($assets->baseUrl . '/images/config.png', array('title' => Yii::t('BbiiModule.bbii', 'Forum settings'), 'style' => 'vertical-align:bottom;')), array('setting/index'), array('class' => 'btn btn-default'));
    ?>
        </div>
    <?php 
}
Пример #6
0
 public function actionSendmail()
 {
     $model = new MailForm();
     // $model->unsetAttributes();
     if (isset(\Yii::$app->request->post()['MailForm'])) {
         $model->load(\Yii::$app->request->post()['MailForm']);
         if (empty($model->member_id)) {
             $model->member_id = -1;
             // All members
         }
         if ($model->validate()) {
             $members = $model->member_id >= 0 ? BbiiMember::find()->where(['group_id' => $model->member_id])->all() : BbiiMember::findAll();
             if (isset(\Yii::$app->request->post()['email'])) {
                 // e-mails
                 $name = $this->context->module->forumTitle;
                 $name = ' = ?UTF-8?B?' . base64_encode($name) . '? = ';
                 $from = BbiiSetting::find()->find()->contact_email;
                 $subject = ' = ?UTF-8?B?' . base64_encode($model->subject) . '? = ';
                 $headers = "From: {$name} <{$from}>\r\n" . "Reply-To: {$from}\r\n" . "MIME-Version: 1.0\r\n" . "Content-type: text/html; charset = UTF-8";
                 $users = array();
                 $class = new $this->module->userClass();
                 foreach ($members as $member) {
                     $sendto = $member->member_name . " <{$to}>";
                     $to = $user->getAttribute($this->module->userMailColumn);
                     $user = $class::find()->where([$this->module->userIdColumn => $member->id])->all();
                     mail($sendto, $subject, $model->body, $headers);
                     $users[] = $member->member_name;
                 }
                 // $model->unsetAttributes();
                 \Yii::$app->session->addFlash('success', Yii::t('BbiiModule.bbii', 'You have sent an e-mail to the following users: ') . implode(', ', $users));
             } else {
                 // private messages
                 $users = array();
                 foreach ($members as $member) {
                     $message = new BbiiMessage();
                     $message->sendfrom = \Yii::$app->user->identity->id;
                     $message->sendto = $member->id;
                     $message->subject = $model->subject;
                     $message->content = $model->body;
                     $message->outbox = 0;
                     if ($message->save()) {
                         $users[] = $member->member_name;
                     }
                 }
                 // $model->unsetAttributes();
                 \Yii::$app->session->addFlash('success', Yii::t('BbiiModule.bbii', 'You have sent a private message to the following users: ') . implode(', ', $users));
             }
         }
     }
     return $this->render('sendmail', array('model' => $model));
 }