This file is indexed.

/usr/share/horde/ansel/lib/View/List.php is in php-horde-ansel 3.0.5+debian0-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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
<?php
/**
 * The Ansel_View_List:: provides a view for handling lists of galleries.
 *
 * Copyright 2008-2016 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.
 *
 * @TODO: should extend Base, not Ansel
 *
 * @author  Michael J. Rubinsky <mrubinsk@horde.org>
 * @package Ansel
 */
class Ansel_View_List extends Ansel_View_Ansel
{
    /**
     * The owner we are grouping by, if any.
     *
     * @var string
     */
    protected $_owner;

    /**
     *  @TODO
     *
     * @var boolean
     */
    protected $_special;

    /**
     * The current page number of the view.
     *
     * @var integer
     */
    protected $_page;

    /**
     * The Horde_View used to render this view.
     *
     * @var Horde_View
     */
    protected $_view;

    /**
     * Const'r
     *
     * @param array $params  Any parameters that the view might need.
     * <pre>
     *  In addition to the params taken by Ansel_View_Gallery, this view
     *  can also take:
     *
     *  groupby      -  Group the results (owner)
     *
     *  owner        -  The owner to group by
     *
     *  tags         -  Limit to galleries matching tags
     *
     *  gallery_ids  -  No fitering, just show these galleries
     *
     *  pager_url    -  The url for the pager to use see Ansel_Gallery for
     *                  more information on the url parameters.
     */
    public function __construct(array $params = array())
    {
        global $prefs, $notification, $registry;

        parent::__construct($params);

        $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage');

        // View
        $this->_view = $GLOBALS['injector']->createInstance('Horde_View');
        $this->_view->addTemplatePath(ANSEL_TEMPLATES . '/view');
        $this->_view->sortBy = !empty($this->_params['sort']) ?
           $this->_params['sort'] :
           'name';
        $this->_view->sortDir = isset($this->_params['sort_dir']) ?
           $this->_params['sort_dir'] :
           0;

        // Check for grouping.
        if (empty($this->_params['groupby'])) {
            $this->_view->groupby = Horde_Util::getFormData(
              'groupby',
              $prefs->getValue('groupby'));
        } else {
            $this->_view->groupby = $this->_params['groupby'];
        }
        $this->_view->gPerPage = $prefs->getValue('tilesperpage');

        // Listing a single user?
        if (empty($this->_params['owner'])) {
            $this->_owner = Horde_Util::getFormData('owner');
            $this->_owner = empty($this->_owner) ? null : $this->_owner;
        } else {
            $this->_owner = $this->_params['owner'];
        }

        // Special?
        $this->_special = Horde_Util::getFormData('special');
        if (!$this->_owner && !$this->_special && $this->_view->groupby != 'none' ) {
            Ansel::getUrlFor(
              'group',
              array('groupby' => $this->_view->groupby)
            )->redirect();
            exit;
        }

        // If we aren't supplied with a page number, default to page 0.
        if (isset($this->_params['page'])) {
            $this->_page = $this->_params['page'];
        } else {
            $this->_page = Horde_Util::getFormData('page', 0);
        }

        // If we are calling from the api, we can just pass a list of ids
        if (!empty($this->_params['api']) && is_array($this->_params['gallery_ids'])) {
            $this->_view->start = $this->_page * $this->_view->gPerPage;
            $this->_view->numGalleries = count($this->_params['gallery_ids']);
            if ($this->_view->numGalleries > $this->_view->start) {
                $getThese = array_slice(
                    $this->_params['gallery_ids'],
                    $this->_view->start,
                    $this->_view->gPerPage);
                $this->_view->galleryList = $ansel_storage->getGalleries($getThese);
            } else {
                $this->_view->galleryList = array();
            }
        } else {
            // Set list filter/title
            $filter = array();
            if (!is_null($this->_owner)) {
                $filter['owner'] = $this->_owner;
            }

            $this->_view->numGalleries = $ansel_storage->countGalleries(
                $registry->getAuth(),
                array('attributes' => $filter,
                      'all_levels' => false,
                      'tags' => !empty($params['tags']) ? $params['tags'] : null));

            if ($this->_view->numGalleries == 0 && empty($this->_params['api'])) {
                if ($this->_owner && $this->_owner == $registry->getAuth()) {

                    $notification->push(_("You have no photo galleries, add one!"), 'horde.message');
                    Horde::url('gallery.php')->add('actionID', 'add')->redirect();
                    exit;
                }
                $notification->push(_("There are no photo galleries available."), 'horde.message');
                $this->_view->galleryList = array();
            } else {
                $this->_view->galleryList = $ansel_storage->listGalleries(
                    array('attributes' => $filter,
                          'all_levels' => false,
                          'from' => $this->_page * $this->_view->gPerPage,
                          'count' => $this->_view->gPerPage,
                          'sort_by' => $this->_view->sortBy,
                          'direction' => $this->_view->sortDir,
                          'tags' => !empty($params['tags']) ? $params['tags'] : null));
            }
        }
    }

    /**
     * Get this view's title.
     *
     * @return string  The gallery's title.
     */
    public function getTitle()
    {
        if ($this->_owner) {
            if ($this->_owner == $GLOBALS['registry']->getAuth() &&
                empty($this->_params['api'])) {

                return  _("My Galleries");
            } elseif (!empty($GLOBALS['conf']['gallery']['customlabel'])) {
                $uprefs = $GLOBALS['injector']
                  ->getInstance('Horde_Core_Factory_Prefs')
                  ->create('ansel', array(
                      'cache' => false,
                      'owner' => $this->_owner));
                $fullname = $uprefs->getValue('grouptitle');
                if (!$fullname) {
                    $identity = $GLOBALS['injector']
                        ->getInstance('Horde_Core_Factory_Identity')
                        ->create($this->_owner);
                    $fullname = $identity->getValue('fullname');
                    if (!$fullname) {
                        $fullname = $this->_owner;
                    }
                    return sprintf(_("%s's Galleries"), $fullname);
                } else {
                    return $fullname;
                }
            } else {
                return sprintf(_("%s's Galleries"), $this->_owner);
            }
        } else {
            return _("Gallery List");
        }
    }

    /**
     * Return the HTML representing this view.
     *
     * @return string  The HTML.
     *
     */
    public function html()
    {
        global $conf, $prefs, $registry;

        $vars = Horde_Variables::getDefaultVariables();
        if (!empty($this->_params['page'])) {
            $vars->add('page', $this->_params['page']);
        }

        if (!empty($this->_params['pager_url'])) {
            $this->_pagerurl = $this->_params['pager_url'];
            $override = true;
        } else {
            $override = false;
            $this->_pagerurl = Ansel::getUrlFor(
              'view',
               array(
                 'owner' => $this->_owner,
                 'special' => $this->_special,
                 'groupby' => $this->_view->groupby,
                 'view' => 'List'));
        }
        $p_params = array('num' => $this->_view->numGalleries,
                          'url' => $this->_pagerurl,
                          'perpage' => $this->_view->gPerPage);

        if ($override) {
            $p_params['url_callback'] = null;
        }
        $this->_pager = new Horde_Core_Ui_Pager('page', $vars, $p_params);
        $preserve = array('sort_dir' => $this->_view->sortDir);
        if (!empty($this->_view->sortBy)) {
            $preserve['sort'] = $this->_view->sortBy;
        }
        $this->_pager->preserve($preserve);

        if ($this->_view->numGalleries) {
            $min = $this->_page * $this->_view->gPerPage;
            $max = $min + $this->_view->gPerPage;
            if ($max > $this->_view->numGalleries) {
                $max = $this->_view->numGalleries - $min;
            }
            $this->_view->start = $min + 1;
            $this->_view->end = min($this->_view->numGalleries, $min + $this->_view->gPerPage);

            if ($this->_owner) {
                $this->_view->refresh_link = Ansel::getUrlFor(
                  'view',
                   array(
                     'groupby' => $this->_view->groupby,
                     'owner' => $this->_owner,
                     'page' => $this->_page,
                     'view' => 'List'));
            } else {
                $this->_view->refresh_link = Ansel::getUrlFor(
                  'view',
                  array(
                    'view' => 'List',
                    'groupby' => $this->_view->groupby,
                    'page' => $this->_page));
            }

            // Get top-level / default gallery style.
            if (empty($this->_params['style'])) {
                $style = Ansel::getStyleDefinition($prefs->getValue('default_gallerystyle'));
            } else {
                $style = Ansel::getStyleDefinition($this->_params['style']);
            }

            // Final touches.
            if (empty($this->_params['api'])) {
                $this->_view->breadcrumbs = Ansel::getBreadcrumbs();
                $this->_view->groupbyUrl = strval(Ansel::getUrlFor('group', array('actionID' => 'groupby', 'groupby' => 'owner')));
            }
            $this->_view->pager = $this->_pager->render();
            $this->_view->style = $style;
            $this->_view->tilesperrow = $prefs->getValue('tilesperrow');
            $this->_view->cellwidth = round(100 / $this->_view->tilesperrow);
            $this->_view->params = $this->_params;

            $GLOBALS['page_output']->addScriptFile('views/common.js');
            return $this->_view->render('list');
        }

        return '&nbsp;';
    }

    public function viewType()
    {
        return 'List';
    }

    /**
     * noop
     *
     * @see ansel/lib/View/Ansel_View_Base#getGalleryCrumbData()
     */
    public function getGalleryCrumbData()
    {
        throw new Ansel_Exception('Ansel_View_List::getGalleryCrumbData not implemented.');
    }

}