Example #1
0
 public static function unreadInboxMessageAlert()
 {
     $new = Message::where('to', '=', Auth::user()->id)->where('checked', '=', 0)->where('type', '=', 1);
     $data['count'] = $new->count();
     $data['messages'] = $new->get()->toArray();
     //tt($data);
     return $data;
 }
Example #2
0
 public static function unreadInboxMessageAlert($type)
 {
     $new = Message::where('to', '=', Auth::user()->id)->where('checked', '=', 0)->where('type', '=', 1);
     $data['count'] = $new->count();
     if ($type === 'list' || $type === 'all') {
         $data['messages'] = $new->get()->toArray();
     }
     return $data;
 }
 public function beheer()
 {
     if (Auth::check()) {
         $messages = Message::where('status', '=', 'unsolved')->get();
         return View::make('users.admin.beheer', ['messages' => $messages]);
     } else {
         return Redirect::to('/');
     }
 }
 public function messageList()
 {
     if (Auth::user()->role == 1) {
         $messages = Message::all();
         return View::make('backend.user.messagelist')->with('data', $messages);
     } elseif (Auth::user()->role == 2) {
         $messages = Message::where('recipient_id', '=', Auth::user()->id)->orWhere('mass_message', '=', 1)->get();
         return View::make('backend.user.messagelist')->with('data', $messages);
     }
 }
Example #5
0
 public function quickView($id)
 {
     $msg = Message::where('id', '=', $id);
     $msgx = $msg->where('to', '=', Auth::user()->id)->get()->toArray();
     $msgx = empty($msgx) ? tt('Access denied to this message') : $msgx[0];
     //tt($msg->get()->toArray());
     $msg->update(array('checked' => 1));
     //tt($msg);
     $data['msg'] = $msgx;
     return View::make('quickview_messagealert', $data);
 }
Example #6
0
 public function getUserMsg($interlocutor_id)
 {
     $user_id = Auth::user()->id;
     $messages = Message::where(function ($query) use($interlocutor_id, $user_id) {
         $query->where('addressee_id', $interlocutor_id)->where('sender_id', $user_id);
     })->orWhere(function ($query) use($interlocutor_id, $user_id) {
         $query->where('addressee_id', $user_id)->where('sender_id', $interlocutor_id);
     })->orderBy('created_at', 'desc')->paginate(20);
     $interlocutor = array('id' => $interlocutor_id, 'name' => User::where('id', $interlocutor_id)->pluck('name'));
     Message::where('addressee_id', $user_id)->where('sender_id', $interlocutor_id)->update(array('isread' => 1));
     $view = array('messages' => $messages, 'addressee' => $interlocutor);
     return View::make('user.msg.user-msg', $view);
 }
Example #7
0
 public function infinite($chan, $direction, $id)
 {
     $channel = Channel::where('name', $chan)->firstOrFail();
     $log = Message::findOrFail($id);
     // Build the query to fetch logs with
     if ($direction === 'up') {
         $logs = Message::where('channel', $channel->sid)->where('ts', '<', "{$log->ts}")->orderBy('ts', 'desc')->take($this->ajaxLoad)->get();
     } else {
         $logs = Message::where('channel', $channel->sid)->where('ts', '>', "{$log->ts}")->orderBy('ts', 'asc')->take($this->ajaxLoad)->get();
     }
     $logs = Message\Repository::convertCollection($logs);
     $loadMore = null;
     if (count($logs) === $this->ajaxLoad) {
         $loadMore = end($logs)->_id;
     }
     if ($direction === 'up') {
         $logs = array_reverse($logs);
     }
     return View::make('partials.logs', compact('chan', 'logs'))->with('more' . $direction, $loadMore);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($url, $key)
 {
     $fbua = ["facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)", "facebookexternalhit/1.1 (+https://www.facebook.com/externalhit_uatext.php)", "facebookexternalhit/1.0 (+http://www.facebook.com/externalhit_uatext.php)", "facebookexternalhit/1.0 (+https://www.facebook.com/externalhit_uatext.php)", "facebookexternalhit/1.2 (+http://www.facebook.com/externalhit_uatext.php)", "facebookexternalhit/1.2 (+https://www.facebook.com/externalhit_uatext.php)"];
     if (in_array(Request::header('User-Agent'), $fbua)) {
         return View::make('messages.show', ['body' => '']);
     }
     // Fetch our message
     $msg = Message::where('url', '=', $url)->first();
     if ($msg->destroyed) {
         $body = "This message has been destroyed";
     } else {
         // Decrypt it
         $iv = $msg->iv;
         $body = mcrypt_decrypt(MCRYPT_BLOWFISH, $key, $msg->body, MCRYPT_MODE_CFB, $iv);
         // Destroy the message
         $msg->body = null;
         $msg->destroyed = true;
         $msg->save();
     }
     return View::make('messages.show', ['body' => $body]);
 }
 public function getIndex()
 {
     $this->pusher = App::make('pusher');
     $this->user = Auth::user();
     $this->chatChannel = self::DEFAULT_CHAT_CHANNEL;
     $this->friends = Enroll::getFriends(\Auth::user());
     if (!$this->user) {
         return redirect('auth/login');
     }
     if (!$this->friends) {
         return redirect('/main');
     }
     if (\Input::get('friend')) {
         $current_friend = \Input::get('friend');
     } else {
         $current_friend = $this->friends[0];
     }
     $messages = Message::where('from_user_id', '=', $this->user->id)->where('to_user_id', '=', $current_friend->id)->orWhere(function ($query) use($current_friend) {
         $query->where('from_user_id', '=', $current_friend->id)->where('to_user_id', '=', $this->user->id);
     })->get();
     return view('chat', ['chatChannel' => $this->chatChannel, 'friends' => $this->friends, 'messages' => $messages, 'current_friend' => $current_friend]);
 }
Example #10
0
 public function sentMessages()
 {
     $sentMessages = Message::where('from_user_id', Auth::user()->id)->orderBy('created_at', 'desc')->paginate(8);
     return $sentMessages;
 }
 public function checkMsgTypeUsed($type_id)
 {
     $count = Message::where('type_id', '=', $type_id)->count();
     if ($count > 0) {
         return true;
     } else {
         return false;
     }
 }
Example #12
0
 public function showActu()
 {
     return View::make('actu')->with('position', Position::all())->with('messages', Message::where('active', '>', 0)->get());
 }
 public function sendMails()
 {
     //gedeelte dat mails verstuurd wanneer er iets deffect of vermist is
     $teachers = User::where('type', '=', 'teacher')->get();
     $messages = Message::where('status', '=', 'unsolved')->where('mailsend', '=', false)->get();
     if (!$messages->isEmpty()) {
         Mail::send('emails.message', array('messages' => $messages), function ($message) use($teachers) {
             foreach ($teachers as $teacher) {
                 $message->to($teacher->email, $teacher->lastname . ' ' . $teacher->firstname)->subject("Alle berichten van uitleendienst");
             }
         });
     }
     foreach ($messages as $message) {
         $message->mailsend = true;
         $message->save();
     }
     //gedeelte dat studenten op de hoogt brengt wanneer hun materiaal nog niet binnen is wanneer iemand anders zijn reservatie start
     // de gebruikers + details van reservatie waarvan het materiaal nog niet binnen is of het gebroken of vermist is
     $usersMaterialNotAvailable = $this->reservation->checkMaterialAvailable();
     if (!empty($usersMaterialNotAvailable)) {
         foreach ($usersMaterialNotAvailable as $reservation) {
             Mail::send('emails.notavailable', array('reservation' => $reservation), function ($message) use($reservation) {
                 $message->to($reservation->email, $reservation->lastname . ' ' . $reservation->firstname)->subject('materiaal voor reservatie niet binnen');
             });
         }
     }
     // gedeelte waarbij student op de hoogte word gebracht wanneer materiaal niet binnen is na de opgegeven eind tijd
     $usersMaterialBringback = $this->reservation->checkMaterialBroughtBack();
     if (!empty($usersMaterialBringback)) {
         foreach ($usersMaterialBringback as $reservation) {
             Mail::send('emails.bringBack', array('reservation' => $reservation), function ($message) use($reservation) {
                 $message->to($reservation->email, $reservation->lastname . ' ' . $reservation->firstname)->subject('materiaal voor reservatie niet binnen gebracht');
             });
         }
     }
 }
Example #14
0
 public static function textSearch(\Channel $channel, $q)
 {
     $results = \Message::where('channel', $channel->sid)->where('text', 'like', "%{$q}%")->take(static::$downLimit + static::$upLimit)->orderBy('ts', 'desc')->get();
     return static::convertCollection($results);
 }
 public function deleteUser()
 {
     $id = Input::get('userId');
     $test_user = DB::table('admin_option')->where('option_name', 'Test User Emails')->select('option_value')->get();
     if (!empty($test_user)) {
         $count = 0;
         foreach ($test_user as $value) {
             foreach (explode(',', $value->option_value) as $test_user_id) {
                 if ($id == $test_user_id) {
                     $count = $count + 1;
                 }
             }
         }
     } else {
         $count = 0;
     }
     if ($count > 0) {
         $connections = Connection::Where('user_id', '=', $id)->first();
         if (!empty($connections)) {
             $connections->user_id = null;
             $connections->save();
         }
         $deletekarmanote = Karmanote::where('user_idreceiver', '=', $id)->delete();
         $deletekarmanote = Karmanote::where('user_idgiver', '=', $id)->delete();
         $deleterequest = Meetingrequest::where('user_id_receiver', '=', $id)->delete();
         $deletekarmanote = Meetingrequest::where('user_id_giver', '=', $id)->delete();
         $deletekarmanote = Meetingrequest::where('user_id_introducer', '=', $id)->delete();
         $deleteusergroups = Usersgroup::where('user_id', '=', $id)->delete();
         $findquestion = Question::Where('user_id', '=', $id)->get();
         if (!empty($findquestion)) {
             foreach ($findquestion as $val) {
                 $question_id = $val->id;
                 $findgroupquestion = Groupquestion::Where('question_id', '=', $question_id)->get();
                 if (!empty($findgroupquestion)) {
                     $deletegroupquestion = Groupquestion::Where('question_id', '=', $question_id)->delete();
                 }
                 $findQuestionwillingtohelp = Questionwillingtohelp::Where('question_id', '=', $question_id)->get();
                 if (!empty($findQuestionwillingtohelp)) {
                     $deleteQuestionwillingtohelp = Questionwillingtohelp::Where('question_id', '=', $question_id)->delete();
                 }
             }
         }
         $deleteQuestionwillingtohelp = Questionwillingtohelp::Where('user_id', '=', $id)->delete();
         if (!empty($findquestion)) {
             $deletequestion = Question::where('user_id', '=', $id)->delete();
         }
         $deletekarmacircles = Karmacircle::where('user_id', '=', $id)->delete();
         $deletekarmaFeed = Karmafeed::where('receiver_id', '=', $id)->orWhere('giver_id', '=', $id)->delete();
         $userMykarmaDelete = Mykarma::where('user_id', '=', $id)->delete();
         $userMessageDelete = Message::where('receiver_id', '=', $id)->orWhere('giver_id', '=', $id)->delete();
         $getIntroDataDelete = KarmaIntro::where('intro_giver_id', '=', $id)->orWhere('intro_receiver_id', '=', $id)->orWhere('intro_introducer_id', '=', $id)->delete();
         $getMyKarmaDataDelete = Mykarma::where('user_id', '=', $id)->delete();
         $user = User::find($id);
         $user->delete();
         echo "User " . $id . " deleted";
     } else {
         echo "User " . $id . " cant be deleted.Its not a test user.";
     }
 }
Example #16
0
 public function showMessages()
 {
     // Only show the messages from this day
     $messages = Message::where('published_at', '>', date('Y-m-d') . ' 00:00:00')->where('published_at', '<=', date('Y-m-d') . ' 23:59:59')->orderBy('published_at', 'desc')->get();
     return View::make('live', compact('messages'));
 }
Example #17
0
 public function message_history()
 {
     return Message::where('object_id', '=', $this->id)->orderBy('id', 'desc')->get();
 }
Example #18
0
 public static function countUnreadMessages($user_fp)
 {
     return Message::where('user_fp', '=', $user_fp)->where('unread', '=', '1')->count();
 }
Example #19
0
 private function markAsRead($chat, $user)
 {
     $deliverState = false;
     foreach ($chat->getMembersTokens(true) as $token) {
         MessageUnread::whereRaw('chat_id = ' . $chat->id)->get()->each(function ($unread) use($chat, $user, $deliverState) {
             if ($unread->user_id == $user->id) {
                 $unread->delete();
                 Message::where('chat_id', $chat->id)->whereNull('delivered_at')->get()->map(function ($message) use($chat, $user, $deliverState) {
                     if (!$message->delivered_at) {
                         $message->delivered_at = Carbon::now();
                     }
                     if (!$message->viewed_at) {
                         $message->viewed_at = Carbon::now();
                     }
                     $message->save();
                 });
             }
         });
         $state = new StateSender($token);
         if ($deliverState) {
             $state->setChatAsDelivered($chat->id, $user->id);
         }
         $state->setChatAsRead($chat->id, $user->id);
         $state->send();
     }
     $this->updateCounts($chat);
     return $this;
 }
Example #20
0
 /**
  * 获取未读消息数
  *
  * @param int   $user_id
  * @return int
  */
 function unread_message_count($user_id = 0)
 {
     $unread_count = 0;
     if (Auth::check()) {
         $user_id = !$user_id ? Auth::user()->id : $user_id;
         $unread_count = Message::where('user_id', $user_id)->where('type', '>', 1)->where('is_readed', 0)->count();
     }
     return $unread_count;
 }
Example #21
0
 /**
  * Login form processing.
  *
  * @access   public
  * @return   Redirect
  */
 public function postModerer($id)
 {
     $mess = Message::where('id', '=', $id)->first();
     if (Input::get('modifier') !== null) {
         if ($mess->active == 1) {
             $mess->update(array('active' => 0));
         } else {
             $mess->update(array('active' => 1));
         }
     } else {
         $mess->delete();
     }
     return Redirect::to('moderer')->with('success', 'Logged out with success!');
 }
Example #22
0
 public function message()
 {
     $user_id = Input::get('user_id');
     $user = User::find($user_id);
     $messages = Message::where('receiver_id', '=', $user_id)->orderBy("created_at", "desc")->get();
     foreach ($messages as $message) {
         $message['sender'] = User::find($message['sender_id'])->username;
         $message['avatar'] = User::find($message['sender_id'])->avatar;
         $message['messageCommentCount'] = $message->MessageComments()->count();
         $message['comments'] = MessageComment::where("message_id", "=", $message->id)->orderBy("created_at")->get();
         foreach ($message["comments"] as &$comment) {
             $comment["sender_name"] = User::find($comment["sender_id"])->username;
             $comment["receiver_name"] = User::find($comment["receiver_id"])->username;
             $comment["sender_avatar"] = User::find($comment["sender_id"])->avatar;
         }
     }
     return View::make('userCenter.message')->with(array('messages' => $messages, 'user' => $user, 'links' => $this->link()));
 }
Example #23
0
 public function messages()
 {
     // return $this->hasMany('Message')->get();
     return Message::where('from', $this->email)->orWhere('to', $this->email)->get();
 }
 public function searchConversationByID()
 {
     $input = Input::all();
     $user = Auth::user();
     $messages = array();
     $umessages = Message::where('to', '=', $user['id'])->where('from', $input['id'])->get();
     $imessages = Message::where('to', '=', $input['id'])->where('from', $user['id'])->get();
     //echo($input['id']);
     $i = 0;
     foreach ($umessages as $umessage) {
         if (true) {
             $tou = DB::select('select * from users where id = ?', array($umessage->to));
             $fromu = DB::select('select * from users where id = ?', array($umessage->from));
             $messages['user']['firstname'] = ucfirst($tou[0]->firstname);
             $messages['user']['lastname'] = ucfirst($tou[0]->lastname);
             $messages['list'][$i]['id'] = $umessage->id;
             $messages['list'][$i]['message'] = $umessage->message;
             $messages['list'][$i]['from'] = $umessage->from;
             $messages['list'][$i]['to'] = $umessage->to;
             $messages['list'][$i]['pic'] = base64_decode($fromu[0]->picture);
             $messages['list'][$i]['tousername'] = $tou[0]->firstname . " " . $tou[0]->lastname;
             $messages['list'][$i]['fromusername'] = $fromu[0]->firstname . " " . $fromu[0]->lastname;
             if ($umessage->from == $user['id']) {
                 $messages['list'][$i]['type'] = 'current_user';
             }
             $m = new \MomentPHP\MomentPHP($umessage->updated_at);
             $momentFromVo = $m->fromNow();
             $messages['list'][$i]['updated_at'] = $momentFromVo;
             $i++;
         }
     }
     foreach ($imessages as $imessage) {
         if (true) {
             $tou = DB::select('select * from users where id = ?', array($imessage->to));
             $fromu = DB::select('select * from users where id = ?', array($imessage->from));
             $messages['user']['firstname'] = ucfirst($tou[0]->firstname);
             $messages['user']['lastname'] = ucfirst($tou[0]->lastname);
             $messages['list'][$i]['id'] = $imessage->id;
             $messages['list'][$i]['message'] = $imessage->message;
             $messages['list'][$i]['from'] = $imessage->from;
             $messages['list'][$i]['to'] = $imessage->to;
             $messages['list'][$i]['pic'] = base64_decode($fromu[0]->picture);
             $messages['list'][$i]['tousername'] = $tou[0]->firstname . " " . $tou[0]->lastname;
             $messages['list'][$i]['fromusername'] = $fromu[0]->firstname . " " . $fromu[0]->lastname;
             if ($imessage->from == $user['id']) {
                 $messages['list'][$i]['type'] = 'current_user';
             }
             $m = new \MomentPHP\MomentPHP($imessage->updated_at);
             $momentFromVo = $m->fromNow();
             $messages['list'][$i]['updated_at'] = $momentFromVo;
             $i++;
         }
     }
     //print_r($messages);
     return $messages;
 }
Example #25
0
 public function readAllMessages()
 {
     $messages = Message::where('to_user_id', Auth::user()->id)->update(['read' => true]);
     return Redirect::to('/message');
 }
Example #26
0
 /**
  * Clear the chat.
  *
  * @param $chatId Chat ID
  * @return Response
  */
 public function clearChatHistory($chatId)
 {
     if (($chat = Chat::find($chatId)) && $chat->hasMember(Auth::user()->id)) {
         $lastMessage = Message::where('chat_id', $chat->id)->orderBy('id', 'desc')->take(1)->get()->first();
         ChatCleared::whereRaw('chat_id = ? and user_id = ?', array($chat->id, Auth::user()->id))->delete();
         $cleared = new ChatCleared();
         $cleared->chat_id = $chat->id;
         $cleared->user_id = Auth::user()->id;
         $cleared->message_id = $lastMessage->id;
         $cleared->save();
         return $this->respondNoContent();
     } else {
         return $this->respondWithError('Chat isn\'t found');
     }
 }
 /**
  * Display a listing of messages.
  *
  * @return Response
  */
 public function index()
 {
     $conversation = Conversation::where('name', Input::get('conversation'))->first();
     $messages = Message::where('conversation_id', $conversation->id)->orderBy('created_at')->get();
     return View::make('templates/messages')->with('messages', $messages)->render();
 }