This file is indexed.

/usr/share/horde/whups/lib/Application.php is in php-horde-whups 3.0.0~beta1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<?php
/**
 * Whups application API.
 *
 * This file defines Horde's core API interface. Other core Horde libraries
 * can interact with Whups through this API.
 *
 * Copyright 2010-2013 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.horde.org/licenses/gpl.
 *
 * @package Whups
 */

/* Determine the base directories. */
if (!defined('WHUPS_BASE')) {
    define('WHUPS_BASE', __DIR__ . '/..');
}

if (!defined('HORDE_BASE')) {
    /* If Horde does not live directly under the app directory, the HORDE_BASE
     * constant should be defined in config/horde.local.php. */
    if (file_exists(WHUPS_BASE . '/config/horde.local.php')) {
        include WHUPS_BASE . '/config/horde.local.php';
    } else {
        define('HORDE_BASE', WHUPS_BASE . '/..');
    }
}

/* Load the Horde Framework core (needed to autoload
 * Horde_Registry_Application::). */
require_once HORDE_BASE . '/lib/core.php';

class Whups_Application extends Horde_Registry_Application
{
    /**
     */
    public $version = 'H5 (3.0.0beta1)';

    /**
     * Global variables defined:
     * - $whups_driver: The global Whups driver object.
     */
    protected function _init()
    {
        $GLOBALS['whups_driver'] = $GLOBALS['injector']
            ->getInstance('Whups_Factory_Driver')
            ->create();

        /* Set the timezone variable, if available. */
        $GLOBALS['registry']->setTimeZone();
    }

    /**
     */
    public function perms()
    {
        /* Available Whups permissions. */
        $perms = array(
            'admin' => array(
                'title' => _("Administration")
            ),
            'hiddenComments' => array(
                'title' => _("Hidden Comments")
            ),
            'queues' => array(
                'title' => _("Queues")
            ),
            'replies' => array(
                'title' => _("Form Replies")
            )
        );

        /* Loop through queues and add their titles. */
        $queues = $GLOBALS['whups_driver']->getQueues();
        foreach ($queues as $id => $name) {
            $perms['queues:' . $id] = array(
                'title' => $name
            );

            $entries = array(
                'assign' => _("Assign"),
                'requester' => _("Set Requester"),
                'update' => _("Update")
            );

            foreach ($entries as $key => $val) {
                $perms['queues:' . $id . ':' . $key] = array(
                    'title' => $val,
                    'type' => 'boolean'
                );
            }
        }

        /* Loop through type and replies and add their titles. */
        foreach ($GLOBALS['whups_driver']->getAllTypes() as $type_id => $type_name) {
            foreach ($GLOBALS['whups_driver']->getReplies($type_id) as $reply_id => $reply) {
                $perms['replies:' . $reply_id] = array(
                    'title' => $type_name . ': ' . $reply['reply_name']
                );
            }
        }

        return $perms;
    }

    public function sidebar($sidebar)
    {
        $sidebar->addNewButton(
            _("_New Ticket"),
            Horde::url('ticket/create.php'));
    }

    /**
     */
    public function menu($menu)
    {
        $menu->add(Horde::url('mybugs.php'), sprintf(_("_My %s"), $GLOBALS['registry']->get('name')), 'whups-mywhups', null, null, null, $GLOBALS['prefs']->getValue('whups_default_view') == 'mybugs' && strpos($_SERVER['PHP_SELF'], $GLOBALS['registry']->get('webroot') . '/index.php') !== false ? 'current' : null);
        $menu->add(Horde::url('search.php'), _("_Search"), 'horde-search', null, null, null, $GLOBALS['prefs']->getValue('whups_default_view') == 'search' && strpos($_SERVER['PHP_SELF'], $GLOBALS['registry']->get('webroot') . '/index.php') !== false ? 'current' : null);
        $menu->add(Horde::url('query/index.php'), _("_Query Builder"), 'whups-query');
        $menu->add(Horde::url('reports.php'), _("_Reports"), 'whups-reports');

        /* Administration. */
        if ($GLOBALS['registry']->isAdmin(array('permission' => 'whups:admin'))) {
            $menu->add(Horde::url('admin/'), _("_Admin"), 'whups-admin');
        }
    }

    /* Topbar method. */

    /**
     */
    public function topbarCreate(Horde_Tree_Renderer_Base $tree, $parent = null,
                                 array $params = array())
    {
        $tree->addNode(array(
            'id' => $parent . '__new',
            'parent' => $parent,
            'label' => _("New Ticket"),
            'expanded' => false,
            'params' => array(
                'url' => Horde::url('ticket/create.php')
            )
        ));

        $tree->addNode(array(
            'id' => $parent . '__search',
            'parent' => $parent,
            'label' => _("Search"),
            'expanded' => false,
            'params' => array(
                'url' => Horde::url('search.php')
            )
        ));
    }

    /* Download data. */

    /**
     * @throws Whups_Exception
     */
    public function download(Horde_Variables $vars)
    {
        global $injector, $whups_driver;

        switch ($vars->actionID) {
        case 'download_file':
            // Get the ticket details first.
            if (empty($vars->id)) {
                exit;
            }

            $details = $whups_driver->getTicketDetails($vars->id);

            // Check permissions on this ticket.
            if (!count(Whups::permissionsFilter($whups_driver->getHistory($vars->id), 'comment', Horde_Perms::READ))) {
                throw new Whups_Exception(sprintf(_("You are not allowed to view ticket %d."), $vars->id));
            }

            try {
                $vfs = $injector->getInstance('Horde_Core_Factory_Vfs')->create();
            } catch (Horde_Exception $e) {
                throw new Whups_Exception(_("The VFS backend needs to be configured to enable attachment uploads."));
            }

            try {
                return array(
                    'data' => $vfs->read(Whups::VFS_ATTACH_PATH . '/' . $vars->id, $vars->file),
                    'name' => $vars->file
                );
            } catch (Horde_Vfs_Exception $e) {
                throw Whups_Exception(sprintf(_("Access denied to %s"), $vars->file));
            }
            break;

        case 'report':
            $_templates = Horde::loadConfiguration('templates.php', '_templates', 'whups');
            $tpl = $vars->template;
            if (empty($_templates[$tpl])) {
                throw new Whups_Exception(_("The requested template does not exist."));
            }
            if ($_templates[$tpl]['type'] != 'searchresults') {
                throw new Whups_Exception(_("This is not a search results template."));
            }

            // Fetch all unresolved tickets assigned to the current user.
            $info = array('id' => explode(',', $vars->ids));
            $tickets = $whups_driver->getTicketsByProperties($info);
            foreach ($tickets as $id => $info) {
                $tickets[$id]['#'] = $id + 1;
                $tickets[$id]['link'] = Whups::urlFor('ticket', $info['id'], true, -1);
                $tickets[$id]['date_created'] = strftime('%x', $info['timestamp']);
                $tickets[$id]['owners'] = Whups::getOwners($info['id']);
                $tickets[$id]['owner_name'] = Whups::getOwners($info['id'], false, true);
                $tickets[$id]['owner_email'] = Whups::getOwners($info['id'], true, false);
                if (!empty($info['date_assigned'])) {
                    $tickets[$id]['date_assigned'] = strftime('%x', $info['date_assigned']);
                }
                if (!empty($info['date_resolved'])) {
                    $tickets[$id]['date_resolved'] = strftime('%x', $info['date_resolved']);
                }

                // If the template has a callback function defined for data
                // filtering, call it now.
                if (!empty($_templates[$tpl]['callback'])) {
                    array_walk($tickets[$id], $_templates[$tpl]['callback']);
                }
            }

            Whups::sortTickets($tickets,
                isset($_templates[$tpl]['sortby']) ? $_templates[$tpl]['sortby'] : null,
                isset($_templates[$tpl]['sortdir']) ? $_templates[$tpl]['sortdir'] : null
            );

            $template = $injector->createInstance('Horde_Template');
            $template->set('tickets', $tickets);
            $template->set('now', strftime('%x'));
            $template->set('values', Whups::getSearchResultColumns(null, true));

            return array(
                'data' => $template->parse($_templates[$tpl]['template']),
                'name' => isset($_templates[$tpl]['filename']) ? $_templates[$tpl]['filename'] : 'report.html'
            );
        }
    }

}