public function mailboxFull($attr, $params) { $criteria = ['outbox' => 1, 'sendfrom' => Yii::$app->user->id]; if (YBoardMessage::find()->where($criteria)->outbox()->count() >= Yii::$app->params['maxMessages']) { $this->addError('sendto', YBoard::t('yboard', 'Your outbox is full. Please make room before sending new messages.')); } }
public function beforeAction($action) { if (parent::beforeAction($action)) { //update users online information $this->updateOnlineStatus($action); // register visit by webspider if (isset($_SERVER['HTTP_USER_AGENT'])) { $spider = YBoardSpider::find()->where(['user_agent' => $_SERVER['HTTP_USER_AGENT']])->one(); } else { $spider = null; } if ($spider != null) { $spider->setScenario('visit'); $spider->hits++; $spider->last_visit = null; $spider->save(); } //menu fixed for Views $approvals1 = YBoardPost::find()->unapprovedScope()->count(); $approvals2 = YBoardTopic::find()->andWhere(['approved' => 0])->count(); $reports = YBoardMessage::find()->reportScope()->unreadScope()->count(); $this->params['foroMenu'] = [['label' => Yii::t('app', 'Members'), 'url' => ['member/index']], ['label' => Yii::t('app', 'Pending') . ' (' . ($approvals1 + $approvals2) . ')', 'url' => ['moderator/approve'], 'visible' => Yii::$app->user->can('moderator')], ['label' => Yii::t('app', 'Reported') . ' (' . $reports . ')', 'url' => ['moderator/reported'], 'visible' => Yii::$app->user->can('moderator')]]; return true; } else { return false; } }
public function search($params) { $query = YBoardMessage::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'sendfrom' => $this->sendfrom, 'sendto' => $this->sendto, 'create_time' => $this->create_time, 'read_indicator' => $this->read_indicator, 'type' => $this->type, 'inbox' => $this->inbox, 'outbox' => $this->outbox, 'post_id' => $this->post_id]); $query->andFilterWhere(['like', 'subject', $this->subject])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'ip', $this->ip]); return $dataProvider; }
/* @var $this ForumController */ /* @var $forum YBoardForum */ /* @var $dataProvider DataProvider */ use app\modules\yboard\YBoard; use app\modules\yboard\models\YBoardPost; use app\modules\yboard\models\YBoardTopic; use app\modules\yboard\models\YBoardMessage; use yii\widgets\ListView; use yii\helpers\Html; use yii\widgets\ActiveForm; use yii\jui\Dialog; use yii\web\JsExpression; $this->params['breadcrumbs'] = [['label' => YBoard::t('yboard', 'Forums'), 'url' => ['forum/index']], $forum->name]; $approvals = YBoardPost::find()->unapprovedScope()->count(); $reports = YBoardMessage::find()->reportScope()->count(); $this->title = $forum->name; ?> <?php if (\Yii::$app->session->hasFlash('moderation')) { ?> <div class="flash-notice"> <?php echo \Yii::$app->session->getFlash('moderation'); ?> </div> <?php } ?>
/** * Finds the YBoardMessage model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return YBoardMessage the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = YBoardMessage::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function beforeDelete() { if (parent::beforeDelete()) { //delete: Messages(to/from), Ban History, UpVotes, LogTopic YBoardMessage::deleteAll(['or', 'sendfrom' => $this->id, 'sendto' => $this->id]); // Post(Polls and Votes) YBoardVote::deleteAll(['user_id' => $this->id]); YBoardUpvoted::deleteAll(['member_id' => $this->id]); YBoardPoll::deleteAll(['user_id' => $this->id]); YBoardPost::deleteAll(['user_id' => $this->id]); //log topic YBoardLogTopic::deleteAll(['member_id' => $this->id]); //ban YBoardBan::deleteAll(['user_id' => $this->id]); return true; } else { return false; } }
<?php use app\modules\yboard\YBoard; use yii\helpers\Html; use yii\bootstrap\Nav; use yii\bootstrap\NavBar; use yii\widgets\Breadcrumbs; use yii\widgets\Menu; use app\modules\yboard\models\YBoardMessage; /* @var $this \yii\web\View */ /* @var $content string */ $this->registerJs('hljs.initHighlightingOnLoad();'); $unread = YBoardMessage::find()->inboxScope()->unreadScope()->andWhere(['sendto' => \Yii::$app->user->id])->count(); $total = YBoardMessage::find()->inboxScope()->andWhere(['sendto' => \Yii::$app->user->id])->count(); $this->beginPage(); ?> <!DOCTYPE html> <html lang="<?php echo Yii::$app->language; ?> "> <head> <meta charset="<?php echo Yii::$app->charset; ?> "/> <meta name="viewport" content="width=device-width, initial-scale=1"> <?php echo Html::csrfMetaTags(); ?> <title><?php
public function actionReported() { if (!Yii::$app->user->can('app.forum.moderator.reported')) { throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.')); } $count = []; $query = YBoardMessage::find()->inboxScope()->reportMsgScope(); $count['reported'] = $query->count(); $dataProvider = new ActiveDataProvider(['query' => $query]); return $this->render('report', ['dataProvider' => $dataProvider, 'count' => $count]); }
/** * @return \yii\db\ActiveQuery */ public function getMessages() { return $this->hasMany(YBoardMessage::className(), ['post_id' => 'id']); }