public function edit()
 {
     $message = Message::find($this->request->id);
     if ($this->request->data && $message->save($this->request->data)) {
         return compact('message');
     } else {
         return array('errors' => $message->errors());
     }
 }
Пример #2
0
 public function actionIndex()
 {
     $curUser = \Yii::$app->user->id;
     UserSettingsBlock::sync($curUser);
     //todo return data model
     $block = Block::find()->with('links')->where(['hidden' => Block::STATUS_SHOW, 'type' => Block::TYPE_TAB])->orderBy('order')->all();
     $model = UserSettingsBlock::find()->with('block')->orderBy('column, order')->where(['{{%user_settings_block}}.user_id' => $curUser])->all();
     $msg = Message::find()->where(['status' => Message::STATUS_SHOW])->all();
     return $this->render('index', ['model' => $model, 'blocks' => $block, 'messages' => $msg, 'link' => Link::getLinksBlocks()]);
 }
Пример #3
0
 public function actionList()
 {
     $messages = Message::find()->where(['is_visible' => true])->orderBy('timestamp desc')->all();
     $model = new Message();
     if ($model->load(Yii::$app->request->post())) {
         $model->save();
         $this->redirect(['list']);
     }
     return $this->render('list', ['messages' => $messages, 'model' => $model]);
 }
 public function actionEdit()
 {
     $languages = Message::getLanguages();
     $model = new Message();
     $model->language = $_GET['language'];
     $model->file = $_GET['file'];
     $model->messageId = $_GET['message-id'];
     $model->message = Message::find($_GET['language'], $_GET['file'], $_GET['message-id']);
     $files = Message::getFiles($_GET['language']);
     return $this->render('edit', array('languages' => $languages, 'files' => $files, 'language' => $model->language, 'file' => $model->file, 'message' => $model->message, 'messageId' => $model->messageId));
 }
Пример #5
0
 public function bootstrap()
 {
     $messages = Message::find('all', array('order' => array('created' => -1), 'limit' => 20));
     $messages = $messages->map(function ($model) {
         $arr = $model->to('array');
         $arr['id'] = $arr['_id'];
         unset($arr['_id']);
         return $arr;
     }, array('collect' => false));
     $messages = json_encode($messages);
     return compact('messages');
 }
Пример #6
0
 public function actionDelMessage()
 {
     if (!Yii::$app->user->isGuest && Yii::$app->user->identity->isAdmin()) {
         $post = Yii::$app->request->post();
         if ($post['id']) {
             $message = Message::find()->where(['id' => $post['id']])->one();
             if ($message) {
                 $message->delete();
             }
         }
     }
 }
Пример #7
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]);
     $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]);
     $query->andFilterWhere(['like', 'language', $this->language])->andFilterWhere(['like', 'translation', $this->translation]);
     return $dataProvider;
 }
Пример #8
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]);
     $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, 'timestamp' => $this->timestamp, 'creator_id' => $this->creator_id, 'is_visible' => $this->is_visible]);
     $query->andFilterWhere(['like', 'content', $this->content]);
     return $dataProvider;
 }
Пример #9
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Message::find();
     $query->joinWith(['editor']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['editor'] = ['asc' => ['bnm_users.name' => SORT_ASC]];
     $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, 'user' => $this->user, 'date' => $this->date, 'type' => $this->type]);
     $query->andFilterWhere(['like', 'bnm_media.name', $this->name])->andFilterWhere(['like', 'desp', $this->desp])->andFilterWhere(['like', 'author', $this->author])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'bnm_users.name', $this->editor])->andFilterWhere(['like', 'thumbnail', $this->thumbnail]);
     return $dataProvider;
 }
Пример #10
0
 public function searchOwnMessages($params)
 {
     $query = Message::find()->joinWith(['sender' => function ($query) {
         $query->from(['senderName' => 'user']);
     }]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['senderName.username'] = ['asc' => ['senderName.username' => SORT_ASC], 'desc' => ['senderName.username' => SORT_DESC]];
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->joinWith('senderName');
     //$query->where(['like', 'senderName.username', $this->sender]);
     $query->andFilterWhere(['content' => $this->content])->andFilterWhere(['like', 'senderName.username', $this->sender])->andFilterWhere(['like', 'created_at', $this->created_at])->andFilterWhere(['receiver' => Yii::$app->user->identity->id]);
     return $dataProvider;
 }
Пример #11
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Message::find();
     $query->joinWith('sender');
     ///$query->select($_columns);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $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, 'sender_id' => $this->sender_id, 'seen_at' => $this->seen_at]);
     $query->andFilterWhere(['like', 'message', $this->message])->andFilterWhere(['like', 'status', $this->status])->orderBy('send_at DESC');
     return $dataProvider;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make(Input::all(), Message::rules(), [], Message::niceNames());
     if ($validator->fails()) {
         $error = $validator->errors();
         $data['success'] = false;
     } else {
         $input = Request::all();
         $message = Message::create($input);
         $id = $message->id;
         $data = Message::find($id)->toArray();
         $data['user2_accountname'] = $input['user2_accountname'];
         $id_conv2 = $input['conversation2_id'];
         $conversation2 = Conversation::find($id_conv2);
         $conversation2->unseen++;
         $conversation2->save();
         $data['success'] = true;
     }
     return json_encode($data);
 }
Пример #13
0
 public function actionView($id)
 {
     $message = Message::findOne($id);
     $messages = Message::find()->where(['number' => $message->number])->all();
     $model = Project::findOne($message->project_id);
     $reply = new Message();
     foreach ($messages as $item) {
         $item->status = 4;
         $item->save();
     }
     if ($reply->load(Yii::$app->request->post()) && $reply->validate()) {
         // $reply->user_id =
         $reply->project_id = $message->project_id;
         $reply->status = 1;
         $reply->time = time();
         $reply->type = 'text';
         $reply->save();
         // Send twilio Text through project model
         $model->sendText([$message->user_id], $reply->message);
         Yii::$app->session->setFlash('success', 'Message Sent');
         $this->redirect(['/project/messages', 'id' => $message->project_id]);
     }
     return $this->render('view', ['message' => $message, 'messages' => $messages, 'model' => $model, 'reply' => $reply]);
 }
Пример #14
0
 public function actionMessages($id)
 {
     $messages = \app\models\Message::find()->where(['project_id' => $id])->andWhere('status != 3')->andWhere('status != 1')->limit(999)->orderBy('time DESC')->all();
     $model = Project::findOne($id);
     return $this->render('messages', ['messages' => $messages, 'model' => $model]);
 }
Пример #15
0
 public function actionNewmsglist()
 {
     $user_id = Yii::$app->user->identity->id;
     $res = Message::find()->select('from')->where(['`to`' => $user_id, '`status`' => 0])->asArray()->all();
     //$res = count($res);
     //print_r($res);
     return json_encode($res);
 }
Пример #16
0
 /**
  * Display the specified resource.
  * GET /inbox/{message}
  *
  * @param  Message  $message
  * @return Response
  */
 public function read($id)
 {
     $message = Message::find($id);
     if ($message == null) {
         return Redirect::to('inbox');
     }
     $user = Auth::user();
     if ($message->recipient_id == $user->id && $message->last_reply <= $message->created_at) {
         $message->unread = 0;
         $message->save();
     } elseif ($message->sender_id == $user->id && $message->receiver_replied == 1) {
         $message->receiver_replied = 0;
         $message->save();
     }
     foreach ($message->unreadReplies as $reply) {
         if ($reply->recipient_id == $user->id) {
             $reply->unread = 0;
             $reply->save();
         }
     }
     return View::make($user->role->name . '.messages.read')->withMessage($message);
 }
Пример #17
0
 public function actionMedia($type, $cat = 0, $order = 'date', $asc = 'desc', $name = "", $desp = "", $author = "")
 {
     $query;
     $typeid;
     if ($type == 'album') {
         $query = Album::find();
         $typeid = 0;
     } else {
         if ($type == 'video') {
             $query = Video::find();
             $typeid = 1;
         } else {
             $query = Message::find();
             $typeid = 2;
         }
     }
     $pagination = new Pagination(['defaultPageSize' => 30, 'totalCount' => $query->count()]);
     $query->distinct();
     $catArr = [];
     if ($cat) {
         $query->joinWith("category");
         $catArr = explode(',', $cat);
         $query->andWhere(['or', ['bnm_category_relationships.category' => $catArr]]);
     }
     $query->joinWith("editor");
     $query->andFilterWhere(['like', 'bnm_media.name', $name]);
     $query->andFilterWhere(['like', 'bnm_media.desp', $desp]);
     $query->orderBy($order . ' ' . $asc)->offset($pagination->offset)->limit($pagination->limit);
     //->asArray()
     //
     $catQuery = Category::find()->joinWith("categoryRelationship")->andWhere(['bnm_category_relationships.type' => $typeid])->distinct();
     return $this->render('media', ['media' => $query->all(), 'categories' => $catQuery->all(), 'pagination' => $pagination, 'catArr' => $catArr, 'catUrl' => $cat, 'oldCat' => ['cat' => $cat], 'oldOrder' => ['order' => $order, 'asc' => $asc], 'oldSearch' => ['name' => $name, 'desp' => $desp, 'author' => $author], 'type' => $type, 'typeid' => $typeid, 'asc' => $asc, 'order' => $order, 'name' => $name, 'desp' => $desp, 'author' => $author]);
 }
Пример #18
0
 public function messageAction()
 {
     $where = '1=1';
     if ($this->request->isPost()) {
         if ($this->request->getPost("search") == 1) {
             empty($this->request->getPost("keyword", "string")) || ($where .= " and keyword like '%" . $this->request->getPost("keyword", "string") . "%'");
             empty($this->request->getPost("type", "int")) || ($where .= " and type=" . $this->request->getPost("type", "int"));
             //                $this->view->disable();
             //                echo $where;
             //                exit;
         } else {
             $message = new Message();
             $message->setKeyword($this->request->getPost("keyword", "string"));
             $message->setType($this->request->getPost("type", "int"));
             if ($this->request->getPost("type") == 2) {
                 if ($this->request->hasFiles() == true) {
                     $content = $this->request->getPost("content");
                     $title = $this->request->getPost("title");
                     $url = $this->request->getPost("url");
                     $img = array();
                     foreach ($this->request->getUploadedFiles() as $file) {
                         if ($file->getError()) {
                             exit($file->getError());
                         }
                         $filename = $this->config->uploadDir . uniqid() . "." . $file->getExtension();
                         $file->moveTo(APP_PATH . "/public" . $filename);
                         $filename = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . $filename;
                         array_push($img, $filename);
                     }
                     $message->setUrl(htmlspecialchars(json_encode($url)));
                     $message->setContent(htmlspecialchars(json_encode($content)));
                     $message->setTitle(htmlspecialchars(json_encode($title)));
                     $message->setImg(json_encode($img));
                     $message->create();
                 } else {
                     exit("图片上传错误");
                 }
             } else {
                 $message->setContent($this->request->getPost("content", "string")[0]);
                 $message->create();
             }
         }
     }
     if ($message = Message::find($where)) {
         $arr = array();
         $message->rewind();
         while ($message->valid()) {
             $n = $message->current();
             if ($n) {
                 $r['id'] = $n->getId();
                 $r['keyword'] = $n->getKeyword();
                 $r['type'] = $n->getType();
                 $r['title'] = $n->getTitle();
                 $r['content'] = $n->getContent();
                 $r['img'] = $n->getImg();
                 $r['url'] = $n->getUrl();
                 array_push($arr, $r);
             }
             $message->next();
         }
         $this->view->messages = $arr;
     }
 }
Пример #19
0
NavBar::begin(['brandLabel' => Yii::$app->name, 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'encodeLabels' => false, 'items' => [['label' => 'Home', 'url' => ['/site/index']], Yii::$app->user->isGuest ? ['label' => 'Login', 'url' => ['/site/login']] : ['label' => Html::img(Yii::$app->user->identity->avatar_md, ['class' => 'avatar img-circle']), 'linkOptions' => ['class' => 'hasAvatar'], 'items' => [['label' => 'Logout', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']]]]]]);
NavBar::end();
?>

    <div class="container">
        <div class="row">
            <div class="col-sm-6 col-sm-offset-3">
                <div class="chat panel panel-default">
                    <div class="panel-heading">
                        Chat
                    </div>
                    <div class="panel-body">
                        <div id="chat">
                            <?php 
foreach (\app\models\Message::find()->limit(8)->orderBy('date DESC')->all() as $msg) {
    ?>
                                <div class="chat-post" data-steamid="<?php 
    echo $msg->steamid;
    ?>
">
                                    <a href="<?php 
    echo $msg->user->profile_url;
    ?>
" target="_blank">
                                        <img class="chat-avatar img-circle" src="<?php 
    echo $msg->user->avatar_md;
    ?>
">
                                    </a>
                                    <dl class="chat-body">
Пример #20
0
 public function getMessageCount()
 {
     $message_count = \app\models\Message::find()->where(['project_id' => $this->id])->andWhere('status != 3')->andWhere('status != 4')->andWhere('status != 1')->limit(999)->orderBy('time DESC')->count();
     return $message_count;
 }
Пример #21
0
 public function actionDashboard()
 {
     $projectGraphs = NULL;
     $availableGraph = NULL;
     $unavailableGraph = NULL;
     $finalListGraph = NULL;
     $requestsGraph = NULL;
     // Get Messages
     $messages = \app\models\Message::find()->andWhere('status != 3')->andWhere('status != 1')->limit(15)->orderBy('time DESC')->all();
     // Get Project Data
     $projectDataProvider = new ActiveDataProvider(['query' => \app\models\Project::find()->orderBy('date DESC')->limit(5), 'pagination' => ['pageSize' => 5]]);
     // Get Talent Data
     $personDataProvider = new ActiveDataProvider(['query' => \app\models\Person::find()->orderBy('date_updated DESC')->limit(5), 'pagination' => ['pageSize' => 5]]);
     // Get data for graphs
     $projects = \app\models\Project::find()->limit(5)->all();
     foreach ($projects as $project) {
         $projectGraphs[] = $project->title;
         $finalListGraph[] = \app\models\Project::countList($project->id, 2);
         $availableGraph[] = \app\models\Project::countList($project->id, 1, 3);
         $unavailableGraph[] = \app\models\Project::countList($project->id, 1, 4);
         $requestsGraph[] = \app\models\Project::countList($project->id, 1, 2);
     }
     Yii::$app->view->title = 'Dashboard';
     return $this->render('dashboard', ['messages' => $messages, 'projectDataProvider' => $projectDataProvider, 'personDataProvider' => $personDataProvider, 'projectGraphs' => $projectGraphs, 'availableGraph' => $availableGraph, 'unavailableGraph' => $unavailableGraph, 'finalListGraph' => $finalListGraph, 'requestsGraph' => $requestsGraph]);
 }
Пример #22
0
 /**
  * Lists all Message models.
  * @return mixed
  */
 public function actionIndex()
 {
     return $this->render('index', ['messages' => Message::find()->all()]);
 }
Пример #23
0
 /**
  * Lists all Message models.
  * @return mixed
  */
 public function actionIndex()
 {
     $model = Message::find()->all();
     return $this->render('index', ['model' => $model]);
 }
Пример #24
0
 public function actionList()
 {
     $dataProvider = new ActiveDataProvider(['query' => Message::find(), 'pagination' => array('pageSize' => 25)]);
     return $this->render('list', ['dataProvider' => $dataProvider]);
 }
Пример #25
0
 /**
  * Lists all Message models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Message::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
Пример #26
0
 public function actionIndex()
 {
     $count = ['clients' => count(Client::find()->all()), 'websites' => count(Website::find()->all()), 'checklists' => count(Checklist::find()->all()), 'messages' => count(Message::find()->all())];
     return $this->render('index', ['count' => $count]);
 }
Пример #27
0
<?php

/* @var $this yii\web\View */
use app\models\Message;
use kartik\file\FileInput;
use yii\helpers\Url;
use app\models;
$this->title = 'Messenger';
?>
<div class="site-index">
	<div class="messages">
		<h1>Messages</h1>
		<?php 
foreach (Message::find()->all() as $message) {
    ?>
			<div class="message" id="<?php 
    echo $message->id;
    ?>
">
				<h4><?php 
    echo $message->user_name;
    ?>
 says:</h4>
				<?php 
    echo $message->content;
    ?>
				<br>
				<br>
				<small><?php 
    echo date("d M H:i", strtotime($message->created_at));
    ?>