Whups::getCurrentTicket PHP Method

getCurrentTicket() public static method

Uses the 'id' request variable to determine what to look for. Will redirect to the default view if the ticket isn't found or if permissions checks fail.
public static getCurrentTicket ( ) : Whups_Ticket
return Whups_Ticket The current ticket.
    public static function getCurrentTicket()
    {
        $default = Horde::url($GLOBALS['prefs']->getValue('whups_default_view') . '.php', true);
        $id = Horde_Util::getFormData('searchfield');
        if (empty($id)) {
            $id = Horde_Util::getFormData('id');
        }
        $id = preg_replace('|\\D|', '', $id);
        if (!$id) {
            $GLOBALS['notification']->push(_("Invalid Ticket Id"), 'horde.error');
            $default->redirect();
        }
        try {
            return Whups_Ticket::makeTicket($id);
        } catch (Whups_Exception $e) {
            if ($ticket->code === 0) {
                // No permissions to this ticket.
                $GLOBALS['notification']->push($e->getMessage(), 'horde.warning');
                $default->redirect();
            }
        } catch (Exception $e) {
            $GLOBALS['notification']->push($e);
            $default->redirect();
        }
    }

Usage Example

Exemplo n.º 1
0
<?php

/**
 * Copyright 2001-2002 Robert E. Coyle <*****@*****.**>
 * Copyright 2001-2014 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file LICENSE for license information (BSD). If you
 * did not receive this file, see http://www.horde.org/licenses/bsdl.php.
 */
require_once __DIR__ . '/../lib/Application.php';
Horde_Registry::appInit('whups');
$ticket = Whups::getCurrentTicket();
$page_output->addLinkTag($ticket->feedLink());
if (!Whups::hasPermission($ticket->get('queue'), 'queue', 'update')) {
    $notification->push(_("Permission Denied"), 'horde.error');
    Horde::url($prefs->getValue('whups_default_view') . '.php', true)->redirect();
}
Whups::addTopbarSearch();
$vars = Horde_Variables::getDefaultVariables();
$vars->set('id', $id = $ticket->getId());
foreach ($ticket->getDetails() as $varname => $value) {
    if ($varname == 'owners') {
        $owners = $gowners = array();
        foreach ($value as $owner) {
            if (strpos($owner, 'user:'******'owners', $owners);