public function create($request) { $req = $request->getParameters(); $response = new ViewResponse('assist/ticket'); if (trim($req['bug']) != '') { if (Session::isActive()) { $user_id = Session::get()->id; } else { if (trim($req['email']) != '') { $user_id = $req['email']; } else { $user_id = 0; } } if (!empty(Ticket::find('all', ['conditions' => ['ip = ? AND timestamp < ' . (Utils::tps() + 60), $_SERVER['REMOTE_ADDR']]]))) { $r = $this->index($request); $r->addMessage(ViewMessage::error('Trop d\'envois avec la même IP en une minute, réssayez plus tard.')); return $r; } $ticket = Ticket::create(array('user_id' => $user_id, 'description' => $req['bug'], 'timestamp' => time(), 'ip' => $_SERVER['REMOTE_ADDR'])); StaffNotification::createNotif('ticket', $user_id, null, $ticket->id); $ticket_id = $ticket->id; $response->addMessage(ViewMessage::success('Envoyé ! Vous serez notifié de l\'avancement par E-Mail ou Message Privé (Ticket #' . $ticket_id . ')')); /*$username = (Session::isActive()) ? Session::get()->username : '******'; $notif = new PushoverNotification(); $notif->setMessage('Nouveau ticket de '.$username); $notif->setReceiver('all'); $notif->setExtraParameter('url', 'http://dreamvids.fr'.WEBROOT.'admin/tickets'); $notif->send();*/ } else { $response->addMessage(ViewMessage::error('Merci de nous décrire votre problème.')); } return $response; }
public static function validateAdd($data, $id) { if (Ticket::find($id)->replies()->count() == 0 && Ticket::find($id)->user_id == Auth::user()->id) { return View::make('msg.error')->with('error', 'You cannot double post, please wait for a staff member to reply'); } $reply = Ticket::find($id)->replies()->order_by('created_at', 'desc')->first(); if ($reply != NULL) { if ($reply->user_id == Auth::user()->id && !Auth::user()->isStaff()) { return View::make('msg.error')->with('error', 'You cannot double post, please wait for a staff member to reply'); } } $rules = array('message' => 'required|min:30|max:1000'); $messages = array('message_min' => 'Please form your reply to at least 30 characters.', 'message_max' => 'Please shorten your reply to less than 1000 characters.'); $validator = Validator::make($data, $rules, $messages); if ($validator->fails()) { $errors = $validator->errors->all(); $error_str = ''; foreach ($errors as $e) { $error_str .= $e . '<br />'; } return View::make('msg.error')->with('error', $error_str); } $data['user_id'] = Auth::user()->id; $data['ticket_id'] = $id; $data['ip'] = $_SERVER['REMOTE_ADDR']; self::create($data); $ticket = Ticket::find($id); $ticket->touch(); return Redirect::to('/support/ticket/' . $id); }
function reset_user_password($key = null) { if (!empty($this->data)) { $user = $this->Ticket->findUser($this->data['Ticket']['email']); $hasTicket = $this->Ticket->find('first', array('conditions' => array('Ticket.email' => $user['User']['email']))); //pr($hasTicket); //die; if (!empty($user) && empty($hasTicket)) { App::import('Helper', 'Time'); $time = new TimeHelper(); $key = Security::hash(String::uuid(), 'sha1', true); $this->data['Ticket']['key'] = $key; $this->data['Ticket']['creation_date'] = $time->format('Y-m-d H:i:s', time()); $url = Router::url(array('controller' => 'tickets', 'action' => 'reset_user_password'), true) . '/' . $key; //pr($url); //die; //ko se ticket shrani v bazo se poslje email (email element: lost_password_notification.ctp) useru, ki je ticket odprl if ($this->Ticket->save($this->data)) { $this->set('url', $url); $this->MyEmail->sendResetPasswordEmail($user['User']['email']); $this->Session->setFlash('notification email has been sent to you with reset data'); } } elseif (!empty($hasTicket)) { if ($this->Ticket->checkTicketDateValidity($hasTicket)) { $this->Session->setFlash('We had already sent you a link to your email address! Go get it, lazy ass!'); } else { $this->Session->setFlash('Your ticket regarding lost password has been deleted due to expiration! Try submitting again'); } } //se prozi kadar user klikne link, ki vsebuje generiran key, v svojem mailu in ga redirecta sem } elseif (isset($key) && !empty($key)) { $result = $this->Ticket->find('first', array('conditions' => array('Ticket.key' => $key))); $this->Ticket->checkTicketDateValidity($result); if (!empty($result)) { $user = $this->Ticket->findUser($result['Ticket']['email']); $this->set('userId', $user['User']['id']); $this->set('key', $key); $this->Ticket->delete($result['Ticket']['id']); //$this->redirect(array('controller' => 'users', 'action' => 'changeUserPassword/uid:'.$user['User']['id'])); } } else { $this->Session->setFlash('Please provide your email!'); } }
public function get_open($id) { $ticket = Ticket::find($id); if (empty($ticket)) { return View::make('msg.error')->with('error', 'This ticket doesn\'t exist.'); } if (!Auth::user()->isStaff()) { return View::make('msg.error')->with('error', 'You have no access to this ticket.'); } $ticket->solved = 0; $ticket->save(); return Redirect::to('/support/ticket/' . $id); }
public function updateParent() { if ($this->object_type == "ticket") { $ticket = Ticket::find($this->object_id); $ticket->status_id = $this->status_id; $ticket->save(); } else { if ($this->object_type == "incident") { $ticket = Incident::find($this->object_id); $ticket->status_id = $this->status_id; $ticket->save(); } } }
public function update($id, $request) { $param = $request->getParameters(); $ticket = Ticket::find($id); if (isset($param['new']) && $param['new']) { $level = TicketLevels::create(['label' => $param['label']]); $ticket->ticket_levels_id = $level->id; } else { $ticket->ticket_levels_id = $param['level_id']; } $ticket->save(); $r = $this->index($request); $r->addMessage(ViewMessage::success("Modification effectuée")); return $r; }
/** * Delete all tickets for an itemtype * @param the itemtype * @return nothing */ public static function deleteTicketAssignation($itemtype) { global $DB; $ticket = new Ticket(); foreach ($ticket->find("`itemtype`='{$itemtype}'") as $data) { $data['itemtype'] = ''; $data['items_id'] = 0; $ticket->update($data); } }
public function getAssignedTickets() { $tickets = Ticket::find('all', ['ticket_levels_id' => $this->getAssignedLevelsIds()]); if (is_null($tickets)) { return []; } return is_array($tickets) ? $tickets : [$tickets]; }
/** * Test pushing object without id * * @return null */ public function testPushReceiverWithoutIdObjectWithoutId() { $user = TORM\Factory::build("user"); $ticket = TORM\Factory::build("ticket"); $user->push($ticket); $this->assertTrue($user->save()); $ticket = Ticket::find($ticket->id); $this->assertEquals($user->id, $ticket->user->id); $this->assertTrue($user->destroy()); $this->assertTrue($ticket->destroy()); }
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'; } }
static function updateTicketFromForm($idform, $idticket) { global $DB; $datas = array(); $templates_id = PluginFormcreatorForm::getTemplateTicketFromForm($idform); $ttp = new TicketTemplatePredefinedField(); $predefined_fields = $ttp->getPredefinedFields($templates_id, true); $Ticket = new Ticket(); $listaObjetos = $Ticket->find("id = '{$idticket}'"); //$listaobjetos es un array que contiene, por cada ticket que comple la condición del find, un array con los campos del ticket $clave = array_keys($listaObjetos); if (isset($clave[0])) { if (isset($listaObjetos[$clave[0]])) { $datas = $listaObjetos[$clave[0]]; unset($datas['urgency']); // unset($datas['priority']); // unset($datas['type']); // unset($datas['itilcategories_id']); // unset($datas['slas_id']); // $datas = array_merge($datas, $predefined_fields); $Ticket->update($datas); } } }
public function postDelete($ticket) { $rules = array('id' => 'required|integer'); $validator = Validator::make(Input::all(), $rules); if ($validator->passes()) { $id = $ticket->id; $ticket->delete(); $ticket = Ticket::find($id); if (empty($ticket)) { return Redirect::to('admin/tickets')->with('success', Lang::get('admin/blogs/messages.delete.success')); } } return Redirect::to('admin/tickets')->with('error', Lang::get('admin/blogs/messages.delete.error')); }
function bulk($action) { $this->load->helper('notification'); if ($_POST) { if (empty($_POST['list'])) { redirect('tickets'); } $list = explode(",", $_POST['list']); switch ($action) { case 'close': $attr = array('status' => "closed"); $email_message = $this->lang->line('messages_bulk_ticket_closed'); $success_message = $this->lang->line('messages_bulk_ticket_closed_success'); break; default: redirect('tickets'); break; } foreach ($list as $value) { $ticket = Ticket::find_by_id($value); $ticket->update_attributes($attr); send_ticket_notification($ticket->user->email, '[Ticket#' . $ticket->reference . '] - ' . $ticket->subject, $email_message, $ticket->id); if (!$ticket) { $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_save_ticket_error')); } else { $this->session->set_flashdata('message', 'success:' . $success_message); } } redirect('tickets'); /* if(isset($ticket->client->email)){ $email = $ticket->client->email; } else {$emailex = explode(' - ', $ticket->from); $email = $emailex[1]; } if(isset($_POST['notify'])){ send_ticket_notification($email, '[Ticket#'.$ticket->reference.'] - '.$ticket->subject, $_POST['message'], $ticket->id); } send_ticket_notification($ticket->user->email, '[Ticket#'.$ticket->reference.'] - '.$ticket->subject, $_POST['message'], $ticket->id); $_POST['internal'] = "0"; unset($_POST['notify']); $_POST['subject'] = htmlspecialchars($_POST['subject']); $_POST['datetime'] = time(); $_POST['from'] = $this->user->firstname." ".$this->user->lastname.' - '.$this->user->email; $_POST['reply_to'] = $this->user->email; $_POST['ticket_id'] = $id; $_POST['to'] = $email; unset($_POST['client_id']); $article = TicketHasArticle::create($_POST); if(!$ticket){$this->session->set_flashdata('message', 'error:'.$this->lang->line('messages_save_ticket_error'));} else{$this->session->set_flashdata('message', 'success:'.$this->lang->line('messages_ticket_close_success'));} redirect('tickets'); */ } else { $this->view_data['ticket'] = Ticket::find($id); $this->theme_view = 'modal'; $this->view_data['title'] = $this->lang->line('application_close'); $this->view_data['form_action'] = 'tickets/close'; $this->content_view = 'tickets/_close'; } }
/** * Remove the specified resource from storage. * * @param $post * @return Response */ public function postDelete($ticket) { // Declare the rules for the form validation $rules = array('id' => 'required|integer'); // Validate the inputs $validator = Validator::make(Input::all(), $rules); // Check if the form validates with success if ($validator->passes()) { $id = $ticket->id; $ticket->delete(); // Was the blog post deleted? $ticket = Ticket::find($id); if (empty($ticket)) { // Redirect to the blog posts management page return Redirect::to('admin/tickets')->with('success', Lang::get('admin/tickets/messages.delete.success')); } } // There was a problem deleting the blog post return Redirect::to('admin/tickets')->with('error', Lang::get('admin/tickets/messages.delete.error')); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $this->ticket->find($id)->delete(); return Redirect::route('tickets.index'); }
function article($id = FALSE, $condition = FALSE, $article_id = FALSE) { $this->view_data['submenu'] = array($this->lang->line('application_back') => 'ctickets', $this->lang->line('application_overview') => 'ctickets/view/' . $id); switch ($condition) { case 'add': $this->content_view = 'tickets/client_views/_note'; if ($_POST) { $config['upload_path'] = './files/media/'; $config['encrypt_name'] = TRUE; $config['allowed_types'] = '*'; $this->load->library('upload', $config); $this->load->helper('notification'); unset($_POST['userfile']); unset($_POST['file-name']); unset($_POST['send']); unset($_POST['_wysihtml5_mode']); $ticket = Ticket::find_by_id($id); $ticket->updated = "1"; $ticket->save(); if ($ticket->company_id != $this->client->company->id || $ticket->client_id != $this->client->id) { redirect('ctickets'); } send_ticket_notification($ticket->user->email, '[Ticket#' . $ticket->reference . '] - ' . $_POST['subject'], $_POST['message'], $ticket->id); $_POST['internal'] = "0"; unset($_POST['notify']); $_POST['subject'] = htmlspecialchars($_POST['subject']); $_POST['datetime'] = time(); $_POST['ticket_id'] = $id; $_POST['from'] = $this->client->firstname . " " . $this->client->lastname . ' - ' . $this->client->email; $_POST['reply_to'] = $this->client->email; $article = TicketHasArticle::create($_POST); if (!$this->upload->do_upload()) { $error = $this->upload->display_errors('', ' '); $this->session->set_flashdata('message', 'error:' . $error); } else { $data = array('upload_data' => $this->upload->data()); $attributes = array('article_id' => $article->id, 'filename' => $data['upload_data']['orig_name'], 'savename' => $data['upload_data']['file_name']); $attachment = ArticleHasAttachment::create($attributes); } if (!$article) { $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_save_article_error')); } else { $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_save_article_success')); } redirect('ctickets/view/' . $id); } else { $this->theme_view = 'modal'; $this->view_data['ticket'] = Ticket::find($id); $this->view_data['title'] = $this->lang->line('application_add_note'); $this->view_data['form_action'] = 'ctickets/article/' . $id . '/add'; $this->content_view = 'tickets/client_views/_note'; } break; default: redirect('ctickets'); break; } }
public function search() { fallback($_GET['query'], ""); $config = Config::current(); if ($config->clean_urls and substr_count($_SERVER['REQUEST_URI'], "?") and !substr_count($_SERVER['REQUEST_URI'], "%2F")) { # Searches with / and clean URLs = server 404 redirect("search/" . urlencode($_GET['query']) . "/"); } if (empty($_GET['query'])) { return Flash::warning(__("Please enter a search term.")); } list($where, $params) = keywords($_GET['query'], "title LIKE :query OR description LIKE :query OR url LIKE :query", "tickets"); $tickets = Ticket::find(array("placeholders" => true, "where" => $where, "params" => $params, "done" => true)); list($where, $params) = keywords($_GET['query'], "body LIKE :query", "revisions"); $revisions = Revision::find(array("placeholders" => true, "where" => $where, "params" => $params)); list($where, $params) = keywords($_GET['query'], "name LIKE :query", "milestones"); $milestones = Milestone::find(array("placeholders" => true, "where" => $where, "params" => $params)); $this->display("progress/search", array("tickets" => new Paginator($tickets, 25, "tickets_page"), "revisions" => new Paginator($revisions, 25, "revisions_page"), "milestones" => new Paginator($milestones, 25, "milestones_page"), "search" => $_GET['query']), fix(_f("Search results for \"%s\"", $_GET['query']))); }
public function get_helpdeskdelete($id) { //Verify the ticket exists $ticket = Ticket::findOrFail($id); //Now delete the replies to start Ticket::find($id)->replies()->delete(); //And finally the ticket $ticket->delete(); //That was easy. Now just redirect back to the dashboard with a message return Redirect::route('console')->with('message', 'Ticket successfully deleted.'); }