1<?php
2/**
3 * Copyright 2013-2017 Horde LLC (http://www.horde.org/)
4 *
5 * See the enclosed file LICENSE for license information (BSD). If you
6 * did not receive this file, see http://www.horde.org/licenses/bsdl.php.
7 *
8 * @author Jan Schneider <jan@horde.org>
9 */
10
11require_once __DIR__ . '/../lib/Application.php';
12Horde_Registry::appInit('whups');
13
14$vars = Horde_Variables::getDefaultVariables();
15$ticket = Whups::getCurrentTicket();
16
17$view = $injector->createInstance('Horde_View');
18try {
19    $files = $ticket->listAllAttachments();
20} catch (Whups_Exception $e) {
21    $notification->push($e);
22}
23if ($files) {
24    $format = array(
25        $prefs->getValue('date_format'),
26        $prefs->getValue('time_format')
27    );
28    $attachments = Whups::getAttachments($ticket->getId());
29    $view->attachments = array();
30    foreach ($files as $file) {
31        $view->attachments[] = array_merge(
32            array(
33                'timestamp' => $file['timestamp'],
34                'date' => strftime($format[0], $file['timestamp'])
35                    . ' ' . strftime($format[1], $file['timestamp']),
36                'user' => Whups::formatUser(
37                    Whups::getUserAttributes($file['user_id']),
38                    true,
39                    true,
40                    true
41                ),
42            ),
43            Whups::attachmentUrl(
44                $ticket->getId(),
45                $attachments[$file['value']],
46                $ticket->get('queue')
47            )
48        );
49    }
50}
51
52Whups::addTopbarSearch();
53Whups::addFeedLink();
54$page_output->addLinkTag($ticket->feedLink());
55$page_output->addScriptFile('tables.js', 'horde');
56$page_output->header(array(
57    'title' => sprintf(_("Attachments for %s"), '[#' . $id . '] ' . $ticket->get('summary'))
58));
59$notification->notify(array('listeners' => 'status'));
60echo Whups::getTicketTabs($vars, $ticket->getId())->render('attachments');
61echo $view->render('ticket/attachments');
62$page_output->footer();
63