当前位置: 首页>>代码示例>>PHP>>正文


PHP Ticket::create方法代码示例

本文整理汇总了PHP中Ticket::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Ticket::create方法的具体用法?PHP Ticket::create怎么用?PHP Ticket::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ticket的用法示例。


在下文中一共展示了Ticket::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $validation = Validator::make($input, Ticket::$rules);
     if ($validation->passes()) {
         $this->ticket->create($input);
         return Redirect::route('tickets.index');
     }
     return Redirect::route('tickets.create')->withInput()->withErrors($validation)->with('message', 'There were validation errors.');
 }
开发者ID:Atiragram,项目名称:poit-labs,代码行数:15,代码来源:TicketsController.php

示例2: create

 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 : '[Anonyme]';
         		$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;
 }
开发者ID:agiza,项目名称:DreamVids,代码行数:34,代码来源:assist_controller.php

示例3: create

 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;
             }
         }
         $ticket = Ticket::create(array('user_id' => $user_id, 'description' => $req['bug'], 'timestamp' => time(), 'ip' => $_SERVER['REMOTE_ADDR']));
         $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 : '[Anonyme]';
         		$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;
 }
开发者ID:boulama,项目名称:DreamVids,代码行数:28,代码来源:assist_controller.php

示例4: store

 public function store(Request $request)
 {
     $input = $request->all();
     Ticket::create($input);
     Session::flash('flash_message', 'Ticket successfully added!');
     return redirect()->route('tickets.index');
 }
开发者ID:omego,项目名称:sts,代码行数:7,代码来源:TicketsController.php

示例5: create

 function create()
 {
     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']);
         unset($_POST['files']);
         $settings = Setting::first();
         $client = Client::find_by_id($this->client->id);
         $user = User::find_by_id($settings->ticket_default_owner);
         $_POST['from'] = $client->firstname . ' ' . $client->lastname . ' - ' . $client->email;
         $_POST['company_id'] = $client->company->id;
         $_POST['client_id'] = $client->id;
         $_POST['user_id'] = $settings->ticket_default_owner;
         $_POST['queue_id'] = $settings->ticket_default_queue;
         $_POST['type_id'] = $settings->ticket_default_type;
         $_POST['status'] = $settings->ticket_default_status;
         $_POST['created'] = time();
         $_POST['subject'] = htmlspecialchars($_POST['subject']);
         $ticket_reference = Setting::first();
         $_POST['reference'] = $ticket_reference->ticket_reference;
         $ticket = Ticket::create($_POST);
         $new_ticket_reference = $_POST['reference'] + 1;
         $ticket_reference->update_attributes(array('ticket_reference' => $new_ticket_reference));
         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('ticket_id' => $ticket->id, 'filename' => $data['upload_data']['orig_name'], 'savename' => $data['upload_data']['file_name']);
             $attachment = TicketHasAttachment::create($attributes);
         }
         if (!$ticket) {
             $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_create_ticket_error'));
             redirect('ctickets');
         } else {
             $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_create_ticket_success'));
             if (isset($user->email) && isset($ticket->reference)) {
                 send_ticket_notification($user->email, '[Ticket#' . $ticket->reference . '] - ' . $_POST['subject'], $_POST['text'], $ticket->id);
             }
             if (isset($client->email) && isset($ticket->reference)) {
                 send_ticket_notification($client->email, '[Ticket#' . $ticket->reference . '] - ' . $_POST['subject'], $_POST['text'], $ticket->id);
             }
             redirect('ctickets/view/' . $ticket->id);
         }
     } else {
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_create_ticket');
         $this->view_data['form_action'] = 'ctickets/create';
         $this->content_view = 'tickets/client_views/_ticket';
     }
 }
开发者ID:imranweb7,项目名称:msitc-erp,代码行数:58,代码来源:ctickets.php

示例6: createUpgradedTicket

 function createUpgradedTicket()
 {
     global $cfg;
     $i18n = new Internationalization();
     $vars = $i18n->getTemplate('templates/ticket/upgraded.yaml')->getData();
     $vars['deptId'] = $cfg->getDefaultDeptId();
     //Create a ticket to make the system warm and happy.
     $errors = array();
     Ticket::create($vars, $errors, 'api', false, false);
 }
开发者ID:ed00m,项目名称:osTicket-1.8,代码行数:10,代码来源:class.upgrader.php

示例7: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 5) as $index) {
         Ticket::create(['title' => $faker->sentence(), 'description' => $faker->sentence(), 'priority_id' => '1', 'status_id' => '1', 'owner_id' => '1', 'replies' => '0']);
     }
     foreach (range(1, 5) as $index) {
         Ticket::create(['title' => $faker->sentence(), 'description' => $faker->sentence(), 'priority_id' => '1', 'status_id' => '1', 'owner_id' => '2', 'replies' => '0']);
     }
 }
开发者ID:terrygl,项目名称:SimpleLance,代码行数:10,代码来源:TicketsTableSeeder.php

示例8: run

 public function run()
 {
     $faker = Faker\Factory::create();
     DB::table('tickets')->truncate();
     DB::table('departments')->truncate();
     Department::create(array('name' => 'Support'));
     Department::create(array('name' => 'Sales'));
     for ($i = 0; $i < 60; $i++) {
         Ticket::create(array('user_id' => $faker->randomNumber(1, 20), 'department_id' => $faker->randomNumber(1, 2), 'title' => $faker->sentence, 'message' => $faker->paragraph, 'status' => $faker->randomElement(array('Open', 'Closed'))));
     }
 }
开发者ID:carriercomm,项目名称:saaspanel,代码行数:11,代码来源:TicketsTableSeeder.php

示例9: updateMessage

 public static function updateMessage($id, $text, $ticket = false)
 {
     $msg = new Message(array('id' => $id, 'text' => $text));
     $msg->update();
     $tick_no = null;
     if ($ticket) {
         $wlticket = new Ticket(array('message_id' => $id, 'title' => 'NIEUW', 'text' => $text, 'status_id' => 1));
         $tick_no = $wlticket->create();
     }
     if ($tick_no) {
         $msg->setTicket($tick_no);
     }
     return array('id' => $msg->id);
 }
开发者ID:JJWTimmer,项目名称:BLAM,代码行数:14,代码来源:BLAM.class.php

示例10: createTicket

 function createTicket($data)
 {
     # Pull off some meta-data
     $alert = $data['alert'] ? $data['alert'] : true;
     $autorespond = $data['autorespond'] ? $data['autorespond'] : true;
     $data['source'] = $data['source'] ? $data['source'] : 'API';
     # Create the ticket with the data (attempt to anyway)
     $errors = array();
     $ticket = Ticket::create($data, $errors, $data['source'], $autorespond, $alert);
     # Return errors (?)
     if (count($errors)) {
         if (isset($errors['errno']) && $errors['errno'] == 403) {
             return $this->exerr(403, 'Ticket denied');
         } else {
             return $this->exerr(400, "Unable to create new ticket: validation errors:\n" . Format::array_implode(": ", "\n", $errors));
         }
     } elseif (!$ticket) {
         return $this->exerr(500, "Unable to create new ticket: unknown error");
     }
     return $ticket;
 }
开发者ID:pkdevboxy,项目名称:osTicket-1.7,代码行数:21,代码来源:api.tickets.php

示例11: create

 function create($format)
 {
     $this->requireApiKey();
     # Parse request body
     $data = $this->getRequest($format);
     if ($format == "xml") {
         $data = $data["ticket"];
     }
     # Pull off some meta-data
     $alert = $data['alert'] ? $data['alert'] : true;
     $autorespond = $data['autorespond'] ? $data['autorespond'] : true;
     $source = $data['source'] ? $data['source'] : 'API';
     $attachments = $data['attachments'] ? $data['attachments'] : array();
     # TODO: Handle attachment encoding (base64)
     foreach ($attachments as $filename => &$info) {
         if ($info["encoding"] == "base64") {
             # XXX: May fail on large inputs. See
             #      http://us.php.net/manual/en/function.base64-decode.php#105512
             if (!($info["data"] = base64_decode($info["data"], true))) {
                 Http::response(400, sprintf("%s: Poorly encoded base64 data", $filename));
             }
         }
         $info['size'] = strlen($info['data']);
     }
     # Create the ticket with the data (attempt to anyway)
     $errors = array();
     $ticket = Ticket::create($data, $errors, $source, $autorespond, $alert);
     # Return errors (?)
     if (count($errors)) {
         Http::response(400, "Unable to create new ticket: validation errors:\n" . Format::array_implode(": ", "\n", $errors));
     } elseif (!$ticket) {
         Http::response(500, "Unable to create new ticket: unknown error");
     }
     # Save attachment(s)
     foreach ($attachments as &$info) {
         $ticket->saveAttachment($info, $ticket->getLastMsgId(), "M");
     }
     # All done. Return HTTP/201 --> Created
     Http::response(201, $ticket->getExtId());
 }
开发者ID:nunomartins,项目名称:osTicket-1.7,代码行数:40,代码来源:api.ticket.php

示例12: post_request

/**
 * This function call when a post request send .If that request is a valid addTicket request, new ticket will added,
 * Else redirect user to not found page or echo error message;
 * @param WP_USER $user
 * @return string
 */
function post_request($user)
{
    if (!isset($_POST["requestType"]) || $_POST["requestType"] != "addTicket" && $_POST["requestType"] != "addTicketAnswer") {
        header("Location: " . NOT_FOUND_URL);
        exit;
    }
    $const_array = array("applicant_id" => $user->ID, "status" => 0, "attachments" => $_POST["upfile"], "title" => $_POST["title"], "content" => $_POST["message"], "department" => $_POST["department"], "other" => "priority:" . $_POST["priority"] . "|", "related_order" => get_id($_POST["order"]));
    if (isset($_POST['relatedTicket'])) {
        $related_ticket = $_POST['relatedTicket'];
        $const_array = array_merge($const_array, array("related_ticket" => get_id($related_ticket)));
    }
    if ($_POST["requestType"] == "addTicket") {
        foreach ($const_array as $key => $value) {
            if (empty($value) && $value !== 0 && $key !== "attachments" && $key !== "order" && $key !== "related_ticket") {
                return "لطفا متنی تایپ کنید!" . "<br>";
            }
        }
    } else {
        if (empty($_POST["message"])) {
            return "متن پاسخ نیم تواند خالی باشد";
        }
    }
    $ticket = new Ticket($const_array);
    if ($ticket->create()) {
        if ($_POST["requestType"] == "addTicket") {
            echo "1|ticket.php?iti=" . $ticket->get_fake_id();
            exit;
        } else {
            if (get_user_level($user->ID) == 10) {
                Ticket::change_ticket_status($ticket->get_related_ticket_id(), 1);
            } else {
                Ticket::change_ticket_status($ticket->get_related_ticket_id(), 0);
            }
            echo "پاسخ شما افزوده شد";
        }
    } else {
        return "مشکلی در ایجاد تیکت وجود دارد.لطفا مجددا تلاش کنید";
    }
}
开发者ID:alihoseiny,项目名称:Shek,代码行数:45,代码来源:ticket.php

示例13: create_by_staff

 function create_by_staff($var, &$errors)
 {
     global $_FILES, $thisuser, $cfg;
     //check if the staff is allowed to create tickets.
     if (!$thisuser || !$thisuser->getId() || !$thisuser->isStaff() || !$thisuser->canCreateTickets()) {
         $errors['err'] = 'Permission denied';
     }
     if (!$var['issue']) {
         $errors['issue'] = 'Summary of the issue required';
     }
     if ($var['source'] && !in_array(strtolower($var['source']), array('email', 'phone', 'other'))) {
         $errors['source'] = 'Invalid source - ' . Format::htmlchars($var['source']);
     }
     $var['emailId'] = 0;
     //clean crap.
     $var['message'] = 'Ticket created by staff';
     if ($ticket = Ticket::create($var, $errors, 'staff', false, !$var['staffId'])) {
         //Staff are alerted only IF the ticket is not being assigned.
         //post issue as a response...
         $msgId = $ticket->getLastMsgId();
         $issue = $ticket->replaceTemplateVars($var['issue']);
         if ($respId = $ticket->postResponse($msgId, $issue, 'none', null, false)) {
             //Note that we're overwriting alerts.
             //Mark the ticket unanswered - postResponse marks it answered which is not the desired state.
             $ticket->markUnAnswered();
             //Send Notice to user --- if requested AND enabled!!
             if ($cfg->notifyONNewStaffTicket() && isset($var['alertuser'])) {
                 $dept = $ticket->getDept();
                 if (!$dept || !($tplId = $dept->getTemplateId())) {
                     $tplId = $cfg->getDefaultTemplateId();
                 }
                 $sql = 'SELECT ticket_notice_subj,ticket_notice_body FROM ' . EMAIL_TEMPLATE_TABLE . ' WHERE cfg_id=' . db_input($cfg->getId()) . ' AND tpl_id=' . db_input($tplId);
                 if (($resp = db_query($sql)) && db_num_rows($resp) && (list($subj, $body) = db_fetch_row($resp))) {
                     $body = $ticket->replaceTemplateVars($body);
                     $subj = $ticket->replaceTemplateVars($subj);
                     $body = str_replace('%message', $var['issue'], $body);
                     //Figure out the signature to use...if any.
                     switch (strtolower($var['signature'])) {
                         case 'mine':
                             $signature = $thisuser->getSignature();
                             break;
                         case 'dept':
                             $signature = $dept && $dept->isPublic() ? $dept->getSignature() : '';
                             //make sure it is public
                             break;
                         case 'none':
                         default:
                             $signature = '';
                             break;
                     }
                     $body = str_replace("%signature", $signature, $body);
                     //Email attachment when attached AND if emailed attachments are allowed!
                     $file = null;
                     $attachment = $_FILES['attachment'];
                     if ($attachment && is_file($attachment['tmp_name']) && $cfg->emailAttachments()) {
                         $file = array('file' => $attachment['tmp_name'], 'name' => $attachment['name'], 'type' => $attachment['type']);
                     }
                     if ($cfg->stripQuotedReply() && ($tag = trim($cfg->getReplySeparator()))) {
                         $body = "\n{$tag}\n\n" . $body;
                     }
                     if (!$dept || !($email = $dept->getEmail())) {
                         $email = $cfg->getDefaultEmail();
                     }
                     if ($email && $email->getId()) {
                         $email->send($ticket->getEmail(), $subj, $body, $file);
                     }
                 } else {
                     //We have a big problem...alert admin...
                     $msg = 'Problems fetching response template for ticket#' . $ticket->getId() . ' Possible config error - template #' . $tplId;
                     Sys::alertAdmin('System Error', $msg);
                 }
             }
             //Send send alert.
             //Upload attachment if any...
             if ($_FILES['attachment'] && $_FILES['attachment']['size']) {
                 $ticket->uploadAttachment($_FILES['attachment'], $respId, 'R');
             }
         } else {
             //end post response
             $errors['err'] = 'Internal error - message/response post error.';
         }
         //post create actions
         if ($var['staffId']) {
             //Assign ticket to staff if any. (internal note as message)
             $ticket->assignStaff($var['staffId'], $var['note'], isset($var['alertstaff']));
         } elseif ($var['note']) {
             //Not assigned...save optional note if any
             $ticket->postNote('New Ticket', $var['note'], false);
         } else {
             //Not assignment and no internal note - log activity
             $ticket->logActivity('New Ticket by Staff', 'Ticket created by staff -' . $thisuser->getName());
         }
     } else {
         $errors['err'] = $errors['err'] ? $errors['err'] : 'Unable to create the ticket. Correct the error(s) and try again';
     }
     return $ticket;
 }
开发者ID:supaket,项目名称:helpdesk,代码行数:97,代码来源:class.ticket.php

示例14: index

 function index()
 {
     $this->load->helper('notification');
     $this->load->helper('string');
     $emailconfig = Setting::first();
     if ($emailconfig->ticket_config_active == "1") {
         $emailconfig->ticket_config_timestamp = time();
         $emailconfig->save();
         // this shows basic IMAP, no TLS required
         $config['login'] = $emailconfig->ticket_config_login;
         $config['pass'] = $emailconfig->ticket_config_pass;
         $config['host'] = $emailconfig->ticket_config_host;
         $config['port'] = $emailconfig->ticket_config_port;
         $config['mailbox'] = $emailconfig->ticket_config_mailbox;
         if ($emailconfig->ticket_config_imap == "1") {
             $flags = "/imap";
         } else {
             $flags = "/pop3";
         }
         if ($emailconfig->ticket_config_ssl == "1") {
             $flags .= "/ssl";
         }
         $config['service_flags'] = $flags . $emailconfig->ticket_config_flags;
         $this->load->library('peeker', $config);
         //attachment folder
         $bool = $this->peeker->set_attachment_dir('files/media/');
         //Search Filter
         $this->peeker->set_search($emailconfig->ticket_config_search);
         if ($this->peeker->search_and_count_messages() != "0") {
             log_message('error', 'Postmaster fetched ' . $this->peeker->search_and_count_messages() . ' new email tickets.');
             $id_array = $this->peeker->get_ids_from_search();
             //walk trough emails
             foreach ($id_array as $email_id) {
                 $ticket = false;
                 $email = $this->peeker->get_message($email_id);
                 $email->rewrite_html_transform_img_tags('files/media/');
                 $emailbody = utf8_encode(nl2br($email->get_plain()));
                 $emailaddr = $email->get_from_array();
                 $emailaddr = $emailaddr[0]->mailbox . '@' . $emailaddr[0]->host;
                 //get next ticket number
                 $settings = Setting::first();
                 $ticket_reference = $settings->ticket_reference;
                 $settings->ticket_reference = $settings->ticket_reference + 1;
                 $settings->save();
                 if (preg_match('/(?<=\\[Ticket\\#)(.+)(?=\\])/is', $email->get_subject(), $matches)) {
                     $ticket = Ticket::find_by_reference($matches[1]);
                 }
                 if ($ticket) {
                     log_message('error', 'Fetched email merged to ticket #' . $matches[1]);
                     $article_attributes = array('ticket_id' => $ticket->id, 'internal' => '0', 'from' => $email->get_from() . ' - ' . $emailaddr, 'reply_to' => $emailaddr, 'to' => $email->get_to(), 'cc' => $email->get_cc(), 'subject' => htmlspecialchars($email->get_subject()), 'message' => $emailbody, 'datetime' => time());
                     if ($ticket->status == "closed") {
                         $ticket->status = 'reopened';
                         $ticket->updated = '1';
                         $ticket->save();
                     }
                     $ticket->updated = '1';
                     $ticket->save();
                     $article = TicketHasArticle::create($article_attributes);
                     if (isset($ticket->user->email)) {
                         send_ticket_notification($ticket->user->email, '[Ticket#' . $ticket->reference . '] - ' . $ticket->subject, $emailbody, $ticket->id);
                     }
                     //Attachments
                     $parts = $email->get_parts_array();
                     if ($email->has_attachment()) {
                         foreach ($parts as $part) {
                             $savename = $email->get_fingerprint() . random_string('alnum', 8) . $part->get_filename();
                             $orgname = $part->get_filename();
                             $part->filename = $savename;
                             $attributes = array('article_id' => $article->id, 'filename' => $orgname, 'savename' => $savename);
                             $attachment = ArticleHasAttachment::create($attributes);
                         }
                         $email->save_all_attachments('files/media/');
                     }
                 } else {
                     //Ticket Attributes
                     $ticket_attributes = array('reference' => $ticket_reference, 'from' => $email->get_from() . ' - ' . $emailaddr, 'subject' => $email->get_subject(), 'text' => $emailbody, 'updated' => "1", 'created' => time(), 'user_id' => $settings->ticket_default_owner, 'type_id' => $settings->ticket_default_type, 'status' => $settings->ticket_default_status, 'queue_id' => $settings->ticket_default_queue);
                     //check if sender is client
                     $client = Client::find_by_email($emailaddr);
                     if (isset($client)) {
                         $ticket_attributes['client_id'] = $client->id;
                         $ticket_attributes['company_id'] = $client->company->id;
                     }
                     //create Ticket
                     $ticket = Ticket::create($ticket_attributes);
                     //Attachments
                     $parts = $email->get_parts_array();
                     if ($email->has_attachment()) {
                         foreach ($parts as $part) {
                             $savename = $email->get_fingerprint() . random_string('alnum', 8) . $part->get_filename();
                             $orgname = $part->get_filename();
                             $part->filename = $savename;
                             $attributes = array('ticket_id' => $ticket->id, 'filename' => $orgname, 'savename' => $savename);
                             $attachment = TicketHasAttachment::create($attributes);
                         }
                         $email->save_all_attachments('files/media/');
                     }
                     send_ticket_notification($ticket->user->email, '[Ticket#' . $ticket->reference . '] - ' . $ticket->subject, $emailbody, $ticket->id);
                     log_message('error', 'New ticket created #' . $ticket->reference);
                 }
                 if ($emailconfig->ticket_config_delete == "1") {
//.........这里部分代码省略.........
开发者ID:pratikbgit,项目名称:freelancerKit,代码行数:101,代码来源:postmaster.php

示例15: createTicket

 function createTicket($mid)
 {
     global $ost;
     if (!($mailinfo = $this->getHeaderInfo($mid))) {
         return false;
     }
     //Make sure the email is NOT already fetched... (undeleted emails)
     if ($mailinfo['mid'] && ($id = Ticket::getIdByMessageId(trim($mailinfo['mid']), $mailinfo['email']))) {
         return true;
     }
     //Reporting success so the email can be moved or deleted.
     //Is the email address banned?
     if ($mailinfo['email'] && EmailFilter::isBanned($mailinfo['email'])) {
         //We need to let admin know...
         $ost->logWarning('Ticket denied', 'Banned email - ' . $mailinfo['email']);
         return true;
         //Report success (moved or delete)
     }
     $emailId = $this->getEmailId();
     $var['name'] = $this->mime_decode($mailinfo['name']);
     $var['email'] = $mailinfo['email'];
     $var['subject'] = $mailinfo['subject'] ? $this->mime_decode($mailinfo['subject']) : '[No Subject]';
     $var['message'] = Format::stripEmptyLines($this->getBody($mid));
     $var['header'] = $this->getHeader($mid);
     $var['emailId'] = $emailId ? $emailId : $ost->getConfig()->getDefaultEmailId();
     //ok to default?
     $var['name'] = $var['name'] ? $var['name'] : $var['email'];
     //No name? use email
     $var['mid'] = $mailinfo['mid'];
     if (!$var['message']) {
         //An email with just attachments can have empty body.
         $var['message'] = '(EMPTY)';
     }
     if ($ost->getConfig()->useEmailPriority()) {
         $var['priorityId'] = $this->getPriority($mid);
     }
     $ticket = null;
     $newticket = true;
     //Check the subject line for possible ID.
     if ($var['subject'] && preg_match("[[#][0-9]{1,10}]", $var['subject'], $regs)) {
         $tid = trim(preg_replace("/[^0-9]/", "", $regs[0]));
         //Allow mismatched emails?? For now NO.
         if (!($ticket = Ticket::lookupByExtId($tid)) || strcasecmp($ticket->getEmail(), $var['email'])) {
             $ticket = null;
         }
     }
     $errors = array();
     if ($ticket) {
         if (!($msgid = $ticket->postMessage($var['message'], 'Email', $var['mid'], $var['header']))) {
             return false;
         }
     } elseif ($ticket = Ticket::create($var, $errors, 'Email')) {
         $msgid = $ticket->getLastMsgId();
     } else {
         //TODO: Log error..
         return null;
     }
     //Save attachments if any.
     if ($msgid && $ost->getConfig()->allowEmailAttachments() && ($struct = imap_fetchstructure($this->mbox, $mid)) && $struct->parts && ($attachments = $this->getAttachments($struct))) {
         //We're just checking the type of file - not size or number of attachments...
         // Restrictions are mainly due to PHP file uploads limitations
         foreach ($attachments as $a) {
             if ($ost->isFileTypeAllowed($a['name'], $a['mime'])) {
                 $file = array('name' => $a['name'], 'type' => $a['mime'], 'data' => $this->decode($a['encoding'], imap_fetchbody($this->mbox, $mid, $a['index'])));
                 $ticket->saveAttachment($file, $msgid, 'M');
             } else {
                 //This should be really a comment on message - NoT an internal note.
                 //TODO: support comments on Messages and Responses.
                 $error = sprintf('Attachment %s [%s] rejected because of file type', $a['name'], $a['mime']);
                 $ticket->postNote('Email Attachment Rejected', $error, false);
                 $ost->logDebug('Email Attachment Rejected (Ticket #' . $ticket->getExtId() . ')', $error);
             }
         }
     }
     return $ticket;
 }
开发者ID:nunomartins,项目名称:osTicket-1.7,代码行数:76,代码来源:class.mailfetch.php


注:本文中的Ticket::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。