Returns a ticket object for an id.
public static makeTicket ( integer $id ) : Whups_Ticket | ||
$id | integer | The ticket id. |
Результат | Whups_Ticket | Whups_Ticket object |
/** * Adds an attachment to a ticket. * * @param integer $ticket_id The ticket number. * @param string $name The name of the attachment. * @param string $data The attachment data. * * @throws Whups_Exception */ public function addAttachment($ticket_id, $name, $data) { $ticket_id = (int) $ticket_id; if (empty($ticket_id)) { throw new Whups_Exception(_("Invalid Ticket Id")); } $ticket = Whups_Ticket::makeTicket($ticket_id); if (!strlen($name) || !strlen($data)) { throw new Whups_Exception(_("Empty attachment")); } $tmp_name = Horde_Util::getTempFile('whups', true, $GLOBALS['conf']['tmpdir']); $fp = fopen($tmp_name, 'wb'); fwrite($fp, $data); fclose($fp); $ticket->change('attachment', array('name' => $name, 'tmp_name' => $tmp_name)); $ticket->commit(); }
* did not receive this file, see http://www.horde.org/licenses/bsdl.php. */ require_once __DIR__ . '/../lib/Application.php'; Horde_Registry::appInit('whups'); Whups::addTopbarSearch(); $vars = Horde_Variables::getDefaultVariables(); $deleteform = new Whups_Form_Ticket_DeleteMultiple($vars); $title = sprintf(_("Delete %d tickets?"), count($deleteform->getTickets())); $deleteform->setTitle($title); if ($vars->get('formname') == 'whups_form_ticket_deletemultiple' && $deleteform->validate($vars)) { if ($vars->get('submitbutton') == _("Delete")) { $deleteform->getInfo($vars, $info); $tickets = @unserialize($info['tickets']); foreach ($tickets as $id) { try { Whups_Ticket::makeTicket($id)->delete(); $notification->push(sprintf(_("Ticket %d has been deleted."), $id), 'horde.success'); } catch (Whups_Exception $e) { $notification->push(_("There was an error deleting the ticket:") . ' ' . $e->getMessage(), 'horde.error'); } catch (Horde_Exception_NotFound $e) { $notification->push(sprintf(_("Ticket %d not found."), $id)); } } } else { $notification->push(_("The tickets were not deleted."), 'horde.message'); } Horde::url($vars->get('url', $prefs->getValue('whups_default_view') . '.php'), true)->redirect(); } $vars->set('tickets', serialize($deleteform->getTickets())); $page_output->header(array('title' => $title)); $notification->notify(array('listeners' => 'status'));
/** * Returns the tabs for navigating between ticket actions. */ public static function getTicketTabs(&$vars, $id) { $tabs = new Horde_Core_Ui_Tabs(null, $vars); $queue = Whups_Ticket::makeTicket($id)->get('queue'); $tabs->addTab(_("_History"), self::urlFor('ticket', $id), 'history'); $tabs->addTab(_("_Attachments"), self::urlFor('ticket_action', array('attachments', $id)), 'attachments'); if (self::hasPermission($queue, 'queue', 'update')) { $tabs->addTab(_("_Update"), self::urlFor('ticket_action', array('update', $id)), 'update'); } else { $tabs->addTab(_("_Comment"), self::urlFor('ticket_action', array('comment', $id)), 'comment'); } $tabs->addTab(_("_Watch"), self::urlFor('ticket_action', array('watch', $id)), 'watch'); if (self::hasPermission($queue, 'queue', Horde_Perms::DELETE)) { $tabs->addTab(_("S_et Queue"), self::urlFor('ticket_action', array('queue', $id)), 'queue'); } if (self::hasPermission($queue, 'queue', 'update')) { $tabs->addTab(_("Set _Type"), self::urlFor('ticket_action', array('type', $id)), 'type'); } if (self::hasPermission($queue, 'queue', Horde_Perms::DELETE)) { $tabs->addTab(_("_Delete"), self::urlFor('ticket_action', array('delete', $id)), 'delete'); } return $tabs; }
/** * Returns the ticket number matching the provided information. * * @param array $info A hash with ticket information. * * @return integer The ticket number if has been passed in the subject, * false otherwise. */ protected static function _findTicket(array $info) { if (!empty($info['ticket'])) { $ticketnum = $info['ticket']; } elseif (preg_match('/\\[[\\w\\s]*#(\\d+)\\]/', $info['summary'], $matches)) { $ticketnum = $matches[1]; } else { return false; } try { return Whups_Ticket::makeTicket($ticketnum); } catch (Whups_Exception $e) { return false; } }