示例#1
0
 function _streamDirect($user_id, $offset = 0, $limit = NOTICES_PER_PAGE, $since_id = 0, $max_id = 0)
 {
     $reply = new Reply();
     $reply->profile_id = $user_id;
     if ($since_id != 0) {
         $reply->whereAdd('notice_id > ' . $since_id);
     }
     if ($max_id != 0) {
         $reply->whereAdd('notice_id <= ' . $max_id);
     }
     $reply->orderBy('notice_id DESC');
     if (!is_null($offset)) {
         $reply->limit($offset, $limit);
     }
     $ids = array();
     if ($reply->find()) {
         while ($reply->fetch()) {
             $ids[] = $reply->notice_id;
         }
     }
     return $ids;
 }
示例#2
0
 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';
     }
 }