public function actionShowDrafts()
 {
     $query = Message::find()->where(['sender_id' => \Yii::$app->user->getId(), 'status' => -1]);
     $pagination = new Pagination(['defaultPageSize' => 15, 'totalCount' => $query->count()]);
     $listMsg = $query->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render('drafts', ['model' => $listMsg, 'pagination' => $pagination]);
 }
Beispiel #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $this->scenario = 'search';
     $query = Message::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 100], 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_user_id' => $this->created_user_id, 'updated_user_id' => $this->updated_user_id, 'for_document_id' => $this->for_document_id, 'for_user_id' => $this->for_user_id, 'parent_message_id' => $this->parent_message_id]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'attachment', $this->attachment])->andFilterWhere(['like', 'created_user_name', $this->created_user_name])->andFilterWhere(['like', 'updated_user_name', $this->updated_user_name])->andFilterWhere(['like', 'created_ip', $this->created_ip])->andFilterWhere(['>=', 'id', $this->id_from])->andFilterWhere(['<=', 'id', $this->id_till]);
     for ($i = 1; $i <= Message::OPTIONS_COUNT; $i++) {
         $option = 'option_' . $i;
         $query->andFilterWhere(['like', $option, $this->{$option}]);
     }
     if ($this->created_at_from) {
         $query->andFilterWhere(['>=', 'created_at', CFF::FormatData($this->created_at_from, false) . ' 00:00:00']);
     }
     if ($this->created_at_till) {
         $query->andFilterWhere(['<=', 'created_at', CFF::FormatData($this->created_at_till, false) . ' 23:59:00']);
     }
     if ($this->updated_at_from) {
         $query->andFilterWhere(['>=', 'updated_at', CFF::FormatData($this->updated_at_from, false) . ' 00:00:00']);
     }
     if ($this->updated_at_till) {
         $query->andFilterWhere(['<=', 'updated_at', CFF::FormatData($this->updated_at_till, false) . ' 23:59:00']);
     }
     return $dataProvider;
 }
Beispiel #3
0
 /**
  * 用户消息控制器
  * @return string
  */
 public function actionUserMessage()
 {
     $user = Yii::$app->user->identity;
     $query = Message::find()->where("NOT FIND_IN_SET({$user->getId()},`deleted`)");
     $query = $query->andFilterWhere(['status' => Message::STATUS_ACTIVE])->orderBy('created_at DESC');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     return $this->render('user-message', ['dataProvider' => $dataProvider]);
 }
Beispiel #4
0
 public function search($params)
 {
     $query = Message::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'message_start' => $this->message_start, 'message_end' => $this->message_end, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'subject', $this->subject])->andFilterWhere(['like', 'body', $this->body])->andFilterWhere(['like', 'message_type', $this->message_type])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
Beispiel #5
0
 public function run()
 {
     $q = Message::find();
     if ($this->home_club_only && !Yii::$app->user->isGuest) {
         $golfer = Golfer::me();
         if ($golfer->facility_id) {
             $q->andWhere(['facility_id' => [0, $golfer->facility_id]]);
         }
     }
     return $this->render('latest-messages', ['dataProvider' => new ActiveDataProvider(['query' => $q->orderBy('created_at desc'), 'pagination' => ['pageSize' => $this->messages_count]])]);
 }
Beispiel #6
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Message::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'receive', $this->receive])->andFilterWhere(['like', 'unread', $this->unread])->andFilterWhere(['like', 'sender', $this->sender]);
     return $dataProvider;
 }
 /**
  * Lists all Message models.
  * @return mixed
  */
 public function actionIndex($usr = null)
 {
     if ($usr == null) {
         return $this->render('index');
     }
     if ($usr == Yii::$app->user->id) {
         return $this->render('index');
     }
     $model_new = new Message();
     $model_new->recipient_id = Yii::$app->request->get()['usr'];
     $model_new->sender_id = Yii::$app->user->id;
     $userto = Yii::$app->request->get()['usr'];
     if ($model_new->load(Yii::$app->request->post()) && $model_new->save()) {
         //return $this->redirect(['view', 'id' => $model->id]);
         $model_new->text = "";
     }
     unset(Yii::$app->request->post()['text']);
     $dataProvider = new ActiveDataProvider(['query' => Message::find()->where(['and', 'sender_id=' . Yii::$app->user->id, 'recipient_id=' . Yii::$app->request->get()['usr']])->orWhere(['and', 'recipient_id=' . Yii::$app->user->id, 'sender_id=' . Yii::$app->request->get()['usr']])->orderBy('id DESC'), 'pagination' => ['pageSize' => 5]]);
     return $this->render('view', ['dataProvider' => $dataProvider, 'model_new' => $model_new, 'userto' => $userto]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Message::find()->joinWith(['member' => function ($query) {
         $query->from(['member' => 'member']);
     }])->orderBy(['created_at' => SORT_DESC]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!Yii::$app->user->identity->isAdmin()) {
         $this->member_id = Yii::$app->user->identity->id;
     }
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'member_id' => $this->member_id, 'type' => $this->type]);
     if ($this->created_at) {
         $date = explode(' - ', $this->created_at);
         if (count($date) == 2) {
             $query->andFilterWhere(['>=', $this::tableName() . '.created_at', $date[0] . ' 00:00:00']);
             $query->andFilterWhere(['<=', $this::tableName() . '.created_at', $date[1] . ' 23:59:59']);
         }
     }
     if ($this->updated_at) {
         $date = explode(' - ', $this->updated_at);
         if (count($date) == 2) {
             $query->andFilterWhere(['>=', $this::tableName() . '.updated_at', $date[0] . ' 00:00:00']);
             $query->andFilterWhere(['<=', $this::tableName() . '.updated_at', $date[1] . ' 23:59:59']);
         }
     }
     $query->andFilterWhere(['like', 'message.title', $this->title])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'member.username', $this->membername])->orderBy(['created_at' => SORT_DESC]);
     if ($this->replied_content == 1) {
         $query->andFilterWhere(['>', 'replied_content', '']);
     } else {
         if ($this->replied_content == 2) {
             $query->andFilterWhere(['=', 'replied_content', null]);
         }
     }
     var_dump($query->createCommand()->getRawSql());
     return $dataProvider;
 }
Beispiel #9
0
 public static function DialogList($user)
 {
     $query = Message::find()->where(['and', "sender_id={$user}", "recipient_id!={$user}"])->orWhere(['and', "sender_id!={$user}", "recipient_id={$user}"]);
     $message_list = new ActiveDataProvider(['query' => $query]);
     $message_list->query->orderBy(['datetime' => SORT_DESC, 'id' => SORT_DESC]);
     $count = $message_list->count;
     $messages = $message_list->getModels();
     $dialog_list = array();
     foreach ($messages as $message) {
         if ($message->sender_id == Yii::$app->user->id) {
             $dialog_list[$message->recipient_id][] = $message;
         } elseif ($message->recipient_id == Yii::$app->user->id) {
             $dialog_list[$message->sender_id][] = $message;
         }
     }
     ArrayHelper::multisort($dialog_list, ['id'], SORT_DESC);
     $result = array();
     foreach ($dialog_list as $dialog) {
         $result[] = $dialog[0];
     }
     return $result;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Message::find();
     $query->joinWith(['source']);
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['is_translated' => SORT_ASC]]]);
     $dataProvider->sort->attributes['message'] = ['asc' => ['{{%core_source_message}}.message' => SORT_ASC], 'desc' => ['{{%core_source_message}}.message' => SORT_DESC]];
     $dataProvider->sort->attributes['category'] = ['asc' => ['{{%core_source_message}}.category' => SORT_ASC], 'desc' => ['{{%core_source_message}}.category' => SORT_DESC]];
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'is_translated' => $this->is_translated]);
     $query->andFilterWhere(['like', 'language', $this->language])->andFilterWhere(['like', 'translation', $this->translation])->andFilterWhere(['like', '{{%core_source_message}}.message', $this->message])->andFilterWhere(['like', '{{%core_source_message}}.category', $this->category]);
     //$query->andFilterWhere([
     //    'DATE(FROM_UNIXTIME(`created_at`))' => $this->created_at,
     //]);
     return $dataProvider;
 }
Beispiel #11
0
<?php

/**
 * Created by PhpStorm.
 * User: Nguyen
 * Date: 11/12/2015
 * Time: 4:16 PM
 */
use yii\widgets\LinkPager;
$this->title = 'Tin nhắn';
$this->params['breadcrumbs'][] = $this->title;
$newCount = \common\models\Message::find()->where(['receiver_id' => Yii::$app->user->getId(), 'status' => 0])->count();
?>

<div class="row">
    <div class="col-md-3">
        <a href="?r=message/compose" class="btn btn-primary btn-block margin-bottom">Soạn</a>
        <div class="box box-solid">
            <div class="box-header with-border">
                <h3 class="box-title">Danh mục</h3>
                <div class="box-tools">
                    <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
                </div>
            </div>
            <div class="box-body no-padding">
                <ul class="nav nav-pills nav-stacked">
                    <li class="active"><a href="#"><i class="fa fa-inbox"></i> Tin đã nhận <span class="label label-primary pull-right"><?php 
echo $newCount;
?>
</span></a></li>
                    <li><a href="?r=message/show-outbox"><i class="fa fa-envelope-o"></i> Tin đã gửi</a></li>
Beispiel #12
0
 /**
  * 获取列表数据
  * @param integer $ta_uid
  * @param integer $login_uid
  * @param string  $table
  * @param integer $pageSize
  * @param mixed $where
  * @param mixed $sort
  * @return []
  */
 public function getTaList($ta_uid, $login_uid, $table, $pageSize, $where, $sort = ['msg_id' => SORT_ASC])
 {
     $pageSize = 1;
     $arr = [$ta_uid, $login_uid];
     $arr = array_unique($arr);
     $str = implode(',', $arr);
     $model_Message = new Message();
     $query = $model_Message->find()->where("`table`=:table and ( (from_uid={$login_uid} and to_uid={$ta_uid} ) or (from_uid={$ta_uid} and to_uid={$login_uid} ) ) ", [':table' => $table]);
     if ($where) {
         $query->andWhere($where);
     }
     if ($sort) {
         $sort['msg_id'] = SORT_DESC;
         $query->orderBy($sort);
     }
     $pagination = new Pagination();
     $pagination->totalCount = $query->count();
     $offset = $pagination->getOffset();
     $limit = $pagination->getLimit();
     $query->offset($offset);
     $query->limit($limit);
     $pagination->page;
     //                 echo $query->createCommand()->getRawSql();
     //                 exit;
     $a_models = $query->all();
     if (isset($_GET[$pagination->pageParam]) && $pagination->pageCount < $_GET[$pagination->pageParam]) {
         $a_models = [];
     }
     $temp_data['models'] = $a_models;
     $temp_data['pagination'] = $pagination;
     return $temp_data;
 }
Beispiel #13
0
 /**
  *
  * 用message表中删除已阅读用户的id,返回0表示删除失败,返回大于0表示成功
  * @param $messageId
  * @param $userId
  * @return int 0=>删除失败,1=>成功删除
  * @throws \yii\db\Exception
  */
 public static function removeUnreadByUserId($messageId, $userId)
 {
     //读取数据库中unread字段值
     $message = Message::find()->where(['id' => $messageId])->one();
     $unread = $message->unread;
     //转换成数组
     $unread = explode(',', $unread);
     //移出对应的userid
     if (in_array($userId, $unread)) {
         $key = array_search($userId, $unread);
         ArrayHelper::remove($unread, $key);
         //数组在用","连接转换成字符串
         $unread = implode(',', $unread);
         //更新unread字段
         return Yii::$app->db->createCommand()->update('{{%message}}', ['unread' => $unread], ['id' => $messageId])->execute();
     }
     return 0;
 }
Beispiel #14
0
 public function getNewMessagesCount()
 {
     return Message::find()->where(['recipient_id' => $this->id])->andWhere(['active' => 1])->count();
 }
Beispiel #15
0
 /**
  * @inheritdoc
  */
 public function getDialogMessages(Message $dialog, $offset = null)
 {
     $subQuery = new Query();
     $messages = Message::find()->selectDate()->from("(" . $subQuery->select('*')->from('message')->where('({{message}}.from = :fid OR {{message}}.to = :fid) AND ({{message}}.from = :tid OR {{message}}.to = :tid)')->params([':fid' => $dialog->from, ':tid' => $dialog->to])->orderBy(['id' => SORT_DESC, 'created_at' => SORT_ASC])->offset($offset)->limit($this->limit)->createCommand()->getRawSql() . ") as m")->with(['sender', 'recipient', 'photos'])->orderBy('m.id')->all();
     return ArrayHelper::mapByColumn($messages, 'date');
 }
Beispiel #16
0
<?php

use yii\helpers\Html;
/* @var $this \yii\web\View */
/* @var $content string */
$model = \common\models\User::findOne(['id' => Yii::$app->user->getId()]);
$postCount = \common\models\Post::find()->where(['user_id' => $model['id']])->count();
$friendCount = \common\models\Relationship::find()->where(['user_id_1' => $model['id'], 'status' => 1])->count() + \common\models\Relationship::find()->where(['user_id_2' => $model['id'], 'status' => 1])->count();
$listNewRelNotify = \common\models\RelationshipNotification::find()->where(['receive_id' => Yii::$app->user->getId()])->orderBy('status')->limit(20)->asArray()->all();
$newRelNotifyCount = \common\models\RelationshipNotification::find()->where(['receive_id' => Yii::$app->user->getId(), 'status' => 0])->count();
$listNewMsgNotify = \common\models\Message::find()->where(['receiver_id' => Yii::$app->user->getId()])->orderBy('is_notified')->limit(20)->asArray()->all();
$newMsgNotifyCount = \common\models\Message::find()->where(['receiver_id' => Yii::$app->user->getId(), 'is_notified' => 0])->count();
?>

<header class="main-header">

    <?php 
echo Html::a('<span class="logo-mini">APP</span><span class="logo-lg">' . Yii::$app->name . '</span>', Yii::$app->homeUrl, ['class' => 'logo']);
?>

    <nav class="navbar navbar-static-top" role="navigation">

        <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
            <span class="sr-only">Toggle navigation</span>
        </a>

        <div class="navbar-custom-menu">

            <ul class="nav navbar-nav">

                <!-- Messages: style can be found in dropdown.less-->
Beispiel #17
0
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Message::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }