コード例 #1
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));
 }
コード例 #2
0
ファイル: _footer.php プロジェクト: sourcetoad/bbii2
?>
            </div>
            <div class = "row">
                <span class = "header"><?php 
echo Yii::t('bbii', 'Total posts');
?>
</span> <?php 
echo BbiiPost::find()->count();
?>
            </div>
            <div class = "row">
                <span class = "header"><?php 
echo Yii::t('bbii', 'Total members');
?>
</span> <?php 
echo BbiiMember::find()->count();
?>
            </div>
            <div class = "row">
                <span class = "header"><?php 
echo Yii::t('bbii', 'Newest member');
?>
</span> <?php 
$member = BbiiMember::find()->newest()->find();
echo Html::a($member->member_name, array('member/view', 'id' => $member->id));
?>
            </div>
        </div>
    </div>
</div>
コード例 #3
0
ファイル: _upvotedBy.php プロジェクト: sourcetoad/bbii2
<?php

/* @var $post_id integer */
$models = BbiiUpvoted::find()->findAllByAttributes(array('post_id' => $post_id));
$count = count($models);
if ($count) {
    echo '<div class = "post-upvote-footer">' . PHP_EOL;
    echo Yii::t('BbiiModule.bbii', 'Post appreciated by: ');
    $users = array();
    foreach ($models as $model) {
        $member = BbiiMember::find($model->member_id);
        if ($member !== null) {
            $users[] = Html::a(Html::encode($member->member_name), array("member/view", "id" => $member->id));
        }
    }
    echo implode(', ', $users);
    echo '</div>' . PHP_EOL;
}