Beispiel #1
0
 /**
  * Create ticket.
  */
 public function createAction()
 {
     $ticket = new Ticket($this->ticketParams());
     if ($ticket->validate()) {
         $ticket->save();
         Timeline::newTicketEvent($this->currentUser, $ticket)->save();
         $this->currentProject->next_ticket_id++;
         $this->currentProject->save();
         return $this->redirectTo('ticket', ['pslug' => $this->currentProject['slug'], 'id' => $ticket->ticket_id]);
     }
     return $this->render('tickets/new.phtml', ['ticket' => $ticket]);
 }
Beispiel #2
0
<?php

/*!
 * Traq Lite
 * Copyright (c) 2009-2016 Jack P.
 * https://github.com/nirix/traq-lite
 *
 * Licensed under the BSD 3-Clause license.
 */
use Traq\Models\Ticket;
$ticket = new Ticket(['status_id' => 1]);
if (Request::$method == 'POST') {
    $ticketId = currentProject()->get('next_ticket_id');
    $ticket->set(['ticket_id' => $ticketId, 'summary' => Request::$post['summary'], 'body' => Request::$post['body'], 'project_id' => currentProject()->get('id'), 'user_id' => currentUser()->get('id'), 'type_id' => Request::$post['type_id'], 'status_id' => Request::$post['status_id'], 'milestone_id' => Request::$post['milestone_id'], 'component_id' => Request::$post['component_id']]);
    if ($ticket->validate()) {
        db()->beginTransaction();
        $query = db()->prepare('
            INSERT INTO ' . PREFIX . 'tickets
            (ticket_id, summary, body, project_id, user_id, type_id, status_id, milestone_id, component_id, created_at)
            VALUES (:ticket_id, :summary, :body, :project_id, :user_id, :type_id, :status_id, :milestone_id, :component_id, NOW())
        ');
        $query->bindValue(':ticket_id', $ticket['ticket_id'], PDO::PARAM_INT);
        $query->bindValue(':summary', $ticket['summary']);
        $query->bindValue(':body', $ticket['body']);
        $query->bindValue(':project_id', $ticket['project_id'], PDO::PARAM_INT);
        $query->bindValue(':user_id', $ticket['user_id'], PDO::PARAM_INT);
        $query->bindValue(':type_id', $ticket['type_id'], PDO::PARAM_INT);
        $query->bindValue(':status_id', $ticket['status_id'], PDO::PARAM_INT);
        $query->bindValue(':milestone_id', $ticket['milestone_id'], PDO::PARAM_INT);
        $query->bindValue(':component_id', $ticket['component_id'] ?: null);
        $query->execute();