public function post_validatelogin() { $session = Session::get('vatsimauth'); return VatsimSSO::validate($session['key'], $session['secret'], Input::get('oauth_verifier'), function ($user, $request) { // At this point we can remove the session data. Session::forget('vatsimauth'); //Verify that our user is a console user $find = ConsoleUser::where('cid', '=', $user->id)->where('access', '>', -1)->count(); if ($find == 0) { return Redirect::route('index')->with('topmessage', 'Member not authorised to use VA Auditors Console'); } Auth::consoleuser()->loginUsingId($user->id); //Update the timestamp (for updated at which is used for last time logged in) ConsoleUser::find(Auth::consoleuser()->get()->cid)->touch(); return Redirect::route('console'); }, function ($error) { Redirect::route('index')->with('topmessage', 'Could not authenticate: ' . $error['message']); }); }
public function post_replyticket() { $postStr = Input::get('data'); parse_str($postStr, $post); $validator = Validator::make(array('Reply' => $post['inputReplyTicket'], 'tid' => $post['tid']), array('Reply' => 'required', 'tid' => 'required|integer'), array('Reply.required' => 'Please enter a reply.', 'tid.required' => 'The system cannot find a ticket to reply to.', 'tid.integer' => 'The system has been sent an invalid ticket id to reply to.')); //Verify some smart ass didn't try to change the hidden input field (tid) or reply to a closed ticket. $count = Ticket::where('id', '=', $post['tid'])->where('vid', '=', Auth::user()->get()->cid)->where('status', '=', '1')->count(); if ($count == 0) { //Damn them. echo '<div class="alert alert-error"><li>Seriously? Nice try.</li></div>'; } if ($validator->fails()) { $messages = $validator->messages(); $errorStr = ''; foreach ($messages->all('<li>:message</li>') as $message) { $errorStr .= '<div class="alert alert-error">' . $message . '</div>'; } echo $errorStr; } else { $reply = new Reply(); $reply->tid = $post['tid']; $reply->author = Auth::user()->get()->cid; $reply->content = $post['inputReplyTicket']; //Save our ticket update $reply->save(); //Find or reply id $reply = Reply::orderBy('updated_at', 'DESC')->first(); //Finally we need to update the updated_at field of our master ticket table $ticket = Ticket::find($post['tid']); $ticket->updated_at = $reply->updated_at; //Save our ticket update $ticket->save(); //Check to see if there is an assigned auditor. If so send them an email notification if (!empty($ticket->assigned)) { $data = array(); $auditor = ConsoleUser::find($ticket->assigned); if (!empty($auditor)) { $data['auditor'] = $auditor; $data['subject'] = "VATSIM VA New Ticket Update"; if (!empty($auditor->email)) { $body = "Hello " . ConsoleUser::getName($ticket->assigned) . ",<br /><br />There has been an update to your assigned ticket " . $ticket->subject . " by VA Administrator " . User::getFullName($ticket->vid) . ". <br /><br />" . $reply->content . "<br /><br /><br /> <strong>Do not reply to this email. If you wish to reply to this ticket, please do so through the auditor console.</strong>"; Mail::send('email.default', array("content" => $body), function ($message) use($data) { $message->to($data['auditor']->email, $data['auditor']->name)->subject($data['subject']); }); } } } //Return 1 to inform the client this was successful. echo '1'; } }